Skip to content

Commit

Permalink
Improve handling of Matrix and Vector debug source mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorro666 committed Dec 19, 2024
1 parent 02c187f commit 48e73fb
Showing 1 changed file with 35 additions and 39 deletions.
74 changes: 35 additions & 39 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7145,7 +7145,7 @@ void Debugger::ParseDebugData()
usage->rows = rows;
usage->columns = columns;

if(bytesRemaining > 0)
if((bytesRemaining > 0) && (bytesRemaining != scalar.sizeInBytes * rows * columns))
{
if(usage->children.isEmpty())
{
Expand Down Expand Up @@ -7179,6 +7179,8 @@ void Debugger::ParseDebugData()
}
RDCASSERTEQUAL(usage->children.size(), rows);

// assigning to a vector (row or column)
uint32_t vecSize = (typeWalk->colMajorMat) ? columns : rows;
// assigning to a single element
if(bytesRemaining == scalar.sizeInBytes)
{
Expand Down Expand Up @@ -7224,51 +7226,46 @@ void Debugger::ParseDebugData()
usage->children[row].emitSourceVar = true;
}
}
else
// Assigning to a row/col
else if(bytesRemaining == scalar.sizeInBytes * vecSize)
{
// assigning to a vector (row or column)
uint32_t vecSize = (typeWalk->colMajorMat) ? columns : rows;
if(bytesRemaining == scalar.sizeInBytes * vecSize)
uint32_t componentIndex = byteOffset / scalar.sizeInBytes;
if(typeWalk->colMajorMat)
{
uint32_t componentIndex = byteOffset / scalar.sizeInBytes;
if(typeWalk->colMajorMat)
{
uint32_t col = componentIndex % columns;
RDCASSERT(col < columns, col, columns);
// one remaining index selects a column within the matrix.
// source vars are displayed as row-major, need <rows> mappings
for(uint32_t r = 0; r < rows; ++r)
{
RDCASSERTEQUAL(usage->children[r].children.size(), columns);
usage->children[r].children[col].emitSourceVar =
!usage->children[r].emitSourceVar;
usage->children[r].children[col].debugVarSSAName = mapping.debugVarSSAName;
usage->children[r].children[col].debugVarComponent = r;
}
}
else
uint32_t col = componentIndex % columns;
RDCASSERT(col < columns, col, columns);
// one remaining index selects a column within the matrix.
// source vars are displayed as row-major, need <rows> mappings
for(uint32_t r = 0; r < rows; ++r)
{
uint32_t row = componentIndex % rows;
RDCASSERT(row < rows, row, rows);
RDCASSERTEQUAL(usage->children.size(), rows);
RDCASSERTEQUAL(usage->children[row].children.size(), columns);
// one remaining index selects a row within the matrix.
// source vars are displayed as row-major, need <rows> mappings
for(uint32_t c = 0; c < columns; ++c)
{
usage->children[row].children[c].emitSourceVar =
!usage->children[row].emitSourceVar;
usage->children[row].children[c].debugVarSSAName = mapping.debugVarSSAName;
usage->children[row].children[c].debugVarComponent = c;
}
RDCASSERTEQUAL(usage->children[r].children.size(), columns);
usage->children[r].children[col].emitSourceVar =
!usage->children[r].emitSourceVar;
usage->children[r].children[col].debugVarSSAName = mapping.debugVarSSAName;
usage->children[r].children[col].debugVarComponent = r;
}
}
else
{
RDCERR("Unhandled matrix source variable mapping %u %u", bytesRemaining,
byteOffset);
uint32_t row = componentIndex % rows;
RDCASSERT(row < rows, row, rows);
RDCASSERTEQUAL(usage->children.size(), rows);
RDCASSERTEQUAL(usage->children[row].children.size(), columns);
// one remaining index selects a row within the matrix.
// source vars are displayed as row-major, need <rows> mappings
for(uint32_t c = 0; c < columns; ++c)
{
usage->children[row].children[c].emitSourceVar =
!usage->children[row].emitSourceVar;
usage->children[row].children[c].debugVarSSAName = mapping.debugVarSSAName;
usage->children[row].children[c].debugVarComponent = c;
}
}
}
else
{
RDCERR("Unhandled matrix assignment");
}
// try to recombine matrix rows to a single source var display
for(uint32_t r = 0; r < rows; ++r)
{
Expand Down Expand Up @@ -7313,7 +7310,7 @@ void Debugger::ParseDebugData()
usage->rows = 1U;
usage->columns = columns;

if(bytesRemaining > 0)
if(bytesRemaining == scalar.sizeInBytes)
{
bytesRemaining -= scalar.sizeInBytes;
RDCASSERTEQUAL(bytesRemaining, 0);
Expand Down Expand Up @@ -7454,7 +7451,6 @@ void Debugger::ParseDebugData()
}
else
{
RDCASSERTEQUAL(n->rows * n->columns, (uint32_t)n->children.count());
for(int32_t c = 0; c < n->children.count(); ++c)
sourceVar.variables.push_back(DebugVariableReference(
DebugVariableType::Variable,
Expand Down

0 comments on commit 48e73fb

Please sign in to comment.