[SPIR-V] -fvk-use-dx-layout places cbuffer matrices with double columns at a different offset than DXIL
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by searching the compiler for -fvk-use-dx-layout handling of cbuffer matrix member offsets, then look for tests covering DX-layout matrix padding, including the cases referenced in #3463 and #3672. Reproduce with the supplied HLSL and compare SPIR-V member offsets with DXIL reflection. Done means the double-matrix member offset matches DirectX’s 16-byte placement while the shared 32-byte column stride and existing float-matrix and vector cases remain unchanged.
Written by the indexing model from the issue text.
Description
Description
Under -fvk-use-dx-layout, a cbuffer matrix whose SPIR-V columns are larger than 16 bytes (3 or 4 doubles) doesn't get DirectX's offset. DirectX starts a cbuffer member on the next 16-byte row, so double a; double3x3 m; puts m at 16. The SPIR-V output instead aligns the matrix to its own 32-byte column stride and puts it at 32. The same HLSL therefore describes different bytes per backend, which defeats the point of the flag: one application-side struct can't serve both backends. Both backends agree on the 32-byte column stride; only the member offset differs.
These cases land identically on both backends:
- float matrices
- double vectors
- double scalars
Related: #3463 / #3672 fixed DX-layout matrix padding for float matrices.
Steps to Reproduce
dxc -T cs_6_2 -E main -spirv -fvk-use-dx-layout repro.hlsl, compared with dxc -T cs_6_2 -E main repro.hlsl:
cbuffer CB { double a; double3x3 m; }
RWByteAddressBuffer o;
[numthreads(1, 1, 1)]
void main(uint id : SV_DispatchThreadID) { o.Store<float>(0, (float) (a + m[2][2])); }
A standalone repro comparing DXIL reflection against SPIRV-Reflect is attached (repro_dx_layout_double_matrix_spirv_reflect.cpp).
Actual Behavior
SPIR-V:
OpMemberDecorate %type_CB 0 Offset 0
OpMemberDecorate %type_CB 1 Offset 32
OpMemberDecorate %type_CB 1 MatrixStride 32
DXIL:
; double a; ; Offset: 0
; column_major double3x3 m; ; Offset: 16
All cases:
cbuffer CB { double a; double3x3 m; } m: DXIL 16, SPIR-V 32 <-- differs
cbuffer CB { double a; double3x2 m; } m: DXIL 16, SPIR-V 32 <-- differs
cbuffer CB { float a; float3x3 m; } m: DXIL 16, SPIR-V 16
cbuffer CB { double a; double3 b; } b: DXIL 16, SPIR-V 16
Environment
- DXC version: <latest release, from
dxc --version>; also reproduces on main, libdxcompiler.so: 1.11(5563-75fba619)(1.10.0.15563) - Host Operating System: Windows (release); Linux x86_64 (main)
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 926
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 45
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/DirectXShaderCompiler
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#9173 ·
Maintainers usually reply within 2 days
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/DirectXShaderCompiler#9155 · 4 comments ·
Maintainers usually reply within 2 days
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#9135 ·
Maintainers usually reply within 2 days
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLPossibly taken @rj123-nv claimed this 18 days ago. Openbug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/DirectXShaderCompiler#9087 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/DirectXShaderCompiler#9086 ·
Maintainers usually reply within 2 days
All issues in microsoft/DirectXShaderCompiler
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
table_translator 当一个 Prism 键映射到多个原码时,首个候选未按权重排序Possibly taken A pull request linked to this issue is open or already merged. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
feature:config kind:docs os:windows toolchain:cmake triaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
arch-based bug niri
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
noctalia-dev/noctalia#5552 ·
Maintainers usually reply within 1 day