mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-03-14 22:50:45 +00:00
Add Optick for Vulkan, remove need for USE_OPTICK_GPU, fix calls to OPTICK_SHUTDOWN()
This commit is contained in:
parent
ab7fefcadc
commit
d9d721a73e
10 changed files with 77 additions and 16 deletions
|
@ -98,9 +98,10 @@ if(UNIX)
|
|||
|
||||
# SRS - Disable precompiled headers when cross-compiling on OSX, e.g. when creating universal binaries
|
||||
# - Also disable precompiled headers when using the Ninja Multi-Config generator on linux or macOS
|
||||
# - Also disable precompiled headers when using the Optick profiler on linux or macOS
|
||||
if((CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64" ) OR
|
||||
(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES MATCHES "x86_64") OR
|
||||
(CMAKE_GENERATOR MATCHES "Ninja Multi-Config"))
|
||||
(CMAKE_GENERATOR MATCHES "Ninja Multi-Config") OR OPTICK)
|
||||
set(USE_PRECOMPILED_HEADERS OFF)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -90,7 +90,11 @@ be called directly in the foreground thread for comparison.
|
|||
*/
|
||||
int idGameThread::Run()
|
||||
{
|
||||
OPTICK_THREAD( "idGameThread" );
|
||||
if( com_smp.GetBool() )
|
||||
{
|
||||
// SRS - label thread in smp mode only, otherwise CPU frame number is missing
|
||||
OPTICK_THREAD( "idGameThread" );
|
||||
}
|
||||
|
||||
commonLocal.frameTiming.startGameTime = Sys_Microseconds();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
#if defined(_MSC_VER)
|
||||
#define OPTICK_ENABLE_GPU_VULKAN (OPTICK_ENABLE_GPU /*&& 0*/)
|
||||
#else
|
||||
#define OPTICK_ENABLE_GPU_VULKAN (0)
|
||||
#define OPTICK_ENABLE_GPU_VULKAN (OPTICK_ENABLE_GPU /*&& 0*/)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -792,9 +792,12 @@ void idRenderBackend::FillDepthBufferFast( drawSurf_t** drawSurfs, int numDrawSu
|
|||
{
|
||||
OPTICK_EVENT( "Render_FillDepthBufferFast" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
#if USE_DX12 && OPTICK_ENABLE_GPU_D3D12
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_FillDepthBufferFast" );
|
||||
#elif USE_VK && OPTICK_ENABLE_GPU_VULKAN
|
||||
OPTICK_GPU_CONTEXT( ( VkCommandBuffer ) commandList->getNativeObject( nvrhi::ObjectTypes::VK_CommandBuffer ) );
|
||||
OPTICK_GPU_EVENT( "Render_FillDepthBufferFast" );
|
||||
#endif
|
||||
|
||||
if( numDrawSurfs == 0 )
|
||||
|
@ -3357,9 +3360,12 @@ void idRenderBackend::ShadowAtlasPass( const viewDef_t* _viewDef )
|
|||
|
||||
OPTICK_EVENT( "Render_ShadowAtlas" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
#if USE_DX12 && OPTICK_ENABLE_GPU_D3D12
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_ShadowAtlas" );
|
||||
#elif USE_VK && OPTICK_ENABLE_GPU_VULKAN
|
||||
OPTICK_GPU_CONTEXT( ( VkCommandBuffer ) commandList->getNativeObject( nvrhi::ObjectTypes::VK_CommandBuffer ) );
|
||||
OPTICK_GPU_EVENT( "Render_ShadowAtlas" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenMainBlock( MRB_SHADOW_ATLAS_PASS );
|
||||
|
@ -3670,9 +3676,12 @@ void idRenderBackend::DrawInteractions( const viewDef_t* _viewDef )
|
|||
|
||||
OPTICK_EVENT( "Render_Interactions" );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
#if USE_DX12 && OPTICK_ENABLE_GPU_D3D12
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "Render_Interactions" );
|
||||
#elif USE_VK && OPTICK_ENABLE_GPU_VULKAN
|
||||
OPTICK_GPU_CONTEXT( ( VkCommandBuffer ) commandList->getNativeObject( nvrhi::ObjectTypes::VK_CommandBuffer ) );
|
||||
OPTICK_GPU_EVENT( "Render_Interactions" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenMainBlock( MRB_DRAW_INTERACTIONS );
|
||||
|
@ -5389,12 +5398,15 @@ void idRenderBackend::DrawViewInternal( const viewDef_t* _viewDef, const int ste
|
|||
OPTICK_EVENT( "Backend_DrawViewInternal" );
|
||||
OPTICK_TAG( "stereoEye", stereoEye );
|
||||
|
||||
#if USE_OPTICK_GPU
|
||||
#if USE_DX12 && OPTICK_ENABLE_GPU_D3D12
|
||||
//uint32_t swapIndex = deviceManager->GetCurrentBackBufferIndex();
|
||||
//idStr eventLabel;
|
||||
//eventLabel.Format( "DrawView( frameIndex = %i, swapIndex = %i ) ", taaPass->GetFrameIndex(), swapIndex );
|
||||
OPTICK_GPU_CONTEXT( ( ID3D12GraphicsCommandList* ) commandList->getNativeObject( nvrhi::ObjectTypes::D3D12_GraphicsCommandList ) );
|
||||
OPTICK_GPU_EVENT( "DrawView" );
|
||||
#elif USE_VK && OPTICK_ENABLE_GPU_VULKAN
|
||||
OPTICK_GPU_CONTEXT( ( VkCommandBuffer ) commandList->getNativeObject( nvrhi::ObjectTypes::VK_CommandBuffer ) );
|
||||
OPTICK_GPU_EVENT( "DrawView" );
|
||||
#endif
|
||||
|
||||
renderLog.OpenBlock( "Render_DrawViewInternal", colorRed );
|
||||
|
|
|
@ -43,13 +43,6 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#include "PipelineCache.h"
|
||||
|
||||
|
||||
#if USE_OPTICK
|
||||
#define USE_OPTICK_GPU 0
|
||||
#else
|
||||
#define USE_OPTICK_GPU 0
|
||||
#endif
|
||||
|
||||
struct tmu_t
|
||||
{
|
||||
unsigned int current2DMap;
|
||||
|
|
|
@ -452,13 +452,17 @@ bool DeviceManager_DX12::CreateDeviceAndSwapChain()
|
|||
m_FrameWaitQuery = m_NvrhiDevice->createEventQuery();
|
||||
m_NvrhiDevice->setEventQuery( m_FrameWaitQuery, nvrhi::CommandQueue::Graphics );
|
||||
|
||||
#if OPTICK_ENABLE_GPU_D3D12
|
||||
OPTICK_GPU_INIT_D3D12( m_Device12, &m_GraphicsQueue, 1 );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager_DX12::DestroyDeviceAndSwapChain()
|
||||
{
|
||||
OPTICK_SHUTDOWN();
|
||||
|
||||
m_RhiSwapChainBuffers.clear();
|
||||
m_RendererString.clear();
|
||||
|
||||
|
|
|
@ -826,6 +826,9 @@ bool DeviceManager_VK::createDevice()
|
|||
|
||||
#if defined(__APPLE__) && defined( VK_KHR_portability_subset )
|
||||
auto portabilityFeatures = vk::PhysicalDevicePortabilitySubsetFeaturesKHR()
|
||||
#if USE_OPTICK
|
||||
.setEvents( true )
|
||||
#endif
|
||||
.setImageViewFormatSwizzle( true );
|
||||
|
||||
void* pNext = &portabilityFeatures;
|
||||
|
@ -863,6 +866,9 @@ bool DeviceManager_VK::createDevice()
|
|||
.setTimelineSemaphore( true )
|
||||
.setShaderSampledImageArrayNonUniformIndexing( true )
|
||||
.setBufferDeviceAddress( bufferAddressSupported )
|
||||
#if USE_OPTICK
|
||||
.setHostQueryReset( true )
|
||||
#endif
|
||||
.setPNext( pNext );
|
||||
|
||||
auto layerVec = stringSetToVector( enabledExtensions.layers );
|
||||
|
@ -1201,11 +1207,17 @@ bool DeviceManager_VK::CreateDeviceAndSwapChain()
|
|||
|
||||
#undef CHECK
|
||||
|
||||
#if OPTICK_ENABLE_GPU_VULKAN
|
||||
OPTICK_GPU_INIT_VULKAN( ( VkDevice* )&m_VulkanDevice, ( VkPhysicalDevice* )&m_VulkanPhysicalDevice, ( VkQueue* )&m_GraphicsQueue, ( uint32_t* )&m_GraphicsQueueFamily, 1, nullptr );
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DeviceManager_VK::DestroyDeviceAndSwapChain()
|
||||
{
|
||||
OPTICK_SHUTDOWN();
|
||||
|
||||
m_FrameWaitQuery = nullptr;
|
||||
|
||||
for( int i = 0; i < m_SwapChainImages.size(); i++ )
|
||||
|
@ -1285,6 +1297,9 @@ void DeviceManager_VK::EndFrame()
|
|||
|
||||
void DeviceManager_VK::Present()
|
||||
{
|
||||
OPTICK_GPU_FLIP( ( VkSwapchainKHR )m_SwapChain );
|
||||
OPTICK_CATEGORY( "Vulkan_Present", Optick::Category::Wait );
|
||||
|
||||
vk::PresentInfoKHR info = vk::PresentInfoKHR()
|
||||
.setWaitSemaphoreCount( 1 )
|
||||
.setPWaitSemaphores( &m_PresentSemaphore )
|
||||
|
@ -1313,6 +1328,8 @@ void DeviceManager_VK::Present()
|
|||
{
|
||||
if constexpr( NUM_FRAME_DATA > 2 )
|
||||
{
|
||||
OPTICK_CATEGORY( "Vulkan_Sync3", Optick::Category::Wait );
|
||||
|
||||
// SRS - For triple buffering, sync on previous frame's command queue completion
|
||||
m_NvrhiDevice->waitEventQuery( m_FrameWaitQuery );
|
||||
}
|
||||
|
@ -1322,6 +1339,8 @@ void DeviceManager_VK::Present()
|
|||
|
||||
if constexpr( NUM_FRAME_DATA < 3 )
|
||||
{
|
||||
OPTICK_CATEGORY( "Vulkan_Sync2", Optick::Category::Wait );
|
||||
|
||||
// SRS - For double buffering, sync on current frame's command queue completion
|
||||
m_NvrhiDevice->waitEventQuery( m_FrameWaitQuery );
|
||||
}
|
||||
|
|
|
@ -521,6 +521,19 @@ int main( int argc, const char** argv )
|
|||
Sys_Printf( "memory consistency checking enabled\n" );
|
||||
#endif
|
||||
|
||||
// Setting memory allocators
|
||||
OPTICK_SET_MEMORY_ALLOCATOR(
|
||||
[]( size_t size ) -> void* { return operator new( size ); },
|
||||
[]( void* p )
|
||||
{
|
||||
operator delete( p );
|
||||
},
|
||||
[]()
|
||||
{
|
||||
/* Do some TLS initialization here if needed */
|
||||
}
|
||||
);
|
||||
|
||||
Posix_EarlyInit();
|
||||
|
||||
if( argc > 1 )
|
||||
|
@ -537,6 +550,8 @@ int main( int argc, const char** argv )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
OPTICK_FRAME( "MainThread" );
|
||||
|
||||
common->Frame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -457,6 +457,19 @@ int main( int argc, const char** argv )
|
|||
cmdargv = argv;
|
||||
// DG end
|
||||
|
||||
// Setting memory allocators
|
||||
OPTICK_SET_MEMORY_ALLOCATOR(
|
||||
[]( size_t size ) -> void* { return operator new( size ); },
|
||||
[]( void* p )
|
||||
{
|
||||
operator delete( p );
|
||||
},
|
||||
[]()
|
||||
{
|
||||
/* Do some TLS initialization here if needed */
|
||||
}
|
||||
);
|
||||
|
||||
Posix_EarlyInit();
|
||||
|
||||
if( argc > 1 )
|
||||
|
@ -472,6 +485,8 @@ int main( int argc, const char** argv )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
OPTICK_FRAME( "MainThread" );
|
||||
|
||||
common->Frame();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2051,8 +2051,6 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
|
|||
common->Frame();
|
||||
}
|
||||
|
||||
OPTICK_SHUTDOWN();
|
||||
|
||||
// never gets here
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue