-
Notifications
You must be signed in to change notification settings - Fork 195
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
Add buffer pointer support for WGSL (SPV_EXT_physical_storage_buffer) #2457
base: master
Are you sure you want to change the base?
Conversation
ea5fb5c
to
0d8cb28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - this looks very interesting.
@felipeagc Just out of curiosity - what are you using this new |
5e0b5cb
to
ec893fe
Compare
I'm writing a Vulkan renderer and wanted to use buffer pointers to simplify the design a bit. But since I was using naga to compile shaders, I needed to add the feature to the compiler! :) I don't know if this kind of feature is too out of scope for naga, as far as WebGPU is concerned, but since I implemented it for myself I figured I should try to upstream it so other people can use it. |
Allows compilation of this kind of access: ``` struct OtherStruct { data: float, } struct MyBuffer { sub_buf: ptr<buffer, OtherStruct> } struct PushConstants { buf: ptr<buffer, MyBuffer>, } var<push_constant> pc: PushConstants; var d = (*(*pc.buf).sub_buf).data; ``` Before you would have to use intermediate variables: ``` var b = (*pc.buf); var d = (*b.sub_buf).data; ```
Hello, thank you for your PR against Naga! As part of gfx-rs/wgpu#4231, we have moved development of Naga into the wgpu repository in the Naga subfolder. We have transferred all issues, but we are unable to automatically transfer PRs. As such, please recreate your PR against the wgpu repository. We apologize for the inconvenience this causes, but will make contributing to both projects more streamlined going forward. We are leaving PRs open, but once they are transferred, please close the original Naga PR. |
@felipeagc As I'm also interested in using these features, I've rebased your PR branch on the post-merge wgpu repo here: https://github.com/exrook/wgpu/tree/buffer_pointer |
Hi. Just wondering what the status of this PR is as I’d like to use this feature too. |
This will add support for the
PhysicalStorage
SPIR-V storage class, which will enable use of the VK_KHR_buffer_device_address Vulkan extension.Here's some example WGSL code for what this looks like:
The name of the WGSL address space is
buffer
and the third parameter for the pointer is the alignment of the pointed-to Buffer, which affects load operations on the buffer. It is optional and defaults to 16, as per the GLSL spec.The size and alignment of pointers in this storage class is 8 bytes, so I also had to change that.
One thing this would allow for and that I did not implement is recursive pointers: