Commit Graph
636 Commits
Author SHA1 Message Date
Anees Iqbal bc13149480 HostRam tests: fresh RAM a device imports; shared RAM a device refuses imports no chunk
On RADV (a Radeon 780M, Mesa 26.2.6) 8 of the 19 host_ram_device tests failed every run: every
test over fresh_ram, a memfd mapped shared as QEMU's memory-backend-memfd,share=on RAM is. RADV
imports a pointer through amdgpu's userptr, which takes private anonymous pages alone, so it
refuses those pages (Device::imports_shared_host_pointers answers false there): the device's
thread imported no chunk ("one chunk from the RAM's start", left 0), and a no-copy buffer over
the RAM was refused, Unsupported(HostMemory, NotRepresentable) (diagnosed on homelab-um870-1,
potluck jobs m3-max-2986, 3083 and 3119). The runtime's answer is the right one with no dma-buf
source; the tests asked RADV for RAM it cannot import.

fresh_ram now takes the device and maps the memory it imports: the memfd mapped shared where
imports_shared_host_pointers answers true (NVIDIA, lavapipe, MoltenVK), else private anonymous
memory, as QEMU's memory-backend-ram RAM is, both never touched and advised for huge pages.
ahead_device asks the probe once up front, so no test's counts or allocation limit meet its
one-page import. A new test pins the no-source case where the device refuses shared pointers:
a_ram_of_shared_memory_a_device_refuses_imports_no_chunk_and_refuses_its_objects makes the
memfd RAM, uses it, and expects the buffer over it refused (Unsupported, HostMemory), no chunk
imported or live, and the RAM's keep-alive dropped after the use; elsewhere it says so and
passes. use_host_ram's docs and HOWTO state that no-source case.

(cherry picked from commit 48202da5ba0c0cb7f49d0a630e59efd11c5918f7)
2026-11-07 05:09:36 -08:00
Anees Iqbal 99c195f869 Conformance ledger: lavapipe's held read-write rows follow the heap's alias views
f4c1fbd170 lets the heap view a held RGBA8Unorm_sRGB, BGRA8Unorm_sRGB or
BGR10A2Unorm read-write texture through its storage alias. On lavapipe
(CachyOS, LLVM 23.1.4, 256 bits, job m3-max-3206 on homelab-gem10-1)
read-write-tier-held's three `beyond` rows now dispatch, and their
read-back, status, stored and stored-bytes sites are exact; only texels
differ, by the device's own answers:

- BGR10A2Unorm: 10 elements one f32 ulp low (Metal 0x3E48320D, ours
  0x3E48320C), the device's reciprocal product, device-texel-conversion,
  as the slot path's row of read-write-tier-round-trip-float says;
- the two sRGB formats: 219 elements, the largest difference 64921 bits,
  the MSL transfer through the device's Pow where Metal takes its
  twelve-bit table (Metal 0x3BB80B81 = 23/4095, ours 0x3BB7AD6D, the
  transfer of code 17), srgb-texel-decode, which the runtime announced for
  the case in that run, as did device-pack-conversion.

So the 18 refused and only-Metal llvmpipe rows go and three native-answer
rows take their place, and norm-storage-fields-bgr10a2unorm's llvmpipe
refusal at case/hsw_held/dispatch (the same heap write, refused the same
way) goes: that site now dispatches. The NVIDIA rows wait for a 5080 run.

The engine_heap_binder table test now allows FLAG_RED_BLUE and checks it
is set on the BGRA8Unorm member alone (it failed at f4c1fbd170: "other
flags are reserved", left 4). read-write-tier-held's allowance comment
says when unnamed-texture-unviewable fires now. CONFORMANCE-COVERAGE.md
regenerated.

Verified at f4c1fbd170 (the binary of this commit differs only in the
ledger and that test): 317 of 318 selected metal2vulkan tests passed, the
one failure the table test fixed here; the replay's unlisted and stale
sites for these rows are the ones this commit lists and removes.

(cherry picked from commit 3e5ef48250375a08ec2f9eadccae7a83481add6b)
2026-11-07 04:56:07 -08:00
Anees Iqbal 3d5bb02ba0 Hold sRGB and blue-first read-write textures in an argument buffer
Metal reads and writes an RGBA8Unorm_sRGB, BGRA8Unorm_sRGB or
BGR10A2Unorm texture through access::read_write, and through an argument
buffer too (read-write-tier-held's `beyond` rows). The heap binder
refused such a member's storage element, NotImplemented
(ArgumentBufferTextures), wherever its storage choice was an alias:
lavapipe and NVIDIA store no 8-bit sRGB format and no A2R10G10B10, so
the dispatch's bind state was refused there, where a slot of the same
texture converts in the shader through the alias.

The heap now does what the slot does, keyed by what the handle carries:

- bind::heap::storage_conversions(profile) lists, per texel class index
  and red-blue order, the formats whose heap storage choice is an alias a
  function converts by (SwizzleBgra, SrgbEncode, SrgbEncodeBgra), one
  class per key; a key whose formats choose otherwise converts nothing.
  The binder views a member of such a choice through its alias (which its
  image lists among its view formats) instead of refusing it; another
  alias (RGB9E5Float's word, ARGB8's rotation, an RGBX format) and a
  swizzle that loses the class are still refused.
- A blue-first format shares its texel class with its red-first kin
  (BGR10A2Unorm with RGB10A2Unorm), so the handle-table entry gains
  FLAG_RED_BLUE (bit 2, metal::format::red_blue_exchanged: BGRA8Unorm,
  BGRA8Unorm_sRGB, BGR10A2Unorm), carried in handle bit 30 by a new
  Lookup::Flagged field where a module converts.
- lower::texture::heap_storage_conversions gives a heap storage read or
  write of a float or half texel the same list; emit::heap_converted
  exchanges red and blue and decodes or encodes the sRGB codes where the
  handle's key is listed, as from_image and to_image do for the slot
  classes. A read's decode notes SrgbTexelDecode and a write's encode
  DevicePackConversion, the slot's notes (rule 1: the device's own
  transfer), recorded outright as other heap accesses' are. On the M3
  Max's MoltenVK, which stores each of these formats itself, the list is
  empty: no conversion, no new note.

Tests: the binder's storage-member test now expects the aliased view
(lavapipe's three formats) and a refusal for the rest; a new test pins
lavapipe's and the M3's conversion lists; metal::format's new test ties
red_blue_exchanged to every committed profile's red-blue choices; the
search's host model and masks cover the new carried bit; an engine test
checks the notes and the carried bit on lavapipe and their absence on the
M3. SEMANTICS_VERSION 1978. docs/API.md's two note entries name the
argument-buffer form.

Verification: Linux unit tests and lavapipe and 5080 replays of
read-write-tier-held follow this commit (sent with the tip).

(cherry picked from commit f4c1fbd1702877f44060593d006dc3372838a112)
2026-11-07 04:56:07 -08:00
Anees Iqbal e9b236a978 Pull a FloatRGB9E5 vertex attribute on every device
Lavapipe reports VERTEX_BUFFER for E5B9G9R9_UFLOAT_PACK32, so a
FloatRGB9E5 attribute went to fixed-function input there, and lavapipe
answered 0 in the fourth component (Metal and Vulkan both say 1) and
other values in the first three: vertex-format-float4 and -half4
differed in 32 (LLVM 21.1.8) or 38 (LLVM 23.1) elements by up to 65409,
and vertex-format-instance-step in its 12 fourth components.

The decision is now structural, made from the format, not the driver:
fetch_as pulls the shared-exponent format on every profile
(fixed_function_format). Vulkan requires no device to fetch it as vertex
input (Table 95, "Mandatory Format Support: 64-bit/uneven Components",
lists only sampled-image features for it), and its decode has no rounding
to leave to the device: each component m * 2^(e - 24) is an f32 and the
fourth is 1. So the module's own decode (lower::stage_io::fetch) gives
the answer a conformant fixed-function fetch gives, and lavapipe gives it
too. FloatRG11B10, the other packed float, stays fixed function: its NaN
widening is the device's.

The vertex-format sweeps now compile two modules where they compiled one
(the pulled format's), and the engine tests say so. SEMANTICS_VERSION
1977: a FloatRGB9E5 attribute's projection and module change. The three
RGB9E5 rows of known-gaps.tsv go (vertex-format-float4 and -half4 on
LLVM 21.1.8, -instance-step on llvmpipe); the LLVM 23.1 pair went in
613a98e22d. docs/API.md's vertex_input entry says it.

Verification: in the commit after this (Linux unit tests, lavapipe
replays on CachyOS LLVM 23.1.4, LLVM 23.1.1 and Ubuntu LLVM 21.1.8, the
5080 and the M3 Max).

(cherry picked from commit 6f2a6f3572b130db513bf457a9daf365ea241951)
2026-11-07 04:56:07 -08:00
Anees Iqbal 8623866704 Conformance ledger: unlist two product bugs this stream's rows recorded
A ledger row is right only where the divergence is the device's native answer (owner, 11-07:
"If its a failure, fix it. Dont sweep it under the rug"). Two sets of rows this stream wrote
record product bugs instead, so they go, and the bugs go back to the orchestrator:

- read-write-tier-held on the RTX 5080 (18 rows): we refuse the dispatch's bind state,
  `Unsupported(ArgumentBufferTextures, NotImplemented)`, for a read-write texture of a `beyond`
  format (`RGBA8Unorm_sRGB`, `BGRA8Unorm_sRGB`, `BGR10A2Unorm`) held in an argument buffer, which
  Metal round-trips. Runtime and translator work (a held read-write texture whose format the heap
  array cannot view).
- vertex-format-float4 and -half4's `FloatRGB9E5` attribute on lavapipe LLVM 23.1 (2 rows): the
  format reaches fixed-function vertex input as `E5B9G9R9_UFLOAT_PACK32`, and lavapipe answers 0
  for the missing fourth component (Metal 1.0) and decodes other elements wrongly; translator work
  (pull the fetch, or fill the component after the load).

The sites read as unlisted on those venues until the bugs are fixed. The same bugs' older rows
(lavapipe's read-write-tier-held, the "llvmpipe" and "LLVM 21.1.8" RGB9E5 rows) were not this
stream's and are handed back with them rather than removed here.

Verified: only those 20 rows are removed; docs/CONFORMANCE-COVERAGE.md regenerated.
(cherry picked from commit 613a98e22de81f35fb926228fc4534ddcd7e848b)
2026-11-07 04:56:07 -08:00
Anees Iqbal 25a0afe356 Conformance: rgb10a2-srgb's sample cases declare the decoded-tap filter's note
rgb10a2-srgb-samples-{nearest,linear}-{f,h} sample `RGB10A2Unorm_sRGB`, which no Vulkan format
holds, through a runtime sampler. The module does not know the slot's state, so it holds the
linear filter of the decoded taps whatever the slot's filter, and records that filter's sum as
the device's arithmetic (`lower::sampler::select`: a filtered access of a decoded form records
`PrecisionNote::BicubicFilterArithmetic` unless its sampler is a constant nearest one). Every
venue run announces `bicubic-filter-arithmetic` for the four cases (the M3 Max's ledger rows, the
RTX 5080 and both 256-bit lavapipe replays), and the cases declared it nowhere, so each read as an
undeclared notice: a test artifact. two_plane_samples declares the same note for the same reason.

The cases now declare it (a notice declaration: it loosens the notices site alone, so every
sample still compares exactly), and the M3 Max's four case/notices rows, which only restated it,
are removed. The module doc no longer says the cases carry no allowance.

docs/CONFORMANCE-COVERAGE.md regenerated: the ledger-row count goes from 2662 to 2658 and nothing
else moves, so the count development carries is the one its sources derive.

Verified by the replays that follow on the M3 Max (MoltenVK), lavapipe and the RTX 3090.

(cherry picked from commit ac79ff3f6a158bdb86a51b291c992436208005e5)
2026-11-07 04:56:06 -08:00
Anees Iqbal e1c3821e23 Announce DevicePointSize only at a draw that rasterizes points
What: `PrecisionNote::DevicePointSize` (a vertex function's `[[point_size]]`, or a mesh
function's `set_point_size`, on a device whose `pointSizeRange` ends below Metal's 511
pixels: ANV 255, lavapipe 256) was announced by `Device::degrade_stages` at the variant's
making and at every bind, whatever the draw's primitive. A point size sizes points alone:
Metal has no point fill mode, and Vulkan reads `PointSize` only where it rasterizes points,
so a triangle or line draw of such a state is Metal's exactly. reims's
`gpu::encode_render` many_passes tests on ANV (Iris Xe) draw only triangles through a
vertex function writing `psize [[point_size]] = 1.0`, and died in strict mode at
drawPrimitives on this false notice.

How: `degrade_stages` skips the note, as it skips `ArgumentPixelSamplerScaling`, and
`Device::degrade_point_size` announces it from a draw's settings
(`ShapeInputs::settings`, the place `UnsizedPoints` is announced, so an execution's
command announces it where the runtime records it) where the draw rasterizes points: a
`POINT_LIST` draw, or a mesh draw whose mesh function outputs points
(`GraphicsState::mesh_corners == Some(1)`), without rasterizer discard. The draw shape
memo keeps it as it keeps every settings notice (announced once, or at every draw on a
device that announces the kind at each occurrence, through `EachWatch`).

The conformance allowances that hid it are narrowed to the cases that draw points:
render-draw-forms declares `device-point-size` from its rows (points and empty draw
points; triangles and lines do not), with a module test that the declaration follows the
rows; sample-positions (triangles only) drops it; topology-class declares it for the
point-size function's point draws; primitive-type-crossings keeps it for its `Point`
cells, its comment saying so. The validation lane's `making_kinds` mirrors the runtime.
docs/API.md's catalogue entry says where it is announced.

Test: `tests::point_size_notices` draws a point-size state as triangles, lines, strips
and points on a device that announces the kind at every occurrence, and asserts the
creation and every non-point draw announce nothing and each point draw announces it once
where the device's largest point is below 511 (none where it is not).

(cherry picked from commit db5a2306aceeb4f9994002e68ff6b2ac3fea0813)
2026-11-07 04:26:25 -08:00
Anees Iqbal 0fe90ba3d4 Leave rgb10a2-srgb-samples' unclassified notice site unlisted off the M3 Max
rgb10a2-srgb-samples-{nearest,linear}-{f,h} announce `bicubic-filter-arithmetic`, which the
cases declare nowhere, on the RTX 5080 and both 256-bit lavapipe venues. The rows the two
earlier commits gave that site reused the M3 Max's text, which describes the format's value
conversions and says nothing of the notice; whether the cases should declare it or the note is
recorded wider than their accesses is not established, so the site stays unlisted there.

Verified: the 8 rows removed are the only rows of those cases' case/notices site outside the M3
Max; docs/CONFORMANCE-COVERAGE.md regenerated.

(cherry picked from commit e28a9842627a2b1c0291c488ec0e317cb17659ba)
2026-11-07 02:59:46 -08:00
Anees Iqbal 231972d92e Cite only the notes each venue's run announced in the new ledger rows
The fix2 replays print, for each failing row, the native notes its own run announced. Read
against them, 36 of the new rows cited a note the case did not announce on that venue:

- fetch-ordered-*-srgb on the RTX 5080 holds the attachment in the interlocked storage form, so
  its conversions are the module's (`device-pack-conversion`), not `srgb-texel-decode` and
  `device-color-conversion`; the row says so and leaves the per-write bound open;
- half-write-nans-*16f on the 5080 announces `native-nan-encoding`, not `device-nan-encoding`;
- integer-vertex-attributes cited `device-vertex-conversion`, which covers normalized fields only;
- vertex-format-half4's narrow-float NaN rows on the 5080 are `native-half-conversion` and
  `native-nan-encoding`;
- half-texel-nans-rg11b10f's rows on the 5080 and both 256-bit lavapipe venues cited
  `device-texel-conversion`, which none announced.

Verified: every note a 5080, LLVM 23.1.1 or LLVM 21.1.8 row cites that is one of
`replay::NATIVE_NOTES` is in that case's announced list in the venue's fix2 replay, but the
xr-gamut and xr-masked rows, which name each of the two blend-source notes for its own fill kind.

(cherry picked from commit 1f14597553913a62fbbce2c462577b25b0fd2a03)
2026-11-07 02:59:40 -08:00
Anees Iqbal a988acb096 Hand a mipmapped sampler a minLod past every last level, not FLT_MAX
Metal's lodMinClamp of FLT_MAX reads a texture's last level. The translator handed it to the
device as minLod itself, and lavapipe on x86-64 (CI's Ubuntu 26.04 Mesa 26.0.8 and msi's 26.2.4,
both 256 bits) reads that sampler at level 0: sampler-mip-nearest and sampler-mip-linear's
clamp-float-max sites answer 1.0 (level 0) where Metal answers 2001 (level 2), 16 elements each.

Vulkan clamps the level into [minLod, maxLod] and then to the view's last level, so every bound at
or past LAST_WORD_LEVEL (15, past every Metal texture's last level, 14) reads the same level. A
mipmapped sampler's minLod is now its lodMinClamp clamped into [0, 15] (`mipmapped_min_lod`); a
bound up to 15 is handed as before, and maxLod stays the descriptor's (never below minLod).
Nothing keys on a device: the bound is exact on every one.

SEMANTICS_VERSION 1973 -> 1974: a sampler descriptor's minLod changes for lodMinClamp above 15.
docs/API.md's device-sampling entry says the bound is handed as 15.

metal/sampler.rs is one of the runtime-sources pin's inputs, so the pin moves with this commit
(RUNTIME_VERSION and the pin are left to the landing).

Verified: `a_mipmapped_samplers_min_lod_is_held_past_every_last_level` fails without the change
(minLod f32::MAX, not 15) and checks every view of 1 to 15 levels reads Metal's clamped level under
the handed bounds; the venue replay is the lavapipe evidence.

Landed with SEMANTICS_VERSION 1976: the branch took 1974, which stack 37 and the heap YCbCr notes
(1975) had already taken.

(cherry picked from commit bdb7efa414f579579e73c33d8f82fd7b312a61c6)
2026-11-07 02:59:40 -08:00
Anees Iqbal b739f0a49a Scope the lavapipe ledger rows by LLVM and vector width
The generic "llvmpipe" rows were measured on the arm64 container's lavapipe (LLVM 21.1.8, 128
bits). CI's Ubuntu 26.04 lavapipe (amd64, LLVM 21.1.8, 256 bits) and msi's (LLVM 23.1.1, 256 bits)
answer otherwise at 79 of their sites, and 253 sites no lavapipe row named:

- a row a 256-bit venue no longer holds is re-scoped to the venues it does hold ("128 bits",
  "LLVM 21.1.8"), and each 256-bit answer gets its own row ("256 bits" where both 256-bit venues
  answer alike, else per LLVM). A row whose text states no number the new answer moves keeps its
  text; the rest get texts from that venue's first differing element: the half NaN families (the
  quiet bit set and the payload kept at 256 bits, a sign and payload, LLVM 23.1.1 dropping the
  half round trip), norm-storage-codes (the 128-bit text plus the case's NaN of each sign, which
  the two sides store at opposite ends of the format; Vulkan leaves a NaN's conversion
  unspecified), 3D samples on LLVM 23.1.1, and the RGB9E5 attribute row's counts;
- the extended-range, padded 10-bit, sRGB 10-bit, xr blend and two-plane families reuse the M3
  Max's venue-neutral texts (mechanism only, no site numbers); xr-planes alpha gets a lavapipe
  ties-to-even text; pixel-samplers-subnormal a digest-only text;
- the 14 compressed-blits-rg11b10f and -rgb9e5f rows are removed: the accepted difference
  `a-device-answers-as-the-class-of-mac-it-presents` now justifies those sites on every venue
  without lossless compression (313abb4b47).

The two sampler-mip clamp-float-max sites get no row: the next commit fixes them.

Verified: every new row is generated from the fix2 census's own paste rows at 2776dd8f06 on each
256-bit venue (site, expects and answer verbatim); a prediction against those censuses leaves 2
sites unlisted (the sampler-mip ones) and no stale row on either venue. A replay at this tree on
both venues is what proves it. docs/CONFORMANCE-COVERAGE.md regenerated.

(cherry picked from commit a1dd53b33b5676b46fdc7654de060ccc8ab0d239)
2026-11-07 02:59:24 -08:00
Anees Iqbal f98735bbdb List the RTX 5080's native-arithmetic divergences in the conformance ledger
886 rows for "NVIDIA GeForce RTX 5080 Laptop GPU", each a site the whole-suite replay on the
5080 (NVIDIA 615.71.09, exact policy, at b982d02d53) reported as divergent or refused and the
ledger did not list, each with the class it was triaged into and the note that records it:

- device NaN encodings (half NaN 0x7FFF, float 0x7FFFFFFF, small-float all ones; gathers of NaNs
  and denormals) under device-nan-encoding, native-nan-encoding, native-half-conversion and
  device-texel-conversion, whose documentation already names this device's encodings;
- BC decode against compressed-texel-decode's NVIDIA bound (covered, or past the colour bound and
  named as open, or not established for an sRGB form's decoded value);
- packed 16-bit texels widened by bit replication (device-texel-conversion's 0.18-code bound);
- 8-bit unorm stores a code apart near a tie (fragment outputs, storage writes, fills, a2c
  targets) under device-color-conversion, which states the 5080 stores 0.5 as 0x7f; each
  norm-storage-codes texel holds one value in four channels, so the largest word difference
  bounds every channel at one code;
- attributes read as half keeping the float, NVIDIA folding the conversion pair
  (native-half-conversion, DriverWorkaround::HalfConversionPairFolded);
- the nearest mip level at a halfway clamp (device-sampling states the shape);
- filters, 3D samples, pixel samplers, downscales and resolves through the device's own units,
  whose bounds are measured on lavapipe and MoltenVK and not on this device: those rows say so
  and name the bound as open;
- read-write-tier-held's refusal, the same open runtime work lavapipe's rows name.

The 80 xr rows and 191 rows reusing venue-neutral texts of the M3 Max's rows are among them.
Sites that the accepted-difference slug fix and the two shared-memory declarations remove
(fresh-*, compressed-blits-*, xr-clear-routes-*, buffer-textures-stride-below-the-row,
format-footprints-plain-stragglers) get no row. ycbcr-gathers-* and ycbcr-minify-band-* (20
digest-only sites) stay unlisted: their class is not established, and the YCbCr notes are
another stream's work.

Verified: the rows are generated from the 5080 census's own paste rows (site, expects and answer
copied verbatim), each text from the site's first differing element in that run; a replay at
this commit on the 5080 is what proves they hold. docs/CONFORMANCE-COVERAGE.md regenerated.

(cherry picked from commit 0bf9ec15eac473fa19002a218ec2978f2e7a1f0f)
2026-11-07 02:59:12 -08:00
Anees Iqbal b37276fa4c Note a heap texture's YCbCr filter where its handles and sampler can reach one that filters
What. A filtered `half` or `float` sample of a texture an argument buffer holds (a heap's) now
records `PrecisionNote::HalfSampleFilter` / `FloatSampleFilter` on a device that samples through
Metal's own sampler (MoltenVK), as a slot's sample does, under clauses the plan answers at each
draw or dispatch:
- `SpecKey::HeapYCbCrTextures(stage)`: a heap member of the command reaching the stage (a texture
  it makes resident, or binds at a texture slot of the stage) is of a two-plane YCbCr class
  (`TexelFormat::two_plane_ycbcr`);
- through an argument buffer's sampler, `SpecKey::FilteringArgumentSampler`: a listed argument
  sampler (`BindShape::argument_samplers`, every live state) has a linear min, mag or mip filter,
  anisotropy or a cubic filter; through a runtime slot, the bound word (`filtering_word`); a
  constexpr sampler that reads one texel of one level records nothing.
Only a 2D, one-layer, color, single-sample heap sample can reach a two-plane texture, so 3D, array,
depth and multisample heap samples record nothing. The plan computes both keys in `record_noted`
(which now takes the heap's stage reach), so they are a function of the bind shape: the runtime's
bound-value memo, keyed by (variant, plan, specialization), stays valid. The runtime announces a
holding heap clause as `ycbcr-filter-not-exact` (`degrade_clauses`), naming the stage.

Why. A probe on the M3 Max (MoltenVK) showed a 4:4:4 two-plane texture (identity address-mode map:
`YCBCR8_444_2P`, `YCBCR10_444_2P`, their sRGB twins, the packed 10-bit one) held by an argument
buffer and sampled linearly through a constexpr, runtime-slot or argument-buffer sampler ran and
announced nothing, where Metal's own sampler filters the kept image's float texels, not Metal's
exact filter: an under-announcement. (4:2:0, 4:2:2 and the code-reading 4:4:4 textures reached
through handles are refused, `MappedTextureSampling { through: Handles }`; a slot texture sampled
through an argument buffer's sampler is refused at translation, `ArgumentBufferTextures`.) Which
sampler state an argument buffer holds is in its memory, which no plan reads (the binder's rule:
argument samplers come from object lifetimes), so the argument-sampler test is "a live state
filters": a program whose live states are all nearest announces nothing.

SEMANTICS_VERSION 1973 -> 1974 (precision notes change for heap samples on metal-sampler
profiles); ARTIFACT_FORMAT_VERSION 489 -> 490 (two `SpecKey` variants in the codec). The golden
table does not move (no SPIR-V changes). `api_signatures.tsv` gains the two variants.
heap_linear_samples_are_the_device_s now expects the specialized note on MoltenVK 2D samples.

Verified (potluck):
- M3 Max, MoltenVK, GPU (job m3-max-2786): 64/64 lane tests (ycbcr_textures, ycbcr_in_place,
  degrade_notices, pixel_samplers, ycbcr_device_reads, argument_linear_samples), the new
  a_ycbcr_texture_through_an_argument_buffer_announces_its_filter_only_where_it_can_filter
  printing, for YCBCR8_444_2P and YCBCR10_444_2P_sRGB: constexpr linear 1, runtime nearest 0,
  runtime linear 1, argument nearest 0, argument linear 1, argument nearest with a linear state
  alive 1; RGBA16Float 0 in every case.
- lavapipe (msi, llvmpipe LLVM 23.1.1; job m3-max-2775): the same 64/64; announced only where
  the device converted the 8-bit 4:4:4 texture itself.
- M3 unit tests (jobs m3-max-2767, m3-max-2774): the new
  tests::engine_heap_binder::a_heap_texture_s_ycbcr_filter_note_holds_where_its_sampler_can_filter
  and 134 more (engine_heap_binder, engine_ycbcr_in_place, engine_handles, golden_hashes, cache),
  api_signatures/api_surface/refusal_surface 19/19, runtime tests::degradation 17/17; clippy
  plain, --cfg m2v_gpu, --cfg m2v_cpu_icd and rustdoc -D warnings clean.
- Negative controls, both failing: no heap note (the unit test, and the lane's constexpr linear
  case announcing nothing on the M3); a plan answering 1 for both keys (the unit test at
  "YCBCR84442P beside none", the lane's argument nearest case announcing on the M3).
- Release CLI on moltenvk-m3, tip against 80d2dc465f, 3 runs: tail_argument_samplers
  argument_sampler_sample 0.02 s / 25.1 MB both; handles argument_buffer_runtime_sampler 0.02 s /
  25.6 MB both; grd_half_many_samples 0.05 s / 25.9 MB both.

(cherry picked from commit 8403d3746182d6c1acf7795666fc46fea811e660)
2026-11-07 02:57:47 -08:00
Anees Iqbal ffbfb8631d Bump SEMANTICS_VERSION to 1974 and regenerate the conformance coverage at stack 37's picks
Three picked branches each moved SEMANTICS_VERSION from 1972 to 1973 on their own: runtime sampler
slots' filter notes now carry a test of the bound sampler word; an object function's barriers
are predicated so a partial object threadgroup runs as Metal's; and extended-range partial masks
and unwritten padded or bfloat attachments link. Together their outputs differ from any one
branch's at 1973, so the version moves once more. docs/CONFORMANCE-COVERAGE.md is regenerated
from the merged sources and recordings (the picks' conflicts kept the earlier text).

Verified: conformance-coverage --check, signatures.py --check and refusal_surface.py --check pass
on this tree; metal-coverage is current.
2026-11-05 21:15:23 -08:00
Anees Iqbal c3cbf1e76b Conformance: the RTX 5080's XR rows at the multisampled shadow; lavapipe's BGR10_XR masks merge
The RTX 5080 (b5080 entry xr2-replay-xr, every xr-* case at b026d47db4) now matches the M3's
four-sample gamut counts (226/295 elements, one code; sRGB 547/548, up to four codes), where the
ledger had 542/543 and 610/622 from before the per-sample shadow: those ten rows take the M3's
counts and text. New rows for the 5080: the eight gradient cases (blended 134/142/109/145
elements, one code; unblended 39/44 and sRGB 56/86, the same counts as lavapipe's, the device's
float arithmetic of the gradient), the BGR10_XR masks (the M3's counts: 37, 41, 9, 14) and the
padded sRGB fill (92). The 5080's other unlisted xr-* divergences (blend, clears, clear-routes,
draw, planes, two-plane samples, two-planes) are in cases this branch does not touch; they are
left out here.

lavapipe at 36239bb3ab (msi's LLVM 23.1.1 and Ubuntu 26.04's Mesa with LLVM 21.1.8, the CI
image's): the four BGR10_XR partial-mask cases no longer refuse. Their texels match Metal's
(linear) or sit one code off (sRGB: 14 and 9 elements, the M3's counts), but the runtime announces
extended-range-blends-stored-codes at the merging draw: it reads the color over an input attachment,
where no half shadow is held, and the pipeline's state does not tell a read that only keeps codes
from the function's own fetch. The ledger records that as our gap (case/notices rows), and the
notice's documentation (degradation.rs, API.md) says it fires there. A base build (cbc30cb2c5) on
msi's lavapipe shows the same 99 older unlisted xr-* divergences as the tip, none new.

Also: `BGR10_XR_sRGB` spelled whole in the masked rows, and the llvmpipe four-sample rows' open
gap narrowed to the shadow over an input attachment. CONFORMANCE-COVERAGE regenerated.

(cherry picked from commit b982d02d53bf879382f09638a7c8c780fce89af9)
2026-11-05 21:13:40 -08:00
Anees Iqbal c559ed6f84 Docs: the half shadow holds at more than one sample; REFUSALS for the merge's refusals
The extended-range-blends-stored-codes notice (its declaration and the
docs/API.md catalogue entry) now says where it is not announced: a color
whose half shadow the runtime holds, in a pass of one layer on a device that
orders fetch through the pixel interlock alone, at one sample or more, from
the pass's clear or (at one sample) its load; and where the codes stay:
over lavapipe's input attachments, in a multisampled pass that loads the
color, and after a draw the shadow cannot follow. docs/FAST-PATHS.md's word
attachment row no longer says an extended-range color keeps its codes at
more than one sample. docs/REFUSALS.md regenerated
(scripts/refusal-surface/refusal_surface.py): link's second
extended_write_mask site and fetch::unordered_extended_fetch.

How verified: refusal_surface.py wrote the table with 0 variants without a
reach mark or a basis; the catalogue test runs with the runtime suite next.

(cherry picked from commit 70691da1d131573dac3a3c4ae4e6436ad48283f3)
2026-11-05 21:13:17 -08:00
Anees Iqbal e10552b553 Re-record the mesh limits cases on the M3 Max, time every new case, regenerate the coverage document
What: the 17 mesh-limits cases' Metal answers and M3 cost bounds over the
trimmed fixture, the timings of all 34 new and re-recorded cases (times
--write, both legs; the host's load was above the gate's 26, so the
verdict is to be re-read on a quieter host), docs/CONFORMANCE-COVERAGE.md
(MTLMeshRenderPipelineDescriptor 27 of 27 items compared, the
MTLRenderPipelineState getters 18 of 22), and the golden and inventory
rows of the trimmed fixture.
Why: the fixture's AIR changed; the suite's own tests ask each case for
its cost and timing records.
Verified: M3 jobs m3-max-2732 (bless, 155 touched translator tests pass)
and m3-max-2737: replay on MoltenVK of the 34 cases, 29 exact, 4
announced (the partial-barrier draws' emulation notices), 1 refused as
known-gaps.tsv expects (mesh-limits-amplification-2), exit 0; the
conformance crate's 1023 tests pass.

(cherry picked from commit d8031c15692c56abc40b3c6fc80579091bbfb680)
2026-11-05 21:13:16 -08:00
Anees Iqbal 7c6b61b76d Leave the mesh limits whose Metal answers follow compiler history out of the cases; ledger the amplification refusal
What: the mesh-limits family drops its 16 rows of a required threadgroup
size or a function's own thread maximum, the fixture its two functions of
one, and MeshLimitsSpec its required sizes. mesh_pipeline_limits.m and
docs/API.md (accepted differences) record why: on the M3 Max each such
answer changes with what the compiler compiled before (a first compile
refuses a required size of 32 under a maximum of 64 in either stage and
makes it after a compile under 64; a first compile of a function of
max_total_threads_per_threadgroup(64) answered 32), so the recorded
mesh-limits-required-mesh-32-max-64 made where the probe and a first
compile refuse. known-gaps.tsv lists mesh-limits-amplification-2's
refusal on every venue.
Why: a recording of those rows holds the compiler's history, not an
answer; the amplification refusal is an open gap.
Verified: fresh-source creations on the M3 Max (jobs m3-max-2717 and
m3-max-2725); the family re-records in the next job.

(cherry picked from commit 187f1b12c0b8282a0dcf1e43ab530123ccf1d2fa)
2026-11-05 21:13:15 -08:00
Anees Iqbal 0f289cdac4 Commit the regenerated fixture companions, and record how Metal runs an amplified mesh draw
What: the .ll and .air.ll companions of mesh_partial_barrier,
compute_thread_limit and mesh_pipeline_limits, and their TOOLCHAIN lines
(regen-air-fixtures on the M3 Max, job m3-max-2677). probes/
mesh_amplification.m records its answers: under an amplification count of
2 the object function runs once (8 threads) and the mesh threadgroups it
launches run once per amplification (16 threads, ids 0 and 1, a count of
2), each into its view mapping's slice. FAST-PATHS.md's known gap for a
mesh pipeline's amplification says what an exact form must do and why
neither built draw form is one.
Why: the tests and cases read the fixtures; the gap stays open with the
measured semantics written down.
Verified: the probe ran on the M3 Max (job m3-max-2677).

(cherry picked from commit bb5a45dd26d89d5af72e755ad4ac976975007d8b)
2026-11-05 21:13:15 -08:00
Anees Iqbal b43ba48ee2 Regenerate the signature table and REFUSALS.md
What: api_signatures.tsv gains ComputePipelineProblem, its two variants and
DescriptorError::ComputePipeline; REFUSALS.md's RequiredThreads row says
only what creation refuses.
Why: the new public refusal and the corrected problem doc.
Verified: signatures.py --bless and refusal_surface.py on msi (job
m3-max-2689).

(cherry picked from commit 301047b4dc4f5f4f3a4d1725c9966e152f5b4fb0)
2026-11-05 21:13:15 -08:00
Anees Iqbal 9609083aa2 Walk object and mesh functions predicated at their barriers, and partial object threadgroups from their threads
What: the divergent-barrier pass (lower::simd::divergent::barriers) now covers
object and mesh functions as it covers kernels: a workgroup barrier in a block
Uniformity does not prove uniform makes the body walk predicated, so every
invocation reaches it. Every object function now runs a drawMeshThreads
partial object threadgroup (lower::mesh::plan_partial_groups no longer
excludes a body with a barrier; RuntimeFact::PartialObjectThreadgroups). One
whose body holds any workgroup barrier is walked predicated
(Predication::partial_groups) from live = KernelDecl::live, the invocation
being one of its threadgroup's threads (dispatch::emit_entry computes it in
the entry block and hands it to the walk through
CodeEmitter::entry_live/EmitCx::entry_live), so the invocations past a
partial threadgroup's threads reach every barrier, and loop vote, as
invocations that returned at entry, and run no other instruction of the body:
no load, store or atomic of theirs is made. A body without a barrier keeps its
early return. The vote word an object function's walk takes counts in its
ObjectThreadgroupArena fact, which the binder checks with the encoder's
lengths; where the word does not fit and the barriers are uniform, the
function runs no partial threadgroup (the binder refuses such a draw as
before).

Why: an object function with a threadgroup barrier on a partial object
threadgroup was refused (NotImplemented(MeshShading), a FAST-PATHS known gap),
which kept the Metal3 mesh shading row false on every device; and an object
or mesh function's barrier after a divergent early return or under a
thread-dependent condition stood in non-uniform control flow, which Vulkan
leaves undefined (an Intel GPU hangs on it).

Docs: FAST-PATHS' known gap is gone; render/mesh.rs, bind/graphics.rs and the
fact's docs say what runs. The Metal3 mesh feature rows
(families/features.rs) lose their not_implemented(MeshShading), and the
families test now expects the mesh shading row exact where the device runs
the stages natively or as compute work.

Tests: engine_mesh_barriers (new, over the owned fixture
mesh_partial_barrier): every object function and the divergent mesh function
predicated on every committed profile, their bodies' barriers all uniform by
spirv::testing::barriers::workgroup_barriers_of (new: the check of a called
body); partial draws instantiate; and the interpreter runs each emulated
object function's partial and whole draws under BarrierRule::Vulkan giving
the predicated reading. The old
a_partial_object_threadgroup_of_a_body_with_a_barrier_is_not_implemented is
replaced by a_partial_object_threadgroup_of_a_body_with_a_barrier_draws.
SEMANTICS_VERSION 1973. Verification in the following commits' potluck runs.

(cherry picked from commit 65660d13d001484e444c0f89b268f92b847976b1)
2026-11-05 21:13:13 -08:00
Anees Iqbal 8f2f973478 Announce a runtime sampler slot's YCbCr filter note only where the bound sampler filters
What: a filtered sample's note of a two-plane YCbCr format through Metal's own sampler
(`PrecisionNote::HalfSampleFilter`, `FloatSampleFilter`, announced `ycbcr-filter-not-exact`)
through a runtime sampler slot now holds only where the word of the sampler bound there filters.
`lower::sampler::linear::filter_note` crosses the bound-format clauses with two tests of the bound
word (`NoteOn::BoundSampler`, `SpecKey::BoundSamplerWord`, which the plan already records for
noted keys): a linear min or mag filter, anisotropy or a cubic filter (any of those bits), or a
linear mip filter, the constexpr rule `linear::unfiltered` read from the word. A constexpr
sampler keeps its rule; an argument buffer's sampler, whose word no slot test reads, keeps the
format-only clauses.

Runtime: such a clause tests a bound value, so `Device::degrade_bound_values` reads it at each
draw or dispatch. It now also answers `SpecKey::BoundTexelFormat` from the command's formats (the
class `bound_texel_format` gives; a slot bound to nothing fails the clause, as
`degrade_bound_formats` reads it; unknown formats hold), checks a filter note's kind as
`ycbcr-filter-not-exact` (one atomic load once announced), and `degrade_clauses` announces a
filter note's slot of unknown format (an execution of GPU-written commands) as that kind, naming
"a format the GPU's commands bind", as `degrade_bound_formats` does. Which clauses hold stays a
function of the plan (the shape it is planned for holds each bound format and sampler word), so
render.rs's `QuietBoundValues` holds.

Why: a runtime sampler slot announced the note whatever its sampler state, so a nearest runtime
sampler on a texture that keeps its image (a 4:2:2 or 4:4:4 one on the M3) announced it though
a nearest sample reads the one texel the view holds, Metal's read; the consumer runs notes fatal
on Apple GPUs.

Validation: `run_kinds` (degrade_notices) evaluates the bound formats through the same closure,
and `bound_value_kinds` maps a filter note to `ycbcr-filter-not-exact`.

Tests: `tests::engine_ycbcr_in_place::a_runtime_sampler_s_filter_note_holds_only_where_the_bound_word_filters`
(clauses on moltenvk-m3 hold for linear min, mag, mip and anisotropic words over YCbCr formats,
not for nearest words or other formats; lavapipe records none) and the lane test
`runtime_lane::ycbcr_textures::a_runtime_sampler_announces_the_ycbcr_filter_only_where_it_filters`.

Docs: the notes' rustdoc, `YCbCrFilterNotExact`, docs/API.md's two entries.
SEMANTICS_VERSION 1973: the artifact's specialized notes change (no SPIR-V changes).

Verified: cargo fmt; builds and runs follow.
(cherry picked from commit d464b1d36f998cd8c69a9f2c9252288df64d13d9)
2026-11-05 21:13:11 -08:00
Anees Iqbal efe9581bcf Map maxArgumentBufferSamplerCount in the porting guide
What: docs/RUNTIME-PORTING.md gets a table for the consumer's IdentityCaps
(MTLDevice identity and size answers) with one row:
sizes.max_argument_buffer_sampler_count, Metal's
maxArgumentBufferSamplerCount, maps to
DeviceProperties::max_argument_buffer_sampler_count. The row gives the
derivation (one fewer than the smaller of a set-1 sampler array's elements,
pipeline::heap_sampler_capacity, and maxSamplerAllocationCount) and marks
it partial: 65535 on MoltenVK on an M3 Max, where Metal answers 500000.

Why: the samplercount work added the property without a row here, so a port
had no entry for the selector. The Item name is the consumer seam's field
(reims-vgpu-core platform/caps.rs, IdentitySizes, on its current branches).

Docs only. Checked against capabilities.rs (the field's rustdoc) and
docs/API.md's accepted differences, which give the same derivation and
values.

(cherry picked from commit 866e5ab81bfee7ebcc521975a7c277d00ac20378)
2026-11-05 21:13:10 -08:00
Anees Iqbal ee4a6c5b52 Bound texture ID placement by the handle table's reach
What: the runtime's set-1 image array capacity (resource_ids.rs
`texture_arrays`, which texture placements and texture reservations are
checked against) is now the least of the handle table's 65536 entries
(bind::HANDLE_TABLE_CAPACITY, within which link sizes every heap array) and
the update-after-bind image limits. Before, it was the limits alone. Each
array carries what bounds it (`ArrayBound`): a device limit, named in the
refusal as before, or the table. An ID past the table is refused
Unsupported(ArgumentBufferTextures, NotImplemented), since no heap array on
any device reaches it. `texture_arrays` and `check_capacity` are now free
functions over the compile profile, so a test reaches them without a device.

Why: this is the same gap `sampler_array` had before the samplercount work.
MoltenVK reports 1,000,000 update-after-bind sampled and storage images,
lavapipe 1,015,808, RADV 8388606, and ANV and NVIDIA more, so a texture
reservation between 65536 and those limits was accepted. Yet no set-1 array
holds such an ID: a texture placed there reads the neutral through its ID.
Placements are unaffected in practice, since Metal's placement limit (16381)
lies below the table's reach. Reservations of 65536 and more are now
refused where they were taken.

Tests: resource_ids::texture_arrays_reach_no_further_than_the_handle_table
checks every committed profile: each array is at most the reach, the ID
below its count is taken, and the ID at its count is refused naming its
bound. It pins MoltenVK, lavapipe, RADV, ANV and NVIDIA to the table and the
desktop baseline to its 128 sampled and 8 storage images a stage. Without
the fix, the pins fail (moltenvk-m3: 1000000). A new device test,
runtime_lane::resource_ids::a_texture_reservation_at_the_handle_table_s_reach_is_refused,
reserves texture ID 65536 (refused, not implemented, where the device's
limits reach past it) and 65535 (taken), printing a TEXTURE_RESERVATION
line. REFUSALS.md is regenerated (check_capacity, 2 sites). Verification
runs follow in the branch report.

(cherry picked from commit 9629f473e25790aa573b03d6c4419d99127f33ce)
2026-11-05 21:13:10 -08:00
Anees Iqbal 570df3cc95 Answer maxArgumentBufferSamplerCount from the set-1 sampler array and the sampler limit
What: `DeviceProperties::max_argument_buffer_sampler_count`, Metal's
`maxArgumentBufferSamplerCount`: one fewer than the smaller of a set-1
sampler array's elements and the device's maxSamplerAllocationCount
(element 0 of the array, and one of the device's samplers, are the
neutral sampler's; each state the array holds takes an element and a
sampler of its own). The array's elements are a new public translator
function, `pipeline::heap_sampler_capacity`: link's heap capacity for a
heap of one sampler array with set 0 counting no sampler, the least of
the handle table's 65536 entries (TABLE_CAPACITY) and the two
update-after-bind sampler limits, 0 where a function cannot read a set-1
sampler array (the layout's features or the module's non-uniform
sampled-image indexing). Link's heap_capacity now reads the same limit
table (`heap_limits`) and arithmetic (`room`), and heap_set the same
layout-feature check (`heap_layout_lacks`), so the sizing and the answer
cannot drift. The runtime's `Device::sampler_array` (each state's
creation-time check) now calls it too: it was the two update-after-bind
limits without the handle table's reach, 500000 on MoltenVK where link
makes 65536 elements, so a state past 65535 was not announced as it was
made. The device's SamplerCount and the answer read one value, the
identity's maxSamplerAllocationCount.

Why: the consumer computed it as the least of the two update-after-bind
sampler limits and maxSamplerAllocationCount; that misses the handle
table's reach (500000 against our 65535 on the M3) and the neutral's
element (32768 against 32767 on lavapipe, 4000 against 3999 on NVIDIA).

Metal on the M3 Max (macOS 27.0.1) answers 500000 (a Swift query of
MTLCreateSystemDefaultDevice, potluck job m3-max-2496), recorded in the
field's docs and docs/API.md's accepted differences.

Tests: engine_handles::an_argument_sampler_array_has_the_heap_sampler_capacity
(link's array equals the function on every committed profile, follows
lowered limits, 0 without the features); capabilities::
argument_buffer_samplers_are_one_fewer_than_the_array_and_the_sampler_limit
(every committed profile, pinned venue values); the device test
argument_sampler_count (the kernel's array, the device's count, the
driver's limit and the answer agree; elements-1 states unannounced, the
next announced). Verification follows in the branch's report.

(cherry picked from commit 7a2b84f15a1dde81e35cbc0b9367962e54d8332f)
2026-11-05 18:59:21 -08:00
Anees Iqbal 296723b362 Test a filter notice's bound format against the format the slot's binding presents
The consumer's own-format view test died on the M3 Max (MoltenVK) in strict mode at a sample of
an 8-bit 4:2:0 texture's 2D array view in its own format: `ycbcr-filter-not-exact`, "texture 0
bound as YCBCR84202P". That view is the luma view (`Texture::luma_view`): an `R8G8B8A8_UNORM`
image of the codes, read as the code-reading format `RGB8_420_2P` through a swizzle, which
Metal's own sampler filters as Metal filters that format (the lane already holds the view's
linear sample to that format's, and Metal's view to it bit for bit). The binding plan reads the
bound record's format (`ViewRecord::bound`, `RGB8_420_2P`), but the notice's bound-format test
read `Texture::pixel_format`, the view's own (`YCBCR8_420_2P`), whose class carries the 1/2048
field `FloatSampleFilter`'s clause tests. So the note was wrong: no float texels are filtered
there. The 10-bit views (`RGB10_420_2P` codes, `A2B10G10R10_UNORM_PACK32`) and the `_sRGB`
twins' views announced it alike.

`Tables::bound_format` now reads the format the texture's bindings present
(`Texture::bound_pixel_format`, `ViewRecord::bound`), the one its slot's code was specialized
for. That changes what the bound-format notices test and name for every texture that reads its
image in another format: the luma views; views in other channels of their image's bits, whose
class is their image's; and converted textures over a P3 surface, whose image is the
code-reading format's codes. A P3 texture's linear sample is no longer announced: Metal's
filter of it is not measured, now a FAST-PATHS known gap. Notices only: no pipeline, binding or
answer changes.

Docs: ycbcr.rs (views; linear filtering, with the in-place form's 4:2:0-only reach), the
YCbCrFilterNotExact declaration and its API.md entry, and the FAST-PATHS known gap.

Verified: cargo fmt. The lane check of the previous commit fails without this on the M3 Max;
device runs follow.

(cherry picked from commit 37a50861dd4e105619690a520a290c30bd3208d5)
2026-11-05 18:59:20 -08:00
Anees Iqbal a2b99ee4f6 Report each write to a log of host pages in one batched call
The consumer measured DirtyCommit::report_host_writes at 77.7% of its present path on the
RTX 5080: PagesLog::wrote_but called the source's hook once per run of the object's window in
a guest RAM's log, about 9,000 calls a report for a 3840x2400 BGRA8 surface over scattered
4 KiB pages. PagesLog::wrote, wrote_as and a shadow's report did the same.

DirtyPages gains wrote_runs(&[Range<u64>]) and wrote_runs_as(&[Range<u64>], writer), whose
defaults call wrote or wrote_as once a run, in order, so existing sources keep working. Every
write the runtime reports now comes to each log as one call carrying all its runs there: each
range of a command buffer's writes in place (the bytes no shadow wrote, the gaps between the
shadows' writes, in order), each shadow's write to the other logs, a copied host buffer's merge
back (all its blocks, one call per log and copy, where it was one call per run of each block), a
CPU write, and a shadow's copy back or merge (one run). For each source, the runs, their order
and their writers are what the per-run calls carried. The runs gather in a thread-local buffer
kept for the thread's next report, so a warm report allocates nothing (wrote_but also no longer
builds a Vec per range to cut out the shadows' writes: one sorted list, swept). The internal
DirtyHook calls the batched forms alone; its per-run methods went.

The read side needs no batching: changed and changed_except already hand back every run of a
query in one call. watch stays per run: a copied host buffer watches its runs once, at its
making, not per report.

Docs: the trait's contract for the runs (never empty, each non-empty, in the order of the
object's bytes, apart in the object, not sorted by offset over scattered pages), its Batches
paragraph, HostMemory::with_dirty_pages, the runtime README and HOWTO's guest RAM log; the
api_signatures table blessed (two trait items).

Tests: dirty_runs checks, over a memory log and a guest RAM log of 24 scattered pages, that a
command buffer's report, a write with a shadow's merge inside it, a copy's merge back of three
blocks and a CPU write each reach each log in one call per range carrying exactly the runs
worked out from the window, and that a log keeping only wrote/wrote_as hears every run in the
same order with the same writers. The bench gains a batched trivial log.

(cherry picked from commit b69d6b70c49af0b0ab08db5fe2f8b78cd61ed2fe)
2026-11-05 18:59:20 -08:00
Anees Iqbal b18b105cc0 Let a thread's own pass take the ready heads not behind, as the scheduler's does
A committing thread's pass (commit_and_submit) and a waiting thread's took
only the line head committed first of all (Order::take_first, and
claim_check's first_mut): any earlier commit held on any queue, its checks
waiting for a signal to land or run by the scheduler's thread, sent every
later commit to the scheduler's thread, a wake and a hop each, even a ready
one on another queue. A consumer's video round (5080, 1 s windows) showed it:
879 commits, 741 passes at commit, 358 batches submitted there, the other
~521 batches the scheduler's (batches_held_past_a_look 522, heads held for
checks 718, for check signals 129, for earlier commits 46; no event-value,
host-step or binary-semaphore holds), scheduler_wakes_host 668.

submit_plain_ready now takes its heads with Order::next and is_behind, the
scheduler pass's own selection: the first ready head in commit order that
waits behind no earlier commit keeping its place. claim_check takes the first
head in commit order whose checks the thread may run and that is behind no
earlier commit (no check before the batch it waits behind is submitted, as
check_heads keeps). A held head so holds back only the later commits that
wait behind it: its own queue's, and another queue's whose footprint runs in
commit order with it. Order::take_first and first_mut, now unused, go with
their two unit tests; the scheduler's next is tested by the rest of
tests::scheduler.

Test: commit_and_submit
a_head_held_for_its_check_holds_back_only_the_commits_behind_it holds queue
A's check on the scheduler's thread, then commits B (same buffer, behind A)
and C (another buffer) with commit_and_submit: C is checked and submitted on
the committing thread inside its call while A's check runs, B on the
scheduler's thread after A; handlers in submission order C, A, B; one batch
checked and submitted at commit. Before this change C's check ran on the
scheduler's thread after A's (expected; the run's evidence goes with the
landing report).

(cherry picked from commit ff664020a1c7fe171ff15422e17b3c846624d94c)
2026-11-05 18:59:00 -08:00
Anees Iqbal 8a516f2255 Submit a queued commit_and_submit on the thread that runs its commit
Under RenderLoweringPolicy::Worker a commit whose last render encoder's end
the lowering thread has not lowered returns at once and leaves its own work
to the thread that lowers the end (render/queued_commits.rs). That run
committed with Hand::Wake whatever the call was, so a commit_and_submit left
so lost its inline pass: the scheduler's thread was woken for it and ran its
checks and handlers.

The queued commit now keeps the call's hand (State::queued_commit is
Option<Hand>), and commit_queued makes commit_and_submit's pass on the thread
that runs it (the lowering thread, or a program thread that settles it before
a wait), with Hand::Wake on a thread command buffers' completion depends on,
as commit_and_submit does there. The pass's submission checks and handlers
then run on that thread. A render encoder opened there (by such a check or
handler) lowers its calls at their calls: one that handed them to the
lowering thread could wait for itself in reserve_end or wait_for_room.

Test: deferred_calls
a_commit_and_submit_after_an_end_in_flight_is_submitted_by_the_lowering_thread
holds the slot so the end is in flight at the commit, then checks the check
and handler ran on metal2vulkan-lowering, one pass at commit submitted and
checked the batch, and an encoder the handler opened lowers at its calls.
Without the hand kept the check runs on metal2vulkan-scheduler and
scheduler_passes_at_commit stays 0; without the guard lowers_at_call is false.

(cherry picked from commit bed9dc881cc1e6f18df708796da144a9072b9fb1)
2026-11-05 18:59:00 -08:00
Anees Iqbal 21a1cf7218 Give the commit hand-off's cost from idle too, and name commit_and_submit its inline form
docs/FAST-PATHS.md gave the scheduler thread's wake as 5 us on the RTX
5080 Laptop GPU, true for commits back to back, where the thread is
awake. From idle it is far longer: with one fill committed every 2 ms
(the completion latency lane), a commit's batch was watched 140 to 165 us
after the call at the median on that GPU, against 5 us for vkQueueSubmit,
and a parked thread's wake took 80 to 105 us at the median on that host.
The row gives both, and names CommandBuffer::commit_and_submit as the
inline form a program that needs the latency takes.

(cherry picked from commit 880ffe3b551b585a7593784165a7b4ac11bc50ec)
2026-11-05 18:58:59 -08:00
Anees Iqbal 7d813def6f Regenerate the derived tables at stack 35's picks
The private-doc-link mend shortened the degradations! macro's note link and a refusal's doc link
to in-scope paths, which moves the macro's template in api_signatures.tsv and one row of
docs/REFUSALS.md; no item's signature changed for a consumer. The mesh change runs a partial object
threadgroup, so the two mesh-object-draws-partial-threadgroup cases leave the conformance ledger
(1378 rows to 1376) in docs/CONFORMANCE-COVERAGE.md, whose conflict the pick resolved to the
earlier text.

Verified: signatures.py --check, refusal_surface.py --check and conformance-coverage --check pass
on this tree; metal-coverage is current.
2026-11-05 17:14:20 -08:00
Anees Iqbal c305c66a7f Give mesh pipelines Metal's descriptor limits, state queries and refusals
The mesh descriptor gains Metal's fields, with Metal's defaults:
max_total_threads_per_{object,mesh}_threadgroup, max_total_threadgroups_per_mesh_grid,
the two threadgroup-size-is-multiple-of-width flags, payload_memory_length,
max_vertex_amplification_count (1) and required_threads_per_{object,mesh}_threadgroup. The
descriptor key reads every one.

A compiled mesh pipeline carries MeshPipelineMetalInfo (RenderPipeline::mesh_info), and the
runtime's RenderPipelineState answers Metal's five mesh queries from it, plus the two required
sizes. Each thread limit is the descriptor's maximum, else the function's
[[max_total_threads_per_threadgroup(n)]], else 1024, held to the device's own limit where that is
lower: the task and mesh stages' invocations with VK_EXT_mesh_shader, the compute stage's where
both stages run as compute work. The widths are 32. The grid limit is the descriptor's, else the
object function's [[max_total_threadgroups_per_mesh_grid(n)]], else 2^20, held to
maxMeshWorkGroupTotalCount where mesh functions run natively. Without an object function the
object stage answers 0 and 0, where the M3 Max answers 3 and 32 (an accepted difference).
DeviceProfile::emulates_mesh_shading says how a device runs the stages, so a consumer no longer
copies the compile layer's rule; with the getters, no separate per-stage query is needed.

What Metal refuses is refused as Metal's rule, DescriptorError::MeshPipeline with a
MeshPipelineProblem, measured on the M3 Max (mesh_pipeline_limits.m, plain and under
MTL_DEBUG_LAYER): a required size with an axis of 0, past 1024 threads or past its stage's
maximum, or for an object stage without an object function (process ends); a maximum past 1024,
a function maximum other than the descriptor's, a mesh stage's required size of other threads
than its maximum, and a payload past 16384 bytes (creation errors, codes 3 and 2). An
amplification count of 0 is VertexAmplificationCount, as a render pipeline's; one above 1, which
Metal makes, is NotImplemented(VertexAmplification), recorded in FAST-PATHS' known gaps.

payloadMemoryLength widens the object and mesh functions' payload arena past the declared type
(LoweringInputs::object_payload now reaches the object stage too); an object stage compiled on
its own without it is NeedsInput(ObjectPayload). SEMANTICS_VERSION 1971 and
ARTIFACT_FORMAT_VERSION 488 for that and the new artifact field; the runtime's warm record
format 4 for the descriptor's fields.

Docs: the new_mesh_render_pipeline_state doc now says how each device runs mesh stages, and
what it refuses; API.md's accepted differences gain the mesh pipeline rows. api_signatures
blessed (it also records RuntimeFact::PartialObjectThreadgroups from the partial-threadgroup
commit), api_surface lists MeshPipelineMetalInfo and MeshPipelineProblem, REFUSALS.md,
METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md regenerated.

Tests: engine_mesh's a_mesh_pipeline_answers_metals_mesh_queries_within_the_device and
a_mesh_descriptor_metal_refuses_is_refused_as_its_rule over every committed mesh and
emulating profile; the validation lane's
a_mesh_state_answers_metals_queries_and_refuses_what_metal_refuses on a device. Not yet built:
the next steps are the M3, lavapipe and RTX 5080 runs.

(cherry picked from commit d6934967fad363ca2185c49935204141f253b416)
2026-11-05 17:12:37 -08:00
Anees Iqbal ead2c31249 Run a partial object threadgroup of drawMeshThreads as Metal does
What: a drawMeshThreads with an object function whose threads leave a
partial object threadgroup now draws instead of failing with
NotImplemented(MeshShading). The binder launches the object threadgroups
the threads fill, rounded up, at their whole size, under MultiRegion 1,
with Metal's threads in region[1].xyz and the new flag
lower::dispatch::NONUNIFORM in region[1].w (a folded variant's record
carries it in word 7). An object function whose body holds no workgroup
barrier (lower::mesh::plan_partial_groups, RuntimeFact::
PartialObjectThreadgroups) reads the flag: its threadgroup answers
min(L, threads - group * L) per axis as threads_per_threadgroup and in
its simdgroup counts, its thread position is lin unflattened over that
size, and its invocations past it return before the body. The emulated
wrapper's payload copy strides by the dispatched threads so those
invocations still copy. A body that holds a barrier keeps the uniform
form and its partial draws stay NotImplemented(MeshShading), since the
returned invocations would not reach the barrier (FAST-PATHS known gap).

Why: Metal (M3 Max, macOS 27.0.1) draws these: 6 threads in object
threadgroups of 4 run a threadgroup of 4 and one of 2 whose
threads_per_threadgroup is 2, as dispatchThreads runs a kernel.

Tests: lower::dispatch's partial_object_threadgroups_match_metal (each
Metal thread live once with Metal's builtins, Spec and Flat forms);
the binder's object_draws_specialize_each_stage_within_its_limits (the
flagged region, MultiRegion 1, refused without the fact); engine_mesh's
emulated and native partial draws and
a_partial_object_threadgroup_of_a_body_with_a_barrier_is_not_implemented;
the lane test object_draws_store_metals_words now requires Metal's words
for both Threads rows; the conformance ledger's two partial rows are
removed. SEMANTICS_VERSION 1970. Verification in the following commits'
potluck runs.

(cherry picked from commit 1707d3428bcd641faba462d4c35b13148df83a91)
2026-11-05 17:12:36 -08:00
Anees Iqbal 1f2b0f2d39 Run a command buffer's completion-seen handlers where seen even with completed handlers
A command buffer with completed handlers ran its whole transition to
Completed on its queue's handler thread, its completion-seen handlers
included, so they started a thread wake after the queue waiter's turn: the
consumer's handler_cost bench (a completion-seen and a completed handler on
each 4 KiB fill) put that wake into the completion-seen latency. On an idle
M3 Max (MoltenVK 1.4.2) the turn-to-handler time was 22 us at the median
with a completed handler against 1 us without.

Now the waiter runs such a transition to its completion-seen handlers
(To::Seen: its status final, those handlers run) where its queue's context
is idle, and posts the rest (To::Rest: follow release, completed handlers,
slot, releases, gate) to that context while it still runs it, so the queue's
later items stay behind the rest. The rest holds its own Hold, so the gate,
and wait_until_completed, open only after the completed handlers and once
the context is done with the rest (the order a10704b730 set). A command
buffer with a Follow (it signals at its end an event another queue's
command buffer may wait for) keeps the whole transition on the handler
thread, so the cross-queue order (follow.rs) is untouched. Where the waiter
cannot run it here (the line busy, a deallocator held), the transition goes
whole, as before (Item::whole).

complete() is split into complete_seen() and complete_rest(), unchanged in
order. Docs: add_completion_seen_handler, completion.rs, the runtime README
and RUNTIME-PORTING.

Not yet run on a device.

(cherry picked from commit e1f36ec2f08735c92872a3d5eed8689b398373ce)
2026-11-05 17:12:27 -08:00
Anees Iqbal 5080707c8c Document the surface shapes and BC textures the runtime makes
linear_plan.rs gains **Block-compressed surfaces** and **Beyond the
plane's rows** (the probe's measurements and what the runtime holds);
new_texture_with_iosurface_plane names the new shapes and the
SurfacePlaneShape refusal; TexelsPastBufferLength records where the M3
Max puts rows past a surface's end and that the x86 Macs' are
unmeasured; FAST-PATHS.md's known gaps record the refused shapes and
the taller-than-plane divergence on the x86 Macs, which IoSurfacePlane
cannot hold as it carries no plane height. Regenerated docs/REFUSALS.md
and api_signatures.tsv (RuntimeGap::SurfacePlaneShape).

Verified: refusal_surface.py (0 variants without reach or basis);
signatures.py --bless. Rustdoc runs in the next M3 job.

(cherry picked from commit d3bb1dfa2aab94728518529a0b2020da4a3e76aa)
2026-11-05 15:26:47 -08:00
Anees Iqbal a57e6c770a Copy a standing shadow in whole at its command buffer's first use
A pass that loads a shadow and draws under a scissor copied in only the
scissor's texels, so the image held only those: a later command of the
same command buffer reading every texel copied them all in again (beyond
what it held), and the command buffer's end, holding less than every
texel, left no standing. On the M3 the padded Private plane's Write frame
(a scissored pass, then a pass sampling the surface whole) planned
9478144 texels in a frame and skipped only the scissor's 262144 (job
m3-max-1937); WriteThenReadApart's writer never stood.

At a command buffer's first use of a shadow that may stand across
command buffers, the copy in takes every texel, as over logged host
pages: it moves nothing where the image stands, and leaves the image
holding every texel for the command buffer's later commands and its end.

The device test adds a pass that draws inside four rows: its load takes
the standing image, and the next command buffer's read stands and holds
the pass's rows over the earlier texels. API.md's catalogue entry says
the scissor cut does not apply to that first use.

Verified: runs next on the M3 with the controls.
(cherry picked from commit 258964cc06d8c4da64866b6991ec8b46906fa504)
2026-11-05 13:14:47 -08:00
Anees Iqbal 66ea975bdb Take a command buffer's tracked uses as its writes, whatever the logs collected
The standing let go of every shadow at each command buffer whose uses the
device's logs of host pages did not collect (`unnoted`), taking that as a
command buffer that may reach memory no use names. But `unnoted` only
says no log or copied host buffer lived to collect them (`note_dirty`):
the tracker's summary of every encoder holds its tracked uses either way.
So on a device with no logs every command buffer let go of every
standing, and none ever held (M3 job m3-max-1916: the second read of the
Private plane skipped no copy in).

Only `State::reaches_unnamed` (a root table, work resolved from records)
lets go of all now. A shadow over a buffer whose own uses are untracked,
whose writes no summary holds, never stands: the plane's texture takes
its descriptor's tracking, not the buffer's. The module docs and the
API.md catalogue entry say both.

Verified: runs next on the M3, with the negative controls.
(cherry picked from commit dcc32875db5aee8a8903ef9443235edce8de97cf)
2026-11-05 13:14:47 -08:00
Anees Iqbal 660f69188b Name the cross-command-buffer standing apart from a carry's, and say its cost
The standing commit's `shadow_standing::Standing` collided with shadow.rs's
own `Standing` (a carry entry's Unread/Current/Lost), which failed the
build (E0255). It is `StandingAcross` now.

The ShadowedTexture notice's cost said every use copies in; over a tracked
private buffer of the runtime's own a later command buffer now copies in
only once another command buffer wrote it. The cost text and the API.md
catalogue entry say so, and the entry names the conditions (the buffer's
kind, no handed-out VkBuffer, a command buffer reaching unnamed memory
letting go) and the counter.

Verified: the M3 build that failed on E0255 (job m3-max-1857); this
commit's build and the catalogue test run next.

(cherry picked from commit 52986e4c999b6fbdb593c177265fd577cdcfe553)
2026-11-05 13:14:47 -08:00
Anees Iqbal 81d45b6d40 Conformance: ledger rows for the wide-gamut cases on the RTX 5080
The RTX 5080 Laptop replay of the 32 cases (NVIDIA, b5080 batch m3-max-1762, binary at
aa91079622) made every pipeline and ran every case. The linear unwritten and masked cases match
Metal code for code; the rest differ at their texels in the families the MoltenVK rows name, in
the same shapes (the blend over the half shadow in the pixel interlock at one sample, the blends
over stored codes and the runtime's resolve at four, the sRGB twin's encode through the device's
Pow): a code from Metal's for the linear form, up to three for the sRGB twin at four samples.
26 rows, venue NVIDIA GeForce RTX 5080 Laptop GPU, in the MoltenVK rows' words.

The run's other gap, dont-care-store announced by the depth-only unwritten pipeline, is the one
46ff85e725 already declares (that binary predates it).

docs/CONFORMANCE-COVERAGE.md regenerated.

(cherry picked from commit 0f5ffdf4b634171cfcbecc386a58942f9002dd34)
2026-11-05 13:14:42 -08:00
Anees Iqbal 38210e8938 Conformance: the wide-gamut cases on lavapipe, declarations and ledger rows
The lavapipe replay of the 32 cases (llvmpipe, LLVM 23.1.1, job m3-max-1679) made every
pipeline, the four-sample ones included, and announced two notices the cases did not declare:
extended-range-blends-stored-codes at one sample too (lavapipe blends over the input attachment,
and the half shadow is built only for passes fetching in the pixel interlock), and
dont-care-store for the depth-only unwritten pipeline (its pass stores depth DontCare). The
blended draws and the blended masked write now declare the first, the depth-only unwritten
cases the second; each loosens the notices site alone.

26 llvmpipe rows for the texel sites: the linear blends a code from Metal's, the sRGB twin up
to three (four under the color mask), each saying which notes record it and what is open (the
half shadow over an input attachment and at four samples; the stored-codes note's stated code
does not cover an sRGB twin). The linear unwritten and masked cases match Metal on lavapipe.

The translator test's note on lavapipe at four samples now says what it is: the committed
profile states framebufferIntegerColorSampleCounts of one and no per-format count, so the
profile refuses; the device itself renders them (this replay).

docs/CONFORMANCE-COVERAGE.md regenerated.

(cherry picked from commit 46ff85e7254d5626292ad8e906c484b7c94d4bcf)
2026-11-05 13:14:42 -08:00
Anees Iqbal 0f04983d25 Conformance: ledger rows for the wide-gamut cases' MoltenVK texel differences
26 rows, venue Apple M3 Max, one per texel site the MoltenVK replay of the new cases left
unlisted (job m3-max-1657). Each says whose answer moves the codes:

- linear BGRA10_XR at one sample: the shader's blend over the half shadow in the device's
  float arithmetic (extended-range-blend-source / -float-blend-source), one code;
- linear at four samples: the same, plus the blends over stored codes and the runtime's resolve
  (extended-range-blends-stored-codes, extended-range-resolve, both announced), one code; open:
  the half shadow is single-sampled;
- the sRGB twin: the same plus the encode through the device's Pow (device-pack-conversion),
  one code at one sample and up to three at four, which extended-range-resolve's measured
  bound covers; the unblended sRGB rows take the existing sRGB-twin family's words.

The linear unwritten and masked cases need no row: they match Metal code for code.
docs/CONFORMANCE-COVERAGE.md regenerated (`scripts/conformance-coverage/coverage.py`).

(cherry picked from commit aa9107962298198722825148379784d1f5b546cc)
2026-11-05 13:14:41 -08:00
Anees Iqbal d1b5ace93d Keep draws that read textures through the heap, at commit and at a host step
A draw that read the heap (set 1's heap set, the device's texture table or a sampler table) was
never plain (render.rs draw_resident), so no execution of such draws kept a chunk: a host step
of the replayed_textured page (5001 commands, each reading a texture of its own through an
argument buffer) read and recorded all 5001 again at every step.

Now a replayed draw that is plain but for its heap is kept where its set-1 binding is one a
kept recording may bind again (heap_sets::bind's Bound::again):
- the device has descriptorBindingUpdateUnusedWhilePending, so the heap set is the shared
  SetVersion that later writes update in place (heap_sets.rs);
- the draw writes no set elements of its own (a function table's);
- its set holds no shadowed texture, decoded twin or raw read (SetEntry::notes_nothing);
- it reads no sampler table, and its tables bind no texture its heap part reads
  (HeapPart::binds_slot_textures).
A kept chunk holds a Weak of each SetVersion its draws bound (KeptEffects::heaps). Running it
again (KeptEffects::runs_again, heap_sets::bound_again) requires each to be its layout's
current shared version with nothing noted, and pins it for the command buffer as a fresh bind
does (HeapUse::bind_again). RenderKey gains the device's sampler_slots_changed count, so a
sampler state made or released between steps records the kept chunks again. Draws that fall
out are counted by why, new public WorkCounts fields: replayed_heap_draws_unshared,
replayed_heap_draws_writing, replayed_heap_draws_noted, replayed_heap_draws_over_sampler_tables,
replayed_heap_draws_table_textures. The replayed_frames lane prints them.

Images in the heap set rest in GENERAL and its image infos name GENERAL; only an instance's own
attachments move, as for a fresh recording. A kept chunk's run notes the uses its recording
noted (EncoderCore::run_kept), so the tracker orders it after earlier writers as it orders a
fresh recording.

Verified on the M3 Max (MoltenVK 1.4.2), release, the replayed_textured page (5001 commands,
15018 resident buffers), 2 rounds of 3 frames, interleaved, b960f51b05 (this branch's base
before commit 1; it carries the code of bfcfa638ee) against this commit:
- frame 2 (the first step that runs kept chunks): host_step_ms 25.6/26.7 before, 7.4/7.3 now;
  encoding to completion 57.0/57.8 ms before, 38.8/38.3 now; host_step_chunks_kept 0 before,
  20 now (every chunk); records_read 5001 before, 0 now.
- frame 1 (the step that records the chunks apart to keep them): host_step_ms 27.4/28.7
  before, 85.9/83.3 now; encoding to completion 60.1/60.3 ms before, 117.6/116.1 now. Each of
  the 20 chunks recorded apart gathers the page's 5002 resident uses (resident_uses_gathered
  100044, against 5006 inline). It is paid once, at the step that first finds the records
  unchanged.
- frame 0: 99.4/98.5 ms before, 102.9/101.5 now.
- replayed_heap_draws_*: 0 in every frame.

New tests:
- runtime tests::kept_heap_uses (device test): the batches planned for a frame that runs both
  chunks kept hold the same tracked uses (resource, range, read and write stages and accesses)
  as those of the frame that recorded inline, the 512 textures among them
  (CommandBuffer::watch_planned, test-only).
- lane kept_textured (two chunks, validation layer): a host step keeps the heap draws (frame 1
  records apart, frame 2 runs kept, frame 0's pixels; the host then writes every texture's
  texels and frame 3, still kept, draws what a fresh page of those texels draws; where the
  device lacks the feature, every frame records inline and counts every replayed draw unshared);
  a kept draw reads what a blit in an earlier command buffer wrote, on the same queue and on
  another queue (a spinning kernel holds the blit back past the host step); a sampler state made
  between steps records the chunks again; a texture swapped at a token records them again; a
  texture made with a released texture's ID is read by the kept draws.
- replayed_textured's commit-1 test now runs on a device made without
  descriptorBindingUpdateUnusedWhilePending (DeviceOptions::withheld_features), so each command
  buffer binds a heap set of its own and its draws stay not plain: it still covers commit 1's
  hand-back, and now also asserts that no chunk is kept.

Negative controls, each fails its test on the M3:
- plain_drawn set from the old plain rule (no heap draw kept): the keeping test fails;
- run_kept noting none of the recording's uses: tests::kept_heap_uses fails (the kept frame's
  planned uses differ from the inline frame's);
- RenderKey's samplers left out of its equality: the sampler test fails;
- the resident key left out: the token-swap and gone-ID tests fail;
- commit 1's hand-back dropped: the commit-1 test fails at frame 2 (674400 bytes copied).
The pixel test a_kept_heap_draw_reads_what_an_earlier_command_buffer_wrote still passes on the
M3 under the dropped-uses control: there the copies land before the kept draws read them anyway
(expected cause: Metal under MoltenVK orders its tracked textures' writes itself; unaudited).
The structural uses test is the check that fails.

Checks run on the M3: clippy -D warnings with --cfg m2v_gpu over the runtime and validation
crates (all targets, all features); the runtime suite (1659 passed; tests::kept_heap_uses
passed on its own after its hook was keyed right); the residency, draw and notice lanes (248
passed); the kept, step and replayed lanes (62 passed; kept_textured and the commit-1 test run
again after the last test edits, 6 passed); the frame-cost lanes in debug and release (3
passed); the API signature table (blessed for the five fields).

(cherry picked from commit bc717ab533dbc4d36d47f355245857fd0d1fe773)
2026-11-05 11:25:48 -08:00
Anees Iqbal f2fc42a95d Show a command buffer's kernel start only with its end, waiting or not
`kernelStartTime` answered the host time the scheduler began submitting the first batch as soon
as it began, while `kernelEndTime` answered 0 until the last batch was submitted: a start without
an end for as long as the submission took, and for as long as a command buffer that waits for an
event after its first batch waited. Metal shows neither before both. A Swift probe on the M3 Max
under macOS 27.0.1 (a potluck job, committed nowhere) read each command buffer's pair, start
first, from its commit until it completed: 3,900 to 240,000 reads of each of six that waited for
nothing, and 4.6 to 4.7 million over 200 ms of each of eighteen that waited for an
`MTLSharedEvent` the host signalled or an `MTLEvent` another queue's command buffer signalled,
after a blit encoder, before one, or alone. None answered a start and no end. The waiting ones
answered both 0, `Committed`, until 50 to 160 us after the signal, then both; their start was
13 to 39 us after the commit, from before the wait.

`kernel_start_time` now reads `KernelTimes::shown_start`: 0 until the end is stored, the start
then (the end loaded first, acquire; the start is stored before the end on every path). The
scheduler's own reads (whether to begin, a recovery's window, the GPU times' life check) keep the
stored start, `KernelTimes::start`, so no scheduler file changes. Where the first command waits
for the event, the runtime's start is that batch's submission after the signal, where Metal's is
about the commit: recorded among docs/FAST-PATHS.md's known gaps.

The users of the old order move to Metal's semantics:
- rebind_reach's four held-buffer cases waited for `kernel_start_time() != 0` as the sign that
  the batch before the wait was submitted, which now never shows while it waits (they timed out
  at 60 s with 86701a2e00). They wait instead for the device's batches submitted to rise
  (`WorkCounts::batches_with_none_pending` and the three fields after it, which count a batch as
  it is submitted or held, at the place in `submit_batch` where the start was stored), through
  `property_reads::first_batch_submitted`; `walk`'s check that nothing was submitted before the
  event reads the same count.
- property_reads_wait_for_no_submission_and_no_busy_work counted a read inside the submission as
  one that answered a start and no end. A read inside is now one begun after the kernel start
  and returned before the kernel end, on their clock (`host_time`), judged once the end shows
  from the most recent 2^16 reads each thread keeps; and the test asserts that no read of either
  thread answered a start and then no end.
- New: property_reads' kernel_times_show_neither_while_their_command_buffer_waits_for_an_event,
  for both kinds of event: after the batch before the wait was submitted (the count), 50 ms of
  reads answer neither time and `Committed`; after the signal no read answers a start alone, and
  the start lies before the signal, the end after it.
- New: tests::gpu_time::a_kernel_start_shows_with_its_end_alone.

Tests: those above on MoltenVK (M3 Max, --cfg m2v_gpu) and lavapipe (--cfg m2v_cpu_icd); the
negative control is `kernel_start_time` reading the stored start again, under which both
property_reads tests and the unit test fail.

(cherry picked from commit 2ce15a20927a8f7a44c1bc7ee70869977a88d702)
2026-11-05 11:25:47 -08:00
Anees Iqbal e56b684d54 Record the packed word's blend refused on lavapipe among the known gaps
A blend or a partial write mask of a packed 16-bit attachment the device renders through its
word view (`A1BGR5Unorm`, `ABGR4Unorm`) is built only where the device orders fragment fetch
through the pixel interlock alone (`color_writes::stored_word`, `fetch::interlock_orders`). The
known-gap line named the device without the interlock as where it is refused; lavapipe has the
interlock but orders fetch through rasterization-order input attachments, and there the function
neither blends the word nor merges its fields over the input attachment (`merges_over_input`
leaves packed words out), so it is refused as the device lacking the format too. That is ours,
not the device's: lavapipe orders the fetch an in-shader blend needs, as the extended-range blend
over its input attachment uses. 98d65ecad3 made the multisampled word lane accept the refusal
there; the ledger now says so.

Docs only. Checked against the code paths named above and lavapipe's committed profiles
(`profiles/lavapipe.json`, `gate-lavapipe-x86_64.json`: `fragmentShaderPixelInterlock` and
`rasterizationOrderColorAttachmentAccess` both true).

(cherry picked from commit 25b55132654d8b4c6554e9a0bc0a030820db22f9)
2026-11-05 11:25:47 -08:00
Anees Iqbal 39639ef473 Follow struct members in the narrow analysis: mixed-select merges and a read's noted bits
What. Two analyses in lower/arith/narrow.rs looked only at whole values, so a value carried
inside a composite slipped past both:

- `merges_mixed_selects` (now `narrow::merges`) decides whether a module merges a select of a
  widened `half` against a value it does not hold widened with another widened value. Metal's
  compiler answers 2045 of the 2046 `half` NaNs of that merge `0x7E00` (measured on the M3 Max,
  2026-11-03), so a module that does it stays outside `DriverDeviation::MetalNanMoves`. It
  checked only scalar selects at phis and stores, and missed the same merge when a struct (a
  texel read's `{T, i8}`), an array or a vector carried the select and the other value. The new
  module records how each value is made (construct, insert, extract, copy, select, phi) and asks
  member by member, by a path of literal indices, whether a merged value holds a mixed select
  where another merged value holds a widened one. Walks are bounded (256 steps per question, 256
  members per type; past a bound the answer is the conservative one), and the records are charged
  to the meter.
- `known_bits` reused a `half`'s read bits only when the stored value was the read itself. A
  store of the read's value pulled back out of a struct (`{T, i8}` built from the read, then
  `OpCompositeExtract`) encoded the `half` again, which is the device's narrowing and loses a NaN's
  bits. The builder now records each struct construct, insert and extract it emits
  (`ModuleBuilder::structs`, counted in its footprint), and `FunctionBuilder::member_source`
  walks an extract back to the value that supplies the member wholly. A later insert into part
  of the path, a struct the builder did not make, a load or a phi gives no source. `known_bits`
  follows it before looking up noted bits.

Both decide from IR structure only (types, composite paths, operands), never from names.

Why. The coordinator's bug: `narrow::merges_mixed_selects` misses struct-wrapped merges, and a
store of a read's value does not see noted bits through the `{T, i8}` extract.

Docs: driver_facts.rs (the MetalNanMoves measurement) and docs/API.md's native-nan-encoding
entry now say the merge is followed member by member, and that a `half` moved unchanged from its
read keeps its bits through a struct's member too. The member-by-member reading is not measured
through a composite; the code and the docs say so.

SEMANTICS_VERSION 1968 -> 1969: translations change. The golden table moves 30 cells, all
`engine/rfs_imageblock_cover{.ll,.air.ll} | cover_two_word`, on every one of the 15 profiles.
That kernel's `as_type<half>` result is now stored from its noted bits through the struct
member instead of being encoded again. The table is re-blessed on development, not here.

Verified on the M3 Max (potluck, debug):
- New tests:
  - `lower::arith::tests::narrow::narrow_members_move_as_bits_through_structs`: every
    pattern of every narrow form, through a construct, inserts, a nested struct, and a
    replaced member, compared exactly.
  - `lower::arith::tests::narrow::a_merge_of_a_select_is_followed_through_struct_members`:
    builder-made `OpPhi`s of a plain select and of structs carrying it by construct, insert
    and extract are merges; a struct holding the select apart from the other value's member,
    and a merge with a constant, are not.
  - `tests::engine_arith::half_moves_are_metals_only_where_the_device_folds_them` gains
    kernel `member_kept`: a `half` read, inserted into `{half, i8}` and extracted keeps its
    bits (0xFE01) and widens nothing.
  All three, plus engine_cross_class and engine_float_call_notes, pass: 15/15, job
  m3-max-1192.
- Negative controls, with the translator sources of fd1029d6c9 under these tests (job
  m3-max-1195): all three fail.
  - The merge test fails at `Struct` (false, want true).
  - The members test fails "Form { held: Float(Half), lanes: 1 } through a struct
    (construct): 2045 of 65536 cases differ".
  - `member_kept` widens on lavapipe (true, want false).
- Note sets: a census of every public fixture's entries (2914 rows per stem) on moltenvk-m3 and
  lavapipe. It recorded each row's precision notes and whether it requires MetalNanMoves, before
  (fd1029d6c9's sources) and after. The two files are byte-identical (job m3-max-1195), so no
  fixture gains or loses a note on either device.
- Full metal2vulkan suite at an earlier stage of this change: 3335 passed. The 2 failures were a
  since-corrected test expectation and the golden table above (job m3-max-1190).

(cherry picked from commit a4c235fb867a6a32098b77e39387c43a97a28862)
2026-11-05 07:39:33 -08:00
Anees Iqbal be34c40f1d Bound a packed blend by the code its sample was stored at
The multisampled word lane compares each blended sample of a format the
device renders itself with Metal's within one code. The blend reads the
sample the device's fill stored, which the lane already accepts a code from
Metal's (the device's conversion, `device-color-conversion`), and the device
blends over that code by its own arithmetic, so the two native differences add.
On lavapipe (Mesa 26.2.4, LLVM 23.1.1) `A1BGR5Unorm` at 4 samples, pixel 12:
the fill stored 0x9ea1 where Metal stored 0x9e61 (green 26 against 25), and
source-over at alpha 0.102 stored 0x9ea5 against Metal's 0x9e23 (green 26
against 24, blue 18 against 17); the exact blend over the device's own sample
is green 25.31, blue 17.44, so the device's blend is itself within a code.

The lane now allows a blended sample one code more for each code its stored
sample lies from Metal's (none on the word path, whose fill is exact).
`PrecisionNote::DeviceColorConversion`, `Degradation::DeviceColorConversion`
and docs/API.md's catalogue record the measured lavapipe bound: within 2
codes over a sample stored a code from Metal's.

Verified on msi-laptop, lavapipe (Mesa 26.2.4), `--cfg m2v_cpu_icd`: at
b23d78eb50 `multisampled_word_formats_store_read_resolve_and_blend_as_metal`
fails on that one sample (word 0x9ea5 against Metal's 0x9e23), every other
blended sample within one code; the words above came from a scratch
diagnostic run (not committed).

(cherry picked from commit 5a4a8ca8fc297b03f19b39cf675eee1ada29742c)
2026-11-05 07:39:32 -08:00
Anees Iqbal d261d6ed46 Announce device-subpixel-snap where the band draws on a driver not measured to snap a half step as Metal
line_widths' wide_lines_draw_metal_s_parallelograms (and its exact-answers
twin) failed on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, b5080 entries
nvlane-lane2-a2f and nvlane-lane3-a2f at a2f4c50f94) and on lavapipe
(llvmpipe, LLVM 23.1.1, Mesa 26.2.4, nvlane-lvplines-a2f) at "rows
offset by (r - 32) / 512 width 0": both drew the map's rows 18 to 49
where Metal draws 17 to 48. Before a5e1d20bd9 the 5080 failed earlier in
that test, at "LANE strip 1", so this case had not run there.

The case draws lines at y = r + 0.5 + (r - 32) / 512, which the band
draws at width 1/16 (half width 16/512). band.rs leaves the corners'
snap to 1/256 pixel to the device's rasterizer, where Metal snaps the
endpoints first, a half step rounded up, and offsets them after; the two
agree on the grid, and for odd r the endpoint lies half a step off it.
Half steps rounded down give the device's map exactly: odd r covers its
row for r in 19..49 and even r for 18..48, against Metal's 17..48 (round
to even gives the same rows here). The band's arithmetic is exact at
these values (side 64, every conversion a power of two), so the rounding
is the rasterizer's, which Vulkan leaves to the implementation: the
device's own answer, so it is announced, not emulated.

- DriverFact::SubpixelSnapIsMetals (appended): the driver's rasterizer
  snaps a vertex half a step off its 1/256-pixel grid as Metal snaps a
  line's endpoint, up. Row: MoltenVK on the M3 Max (APPLE9), where this
  lane's maps pass (a2f4c50f94, m3-max-994: 1847 of 1847). NVIDIA and
  lavapipe drew otherwise, so neither takes it; every other driver is
  unmeasured.
- Degradation::DeviceSubpixelSnap ("device-subpixel-snap", precision):
  announced by line_route at each draw the band draws on a driver
  without the fact. Its catalogue entry in docs/API.md, a FAST-PATHS
  known gap, and the conformance suite's NATIVE_NOTES (the device's own
  answer) take it. band.rs's and line_width.rs's docs say where the two
  snaps differ.
