⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 profile.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
			else
				sprintf(psString, "   ");
			break;
		case 2:
			if(psTemp->ui32IgnoredEnables & ui32Bit)
				sprintf(psString, " x ");
			else
				sprintf(psString, "   ");
			break;
		case 3:
			if(psTemp->ui32FrameEnables & ui32Bit)
				sprintf(psString, " x ");
			else
				sprintf(psString, "   ");
			break;
		}
		GLESProfileOutput(gc, psString);
	}

	GLESProfileOutput(gc, "\n");

}

/***********************************************************************************
 Function Name      : DisplayStateMetricTable
 Inputs             : -
 Outputs            : -
 Returns            : -
 Description        : Displays the state table (link list) 
************************************************************************************/
IMG_VOID DisplayStateMetricTable(GLESContext *gc)
{
	IMG_UINT32 ui32CumulativeRasterEnables = 0;
	IMG_UINT32 ui32CumulativeTnLEnables = 0;
	IMG_UINT32 ui32CumulativeIgnoredEnables = 0;
	IMG_UINT32 ui32CumulativeFrameEnables = 0;
	StateMetricData *psTemp;
	IMG_UINT32 i;
	IMG_UINT32 ui32NumberStates = 0;
	IMG_CHAR psString[256];

	psTemp = gc->psStateMetricData;

	/* First get information about all the enables in all the states, and those will
	be our head rows of the table */

	while(psTemp)
	{
		ui32CumulativeRasterEnables |= psTemp->ui32RasterEnables;
		ui32CumulativeTnLEnables	|= psTemp->ui32TnLEnables;
		ui32CumulativeIgnoredEnables|= psTemp->ui32IgnoredEnables;
		ui32CumulativeFrameEnables	|= psTemp->ui32FrameEnables;
		psTemp = psTemp->next;
		ui32NumberStates++;
	}

	/* print the head of the table */

	GLESProfileOutput(gc, "State combinations used in rendering\n\n");

	sprintf(psString, "State       ");
	GLESProfileOutput(gc, psString);
	for(i=0; i<ui32NumberStates; i++)
	{
		sprintf(psString, " %lu ", i);
		GLESProfileOutput(gc, psString);
	}
	GLESProfileOutput(gc, "\n");

	/* start with raster enables */
	for(i=0; i<9; i++)
	{
		IMG_UINT32 ui32Index = 1 << i;

		if(ui32CumulativeRasterEnables & ui32Index)
		{
			PrintMetricStateRow(gc, RasterEnables[i], 0, ui32Index, ui32NumberStates);
		}
	}

	/* display the TnL enables */
	for(i=0; i<12; i++)
	{
		IMG_UINT32 ui32Index = 1 << i;

		if(ui32CumulativeTnLEnables & ui32Index)
		{
			PrintMetricStateRow(gc, TnLEnables[i], 1, ui32Index, ui32NumberStates);
		}
	}

	/* display the ignore enables */
	for(i=0; i<12; i++)
	{
		IMG_UINT32 ui32Index = 1 << i;

		if(ui32CumulativeIgnoredEnables & ui32Index)
		{
			PrintMetricStateRow(gc, IgnoreEnables[i], 2, ui32Index, ui32NumberStates);
		}
	}

	/* display the full screen enables */
	for(i=0; i<3; i++)
	{
		IMG_UINT32 ui32Index = 1 << i;

		if(ui32CumulativeFrameEnables & ui32Index)
		{
			PrintMetricStateRow(gc, FrameEnables[i], 3, ui32Index, ui32NumberStates);
		}
	}

	/* now output each state how many times has been used */
	GLESProfileOutput(gc, "\n");

	GLESProfileOutput(gc, "State       ");
	for(i=0; i<ui32NumberStates; i++)
	{
		sprintf(psString, " %6lu ", i);
		GLESProfileOutput(gc, psString);
	}
	GLESProfileOutput(gc, "\n");

	GLESProfileOutput(gc, "Usage Count ");
	psTemp = gc->psStateMetricData;
	while(psTemp)
	{
		sprintf(psString, " %6lu ", psTemp->ui32Count);
		GLESProfileOutput(gc, psString);
		psTemp = psTemp->next;
	}

	GLESProfileOutput(gc, "\n");
}


