On the M3 (MoltenVK 1.4.2) the runtime lane's
fetches_between_draws_read_every_earlier_draw_and_note_the_draw_itself
counted 3 fetch barriers for 4 draws. The cause: the race split
(DriverFact::InterlockedDrawsRaceUnderLoad, held by MoltenVK on Apple's
GPUs) tested InterlockedStorage::meets, which since the between-draws form
includes the fetch kinds. So on the M3's withheld venue each draw after
the first went into a new render pass instance (Split::InterlockedWrites)
instead of after the barrier. The white write took no barrier at all, and
each later fetch took the split plus the new instance's BEGUN barrier.
That ordered the draws twice.
The race is the interlock's. The fact's measure is of interlocked storage
images, which MoltenVK encodes as raster order group 0 with no barrier
inside its Metal render pass. Input attachments ordered between draws are
not interlocked, and their barrier is by region with INPUT_ATTACHMENT_READ
in its destination. MoltenVK's MVKCmdPipelineBarrier::encode (v1.4.2, on a
tile-based GPU) ends its Metal render pass and begins another for exactly
that barrier. The split now tests only the interlocked kinds
(InterlockedStorage::meets_interlocked). The fetch kinds take the Whole
barrier on every driver: one barrier per draw, as on lavapipe and the
RX 550. The lane test now asserts (barriers, interlocked splits) = (4, 0),
(3, 0) and (1, 0). Without the fix the M3 gives (3, 3) in the first section.
The second fallout is the validation executor's planner test
a_framebuffer_fetch_case_plans_its_ordered_input_attachment. It expected a
device with neither ordered form to refuse the fetch, which the product no
longer does. The executor is a consumer of that contract
(GraphicsState::rasterization_order_attachment_access): a pipeline with
input attachments and no rasterization-order access must be ordered between
draws by a barrier of the subpass's dependency on itself.
- The executor's render pass self-dependency now covers both directions:
color writes to input attachment and color reads, and fragment-shader
reads to color writes (FETCH_SELF_DEPENDENCY).
- It records that barrier before each of its draws where
fetches_between_draws holds, after the load operations too, as the
runtime does.
- The planner tests now plan the neither device: input attachment 0, no
rasterization-order access, neither ordered feature required, the note
on the fragment stage. Every public fetch case on lunarg-2023 and
vk12-floor plans the same way; a multisampled one may be refused as on
every device.
- The executor's device test of the halving fetch expects one instance
exact and three (one draw) each texel at some order's 2^-k on a device
with neither form, where it used to expect the refusal.
Verified: see the hkfbfetch-2 report (M3 lane module, lavapipe whole
validation suite, RX 550 module and executor fetch test, clippy).