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

[0010] Is type punning allowed? #43

Closed
llvm-beanz opened this issue Apr 14, 2023 · 4 comments · Fixed by #55
Closed

[0010] Is type punning allowed? #43

llvm-beanz opened this issue Apr 14, 2023 · 4 comments · Fixed by #55
Assignees
Labels
active proposal Issues relating to active proposals

Comments

@llvm-beanz
Copy link
Collaborator

llvm-beanz commented Apr 14, 2023

Which proposal does this relate to?
0010-vk-buffer-ref.md

Describe the issue or outstanding question.
With the planned introduction of unions to HLSL we need to know if vk::BufferPointer<T,A> objects are allowed in unions and if type punning is allowed.

Additional context
See initial review discussion.
Related unions issue.

@s-perron
Copy link
Collaborator

This is hard to answer. SPIR-V does not allow unions. It is unclear what we would be able to do with type punning.

@greg-lunarg
Copy link
Contributor

greg-lunarg commented Apr 20, 2023

If it is decided that type punning through unions is allowed, I think we could define what happens during type punning of a buffer pointer between buffer pointers or a buffer pointer and a uint64_t. It would essentially be a casting operation. Any interaction between a buffer pointer and any other type would be undefined.

If it is decided to support the aliasing attributes vk::aliased and vk::restrict, it would be the users responsibility to make sure any pointers are attributed correctly based on how they are dereferenced. If the aliasing attributes are not supported, the user must take care when dereferencing pointers to assure correct behavior.

@greg-lunarg
Copy link
Contributor

Given the current aliasing policy, I must change change the proposal above.

Type punning across different buffer pointer types with the vk::aliased_pointer attribute is currently not directly expressible in SPIR-V, so I would lean toward disallowing it.

@llvm-beanz llvm-beanz self-assigned this May 8, 2023
greg-lunarg added a commit to greg-lunarg/hlsl-specs that referenced this issue May 8, 2023
@s-perron
Copy link
Collaborator

s-perron commented May 9, 2023

I think that is fine. People will still have the option to have a BufferPointer to a union. We can revisit later if needed, but you shouldn't have to deal with that now.

llvm-beanz pushed a commit that referenced this issue Sep 1, 2023
* Add type punning rules to vk::BufferPointer

Fixes #43

* Clarify that type punning with buffer pointers leads to undefined
behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
active proposal Issues relating to active proposals
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants