From 5af3a4e23be44d2c1668d9252a2390cdc8edd33f Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 29 Jul 2020 10:59:18 +0100 Subject: [PATCH] Add a debug option to embed the log file in captures --- renderdoc/api/replay/renderdoc_tostr.inl | 1 + renderdoc/api/replay/replay_enums.h | 7 +++++++ renderdoc/core/core.cpp | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/renderdoc/api/replay/renderdoc_tostr.inl b/renderdoc/api/replay/renderdoc_tostr.inl index d829b502a..c04b6cd62 100644 --- a/renderdoc/api/replay/renderdoc_tostr.inl +++ b/renderdoc/api/replay/renderdoc_tostr.inl @@ -1013,6 +1013,7 @@ rdcstr DoStringise(const SectionType &el) STRINGISE_ENUM_CLASS_NAMED(ResourceRenames, "renderdoc/ui/resrenames"); STRINGISE_ENUM_CLASS_NAMED(AMDRGPProfile, "amd/rgp/profile"); STRINGISE_ENUM_CLASS_NAMED(ExtendedThumbnail, "renderdoc/internal/exthumb"); + STRINGISE_ENUM_CLASS_NAMED(EmbeddedLogfile, "renderdoc/internal/logfile"); } END_ENUM_STRINGISE(); } diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index 0b002d846..ace253d75 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -86,6 +86,12 @@ version of RenderDoc that addes a new section type. They should be considered eq lossless. The name for this section will be "renderdoc/internal/exthumb". + +.. data:: EmbeddedLogfile + + This section contains the log file at the time of capture, for debugging. + + The name for this section will be "renderdoc/internal/logfile". )"); enum class SectionType : uint32_t { @@ -98,6 +104,7 @@ enum class SectionType : uint32_t ResourceRenames, AMDRGPProfile, ExtendedThumbnail, + EmbeddedLogfile, Count, }; diff --git a/renderdoc/core/core.cpp b/renderdoc/core/core.cpp index 278f7af84..a556c3a79 100644 --- a/renderdoc/core/core.cpp +++ b/renderdoc/core/core.cpp @@ -29,6 +29,7 @@ #include "api/replay/version.h" #include "common/common.h" #include "common/threading.h" +#include "core/settings.h" #include "hooks/hooks.h" #include "maths/formatpacking.h" #include "replay/replay_driver.h" @@ -44,6 +45,9 @@ #include "replay/renderdoc_serialise.inl" +RDOC_DEBUG_CONFIG(bool, Capture_Debug_SnapshotDiagnosticLog, false, + "Snapshot the diagnostic log at capture time and embed in the capture."); + void LogReplayOptions(const ReplayOptions &opts) { RDCLOG("%s API validation during replay", (opts.apiValidation ? "Enabling" : "Not enabling")); @@ -1681,6 +1685,22 @@ void RenderDoc::FinishCaptureWriting(RDCFile *rdc, uint32_t frameNumber) delete w; } + if(Capture_Debug_SnapshotDiagnosticLog()) + { + rdcstr logcontents = FileIO::logfile_readall(RDCGETLOGFILE()); + + SectionProperties props = {}; + props.type = SectionType::EmbeddedLogfile; + props.version = 1; + StreamWriter *w = rdc->WriteSection(props); + + w->Write(logcontents.data(), logcontents.size()); + + w->Finish(); + + delete w; + } + RDCLOG("Written to disk: %s", m_CurrentLogFile.c_str()); CaptureData cap(m_CurrentLogFile, Timing::GetUnixTimestamp(), rdc->GetDriver(), frameNumber);