[SPIR-V] -fvk-use-dx-layout doesn't apply DirectX cbuffer layout to [[vk::push_constant]] blocks
Los mantenedores suelen responder en 2 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Start in tools/clang/lib/SPIRV/DeclResultIdMapper.cpp and SpirvEmitter.cpp, where the issue says push constants use sBufferLayoutRule while cbuffers use cBufferLayoutRule; compare how -fvk-use-dx-layout sets those rules. Reproduce with the HLSL example and compare SPIR-V offsets and array strides against DXIL reflection. Done means push-constant arrays and matrices follow the intended DirectX cbuffer layout without regressing existing cases.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
With -fvk-use-dx-layout, a [[vk::push_constant]] block is packed with structured-buffer rules (tightly packed, scalar-like), not cbuffer rules. In DXIL the same struct is an ordinary constant buffer with DirectX's 16-byte rows. Scalars and vectors happen to agree, but arrays and matrices sit at different offsets with different element spacing, so one application-side struct can't feed both backends.
The cause appears to be that push constants take spirvOptions.sBufferLayoutRule, which -fvk-use-dx-layout sets to FxcSBuffer, whereas cbuffers get cBufferLayoutRule (FxcCTBuffer) (tools/clang/lib/SPIRV/DeclResultIdMapper.cpp, SpirvEmitter.cpp). The docs describe the DX layout rules as applying to "uniform buffers and storage buffers" and never mention push constants, so this may be an omission rather than intent. The flag's stated purpose is to allow packing data on the application side that can be shared with DirectX, and a push constant block (root constants on D3D12) is exactly that kind of struct.
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:
[[vk::push_constant]] struct PC { float a; float arr[3]; float tail; } pc;
RWByteAddressBuffer o;
[numthreads(1, 1, 1)]
void main(uint id : SV_DispatchThreadID) { o.Store<float>(0, pc.a + pc.arr[2] + pc.tail); }
A standalone repro comparing DXIL reflection against SPIRV-Reflect is attached (repro_push_constant_dx_layout.cpp).
Actual Behavior
SPIR-V:
OpDecorate %_arr_float_uint_3 ArrayStride 4
OpMemberDecorate %type_PushConstant_PC 0 Offset 0
OpMemberDecorate %type_PushConstant_PC 1 Offset 4
OpMemberDecorate %type_PushConstant_PC 2 Offset 16
DXIL:
; float a; ; Offset: 0
; float arr[3]; ; Offset: 16
; float tail; ; Offset: 52
All cases:
struct PC { float a; float3 b; float c; } a 0/0, b 4/4, c 16/16
struct PC { float a; float arr[3]; float tail; } arr 16/4, tail 52/16 <-- differs
struct PC { float a; float2x2 m; float4x4 big; } m 16/4, big 48/20 <-- differs
(DXIL/SPIR-V)
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)
- Lenguaje dominante
- C++
- Estrellas
- 3.7k
- Forks
- 926
- Merge medio
- 3 d 22 h
- PR fusionados (30 d)
- 45
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/DirectXShaderCompiler
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/DirectXShaderCompiler#9173 ·
Los mantenedores suelen responder en 2 días
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
microsoft/DirectXShaderCompiler#9155 · 4 comentarios ·
Los mantenedores suelen responder en 2 días
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/DirectXShaderCompiler#9135 ·
Los mantenedores suelen responder en 2 días
-
DXC emits DW_LANG_C_plus_plus instead of DW_LANG_HLSL for HLSLPosiblemente ocupada @rj123-nv la tomó hace 18 días. Abiertobug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/DirectXShaderCompiler#9087 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoft/DirectXShaderCompiler#9086 ·
Los mantenedores suelen responder en 2 días
Todos los issues de microsoft/DirectXShaderCompiler
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
feature:config kind:docs os:windows toolchain:cmake triaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
arch-based bug niri
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
noctalia-dev/noctalia#5552 ·
Los mantenedores suelen responder en 1 día