- The lane announces it per draw; a band case with a vertex an odd
  multiple of 1/512 pixel off (in framebuffer pixels) is left unchecked
  where it is announced, and every other band case is still compared
  with Metal's map. Held to the fact: never announced where the driver
  has it, and some case unchecked where it does not and the device
  tessellates. degrade_notices lists SUBPIXEL_SNAP as its site.
- driver_facts' profile test expects the fact on moltenvk-m3.

Note sets: MoltenVK on the M3 Max takes the fact, so it announces
nothing new. NVIDIA, lavapipe, RADV and ANV now announce
device-subpixel-snap at band draws. api_signatures.tsv gains the three
items (blessed); docs/REFUSALS.md regenerates unchanged. driver_facts.rs,
degradation.rs and line_width.rs are runtime pin inputs, so
RUNTIME_VERSION and the pin are the orchestrator's to move.

Verified: cargo fmt; scripts/api-signatures --check after --bless;
refusal_surface.py. Builds, clippy, the unit tests and the 5080, M3 and
lavapipe lane reruns are in the next jobs.

(cherry picked from commit 2574f4bb084656035feae4ef714bac96f720f497)
2026-11-05 05:11:14 -08:00
Anees Iqbal 792822226e Take lavapipe out of LineTiesAreMetals: it leaves out the line lane's strip's first pixel
a5e1d20bd9 gave lavapipe the fact on the conformance case's evidence
(llvmpipe draws primitive-type-restart-indices' line through (3.5, 1.0)
as Metal does). The line lane on lavapipe says otherwise: at 3785e99d8e,
under --cfg m2v_cpu_icd on msi-laptop's lavapipe (llvmpipe, LLVM 23.1.1,
Mesa 26.2.4, m3-max-949), wide_lines_draw_metal_s_parallelograms and its
exact-answers twin fail at "LANE strip 1": the strip starts at (3.5, 1.0),
a vertex the diamonds of rows 0 and 1 share, and lavapipe leaves out row
0 column 3, which Metal covers; every other pixel of the map is Metal's.
With the fact the lane held lavapipe to exactness there, and it failed.

