diff --git a/crates/metal2vulkan-runtime/src/tests/event_wake_bench.rs b/crates/metal2vulkan-runtime/src/tests/event_wake_bench.rs index 23660d044..1bcfe533b 100644 --- a/crates/metal2vulkan-runtime/src/tests/event_wake_bench.rs +++ b/crates/metal2vulkan-runtime/src/tests/event_wake_bench.rs @@ -148,6 +148,7 @@ fn repeat(rig: &Rig, shape: Shape, value: u64, times: &mut Times) { assert!(start.elapsed() < WAIT, "the completed handler never ran"); std::thread::sleep(Duration::from_micros(50)); }; + super::scheduler_wakes::asleep(device, "the waiting command buffer's pass"); times.rescues += device.work_counts().scheduler_slice_rescues - before; let mut ahead_end = t0; for other in &ahead { diff --git a/crates/metal2vulkan-runtime/src/tests/scheduler_held_wakes.rs b/crates/metal2vulkan-runtime/src/tests/scheduler_held_wakes.rs index de218aa20..40c63ea66 100644 --- a/crates/metal2vulkan-runtime/src/tests/scheduler_held_wakes.rs +++ b/crates/metal2vulkan-runtime/src/tests/scheduler_held_wakes.rs @@ -33,6 +33,7 @@ //! `DeviceOptions::assume_submissions_merge`. use super::plan_room::device_with_room; +use super::scheduler_wakes::asleep; use crate::command_buffer::completion::trace::{self, Point}; use crate::{ Buffer, CommandBuffer, CommandBufferStatus, CommandQueue, Device, DeviceKind, DeviceOptions, @@ -181,6 +182,7 @@ fn a_kept_group_whose_completion_was_published_as_it_was_kept_goes_in_that_pass( completes(&second, "the second command buffer"); trace::release(Point::KeptGate); let took = completes(&kept, "the kept command buffer"); + asleep(&device, "the kept group's pass"); let after = device.work_counts(); let rescues = after.scheduler_slice_rescues - before.scheduler_slice_rescues; let kept_groups = after.groups_kept_pending - before.groups_kept_pending; @@ -265,6 +267,7 @@ fn a_held_batch_whose_wake_never_came_goes_at_the_next_slice() { completes(&first, "the first command buffer"); completes(&second, "the second command buffer"); let took = completes(&kept, "the kept command buffer"); + asleep(&device, "the kept group's pass"); let after = device.work_counts(); let steps = trace::stop(); let rescues = after.scheduler_slice_rescues - before.scheduler_slice_rescues; @@ -367,6 +370,7 @@ fn a_batch_held_for_an_unshared_queue_goes_at_the_completion_published_as_it_was trace::release(Point::Leave); let took = completes(&behind, "the command buffer behind"); completes(&ahead, "the first command buffer"); + asleep(&device, "the pass behind the first command buffer"); let after = device.work_counts(); let rescues = after.scheduler_slice_rescues - before.scheduler_slice_rescues; let looks = after.heads_held_for_unshared_isolation - before.heads_held_for_unshared_isolation; diff --git a/crates/metal2vulkan-runtime/src/tests/scheduler_wakes.rs b/crates/metal2vulkan-runtime/src/tests/scheduler_wakes.rs index d27ac9e2c..58cd79a77 100644 --- a/crates/metal2vulkan-runtime/src/tests/scheduler_wakes.rs +++ b/crates/metal2vulkan-runtime/src/tests/scheduler_wakes.rs @@ -127,7 +127,9 @@ fn settle(completed: &AtomicU64, count: u64, what: &str) { /// Wait until the scheduler's thread sleeps (`Scheduler::asleep`), failing where it stays awake /// for [`BOUND`]: what the last commit or completion set going is over, and no pass is under way. -fn asleep(device: &Device, what: &str) { +/// The counts a pass makes are then made: a pass counts a slice's rescue once its submission +/// returned (`WorkCounts::scheduler_slice_rescues`), which the batch's completion can come before. +pub(super) fn asleep(device: &Device, what: &str) { let since = Instant::now(); while !device.shared().scheduler.asleep() { assert!( diff --git a/crates/metal2vulkan-runtime/src/tests/submit_long_bench.rs b/crates/metal2vulkan-runtime/src/tests/submit_long_bench.rs index 1f33da3ee..bc8d324fc 100644 --- a/crates/metal2vulkan-runtime/src/tests/submit_long_bench.rs +++ b/crates/metal2vulkan-runtime/src/tests/submit_long_bench.rs @@ -285,6 +285,7 @@ fn run(device: &Device, arm: Arm, chain: &Chain, fill: &Buffer) -> (WorkCounts, for command_buffer in flight { command_buffer.wait_until_completed_for(WAIT).unwrap(); } + super::scheduler_wakes::asleep(device, "the arm's last pass"); let after = device.work_counts(); stop.store(true, Ordering::Relaxed); if let Some(thread) = compositor {