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

[0011] Clarify behavior of SpirvType parameters and add SpirvOpaqueType #150

Merged
merged 1 commit into from
Jan 18, 2024

Conversation

cassiebeckley
Copy link
Contributor

SpirvType now takes size and alignment as parameters, and a new template SpirvOpaqueType is added that does not. Also lets users specify whether a parameter for the type-declaration instruction should take an id or an immediate literal value.

Fixes #128.

@cassiebeckley
Copy link
Contributor Author

@s-perron

@s-perron s-perron requested a review from llvm-beanz January 9, 2024 20:01
@s-perron
Copy link
Collaborator

s-perron commented Jan 9, 2024

This is a pretty big change to the original proposal, but necessary to do what we need to do.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

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

I think this LGTM. I wonder if there is some alignment we should aim for between this proposal and #154.

@cassiebeckley
Copy link
Contributor Author

I'd considered using alignas, but it would require modifying the parser to have a different behavior than C++, which we were trying to avoid for the most part.

For example

typedef alignas(8) vk::SpirvType</* OpTypeInt */ 21, /* size */ 8, vk::ext_literal(8), vk::ext_literal(false)> uint8_t;

or

typedef vk::SpirvType</* OpTypeInt */ 21, /* size */ 8, vk::ext_literal(8), vk::ext_literal(false)> alignas(8) uint8_t;

would not be valid syntax.

@llvm-beanz
Copy link
Collaborator

Right... because alignas isn't valid for typedefs :(

That said, we might be able to implement this feature in terms of alignas in the future because this horrible thing is completely valid (with C23):

template<int Align, int Size>
struct alignas(Align) OpaqueType
{
  _BitInt(Size) V;
};

@s-perron s-perron merged commit 2676ae5 into microsoft:main Jan 18, 2024
@cassiebeckley cassiebeckley deleted the spirv-type branch January 18, 2024 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0011] Enable vk::SpirvType to be used in interface arrays and structs
3 participants