From 309a2aaded4b09134362d7a3752ddd85321e8c67 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 23 Feb 2021 12:00:26 +0000 Subject: [PATCH] Add variable debug variables when we have debug info * We don't want to wait until the first store to do this, since the source variables are added at the appropriate scope - even before the first store. --- renderdoc/driver/shaders/spirv/spirv_debug.cpp | 9 +++++++-- renderdoc/driver/shaders/spirv/spirv_debug.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.cpp b/renderdoc/driver/shaders/spirv/spirv_debug.cpp index a0a7b3a72..ce3b7b26f 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug.cpp @@ -184,9 +184,14 @@ void ThreadState::EnterFunction(const rdcarray &arguments) frame->locals.resize(numVars); - // don't add source vars for variables, we'll add it on the first store ShaderDebugState *state = m_State; - m_State = NULL; + + // don't add variables if we don't have debug info, we'll add it on the first store to reduce + // noise on unoptimised shaders with lots of variables and no scope information. However if we + // have debug info we'll add the variable immediately because the source variable will only be + // added at the correct scope and we want to display that before it's stored to. + if(!debugger.HasDebugInfo()) + m_State = NULL; size_t i = 0; // handle any variable declarations diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 83c7e7e6f..cc7c205cb 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -289,6 +289,7 @@ public: const DataType &GetTypeForId(Id ssaId); const Decorations &GetDecorations(Id typeId); bool IsDebugExtInstSet(Id id) const; + bool HasDebugInfo() const { return m_DebugInfo.valid; } rdcstr GetRawName(Id id) const; rdcstr GetHumanName(Id id); void AddSourceVars(rdcarray &sourceVars, const ShaderVariable &var, Id id);