mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Added basic support for Optick and D3D12
This commit is contained in:
parent
2ad666adcf
commit
12789bd95e
6 changed files with 68 additions and 7 deletions
|
@ -672,7 +672,7 @@ void idCommonLocal::Frame()
|
|||
|
||||
{
|
||||
|
||||
OPTICK_EVENT( "Wait for Frame" )
|
||||
OPTICK_CATEGORY( "Wait for Frame", Optick::Category::Wait );
|
||||
|
||||
for( ;; )
|
||||
{
|
||||
|
|
|
@ -1571,7 +1571,10 @@ idRenderBackend::GL_EndFrame
|
|||
*/
|
||||
void idRenderBackend::GL_EndFrame()
|
||||
{
|
||||
uint32_t swapIndex = deviceManager->GetCurrentBackBufferIndex();
|
||||
|
||||
OPTICK_EVENT( "EndFrame" );
|
||||
OPTICK_TAG( "Firing to swapIndex", swapIndex );
|
||||
|
||||
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::VULKAN )
|
||||
{
|
||||
|
@ -1600,14 +1603,17 @@ We want to exit this with the GPU idle, right at vsync
|
|||
*/
|
||||
void idRenderBackend::GL_BlockingSwapBuffers()
|
||||
{
|
||||
OPTICK_EVENT( "BlockingSwapBuffers" );
|
||||
uint32_t swapIndex = deviceManager->GetCurrentBackBufferIndex();
|
||||
|
||||
OPTICK_CATEGORY( "BlockingSwapBuffers", Optick::Category::Wait );
|
||||
//OPTICK_CATEGORY( "BlockingSwapBuffers", Optick::Category::Wait );
|
||||
OPTICK_TAG( "Waiting for swapIndex", swapIndex );
|
||||
|
||||
// Make sure that all frames have finished rendering
|
||||
// SRS - device-level sync kills perf by serializing command queue processing (CPU) and rendering (GPU)
|
||||
// - instead, use alternative sync method (based on command queue event queries) inside Present()
|
||||
//deviceManager->GetDevice()->waitForIdle();
|
||||
|
||||
// Present to the swap chain.
|
||||
// Make sure that all frames have finished rendering
|
||||
deviceManager->Present();
|
||||
|
||||
// Release all in-flight references to the render targets
|
||||
|
|
|
@ -144,4 +144,9 @@ public:
|
|||
|
||||
void AdvanceFrame();
|
||||
idVec2 GetCurrentPixelOffset();
|
||||
|
||||
uint32_t GetFrameIndex() const
|
||||
{
|
||||
return m_FrameIndex;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -794,6 +794,11 @@ void idRenderBackend::FillDepthBufferFast( drawSurf_t** drawSurfs, int numDrawSu
|
|||
{
|
||||
OPTICK_EVENT( "Render_FillDepthBufferFast" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_FillDepthBufferFast" );
|
||||
#endif
|
||||
|
||||
if( numDrawSurfs == 0 )
|
||||
{
|
||||
return;
|
||||
|
@ -4014,6 +4019,11 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
|
||||
OPTICK_EVENT( "Render_ShadowAtlas" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_ShadowAtlas" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenMainBlock( MRB_SHADOW_ATLAS_PASS );
|
||||
renderLog.OpenBlock( "Render_ShadowAtlas", colorYellow );
|
||||
|
||||
|
@ -4341,6 +4351,11 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef )
|
|||
|
||||
OPTICK_EVENT( "Render_Interactions" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_Interactions" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenMainBlock( MRB_DRAW_INTERACTIONS );
|
||||
renderLog.OpenBlock( "Render_Interactions", colorYellow );
|
||||
|
||||
|
@ -6642,6 +6657,21 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
OPTICK_EVENT( "Backend_DrawViewInternal" );
|
||||
OPTICK_TAG( "stereoEye", stereoEye );
|
||||
|
||||
/*
|
||||
if( deviceManager->GetGraphicsAPI() == nvrhi::GraphicsAPI::D3D12 )
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
//uint32_t swapIndex = deviceManager->GetCurrentBackBufferIndex();
|
||||
//idStr eventLabel;
|
||||
//eventLabel.Format( "DrawView( frameIndex = %i, swapIndex = %i ) ", taaPass->GetFrameIndex(), swapIndex );
|
||||
OPTICK_GPU_EVENT( "DrawView" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenBlock( "Render_DrawViewInternal", colorRed );
|
||||
|
||||
//-------------------------------------------------
|
||||
|
|
|
@ -46,6 +46,14 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#endif
|
||||
|
||||
|
||||
#if USE_OPTICK
|
||||
#define USE_OPTICK_GPU 0
|
||||
#else
|
||||
#define USE_OPTICK_GPU 0
|
||||
#endif
|
||||
|
||||
// TODO remove
|
||||
bool GL_CheckErrors_( const char* filename, int line );
|
||||
#if 1 // !defined(RETAIL)
|
||||
#define GL_CheckErrors() GL_CheckErrors_(__FILE__, __LINE__)
|
||||
|
|
|
@ -454,6 +454,8 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain()
|
|||
m_FrameWaitQuery = m_NvrhiDevice->createEventQuery();
|
||||
m_NvrhiDevice->setEventQuery( m_FrameWaitQuery, nvrhi::CommandQueue::Graphics );
|
||||
|
||||
OPTICK_GPU_INIT_D3D12( m_Device12, &m_GraphicsQueue, 1 );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -603,6 +605,9 @@ void DeviceManager_DX12::BeginFrame()
|
|||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
OPTICK_CATEGORY( "DX12_BeginFrame", Optick::Category::Wait );
|
||||
|
||||
auto bufferIndex = m_SwapChain->GetCurrentBackBufferIndex();
|
||||
|
||||
WaitForSingleObject( m_FrameFenceEvents[bufferIndex], INFINITE );
|
||||
|
@ -640,9 +645,13 @@ void DeviceManager_DX12::EndFrame()
|
|||
void DeviceManager_DX12::Present()
|
||||
{
|
||||
// SRS - Sync on previous frame's command queue completion vs. waitForIdle() on whole device
|
||||
m_NvrhiDevice->waitEventQuery( m_FrameWaitQuery );
|
||||
m_NvrhiDevice->resetEventQuery( m_FrameWaitQuery );
|
||||
m_NvrhiDevice->setEventQuery( m_FrameWaitQuery, nvrhi::CommandQueue::Graphics );
|
||||
{
|
||||
OPTICK_CATEGORY( "DX12_Present", Optick::Category::Wait );
|
||||
|
||||
m_NvrhiDevice->waitEventQuery( m_FrameWaitQuery );
|
||||
m_NvrhiDevice->resetEventQuery( m_FrameWaitQuery );
|
||||
m_NvrhiDevice->setEventQuery( m_FrameWaitQuery, nvrhi::CommandQueue::Graphics );
|
||||
}
|
||||
|
||||
if( !m_windowVisible )
|
||||
{
|
||||
|
@ -659,6 +668,9 @@ void DeviceManager_DX12::Present()
|
|||
presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
|
||||
}
|
||||
|
||||
OPTICK_GPU_FLIP( m_SwapChain.Get() );
|
||||
OPTICK_CATEGORY( "Present", Optick::Category::Wait );
|
||||
|
||||
// SRS - Don't change m_DeviceParams.vsyncEnabled here, simply test for vsync mode 2 to set DXGI SyncInterval
|
||||
m_SwapChain->Present( m_DeviceParams.vsyncEnabled && r_swapInterval.GetInteger() == 2 ? 1 : 0, presentFlags );
|
||||
|
||||
|
|
Loading…
Reference in a new issue