Skip to content

Add validation for invalid layout decoration usage #6012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

Image for: Conversation
Copy link
Contributor

  • Checks that Block, BufferBlock, Offset, ArrayStride, and MatrixStride are not used in a Vulkan environment in disallowed storage classes
* Checks that Block, BufferBlock, Offset, ArrayStride, and MatrixStride
  are not used in a Vulkan environment in disallowed storage classes
alan-baker marked this pull request as ready for review February 25, 2025 15:43
github-project-automation bot moved this to In progress in Validator Feb 25, 2025
alan-baker merged commit b095f36 into KhronosGroup:main Feb 27, 2025
22 checks passed
alan-baker deleted the invalid-layout-decorations branch February 27, 2025 18:17
github-project-automation bot moved this from In progress to Done in Validator Feb 27, 2025
spv::Capability::WorkgroupMemoryExplicitLayoutKHR);
case spv::StorageClass::Function:
case spv::StorageClass::Private:
return vstate.version() < SPV_SPIRV_VERSION_WORD(1, 4);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alan-baker so for something in GLSL like

#version 450

struct Bar {
    uint x;
    uint y;
    uint z[2];
};

layout(set = 0, binding = 0, std430) buffer foo {
    uvec4 a;
    Bar b; // size 16 at offset 16
    uint c;
};

void main() {
    Bar new_bar;
    b = new_bar;
}

this will pass spirv-val if using --target-env vulkan1.1 (https://godbolt.org/z/bjKodYPKG)

but fail here with 1.2

I guess trying to figure out what spec change causes this to fail from 1.1 to 1.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This chapter describes valid uses for a set of SPIR-V decorations. Any other use of one of these decorations is invalid, with the exception that, when using SPIR-V versions 1.4 and earlier: Block, BufferBlock, Offset, ArrayStride, and MatrixStride can also decorate types and type members used by variables in the Private and Function storage classes.

Vulkan 1.2 is considered SPIR-V 1.5 (for the assembler) so that prevents putting layouts on types used in function variables.

Looks like I misread the spec though and should change the conditions to <= 1.4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this was in the Shader Interfaces section of the Vulkan Spec (I was searching only in the SPIR-V spec)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That fix is #6023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants