From 62c86f647ef279f0562990221ef3e2f961157ee4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 23 Aug 2024 14:03:11 +0100 Subject: [PATCH] Add a config option to print chunk timings in release --- renderdoc/core/core.cpp | 2 ++ renderdoc/driver/d3d11/d3d11_device.cpp | 34 +++++++++++++++++-------- renderdoc/driver/d3d12/d3d12_device.cpp | 33 ++++++++++++++++-------- renderdoc/driver/gl/gl_driver.cpp | 34 +++++++++++++++++-------- renderdoc/driver/vulkan/vk_core.cpp | 33 ++++++++++++++++-------- 5 files changed, 92 insertions(+), 44 deletions(-) diff --git a/renderdoc/core/core.cpp b/renderdoc/core/core.cpp index 7845ae836..2939583ef 100644 --- a/renderdoc/core/core.cpp +++ b/renderdoc/core/core.cpp @@ -51,6 +51,8 @@ extern "C" const rdcstr VulkanLayerJSONBasename = STRINGIZE(RDOC_BASE_NAME); RDOC_DEBUG_CONFIG(bool, Capture_Debug_SnapshotDiagnosticLog, false, "Snapshot the diagnostic log at capture time and embed in the capture."); +RDOC_CONFIG(bool, Replay_Debug_PrintChunkTimings, false, "Print stats of chunk processing times"); + // this is declared centrally so it can be shared with any backend - the name is a misnomer but kept // for backwards compatibility reasons. RDOC_CONFIG(rdcarray, DXBC_Debug_SearchDirPaths, {}, diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index a6dd62bb5..67ebb7472 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -25,6 +25,7 @@ #include "d3d11_device.h" #include "core/core.h" +#include "core/settings.h" #include "driver/dxgi/dxgi_wrapped.h" #include "jpeg-compressor/jpge.h" #include "maths/formatpacking.h" @@ -38,6 +39,8 @@ #include "d3d11_resources.h" #include "d3d11_shader_cache.h" +RDOC_EXTERN_CONFIG(bool, Replay_Debug_PrintChunkTimings); + WRAPPED_POOL_INST(WrappedID3D11Device); WrappedID3D11Device *WrappedID3D11Device::m_pCurrentWrappedDevice = NULL; @@ -1519,20 +1522,29 @@ RDResult WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool storeStru } } + const bool develMode = #if ENABLED(RDOC_DEVEL) - for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) - { - double dcount = double(it->second.count); - - RDCDEBUG( - "% 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s (%u)", - it->second.count, it->second.total, it->second.total / dcount, - double(it->second.totalsize) / (1024.0 * 1024.0), - double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), - GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); - } + true; +#else + false; #endif + if(Replay_Debug_PrintChunkTimings() || develMode) + { + for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) + { + double dcount = double(it->second.count); + + RDCLOG( + "| % 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s " + "(%u)", + it->second.count, it->second.total, it->second.total / dcount, + double(it->second.totalsize) / (1024.0 * 1024.0), + double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), + GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); + } + } + GetReplay()->WriteFrameRecord().frameInfo.uncompressedFileSize = rdc->GetSectionProperties(sectionIdx).uncompressedSize; GetReplay()->WriteFrameRecord().frameInfo.compressedFileSize = diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 79d6eaa59..8d3127b92 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -43,6 +43,8 @@ #include "d3d12_resources.h" #include "d3d12_shader_cache.h" +RDOC_EXTERN_CONFIG(bool, Replay_Debug_PrintChunkTimings); + RDOC_DEBUG_CONFIG(bool, D3D12_Debug_SingleSubmitFlushing, false, "Every command buffer is submitted and fully flushed to the GPU, to narrow down " "the source of problems."); @@ -4918,20 +4920,29 @@ RDResult WrappedID3D12Device::ReadLogInitialisation(RDCFile *rdc, bool storeStru } } + const bool develMode = #if ENABLED(RDOC_DEVEL) - for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) - { - double dcount = double(it->second.count); - - RDCDEBUG( - "% 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s (%u)", - it->second.count, it->second.total, it->second.total / dcount, - double(it->second.totalsize) / (1024.0 * 1024.0), - double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), - GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); - } + true; +#else + false; #endif + if(Replay_Debug_PrintChunkTimings() || develMode) + { + for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) + { + double dcount = double(it->second.count); + + RDCLOG( + "| % 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s " + "(%u)", + it->second.count, it->second.total, it->second.total / dcount, + double(it->second.totalsize) / (1024.0 * 1024.0), + double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), + GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); + } + } + GetReplay()->WriteFrameRecord().frameInfo.uncompressedFileSize = rdc->GetSectionProperties(sectionIdx).uncompressedSize; GetReplay()->WriteFrameRecord().frameInfo.compressedFileSize = diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index ab4486d61..9b1576eb3 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -26,12 +26,15 @@ #include "gl_driver.h" #include #include "common/common.h" +#include "core/settings.h" #include "driver/shaders/spirv/spirv_compile.h" #include "jpeg-compressor/jpge.h" #include "serialise/rdcfile.h" #include "strings/string_utils.h" #include "gl_replay.h" +RDOC_EXTERN_CONFIG(bool, Replay_Debug_PrintChunkTimings); + std::map WrappedOpenGL::m_ActiveContexts; void WrappedOpenGL::BuildGLExtensions() @@ -3508,20 +3511,29 @@ RDResult WrappedOpenGL::ReadLogInitialisation(RDCFile *rdc, bool storeStructured m_ImplicitThreadSwitches)); } + const bool develMode = #if ENABLED(RDOC_DEVEL) - for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) - { - double dcount = double(it->second.count); - - RDCDEBUG( - "% 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s (%u)", - it->second.count, it->second.total, it->second.total / dcount, - double(it->second.totalsize) / (1024.0 * 1024.0), - double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), - GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); - } + true; +#else + false; #endif + if(Replay_Debug_PrintChunkTimings() || develMode) + { + for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) + { + double dcount = double(it->second.count); + + RDCLOG( + "| % 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s " + "(%u)", + it->second.count, it->second.total, it->second.total / dcount, + double(it->second.totalsize) / (1024.0 * 1024.0), + double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), + GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); + } + } + // steal the structured data for ourselves m_StructuredFile->Swap(*m_StoredStructuredData); diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 87042a8dc..dddbc58d7 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -37,6 +37,8 @@ #include "stb/stb_image_write.h" +RDOC_EXTERN_CONFIG(bool, Replay_Debug_PrintChunkTimings); + RDOC_EXTERN_CONFIG(bool, Vulkan_Debug_VerboseCommandRecording); RDOC_DEBUG_CONFIG(bool, Vulkan_Debug_SingleSubmitFlushing, false, @@ -3146,20 +3148,29 @@ RDResult WrappedVulkan::ReadLogInitialisation(RDCFile *rdc, bool storeStructured SAFE_DELETE(sink); + const bool develMode = #if ENABLED(RDOC_DEVEL) - for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) - { - double dcount = double(it->second.count); - - RDCDEBUG( - "% 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s (%u)", - it->second.count, it->second.total, it->second.total / dcount, - double(it->second.totalsize) / (1024.0 * 1024.0), - double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), - GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); - } + true; +#else + false; #endif + if(Replay_Debug_PrintChunkTimings() || develMode) + { + for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it) + { + double dcount = double(it->second.count); + + RDCLOG( + "| % 5d chunks - Time: %9.3fms total/%9.3fms avg - Size: %8.3fMB total/%7.3fMB avg - %s " + "(%u)", + it->second.count, it->second.total, it->second.total / dcount, + double(it->second.totalsize) / (1024.0 * 1024.0), + double(it->second.totalsize) / (dcount * 1024.0 * 1024.0), + GetChunkName((uint32_t)it->first).c_str(), uint32_t(it->first)); + } + } + // steal the structured data for ourselves m_StructuredFile->Swap(*m_StoredStructuredData);