diff --git a/renderdoc/driver/shaders/spirv/spirv_editor.cpp b/renderdoc/driver/shaders/spirv/spirv_editor.cpp index e536a426e..eb81d6c69 100644 --- a/renderdoc/driver/shaders/spirv/spirv_editor.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_editor.cpp @@ -197,7 +197,7 @@ void Editor::SetName(Id id, const rdcstr &name) Iter it; // OpName/OpMemberName must be before OpModuleProcessed. - for(it = Begin(Section::Debug); it < End(Section::Debug); ++it) + for(it = Begin(Section::DebugNames); it < End(Section::DebugNames); ++it) { if(it.opcode() == Op::ModuleProcessed) break; @@ -212,18 +212,10 @@ void Editor::SetMemberName(Id id, uint32_t member, const rdcstr &name) { Operation op = OpMemberName(id, member, name); - Iter it; - - // OpName/OpMemberName must be before OpModuleProcessed. - for(it = Begin(Section::Debug); it < End(Section::Debug); ++it) - { - if(it.opcode() == Op::ModuleProcessed) - break; - } - - op.insertInto(m_SPIRV, it.offs()); - RegisterOp(Iter(m_SPIRV, it.offs())); - addWords(it.offs(), op.size()); + size_t offset = m_Sections[Section::DebugNames].endOffset; + op.insertInto(m_SPIRV, offset); + RegisterOp(Iter(m_SPIRV, offset)); + addWords(offset, op.size()); } void Editor::AddDecoration(const Operation &op) @@ -786,9 +778,31 @@ void main() { CheckSPIRV(ed, offsets); } - RemoveSection(spirv, offsets, rdcspv::Section::Debug); + RemoveSection(spirv, offsets, rdcspv::Section::DebugNames); - SECTION("Check with debug removed") + SECTION("Check with debug names removed") + { + rdcspv::Editor ed(spirv); + + ed.Prepare(); + + CheckSPIRV(ed, offsets); + } + + RemoveSection(spirv, offsets, rdcspv::Section::DebugStringSource); + + SECTION("Check with debug strings/sources removed") + { + rdcspv::Editor ed(spirv); + + ed.Prepare(); + + CheckSPIRV(ed, offsets); + } + + RemoveSection(spirv, offsets, rdcspv::Section::DebugModuleProcessed); + + SECTION("Check with module processed removed") { rdcspv::Editor ed(spirv); diff --git a/renderdoc/driver/shaders/spirv/spirv_processor.cpp b/renderdoc/driver/shaders/spirv/spirv_processor.cpp index 7fc08602b..80c7cce73 100644 --- a/renderdoc/driver/shaders/spirv/spirv_processor.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_processor.cpp @@ -389,7 +389,9 @@ void Processor::Parse(const rdcarray &spirvWords) // MemoryModel: REQUIRED (required by spec) // EntryPoints: REQUIRED (we assume) // ExecutionMode: OPTIONAL - // Debug: OPTIONAL + // DebugStringSource: OPTIONAL + // DebugNames: OPTIONAL + // DebugModuleProcessed: OPTIONAL // Annotations: OPTIONAL (in theory - would require empty shader) // TypesVariables: REQUIRED (must at least have the entry point function type) // Functions: REQUIRED (must have the entry point) @@ -430,10 +432,17 @@ void Processor::Parse(const rdcarray &spirvWords) START_SECTION(Section::ExecutionMode); } else if(opcode == Op::String || opcode == Op::Source || opcode == Op::SourceContinued || - opcode == Op::SourceExtension || opcode == Op::Name || opcode == Op::MemberName || - opcode == Op::ModuleProcessed) + opcode == Op::SourceExtension) { - START_SECTION(Section::Debug); + START_SECTION(Section::DebugStringSource); + } + else if(opcode == Op::Name || opcode == Op::MemberName) + { + START_SECTION(Section::DebugNames); + } + else if(opcode == Op::ModuleProcessed) + { + START_SECTION(Section::DebugModuleProcessed); } else if(opcode == Op::Decorate || opcode == Op::MemberDecorate || opcode == Op::GroupDecorate || opcode == Op::GroupMemberDecorate || opcode == Op::DecorationGroup || diff --git a/renderdoc/driver/shaders/spirv/spirv_processor.h b/renderdoc/driver/shaders/spirv/spirv_processor.h index 5499c2304..cbc6672ec 100644 --- a/renderdoc/driver/shaders/spirv/spirv_processor.h +++ b/renderdoc/driver/shaders/spirv/spirv_processor.h @@ -491,7 +491,9 @@ struct Section MemoryModel, EntryPoints, ExecutionMode, - Debug, + DebugStringSource, + DebugNames, + DebugModuleProcessed, Annotations, TypesVariablesConstants, // handy aliases diff --git a/renderdoc/driver/vulkan/vk_postvs.cpp b/renderdoc/driver/vulkan/vk_postvs.cpp index 3f52bc3e9..f3960ba26 100644 --- a/renderdoc/driver/vulkan/vk_postvs.cpp +++ b/renderdoc/driver/vulkan/vk_postvs.cpp @@ -420,8 +420,8 @@ static void ConvertToMeshOutputCompute(const ShaderReflection &refl, const SPIRV RDCASSERT(entryID); - for(rdcspv::Iter it = editor.Begin(rdcspv::Section::Debug), - end2 = editor.End(rdcspv::Section::Debug); + for(rdcspv::Iter it = editor.Begin(rdcspv::Section::DebugNames), + end2 = editor.End(rdcspv::Section::DebugNames); it < end2; ++it) { if(it.opcode() == rdcspv::Op::Name) diff --git a/renderdoc/driver/vulkan/vk_shaderdebug.cpp b/renderdoc/driver/vulkan/vk_shaderdebug.cpp index 46d354ae0..5c0280656 100644 --- a/renderdoc/driver/vulkan/vk_shaderdebug.cpp +++ b/renderdoc/driver/vulkan/vk_shaderdebug.cpp @@ -2858,8 +2858,8 @@ static void CreatePSInputFetcher(rdcarray &fragspv, uint32_t &structSt } // remove any OpName that refers to deleted IDs - functions or results - it = editor.Begin(rdcspv::Section::Debug); - end = editor.End(rdcspv::Section::Debug); + it = editor.Begin(rdcspv::Section::DebugNames); + end = editor.End(rdcspv::Section::DebugNames); while(it < end) { if(it.opcode() == rdcspv::Op::Name)