From a044cc211dfb4b98730c659cecf6e4cd78fc703d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 18 Nov 2026 11:19:21 -0800 Subject: [PATCH] rt: the kept lists are boxed, so a retiring command buffer's item stays small; the handles' unused is goes The kept-object lists made Item::Command larger than clippy's large_enum_variant allows. The box travels with the lists between the queue's spares and the next command buffer, so a recording makes no allocation for it once the queue has one spare per slot. Texture::is and SamplerState::is have no caller left: a bind compares the handles' addresses. --- crates/metal2vulkan-rt/src/command.rs | 4 ++-- crates/metal2vulkan-rt/src/queue.rs | 4 ++-- crates/metal2vulkan-rt/src/sampler.rs | 5 ----- crates/metal2vulkan-rt/src/texture.rs | 6 ------ 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/crates/metal2vulkan-rt/src/command.rs b/crates/metal2vulkan-rt/src/command.rs index b289e31e4..54658764f 100644 --- a/crates/metal2vulkan-rt/src/command.rs +++ b/crates/metal2vulkan-rt/src/command.rs @@ -195,7 +195,7 @@ pub(crate) struct Gpu { /// copied, once each, kept until the command buffer retires: a buffer's block and device copy /// with it, and a texture's and a sampler's elements of set 1 stay theirs while work may read /// them (`crate::kept`). - pub(crate) kept: Objects, + pub(crate) kept: Box, /// What the commands wrote into the parameter ring. pub(crate) ring: Writes, /// A texture over a Managed buffer's device copy in an image of its own is kept: the submit @@ -282,7 +282,7 @@ impl CommandBuffer { queue: Arc, device: Device, slot: u32, - kept: Objects, + kept: Box, ) -> CommandBuffer { let stamps = (queue.stamps.pool, Stamps::first(slot)); CommandBuffer { diff --git a/crates/metal2vulkan-rt/src/queue.rs b/crates/metal2vulkan-rt/src/queue.rs index 575bc4e12..3a8c89734 100644 --- a/crates/metal2vulkan-rt/src/queue.rs +++ b/crates/metal2vulkan-rt/src/queue.rs @@ -47,7 +47,7 @@ struct Slots { free: Vec, /// The kept-object lists of retired command buffers, empty, with their capacity /// (`crate::kept`): at most one per slot. - objects: Vec, + objects: Vec>, } impl Slots { @@ -177,7 +177,7 @@ impl QueueInner { /// and `kept`, its kept-object lists emptied, for the next command buffer made. Its gauge falls /// first, so a command buffer made in the freed slot never reads one more live than the queue /// holds. - pub(crate) fn release(&self, slot: u32, kept: Objects) { + pub(crate) fn release(&self, slot: u32, kept: Box) { self.counters.fall(Gauge::CommandBuffers); let mut slots = lock(&self.slots); slots.free.push(slot); diff --git a/crates/metal2vulkan-rt/src/sampler.rs b/crates/metal2vulkan-rt/src/sampler.rs index 770218dca..c61bf83f2 100644 --- a/crates/metal2vulkan-rt/src/sampler.rs +++ b/crates/metal2vulkan-rt/src/sampler.rs @@ -373,11 +373,6 @@ fn make(core: &Core, desc: &SamplerDesc) -> Result { } impl SamplerState { - /// Whether two handles are one state. - pub(crate) fn is(&self, other: &SamplerState) -> bool { - Arc::ptr_eq(&self.inner, &other.inner) - } - /// Whether `core` is the device this state was made on. pub(crate) fn is_of(&self, core: &Arc) -> bool { Arc::ptr_eq(self.inner.device.core(), core) diff --git a/crates/metal2vulkan-rt/src/texture.rs b/crates/metal2vulkan-rt/src/texture.rs index 2b54e7fc3..de947d1fa 100644 --- a/crates/metal2vulkan-rt/src/texture.rs +++ b/crates/metal2vulkan-rt/src/texture.rs @@ -2249,12 +2249,6 @@ impl Texture { self.inner.id } - /// Whether `other` is this texture object: a view is not its parent, though it shares its - /// [`id`](Self::id), and each holds elements of set 1 and image views of its own. - pub(crate) fn is(&self, other: &Texture) -> bool { - Arc::ptr_eq(&self.inner, &other.inner) - } - /// Where the texture starts in its image: a view's first level and array layer. pub(crate) fn base(&self) -> [u32; 2] { self.inner.base()