From d50eeb352239c4cac0493f8086b2b4b2cad772f3 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Fri, 27 Nov 2026 04:33:07 -0800 Subject: [PATCH] Runtime docs: what a timeline value seen on the host means, at the completion thread complete.rs's module doc now states the completion path's host side: a host wait (vkWaitSemaphores) or a counter read (vkGetSemaphoreCounterValue) at or above the value a submission signals means that signal operation has happened. It rests on the Vulkan specification's Queue Operation section (3.2.1: a semaphore is signaled only once earlier queue operations completed and their writes are available), Semaphore Signaling (7.4.1: a timeline semaphore is signaled with respect to its counter value) and VK_KHR_timeline_semaphore's issue 5 (the payload query is one of the two documented host waits). It also says that Host Operations on Semaphores (7.4.4) carries no execution-dependency sentence, unlike the fence wait, and that host visibility comes from record::end's host-reaching barrier (Reach::Host), then host coherence or the flush and invalidate of crate::coherence. Doc only: no behaviour change, no version bump. Verification: cargo fmt here; Rustdoc with -D warnings in the lane's lint job. --- crates/metal2vulkan-runtime/src/complete.rs | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/metal2vulkan-runtime/src/complete.rs b/crates/metal2vulkan-runtime/src/complete.rs index 22392edc8..e46804dbd 100644 --- a/crates/metal2vulkan-runtime/src/complete.rs +++ b/crates/metal2vulkan-runtime/src/complete.rs @@ -1,6 +1,28 @@ //! The completion thread: it retires command buffers and uploads as the GPU completes them, runs //! their completed handlers, follows the event signals it submitted and runs listeners, and ends //! the work in flight at a loss. +//! +//! **What a value seen on the host means.** A host wait (`vkWaitSemaphores`) or a counter read +//! (`vkGetSemaphoreCounterValue`) that finds a timeline semaphore at or above the value a +//! submission signals means that signal operation has happened: +//! +//! - the Vulkan specification's Queue Operation section (3.2.1): "Before a fence or semaphore is +//! signaled, it is guaranteed that any previously submitted queue operations have completed +//! execution, and that memory writes from those queue operations are available to future queue +//! operations."; +//! - its Semaphore Signaling section (7.4.1): a timeline semaphore "is considered signaled with +//! respect to the counter value set to be signaled"; +//! - `VK_KHR_timeline_semaphore`, issue 5: "Both a non-blocking query of the current payload value +//! of the synchronization primitive, and a blocking wait operation are provided.": the query is +//! one of the two documented forms of a host wait. +//! +//! Host Operations on Semaphores (7.4.4) carries no "defines an execution dependency" sentence, +//! unlike the fence wait's (7.3, Fences). Host visibility does not come from the semaphore: it +//! comes from the barrier `record::end` records at the end of each segment that writes Shared +//! memory or signals an event (`Reach::Host`, whose second scope is `ALL_COMMANDS | HOST` with +//! `HOST_READ` among its accesses). After it, host-coherent memory holds the writes for the host, +//! and where the Shared memory type is not host-coherent, the flush then invalidate of +//! `crate::coherence` makes them visible. use crate::capture::CopyIn; use crate::command::{self, CbInner, CommandBufferError, DeviceLoss, Gpu, Handlers, Pending};