From 0bd07bf283d68f4922dc91f506fb1f5733b80e35 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 10 Dec 2025 21:51:33 +1300 Subject: [PATCH] Connect Vk and DXBC Shader Debug files to dependent files Core API Add any found external shader debug file as a tracked dependency. If external shader file is not found on disk, try to find it in the loaded tracked file data. Use the shader debug filename reference as the dependency nickname : this might be an absolute path, relative path or a hash. --- .../driver/shaders/dxbc/dxbc_container.cpp | 18 ++++++++++++- renderdoc/driver/vulkan/vk_info.cpp | 25 ++++++++++++------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp index e77fe6908..ef70ba7f7 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp @@ -125,7 +125,10 @@ struct DebugFile void ReadAndProcess(bool lz4, const rdcfixedarray &desiredHash) { FileIO::ReadAll(path, contents); - + Process(lz4, desiredHash); + } + void Process(bool lz4, const rdcfixedarray &desiredHash) + { if(lz4) { bytebuf decompressed; @@ -1517,6 +1520,7 @@ void DXBCContainer::TryFetchSeparateDebugInfo(bytebuf &byteCode, const rdcstr &d DebugFile found; + rdcstr nickname = originalPath; // keep searching until we've exhausted all possible path options, or we've found a file that // opens and (optionally if we have it matches the hash we're looking for) rdcstr tempPath = originalPath; @@ -1609,12 +1613,24 @@ void DXBCContainer::TryFetchSeparateDebugInfo(bytebuf &byteCode, const rdcstr &d } } + // Try to retrieve debug file from the externally referenced files in the capture + if(found.empty()) + { + if(RenderDoc::Inst().GetTrackedFileData(nickname, found.contents)) + { + found.path = nickname; + found.Process(lz4, desiredHash); + } + } + if(found.empty()) { RDCDEBUG("Couldn't find pdb for %s", originalPath.c_str()); return; } + RenderDoc::Inst().AddTrackedFileReference(nickname, found.path); + if(found.pdb) { m_DebugShaderBlob = found.contents; diff --git a/renderdoc/driver/vulkan/vk_info.cpp b/renderdoc/driver/vulkan/vk_info.cpp index f1ebb2ed5..153fdd20b 100644 --- a/renderdoc/driver/vulkan/vk_info.cpp +++ b/renderdoc/driver/vulkan/vk_info.cpp @@ -2762,6 +2762,7 @@ void VulkanCreationInfo::ShaderModule::Reinit() size_t numSearchPaths = searchPaths.size(); + rdcstr foundFname = originalPath; rdcstr foundPath; // keep searching until we've exhausted all possible path options, or we've found a file that @@ -2804,19 +2805,26 @@ void VulkanCreationInfo::ShaderModule::Reinit() } } + // Try to retrieve debug file from the externally referenced files in the capture + bytebuf debugBytecode; if(originalShaderFile == NULL) - return; - - FileIO::fseek64(originalShaderFile, 0L, SEEK_END); - uint64_t originalShaderSize = FileIO::ftell64(originalShaderFile); - FileIO::fseek64(originalShaderFile, 0, SEEK_SET); - { - bytebuf debugBytecode; + if(!RenderDoc::Inst().GetTrackedFileData(foundFname, debugBytecode)) + return; + } + else + { + FileIO::fseek64(originalShaderFile, 0L, SEEK_END); + uint64_t originalShaderSize = FileIO::ftell64(originalShaderFile); + FileIO::fseek64(originalShaderFile, 0, SEEK_SET); debugBytecode.resize((size_t)originalShaderSize); FileIO::fread(&debugBytecode[0], sizeof(byte), (size_t)originalShaderSize, originalShaderFile); + FileIO::fclose(originalShaderFile); + originalShaderFile = NULL; + } + { if(lz4) { rdcarray decompressed; @@ -2858,10 +2866,9 @@ void VulkanCreationInfo::ShaderModule::Reinit() if(!reflTest.GetSPIRV().empty()) { spirv = reflTest; + RenderDoc::Inst().AddTrackedFileReference(foundFname, foundPath); } } - - FileIO::fclose(originalShaderFile); } void VulkanCreationInfo::ShaderModuleReflection::Init(VulkanResourceManager *resourceMan,