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

Alignof operator #159

Open
KStocky opened this issue Jan 19, 2024 · 1 comment
Open

Alignof operator #159

KStocky opened this issue Jan 19, 2024 · 1 comment
Milestone

Comments

@KStocky
Copy link

KStocky commented Jan 19, 2024

Is your feature request related to a problem? Please describe.
It used to be that every type in HLSL was 4 bytes in size. Even bools are 4 bytes. So you could assume that everything was 4 byte aligned. However, this is no longer the case. We now have types like float16_t which have an alignment of 2 and uint64_t which have an alignment of 8. This is important if we are using templated ByteAddressBuffer stores because we have to be able to align our writes. However, there is currently no way to query what a struct's alignment is, so writing generic code that makes use of byte address buffer stores is difficult. The best we can do is just align every unknown type by 8 bytes.

Describe the solution you'd like
I would like an alignof operator like in C++11 to simply query a type's alignment.

Describe alternatives you've considered
The only workaround now (that I know of) is to make all stores of unknown types be 8 byte aligned.

@llvm-beanz
Copy link
Collaborator

This is related to: #154

@damyanp damyanp added this to the HLSL Backlog milestone May 13, 2024
@damyanp damyanp moved this to Triaged in HLSL Triage May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triaged
Development

No branches or pull requests

3 participants