[SPIR-V] -fvk-use-dx-layout places cbuffer matrices with double columns at a different offset than DXIL

Aperta
#9,017 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug needs-triage spirv

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)
Lingua principale
C++
Stelle
3.7k
Fork
926
Merge medio
3g 22h
PR unite (30g)
45

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/DirectXShaderCompiler

Tutte le issue di microsoft/DirectXShaderCompiler

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.