From c4b4c528a3d19af735009bb286b9455b38d3a6dd Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 2 Jun 2022 18:18:58 +0100 Subject: [PATCH] Add a testing option to step to DebugValue instructions --- .../driver/shaders/spirv/spirv_debug.cpp | 19 +++++++++++++++++-- renderdoc/driver/shaders/spirv/spirv_debug.h | 1 + .../shaders/spirv/spirv_debug_setup.cpp | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.cpp b/renderdoc/driver/shaders/spirv/spirv_debug.cpp index 41390db91..ea507569f 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug.cpp @@ -26,11 +26,15 @@ #include #include #include "common/formatting.h" +#include "core/settings.h" #include "maths/half_convert.h" #include "os/os_specific.h" #include "spirv_op_helpers.h" #include "var_dispatch_helpers.h" +RDOC_CONFIG(bool, Vulkan_Debug_StepToDebugValue, false, + "Treat DebugValue as a steppable executable instruction."); + static bool ContainsNaNInf(const ShaderVariable &var) { bool ret = false; @@ -581,8 +585,19 @@ void ThreadState::SkipIgnoredInstructions() { if(debugger.IsDebugExtInstSet(Id::fromWord(it.word(3)))) { - nextInstruction++; - continue; + if(Vulkan_Debug_StepToDebugValue()) + { + if(ShaderDbg(it.word(4)) != ShaderDbg::Value || !debugger.InDebugScope(nextInstruction)) + { + nextInstruction++; + continue; + } + } + else + { + nextInstruction++; + continue; + } } } diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 59fbcd838..c0c5266bd 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -350,6 +350,7 @@ public: const Decorations &GetDecorations(Id typeId); bool IsDebugExtInstSet(Id id) const; bool HasDebugInfo() const { return m_DebugInfo.valid; } + bool InDebugScope(uint32_t inst) const; rdcstr GetRawName(Id id) const; rdcstr GetHumanName(Id id); void AddSourceVars(rdcarray &sourceVars, const ShaderVariable &var, Id id); diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index 2c4310f23..c464cde10 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -2725,6 +2725,11 @@ bool Debugger::IsDebugExtInstSet(Id id) const return knownExtSet[ExtSet_ShaderDbg] == id; } +bool Debugger::InDebugScope(uint32_t inst) const +{ + return m_DebugInfo.lineScope.find(instructionOffsets[inst]) != m_DebugInfo.lineScope.end(); +} + const ScopeData *Debugger::GetScope(size_t offset) const { auto it = m_DebugInfo.lineScope.find(offset);