diff --git a/wgpu-core/src/command/bind.rs b/wgpu-core/src/command/bind.rs index d17144a27..55dc5269e 100644 --- a/wgpu-core/src/command/bind.rs +++ b/wgpu-core/src/command/bind.rs @@ -7,7 +7,7 @@ use thiserror::Error; use crate::{ binding_model::{BindGroup, LateMinBufferBindingSizeMismatch, PipelineLayout}, pipeline::LateSizedBufferGroup, - resource::{Labeled, ResourceErrorIdent}, + resource::{Labeled, ParentDevice, ResourceErrorIdent}, }; mod compat { @@ -336,12 +336,20 @@ impl Binder { } } + /// Returns `true` if the pipeline layout has been changed, i.e. if the + /// new PL was not the same as the old PL. pub(super) fn change_pipeline_layout<'a>( &'a mut self, new: &Arc, late_sized_buffer_groups: &[LateSizedBufferGroup], - ) { - let old_id_opt = self.pipeline_layout.replace(new.clone()); + ) -> bool { + if let Some(old) = self.pipeline_layout.as_ref() { + if old.is_equal(new) { + return false; + } + } + + let old = self.pipeline_layout.replace(new.clone()); self.manager.update_expectations(&new.bind_group_layouts); @@ -372,12 +380,14 @@ impl Binder { } } - if let Some(old) = old_id_opt { + if let Some(old) = old { // root constants are the base compatibility property if old.immediate_size != new.immediate_size { self.manager.update_start_index(0); } } + + true } pub(super) fn assign_group<'a>( diff --git a/wgpu-core/src/command/pass.rs b/wgpu-core/src/command/pass.rs index 0ded4bf1e..fc3ce3494 100644 --- a/wgpu-core/src/command/pass.rs +++ b/wgpu-core/src/command/pass.rs @@ -202,18 +202,10 @@ pub(super) fn change_pipeline_layout( where E: From, { - if state.binder.pipeline_layout.is_none() - || !state - .binder - .pipeline_layout - .as_ref() - .unwrap() - .is_equal(pipeline_layout) + if state + .binder + .change_pipeline_layout(pipeline_layout, late_sized_buffer_groups) { - state - .binder - .change_pipeline_layout(pipeline_layout, late_sized_buffer_groups); - f(); super::immediates_clear(