diff --git a/crates/metal2vulkan-runtime/src/render.rs b/crates/metal2vulkan-runtime/src/render.rs index 8b7054de2..8e646118a 100644 --- a/crates/metal2vulkan-runtime/src/render.rs +++ b/crates/metal2vulkan-runtime/src/render.rs @@ -1383,9 +1383,9 @@ pub(crate) struct RenderLowering { core: EncoderCore, /// The pass's instances before the current one, which the draws record into. earlier: Vec, - /// The instance the draws record into, in a box: the encoder moves as its pass ends, and - /// the instance with it by its box (`end_pass`). - current: Box, + /// The instance the draws record into, in the encoder's box, which its open makes once + /// (`assemble`): no box of its own to make at each open. + current: Instance, /// Versioned, as the state and the amplification are: a draw's shape is derived from them /// (`render/draw_shape.rs`). layout: Versioned, @@ -1993,7 +1993,7 @@ impl RenderLowering { Box::new(RenderLowering { core, earlier: Vec::new(), - current: Box::new(Instance { + current: Instance { draws, shape: Versioned::new(shape.clone()), compatible: Arc::clone(&compatible), @@ -2021,7 +2021,7 @@ impl RenderLowering { planned: false, feedback: Feedback::NONE, storage_colors: 0, - }), + }, state: Versioned::new(EncoderState::metal_defaults(area)), scissors: ScissorRects::metal_default(area), render_target_array_length, @@ -4095,10 +4095,8 @@ impl RenderLowering { // The bind state its last draw left, which the device's next render encoder starts from // (`live_bind.rs`): no draw holds it once the encoder ends. core.device().shared().live_binds.give(live); - // The pass's instances in order, each by a box: the current one's, and the earlier ones' - // (a pass split) each moved into one. - let mut instances = Vec::with_capacity(earlier.len() + 1); - instances.extend(earlier.into_iter().map(Box::new)); + // The pass's instances in order: the earlier ones (a pass split), then the current one. + let mut instances = earlier; instances.push(current); // The first instance's render pass and framebuffer, where it recorded inline in the // command buffer the encoder holds for the pass (`render/inline_first.rs`), and the @@ -5279,7 +5277,7 @@ impl RenderLowering { shadows: gathered, drawn: instance_drawn, .. - } = *instance; + } = instance; if index == 0 { first_gathered = Some((gathered, instance_drawn)); } @@ -6080,7 +6078,7 @@ impl RenderLowering { let viewed = self .earlier .iter() - .chain([&*self.current]) + .chain([&self.current]) .any(|i| i.reformats.iter().any(|r| r.index == index as usize)); if copies.is_some() && viewed { return Err(Error::NotImplemented(RuntimeGap::Render)); @@ -6448,15 +6446,15 @@ impl RenderLowering { (false, false) => cause, }; self.core.device().shared().counts.instance_split(cause); - let previous = std::mem::replace(&mut self.current, instance); - self.earlier.push(*previous); + let previous = std::mem::replace(&mut self.current, *instance); + self.earlier.push(previous); self.barrier_splits += usize::from(self.barrier); if self.barrier { self.reload_at.insert(self.earlier.len()); } } else { // It takes the place of the current one, whose draws it records again. - let mut instance = instance; + let mut instance = *instance; instance.drawn.join(&self.current.drawn); let replaced = std::mem::replace(&mut self.current, instance); self.end_unrun(&replaced); @@ -6697,7 +6695,7 @@ impl RenderLowering { && self .earlier .iter() - .chain([&*self.current]) + .chain([&self.current]) .any(|instance| instance.reformats.iter().any(|r| r.copies)) } diff --git a/crates/metal2vulkan-runtime/src/render/executions.rs b/crates/metal2vulkan-runtime/src/render/executions.rs index ed7b3271d..71e891ed9 100644 --- a/crates/metal2vulkan-runtime/src/render/executions.rs +++ b/crates/metal2vulkan-runtime/src/render/executions.rs @@ -2251,7 +2251,7 @@ impl RenderExecution { // begun against a pass compatible with it: a pass of one subpass ignores its resolves. let ending = PassShape::of(pass)?; let mut runs = Vec::with_capacity(earlier.len() + 1); - for run in earlier.into_iter().chain([*current]) { + for run in earlier.into_iter().chain([current]) { let other = (*run.shape != snapshot.shape || run.views != ViewSetup::default()).then(|| { let mut shape = run.shape.clone(); @@ -2324,7 +2324,7 @@ impl RenderExecution { RenderLowering { core, earlier: Vec::new(), - current: Box::new(Instance { + current: Instance { draws, shape: Versioned::new(snapshot.shape.clone()), compatible: Arc::clone(&snapshot.compatible), @@ -2358,7 +2358,7 @@ impl RenderExecution { planned: false, feedback: Feedback::NONE, storage_colors: 0, - }), + }, layout: Versioned::new(layout), passes: vec![(snapshot.shape.clone(), Arc::clone(&snapshot.compatible))], render_target_array_length: snapshot.render_target_array_length, diff --git a/crates/metal2vulkan-runtime/src/render/reroute.rs b/crates/metal2vulkan-runtime/src/render/reroute.rs index b3912a13d..3b5f2e30f 100644 --- a/crates/metal2vulkan-runtime/src/render/reroute.rs +++ b/crates/metal2vulkan-runtime/src/render/reroute.rs @@ -180,7 +180,7 @@ impl RenderLowering { }; let previous_layout = stood.map(|layout| std::mem::replace(&mut *self.layout, *layout)); self.kept_attachments = None; - let mut previous = std::mem::replace(&mut self.current, instance); + let mut previous = std::mem::replace(&mut self.current, *instance); let mut again = Ok(()); if let Some(draws) = previous.rerecord.as_mut() { for kept in draws.iter_mut() { diff --git a/crates/metal2vulkan-runtime/src/render/untouched.rs b/crates/metal2vulkan-runtime/src/render/untouched.rs index 64a728f29..908bcc2d8 100644 --- a/crates/metal2vulkan-runtime/src/render/untouched.rs +++ b/crates/metal2vulkan-runtime/src/render/untouched.rs @@ -38,11 +38,7 @@ use crate::render_values::{LoadAction, StoreAction}; /// module docs): `called` false (no draw call), `instances` one that nothing recorded into, and its /// attachments' load and store actions as settled (an unknown store made `DontCare`) keeping every /// texel, no depth written with a NaN before it. -pub(super) fn changes_nothing( - layout: &PassLayout, - called: bool, - instances: &[Box], -) -> bool { +pub(super) fn changes_nothing(layout: &PassLayout, called: bool, instances: &[Instance]) -> bool { let keeps = |load: LoadAction, store: StoreAction| { matches!(load, LoadAction::Load | LoadAction::DontCare) && matches!(store, StoreAction::Store | StoreAction::DontCare) diff --git a/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs b/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs index b6d2c5c28..e2823e568 100644 --- a/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs +++ b/crates/metal2vulkan-validation/src/runtime_lane/frame_costs.rs @@ -308,8 +308,9 @@ const DRAW_ALLOCATIONS_DEBUG: f64 = 20.0; /// platforms: its shape's lists (`color_list.rs`), its encoder's default viewport and scissor /// rectangle (`render_state::ViewportList`), its attachments' extents and its tracker's first part /// (`tracker::EncoderUses`) are held in place, and its lowering is boxed once where it is built -/// (`render.rs`), which the encoder then moves as a pointer. Measured: 4.00 on lavapipe in a build -/// with debug assertions; 5.00 on the M3 Max through MoltenVK. +/// (`render.rs`), its current instance inside that box, which the encoder then moves as a pointer. +/// Measured: 4.00 on lavapipe in a build with debug assertions; 5.00 on the M3 Max through +/// MoltenVK. #[cfg(not(m2v_system_alloc))] const OPEN_ALLOCATIONS: f64 = 4.5; /// The most allocations a frame's pass end (`end_encoding`) makes on the encoding thread on