From 3cc79316b3f41ef2102eedc62ab106319d609984 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 6 Mar 2016 00:13:16 +0100 Subject: [PATCH] Add a GUID for the shader debug info that is required in a PRIV section --- renderdoc/api/app/renderdoc_app.h | 14 ++++++++++ .../driver/shaders/dxbc/dxbc_inspect.cpp | 27 ++++++++++++++----- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/renderdoc/api/app/renderdoc_app.h b/renderdoc/api/app/renderdoc_app.h index 0e59b4d43..67c179ad0 100644 --- a/renderdoc/api/app/renderdoc_app.h +++ b/renderdoc/api/app/renderdoc_app.h @@ -39,7 +39,21 @@ #ifdef __cplusplus extern "C" { #endif + +////////////////////////////////////////////////////////////////////////////////////////////////// +// Constants not used directly in below API + +// This is a GUID/magic value used for when applications pass a path where shader debug +// information can be found to match up with a stripped shader. +// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_value +#define RENDERDOC_ShaderDebugMagicValue_struct { 0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff } + +// as an alternative when you want a byte array (assuming x86 endianness): +#define RENDERDOC_ShaderDebugMagicValue_bytearray { 0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff } +// truncated version when only a uint64_t is available (e.g. Vulkan tags): +#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL + ////////////////////////////////////////////////////////////////////////////////////////////////// // RenderDoc capture options // diff --git a/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp b/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp index 5e6471de4..d9fc737e8 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_inspect.cpp @@ -27,6 +27,7 @@ #include "common/common.h" #include "serialise/serialiser.h" #include "serialise/string_utils.h" +#include "api/app/renderdoc_app.h" #include "dxbc_inspect.h" #include "dxbc_sdbg.h" #include "dxbc_spdb.h" @@ -160,10 +161,19 @@ struct PRIVHeader { uint32_t fourcc; // "PRIV" uint32_t chunkLength; // length of this chunk + + GUID debugInfoGUID; // GUID/magic number, since PRIV data could be used for something else. + // Set to the value of RENDERDOC_ShaderDebugMagicValue from + // renderdoc_app.h which can also be used as a GUID to set the path + // at runtime via SetPrivateData (see documentation) + + static const GUID RENDERDOC_ShaderDebugMagicValue; void* data; }; +const GUID PRIVHeader::RENDERDOC_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_struct; + struct SIGNElement { uint32_t nameOffset; // relative to the same offset base position as others in similar chunks - after FourCC and chunk length. @@ -517,14 +527,17 @@ string DXBCFile::GetDebugBinaryPath(const void *ByteCode, size_t ByteCodeLength) if(*fourcc == FOURCC_PRIV) { PRIVHeader *privHeader = (PRIVHeader *)fourcc; - const char* pathData = (char*)&privHeader->data; - size_t pathLength = strnlen(pathData, privHeader->chunkLength); - - if(privHeader->chunkLength == (pathLength + 1)) + if(privHeader->debugInfoGUID == PRIVHeader::RENDERDOC_ShaderDebugMagicValue) { - debugPath.append(pathData, pathData + pathLength); - return debugPath; - } + const char* pathData = (char*)&privHeader->data; + size_t pathLength = strnlen(pathData, privHeader->chunkLength); + + if(privHeader->chunkLength == (sizeof(GUID) + pathLength + 1)) + { + debugPath.append(pathData, pathData + pathLength); + return debugPath; + } + } } }