Skip to content

Commit d76d0c3

Browse files
committedDec 18, 2024
Improve handling of Load and Atomic operations on global memory
Remove assert about bool being 8-bits
1 parent ed9c24a commit d76d0c3

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed
 

‎renderdoc/driver/shaders/dxil/dxil_debug.cpp

+28-7
Original file line numberDiff line numberDiff line change
@@ -4100,9 +4100,26 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
41004100
Id ptrId = GetArgumentId(0);
41014101
if(ptrId == DXILDebug::INVALID_ID)
41024102
break;
4103-
RDCASSERT(m_Memory.m_AllocPointers.count(ptrId) == 1);
4103+
4104+
auto itPtr = m_Memory.m_AllocPointers.find(ptrId);
4105+
RDCASSERT(itPtr != m_Memory.m_AllocPointers.end());
4106+
4107+
const MemoryTracking::AllocPointer &ptr = itPtr->second;
4108+
Id baseMemoryId = ptr.baseMemoryId;
4109+
4110+
auto itAlloc = m_Memory.m_Allocs.find(baseMemoryId);
4111+
RDCASSERT(itAlloc != m_Memory.m_Allocs.end());
4112+
const MemoryTracking::Alloc &alloc = itAlloc->second;
41044113
ShaderVariable arg;
4105-
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, arg));
4114+
if(alloc.global)
4115+
{
4116+
RDCASSERT(IsVariableAssigned(baseMemoryId));
4117+
arg = m_Variables[baseMemoryId];
4118+
}
4119+
else
4120+
{
4121+
RDCASSERT(GetShaderVariable(inst.args[0], opCode, dxOpCode, arg));
4122+
}
41064123
result.value = arg.value;
41074124
break;
41084125
}
@@ -5098,7 +5115,7 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
50985115
RDCASSERT(baseMemoryBackingPtr);
50995116
RDCASSERTNOTEQUAL(baseMemoryId, DXILDebug::INVALID_ID);
51005117

5101-
RDCASSERTEQUAL(resultId, DXILDebug::INVALID_ID);
5118+
RDCASSERTNOTEQUAL(resultId, DXILDebug::INVALID_ID);
51025119
RDCASSERT(IsVariableAssigned(baseMemoryId));
51035120
const ShaderVariable a = m_Variables[baseMemoryId];
51045121

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

5110-
ShaderVariable res;
5127+
ShaderVariable res = a;
51115128

51125129
if(opCode == Operation::AtomicExchange)
51135130
{
@@ -5417,8 +5434,13 @@ bool ThreadState::GetShaderVariableHelper(const DXIL::Value *dxilValue, DXIL::Op
54175434
}
54185435
else if(const GlobalVar *gv = cast<GlobalVar>(dxilValue))
54195436
{
5420-
var.value.u64v[0] = gv->initialiser->getU64();
5421-
return true;
5437+
if(gv->initialiser)
5438+
{
5439+
var.value.u64v[0] = gv->initialiser->getU64();
5440+
return true;
5441+
}
5442+
RDCERR("Unhandled DXIL GlobalVar no initialiser");
5443+
return false;
54225444
}
54235445

54245446
if(const Instruction *inst = cast<Instruction>(dxilValue))
@@ -6246,7 +6268,6 @@ const TypeData &Debugger::AddDebugType(const DXIL::Metadata *typeMD)
62466268
{
62476269
case DW_ATE_boolean:
62486270
{
6249-
RDCASSERTEQUAL(sizeInBits, 8);
62506271
typeData.type = VarType ::Bool;
62516272
break;
62526273
}

0 commit comments

Comments
 (0)