Skip to content

Matrix of the form matCx2 not getting translated properly when in a uniform buffer #4371

@teoxoy

Description

@teoxoy

WGSL expects a matCx2 to have a matrix stride of 8 (inner vector components to be aligned to 8 bytes including itself).
SPIR-V/GLSL/HLSL expect a matCx2 to have a matrix stride of 16 (inner vector components to be aligned to 16 bytes including itself).

Solution

Replace matCx2 with a sequence of C vec2's (since vec2s alignment is 8) and reconstruct the matrix in the shader.

References

WGSL Alignment and Size
GLSL Standard Uniform Block Layout
HLSL DirectXShaderCompiler Buffer-Packing Wiki
Vulkan Offset and Stride Assignment

Related issues

gfx-rs/naga#1400 (gfx-rs/naga#1400 (comment)), #4375, #4376 - inverse of this issue (concerning the frontends)

Metadata

Metadata

Assignees

Labels

area: naga back-endOutputs of naga shader conversionhelp requiredWe need community help to make this happen.lang: GLSLOpenGL Shading Languagelang: SPIR-VVulkan's Shading LanguagenagaShader Translatortype: bugSomething isn't working

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions