From f683293b4b5df5c62764d4aa856a7a794d3cf524 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Thu, 3 Dec 2026 03:35:47 -0800 Subject: [PATCH] Docs: a fetch may read the texel from before its draw, so overlapping read-modify-writes leave one UnorderedFetchWithinDraw's words said a pixel that overlapping fragments of one draw fetch and write "holds the result of some order of the draw's fragments", "not necessarily Metal's". The Radeon 780M (RADV, Mesa 26.2.6) shows otherwise. Job m3-max-83259 ran the eight authored cases the ordered_fetch_within_draw gap holds (n instances of the companion's fullscreen triangle in one draw, so n identical fragments at every pixel or sample) five times at 702916d9d3. All five outputs were identical. Every differing word is the fragment function applied once to the texel as it stood before the draw. Each case's chain f^k(initial), computed from its own inputs, gives Metal's stored output at k = n on every word, and the 780M's at k = 1 on every word that differs, all four lanes of each texel alike. All n fragments are identical, so every order of them gives Metal's value: the 780M's value is no order's result. Lavapipe matches Metal on the seven cases it runs (job m3-max-83255). The note now says what a fetch can observe there: it may read the texel from before its draw, so overlapping read-modify-writes of one draw may leave one application. Changed in docs/API.md's precision-note catalogue, PrecisionNote::UnorderedFetchWithinDraw's doc comment and the runtime README's known gap. Docs only, no behaviour change. The runtime-sources pin is unchanged (pin-compute.py gives a92fe0a8...). Verified: cargo fmt --all; nothing built. --- crates/metal2vulkan-runtime/README.md | 9 +++++---- crates/metal2vulkan/src/pipeline/artifact.rs | 12 +++++------- docs/API.md | 9 ++++----- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/metal2vulkan-runtime/README.md b/crates/metal2vulkan-runtime/README.md index c3b7f1eef..861cdaaef 100644 --- a/crates/metal2vulkan-runtime/README.md +++ b/crates/metal2vulkan-runtime/README.md @@ -5557,10 +5557,11 @@ cache is answered compile-required on both. texture is a colour render target of `Private` storage, read from the fragment function; and their stepped draws (a WebGL stream's, at rates 2 and 3) are all at base instance 0. - A fetch (`[[color(n)]]`) orders the fragments of earlier draws before it, not the fragments of its - own draw that cover the same pixel, which Metal orders in primitive order: a fragment may read the - texel from before an earlier fragment of its draw wrote it - (`PrecisionNote::UnorderedFetchWithinDraw`). Exact for a draw whose primitives do not overlap at a - pixel. A write the fragment function would compute over its own read of the attachment, where no + own draw that cover the same pixel, which Metal orders in primitive order: a fetch may read the + texel from before its draw, so overlapping read-modify-writes of one draw may leave one + application (`PrecisionNote::UnorderedFetchWithinDraw`). Exact for a draw whose primitives do not + overlap at a pixel. A write the fragment function would compute over its own read of the + attachment, where no Vulkan blend, write mask or logic operation gives Metal's, is not built: the translator refuses each such state at creation on every device, an `Error::Translation` (the conformance ledger's 22 such rows). Each is built on the runtime's own fetch form, the attachment's pushed texture diff --git a/crates/metal2vulkan/src/pipeline/artifact.rs b/crates/metal2vulkan/src/pipeline/artifact.rs index 7c73229c5..4698fafad 100644 --- a/crates/metal2vulkan/src/pipeline/artifact.rs +++ b/crates/metal2vulkan/src/pipeline/artifact.rs @@ -1884,13 +1884,11 @@ pub enum PrecisionNote { /// ([`PushField::FetchedColor`](crate::pipeline::PushField::FetchedColor)), and the /// consumer orders each fetching draw after the earlier draws of its pass by a barrier between /// them. Vulkan orders nothing between the overlapping fragments of one draw, where Metal - /// orders them in primitive order: a fragment that covers a pixel an earlier fragment of its - /// own draw covered may read the texel from before that fragment's write, and its own write may land - /// before that one. Exact for a draw whose primitives do not overlap at a pixel (one - /// fullscreen triangle, a rectangle of two triangles, disjoint quads); otherwise each such - /// pixel holds the result of some order of the draw's fragments there, not necessarily - /// Metal's. A raster order group on the color input, or on a color output of an attachment - /// the function reads, takes the same form there, without an interlock. + /// orders them in primitive order: a fetch may read the texel from before its draw, so + /// overlapping read-modify-writes of one draw may leave one application. Exact for a draw + /// whose primitives do not overlap at a pixel (one fullscreen triangle, a rectangle of two + /// triangles, disjoint quads). A raster order group on the color input, or on a color output + /// of an attachment the function reads, takes the same form there, without an interlock. /// /// Validation derives no tolerance from it: a difference stays a mismatch for review. UnorderedFetchWithinDraw, diff --git a/docs/API.md b/docs/API.md index 2fccabe7e..a8108372a 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1943,11 +1943,10 @@ category, and says what makes an operation carry the note and what may differ. E each fetching draw after the earlier draws of its pass by a barrier between them (the runtime's `Metrics::attachment_loop_reads`, or its copies into the attachment's shadow on a device without the attachment feedback loop). Vulkan orders nothing between the overlapping fragments of one draw - there, where Metal orders them in primitive order: a fragment that covers a pixel an earlier - fragment of its own draw covered may read the texel from before that fragment's write. Exact for a - draw whose primitives do not overlap at a pixel; otherwise each such pixel holds the result of - some order of the draw's fragments there. A raster order group on the color input, or on a color - output of an attachment the function reads, takes the same form. + there, where Metal orders them in primitive order: a fetch may read the texel from before its + draw, so overlapping read-modify-writes of one draw may leave one application. Exact for a draw + whose primitives do not overlap at a pixel. A raster order group on the color input, or on a + color output of an attachment the function reads, takes the same form. - `metal2vulkan-degrade-fp8-value` (precision). `PrecisionNote::Fp8Value`: An 8-bit float converts to an integer from the format's documented value with Metal's saturating float-to-integer rule, where Metal's device here answers otherwise: Metal on Apple M3 compiles these reads but extends