-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Adds ShaderStorageBuffer
asset
#14663
Adds ShaderStorageBuffer
asset
#14663
Conversation
See related old PR: #6669 |
Like mentioned on discord. I'd prefer if this kept the ability to use a raw |
Adds a new `Handle<Storage>` asset type that can be used as a render asset, particularly for use with `AsBindGroup`.
cc1ca19
to
817b1f1
Compare
@IceSentry The refactor we did in #14909 helped clean this up a lot. Changes since you last reviewed:
|
@@ -0,0 +1,113 @@ | |||
//! This example demonstrates how to use a storage buffer with `AsBindGroup` in a custom material. |
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.
Should the example be renamed to match the new type? I don't really have an opinion either way honestly.
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.
My thought was just that shader/shader_storage_buffer
was a bit redundant.
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.
But happy to change :)
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.
I didn't test the example, but the implementation LGTM
Also, could you update the PR description with the new name? |
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
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.
ran the example successfully and the new usage makes sense to me
…ata (#15044) Adds some methods to assist in building `ShaderStorageBuffer` without using `bytemuck`. We keep the `&[u8]` constructors since this is still modeled as a thin wrapper around the buffer descriptor, but should make it easier to interact with at the cost of an extra allocation in the `ShaderType` path for the buffer writer. Follow up from #14663
Adds a new
Handle<Storage>
asset type that can be used as a render asset, particularly for use withAsBindGroup
.Closes: #13658
Objective
Allow users to create storage buffers in the main world without having to access the
RenderDevice
. While this resource is technically available, it's bad form to use in the main world and requires mixing rendering details with main world code. Additionally, this makes storage buffers easier to use withAsBindGroup
, particularly in the following scenarios:Vec
AsBindGroup
option).Default
. Previously, the lack of aDefault
implement for the rawwgpu::Buffer
type made implementing aAsBindGroup + Default
bound difficult in the presence of buffers.Solution
Adds a new
Handle<Storage>
asset type that is prepared into aGpuStorageBuffer
render asset. This asset can either be initialized with aVec<u8>
of properly aligned data or with a size hint. Users can modify the underlyingwgpu::BufferDescriptor
to provide additional usage flags.Migration Guide
The
AsBindGroup
storage
attribute has been modified to reference the newHandle<Storage>
asset instead. Usages of Vec` should be converted into assets instead.