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.
This commit is contained in:
Anees Iqbal committed 2026-11-18 11:51:55 -08:00
1 parent 0a2f14fccb
commit a044cc211d
4 files changed
+4 -15

No files matched your search

+2 -2
View File
@@ -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<Objects>,
/// 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<QueueInner>,
device: Device,
slot: u32,
kept: Objects,
kept: Box<Objects>,
) -> CommandBuffer {
let stamps = (queue.stamps.pool, Stamps::first(slot));
CommandBuffer {
+2 -2
View File
@@ -47,7 +47,7 @@ struct Slots {
free: Vec<u32>,
/// The kept-object lists of retired command buffers, empty, with their capacity
/// (`crate::kept`): at most one per slot.
objects: Vec<Objects>,
objects: Vec<Box<Objects>>,
}
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<Objects>) {
self.counters.fall(Gauge::CommandBuffers);
let mut slots = lock(&self.slots);
slots.free.push(slot);
-5
View File
@@ -373,11 +373,6 @@ fn make(core: &Core, desc: &SamplerDesc) -> Result<vk::Sampler, Error> {
}
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<Core>) -> bool {
Arc::ptr_eq(self.inner.device.core(), core)
-6
View File
@@ -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()