diff --git a/crates/metal2vulkan-runtime/src/tests/pieces.rs b/crates/metal2vulkan-runtime/src/tests/pieces.rs index bca8ae5a0..30873e01d 100644 --- a/crates/metal2vulkan-runtime/src/tests/pieces.rs +++ b/crates/metal2vulkan-runtime/src/tests/pieces.rs @@ -457,8 +457,8 @@ mod on_device { /// Behind a cut command buffer whose later pieces wait for room, a command buffer of its /// queue that holds nothing for the GPU, or one ended before it went (enqueued, its queue /// abandoned, then committed), is not held for room (`WorkState::hold`): it retires behind - /// the pieces, after them, as the room comes. The window is shown open first: two of the - /// four pieces submitted, the head held for room (`Metrics::held_for_room`). Its commit and + /// the pieces, after them, as the room comes. The window is shown open first: the head + /// scheduled with its first piece, two of its four pieces submitted 50 ms on. Its commit and /// both completions are waited for on another thread, within `BOUND` each; past it the test /// ends its process, as a submit thread that spins holding the work lock lets no handle drop. #[test] @@ -480,16 +480,13 @@ mod on_device { })) .expect("a completed handler"); }; - let (from, before) = (sent(&device, &queue), device.counters().metrics()); + let from = sent(&device, &queue); state.inner.compiled.rate.set_for_test(RATE); let pieces = queue.command_buffer().expect("a command buffer"); steps(&pieces, &state, &x, 4).end_encoding(); log(&pieces, "pieces"); pieces.commit().expect("a commit"); within(name, || order(&device, &pieces).len() == from + 2); - within(name, || { - device.counters().metrics().held_for_room > before.held_for_room - }); let behind = queue.command_buffer().expect("a command buffer"); log(&behind, form); if form == "ended" { @@ -497,10 +494,16 @@ mod on_device { behind.enqueue().expect("an enqueue"); queue.abandon(); } - println!( - "{name}: {form}: committed behind {} of 4 pieces submitted, held for room {}", - order(&device, &pieces).len() - from, - device.counters().metrics().held_for_room - before.held_for_room + // The window: the head scheduled with its first piece (held, `WorkState::step`), + // two of its four pieces on the device and, nothing completing behind the gate, + // the third waiting for room a while on. + thread::sleep(Duration::from_millis(50)); + let window = (pieces.status(), order(&device, &pieces).len() - from); + println!("{name}: {form}: committed behind the head at {window:?} of 4 pieces"); + assert_eq!( + window, + (CommandBufferStatus::Scheduled, 2), + "{name}: {form}: the head scheduled, its third piece waiting for room" ); let (tell, told) = mpsc::channel(); let watcher = { diff --git a/crates/metal2vulkan-runtime/src/tests/present.rs b/crates/metal2vulkan-runtime/src/tests/present.rs index c3725706b..4fdef261d 100644 --- a/crates/metal2vulkan-runtime/src/tests/present.rs +++ b/crates/metal2vulkan-runtime/src/tests/present.rs @@ -980,8 +980,8 @@ mod on_device { /// later pieces wait for room, one that only presents the drawable retires after the pieces /// ("behind"); and a cut command buffer that presents, its first piece waiting for the room /// another queue's pieces hold, goes as the room comes ("cut"). Behind the busy gate the - /// window is shown open first: two of the four pieces holding the room submitted, their head - /// held for room (`Metrics::held_for_room`). The presenting command buffer's commit and both + /// window is shown open first: the head of the pieces holding the room scheduled with its + /// first, two of its four submitted 50 ms on. The presenting command buffer's commit and both /// completions are waited for on another thread within `BOUND` each; past it the test ends /// its process, as a submit thread that spins holding the work lock lets no handle drop. The /// presents name no semaphore. @@ -997,7 +997,6 @@ mod on_device { const RATE: u64 = 3_000_000_000; each_device("present_hold", |name, _, device| { (device.grant_indices(IndexClass::Texture, 4096, 2)).expect("a grant"); - let counters = device.counters(); let state = step(&device); let mut arena = Arena::new(&device); let info = swapchain(USAGE); @@ -1044,14 +1043,10 @@ mod on_device { })) .expect("a completed handler"); }; - let before = counters.metrics(); let room = pieces(if form == "behind" { &queue } else { &other }, &x); log(&room, "pieces"); room.commit().expect("a commit"); within(name, || own(&room) == 2); - within(name, || { - counters.metrics().held_for_room > before.held_for_room - }); let presenting = match form { "behind" => queue.command_buffer().expect("a command buffer"), _ => pieces(&queue, &y), @@ -1060,10 +1055,18 @@ mod on_device { // SAFETY: no semaphore is named, and the drawable is acquired. unsafe { presenting.present_drawable(&drawable, vk::Semaphore::null()) } .unwrap_or_else(|error| panic!("{name}: {form}: a present: {error}")); + // The window: the room's head scheduled with its first piece (held, + // `WorkState::step`), two of its four pieces on the device and, nothing + // completing behind the gate, the third waiting for room a while on. + thread::sleep(Duration::from_millis(50)); + let window = (room.status(), own(&room)); println!( - "{name}: {form}: committed with {} of 4 pieces submitted, held for room {}", - own(&room), - counters.metrics().held_for_room - before.held_for_room + "{name}: {form}: committed with the room's head at {window:?} of 4 pieces" + ); + assert_eq!( + window, + (CommandBufferStatus::Scheduled, 2), + "{name}: {form}: the room's head scheduled, its third piece waiting for room" ); let (tell, told) = mpsc::channel(); let watcher = {