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
This commit is contained in:
Jake Turner committed 2025-05-14 18:11:05 +01:00
1 parent 8dcf051d99
commit 0ee04850c1
1 file changed
+25 -7
+25 -7
View File
@@ -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);
}