/***********************************************************************************
 Function Name      : DestroyStateMetricData
 Inputs             : -
 Outputs            : -
 Returns            : -
 Description        : Destroys the state table (link list) 
************************************************************************************/
IMG_VOID DestroyStateMetricData(GLESContext *gc)
{
	StateMetricData *psTemp, *psTemp1;

	psTemp = gc->psStateMetricData;

	while(psTemp)
	{
		psTemp1 = psTemp->next;
		GLESFree(gc, psTemp);
		psTemp = psTemp1;
	}
}

/***********************************************************************************
 Function Name      : DisplayRedundantCallInfo
 Inputs             : -
 Outputs            : -
 Returns            : -
 Description        : Destroys the redundant call table 
************************************************************************************/
IMG_VOID DisplayRedundantCallInfo(GLESContext *gc)
{
	IMG_UINT32 i;
	IMG_BOOL bRedundantInfoPresent = IMG_FALSE;
	IMG_CHAR psString[256];

	for(i=0; i<9; i++)
	{
		if(gc->RedundantStatesRaster[i])
		{
			bRedundantInfoPresent = IMG_TRUE;
		}
	}
	for(i=0; i<12; i++)
	{
		if(gc->RedundantStatesTnL[i])
		{
			bRedundantInfoPresent = IMG_TRUE;
		}
	}
	for(i=0; i<3; i++)
	{
		if(gc->RedundantStatesFrame[i])
		{
			bRedundantInfoPresent = IMG_TRUE;
		}
	}
	for(i=0; i<7; i++)
	{
		if(gc->RedundantStatesIgnore[i])
		{
			bRedundantInfoPresent = IMG_TRUE;
		}
	}

	/*first see if there is any redundant information to display */
	if(bRedundantInfoPresent)
	{
		GLESProfileOutput(gc, "\n");
		GLESProfileOutput(gc, "Redundant State Table \n\n");
		GLESProfileOutput(gc, "State        Number Total Number/Frame\n");
		for(i=0; i<9; i++)
		{
			if(gc->RedundantStatesRaster[i])
			{
				sprintf(psString, "%s %13lu %7.4f\n",
					RasterEnables[i], 
					gc->RedundantStatesRaster[i],
					gc->RedundantStatesRaster[i]/(IMG_FLOAT)gc->asTimes[GLES_TIMER_FLUSH_HW_TIME].ui32Count);
				GLESProfileOutput(gc, psString);
			}
		}
		for(i=0; i<12; i++)
		{
			if(gc->RedundantStatesTnL[i])
			{
				sprintf(psString, "%s %13lu %7.4f\n",
					TnLEnables[i], 
					gc->RedundantStatesTnL[i],
					gc->RedundantStatesTnL[i]/(IMG_FLOAT)gc->asTimes[GLES_TIMER_FLUSH_HW_TIME].ui32Count);
				GLESProfileOutput(gc, psString);
			}
		}
		for(i=0; i<3; i++)
		{
			if(gc->RedundantStatesFrame[i])
			{
				sprintf(psString, "%s %13lu %7.4f\n",
					FrameEnables[i], 
					gc->RedundantStatesFrame[i],
					gc->RedundantStatesFrame[i]/(IMG_FLOAT)gc->asTimes[GLES_TIMER_FLUSH_HW_TIME].ui32Count);
				GLESProfileOutput(gc, psString);
			}
		}
		for(i=0; i<7; i++)
		{
			if(gc->RedundantStatesIgnore[i])
			{
				sprintf(psString, "%s %13lu %7.4f\n",
					IgnoreEnables[i], 
					gc->RedundantStatesIgnore[i],
					gc->RedundantStatesIgnore[i]/(IMG_FLOAT)gc->asTimes[GLES_TIMER_FLUSH_HW_TIME].ui32Count);
				GLESProfileOutput(gc, psString);
			}
		}
	}

}

