bevy/crates/bevy_render/src/render_resource
charlotte a4640046fc
Adds ShaderStorageBuffer asset (#14663)
Adds a new `Handle<Storage>` asset type that can be used as a render
asset, particularly for use with `AsBindGroup`.

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 with `AsBindGroup`, particularly in the following
scenarios:
- Sharing the same buffers between a compute stage and material shader.
We already have examples of this for storage textures (see game of life
example) and these changes allow a similar pattern to be used with
storage buffers.
- Preventing repeated gpu upload (see the previous easier to use `Vec`
`AsBindGroup` option).
- Allow initializing custom materials using `Default`. Previously, the
lack of a `Default` implement for the raw `wgpu::Buffer` type made
implementing a `AsBindGroup + Default` bound difficult in the presence
of buffers.

## Solution

Adds a new `Handle<Storage>` asset type that is prepared into a
`GpuStorageBuffer` render asset. This asset can either be initialized
with a `Vec<u8>` of properly aligned data or with a size hint. Users can
modify the underlying `wgpu::BufferDescriptor` to provide additional
usage flags.

## Migration Guide

The `AsBindGroup` `storage` attribute has been modified to reference the
new `Handle<Storage>` asset instead. Usages of Vec` should be converted
into assets instead.

---------

Co-authored-by: IceSentry <IceSentry@users.noreply.github.com>
2024-09-02 16:46:34 +00:00
..
batched_uniform_buffer.rs Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00
bind_group_entries.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
bind_group_layout_entries.rs Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00
bind_group_layout.rs Replace UUID based IDs with a atomic-counted ones (#6988) 2022-12-25 00:23:15 +00:00
bind_group.rs Adds ShaderStorageBuffer asset (#14663) 2024-09-02 16:46:34 +00:00
buffer_vec.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
buffer.rs Make TrackedRenderPass::set_vertex_buffer aware of slice size (#14916) 2024-08-28 11:41:42 +00:00
gpu_array_buffer.rs Fix intra-doc links and make CI test them (#14076) 2024-07-11 13:08:31 +00:00
mod.rs Meshlet software raster + start of cleanup (#14623) 2024-08-26 17:54:34 +00:00
pipeline_cache.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
pipeline_specializer.rs Micro-optimize queue_material_meshes, primarily to remove bit manipulation. (#12791) 2024-04-01 21:58:53 +00:00
pipeline.rs Add VertexBufferLayout::offset_locations (#9805) 2024-08-26 17:54:33 +00:00
resource_macros.rs Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00
shader.rs Optimize common usages of AssetReader (#14082) 2024-07-01 19:59:42 +00:00
storage_buffer.rs Only create changed buffer if it already exists (#13242) 2024-05-05 22:16:11 +00:00
texture.rs Add screenshot api (#7163) 2023-04-19 21:28:42 +00:00
uniform_buffer.rs Migrated NonZero* to NonZero<*> (#14978) 2024-08-30 02:37:47 +00:00