From 0ee04850c163700d2844b964e6734f6a4917996f Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Mon, 12 May 2025 16:45:25 +0100 Subject: [PATCH] Spirv debugger ShaderViewer UI consistency fixes * use a NULL before value when variables are recreated after going out of scope i.e. in a loop * only add to the live list if m_State is not NULL (m_State can be NULL in EnterFunction() if HasDebugInfo() is false i.e. when called from EnterEntryPoint()) When generating variable changes from pointers: * only include variables which are live * do not include the base variable change in the list of extra changes --- .../driver/shaders/spirv/spirv_debug.cpp | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.cpp b/renderdoc/driver/shaders/spirv/spirv_debug.cpp index b6ad707e0..3475d8bb2 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug.cpp @@ -371,13 +371,21 @@ void ThreadState::WritePointerValue(Id pointer, const ShaderVariable &val) // for every other pointer, evaluate its value now before for(size_t i = 0; i < pointers.size(); i++) - changes[i].before = debugger.GetPointerValue(ids[pointers[i]]); + { + Id id = pointers[i]; + if(id != ptrid && live.contains(id)) + changes[i].before = debugger.GetPointerValue(ids[id]); + } debugger.WriteThroughPointer(var, val); // now evaluate the value after for(size_t i = 0; i < pointers.size(); i++) - changes[i].after = debugger.GetPointerValue(ids[pointers[i]]); + { + Id id = pointers[i]; + if(id != ptrid && live.contains(id)) + changes[i].after = debugger.GetPointerValue(ids[id]); + } // if the pointer we're writing is one of the aliased pointers, be sure we add it even if // it's a no-op change @@ -385,8 +393,11 @@ void ThreadState::WritePointerValue(Id pointer, const ShaderVariable &val) if(ptrIdx >= 0) { - m_State->changes.push_back(changes[ptrIdx]); - changes.erase(ptrIdx); + if(pointer != ptrid) + { + m_State->changes.push_back(changes[ptrIdx]); + changes.erase(ptrIdx); + } } // remove any no-op changes. Some pointers might point to the same ID but a child that @@ -439,8 +450,14 @@ void ThreadState::SetDst(Id id, const ShaderVariable &val) lastWrite[id] = m_State ? m_State->stepIndex : nextInstruction; - auto it = std::lower_bound(live.begin(), live.end(), id); - live.insert(it - live.begin(), id); + bool wasLive = false; + if(m_State) + { + auto it = std::lower_bound(live.begin(), live.end(), id); + wasLive = (it != live.end() && *it == id); + if(!wasLive) + live.insert(it - live.begin(), id); + } if(val.type == VarType::GPUPointer && !debugger.IsPhysicalPointer(val)) { @@ -455,7 +472,8 @@ void ThreadState::SetDst(Id id, const ShaderVariable &val) if(m_State) { ShaderVariableChange change; - change.before = debugger.GetPointerValue(prev); + if(wasLive) + change.before = debugger.GetPointerValue(prev); change.after = debugger.GetPointerValue(ids[id]); m_State->changes.push_back(change); }