A fence used on a second queue was refused (Gap::FenceOtherQueue): 18 refusals in a
live boot on a 780M, every one a fence update on a second queue. The rule was ours,
from a replay census in which no fence crossed queues, not Metal's contract: the headers
say a fence update and wait are each "evaluated at kernel submission to maintain global
order and prevent deadlock", and MTLFence.h says nothing about queues.
What Metal does, measured (probe cross_queue_fence_held_update.m, M3 Max, macOS 27.0.1,
jobs m3-max-52186, m3-max-52188, m3-max-52194, plain and under the validation layer):
a wait on queue B waits for an update on queue A submitted before it (untracked
buffers: B starts 0.3-1 us after A ends and reads all its words; with no fence B runs
beside A and reads none); a wait with no work after it waits too (its handler 0.11-0.16
ms after A's GPU end); an update in a command buffer Metal holds, at an MTLSharedEvent
or MTLEvent wait, behind one held so, or behind an uncommitted enqueue, is not waited
for (B completes in 0.2-3.5 ms without A's writes, A still Committed).
Every rt queue submits to the device's one VkQueue and each segment ends with a
barrier, so a wait sees every update submitted before it. B passes A in four places:
(i) A's head held at an event wait, (iii) behind an uncommitted enqueue, both Metal's
own behaviour per the probe, so no hold and no gap; (ii) A's command buffer in a group
the submit thread holds while A's submissions run, and (iv) held groups released in
FIFO order rather than commit order, both rt's own. For those: each command buffer
keeps the fences its encoders wait on and update (empty, nothing allocated, when it
uses none); before a segment of a command buffer that waits on a fence is staged, the
submit thread sends first any other queue's held group (member or partial head) that
updates one, by send_through as a host wait does. A command buffer with nothing for the
GPU that waits on a fence retires no earlier than the last submission carrying an
update of it (the fence keeps that progress value, set in close). Same-queue fence use
is unchanged in submissions; no fence: one empty-Vec test per staged segment.
Tests: the two other-queue cases turned to accept; a new device test with A held in a
group behind the busy gate: (1) B's wait committed after reads A's fill, (2) B's wait
held at a shared event, released after A's later update joined the group, reads it,
(3) B's fence-only wait does not complete before A's update; and a corner test: a wait
on B runs while A's update is held at an event wait or behind an enqueue, without its
write, then A runs once let go. Docs: fence.rs, the three encoder sites, the rt README,
REFUSALS regenerated, api_signatures.tsv loses the variant.