diff --git a/pipelined/bevy_wgpu2/src/bind_group.rs b/pipelined/bevy_wgpu2/src/bind_group.rs deleted file mode 100644 index 79ef492be2..0000000000 --- a/pipelined/bevy_wgpu2/src/bind_group.rs +++ /dev/null @@ -1,50 +0,0 @@ -use bevy_render2::{pipeline::BindGroupDescriptorId, render_resource::BindGroupId}; -use bevy_utils::tracing::trace; -use crate::resources::WgpuResourceRefs; - -pub enum Pass<'a, 'b> { - Render(&'b mut wgpu::RenderPass<'a>), - Compute(&'b mut wgpu::ComputePass<'a>), -} - -pub fn set_bind_group<'a, 'b>( - pass: Pass<'a, 'b>, - wgpu_resources: &WgpuResourceRefs<'a>, - index: u32, - bind_group_descriptor_id: BindGroupDescriptorId, - bind_group: BindGroupId, - dynamic_uniform_indices: Option<&[u32]>, -) { - if let Some(bind_group_info) = wgpu_resources - .bind_groups - .get(&bind_group_descriptor_id) - { - if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) { - const EMPTY: &[u32] = &[]; - let dynamic_uniform_indices = - if let Some(dynamic_uniform_indices) = dynamic_uniform_indices { - dynamic_uniform_indices - } else { - EMPTY - }; - wgpu_resources - .used_bind_group_sender - .send(bind_group) - .unwrap(); - - trace!( - "set bind group {:?} {:?}: {:?}", - bind_group_descriptor_id, - dynamic_uniform_indices, - bind_group - ); - - match pass { - Pass::Render(render_pass) => - render_pass.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices), - Pass::Compute(compute_pass) => - compute_pass.set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices), - } - } - } -} \ No newline at end of file diff --git a/pipelined/bevy_wgpu2/src/compute_pass.rs b/pipelined/bevy_wgpu2/src/compute_pass.rs index 0794834a3d..fd0a8209c2 100644 --- a/pipelined/bevy_wgpu2/src/compute_pass.rs +++ b/pipelined/bevy_wgpu2/src/compute_pass.rs @@ -1,10 +1,11 @@ -use crate::{WgpuRenderContext, bind_group::{self, Pass}, resources::WgpuResourceRefs}; +use crate::{resources::WgpuResourceRefs, WgpuRenderContext}; use bevy_render2::{ pass::ComputePass, pipeline::{BindGroupDescriptorId, ComputePipelineDescriptor, PipelineId}, render_resource::BindGroupId, renderer::RenderContext, }; +use bevy_utils::tracing::trace; #[derive(Debug)] pub struct WgpuComputePass<'a> { @@ -26,14 +27,34 @@ impl<'a> ComputePass for WgpuComputePass<'a> { bind_group: BindGroupId, dynamic_uniform_indices: Option<&[u32]>, ) { - bind_group::set_bind_group( - Pass::Compute(&mut self.compute_pass), - &self.wgpu_resources, - index, - bind_group_descriptor_id, - bind_group, - dynamic_uniform_indices, - ) + if let Some(bind_group_info) = self + .wgpu_resources + .bind_groups + .get(&bind_group_descriptor_id) + { + if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) { + const EMPTY: &[u32] = &[]; + let dynamic_uniform_indices = + if let Some(dynamic_uniform_indices) = dynamic_uniform_indices { + dynamic_uniform_indices + } else { + EMPTY + }; + self.wgpu_resources + .used_bind_group_sender + .send(bind_group) + .unwrap(); + + trace!( + "set bind group {:?} {:?}: {:?}", + bind_group_descriptor_id, + dynamic_uniform_indices, + bind_group + ); + self.compute_pass + .set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices); + } + } } fn set_pipeline(&mut self, pipeline: PipelineId) { diff --git a/pipelined/bevy_wgpu2/src/lib.rs b/pipelined/bevy_wgpu2/src/lib.rs index c3fec59955..c70413cb9b 100644 --- a/pipelined/bevy_wgpu2/src/lib.rs +++ b/pipelined/bevy_wgpu2/src/lib.rs @@ -8,7 +8,6 @@ mod render_resource_context; mod renderer; mod resources; mod type_converter; -mod bind_group; pub use compute_pass::*; pub use render_context::*; diff --git a/pipelined/bevy_wgpu2/src/render_pass.rs b/pipelined/bevy_wgpu2/src/render_pass.rs index 0b22f63061..a51367fdce 100644 --- a/pipelined/bevy_wgpu2/src/render_pass.rs +++ b/pipelined/bevy_wgpu2/src/render_pass.rs @@ -1,10 +1,11 @@ -use crate::{WgpuRenderContext, bind_group::{self, Pass}, resources::WgpuResourceRefs, type_converter::WgpuInto}; +use crate::{resources::WgpuResourceRefs, type_converter::WgpuInto, WgpuRenderContext}; use bevy_render2::{ pass::RenderPass, pipeline::{BindGroupDescriptorId, IndexFormat, RenderPipelineDescriptor, PipelineId}, render_resource::{BindGroupId, BufferId}, renderer::RenderContext, }; +use bevy_utils::tracing::trace; use std::ops::Range; #[derive(Debug)] @@ -61,14 +62,34 @@ impl<'a> RenderPass for WgpuRenderPass<'a> { bind_group: BindGroupId, dynamic_uniform_indices: Option<&[u32]>, ) { - bind_group::set_bind_group( - Pass::Render(&mut self.render_pass), - &self.wgpu_resources, - index, - bind_group_descriptor_id, - bind_group, - dynamic_uniform_indices, - ) + if let Some(bind_group_info) = self + .wgpu_resources + .bind_groups + .get(&bind_group_descriptor_id) + { + if let Some(wgpu_bind_group) = bind_group_info.bind_groups.get(&bind_group) { + const EMPTY: &[u32] = &[]; + let dynamic_uniform_indices = + if let Some(dynamic_uniform_indices) = dynamic_uniform_indices { + dynamic_uniform_indices + } else { + EMPTY + }; + self.wgpu_resources + .used_bind_group_sender + .send(bind_group) + .unwrap(); + + trace!( + "set bind group {:?} {:?}: {:?}", + bind_group_descriptor_id, + dynamic_uniform_indices, + bind_group + ); + self.render_pass + .set_bind_group(index, wgpu_bind_group, dynamic_uniform_indices); + } + } } fn set_pipeline(&mut self, pipeline: PipelineId) {