Show masked occlusion time with com_showFPS 3

This commit is contained in:
Robert Beckebans 2024-08-28 21:43:19 +02:00
parent 529beb5095
commit 09224febca
8 changed files with 26 additions and 66 deletions

View file

@ -896,11 +896,11 @@ void idCommonLocal::RenderSplash()
renderSystem->SetColor4( 1, 1, 1, 1 );
renderSystem->DrawStretchPic( barWidth, barHeight, renderSystem->GetVirtualWidth() - barWidth * 2.0f, renderSystem->GetVirtualHeight() - barHeight * 2.0f, 0, 0, 1, 1, splashScreen );
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_moc, &time_gpu, &stats_backend, &stats_frontend );
renderSystem->RenderCommandBuffers( cmd );
// RB: this is the same as Doom 3 renderSystem->EndFrame()
//renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu );
//renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_moc, &time_gpu );
}
/*
@ -933,7 +933,7 @@ void idCommonLocal::RenderBink( const char* path )
while( ( Sys_Milliseconds() <= ( material->GetCinematicStartTime() + cinematicLength ) ) && material->CinematicIsPlaying() )
{
renderSystem->DrawStretchPic( chop, 0, imageWidth, renderSystem->GetVirtualHeight(), 0, 0, 1, 1, material );
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_moc, &time_gpu, &stats_backend, &stats_frontend );
renderSystem->RenderCommandBuffers( cmd );
Sys_GenerateEvents();

View file

@ -306,9 +306,9 @@ public:
return time_backend;
}
uint64 GetRendererShadowsMicroseconds() const
uint64 GetRendererMaskedOcclusionRasterizationMicroseconds() const
{
return time_shadows;
return time_moc;
}
uint64 GetRendererIdleMicroseconds() const
@ -642,7 +642,7 @@ private:
int time_gameDraw; // game present time
uint64 time_frontend; // renderer frontend time
uint64 time_backend; // renderer backend time
uint64 time_shadows; // renderer backend waiting for shadow volumes to be created
uint64 time_moc; // renderer frontend masked software rasterization time
uint64 time_gpu; // total gpu time, at least for PC
// RB: r_speeds counters

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2017-2024 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -297,7 +298,7 @@ float idConsoleLocal::DrawFPS( float y )
const uint64 gameThreadRenderTime = commonLocal.mainFrameTiming.finishDrawTime - commonLocal.mainFrameTiming.finishGameTime;
const uint64 rendererBackEndTime = commonLocal.GetRendererBackEndMicroseconds();
const uint64 rendererShadowsTime = commonLocal.GetRendererShadowsMicroseconds();
const uint64 rendererMaskedOcclusionCullingTime = commonLocal.GetRendererMaskedOcclusionRasterizationMicroseconds();
const uint64 rendererGPUTime = commonLocal.GetRendererGPUMicroseconds();
const uint64 rendererGPUEarlyZTime = commonLocal.GetRendererGpuBeginDrawingMicroseconds() + commonLocal.GetRendererGpuEarlyZMicroseconds() + commonLocal.GetRendererGpuGeometryMicroseconds();
const uint64 rendererGPU_SSAOTime = commonLocal.GetRendererGpuSSAOMicroseconds();
@ -338,8 +339,6 @@ float idConsoleLocal::DrawFPS( float y )
previousCpuUsage[( index - 1 ) % FPS_FRAMES] = float( rendererCPUBusyTime ) / float( frameBusyTime + frameIdleTime ) * 100.0;
previousGpuUsage[( index - 1 ) % FPS_FRAMES] = float( rendererGPUTime ) / float( rendererGPUTime + rendererGPUIdleTime ) * 100.0;
#if 1
// RB: use ImGui to show more detailed stats about the scene loads
if( ImGuiHook::IsReadyToRender() )
{
@ -546,7 +545,7 @@ float idConsoleLocal::DrawFPS( float y )
ImGui::TextColored( gameThreadGameTime > maxTime ? colorRed : colorWhite, "Game: %5llu us SSAO: %5llu us", gameThreadGameTime, rendererGPU_SSAOTime );
ImGui::TextColored( gameThreadRenderTime > maxTime ? colorRed : colorWhite, "RF: %5llu us SSR: %5llu us", gameThreadRenderTime, rendererGPU_SSRTime );
ImGui::TextColored( rendererBackEndTime > maxTime ? colorRed : colorWhite, "RB: %5llu us Ambient Pass: %5llu us", rendererBackEndTime, rendererGPUAmbientPassTime );
ImGui::TextColored( rendererGPUShadowAtlasTime > maxTime ? colorRed : colorWhite, "Shadows: %5llu us Shadow Atlas: %5llu us", rendererShadowsTime, rendererGPUShadowAtlasTime );
ImGui::TextColored( rendererMaskedOcclusionCullingTime > maxTime ? colorRed : colorWhite, "MOC: %5llu us Shadow Atlas: %5llu us", rendererMaskedOcclusionCullingTime, rendererGPUShadowAtlasTime );
#if defined(__APPLE__) && defined( USE_MoltenVK )
// SRS - For more recent versions of MoltenVK with enhanced performance statistics (v1.2.6 and later), display the Vulkan to Metal encoding thread time on macOS
ImGui::TextColored( rendererMvkEncodeTime > maxTime || rendererGPUInteractionsTime > maxTime ? colorRed : colorWhite, "Encode: %5lld us Interactions: %5llu us", rendererMvkEncodeTime, rendererGPUInteractionsTime );
@ -567,52 +566,6 @@ float idConsoleLocal::DrawFPS( float y )
}
return y;
#else
// print the resolution scale so we can tell when we are at reduced resolution
idStr resolutionText;
resolutionScale.GetConsoleText( resolutionText );
int w = resolutionText.Length() * BIGCHAR_WIDTH;
renderSystem->DrawBigStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, resolutionText.c_str(), colorWhite, true );
y += SMALLCHAR_HEIGHT + 4;
idStr timeStr;
timeStr.Format( "%sG+RF: %4d", gameThreadTotalTime > maxTime ? S_COLOR_RED : "", gameThreadTotalTime );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sG: %4d", gameThreadGameTime > maxTime ? S_COLOR_RED : "", gameThreadGameTime );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sRF: %4d", gameThreadRenderTime > maxTime ? S_COLOR_RED : "", gameThreadRenderTime );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sRB: %4.1f", rendererBackEndTime > maxTime * 1000 ? S_COLOR_RED : "", rendererBackEndTime / 1000.0f );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sSV: %4.1f", rendererShadowsTime > maxTime * 1000 ? S_COLOR_RED : "", rendererShadowsTime / 1000.0f );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sIDLE: %4.1f", rendererGPUIdleTime > maxTime * 1000 ? S_COLOR_RED : "", rendererGPUIdleTime / 1000.0f );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
y += SMALLCHAR_HEIGHT + 4;
timeStr.Format( "%sGPU: %4.1f", rendererGPUTime > maxTime * 1000 ? S_COLOR_RED : "", rendererGPUTime / 1000.0f );
w = timeStr.LengthWithoutColors() * SMALLCHAR_WIDTH;
renderSystem->DrawSmallStringExt( LOCALSAFE_RIGHT - w, idMath::Ftoi( y ) + 2, timeStr.c_str(), colorWhite, false );
return y + BIGCHAR_HEIGHT + 4;
#endif
}
/*

View file

@ -455,7 +455,7 @@ void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
// this should exit right after vsync, with the GPU idle and ready to draw
frameTiming.startRenderTime = Sys_Microseconds(); // SRS - Added frame timing for out-of-sequence updates (e.g. used in timedemo "twice" mode)
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
const emptyCommand_t* cmd = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_moc, &time_gpu, &stats_backend, &stats_frontend );
// get the GPU busy with new commands
renderSystem->RenderCommandBuffers( cmd );
@ -631,13 +631,13 @@ void idCommonLocal::Frame()
// foresthale 2014-05-12: also check com_editors as many of them are not particularly thread-safe (editLights for example)
if( com_smp.GetBool() && com_editors == 0 )
{
renderCommands = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
renderCommands = renderSystem->SwapCommandBuffers( &time_frontend, &time_backend, &time_moc, &time_gpu, &stats_backend, &stats_frontend );
}
else
{
// the GPU will stay idle through command generation for minimal
// input latency
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_shadows, &time_gpu, &stats_backend, &stats_frontend );
renderSystem->SwapCommandBuffers_FinishRendering( &time_frontend, &time_backend, &time_moc, &time_gpu, &stats_backend, &stats_frontend );
}
frameTiming.finishSyncTime = Sys_Microseconds();

View file

@ -913,9 +913,9 @@ public:
virtual void DrawCRTPostFX(); // RB
virtual const emptyCommand_t* SwapCommandBuffers( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* shadowMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc );
virtual const emptyCommand_t* SwapCommandBuffers( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* mocMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc );
virtual void SwapCommandBuffers_FinishRendering( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* shadowMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc );
virtual void SwapCommandBuffers_FinishRendering( uint64* frontEndMicroSec, uint64* backEndMicroSec, uint64* mocMicroSec, uint64* gpuMicroSec, backEndCounters_t* bc, performanceCounters_t* pc );
virtual const emptyCommand_t* SwapCommandBuffers_FinishCommandBuffers();
virtual void RenderCommandBuffers( const emptyCommand_t* commandBuffers );

View file

@ -605,13 +605,13 @@ with the rendering of the closed off command buffers by RenderCommandBuffers()
const emptyCommand_t* idRenderSystemLocal::SwapCommandBuffers(
uint64* frontEndMicroSec,
uint64* backEndMicroSec,
uint64* shadowMicroSec,
uint64* mocMicroSec,
uint64* gpuMicroSec,
backEndCounters_t* bc,
performanceCounters_t* pc
)
{
SwapCommandBuffers_FinishRendering( frontEndMicroSec, backEndMicroSec, shadowMicroSec, gpuMicroSec, bc, pc );
SwapCommandBuffers_FinishRendering( frontEndMicroSec, backEndMicroSec, mocMicroSec, gpuMicroSec, bc, pc );
return SwapCommandBuffers_FinishCommandBuffers();
}
@ -625,7 +625,7 @@ idRenderSystemLocal::SwapCommandBuffers_FinishRendering
void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
uint64* frontEndMicroSec,
uint64* backEndMicroSec,
uint64* shadowMicroSec,
uint64* mocMicroSec,
uint64* gpuMicroSec,
backEndCounters_t* bc,
performanceCounters_t* pc
@ -673,9 +673,9 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
*backEndMicroSec = backend.pc.cpuTotalMicroSec;
}
if( shadowMicroSec != NULL )
if( mocMicroSec != NULL )
{
*shadowMicroSec = backend.pc.cpuShadowMicroSec;
*mocMicroSec = this->pc.mocMicroSec;
}
// RB: TODO clean up the above and just pass entire backend and performance stats before they get cleared

View file

@ -132,6 +132,7 @@ struct performanceCounters_t
int c_mocCulledSurfaces;
int c_mocCulledLights;
uint64 mocMicroSec;
uint64 frontEndMicroSec; // sum of time in all RE_RenderScene's in a frame
};

View file

@ -504,6 +504,8 @@ void R_FillMaskedOcclusionBufferWithModels( viewDef_t* viewDef )
return;
}
int startTime = Sys_Microseconds();
const int viewWidth = viewDef->viewport.x2 - viewDef->viewport.x1 + 1;
const int viewHeight = viewDef->viewport.y2 - viewDef->viewport.y1 + 1;
@ -544,6 +546,10 @@ void R_FillMaskedOcclusionBufferWithModels( viewDef_t* viewDef )
R_RenderSingleModel( vEntity );
}
}
int endTime = Sys_Microseconds();
tr.pc.mocMicroSec += endTime - startTime;
#endif
}