From ab86ef7f3ffba5cb7e8e21009f28f437222087da Mon Sep 17 00:00:00 2001 From: local Date: Wed, 25 Nov 2026 15:42:59 -0600 Subject: [PATCH] A pipeline a list binds again is not kept and named again (from Belobug 92d353f8, romainhedouin) Two queries for an interface, three locks and a name looked up at every change of pipeline; now one lookup by address. Co-Authored-By: Claude Opus 5.5 --- crates/victory-gpu/src/draw.rs | 4 +--- crates/victory-gpu/src/host.rs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 88729fc..2641d9c 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -1460,10 +1460,8 @@ impl State { // SAFETY: an open list and a live pipeline. unsafe { l.SetPipelineState(&p.pso) }; self.host_pipeline = p.pso.as_raw() as usize; - list.used_pipeline(&p.name); // The title may release the pipeline before it submits the list. - list.keep(&p.pso); - list.keep(&p.root); + list.bind_pipeline(&p.name, &p.pso, &p.root); } for stage in &p.stages { let t = stage.translated(); diff --git a/crates/victory-gpu/src/host.rs b/crates/victory-gpu/src/host.rs index bbb733b..da8f6da 100644 --- a/crates/victory-gpu/src/host.rs +++ b/crates/victory-gpu/src/host.rs @@ -2181,6 +2181,8 @@ struct Deferred { /// descriptor heaps): the title may release its objects before it /// submits the list. kept: Vec, + /// The pipelines [`HostList::bind_pipeline`] kept, by address. + bound: std::collections::HashSet>, /// Buffer ranges refreshed since the last title copy (host copy, /// address, bytes): refreshing them again would find the same bytes. refreshed: std::collections::HashSet<(usize, usize, usize), std::hash::BuildHasherDefault>, @@ -6624,6 +6626,21 @@ impl HostList { } } + /// The list binds a pipeline: it and its root signature are kept until + /// the list is reset, and its name noted, the first time only (a kept + /// pipeline's address names no other). + pub(crate) fn bind_pipeline(&self, name: &str, pso: &ID3D12PipelineState, root: &ID3D12RootSignature) { + { + let mut deferred = self.deferred(); + if !deferred.bound.insert(pso.as_raw() as usize) { + return; + } + deferred.kept.push(pso.clone().into()); + deferred.kept.push(root.clone().into()); + } + self.used_pipeline(name); + } + fn deferred(&self) -> std::sync::MutexGuard<'_, Deferred> { self.deferred.lock().unwrap_or_else(|e| e.into_inner()) }