Hold the reach model and the restart bit to a driver that is not Metal

Content: the tree of `development` at 88df41783c, unchanged.
This commit is contained in:
Anees Iqbal committed 2026-10-26 13:19:14 +02:00
1 parent c661480b2d
commit 890efb3267
3 files changed
+72 -19

No files matched your search

@@ -73,31 +73,52 @@
//! one, so a side that read the viewport or the scissor in render-area coordinates rather than
//! the attachment's fails it. A per-value sweep of `renderTargetWidth` cannot make either claim.
//!
//! # What this case can and cannot prove **on a device that renders through Metal**
//! # Which driver each claim rests on
//!
//! Said here because it was measured rather than reasoned, and because a reader who skips it will
//! over-read a green run on this Mac.
//! Said here because it was measured rather than reasoned, and because a reader who takes a green
//! run on a Metal venue for the whole proof will over-read it.
//!
//! Our runtime reaches Metal's reach by clearing it before the pass itself
//! (`clear_reach.rs`'s `ReachClears`) — but **on MoltenVK it would get the same answer without
//! doing so**, because the driver underneath is Metal and Metal's own tiles do it. Measured:
//! replacing `reach`'s rounding with the render area exactly, in the runtime, moves **not one
//! texel** of this grid on an M3 Max. So a green run here says the two legs agree and says
//! **nothing** about whether our reach model is right; the `TILE` of 32, the rounding up and the
//! clipping are still held by a probe alone on every non-Metal driver.
//! (`clear_reach.rs`'s `ReachClears`) — but **on MoltenVK it gets the same answer without doing
//! so**, because the driver underneath is Metal and Metal's own tiles do it. Measured: replacing
//! `reach`'s rounding with the render area exactly, in the runtime, moves **not one texel** of this
//! grid on an M3 Max. So a green run there says the two legs agree and says **nothing** about
//! whether our reach model is right.
//!
//! What a green run here *does* say is measured too, by the falsification that does land: making
//! the render area ignore `renderTargetWidth` and `renderTargetHeight` diverges at exactly the
//! four cells whose area is smaller than the attachment **and** whose load is `Clear` **and** which
//! have a draw call, and leaves `whole-area/*`, `area-33x33` (whose reach is already the whole
//! attachment), `area-32x32/clear/no-draw-call` and every `Load` cell exact. So the two numbers
//! reach the device and bound the clear, per axis, and that is a claim only the pair can make: at
//! the whole-attachment value, or under a `Load` load, or without a draw call, the bound is
//! invisible.
//! What a green run on a Metal venue *does* say is measured too, by the falsification that does
//! land there: making the render area ignore `renderTargetWidth` and `renderTargetHeight` diverges
//! at exactly the four cells whose area is smaller than the attachment **and** whose load is
//! `Clear` **and** which have a draw call, and leaves `whole-area/*`, `area-33x33` (whose reach is
//! already the whole attachment), `area-32x32/clear/no-draw-call` and every `Load` cell exact. So
//! the two numbers reach the device and bound the clear, per axis, and that is a claim only the
//! pair can make: at the whole-attachment value, or under a `Load` load, or without a draw call,
//! the bound is invisible.
//!
//! Closing the other half wants this case **replayed on a driver that is not Metal** (lavapipe,
//! RADV, ANV), where the runtime must synthesize the reach and the model is on the observable path.
//! **The reach model itself is evidenced on llvmpipe**, where the runtime must synthesize the reach
//! and `reach` is on the observable path. The case replays exact there (llvmpipe, LLVM 23.1.1, 256
//! bits, x86-64, Mesa's lavapipe), and the same one-line falsification — `reach` returning the
//! render area clipped to the attachment, with no rounding — moves **three** of the ten cells and
//! exactly those three:
//!
//! | cell | texels that move | the first of them |
//! |---|---|---|
//! | `area-33x33/clear/drawing` | 511 = 1600 − 33·33 | row 0, column 33 |
//! | `area-8x40/clear/drawing` | 960 = 32·40 − 8·40 | row 0, column 8 |
//! | `area-40x8/clear/drawing` | 960 = 40·32 − 40·8 | row 8, column 0 |
//!
//! Each moved texel holds the priming pass's value where Metal holds the test pass's clear, so the
//! three say the rounding reaches those texels and nothing else does. `whole-area/*`,
//! `area-32x32/clear/drawing`, `area-32x32/clear/no-draw-call`,
//! `area-32x32/clear/draw-covers-nothing` and every `Load` cell stay exact under it, which is the
//! model's own shape: 40 and 32 are whole tiles already, the no-draw cell clears the whole level
//! whatever the area, and a `Load` load clears nothing. The pair `area-8x40` and `area-40x8` is
//! what pins the tile to **32** rather than 16 or 64 — a tile of 16 would reach 16 and one of 64
//! would reach the attachment's 40, and both are what the exact baseline run rules out — and it
//! pins the rounding **per axis**, since each moves one axis alone. `area-33x33` is what pins the
//! **clip**: its reach is the rounded 64 cut back to 40, and dropping the rounding leaves 33.
//!
//! So `TILE`, the rounding up, the per-axis rule and the clip are held by execution on a driver
//! that is not Metal. RADV and ANV are unrun.
//! # Why every value here is defined on both sides
//!
//! A texel past the render area is only a comparable answer because the attachment's prior value
@@ -67,6 +67,29 @@
//! `tests::the_index_type_decides_only_for_a_strip` holds exactly that shape against the
//! recording.
//!
//! # Which driver holds the leg's own switch
//!
//! The recorded answers above measure **Metal's** behaviour directly, on any venue. The *runtime's*
//! reading of it is one pipeline bit — `primitiveRestartEnable`, set for strips only, in
//! `metal::state::input_assembly` — and that bit is **unobservable on MoltenVK**: clearing it for
//! `VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP` moved no texel of this case on an M3 Max, because the
//! driver underneath is Metal and Metal restarts its own strips whatever the Vulkan pipeline asks.
//! Swapping the strip topology for a list there does move the two `TriangleStrip` cells, so the
//! case is not vacuous on a Metal venue, but it is not the bit that it reads.
//!
//! **The bit is evidenced on llvmpipe** (LLVM 23.1.1, 256 bits, x86-64, Mesa's lavapipe), which
//! honours it. Clearing it for `TRIANGLE_STRIP` alone moves exactly one cell of the ten:
//! `TriangleStrip`/`UInt16`, by **26** texels, the first at row 1 column 0, where Metal holds the
//! clear (no fragment: the strip restarted) and we hold a fragment of the vertex the un-restarted
//! index fetched. `TriangleStrip`/`UInt32` stays exact under it, which is the cross's own claim
//! read back from the device: under `UInt32` the strip has no restart to suppress, because `0xffff`
//! is no sentinel there. Every `Point`, `Line`, `Triangle` and `LineStrip` cell is untouched by it,
//! the first three because they carry no restart at all. RADV and ANV are unrun.
//!
//! llvmpipe's own baseline is not exact at the four `Line` and `LineStrip` cells — 7, 7, 5 and 13
//! texels against the M3 Max's recording, its line rasterization rather than anything this case
//! states — so the falsification above is read against that baseline, which it leaves unmoved.
//!
//! # Nothing here can fault a GPU
//!
//! One pass a cell, one draw a pass, six indices a draw, over an 8 by 8 target, no loop in the
@@ -84,6 +84,15 @@ use std::collections::BTreeSet;
/// both axes: Metal's on the M3 Max and an M4, the same at every format, sample count and tile
/// size measured (the module docs). The one place the runtime states it: every device clears as
/// Metal's do.
///
/// **Executed on a driver that is not Metal.** On MoltenVK this constant is unobservable — the
/// driver is Metal and Metal's own tiles produce the reach whether [`reach`] rounds or not, so
/// replacing the rounding with the render area exactly moves no texel of the conformance suite's
/// `pass-bound-clear-reach` on an M3 Max. On llvmpipe (LLVM 23.1.1, x86-64) the runtime must
/// synthesize the reach, the case replays exact, and that same one-line change moves 511, 960 and
/// 960 texels of the case's `area-33x33`, `area-8x40` and `area-40x8` cells. The `8x40` and `40x8`
/// pair is what pins the side to 32 rather than 16 or 64, and pins the rounding to each axis on its
/// own; `area-33x33` is what pins the clip to the attachment. RADV and ANV are unrun.
pub(super) const TILE: u32 = 32;
/// The extent from the origin that a `Clear` load of an attachment of `extent` clears in a pass