From 467e7441efe3f126d006e436f75d83aed2dd4555 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 26 Nov 2026 18:02:57 -0800 Subject: [PATCH] Runtime docs: what with_present_queue's closure may wait for, by its reason The contract said `f` "waits for no work of the runtime's". By its words that forbids a vkQueueWaitIdle on the presenting queue, which a consumer runs under the lock where its device has no present fences, and which Vulkan requires to run with the queue externally synchronized. It now says what holds. `f` waits for nothing that needs a thread of the runtime's or the lock it holds. A wait for work already submitted ends. Where the family has one queue, the wait holds every submission of the runtime for its length. The reason a wait for submitted work ends (files read at 0c0aab0df9): no batch the runtime submits waits on a signal that only a later submission gives. - Search: `git grep -n -E 'wait_semaphore_infos|wait_semaphores\(|p_wait_semaphores|queue_bind_sparse|queue_submit2?\('` over crates/metal2vulkan-runtime/src, tests excluded. Its submission hits: submit.rs:2803 and :2824, and import.rs:335. The other hits are host-side semaphore waits. - A submission's only semaphore waits are its first segment's wait for a sparse bind (submit.rs:2783-2791, `Sparse::owed`). That bind's signal was submitted earlier, by vkQueueBindSparse under the same runtime-queue lock (import.rs:308-341), before `owed` is set. - A bind sparse waits on nothing. - Segments stage signals only (submit.rs:2278-2311, `stage`). - encodeWaitForEvent submits no semaphore wait: the submit thread holds the segment until the event's value is reached (command.rs:557-563). - The runtime makes no present and no acquire call: zero hits for queue_present and acquire_next_image outside the tests. Docs only, outside pin 1b908464ea. --- crates/metal2vulkan-runtime/src/device.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/metal2vulkan-runtime/src/device.rs b/crates/metal2vulkan-runtime/src/device.rs index 125d78ad5..f69141f7b 100644 --- a/crates/metal2vulkan-runtime/src/device.rs +++ b/crates/metal2vulkan-runtime/src/device.rs @@ -1056,9 +1056,12 @@ impl Device { /// so `f` and the runtime never submit at once. /// /// The queue is externally synchronized only inside `f`, so the Vulkan calls `f` makes with it - /// keep no handle past its return. `f` waits for no work of the runtime's, which may need the - /// lock `f` holds; a present in `f` waits only on semaphores whose signal is already submitted: - /// the command buffer that presents the image + /// keep no handle past its return. `f` waits for nothing that needs a thread of the runtime's + /// or the lock `f` holds. A wait for work already submitted to the queue ends + /// (`vkQueueWaitIdle` included: no batch the runtime submits waits on a signal that only a + /// later submission gives), and where the family has one queue it holds every submission of + /// the runtime for its length. A present in `f` waits only on semaphores whose signal is + /// already submitted: the command buffer that presents the image /// ([`CommandBuffer::present_drawable`](crate::CommandBuffer::present_drawable)) is /// scheduled ([`CommandBuffer::wait_until_scheduled`](crate::CommandBuffer::wait_until_scheduled) /// has returned for it, or `f` runs in its scheduled handler).