Possible debug info bug with matrix bitpieces #7044
Labels
bug
Bug, regression, crash
debug info
Related to debug info generation
matrix-bug
Bugs relating to matrix types
Milestone
Description
The debug info uses bitpieces to map from matrices to elements but it uses a column-major conventions in conflict with how the matrix template members are defined.
The first convention is on the members -
_11
,_12
etc which are treated as row-major and have bit offsets with the first-row first-column element to be at bit offset 0, the first-row second-column element at bit offset 32, etc up to the last element at bit offset 480. This is what I'd expect for HLSL conventions.The bitpieces themselves when mapping individual scalar SSAs seem to use a column-major convention, so so the first-column second-row element is mapped to bit offset 32.
Steps to Reproduce
I initially saw this on the ModelViewer sample in DirectX-Graphics-Samples if you want a real-world test case, but I've simplified it down to a synthetic test compiled with
-Zi -Od
: https://godbolt.org/z/K8jK8fj6jThe main function is simple and it just launders a vector through a matrix to test indexing:
The actual executable part is what I'd expect (elided):
So the _14, _24, _34 indices correspond to the first, second and third row in the fourth column.
Looking at the definition of the members you can see that this is bit-packing those row-major:
However look at the way the
test
elements are mentioned as members:These are contiguous in the next-to-final elements of the matrix - if this were row-major that would make them the first elements of the final row.
I also added some constants so you can see the first-row second-column value of
4
and the second-row first-column value of5
, which are laid out column-wise:Actual Behavior
The bitpieces identifying matrix elements are calculated column-wise while the members are row-wise. Either would work, but it's currently inconsistent and the bitpieces are not what I'd expect matching HLSL conventions.
The result of this is any program parsing the debug info that either hardcodes a row-major convention or even does something smart to reflect the layout out of the matrix members by
_11
,_12
offsets etc will end up transposing the matrix.Environment
The text was updated successfully, but these errors were encountered: