Skip to content

Commit 730de07

Browse files
committed
DXIL RD Fixes to MakeCBufferRegisterStr()
Changed array offset handling Added TODO about handling double vectors, the load might not start at x component Improved handling of variable offset for when the offset is within a variable i.e. matrix row, array element. Removed unused function GetCBufferVariableTypeName()
1 parent 713894d commit 730de07

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

renderdoc/driver/shaders/dxil/dxil_disassemble.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,12 +1018,6 @@ static rdcstr GetResourceTypeName(const Type *type)
10181018
return "UNHANDLED RESOURCE TYPE";
10191019
};
10201020

1021-
rdcstr GetCBufferVariableTypeName(const DXBC::CBufferVariableType &type)
1022-
{
1023-
rdcstr ret;
1024-
return ret;
1025-
}
1026-
10271021
rdcstr Program::GetHandleAlias(const rdcstr &handleStr) const
10281022
{
10291023
auto it = m_SsaAliases.find(handleStr);
@@ -2585,7 +2579,7 @@ static rdcstr MakeCBufferRegisterStr(uint32_t reg, uint32_t bytesPerElement,
25852579
if(var)
25862580
{
25872581
ret += handleStr + "." + prefix + var->name;
2588-
uint32_t varOffset = regOffset - baseOffset;
2582+
int32_t varOffset = baseOffset - regOffset;
25892583

25902584
// if it's an array, add the index based on the relative index to the base offset
25912585
if(var->type.elements > 1)
@@ -2596,19 +2590,19 @@ static rdcstr MakeCBufferRegisterStr(uint32_t reg, uint32_t bytesPerElement,
25962590
byteSize = AlignUp16(byteSize);
25972591

25982592
const uint32_t elementSize = byteSize / var->type.elements;
2599-
const uint32_t elementIndex = varOffset / elementSize;
2593+
const uint32_t elementIndex = abs(varOffset) / elementSize;
26002594

26012595
ret += StringFormat::Fmt("[%u]", elementIndex);
26022596

2603-
// subtract off so that if there's any further offset, it can be processed
2604-
varOffset -= elementIndex;
2597+
// add on so that if there's any further offset, it can be processed
2598+
varOffset += elementIndex * elementSize;
26052599
}
26062600

26072601
// or if it's a matrix
26082602
if((var->type.varClass == DXBC::CLASS_MATRIX_ROWS && var->type.cols > 1) ||
26092603
(var->type.varClass == DXBC::CLASS_MATRIX_COLUMNS && var->type.rows > 1))
26102604
{
2611-
ret += StringFormat::Fmt("[%u]", varOffset / 16);
2605+
ret += StringFormat::Fmt("[%u]", abs(varOffset) / 16);
26122606
}
26132607
// or if it's a vector
26142608
if((var->type.varClass == DXBC::CLASS_VECTOR && var->type.cols > 1) ||
@@ -2620,6 +2614,7 @@ static rdcstr MakeCBufferRegisterStr(uint32_t reg, uint32_t bytesPerElement,
26202614
uint32_t byteSize = var->type.bytesize;
26212615
const uint32_t elementSize = byteSize / var->type.cols;
26222616
const char *swizzle = "xyzw";
2617+
// TODO: handle double vectors : the load might start part way through
26232618
ret += ".x";
26242619
offset += elementSize;
26252620
for(uint32_t c = 1; c < var->type.cols; ++c)
@@ -2632,9 +2627,7 @@ static rdcstr MakeCBufferRegisterStr(uint32_t reg, uint32_t bytesPerElement,
26322627
offset += elementSize;
26332628
}
26342629
}
2635-
2636-
offset = var->offset + var->type.bytesize;
2637-
offset -= regOffset;
2630+
offset = varOffset + var->type.bytesize;
26382631
}
26392632
else
26402633
{

0 commit comments

Comments
 (0)