Skip to content

Commit

Permalink
Improve handling of Load and Atomic operations on global memory
Browse files Browse the repository at this point in the history
Remove assert about bool being 8-bits
  • Loading branch information
Zorro666 committed Dec 18, 2024
1 parent ed9c24a commit d76d0c3
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4100,9 +4100,26 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
Id ptrId = GetArgumentId(0);
if(ptrId == DXILDebug::INVALID_ID)
break;
RDCASSERT(m_Memory.m_AllocPointers.count(ptrId) == 1);

auto itPtr = m_Memory.m_AllocPointers.find(ptrId);
RDCASSERT(itPtr != m_Memory.m_AllocPointers.end());

const MemoryTracking::AllocPointer &ptr = itPtr->second;
Id baseMemoryId = ptr.baseMemoryId;

auto itAlloc = m_Memory.m_Allocs.find(baseMemoryId);
RDCASSERT(itAlloc != m_Memory.m_Allocs.end());
const MemoryTracking::Alloc &alloc = itAlloc->second;
ShaderVariable arg;
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, arg));
if(alloc.global)
{
RDCASSERT(IsVariableAssigned(baseMemoryId));
arg = m_Variables[baseMemoryId];
}
else
{
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, arg));
}
result.value = arg.value;
break;
}
Expand Down Expand Up @@ -5098,7 +5115,7 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
RDCASSERT(baseMemoryBackingPtr);
RDCASSERTNOTEQUAL(baseMemoryId, DXILDebug::INVALID_ID);

RDCASSERTEQUAL(resultId, DXILDebug::INVALID_ID);
RDCASSERTNOTEQUAL(resultId, DXILDebug::INVALID_ID);
RDCASSERT(IsVariableAssigned(baseMemoryId));
const ShaderVariable a = m_Variables[baseMemoryId];

Expand All @@ -5107,7 +5124,7 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
RDCASSERT(GetShaderVariable(inst.args[newValueArgIdx], opCode, dxOpCode, b));
const uint32_t c = 0;

ShaderVariable res;
ShaderVariable res = a;

if(opCode == Operation::AtomicExchange)
{
Expand Down Expand Up @@ -5417,8 +5434,13 @@ bool ThreadState::GetShaderVariableHelper(const DXIL::Value *dxilValue, DXIL::Op
}
else if(const GlobalVar *gv = cast<GlobalVar>(dxilValue))
{
var.value.u64v[0] = gv->initialiser->getU64();
return true;
if(gv->initialiser)
{
var.value.u64v[0] = gv->initialiser->getU64();
return true;
}
RDCERR("Unhandled DXIL GlobalVar no initialiser");
return false;
}

if(const Instruction *inst = cast<Instruction>(dxilValue))
Expand Down Expand Up @@ -6246,7 +6268,6 @@ const TypeData &Debugger::AddDebugType(const DXIL::Metadata *typeMD)
{
case DW_ATE_boolean:
{
RDCASSERTEQUAL(sizeInBits, 8);
typeData.type = VarType ::Bool;
break;
}
Expand Down

0 comments on commit d76d0c3

Please sign in to comment.