Naga generates HLSL that doesn't satisfy WGSL's layout rules for global matCx2
matrices
#1837
Labels
area: back-end
Outputs of shader conversion
kind: bug
Something isn't working
lang: HLSL
High-Level Shading Language
Milestone
When a
uniform
global variable has a matrix type, Naga generates HLSL code that misinterprets the bytes passed from the GPU.In buffers shared with the host, WGSL stores
matCx2<f32>
matrices packed, with columns aligned on eight-byte boundaries, as appropriate for avec2<f32>
. However, HLSL stores all matrix rows aligned on 16-byte boundaries. To compensate for this, Naga generates HLSL that interprets the memory as a sequence ofC
float2
vectors, and then reassembles them into a matrix when they are loaded.However, since Naga (following WGSL) used to require global variables to be
Struct
types, the HLSL back end only implements this hack for struct members. Now that Naga allows globals of any type, the HLSL back end needs to apply this hack in more places.For example, Naga translates the following WGSL:
into the following HLSL:
This is incorrect: the latter is a series of three
float2
vectors each followed by eight bytes of padding, whereas the former should be threevec2<f32>
vectors packed into 24 bytes, without padding.The text was updated successfully, but these errors were encountered: