@@ -4155,11 +4155,11 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
4155
4155
const MemoryTracking::AllocPointer &ptr = itPtr->second ;
4156
4156
baseMemoryId = ptr.baseMemoryId ;
4157
4157
baseMemoryBackingPtr = ptr.backingMemory ;
4158
+ allocSize = ptr.size ;
4158
4159
4159
4160
auto itAlloc = m_Memory.m_Allocs .find (baseMemoryId);
4160
4161
RDCASSERT (itAlloc != m_Memory.m_Allocs .end ());
4161
4162
const MemoryTracking::Alloc &alloc = itAlloc->second ;
4162
- allocSize = alloc.size ;
4163
4163
allocMemoryBackingPtr = alloc.backingMemory ;
4164
4164
4165
4165
RDCASSERT (baseMemoryBackingPtr);
@@ -5124,20 +5124,20 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
5124
5124
const MemoryTracking::AllocPointer &ptr = itPtr->second ;
5125
5125
baseMemoryId = ptr.baseMemoryId ;
5126
5126
baseMemoryBackingPtr = ptr.backingMemory ;
5127
+ allocSize = ptr.size ;
5127
5128
5128
5129
auto itAlloc = m_Memory.m_Allocs .find (baseMemoryId);
5129
5130
RDCASSERT (itAlloc != m_Memory.m_Allocs .end ());
5130
5131
const MemoryTracking::Alloc &alloc = itAlloc->second ;
5131
- allocSize = alloc.size ;
5132
5132
allocMemoryBackingPtr = alloc.backingMemory ;
5133
5133
}
5134
5134
5135
5135
RDCASSERT (baseMemoryBackingPtr);
5136
5136
RDCASSERTNOTEQUAL (baseMemoryId, DXILDebug::INVALID_ID);
5137
5137
5138
5138
RDCASSERTNOTEQUAL (resultId, DXILDebug::INVALID_ID);
5139
- RDCASSERT (IsVariableAssigned (baseMemoryId ));
5140
- const ShaderVariable a = m_Variables[baseMemoryId ];
5139
+ RDCASSERT (IsVariableAssigned (ptrId ));
5140
+ const ShaderVariable a = m_Variables[ptrId ];
5141
5141
5142
5142
size_t newValueArgIdx = (opCode == Operation::CompareExchange) ? 2 : 1 ;
5143
5143
ShaderVariable b;
@@ -5252,21 +5252,33 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
5252
5252
UpdateBackingMemoryFromVariable (baseMemoryBackingPtr, allocSize, res);
5253
5253
5254
5254
ShaderVariableChange change;
5255
- change.before = a;
5255
+ if (m_State)
5256
+ change.before = a;
5256
5257
5257
5258
UpdateMemoryVariableFromBackingMemory (baseMemoryId, allocMemoryBackingPtr);
5258
5259
5259
5260
// record the change to the base memory variable
5260
- change.after = m_Variables[baseMemoryId];
5261
5261
if (m_State)
5262
+ {
5263
+ change.after = m_Variables[baseMemoryId];
5262
5264
m_State->changes .push_back (change);
5265
+ }
5263
5266
5267
+ // record the change to the ptr variable value
5268
+ RDCASSERT (IsVariableAssigned (ptrId));
5269
+ if (m_State)
5270
+ change.before = m_Variables[ptrId];
5264
5271
// Update the ptr variable value
5265
- // Set the result to be the ptr variable which will then be recorded as a change
5272
+ m_Variables[ptrId].value = res.value ;
5273
+
5274
+ if (m_State)
5275
+ {
5276
+ change.after = m_Variables[ptrId];
5277
+ m_State->changes .push_back (change);
5278
+ }
5279
+
5266
5280
RDCASSERT (IsVariableAssigned (ptrId));
5267
- result = m_Variables[ptrId];
5268
5281
result.value = res.value ;
5269
- resultId = ptrId;
5270
5282
break ;
5271
5283
}
5272
5284
case Operation::AddrSpaceCast:
@@ -5626,6 +5638,7 @@ void ThreadState::UpdateMemoryVariableFromBackingMemory(Id memoryId, const void
5626
5638
{
5627
5639
for (uint32_t i = 0 ; i < baseMemory.members .size (); ++i)
5628
5640
{
5641
+ RDCASSERT (elementSize < sizeof (ShaderValue), elementSize);
5629
5642
memcpy (&baseMemory.members [i].value .f32v [0 ], src, elementSize);
5630
5643
src += elementSize;
5631
5644
}
0 commit comments