Spirv Debugger mark pointer stores and memory copies as live

Added helper method SetLive() used by SetDst() and WritePointerValue()
This commit is contained in:
Jake Turner committed 2025-11-26 08:19:57 +13:00
1 parent f5e63aa838
commit 21a699e339
2 files changed
+21 -10

No files matched your search

+20 -10
View File
@@ -387,6 +387,10 @@ DeviceOpResult ThreadState::WritePointerValue(Id pointer, const ShaderVariable &
if(opResult == DeviceOpResult::NeedsDevice)
return DeviceOpResult::NeedsDevice;
// Mark the pointer as being live
bool wasLive = SetLive(pointer);
bool baseWasLive = (pointer == ptrid) ? wasLive : true;
rdcarray<ShaderVariableChange> changes;
rdcarray<Id> &pointers = pointersForId[ptrid];
@@ -451,8 +455,8 @@ DeviceOpResult ThreadState::WritePointerValue(Id pointer, const ShaderVariable &
SPIRV_DEBUG_RDCASSERTEQUAL(opResult, DeviceOpResult::Succeeded);
// if this is the first local write, mark this variable as becoming alive here, instead of at
// its declaration
if(firstLocalWrite)
// its declaration or if the variable wasn't live
if(firstLocalWrite || !baseWasLive)
basechange.before = {};
pendingDebugState.changes.push_back(basechange);
@@ -489,6 +493,19 @@ void ThreadState::DebugBreak()
pendingDebugState.flags |= ShaderEvents::DebugBreak;
}
bool ThreadState::SetLive(Id id)
{
bool wasLive = false;
if(hasDebugState)
{
auto it = std::lower_bound(live.begin(), live.end(), id);
wasLive = (it != live.end() && *it == id);
if(!wasLive)
live.insert(it - live.begin(), id);
}
return wasLive;
}
void ThreadState::SetDst(Id id, const ShaderVariable &val)
{
// Waiting for result i.e. from the GPU or replay thread
@@ -525,14 +542,7 @@ void ThreadState::SetDst(Id id, const ShaderVariable &val)
lastWrite[id] = hasDebugState ? stepIndex : nextInstruction;
bool wasLive = false;
if(hasDebugState)
{
auto it = std::lower_bound(live.begin(), live.end(), id);
wasLive = (it != live.end() && *it == id);
if(!wasLive)
live.insert(it - live.begin(), id);
}
bool wasLive = SetLive(id);
if(val.type == VarType::GPUPointer && !debugger.IsPhysicalPointer(val))
{
@@ -433,6 +433,7 @@ struct ThreadState
private:
void EnterFunction(const rdcarray<Id> &arguments);
void SetDst(Id id, const ShaderVariable &val);
bool SetLive(Id id);
void ProcessScopeChange(const rdcarray<Id> &oldLive, const rdcarray<Id> &newLive);
void JumpToLabel(Id target);
bool ReferencePointer(Id id);