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.
This commit is contained in:
Anees Iqbal committed 2026-11-26 18:02:57 -08:00
1 parent 0c0aab0df9
commit 467e7441ef
1 file changed
+6 -3
+6 -3
View File
@@ -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).