Add debug option for showing DebugValue opcodes

This commit is contained in:
baldurk
2022-06-02 18:13:29 +01:00
parent 21d4d4c017
commit c625f9dbd1
3 changed files with 32 additions and 0 deletions
@@ -23,10 +23,14 @@
******************************************************************************/
#include "common/formatting.h"
#include "core/settings.h"
#include "maths/half_convert.h"
#include "spirv_op_helpers.h"
#include "spirv_reflect.h"
RDOC_CONFIG(bool, Vulkan_Debug_ShowDebugValues, false,
"Show DebugValue instructions in shader disassembly.");
struct StructuredCFG
{
enum
@@ -1574,6 +1578,23 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint,
ret += ToStr(rdcspv::SourceLanguage(lang));
ret += ")";
}
else if(dbg.inst == ShaderDbg::Value && Vulkan_Debug_ShowDebugValues())
{
OpShaderDbg localVar(GetID(dbg.arg<Id>(0)));
ret += indent;
ret += "// DebugValue(";
ret += idName(dbg.arg<Id>(1));
ret += " = ";
ret += idName(localVar.arg<Id>(0));
ret += " ";
ret += idName(localVar.arg<Id>(2));
ret += ":";
ret += idName(localVar.arg<Id>(3));
if(dbg.params.size() > 3)
ret += " (subset)";
ret += ")";
}
else
{
continue;
@@ -960,6 +960,16 @@ Iter Processor::GetID(Id id)
return Iter();
}
ConstIter Processor::GetID(Id id) const
{
size_t offs = idOffsets[id];
if(offs)
return ConstIter(m_SPIRV, offs);
return ConstIter();
}
ShaderVariable Processor::MakeNULL(const DataType &type, uint64_t value)
{
ShaderVariable v("", 0, 0, 0, 0);
@@ -539,6 +539,7 @@ protected:
virtual void PostParse();
Iter GetID(Id id);
ConstIter GetID(Id id) const;
ShaderVariable MakeNULL(const DataType &type, uint64_t value);