Skip to content

Commit 2aaac27

Browse files
committed
AtomicStore, Atomic* fixes
Use the allocation size of the pointer argument not the allocation size of the memory backing variable (stack or global) For Atomic* operations: * use the pointer argument as the variable input instead of the memory backing variable (static or global) * copy just the res value into the result variable instead of the whole res variable * use the pointer argument variable as the source pointer argument instead of the memory backing variable * record changes to the pointer argument variable as well as to the memory backing variable
1 parent 2759ebf commit 2aaac27

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

renderdoc/driver/shaders/dxil/dxil_debug.cpp

+22-9
Original file line numberDiff line numberDiff line change
@@ -4155,11 +4155,11 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
41554155
const MemoryTracking::AllocPointer &ptr = itPtr->second;
41564156
baseMemoryId = ptr.baseMemoryId;
41574157
baseMemoryBackingPtr = ptr.backingMemory;
4158+
allocSize = ptr.size;
41584159

41594160
auto itAlloc = m_Memory.m_Allocs.find(baseMemoryId);
41604161
RDCASSERT(itAlloc != m_Memory.m_Allocs.end());
41614162
const MemoryTracking::Alloc &alloc = itAlloc->second;
4162-
allocSize = alloc.size;
41634163
allocMemoryBackingPtr = alloc.backingMemory;
41644164

41654165
RDCASSERT(baseMemoryBackingPtr);
@@ -5124,20 +5124,20 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
51245124
const MemoryTracking::AllocPointer &ptr = itPtr->second;
51255125
baseMemoryId = ptr.baseMemoryId;
51265126
baseMemoryBackingPtr = ptr.backingMemory;
5127+
allocSize = ptr.size;
51275128

51285129
auto itAlloc = m_Memory.m_Allocs.find(baseMemoryId);
51295130
RDCASSERT(itAlloc != m_Memory.m_Allocs.end());
51305131
const MemoryTracking::Alloc &alloc = itAlloc->second;
5131-
allocSize = alloc.size;
51325132
allocMemoryBackingPtr = alloc.backingMemory;
51335133
}
51345134

51355135
RDCASSERT(baseMemoryBackingPtr);
51365136
RDCASSERTNOTEQUAL(baseMemoryId, DXILDebug::INVALID_ID);
51375137

51385138
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];
51415141

51425142
size_t newValueArgIdx = (opCode == Operation::CompareExchange) ? 2 : 1;
51435143
ShaderVariable b;
@@ -5252,21 +5252,33 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
52525252
UpdateBackingMemoryFromVariable(baseMemoryBackingPtr, allocSize, res);
52535253

52545254
ShaderVariableChange change;
5255-
change.before = a;
5255+
if(m_State)
5256+
change.before = a;
52565257

52575258
UpdateMemoryVariableFromBackingMemory(baseMemoryId, allocMemoryBackingPtr);
52585259

52595260
// record the change to the base memory variable
5260-
change.after = m_Variables[baseMemoryId];
52615261
if(m_State)
5262+
{
5263+
change.after = m_Variables[baseMemoryId];
52625264
m_State->changes.push_back(change);
5265+
}
52635266

5267+
// record the change to the ptr variable value
5268+
RDCASSERT(IsVariableAssigned(ptrId));
5269+
if(m_State)
5270+
change.before = m_Variables[ptrId];
52645271
// 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+
52665280
RDCASSERT(IsVariableAssigned(ptrId));
5267-
result = m_Variables[ptrId];
52685281
result.value = res.value;
5269-
resultId = ptrId;
52705282
break;
52715283
}
52725284
case Operation::AddrSpaceCast:
@@ -5626,6 +5638,7 @@ void ThreadState::UpdateMemoryVariableFromBackingMemory(Id memoryId, const void
56265638
{
56275639
for(uint32_t i = 0; i < baseMemory.members.size(); ++i)
56285640
{
5641+
RDCASSERT(elementSize < sizeof(ShaderValue), elementSize);
56295642
memcpy(&baseMemory.members[i].value.f32v[0], src, elementSize);
56305643
src += elementSize;
56315644
}

0 commit comments

Comments
 (0)