KhronosGroup / KhronosGroup/glslang
Default state of Vulkan GLSL is `std430` but `align()` qualifier ignored?
- Dominant language
- C++
- Stars
- 3.6k
- Forks
- 989
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 31
Description
The `GL_KHR_vulkan_glsl` extension says that initial state of compilation (for buffers) is equivalent to:
```
layout(std430, column_major) buffer;
```
Yet the `align()` qualifier appears to be ignored when `std430` does not appear in the layout.
The extension says:
```
Change section 4.4.5 Uniform and Shader Storage Block Layout Qualifiers
"The initial state of compilation is as if the following were declared:
layout(std140, column_major) uniform; // without push_constant
layout(std430, column_major) buffer;
"However, when push_constant is declared, the default layout of the
buffer will be std430. There is no method to globally set this default."
```
There is a Shader Playground example [here](http://shader-playground.timjones.io/d021fa02e5e6aeacc8a77afceecf7c97) that captures my confusion on this issue.
The relevant SPIR-V being:
```
MemberDecorate 14(_ttcks_default) 0 NonWritable
MemberDecorate 14(_ttcks_default) 0 Offset 0
MemberDecorate 14(_ttcks_default) 1 Offset 16
MemberDecorate 14(_ttcks_default) 2 Offset 32 <-- align(256): What?
MemberDecorate 14(_ttcks_default) 3 NonWritable
MemberDecorate 14(_ttcks_default) 3 Offset 16416
MemberDecorate 21(_ttcks_std430) 0 NonWritable
MemberDecorate 21(_ttcks_std430) 0 Offset 0
MemberDecorate 21(_ttcks_std430) 1 Offset 16
MemberDecorate 21(_ttcks_std430) 2 Offset 256 <-- align(256): OK!
MemberDecorate 21(_ttcks_std430) 3 NonWritable
MemberDecorate 21(_ttcks_std430) 3 Offset 16640
```
Maybe I'm missing something subtle?
Contributor guide
Research direction
Start by reproducing the linked Shader Playground example and compare the generated SPIR-V offsets for the default buffer layout and explicit std430. Read the GL_KHR_vulkan_glsl rules quoted in the issue alongside the align() qualifier behavior. Done means establishing whether the default layout should honor align(256) and documenting or correcting the compiler behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100