/***********************************************************************************
 Function Name      : ProfileOutputTotals
 Inputs             : -
 Outputs            : -
 Returns            : -
 Description        : Displays profiling data
************************************************************************************/
IMG_VOID ProfileOutputTotals(GLESContext *gc)
{
	IMG_UINT32 i,j;
	IMG_CHAR psString[256];
	IMG_BOOL bFound;


	/* if there has been no frame do not output profile data */
	if(GLES_CALLS(GLES_TIMES_SWAP_BUFFERS) == 0)
		return;


	GLESInitProfileOutput(gc);

	GLESProfileOutput(gc, "Profiling (per context)\n");
	GLESProfileOutput(gc, "=======================\n");


	GLESProfileOutput(gc, "\n");
	GLESProfileOutput(gc, "Draw calls profiling\n\n");
	/* Output draw calls statistics */
	for(j=DRAW_ARRAYS; j<DRAW_ELEMENTS+1; j++)
	{
		bFound = IMG_FALSE;
		/* first see if there has been any call of this type done */
		for(i=GL_POINTS; i<GL_TRIANGLE_FAN+1; i++)
		{
			if(gc->sDrawCall[j].CallCount[i])
			{
				bFound = IMG_TRUE;
			}
		}
		if(bFound)
		{
			sprintf(psString, "%s Vertices    Calls    Vertices/Frame    Calls/Frame\n", DrawFunctionNames[j]);
			GLESProfileOutput(gc, psString);
			for(i=GL_POINTS; i<GL_TRIANGLE_FAN+1; i++)
			{
				if(gc->sDrawCall[j].CallCount[i])
				{
					DecodePrimitiveCall(gc, j, i);
				}
			}
		}
	}	

	GLESProfileOutput(gc, "\n");
	GLESProfileOutput(gc, "Entry point profiling (Times in uSx10)\n\n");
	/* Output entry point statistics */
	GLESProfileOutput(gc, "Call                       Number Calls  Time/Call  Calls/Frame  Time/Frame\n");
	for(i=GLES_TIMES_glActiveTexture; i<GLES_TIMES_glViewport+1; i++)
	{
		/* at least 1 call of this type has been done */
		if(gc->asTimes[i].ui32Count)
		{
#define BROKEN_FLOAT_PRINTF 1
#ifdef BROKEN_FLOAT_PRINTF
			sprintf(psString, "%s  %12lu  %8d  %12lu  %8d\n",
				FunctionNames[i - GLES_TIMES_glActiveTexture],
				GLES_CALLS(i),
				(int)(10000.0f*GLES_TIME_PER_CALL(i)),
				GLES_METRIC_PER_FRAME_SB(i),
				(int)(10000.0f*GLES_TIME_PER_FRAME_SB(i)));
#else
			sprintf(psString, "%s  %12lu  %2.6f  %12lu  %2.6f\n",
				FunctionNames[i - GLES_TIMES_glActiveTexture],
				GLES_CALLS(i),
				GLES_TIME_PER_CALL(i),
				GLES_METRIC_PER_FRAME_SB(i),
				GLES_TIME_PER_FRAME_SB(i));
#endif
			GLESProfileOutput(gc, psString);
		}
	}

	GLESProfileOutput(gc, "\n\n");

	/* output the state table */
	DisplayStateMetricTable(gc);

	DestroyStateMetricData(gc);

	/* output the redundant calls information */

	DisplayRedundantCallInfo(gc);

	GLESDeInitProfileOutput(gc);
}

#endif /* defined (TIMING) || defined (DEBUG) */

/**************************************************************************
 End of file (profile.c)
**************************************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -