-
Notifications
You must be signed in to change notification settings - Fork 244
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
Incorrect array stride for arrays of vector types #573
Comments
maybe the decoration should be even removed because I don't recall if the stride is defined at all if not part of the shader resource interface.. |
Right - in a uniform buffer with no layout extensions, and thus std140 layout, the stride should be 16, and in a storage buffer with 430 layout, 8. For a plain array like that, it seems kinda arbitrary.. |
Why should they be treated as such? The only rules I know of that have those requirements are for UBOs/SSBOs, and even there it's an archaic mess that I should we should paper over (e.g. if you had that Are you getting an error from anything? Like a validation error that prompted this? EDIT: according to the Vulkan spec:
Unsure which combination opts into that on the |
For sake of completeness, I altered your example somewhat to use glam and appropriate syntax: #[spirv(vertex)]
pub fn quad_vs(
#[spirv(vertex_index)] vert_id: i32,
#[spirv(uniform, descriptor_set = 0, binding = 0)] clip: &[Vec2; 4],
#[spirv(position)] a_position: &mut Vec4,
) {
let idx = vert_id as usize;
let pos_clip = clip[idx];
*a_position = Vec4::new(pos_clip.x, pos_clip.y, idx as f32, 1.0);
} And I get this error
So at least it throws an error when using an incorrect alignment for uniform buffers. |
QUAD_CLIP
type will be generated with anArrayStride
of 8 which is incorrect as in this case all array elements should be treated as vec4 types, requiring a stride of 16.Generated:
Expected:
The text was updated successfully, but these errors were encountered: