Handle OpModuleProcessed being in a separate section properly

This commit is contained in:
baldurk
2020-12-16 17:24:39 +00:00
parent 523af0f2b4
commit 402d43f915
5 changed files with 49 additions and 24 deletions
+29 -15
View File
@@ -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);
@@ -389,7 +389,9 @@ void Processor::Parse(const rdcarray<uint32_t> &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<uint32_t> &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 ||
@@ -491,7 +491,9 @@ struct Section
MemoryModel,
EntryPoints,
ExecutionMode,
Debug,
DebugStringSource,
DebugNames,
DebugModuleProcessed,
Annotations,
TypesVariablesConstants,
// handy aliases
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -2858,8 +2858,8 @@ static void CreatePSInputFetcher(rdcarray<uint32_t> &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)