Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/victory-gpu/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")]
Expand Down
36 changes: 36 additions & 0 deletions crates/victory-gpu/src/pipeline/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<extern "system" fn(crate::object::This) -> u32>(title, 0x10)(title);
assert_eq!(zero_demands, [false; 3]);
assert!(nonempty_demand);
}

}
Loading