Tweak to DXIL debugger cbuffer handling

Initialise the ShaderVariable for the handle to 0xCC
Only memory copy the bytes available (do not assume the source buffer is a multiple of 16 bytes in size)

Fixes non-determinism problem (exposed by root constant buffer of size four bytes)
This commit is contained in:
Jake Turner
2025-09-25 15:35:12 +01:00
parent fa40e51e7d
commit a5c3ee4b70
+4 -1
View File
@@ -2715,6 +2715,8 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
var.columns = 4;
var.name = StringFormat::Fmt("%s[%u]", result.name.c_str(), i);
var.rows = 1;
// Initialise to 0xCC to aid determinism and show unset values
memset(&var.value, 0XCC, sizeof(var.value));
}
// Memory copy from the cbuffer data into the cbuffer variable
@@ -2729,7 +2731,8 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
for(size_t i = 0; i < cbufferVar.members.size(); ++i)
{
ShaderVariable &var = cbufferVar.members[i];
memcpy(var.value.u32v.data(), data + offset, 16);
size_t countBytes = RDCMIN((size_t)16, cbufferData.size() - offset);
memcpy(var.value.u32v.data(), data + offset, countBytes);
offset += 16;
if(offset >= cbufferData.size())
break;