The fact's rows are now MoltenVK on the M3 Max alone, so lavapipe
announces device-line-ties at its width-1 line draws as NVIDIA does: a
notice lavapipe did not announce before, for a difference it drew
silently before. driver_facts' profile test no longer expects the fact
on the three lavapipe profiles; the fact's docs, the catalogue entry,
FAST-PATHS' known gap and the lane's docs say what lavapipe draws.

Verified: cargo fmt. The lavapipe rerun of the line lane is in the next
msi job.

(cherry picked from commit a13ef6b9c4aeb5bac7448bd1a16526352458169d)
2026-11-05 05:11:14 -08:00
Anees Iqbal d9e3324d4e Announce device-line-ties where a driver breaks a width-1 line's diamond-vertex tie unmeasured
line_widths' wide_lines_draw_metal_s_parallelograms (and its exact-answers
twin) failed on the RTX 5080 Laptop GPU at "LANE strip 1": the
three-vertex strip at width 1, drawn in Bresenham's mode, put its
diagonal a row higher than Metal's (row 9 columns 3-4 where Metal draws
row 9 column 3 and row 10 columns 4-5, and so on, its last pixel at row
14 left out). The diagonal runs through vertices two pixels' diamonds
share; Metal covers the lower pixel, and Vulkan's diamond is open, so
the tie is the driver's with no Vulkan control over it. FAST-PATHS'
known gap "One line texel at a diamond vertex on the RTX 5080" already
said so for the conformance case primitive-type-restart-indices, but
the runtime announced nothing: a near-equivalent drawn silently.

