Skip to content

Commit

Permalink
Remove COPY_DST from AsBindGroup uniform buffers (#16705)
Browse files Browse the repository at this point in the history
# Objective
- Wgpu barrier tracking is expensive. Making buffers read-only makes
ideally lets wgpu skip worrying about barriers, although in wgpu 23 it
apparently won't yet.

## Solution
- Remove COPY_DST usage from AsBindGroup uniform buffers to allow future
wgpu versions to make this cheaper.
- AsBindGroup never updates buffers, so there's no need for COPY_DST. We
always recreate all buffers and the bind group every time data changes,
which yeah is also expensive.

## Testing
- Ran the animated materials example with/without bindless enabled. No
crashes.
  • Loading branch information
JMS55 authored Dec 16, 2024
1 parent 35826be commit 1e5d2c8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_render/macros/src/as_bind_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result<TokenStream> {
#render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data(
&#render_path::render_resource::BufferInitDescriptor {
label: None,
usage: #render_path::render_resource::BufferUsages::COPY_DST | #uniform_buffer_usages,
usage: #uniform_buffer_usages,
contents: buffer.as_ref(),
},
))
Expand Down Expand Up @@ -529,7 +529,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result<TokenStream> {
#render_path::render_resource::OwnedBindingResource::Buffer(render_device.create_buffer_with_data(
&#render_path::render_resource::BufferInitDescriptor {
label: None,
usage: #render_path::render_resource::BufferUsages::COPY_DST | #uniform_buffer_usages,
usage: #uniform_buffer_usages,
contents: buffer.as_ref(),
},
))
Expand Down

0 comments on commit 1e5d2c8

Please sign in to comment.