mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-15 07:00:58 +00:00
Implemented NVRHI timer queries
This commit is contained in:
parent
ff29a5dbd4
commit
4e776840d9
12 changed files with 145 additions and 94 deletions
|
@ -216,8 +216,6 @@ void Framebuffer::ResizeFramebuffers()
|
|||
|
||||
void Framebuffer::Bind()
|
||||
{
|
||||
RENDERLOG_PRINTF( "Framebuffer::Bind( %s )\n", fboName.c_str() );
|
||||
|
||||
if( tr.backend.currentFrameBuffer != this )
|
||||
{
|
||||
tr.backend.currentPipeline = nullptr;
|
||||
|
@ -234,7 +232,6 @@ bool Framebuffer::IsBound()
|
|||
|
||||
void Framebuffer::Unbind()
|
||||
{
|
||||
RENDERLOG_PRINTF( "Framebuffer::Unbind()\n" );
|
||||
globalFramebuffers.swapFramebuffers[deviceManager->GetCurrentBackBufferIndex()]->Bind();
|
||||
}
|
||||
|
||||
|
|
|
@ -168,8 +168,6 @@ Automatically enables 2D mapping or cube mapping if needed
|
|||
*/
|
||||
void idImage::Bind()
|
||||
{
|
||||
RENDERLOG_PRINTF( "idImage::Bind( %s )\n", GetName() );
|
||||
|
||||
tr.backend.SetCurrentImage( this );
|
||||
}
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ void idRenderBackend::Init()
|
|||
|
||||
// Need to reinitialize this pass once this image is resized.
|
||||
renderProgManager.Init( deviceManager->GetDevice() );
|
||||
renderLog.Init();
|
||||
|
||||
bindingCache.Init( deviceManager->GetDevice() );
|
||||
samplerCache.Init( deviceManager->GetDevice() );
|
||||
|
@ -229,8 +230,6 @@ void idRenderBackend::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
currentIndexOffset = indexOffset;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "Binding Buffers: %p:%i %p:%i\n", vertexBuffer, vertOffset, indexBuffer, indexOffset );
|
||||
|
||||
if( currentIndexBuffer != ( nvrhi::IBuffer* )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
|
||||
{
|
||||
currentIndexBuffer = indexBuffer->GetAPIObject();
|
||||
|
@ -668,6 +667,9 @@ idRenderBackend::GL_StartFrame
|
|||
*/
|
||||
void idRenderBackend::GL_StartFrame()
|
||||
{
|
||||
// fetch GPU timer queries of last frame
|
||||
renderLog.FetchGPUTimers( pc );
|
||||
|
||||
deviceManager->BeginFrame();
|
||||
|
||||
commandList->open();
|
||||
|
@ -729,7 +731,7 @@ may touch, including the editor.
|
|||
*/
|
||||
void idRenderBackend::GL_SetDefaultState()
|
||||
{
|
||||
RENDERLOG_PRINTF( "--- GL_SetDefaultState ---\n" );
|
||||
renderLog.OpenBlock( "--- GL_SetDefaultState ---\n" );
|
||||
|
||||
glStateBits = 0;
|
||||
|
||||
|
@ -740,6 +742,8 @@ void idRenderBackend::GL_SetDefaultState()
|
|||
renderProgManager.Unbind();
|
||||
|
||||
Framebuffer::Unbind();
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1069,8 +1073,6 @@ void idRenderBackend::SetBuffer( const void* data )
|
|||
|
||||
const setBufferCommand_t* cmd = ( const setBufferCommand_t* )data;
|
||||
|
||||
//RENDERLOG_PRINTF( "---------- RB_SetBuffer ---------- to buffer # %d\n", cmd->buffer );
|
||||
|
||||
renderLog.OpenBlock( "Render_SetBuffer" );
|
||||
|
||||
currentScissor.Clear();
|
||||
|
@ -1203,8 +1205,6 @@ void idRenderBackend::DrawStencilShadowPass( const drawSurf_t* drawSurf, const b
|
|||
currentIndexOffset = indexOffset;
|
||||
}
|
||||
|
||||
//RENDERLOG_PRINTF( "Binding Buffers: %p:%i %p:%i\n", vertexBuffer, vertOffset, indexBuffer, indexOffset );
|
||||
|
||||
if( currentIndexBuffer != ( nvrhi::IBuffer* )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
|
||||
{
|
||||
currentIndexBuffer = indexBuffer->GetAPIObject();
|
||||
|
|
|
@ -2105,9 +2105,8 @@ void idRenderBackend::DBG_RenderDebugTools( drawSurf_t** drawSurfs, int numDrawS
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_DRAW_DEBUG_TOOLS, commandList );
|
||||
renderLog.OpenMainBlock( MRB_DRAW_DEBUG_TOOLS );
|
||||
renderLog.OpenBlock( "Render_DebugTools", colorGreen );
|
||||
RENDERLOG_PRINTF( "---------- RB_RenderDebugTools ----------\n" );
|
||||
|
||||
GL_State( GLS_DEFAULT );
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ void idRenderProgManager::BindProgram( int index )
|
|||
}
|
||||
|
||||
currentIndex = index;
|
||||
RENDERLOG_PRINTF( "Binding HLSL Program %s\n", renderProgs[index].name.c_str() );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -221,8 +221,6 @@ void ForwardShadingPass::ShadowMapPass( nvrhi::ICommandList* commandList, const
|
|||
return;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_ShadowMapPass( side = %i ) ----------\n", side );
|
||||
|
||||
renderProgManager.BindShader_Depth();
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
|
@ -846,8 +844,6 @@ void ForwardShadingPass::SetupInputBuffers( const drawSurf_t* surf, nvrhi::Graph
|
|||
}
|
||||
const uint indexOffset = ( uint )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
|
||||
RENDERLOG_PRINTF( "Binding Buffers: %p:%i %p:%i\n", vertexBuffer, vertOffset, indexBuffer, indexOffset );
|
||||
|
||||
state.indexBuffer = { indexBuffer->GetAPIObject(), nvrhi::Format::R16_UINT, indexOffset };
|
||||
state.vertexBuffers = { { vertexBuffer->GetAPIObject(), 0, vertOffset } };
|
||||
}
|
||||
|
|
|
@ -571,8 +571,6 @@ void GBufferFillPass::DrawElementsWithCounters( const drawSurf_t* surf )
|
|||
}
|
||||
const uint indexOffset = ( uint )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
|
||||
|
||||
RENDERLOG_PRINTF( "Binding Buffers: %p:%i %p:%i\n", vertexBuffer, vertOffset, indexBuffer, indexOffset );
|
||||
|
||||
auto currentIndexBuffer = ( nvrhi::IBuffer* )indexBuffer->GetAPIObject();
|
||||
|
||||
if( currentIndexBuffer != ( nvrhi::IBuffer* )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
|
||||
|
|
|
@ -105,12 +105,6 @@ static void RB_LoadShaderTextureMatrix( const float* shaderRegisters, const text
|
|||
texT[1] = matrix[1 * 4 + 1];
|
||||
texT[2] = matrix[2 * 4 + 1];
|
||||
texT[3] = matrix[3 * 4 + 1];
|
||||
|
||||
RENDERLOG_PRINTF( "Setting Texture Matrix\n" );
|
||||
renderLog.Indent();
|
||||
RENDERLOG_PRINTF( "Texture Matrix S : %4.3f, %4.3f, %4.3f, %4.3f\n", texS[0], texS[1], texS[2], texS[3] );
|
||||
RENDERLOG_PRINTF( "Texture Matrix T : %4.3f, %4.3f, %4.3f, %4.3f\n", texT[0], texT[1], texT[2], texT[3] );
|
||||
renderLog.Outdent();
|
||||
}
|
||||
|
||||
SetVertexParm( RENDERPARM_TEXTUREMATRIX_S, texS );
|
||||
|
|
|
@ -208,11 +208,11 @@ void RB_LoadShaderTextureMatrix( const float* shaderRegisters, const textureStag
|
|||
texT[2] = matrix[2 * 4 + 1];
|
||||
texT[3] = matrix[3 * 4 + 1];
|
||||
|
||||
RENDERLOG_PRINTF( "Setting Texture Matrix\n" );
|
||||
renderLog.Indent();
|
||||
RENDERLOG_PRINTF( "Texture Matrix S : %4.3f, %4.3f, %4.3f, %4.3f\n", texS[0], texS[1], texS[2], texS[3] );
|
||||
RENDERLOG_PRINTF( "Texture Matrix T : %4.3f, %4.3f, %4.3f, %4.3f\n", texT[0], texT[1], texT[2], texT[3] );
|
||||
renderLog.Outdent();
|
||||
//RENDERLOG_PRINTF( "Setting Texture Matrix\n" );
|
||||
//renderLog.Indent();
|
||||
//RENDERLOG_PRINTF( "Texture Matrix S : %4.3f, %4.3f, %4.3f, %4.3f\n", texS[0], texS[1], texS[2], texS[3] );
|
||||
//RENDERLOG_PRINTF( "Texture Matrix T : %4.3f, %4.3f, %4.3f, %4.3f\n", texT[0], texT[1], texT[2], texT[3] );
|
||||
//renderLog.Outdent();
|
||||
}
|
||||
|
||||
SetVertexParm( RENDERPARM_TEXTUREMATRIX_S, texS );
|
||||
|
@ -367,7 +367,6 @@ void idRenderBackend::PrepareStageTexturing( const shaderStage_t* pStage, const
|
|||
|
||||
GL_SelectTexture( 0 );
|
||||
|
||||
RENDERLOG_PRINTF( "TexGen: TG_REFLECT_CUBE: Bumpy Environment\n" );
|
||||
if( surf->jointCache )
|
||||
{
|
||||
renderProgManager.BindShader_BumpyEnvironmentSkinned();
|
||||
|
@ -379,7 +378,6 @@ void idRenderBackend::PrepareStageTexturing( const shaderStage_t* pStage, const
|
|||
}
|
||||
else
|
||||
{
|
||||
RENDERLOG_PRINTF( "TexGen: TG_REFLECT_CUBE: Environment\n" );
|
||||
if( surf->jointCache )
|
||||
{
|
||||
renderProgManager.BindShader_EnvironmentSkinned();
|
||||
|
@ -464,8 +462,8 @@ void idRenderBackend::PrepareStageTexturing( const shaderStage_t* pStage, const
|
|||
float mat[16];
|
||||
R_MatrixMultiply( surf->space->modelViewMatrix, viewDef->projectionMatrix, mat );
|
||||
|
||||
RENDERLOG_PRINTF( "TexGen : %s\n", ( pStage->texture.texgen == TG_SCREEN ) ? "TG_SCREEN" : "TG_SCREEN2" );
|
||||
renderLog.Indent();
|
||||
//RENDERLOG_PRINTF( "TexGen : %s\n", ( pStage->texture.texgen == TG_SCREEN ) ? "TG_SCREEN" : "TG_SCREEN2" );
|
||||
//renderLog.Indent();
|
||||
|
||||
float plane[4];
|
||||
plane[0] = mat[0 * 4 + 0];
|
||||
|
@ -473,23 +471,23 @@ void idRenderBackend::PrepareStageTexturing( const shaderStage_t* pStage, const
|
|||
plane[2] = mat[2 * 4 + 0];
|
||||
plane[3] = mat[3 * 4 + 0];
|
||||
SetVertexParm( RENDERPARM_TEXGEN_0_S, plane );
|
||||
RENDERLOG_PRINTF( "TEXGEN_S = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
//RENDERLOG_PRINTF( "TEXGEN_S = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
|
||||
plane[0] = mat[0 * 4 + 1];
|
||||
plane[1] = mat[1 * 4 + 1];
|
||||
plane[2] = mat[2 * 4 + 1];
|
||||
plane[3] = mat[3 * 4 + 1];
|
||||
SetVertexParm( RENDERPARM_TEXGEN_0_T, plane );
|
||||
RENDERLOG_PRINTF( "TEXGEN_T = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
//RENDERLOG_PRINTF( "TEXGEN_T = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
|
||||
plane[0] = mat[0 * 4 + 3];
|
||||
plane[1] = mat[1 * 4 + 3];
|
||||
plane[2] = mat[2 * 4 + 3];
|
||||
plane[3] = mat[3 * 4 + 3];
|
||||
SetVertexParm( RENDERPARM_TEXGEN_0_Q, plane );
|
||||
RENDERLOG_PRINTF( "TEXGEN_Q = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
//RENDERLOG_PRINTF( "TEXGEN_Q = %4.3f, %4.3f, %4.3f, %4.3f\n", plane[0], plane[1], plane[2], plane[3] );
|
||||
|
||||
renderLog.Outdent();
|
||||
//renderLog.Outdent();
|
||||
|
||||
}
|
||||
else if( pStage->texture.texgen == TG_DIFFUSE_CUBE )
|
||||
|
@ -803,7 +801,7 @@ void idRenderBackend::FillDepthBufferFast( drawSurf_t** drawSurfs, int numDrawSu
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_FILL_DEPTH_BUFFER, commandList );
|
||||
renderLog.OpenMainBlock( MRB_FILL_DEPTH_BUFFER );
|
||||
renderLog.OpenBlock( "Render_FillDepthBufferFast", colorBlue );
|
||||
|
||||
// force MVP change on first surface
|
||||
|
@ -1935,7 +1933,7 @@ void idRenderBackend::AmbientPass( const drawSurf_t* const* drawSurfs, int numDr
|
|||
#endif
|
||||
|
||||
|
||||
renderLog.OpenMainBlock( fillGbuffer ? MRB_FILL_GEOMETRY_BUFFER : MRB_AMBIENT_PASS, commandList );
|
||||
renderLog.OpenMainBlock( fillGbuffer ? MRB_FILL_GEOMETRY_BUFFER : MRB_AMBIENT_PASS );
|
||||
renderLog.OpenBlock( fillGbuffer ? "Fill_GeometryBuffer" : "Render_AmbientPass", colorBlue );
|
||||
|
||||
if( fillGbuffer )
|
||||
|
@ -2402,7 +2400,7 @@ void idRenderBackend::StencilShadowPass( const drawSurf_t* drawSurfs, const view
|
|||
return;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_StencilShadowPass ----------\n" );
|
||||
renderLog.OpenBlock( "Render_StencilShadowPass" );
|
||||
|
||||
renderProgManager.BindShader_Shadow();
|
||||
|
||||
|
@ -2567,6 +2565,8 @@ void idRenderBackend::StencilShadowPass( const drawSurf_t* drawSurfs, const view
|
|||
GL_DepthBoundsTest( 0.0f, 0.0f );
|
||||
}
|
||||
}
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3821,7 +3821,7 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef )
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_DRAW_INTERACTIONS, commandList );
|
||||
renderLog.OpenMainBlock( MRB_DRAW_INTERACTIONS );
|
||||
renderLog.OpenBlock( "Render_Interactions", colorYellow );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
|
@ -4819,7 +4819,7 @@ void idRenderBackend::FogAllLights()
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_FOG_ALL_LIGHTS, commandList );
|
||||
renderLog.OpenMainBlock( MRB_FOG_ALL_LIGHTS );
|
||||
renderLog.OpenBlock( "Render_FogAllLights", colorBlue );
|
||||
|
||||
// force fog plane to recalculate
|
||||
|
@ -4969,8 +4969,6 @@ void idRenderBackend::CalculateAutomaticExposure()
|
|||
|
||||
void idRenderBackend::Tonemap( const viewDef_t* _viewDef )
|
||||
{
|
||||
RENDERLOG_PRINTF( "---------- RB_Tonemap( avg = %f, max = %f, key = %f, is2Dgui = %i ) ----------\n", hdrAverageLuminance, hdrMaxLuminance, hdrKey, ( int )viewDef->is2Dgui );
|
||||
|
||||
renderLog.OpenBlock( "Tonemap" );
|
||||
|
||||
//postProcessCommand_t* cmd = ( postProcessCommand_t* )data;
|
||||
|
@ -5071,11 +5069,9 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_BLOOM, commandList );
|
||||
renderLog.OpenMainBlock( MRB_BLOOM );
|
||||
renderLog.OpenBlock( "Render_Bloom", colorBlue );
|
||||
|
||||
RENDERLOG_PRINTF( "---------- RB_Bloom( avg = %f, max = %f, key = %f ) ----------\n", hdrAverageLuminance, hdrMaxLuminance, hdrKey );
|
||||
|
||||
// BRIGHTPASS
|
||||
renderLog.OpenBlock( "Brightpass" );
|
||||
|
||||
|
@ -5116,7 +5112,7 @@ void idRenderBackend::Bloom( const viewDef_t* _viewDef )
|
|||
int w = viewDef->viewport.x2 - viewDef->viewport.x1 + 1;
|
||||
int h = viewDef->viewport.y2 - viewDef->viewport.y1 + 1;
|
||||
|
||||
RENDERLOG_PRINTF( "Resolve to %i x %i buffer\n", w, h );
|
||||
//RENDERLOG_PRINTF( "Resolve to %i x %i buffer\n", w, h );
|
||||
|
||||
// resolve the screen
|
||||
globalImages->currentRenderImage->CopyFramebuffer( x, y, w, h );
|
||||
|
@ -5236,7 +5232,7 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef
|
|||
return;
|
||||
}
|
||||
|
||||
renderLog.OpenMainBlock( MRB_SSAO_PASS, commandList );
|
||||
renderLog.OpenMainBlock( MRB_SSAO_PASS );
|
||||
renderLog.OpenBlock( "Render_SSAO", colorBlue );
|
||||
|
||||
currentSpace = &viewDef->worldSpace;
|
||||
|
@ -5968,7 +5964,7 @@ void idRenderBackend::ExecuteBackEndCommands( const emptyCommand_t* cmds )
|
|||
if( drawView3D_timestamps )
|
||||
{
|
||||
// SRS - Capture separate timestamps for overlay GUI rendering when RC_DRAW_VIEW_3D timestamps are active
|
||||
renderLog.OpenMainBlock( MRB_DRAW_GUI, commandList );
|
||||
renderLog.OpenMainBlock( MRB_DRAW_GUI );
|
||||
renderLog.OpenBlock( "Render_DrawViewGUI", colorBlue );
|
||||
// SRS - Disable detailed timestamps during overlay GUI rendering so they do not overwrite timestamps from 3D rendering
|
||||
glConfig.timerQueryAvailable = false;
|
||||
|
@ -6195,7 +6191,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
int processed = 0;
|
||||
if( !r_skipShaderPasses.GetBool() )
|
||||
{
|
||||
renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES, commandList );
|
||||
renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES );
|
||||
float guiScreenOffset;
|
||||
if( _viewDef->viewEntitys != NULL )
|
||||
{
|
||||
|
@ -6233,7 +6229,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
int w = viewDef->viewport.x2 - viewDef->viewport.x1 + 1;
|
||||
int h = viewDef->viewport.y2 - viewDef->viewport.y1 + 1;
|
||||
|
||||
RENDERLOG_PRINTF( "Resolve to %i x %i buffer\n", w, h );
|
||||
//RENDERLOG_PRINTF( "Resolve to %i x %i buffer\n", w, h );
|
||||
|
||||
GL_SelectTexture( 0 );
|
||||
|
||||
|
@ -6271,7 +6267,7 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
SetFragmentParm( RENDERPARM_WINDOWCOORD, windowCoordParm ); // rpWindowCoord
|
||||
|
||||
// render the remaining surfaces
|
||||
renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES_POST, commandList );
|
||||
renderLog.OpenMainBlock( MRB_DRAW_SHADER_PASSES_POST );
|
||||
DrawShaderPasses( drawSurfs + processed, numDrawSurfs - processed, 0.0f /* definitely not a gui */, stereoEye );
|
||||
renderLog.CloseMainBlock();
|
||||
}
|
||||
|
@ -6548,7 +6544,7 @@ void idRenderBackend::CopyRender( const void* data )
|
|||
return;
|
||||
}
|
||||
|
||||
RENDERLOG_PRINTF( "***************** RB_CopyRender *****************\n" );
|
||||
renderLog.OpenBlock( "***************** RB_CopyRender *****************" );
|
||||
|
||||
if( cmd->image )
|
||||
{
|
||||
|
@ -6559,6 +6555,8 @@ void idRenderBackend::CopyRender( const void* data )
|
|||
{
|
||||
GL_Clear( true, false, false, STENCIL_SHADOW_TEST_VALUE, 0, 0, 0, 0 );
|
||||
}
|
||||
|
||||
renderLog.CloseBlock();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -6583,7 +6581,7 @@ void idRenderBackend::PostProcess( const void* data )
|
|||
}
|
||||
|
||||
|
||||
renderLog.OpenMainBlock( MRB_POSTPROCESS, commandList );
|
||||
renderLog.OpenMainBlock( MRB_POSTPROCESS );
|
||||
renderLog.OpenBlock( "Render_PostProcessing", colorBlue );
|
||||
|
||||
// FIXME
|
||||
|
|
|
@ -29,6 +29,11 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "RenderCommon.h"
|
||||
#pragma hdrstop
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
#include <sys/DeviceManager.h>
|
||||
extern DeviceManager* deviceManager;
|
||||
#endif
|
||||
|
||||
/*
|
||||
================================================================================================
|
||||
Contains the RenderLog implementation.
|
||||
|
@ -310,26 +315,32 @@ idRenderLog
|
|||
idRenderLog renderLog;
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
idRenderLog::idRenderLog
|
||||
========================
|
||||
*/
|
||||
idRenderLog::idRenderLog()
|
||||
{
|
||||
frameCounter = 0;
|
||||
frameParity = 0;
|
||||
}
|
||||
|
||||
void idRenderLog::Init()
|
||||
{
|
||||
#if defined( USE_NVRHI )
|
||||
for( int i = 0; i < MRB_TOTAL_QUERIES; i++ )
|
||||
{
|
||||
timerQueries.Append( deviceManager->GetDevice()->createTimerQuery() );
|
||||
timerUsed.Append( false );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void idRenderLog::StartFrame( nvrhi::ICommandList* _commandList )
|
||||
{
|
||||
#if defined( USE_NVRHI )
|
||||
commandList = _commandList;
|
||||
#endif
|
||||
}
|
||||
|
||||
void idRenderLog::EndFrame()
|
||||
{
|
||||
frameCounter++;
|
||||
frameParity = frameCounter % NUM_FRAME_DATA;
|
||||
}
|
||||
|
||||
|
||||
|
@ -339,12 +350,8 @@ void idRenderLog::EndFrame()
|
|||
idRenderLog::OpenMainBlock
|
||||
========================
|
||||
*/
|
||||
void idRenderLog::OpenMainBlock( renderLogMainBlock_t block, nvrhi::ICommandList* _commandList )
|
||||
void idRenderLog::OpenMainBlock( renderLogMainBlock_t block )
|
||||
{
|
||||
#if defined( USE_NVRHI )
|
||||
commandList = _commandList;
|
||||
#endif
|
||||
|
||||
// SRS - Use glConfig.timerQueryAvailable flag to control timestamp capture for all platforms
|
||||
if( glConfig.timerQueryAvailable )
|
||||
{
|
||||
|
@ -352,7 +359,10 @@ void idRenderLog::OpenMainBlock( renderLogMainBlock_t block, nvrhi::ICommandList
|
|||
|
||||
#if defined( USE_NVRHI )
|
||||
|
||||
// SP: use nvrhi timer queries
|
||||
int timerIndex = mainBlock + frameParity * MRB_TOTAL;
|
||||
|
||||
commandList->beginTimerQuery( timerQueries[ timerIndex ] );
|
||||
timerUsed[ timerIndex ] = true;
|
||||
|
||||
#elif defined( USE_VULKAN )
|
||||
if( vkcontext.queryIndex[ vkcontext.frameParity ] >= ( NUM_TIMESTAMP_QUERIES - 1 ) )
|
||||
|
@ -402,7 +412,13 @@ void idRenderLog::CloseMainBlock()
|
|||
if( glConfig.timerQueryAvailable )
|
||||
{
|
||||
|
||||
#if defined( USE_VULKAN )
|
||||
#if defined( USE_NVRHI )
|
||||
|
||||
int timerIndex = mainBlock + frameParity * MRB_TOTAL;
|
||||
|
||||
commandList->endTimerQuery( timerQueries[ timerIndex ] );
|
||||
|
||||
#elif defined( USE_VULKAN )
|
||||
if( vkcontext.queryIndex[ vkcontext.frameParity ] >= ( NUM_TIMESTAMP_QUERIES - 1 ) )
|
||||
{
|
||||
return;
|
||||
|
@ -414,10 +430,6 @@ void idRenderLog::CloseMainBlock()
|
|||
uint32 queryIndex = vkcontext.queryAssignedIndex[ vkcontext.frameParity ][ mainBlock * 2 + 1 ] = vkcontext.queryIndex[ vkcontext.frameParity ]++;
|
||||
vkCmdWriteTimestamp( commandBuffer, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, queryPool, queryIndex );
|
||||
|
||||
#elif defined(USE_NVRHI)
|
||||
|
||||
// SP: Close nvrhi timer queries
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
// SRS - For OSX use elapsed time query for Apple OpenGL 4.1 using GL_TIME_ELAPSED vs GL_TIMESTAMP (which is not implemented on OSX)
|
||||
// SRS - OSX AMD drivers have a rendering bug (flashing colours) with an elasped time query when Shadow Mapping is on - turn off query for that case unless r_skipAMDWorkarounds is set
|
||||
|
@ -434,6 +446,63 @@ void idRenderLog::CloseMainBlock()
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
========================
|
||||
idRenderLog::FetchGPUTimers
|
||||
========================
|
||||
*/
|
||||
void idRenderLog::FetchGPUTimers( backEndCounters_t& pc )
|
||||
{
|
||||
frameCounter++;
|
||||
frameParity ^= 1;
|
||||
|
||||
#if defined( USE_NVRHI )
|
||||
|
||||
for( int i = 0; i < MRB_TOTAL; i++ )
|
||||
{
|
||||
int timerIndex = i + frameParity * MRB_TOTAL;
|
||||
|
||||
if( timerUsed[timerIndex] )
|
||||
{
|
||||
double time = deviceManager->GetDevice()->getTimerQueryTime( timerQueries[ timerIndex ] );
|
||||
time *= 1000000.0; // seconds -> microseconds
|
||||
|
||||
if( i == MRB_GPU_TIME )
|
||||
{
|
||||
pc.gpuMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_FILL_DEPTH_BUFFER )
|
||||
{
|
||||
pc.gpuDepthMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_SSAO_PASS )
|
||||
{
|
||||
pc.gpuScreenSpaceAmbientOcclusionMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_AMBIENT_PASS )
|
||||
{
|
||||
pc.gpuAmbientPassMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_DRAW_INTERACTIONS )
|
||||
{
|
||||
pc.gpuInteractionsMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_DRAW_SHADER_PASSES )
|
||||
{
|
||||
pc.gpuShaderPassMicroSec = time;
|
||||
}
|
||||
else if( i == MRB_POSTPROCESS )
|
||||
{
|
||||
pc.gpuPostProcessingMicroSec = time;
|
||||
}
|
||||
}
|
||||
|
||||
// reset timer
|
||||
timerUsed[timerIndex] = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
========================
|
||||
|
|
|
@ -59,18 +59,6 @@ enum renderLogMainBlock_t
|
|||
MRB_TOTAL_QUERIES = MRB_TOTAL * 2,
|
||||
};
|
||||
|
||||
// these are used to make sure each Indent() is properly paired with an Outdent()
|
||||
enum renderLogIndentLabel_t
|
||||
{
|
||||
RENDER_LOG_INDENT_DEFAULT,
|
||||
RENDER_LOG_INDENT_MAIN_BLOCK,
|
||||
RENDER_LOG_INDENT_BLOCK,
|
||||
RENDER_LOG_INDENT_TEST
|
||||
};
|
||||
|
||||
// using this macro avoids printf parameter overhead if the renderlog isn't active
|
||||
#define RENDERLOG_PRINTF( ... ) if ( renderLog.activeLevel ) renderLog.Printf( __VA_ARGS__ );
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
@ -92,11 +80,24 @@ private:
|
|||
|
||||
uint64 frameCounter;
|
||||
uint32 frameParity;
|
||||
|
||||
idStaticList<nvrhi::TimerQueryHandle, MRB_TOTAL_QUERIES> timerQueries;
|
||||
idStaticList<bool, MRB_TOTAL_QUERIES> timerUsed;
|
||||
|
||||
//idArray< idArray< nvrhi::TimerQueryHandle, MRB_TOTAL_QUERIES >, NUM_FRAME_DATA > timerQueries;
|
||||
|
||||
// GPU timestamp queries
|
||||
//idArray< uint32, NUM_FRAME_DATA > queryIndex;
|
||||
|
||||
//idArray< idArray< uint64, NUM_TIMESTAMP_QUERIES >, NUM_FRAME_DATA > queryResults;
|
||||
//idArray< VkQueryPool, NUM_FRAME_DATA > queryPools;
|
||||
#endif
|
||||
|
||||
public:
|
||||
idRenderLog();
|
||||
|
||||
void Init();
|
||||
|
||||
void StartFrame( nvrhi::ICommandList* _commandList );
|
||||
void EndFrame();
|
||||
void Close() {}
|
||||
|
@ -107,14 +108,12 @@ public:
|
|||
|
||||
void OpenBlock( const char* label, const idVec4& color = colorBlack );
|
||||
void CloseBlock();
|
||||
void OpenMainBlock( renderLogMainBlock_t block, nvrhi::ICommandList* commandList );
|
||||
void CloseMainBlock();// {}
|
||||
void Indent( renderLogIndentLabel_t label = RENDER_LOG_INDENT_DEFAULT ) {}
|
||||
void Outdent( renderLogIndentLabel_t label = RENDER_LOG_INDENT_DEFAULT ) {}
|
||||
void OpenMainBlock( renderLogMainBlock_t block );
|
||||
void CloseMainBlock();
|
||||
|
||||
void Printf( VERIFY_FORMAT_STRING const char* fmt, ... ) {}
|
||||
|
||||
int activeLevel;
|
||||
void FetchGPUTimers( backEndCounters_t& pc );
|
||||
};
|
||||
|
||||
extern idRenderLog renderLog;
|
||||
|
|
|
@ -136,8 +136,12 @@ void idRenderSystemLocal::RenderCommandBuffers( const emptyCommand_t* const cmdH
|
|||
// draw 2D graphics
|
||||
if( !r_skipBackEnd.GetBool() )
|
||||
{
|
||||
#if defined(USE_NVRHI)
|
||||
|
||||
renderLog.FetchGPUTimers( backend.pc );
|
||||
|
||||
// SRS - For OSX skip total rendering time query due to missing GL_TIMESTAMP support in Apple OpenGL 4.1, will calculate it inside SwapCommandBuffers_FinishRendering instead
|
||||
#if !defined(USE_VULKAN) && !defined(__APPLE__) && !defined(USE_NVRHI)
|
||||
#elif !defined(USE_VULKAN) && !defined(__APPLE__)
|
||||
if( glConfig.timerQueryAvailable )
|
||||
{
|
||||
if( glcontext.renderLogMainBlockTimeQueryIds[ glcontext.frameParity ][ MRB_GPU_TIME ] == 0 )
|
||||
|
|
Loading…
Reference in a new issue