Skip to content

Commit

Permalink
Add a config option to print chunk timings in release
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Aug 29, 2024
1 parent 2cd1621 commit 62c86f6
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 37 deletions.
2 changes: 2 additions & 0 deletions renderdoc/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<rdcstr>, DXBC_Debug_SearchDirPaths, {},
Expand Down
30 changes: 21 additions & 9 deletions renderdoc/driver/d3d11/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -1519,19 +1522,28 @@ RDResult WrappedID3D11Device::ReadLogInitialisation(RDCFile *rdc, bool storeStru
}
}

const bool develMode =
#if ENABLED(RDOC_DEVEL)
for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it)
true;
#else
false;
#endif

if(Replay_Debug_PrintChunkTimings() || develMode)
{
double dcount = double(it->second.count);
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));
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));
}
}
#endif

GetReplay()->WriteFrameRecord().frameInfo.uncompressedFileSize =
rdc->GetSectionProperties(sectionIdx).uncompressedSize;
Expand Down
29 changes: 20 additions & 9 deletions renderdoc/driver/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down Expand Up @@ -4918,19 +4920,28 @@ RDResult WrappedID3D12Device::ReadLogInitialisation(RDCFile *rdc, bool storeStru
}
}

const bool develMode =
#if ENABLED(RDOC_DEVEL)
for(auto it = chunkInfos.begin(); it != chunkInfos.end(); ++it)
true;
#else
false;
#endif

if(Replay_Debug_PrintChunkTimings() || develMode)
{
double dcount = double(it->second.count);
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));
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));
}
}
#endif

GetReplay()->WriteFrameRecord().frameInfo.uncompressedFileSize =
rdc->GetSectionProperties(sectionIdx).uncompressedSize;
Expand Down
32 changes: 22 additions & 10 deletions renderdoc/driver/gl/gl_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@
#include "gl_driver.h"
#include <algorithm>
#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<uint64_t, GLWindowingData> WrappedOpenGL::m_ActiveContexts;

void WrappedOpenGL::BuildGLExtensions()
Expand Down Expand Up @@ -3508,19 +3511,28 @@ 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)
true;
#else
false;
#endif

if(Replay_Debug_PrintChunkTimings() || develMode)
{
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));
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));
}
}
#endif

// steal the structured data for ourselves
m_StructuredFile->Swap(*m_StoredStructuredData);
Expand Down
29 changes: 20 additions & 9 deletions renderdoc/driver/vulkan/vk_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -3146,19 +3148,28 @@ 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)
true;
#else
false;
#endif

if(Replay_Debug_PrintChunkTimings() || develMode)
{
double dcount = double(it->second.count);
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));
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));
}
}
#endif

// steal the structured data for ourselves
m_StructuredFile->Swap(*m_StoredStructuredData);
Expand Down

0 comments on commit 62c86f6

Please sign in to comment.