mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
a4640046fc
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> |
||
---|---|---|
.. | ||
animate_shader.wgsl | ||
array_texture.wgsl | ||
cubemap_unlit.wgsl | ||
custom_gltf_2d.wgsl | ||
custom_material.frag | ||
custom_material.vert | ||
custom_material.wgsl | ||
custom_material_2d.wgsl | ||
custom_material_import.wgsl | ||
custom_material_screenspace_texture.wgsl | ||
custom_phase_item.wgsl | ||
custom_ui_material.wgsl | ||
custom_vertex_attribute.wgsl | ||
extended_material.wgsl | ||
fallback_image_test.wgsl | ||
game_of_life.wgsl | ||
gpu_readback.wgsl | ||
instancing.wgsl | ||
irradiance_volume_voxel_visualization.wgsl | ||
line_material.wgsl | ||
post_processing.wgsl | ||
shader_defs.wgsl | ||
show_prepass.wgsl | ||
specialized_mesh_pipeline.wgsl | ||
storage_buffer.wgsl | ||
texture_binding_array.wgsl | ||
tonemapping_test_patterns.wgsl | ||
water_material.wgsl |