glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Default state of Vulkan GLSL is `std430` but `align()` qualifier ignored?

Open allanmac opened this issue 5 years ago • 0 comments

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 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?

allanmac avatar Feb 12 '20 00:02 allanmac