[hlsl-out] account for "vector-relaxed" std140 layout for constant buffers #1783
Labels
area: back-end
Outputs of shader conversion
kind: bug
Something isn't working
lang: HLSL
High-Level Shading Language
HLSL uses "vector-relaxed" std140 layout for constant buffers, however the current implementation seems to assume std140 layout
The example below shows the issue.
Going from WGSL to HLSL trough naga translates the struct as if it had the same layout in HLSL.
When translating the same WGSL shader to SPIR-V via naga, the offsets are: 0, 8, 16.
However when translating the produced HLSL to SPIR-V via DXC, the offsets are: 0, 4, 12.
WGSL -> HLSL
WGSL -> SPIR-V
HLSL -> SPIR-V
Solution
Insert padding (when necessary) for vector members that are in constant buffers.
References
HLSL Packing Rules for Constant Variables
DirectXShaderCompiler Buffer-Packing Wiki
DirectXShaderCompiler Memory layout rules
The text was updated successfully, but these errors were encountered: