bevy/assets/shaders
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
..
animate_shader.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
array_texture.wgsl Remove unused mip_bias parameter from apply_normal_mapping (#13752) 2024-06-10 13:00:34 +00:00
cubemap_unlit.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_gltf_2d.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
custom_material.frag Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_material.vert Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_material_2d.wgsl Fix binding group in custom_material_2d.wgsl (#10841) 2023-12-02 22:21:53 +00:00
custom_material_import.wgsl fix custom shader imports (#10030) 2023-10-06 01:34:57 +00:00
custom_material_screenspace_texture.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
custom_phase_item.wgsl Allow phase items not associated with meshes to be binned. (#14029) 2024-06-27 16:13:03 +00:00
custom_ui_material.wgsl Update ui_material example to be a slider instead (#14031) 2024-06-27 21:23:04 +00:00
custom_vertex_attribute.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
extended_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
fallback_image_test.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
game_of_life.wgsl Fix example game of life (#12897) 2024-04-08 17:19:07 +00:00
gpu_readback.wgsl Add gpu readback example (#12877) 2024-04-08 17:08:20 +00:00
instancing.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
irradiance_volume_voxel_visualization.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
line_material.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
post_processing.wgsl update shader imports (#10180) 2023-10-21 11:51:58 +00:00
shader_defs.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
show_prepass.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
specialized_mesh_pipeline.wgsl Add example showing how to use SpecializedMeshPipeline (#14370) 2024-07-31 18:24:58 +00:00
storage_buffer.wgsl Adds ShaderStorageBuffer asset (#14663) 2024-09-02 16:46:34 +00:00
texture_binding_array.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
tonemapping_test_patterns.wgsl move wgsl color operations from bevy_pbr to bevy_render (#13209) 2024-05-04 10:30:23 +00:00
water_material.wgsl Implement opt-in sharp screen-space reflections for the deferred renderer, with improved raymarching code. (#13418) 2024-05-27 13:43:40 +00:00