-
Notifications
You must be signed in to change notification settings - Fork 597
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
Add validation for invalid layout decoration usage #6012
Conversation
alan-baker
commented
Feb 25, 2025
- 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
spv::Capability::WorkgroupMemoryExplicitLayoutKHR); | ||
case spv::StorageClass::Function: | ||
case spv::StorageClass::Private: | ||
return vstate.version() < SPV_SPIRV_VERSION_WORD(1, 4); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That fix is #6023