Process source and global variable information from vulkan debug info

This commit is contained in:
baldurk
2022-02-04 16:45:14 +00:00
parent 0dbd579c10
commit c90a6a72fc
3 changed files with 37 additions and 0 deletions
@@ -946,6 +946,16 @@ void Processor::PostParse()
m_MemberDecorations.clear();
}
Iter Processor::GetID(Id id)
{
size_t offs = idOffsets[id];
if(offs)
return Iter(m_SPIRV, offs);
return Iter();
}
ShaderVariable Processor::MakeNULL(const DataType &type, uint64_t value)
{
ShaderVariable v("", 0, 0, 0, 0);
@@ -538,6 +538,8 @@ protected:
// after parsing - e.g. to do any deferred post-processing
virtual void PostParse();
Iter GetID(Id id);
ShaderVariable MakeNULL(const DataType &type, uint64_t value);
ShaderVariable EvaluateConstant(Id constID, const rdcarray<SpecConstant> &specInfo) const;
@@ -446,6 +446,31 @@ void Reflector::RegisterOp(Iter it)
{
loopBlocks.insert(curBlock);
}
else if(opdata.op == Op::ExtInst)
{
OpShaderDbg dbg(it);
// we don't care about much debug info for just reflection. Only pay attention to source files,
// and potential names of global variables that might be missing.
if(dbg.set == knownExtSet[ExtSet_ShaderDbg])
{
if(dbg.inst == ShaderDbg::CompilationUnit)
{
OpShaderDbg src(GetID(dbg.arg<Id>(2)));
sources.push_back({
(SourceLanguage)EvaluateConstant(dbg.arg<Id>(3), {}).value.u32v[0],
strings[src.arg<Id>(0)], src.params.size() > 1 ? strings[src.arg<Id>(1)] : rdcstr(),
});
}
else if(dbg.inst == ShaderDbg::GlobalVariable)
{
// copy the name string to the variable string only if it's empty. If it has a name already,
// we prefer that. If the variable is DebugInfoNone then we don't care about it's name.
if(strings[dbg.arg<Id>(7)].empty())
strings[dbg.arg<Id>(7)] = strings[dbg.arg<Id>(0)];
}
}
}
}
void Reflector::UnregisterOp(Iter it)