Updated com_showfps to show additional stats.

This commit is contained in:
Justin Marshall
2026-05-21 22:41:49 -07:00
parent 7b60a99f96
commit e8ea0567b0
5 changed files with 94 additions and 6 deletions
+35 -3
View File
@@ -32,6 +32,9 @@ If you have questions concerning this license or the applicable additional terms
void SCR_DrawTextLeftAlign( float &y, const char *text, ... ) id_attribute((format(printf,2,3)));
void SCR_DrawTextRightAlign( float &y, const char *text, ... ) id_attribute((format(printf,2,3)));
extern int QD3D12_GetActiveFrameGenerationMultiplier( void );
extern const char *QD3D12_GetAdapterName( void );
extern int QD3D12_GetVideoMemoryInfo( uint64_t *usageBytes, uint64_t *budgetBytes, uint64_t *dedicatedBytes );
extern glconfig_t glConfig;
#define LINE_WIDTH 78
#define NUM_CON_TIMES 4
@@ -189,6 +192,15 @@ static const idVec4 &SCR_FrameTimeColor( int msec ) {
return colorRed;
}
static void SCR_DrawSmallStringRightAlign( float y, const idVec4 &color, const char *text ) {
const int w = strlen( text ) * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( ( SCREEN_WIDTH - 5.0f ) - w, idMath::FtoiFast( y ) + 2, text, color, true, localConsole.charSetShader );
}
static uint64_t SCR_BytesToMiB( uint64_t bytes ) {
return ( bytes + ( 1024 * 1024 / 2 ) ) / ( 1024 * 1024 );
}
float SCR_DrawFPS( float y ) {
char *s;
int w;
@@ -237,9 +249,29 @@ float SCR_DrawFPS( float y ) {
y += BIGCHAR_HEIGHT + 4;
s = va( "game cpu:%4.1fms render cpu:%4.1fms pt gpu:%4.1fms", com_lastGameFrameMsec, com_lastRenderFrameMsec, com_pathTracingGpuMsec );
w = strlen( s ) * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( (SCREEN_WIDTH - 5.0f) - w, idMath::FtoiFast(y) + 2, s, frameColor, true, localConsole.charSetShader);
return y + SMALLCHAR_HEIGHT + 4;
SCR_DrawSmallStringRightAlign( y, frameColor, s );
y += SMALLCHAR_HEIGHT + 4;
uint64_t vramUsage = 0;
uint64_t vramBudget = 0;
uint64_t vramDedicated = 0;
if ( QD3D12_GetVideoMemoryInfo( &vramUsage, &vramBudget, &vramDedicated ) && vramBudget > 0 ) {
s = va( "VRAM: %llu/%llu MB GPU VRAM: %llu MB", (unsigned long long)SCR_BytesToMiB( vramUsage ), (unsigned long long)SCR_BytesToMiB( vramBudget ), (unsigned long long)SCR_BytesToMiB( vramDedicated ) );
SCR_DrawSmallStringRightAlign( y, frameColor, s );
y += SMALLCHAR_HEIGHT + 4;
}
const char *gpuName = QD3D12_GetAdapterName();
if ( !gpuName || !gpuName[0] ) {
gpuName = glConfig.renderer_string;
}
if ( gpuName && gpuName[0] ) {
s = va( "GPU: %s", gpuName );
SCR_DrawSmallStringRightAlign( y, frameColor, s );
y += SMALLCHAR_HEIGHT + 4;
}
return y;
}
return y + BIGCHAR_HEIGHT + 4;