From b60cb657c7f22051a8ef0ce06a4f1e8ece1f6317 Mon Sep 17 00:00:00 2001 From: stoltembergg Date: Wed, 25 Nov 2026 15:53:34 +0000 Subject: [PATCH 1/2] GPU: skip pipeline demand for empty compute dispatches Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- crates/victory-gpu/src/draw.rs | 5 ++++ crates/victory-gpu/src/pipeline/make.rs | 36 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 461ba95..9ece2e9 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -2191,6 +2191,11 @@ impl State { /// Runs a dispatch on the host. pub(crate) fn dispatch(&mut self, list: &HostList, x: u32, y: u32, z: u32) { + // A zero-sized grid has no shader work: do not demand or wait for + // its pipeline. + if x == 0 || y == 0 || z == 0 { + return; + } // It may write the arguments a window holds clamped. self.window = None; #[cfg(feature = "diagnostics")] diff --git a/crates/victory-gpu/src/pipeline/make.rs b/crates/victory-gpu/src/pipeline/make.rs index b21b716..199c495 100644 --- a/crates/victory-gpu/src/pipeline/make.rs +++ b/crates/victory-gpu/src/pipeline/make.rs @@ -397,4 +397,40 @@ mod tests { assert!(Arc::ptr_eq(&queue.pop().unwrap(), &earlier)); assert!(queue.pop().is_none()); } + + #[test] + fn zero_group_dispatches_do_not_request_a_pipeline() { + use crate::object::{S_OK, slot}; + + let Some(host) = crate::host::host() else { + return; + }; + let list = host.new_list().unwrap(); + // A pending pipeline that cannot translate makes any accidental + // demand observable without depending on a shader's build time. + let mut title = std::ptr::null(); + assert_eq!( + crate::pipeline::hand_out( + Vec::new(), + None, + &crate::pipeline::PIPELINE_IIDS[0], + &mut title, + ), + S_OK + ); + let pending = &crate::pipeline::pipeline(title).host; + let mut state = crate::draw::State::default(); + state.set_pipeline(title); + let zero_demands = [(0, 1, 1), (1, 0, 1), (1, 1, 0)].map(|(x, y, z)| { + state.dispatch(&list, x, y, z); + pending.used.load(Ordering::Relaxed) + }); + state.dispatch(&list, 1, 1, 1); + let nonempty_demand = pending.used.load(Ordering::Relaxed); + list.close(); + slot:: u32>(title, 0x10)(title); + assert_eq!(zero_demands, [false; 3]); + assert!(nonempty_demand); + } + } From d510528b4ed2645e9e4b2e2068afbc645e4cd117 Mon Sep 17 00:00:00 2001 From: stoltembergg Date: Wed, 25 Nov 2026 15:55:33 +0000 Subject: [PATCH 2/2] GPU: document empty dispatches keeping indirect windows Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- crates/victory-gpu/src/draw.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/victory-gpu/src/draw.rs b/crates/victory-gpu/src/draw.rs index 9ece2e9..e8efb2a 100644 --- a/crates/victory-gpu/src/draw.rs +++ b/crates/victory-gpu/src/draw.rs @@ -167,7 +167,7 @@ const WINDOW_MOST: u64 = 64; /// the list's scratch buffer in one pass, and the draws that follow read /// their record there with no pass of ours and no barrier (the scratch /// buffer stays readable as arguments until the next clamp), until one of -/// these: a compute +/// these: a nonempty compute /// dispatch, a direct draw, an indirect call with a count buffer or more /// than one record, a draw whose shaders can store to buffers, a record /// outside the window, another host list.