📄 cmaterialsystemstats.cpp
字号:
// returns timed stats
//-----------------------------------------------------------------------------
double CMaterialSystemStatsDX8::TimedStatInFrame( int /*MaterialSystemTimedStatId_t*/ stat ) const
{
return m_StatGroup[m_CurrentStatGroup].m_StatFrameTime[stat];
}
double CMaterialSystemStatsDX8::TotalTimedStat( int /*MaterialSystemTimedStatId_t*/ stat ) const
{
return m_StatGroup[m_CurrentStatGroup].m_TotalStatTime[stat];
}
//-----------------------------------------------------------------------------
// This method is called when it's time to draw the stats
//-----------------------------------------------------------------------------
void CMaterialSystemStatsDX8::DisplayStats( IClientStatsTextDisplay* pDisplay, int category)
{
float oneOverOneMeg = 1.0 / ( 1024.0 * 1024.0 );
// fixme: doesn't take procedural textures into account?
unsigned char r, g, b;
r = 255;
g = 255;
b = 255;
pDisplay->SetDrawColor( r, g, b );
if( category == 1 )
{
SetStatGroup( MATERIAL_SYSTEM_STATS_TOTAL );
float totalMegatexels = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_TEXELS);
float totalMegabytes = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_BYTES);
// int totalNumTextures = CountedStatInFrame( MATERIAL_SYSTEM_STATS_NUM_UNIQUE_TEXTURES );
float megabytesNewThisFrame = oneOverOneMeg * CountedStatInFrame( MATERIAL_SYSTEM_STATS_TEXTURE_BYTES_NEW_THIS_FRAME );
pDisplay->DrawStatsText( "\n" );
float maxMegabytes = ( float )ShaderUtil()->GetConfig().m_MaxTextureMemory;
pDisplay->SetDrawColorFromStatValues( (float)maxMegabytes, totalMegabytes );
pDisplay->DrawStatsText( " total textures/frame: actual/max: %.1f/%.1fMB (%.1f MTexels)\n",
totalMegabytes, maxMegabytes, totalMegatexels );
pDisplay->SetDrawColorFromStatValues(
(float)( float )ShaderUtil()->GetConfig().m_NewTextureMemoryPerFrame,
megabytesNewThisFrame );
pDisplay->DrawStatsText( " total new textures/frame: actual/max: %.1f/%.1fMB\n",
megabytesNewThisFrame, ( float )ShaderUtil()->GetConfig().m_NewTextureMemoryPerFrame );
pDisplay->SetDrawColor( r, g, b );
pDisplay->DrawStatsText( "\n" );
// HACK HACK: This really shouldn't be in here.
pDisplay->DrawStatsText( " depth complexity:\n" );
pDisplay->DrawStatsText( "\n" );
pDisplay->DrawStatsText( " physics interactions:\n" );
pDisplay->DrawStatsText( "\n" );
pDisplay->DrawStatsText( "GLOBAL BUDGETS:\n" );
float allocatedMegabytes = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_TEXTURE_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxTextureMemory, allocatedMegabytes );
pDisplay->DrawStatsText( " total texture memory: actual/max: %.1f/%.1fMB\n",
allocatedMegabytes,
( float )ShaderUtil()->GetConfig().m_MaxTextureMemory );
float lightmapMegabytes = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_LIGHTMAP_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxLightmapMemory, lightmapMegabytes );
pDisplay->DrawStatsText( " total lightmap memory: actual/max: %.1f/%.1fMB\n",
lightmapMegabytes,
( float )ShaderUtil()->GetConfig().m_MaxLightmapMemory );
float allocatedModels = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_MODEL_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxModelMemory, allocatedModels );
pDisplay->DrawStatsText( " total model memory: actual/max: %.1f/%.1fMB\n",
( float )allocatedModels,
( float )ShaderUtil()->GetConfig().m_MaxModelMemory );
}
if( category != 8 && category > 1 )
{
SetStatGroup( MATERIAL_SYSTEM_STATS_WORLD );
float worldMegatexels = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_TEXELS);
float worldMegabytes = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_BYTES);
SetStatGroup( MATERIAL_SYSTEM_STATS_OTHER );
float otherMegatexels = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_TEXELS);
float otherMegabytes = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_BYTES);
// float lightmapMegatexels = oneOverOneMeg * GetUniqueLightmapTexelsInFrame();
SetStatGroup( MATERIAL_SYSTEM_STATS_WORLD );
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxWorldMegabytes, worldMegabytes );
pDisplay->DrawStatsText( "%0.1f/%d megabytes/frame world textures (%0.1f megatexels)\n",
worldMegabytes /* + lightmapMegatexels*/,
ShaderUtil()->GetConfig().m_MaxWorldMegabytes, worldMegatexels );
// pDisplay->DrawStatsText( m_pFont, x, y, r, g, b, a, " %0.1f megatexels/frame lightmaps\n",
// lightmapMegatexels );
SetStatGroup( MATERIAL_SYSTEM_STATS_OTHER );
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxOtherMegabytes, otherMegabytes );
pDisplay->DrawStatsText( "%0.1f/%d megabytes/frame other textures (%0.1f megatexels)\n",
otherMegabytes,
ShaderUtil()->GetConfig().m_MaxOtherMegabytes, otherMegatexels );
SetStatGroup( MATERIAL_SYSTEM_STATS_TOTAL );
float allocatedModels = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_MODEL_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxModelMemory, allocatedModels );
pDisplay->DrawStatsText( "%0.1f/%d total model memory allocated (megabytes)\n",
allocatedModels,
ShaderUtil()->GetConfig().m_MaxModelMemory );
float allocatedMegabytes = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_TEXTURE_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxTextureMemory, allocatedMegabytes );
pDisplay->DrawStatsText( "%0.1f/%d total texture memory allocated (megabytes)\n",
allocatedMegabytes,
ShaderUtil()->GetConfig().m_MaxTextureMemory );
float lightmapMegabytes = oneOverOneMeg * TotalCountedStat(MATERIAL_SYSTEM_STATS_LIGHTMAP_BYTES_ALLOCATED);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_MaxLightmapMemory, lightmapMegabytes );
pDisplay->DrawStatsText( "%0.1f/%d total lightmap memory allocated (megabytes)\n",
lightmapMegabytes,
ShaderUtil()->GetConfig().m_MaxLightmapMemory );
float newMegabytes = oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_BYTES_NEW_THIS_FRAME);
pDisplay->SetDrawColorFromStatValues( (float)ShaderUtil()->GetConfig().m_NewTextureMemoryPerFrame, newMegabytes );
pDisplay->DrawStatsText( "%0.1f/%d new textures this frame (megabytes)\n",
newMegabytes,
ShaderUtil()->GetConfig().m_NewTextureMemoryPerFrame );
int screenWidth, screenHeight;
ShaderAPI()->GetWindowSize( screenWidth, screenHeight );
int numScreenPixels = screenWidth * screenHeight;
float depthComplexity = (float)CountedStatInFrame(MATERIAL_SYSTEM_STATS_FILL_RATE) /
(float)numScreenPixels;
pDisplay->SetDrawColorFromStatValues( ShaderUtil()->GetConfig().m_MaxDepthComplexity, depthComplexity );
pDisplay->DrawStatsText( "%.2f depth complexity (%d pixels rendered)\n",
depthComplexity,
CountedStatInFrame(MATERIAL_SYSTEM_STATS_FILL_RATE) );
pDisplay->DrawStatsText( "%d pixel shader creates/frame\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_PIXEL_SHADER_CREATES) );
pDisplay->DrawStatsText( "%d vertex shader creates/frame\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_VERTEX_SHADER_CREATES) );
}
if( category == 3 )
{
pDisplay->DrawStatsText( "%0.3f megabytes/frame cache misses\n",
oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_BYTES_DOWNLOADED) );
pDisplay->DrawStatsText( "%0.3f megatexels/frame cache misses\n",
oneOverOneMeg * CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_TEXELS_DOWNLOADED) );
pDisplay->DrawStatsText( "%d cache misses/frame\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_UPLOADS) );
pDisplay->DrawStatsText( "%d texture binds/frame (%d unique)\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_STATE),
CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_UNIQUE_TEXTURES) );
}
else if( category > 1 )
{
pDisplay->DrawStatsText( "%d cache misses/frame\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_TEXTURE_UPLOADS) );
}
pDisplay->DrawStatsText( "\n" );
if( category == 3 )
{
pDisplay->SetDrawColor( 255, 0, 0 );
/*
pDisplay->DrawStatsText( "%.2f ambient lock\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_AMBIENT_LOCK) );
pDisplay->DrawStatsText( "%.2f set render state\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_SET_RENDER_STATE) );
pDisplay->DrawStatsText( "%.2f flush\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_UPDATE_FLUSH) );
pDisplay->DrawStatsText( "%.2f copy\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_TRANSFORM_COPY) );
pDisplay->DrawStatsText( "%.2f set transform\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_SET_TRANSFORM) );
*/
pDisplay->DrawStatsText( "%.2f draw indexed primitive\n",
1000.0f * TimedStatInFrame(MATERIAL_SYSTEM_STATS_DRAW_INDEXED_PRIMITIVE) );
pDisplay->SetDrawColor( r, g, b );
pDisplay->DrawStatsText( "%d shadow state changes\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_SHADOW_STATE) );
pDisplay->DrawStatsText( "%d dynamic state changes\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_DYNAMIC_STATE) );
pDisplay->DrawStatsText( "%d primitives drawn %0.3f ave primitive buffer size\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_PRIMITIVES),
(float)CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_PRIMITIVES) /
(float)CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_INDEX_PRIMITIVE_CALLS)
);
pDisplay->DrawStatsText( "%.2f render pass time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_RENDER_PASS_TIME) * 1000.0f );
pDisplay->DrawStatsText( "%.2f vertex copy time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_VERTEX_COPY_TIME) * 1000.0f );
pDisplay->DrawStatsText( "%.2f mesh build (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_MESH_BUILD_TIME) * 1000.0f );
pDisplay->DrawStatsText( "%.2f ambient cube build (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_AMBIENT_CUBE_TIME) * 1000.0f );
pDisplay->DrawStatsText( "%d # of vertex + index buffer locks\n",
CountedStatInFrame(MATERIAL_SYSTEM_STATS_NUM_BUFFER_LOCK) );
pDisplay->DrawStatsText( "%.2f vertex + index buffer lock (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_BUFFER_LOCK_TIME) * 1000.0f );
pDisplay->DrawStatsText( "%.2f vertex + index buffer unlock (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_BUFFER_UNLOCK_TIME) * 1000.0f );
pDisplay->DrawStatsText( "\n" );
}
if( category == 8 )
{
r = g = b = 128;
pDisplay->DrawStatsText( "%.2f ForceHardwareSync (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_FLUSH_HARDWARE) * 1000.0f );
pDisplay->DrawStatsText( "%.2f render state (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_SET_RENDER_STATE) * 1000.0f );
pDisplay->DrawStatsText( "%.2f draw mesh time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_DRAW_MESH) * 1000.0f );
pDisplay->DrawStatsText( " %.2f commit time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_COMMIT_STATE_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f commit view time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_COMMIT_VIEW_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f commit viewmodel time (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_COMMIT_VIEWMODEL_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f commit transform (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_COMMIT_TRANSFORMS_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f vertex shader constants (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_VERTEX_SHADER_CONSTANT_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f begin pass (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_BEGIN_PASS) * 1000.0f );
pDisplay->DrawStatsText( " %.2f set vertex shader (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_SET_VERTEX_SHADER) * 1000.0f );
pDisplay->DrawStatsText( " %.2f set pixel shader (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_SET_PIXEL_SHADER) * 1000.0f );
pDisplay->DrawStatsText( " %.2f update matrix (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_UPDATE_MATRIX_TRANSFORM) * 1000.0f );
pDisplay->DrawStatsText( " %.2f test 1 (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_TEST1) * 1000.0f );
pDisplay->DrawStatsText( " %.2f update matrix2 (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_TEST2) * 1000.0f );
pDisplay->DrawStatsText( " %.2f update matrix3 (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_TEST3) * 1000.0f );
pDisplay->DrawStatsText( " %.2f update matrix4 (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_TEST4) * 1000.0f );
pDisplay->DrawStatsText( " %.2f update matrix5 (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_TEST5) * 1000.0f );
pDisplay->DrawStatsText( " %.2f fog (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_FOG_MODE) * 1000.0f );
pDisplay->DrawStatsText( " %.2f render pass (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_RENDER_PASS_TIME) * 1000.0f );
pDisplay->DrawStatsText( " %.2f draw indexed (ms)\n",
TimedStatInFrame(MATERIAL_SYSTEM_STATS_DRAW_INDEXED_PRIMITIVE) * 1000.0f );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -