-
Notifications
You must be signed in to change notification settings - Fork 329
Open
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues
Milestone
Description
Currently uniform buffers have more restrictive layout constraints than storage buffers.
13.4.1 Alignment and Size says that for uniform buffers, array strides must be a multiple of 16, and structs must be aligned to 16 bytes or greater.
These constraints come from:
- Vulkan when unextended is similar to GLSL std140. See "Standard Buffer Layout" from https://docs.vulkan.org/spec/latest/chapters/interfaces.html#interfaces-resources-layout
- D3D "Legacy" constant buffer layout: https://github.com/microsoft/DirectXShaderCompiler/wiki/Buffer-Packing#legacy-constant-buffer-basics-excluding-min-precision-or-16-bit-types
This is a legacy hardware requirement that is not needed on more modern hardware.
It would be nice to eliminate those special round-up-to-16 alignment requirements for uniform buffers: use the same rules in uniform buffer as for storage buffer.
- Metal supports this
- Vulkan has VK_KHR_uniform_buffer_standard_layout is this feature, and is always supported in Vulkan 1.2 or later.
- DXC offers
-no-legacy-cbuf-layout
: https://github.com/microsoft/DirectXShaderCompiler/wiki/Buffer-Packing#non-legacy-packing--no-legacy-cbuf-layout
See also scalar block layout
which goes even further, in that the alignment requirement for a vector is lowered to the alignment requirement of its component type. See #4040
Metadata
Metadata
Assignees
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issues