From 4b1cdaf505856cd1ee0fef3f90bca21a61f17c0d Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Sun, 22 Nov 2026 13:59:12 -0800 Subject: [PATCH] Tests: the room-hold present tests signal a semaphore of their own, which the stand-in present waits on What: presenting_by_room presents with a binary semaphore it makes (present.rs's semaphore()), and once both command buffers complete, the stand-in present (show()) waits on it and copies the image out; the semaphore is destroyed with the stand-in. Why: the present named VK_NULL_HANDLE, which present_drawable's contract does not allow (ready is a binary semaphore of the device). With the spin fixed, the presenting command buffers reached the device, and both forms ended in SIGSEGV on lavapipe (m3-max-68769 at c4ba1b9d1d), the submission signalling no semaphore at all: the tests' own error, not the runtime's. Verified: see the jobs named where it is handed over. --- .../metal2vulkan-runtime/src/tests/present.rs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/tests/present.rs b/crates/metal2vulkan-runtime/src/tests/present.rs index 5b6fd44bf..6900d75d0 100644 --- a/crates/metal2vulkan-runtime/src/tests/present.rs +++ b/crates/metal2vulkan-runtime/src/tests/present.rs @@ -996,7 +996,8 @@ mod on_device { /// 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 present names no semaphore. + /// lock lets no handle drop. The present signals a binary semaphore of the test's, which the + /// stand-in present waits on once both have completed. fn presenting_by_room(form: &'static str) { use crate::tests::command::on_device::{word, Busy}; use crate::tests::compute::on_device::step; @@ -1043,7 +1044,8 @@ mod on_device { .unwrap_or_else(|error| panic!("{name}: an acquire: {error}")); let queue = device.new_command_queue(4).expect("a queue"); let other = device.new_command_queue(4).expect("a queue"); - let (x, y) = (arena.buffer(), arena.buffer()); + let (x, y, out) = (arena.buffer(), arena.buffer(), arena.buffer()); + let ready = semaphore(&device); let busy = Busy::new(&device); let retired: Arc>> = Arc::default(); let log = |command_buffer: &CommandBuffer, label: &'static str| { @@ -1062,8 +1064,10 @@ mod on_device { _ => pieces(&queue, &y), }; log(&presenting, form); - // SAFETY: no semaphore is named, and the drawable is acquired. - unsafe { presenting.present_drawable(&drawable, vk::Semaphore::null()) } + // SAFETY: `ready` is a binary semaphore of the device, unsignalled with no signal or + // wait pending, which lives past the command buffer and only the stand-in present + // waits on; the drawable is acquired. + unsafe { presenting.present_drawable(&drawable, ready) } .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 @@ -1118,11 +1122,16 @@ mod on_device { "{name}: {form}: it retires behind the pieces of its queue" ); } + let shown = show(&device, stand_in.image, ready, &out); + assert_eq!(shown, Ok(()), "{name}: {form}: the stand-in present"); drop(busy); drop(drawable); - // SAFETY: every submission that used the image has completed, and nothing uses it - // again. - unsafe { stand_in.destroy(&device) }; + // SAFETY: every submission that used the image, and that signalled or waited on the + // semaphore, has completed, and nothing uses either again. + unsafe { + stand_in.destroy(&device); + device.raw().device.destroy_semaphore(ready, None); + } }); }