Skip to content
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

Fix aligment for empty structs #6635

Merged
merged 1 commit into from
May 22, 2024
Merged

Fix aligment for empty structs #6635

merged 1 commit into from
May 22, 2024

Conversation

s-perron
Copy link
Collaborator

We have a special case to that the the size and alignment for an empty
struct is {1,0}. However that is not correct. See
https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#interfaces-alignment-requirements.

An empty structure has a base alignment equal to the size of the smallest
scalar type permitted by the capabilities declared in the SPIR-V module. (e.g.,
for a 1 byte aligned empty struct in the StorageBuffer storage class,
StorageBuffer8BitAccess or UniformAndStorageBuffer8BitAccess must be declared
in the SPIR-V module.

I'm not 100% sure how DXC handle this minimum alignment, but I figured I
would inialize the alignment to 1. If there are not members, then it
will remain 1, and I would let the rest of the logic happen. No special
case.

Fixes #2882

We have a special case to that the the size and alignment for an empty
struct is `{1,0}`. However that is not correct. See
https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#interfaces-alignment-requirements.

> An empty structure has a base alignment equal to the size of the smallest
scalar type permitted by the capabilities declared in the SPIR-V module. (e.g.,
for a 1 byte aligned empty struct in the StorageBuffer storage class,
StorageBuffer8BitAccess or UniformAndStorageBuffer8BitAccess must be declared
in the SPIR-V module.

I'm not 100% sure how DXC handle this minimum alignment, but I figured I
would inialize the alignment to 1. If there are not members, then it
will remain 1, and I would let the rest of the logic happen. No special
case.

Fixes microsoft#2882
@s-perron s-perron requested a review from a team as a code owner May 17, 2024 19:33
@s-perron s-perron merged commit 86da226 into microsoft:main May 22, 2024
13 checks passed
@s-perron s-perron deleted the i2882 branch May 22, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[SPIRV] Empty struct in cbuffer causes compilation to fail
3 participants