- DriverFact::LineTiesAreMetals (appended): the driver's width-1 lines,
  as the runtime draws them, cover Metal's pixel at such a tie. Rows:
  MoltenVK on the M3 Max (APPLE9; its lines are Metal's own, the lane's
  maps pass there) and lavapipe (the conformance case: no texel differs
  on llvmpipe, LLVM 23.1.1, Mesa 26.2.4). Every other driver is
  unmeasured, so NVIDIA, RADV and ANV announce.
- Degradation::DeviceLineTies ("device-line-ties", precision): announced
  by line_route at each draw the device's lines draw at width 1 (a
  plain-width draw of lines or edges, or the nearest width where that
  is 1) on a driver without the fact. Its catalogue entry in docs/API.md,
  FAST-PATHS' known gap (now "announced"), and the conformance suite's
  NATIVE_NOTES (the device's own answer) take it.
- The lane announces it per draw, leaves such a case unchecked as it
  does the other announced routes, and holds it to the fact: never
  announced where the driver has it, announced in some case where it
  does not. degrade_notices lists LINE_TIES as its site.
- driver_facts' profile test now expects the fact on the three lavapipe
  profiles and moltenvk-m3.

Note sets: MoltenVK on the M3 Max and lavapipe take the fact, so neither
announces anything new. api_signatures.tsv gains the three items
(blessed); docs/REFUSALS.md regenerates unchanged. Not covered (left as
it was): a pipeline whose multisample state keeps Bresenham's mode off
(alpha to coverage, alpha to one, sample shading) draws the device's
default mode, which the fact does not measure. The runtime's notice and
line_width.rs are runtime pin inputs, so RUNTIME_VERSION and the pin are
the orchestrator's to move.

Verified: cargo fmt; scripts/api-signatures --check after --bless;
refusal_surface.py. Build, clippy, the unit tests and the 5080 and M3
lane runs are pending (the lane fixes batch).

(cherry picked from commit 75bb1413eacbf5ef3e1a3abed7ec97eff4b1c42d)
2026-11-05 05:11:13 -08:00
Anees Iqbal 639e505b11 State NVIDIA's BC decode bound as the RTX 5080 measures it: 4/255 for BC1 to BC3, 7.4/255 for BC4 and BC5
compressed_decode's bc1_to_bc5_texels_read_the_device_s_decode failed on
the RTX 5080 Laptop GPU (identically at d19da8bfce and 961b1ff319: the
lane's blocks are seeded) with channels past compressed-texel-decode's
stated bound. Its BCDECODE lines, per channel:

  BC2RGBASRGB  codes [2, 4, 2, 0]            18 past the note
  BC3RGBA      [2.0, 4.0, 2.0, 6.0]/255       7 past
  BC3RGBASRGB  codes [2, 4, 2, 0], alpha 6    12 past
  BC4RUnorm    7.327/255                      6 past
  BC5RGSnorm   16.329/255 (0.064035)          4 past

The others are within it (BC1RGBA [1, 3, 2, 0]/255, BC4RSnorm 0.0595,
BC5RGUnorm [7.163, 5.593]/255). The decode is the device's own (rule 1),
announced; the bound understated it: a BC1 to BC3 channel (the 6-bit
green) up to 4/255 where it said 3/255, a BC4 or BC5 channel up to
7.4/255 (signed 0.065) where it said 7.3/255 (signed 0.064).

The notice's cost (degradation.rs), docs/API.md's catalogue entry,
docs/FAST-PATHS.md's row and the two DriverFact docs now state the 5080's
measured bounds for NVIDIA, lavapipe's 3/255 kept apart, and the lane's
noted_bound copies them (4/255, 7.4/255, signed 0.065), so a run past them
still fails. No decode, note condition or announcement changes.

degradation.rs and driver_facts.rs are runtime pin inputs: the
runtime-sources pin needs its re-hash.

Verified: cargo fmt. The 5080 rerun is pending (the lane fixes batch).
(cherry picked from commit 164575080bf6132dc621a7e542af6a6f133c3a3f)
2026-11-05 05:11:13 -08:00