From a4e7f1d004bff927c205981c623142c8e7dbb4a4 Mon Sep 17 00:00:00 2001 From: FIocker <4461558+FIocker@users.noreply.github.com> Date: Tue, 24 Nov 2026 03:37:31 +0100 Subject: [PATCH] GPU: replay pending descriptors before publishing the host heap --- crates/victory-gpu/src/descriptor.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/victory-gpu/src/descriptor.rs b/crates/victory-gpu/src/descriptor.rs index 9ae83bd..20b33fb 100644 --- a/crates/victory-gpu/src/descriptor.rs +++ b/crates/victory-gpu/src/descriptor.rs @@ -85,15 +85,18 @@ impl Heap { return None; } let mut pending = self.pending.lock().unwrap_or_else(|e| e.into_inner()); - let h = self - .host - .get_or_init(|| host::HostHeap::new(self.samplers(), self.desc.count)) - .as_ref()?; - let step = u64::from(increment(self.desc.kind)?); - for i in pending.drain(..) { - h.mirror(i, self.start + u64::from(i) * step, false); - } - Some(h) + // A recorder can take the fast path as soon as the OnceLock is + // initialized. Publish only after replaying the queued writes. + self.host + .get_or_init(|| { + let step = u64::from(increment(self.desc.kind)?); + let h = host::HostHeap::new(self.samplers(), self.desc.count)?; + for i in pending.drain(..) { + h.mirror(i, self.start + u64::from(i) * step, false); + } + Some(h) + }) + .as_ref() } /// The descriptor index of `handle` in this heap, if it lies in it.