From 1e5d2c88673e10ea2627f016c053e132a641f925 Mon Sep 17 00:00:00 2001 From: JMS55 <47158642+JMS55@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:38:48 -0800 Subject: [PATCH] Remove COPY_DST from AsBindGroup uniform buffers (#16705) # 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. --- crates/bevy_render/macros/src/as_bind_group.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/macros/src/as_bind_group.rs b/crates/bevy_render/macros/src/as_bind_group.rs index 489c0c4bb1d6c..96176e071ca6c 100644 --- a/crates/bevy_render/macros/src/as_bind_group.rs +++ b/crates/bevy_render/macros/src/as_bind_group.rs @@ -483,7 +483,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { #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(), }, )) @@ -529,7 +529,7 @@ pub fn derive_as_bind_group(ast: syn::DeriveInput) -> Result { #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(), }, ))