Commit Graph
3165 Commits
Author SHA1 Message Date
Anees Iqbal 2ef8af3abe A pass-start read takes the copy cleared by MoltenVK's clear command, which is Metal's clear
What: on MoltenVK (DriverFact::ColorClearIsMetals) a draw that samples a colour its pass clears,
after a memory barrier at the pass's start, split the pass again (attachment_read_splits, a
second render pass instance, the render-pass-split notice) instead of reading a copy of the
attachment cleared to the clear before the pass (attachment_read_clears). Texture::cleared_copy
refused a clear whose device-color-conversion note the load operation withholds
(ColorTarget::withheld_clear), because the copy is cleared by vkCmdClearColorImage and only
the load operation was measured to store Metal's texel there. Since 876cfd1402 every clear of
a normalized channel off a whole code is in question (the spec's rule), so the pass-start
clears of the lanes and the conformance cases became withheld on MoltenVK and split.

The driver's clear command is measured to store Metal's texel too, so the fact now covers it:
- Texture::cleared_copy takes a withheld clear (no note owed: the clear command's texel is the
  load operation's, Metal's).
- A memoryless attachment's backing cleared after the first instance, and an attachment the
  first instance leaves out cleared before the pass by the clear command (cleared_ahead), owe no
  note either; the same clear by a render pass of the attachment alone, or as sample planes,
  still announces it.
- DriverFact::ColorClearIsMetals, ColorTarget::withheld_clear, texture/attached_reads.rs and
  docs/API.md's device-color-conversion entry say so.
Elsewhere withheld_clear is None (the note is announced as the pass is laid out), so nothing
changes on other drivers.

Why, measured on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2):
- The cause, by a probe of each condition of cleared_copy over 22,482 runs of
  attachment_reads::a_draw_after_a_barrier_at_the_pass_start_reads_the_clear on development at
  1571c220d7: every run failed the same way, (cleared copies, splits, begun) = (0, 1, 2), with
  withheld_clear Some([200, 40, 120, 160] / 255) the only condition that refused (not load, not
  timing).
- The clear command: each of the 71 colour clears Metal was measured with
  (renders.rs COLOR_CLEARS: ties of 8-, 10- and 16-bit unorm and snorm channels, sRGB, packed
  16-bit, half and small floats, shared exponents, NaNs) by a plain fill of a whole 1x1 texture,
  which is vkCmdClearColorImage of the load operation's clear value (blit_fill.rs): 71 of 71
  Metal's bytes, and equal to the load operation's 71.
  runtime_lane::renders::clears_are_the_device_s_conversion_of_the_clear_value now checks this
  on a driver with the fact.

Ran on the M3 Max (macOS 27.0.1, MoltenVK 1.4.2) at this change over 693fd3f96d, under --cfg
m2v_gpu: the whole validation suite, 3398 of 3400 passed (attachment_reads and renders among
them); the two failures are the runtime-sources pin, which the landing sets, and
degrade_notices::a_creation_s_notices_and_messages_reach_the_sink_on_the_asking_thread at
device creation (creation_heard_checked), before any pass is recorded. conformance cost --check
over the whole set: no gated count and no ceiling moved (the pass-start-barrier cases read the
cleared copy again, as recorded); conformance replay of the 14 pass-start-barrier cases: rc 0,
each difference an accepted one. On this base only driver_facts.rs merged (beside
ClearedDepthAtStandardPositions); the other five files are unchanged since 693fd3f96d.

RUNTIME: the runtime's pass-start reads on MoltenVK change (a cleared copy instead of a split).
(cherry picked from commit 25063af705d28d07b7332cc1b35a5cf1beedc6bb)
2026-11-09 07:53:32 -08:00
Anees Iqbal 6d7f59365a RUNTIME_VERSION 1975 and the runtime-sources pin for a depth cleared ahead where RADV on the RX 550 clears at the standard positions
nvreds c7061858f8: on RADV POLARIS12 (Mesa 26.2.6) a pass at custom sample
positions whose load op clears its depth stores and tests every sample's
depth at the standard position of its index for every draw (16/16 samples,
Depth32Float, Depth16Unorm, Depth32Float_Stencil8), while a pass that loads
the depth takes the custom positions. New DriverFact
ClearedDepthAtStandardPositions (one row, RADV 0x1002:0x699f): ReachClears
clears that depth before the pass in its own render pass
(vkCmdClearAttachments) and the pass loads it; no notice, the answer is
Metal's. Runtime behaviour changed: RUNTIME_VERSION 1974 -> 1975, pin
recomputed. A DriverFact enters no translation fingerprint, so SEMANTICS
stays.

Verified by nvreds: runtime_lane::sample_positions RX 550 9/9 (validation
layer silent, 'cleared ahead true (1 attachment clears)'), 780M 9/9
('cleared ahead false'), base 3d5ed3b021 RX 550 4 red; clippy plain + gpu;
driver_facts/api_signatures/api_surface 9 pass. Here: signatures --check and
refusal surface unchanged. Not measured: separate depth and stencil textures
at custom positions on the RX 550.
2026-11-09 07:38:03 -08:00
Anees Iqbal 3314bd71b9 Clear a depth at custom sample positions before its pass where RADV on the RX 550 clears it at the standard ones
What: DriverFact::ClearedDepthAtStandardPositions (appended), one row: RADV on the Radeon RX 550
(0x1002:0x699f). On a driver with it, a pass at custom sample positions whose depth Metal clears
has that depth cleared before the pass by ReachClears (a render pass of the attachment alone,
vkCmdClearAttachments), wherever the clear reaches, over the render area alone where the pass
does not store it, a memoryless depth too, and the pass then loads it (load_in_pass). Nothing
is announced: the answer is Metal's. clear_reach.rs and sample_positions.rs (runtime) document
the route; driver_facts.rs documents the fact and its measurement.

Why: runtime_lane::sample_positions failed on the RX 550 (RADV POLARIS12, Mesa 26.2.6) in four
tests (depth_takes_the_custom_positions, custom_sample_depth_store_stores_as_store,
later_passes_keep_the_stored_samples, a_callers_image_takes_the_positions_through_a_stand_in):
plane X drawn at four custom positions stored each sample's depth at the standard position of
its index (stored 0.421875, 0.484375, 0.390625, 0.453125 where Metal stores 0.390625,
0.4140625, 0.453125, 0.484375). Probes through the lane's harness on the RX 550:
- Depth32Float, Depth16Unorm and Depth32Float_Stencil8 4x, cleared by the pass: 16 of 16
  samples at the standard positions, 0 at Metal's; a second draw in the pass, and a DontCare
  load the runtime clears, the same.
- the pass's own test under Less against a clear of 0.4375 drew samples 0 and 2 of each
  first-column pixel (the standard positions'), where Metal draws 0 and 1;
- a pass at four other positions that loaded such a depth drew and stored at its own positions;
- a depth cleared by a pass without a draw, then loaded and drawn at the custom positions:
  16 of 16 at Metal's.
Coverage was at the custom positions throughout (the lane's coverage and stencil tests passed).
So the driver evaluates the depth at the standard positions in a pass whose load operation
clears it, and at the pass's positions in one that loads it. The route reaches that by
documented Vulkan alone (a clear in a pass of its own, then LOAD), selected by a measured fact
like PositionedDepthReadAtStandardPositions's stand-in for NVIDIA. RADV on the Radeon 780M
keeps the custom positions' depths and takes no row.

Tests: driver_facts' a_radv_gpu_no_row_names_takes_radv_s_driver_wide_fact_alone gives the RX
550's identity the fact and RADV's driver-wide one alone; the lane's
depth_takes_the_custom_positions holds the route to the fact: where the device has it, its
custom-position pass records an attachment clear (WorkCounts::attachment_clears_recorded), and
it prints whether it cleared ahead. api_signatures.tsv gains the two variant rows.

Ran (um790, at a tree identical to this commit on be59d46240): runtime_lane::sample_positions 9
of 9 on the RX 550 ('1002:699f!', Mesa 26.2.6), "cleared ahead true (1 attachment clears)",
dz_custom4_memoryless included, the validation layer silent; 9 of 9 on the Radeon 780M
('1002:15bf!'), "cleared ahead false (0 attachment clears)". Before it, at 3d5ed3b021, the RX
550 failed the four tests above. clippy -D warnings over metal2vulkan, -runtime and -validation
(all targets, all features), and over -validation and -runtime under --cfg m2v_gpu; the
metal2vulkan tests matching driver_facts, api_signatures and api_surface (9 passed);
signatures.py --check and refusal_surface.py --check.

RUNTIME: clear_reach.rs and sample_positions.rs change (a new route on one driver), so
RUNTIME_VERSION and the runtime-sources pin are the orchestrator's to move.

(cherry picked from commit c7061858f8e8562c2b5dab8dddf0d620c2c5ee29)
2026-11-09 07:37:22 -08:00
Anees Iqbal be59d46240 word_samples_msaa: read the samples in a threadgroup of whole subgroups on every device
What: the sample reads (wsm_read_f, wsm_read_u) are dispatched in one threadgroup of 128
threads (GROUP), whole simdgroups and whole subgroups of every size a kernel's simdgroups run
on (32, or 64 or 128 for wider subgroups split into simdgroups), instead of the row rounded up
to thread_execution_width (32).

Why: on the RX 550 (RADV POLARIS12, 64-wide subgroups) the lane failed with "announced past
[...]: [EmulatedSimdgroups]": "a dispatch of kernel `wsm_read_u`: its threadgroups of [32, 1, 1]
threads are not whole subgroups of the size the kernel's simdgroups run on". The kernels have
no simdgroup operation or barrier in their source, but their translations carry one
OpControlBarrier and LocalSizeConstraint { multiple: 64 } there (printed by a probe): the
lockstep pass orders each thread's stores in its loop over the samples, whose index the
analysis does not prove apart between threads, so a 32-thread group is a partial subgroup and
runs on the emulated-simdgroups variant, announced. The lane's comment already meant to avoid
that route; whole simdgroups are not whole subgroups on a 64-wide device.

Ran on the RX 550 (um790, MESA_VK_DEVICE_SELECT=1002:699f!) at this change on 3d5ed3b021:
runtime_lane::word_samples_msaa passed (announced: ShaderResolve, WordResolve,
DeviceRoundedResolve and the allowed kinds; no EmulatedSimdgroups), with
runtime_lane::shader_stencil's four tests in the same run.

(cherry picked from commit b9e255758cedde5b27b079c75938000b446c172f)
2026-11-09 07:15:41 -08:00
Anees Iqbal ce1fca855a uniform_varyings: a half denormal may read as the zero the device's noted rounding answers
What: the flat read's compared words must be Metal's, but now a `half` denormal (Metal's word is
the denormal itself) may read as a zero where a stage of the pipeline records the device's own
`half` rounding: of either sign under PrecisionNote::NativeHalfQuantize (the device's
OpQuantizeToF16, which the SPIR-V specification lets answer a zero below the smallest normal
`half`), of the denormal's sign under NativeHalfConversion. Those words are counted apart
(`device-rounded denormals` in FLT-LANE, "the device's" in FLT-LANE-WORD), not as differences.

Why: on the RX 550 (RADV POLARIS12, no shaderFloat16) the lane failed with 24 differing
constants: the three `half` denormal constants 2 (0x0001), 3 (0x83ff) and 21 (0x0200) read
0x0000 in hp and hn at every qualifier and sample count (3,672 words each at 1x), where Metal
keeps them. The flat read rounds each `half` lane after Metal's word for it by the device's
quantize and narrows it to its bits by PackHalf2x16 for the store, and both the quantize and
the conversion notes are recorded there; the device's answer is within the quantize note's
bound (rule 1: the device's native rounding, recorded). Every other word stayed Metal's.

Ran on the RX 550 (um790, MESA_VK_DEVICE_SELECT=1002:699f!) at this change on 3d5ed3b021:
runtime_lane::uniform_varyings passed; flat hp/hn 223,992 of 235,008 words Metal's at 1x with
11,016 device-rounded denormals (the three constants), 0 otherwise differing; float varyings
unchanged (cp 216,648/216,648, cn 235,008/235,008). Before the change the same run failed with
those 24 differences.

(cherry picked from commit 48805fe7356f4150c255b9788219aa943c171365)
2026-11-09 07:15:41 -08:00
Anees Iqbal 3d5ed3b021 read_through_views: a view's mipmaps are the device's box filter of each level above, not one format's ties
mipmaps_through_a_view_are_the_formats held the levels generate_mipmaps writes through an
A8Unorm view of an R8Unorm atlas equal to a plain A8Unorm texture's. On the RX 550 (RADV
POLARIS12) the first level through the view read [9, 11, 13, ...] where the plain texture's read
[8, 10, 12, ...] (potluck 11625 and 11635): each texel the average of four codes on a tie, which
the device's blit (device-filtered-mipmaps) rounds up into R8_UNORM and down into A8_UNORM. Vulkan's
conversion to a normalized code takes either of the two codes nearest the value.

Both chains are now held, level by level, to the box filter of the level above as the device wrote
it: the average where it is a code, else one of the two codes around it. The texels where the two
chains differ are counted and printed.

(cherry picked from commit 3dbee7cf7fe3128d8c436dc548a5d265f093d883)
2026-11-09 06:56:12 -08:00
Anees Iqbal 785edff162 alpha_in_red: an A8 edge texel's resolve may round its tie a code from R8Unorm's where the device rounds
a8_resolves_as_r8_unorm held A8Unorm's 4-sample resolve equal to R8Unorm's at every texel. On the
RX 550 (RADV POLARIS12, its own A8_UNORM) every edge texel, whose samples average 114.5, resolved
to 114 in A8Unorm and 115 in R8Unorm (potluck 11625 and 11635), every other texel the same. Where
the device rounds the average (resolve_kind: device-rounded-resolve, whose bound is one code of
Metal's for an 8-bit unorm channel), Vulkan leaves the tie to it, per format; an edge texel may
then lie a code apart, counted and printed. Elsewhere, and where the device's average is
measured to be Metal's, every texel must match as before.

(cherry picked from commit f76c49e82499e02d85e68cdbce20ebdd6a9ffaf1)
2026-11-09 06:56:12 -08:00
Anees Iqbal 4918ab64cd Re-bless the authored compile census at 77ad0f236e
Its product fingerprint follows development's versions at 77ad0f236e. Blessed on the
M3 (s37-pl.sh censusbless --bless, census-at-dev).

(cherry picked from commit e665b0d75e90bd00f40dbe6e6cd9904101faa755)
2026-11-09 06:27:09 -08:00
Anees Iqbal 77ad0f236e Re-bless the golden tables at 4669a4f991
Translation changed at 4669a4f991 (SEMANTICS_VERSION 2005). Blessed on the M3
(s37-pl.sh bless, dv-golden).

(cherry picked from commit 1114ea01357513a2dc57170c47e7ed4e86f29dd4)
2026-11-09 06:22:43 -08:00
Anees Iqbal 693fd3f96d Indirect-executions lane: an output difference names the words apart
The lane printed both outputs whole, as byte arrays. A 256-byte output takes over 2,500
characters, so a log that cuts its lines lost the words that differ. That happened at both
sightings of a-decoupled-lookback-chain-that-yields-publishes-every-prefix on lavapipe
(m3-max-10932, m3-max-11762): only the first 14 to 17 words were readable, all correct prefixes.
The difference now reads as the outputs' lengths, how many 4-byte little-endian words differ, and
the first six with their index and both runs' values, in about 250 characters.

Verification: clippy and the lane's shard 10 on lavapipe.
(cherry picked from commit c8e231e61a4aa9e100ad252ff3d80fc2667ff28e)
2026-11-09 06:20:50 -08:00
Anees Iqbal 4669a4f991 SEMANTICS_VERSION 2005 for Metal 4.1's block reads and the base-level clamp-to-edge read
nvreds 35692bb372..591b8e1804: air.block_read_{texture,depth}_2d[_array].<T>
(MSL block_read<2,1>/<1,2> and sparse_block_read) expands in canon into the
two reads of its texels through the call's own sampler, level
clamp(lod, 0, levels-1), each status byte bit 0 of its read's status word; a
non-literal block size stays refused (typed). A constexpr clamp-to-edge
read(sampler, coord, offset, lod) now reads level 0 with the coordinate
clamped into it, and 0 at lod >= levels, as the M3 measures; a cube's
clamp-to-edge read is refused (Metal reads 0 past the extent and level 0
inside, not built). Measured on the M3 Max, macOS 27.0.1, metal 32023.922,
-std=metal4.1. Refused inputs translate and nonzero-level edge reads change:
SEMANTICS 2004 -> 2005. golden_hashes, public_fixture_expectations and the
compile census are re-blessed on development after this.

Verified by nvreds: M3 at the commit-2 tree (llvm 21): clippy, golden bless
moving nothing, 559/559 tests matching texture|edge|sparse|status|canon|
air_input|families|api_signatures; the engine test runs nine kernels on every
profile in both scheduling orders over 14 points x 2 texels with spirv-val;
7 authored cases: Metal's outputs equal the model word for word, MoltenVK
matches Metal 7/7 (11827). Here: signatures --check, refusal surface and
METAL-COVERAGE regenerate unchanged.
2026-11-09 06:15:23 -08:00
Anees Iqbal 4cc7e2c2d4 Add the block_read authored cases, qualified on Metal and run on MoltenVK
What: seven authored cases over the owned fixture engine/kernel_block_read (br_2x1,
br_1x2_offset, br_edge, br_edge_1x2, br_half, br_array, br_sparse), each a texture of two
levels (8x4 and 4x2; the array three layers) whose every texel is distinct, and one thread per
row reading the block at a point and level and storing one of its two texels: points inside,
at and past each edge, negative and INT_MIN; levels 0 and 1, past the last (2 and 5) and -1.
Shard 004: the cases, the Metal observations (apple-m3-max-macos27.0.1) and the MoltenVK ones
(apple-m3-max-moltenvk).

Why: the block reads' rule rests on these measurements; the cases keep them executable.

Verified: on the M3 Max (macOS 27.0.1), every case qualified on Metal, and each Metal output
equals, word for word, the rule the previous commit implements (a model of it, 56 to 336
words a case, none differing). The MoltenVK candidate of every case, at the previous commit's
translator, matches Metal's output exactly (7 of 7).

(cherry picked from commit 591b8e180467d425b0f18551a750899eb5a23315)
2026-11-09 06:14:25 -08:00
Anees Iqbal df5f779ab1 Metal 4.1's block reads become the reads of their texels, as the M3 measures them
What: air.block_read_{texture,depth}_2d[_array].<T>(tex, smp, coord, [layer], offset, lod,
access, out, status, size), Metal 4.1's block_read<W, H> and sparse_block_read<W, H>, used to
fall back (an unknown intrinsic). It is now decoded (TexOp::BlockRead, with the roles
BlockTexels, BlockStatus and BlockSize) and canonicalization expands each call
(canon::block_read, after the asynchronous copies, for every stage) into a function of two
reads through the call's own sampler: texel k is air.read_<same>(tex, smp, coord + offset +
d_k, (0, 0), level, access) with d_1 (1, 0) for a 2x1 block or (0, 1) for 1x2, level the lod
as a signed int clamped into the texture's levels (get_num_mip_levels), and a depth read's
depth word 1. Each texel is stored at out + k * size; where status is not null its byte is
bit 0 of that read's status word. A block whose size is not a literal (2, 1) or (1, 2) is
left, and lowering refuses it (typed). A read through an argument sampler or another
constexpr sampler state is refused by the read's own lowering, as before.

Why: measured on the M3 Max (macOS 27.0.1, Apple metal 32023.922, -std=metal4.1), textures of
two levels whose texel (x, y) of level l holds (x, y, l, layer):
- block_read<2, 1>/<1, 2>(coord, offset, lod) (the read sampler): texel k is the plain read
  at coord + offset + d_k of level clamp(int(lod), 0, levels - 1): lod 2 and 5 read level 1,
  lod 0xFFFFFFFF level 0; a texel past that level's extent reads zero; the offset applies.
- through a constexpr clamp_to_edge sampler: level 0 at every lod, each texel clamped into
  level 0 (the clamp-to-edge read's own rule, the previous commit).
- argument samplers: clamp_to_edge, repeat and mirrored_repeat clamp to the edge,
  clamp_to_zero and clamp_to_border read the border colour, a mip filter reads level
  min(lod, levels - 1).
- sparse_block_read of a texture that is not sparse: resident for both texels, in and out of
  bounds. Metal's header loads each status byte with !range [0, 2) and tests texel 0 with
  icmp ne 1 and texel 1 with icmp eq 0, so the byte is 1 where not resident.

Tests: the owned fixture engine/kernel_block_read (nine kernels: float, uint, int and half 2D,
a 2D array, depth, read_write, sparse, a 2x1 and a 1x2 block, an offset, the clamp-to-edge
sampler) and engine_texture_oob's block_reads_read_their_texels_as_reads_do, which runs each
kernel on every profile in both scheduling orders over 14 points (in bounds, past each edge,
negative, i32::MIN, lod 0, 1, 2, 5 and -1) and both texels against the measured rule, then
links and validates every kernel with spirv-val. The harness learns what these reads do beyond
a plain read's (Beyond): a sparse read observes its residency and a read_write texture's read
at a level goes through the slot's level views, so the shader selects Metal's out-of-bounds
texel on every class; a profile without non-uniform storage image indexing refuses the level
views (typed). It binds those views as the binder does and pushes the texture's level count
(PushField::TextureLevels). The air_input golden kernel_block_read.txt is blessed on the M3
with llvm 21.

Ran on the M3 (llvm 21) at this tree: clippy; the golden bless, which moved no golden; and the
metal2vulkan tests matching texture, edge, sparse, status, canon, air_input, families and
api_signatures, 559 of 559 passed.

SEMANTICS: inputs with block reads that used to fall back now translate.
(cherry picked from commit 849f3a2cd5fbb79b52e8e19cfc3e8d821284af63)
2026-11-09 06:14:24 -08:00
Anees Iqbal f480f703d0 Clamp-to-edge reads read the base level, as the M3 measures; a cube's is refused
What: Metal 4.1's read(sampler s, coord, offset, lod) through a constexpr
address::clamp_to_edge sampler of default state (no mip filter) reads the base level
wherever its level is one of the texture's, its coordinate (plus offset) clamped into the
base level's extent; past the last level it is out of bounds (zero, the format's alpha), as
before. The lowering read at the level itself, clamped into that level's extent:
- sampled images: the access level is 0 where lod < levels, else lod itself (so a device
  whose robustness answers the read still answers the level past the last); the clamp's size
  is the base level's;
- a read_write texture's level views: element 0, the level deciding whether it is within;
- a heap element's raw read: the base level, the level deciding whether it is in range.
A cube's read through the sampler is refused (Lowering(Texture)): the M3 does not clamp it.

Why: measured on the M3 Max (macOS 27.0.1, Apple metal 32023.922, -std=metal4.1), textures
of two levels whose texel (x, y) of level l holds (x, y, l, layer|z):
- 2D 8x4: read(edge, (4, 0), 0, lod 1) reads level 0's (4, 0) (the old lowering: level 1's
  (3, 0)), (3, 1) at lod 1 level 0's (3, 1); (1, 0) and (9, 1) at lod 2 read zero.
- 2D array (layer 1), 3D (z 1), and read_write 2D: (9, 1) at lod 1 reads level 0's (7, 1),
  (-2, 5) at lod 1 level 0's (0, 3); lod 2 and lod -1 read zero.
- argument samplers of every address mode with no mip filter: the same level rule.
- cube 4x4, face 2: (9, 1) and (-2, 1) at lod 0 read zero (no clamp); (3, 1) at lod 1 reads
  zero (past level 1's 2x2), (1, 1) at lod 1 reads level 0's (1, 1). That read is not built.

Tests: engine_texture_oob's clamp-to-edge rows at level 1 now expect the base level (2D, 2D
array, 3D); edge_cube moves to a_read_through_a_sampler_other_than_clamp_to_edge_is_refused.
The sparse edge read stays refused: its residency was measured only over a texture that is
not sparse. Ran on the M3 (llvm 21) with the next commit's block reads on top: clippy, and the
metal2vulkan tests matching texture, edge, sparse, status, canon, air_input, families and
api_signatures; every clamp-to-edge test passed (558 of 559; the one failure was the block
reads' own harness, fixed in the next commit).

SEMANTICS: translations of such reads at a nonzero level change, and cube ones now fall back.
(cherry picked from commit 35692bb3723f3af2ae2c7b07e1ec9f295399a360)
2026-11-09 06:14:24 -08:00
Anees Iqbal 462934908e RUNTIME_VERSION 1974, the runtime-sources pin and the API table for recovery 1b
exitcrash 1571c220d7..4b9b7ed8b0 (11 commits): a device recovery carries the
program's no-copy buffers (made again on the new VkDevice over the same pages,
same contents pointer, Metal address and bytes: pointer imports, buffers in
another's import, gate-refused copies, runs of guest RAM) and its uses of
guest RAM (HostRamUse, carried before the buffers). The caller's deallocator
still runs once, after every generation's import of the pages is freed; a
detached no-copy buffer stays on the lost generation (MadeBeforeRecovery).
Runtime behaviour changed: RUNTIME_VERSION 1973 -> 1974, pin recomputed,
docs/REFUSALS.md regenerated (two refusal sites renamed: ram_use_on,
buffer_over_host_parts).

API table: HostRamUse is now a tuple struct over a private Arc<RamUseCell>
and its own impl Drop is gone (the cell's use drops it). Nothing breaks for a
consumer: dropping a HostRamUse still lets go of the RAM at once (the
recovery's carry holds only a Weak, upgraded for the carry itself), and
nothing could call the Drop impl directly.

Verified by exitcrash: lavapipe 11782 at a5f0c3be37 runtime suite 1999/2000
(the one red a test bug, fixed), clippy plain/cpuicd/gpucfg, rustdoc, refusal
check; lavapipe 11814 recovery/no-copy/event 30/30 with negative controls A
(deallocator not handed on) and B (lost parts never let go) failing as
designed; rebased tip 4b9b7ed8b0: Iris 11823 51/51 and 780M (RADV PHOENIX)
11824 51/51 over recovery, no-copy, host_ram_device, event_timeline,
detach_lost, the new tests run on both. Not run at the tip: lavapipe whole
suite, clippy, the 5080 (development's checks).
2026-11-09 06:02:36 -08:00
Anees Iqbal 03e5b08410 Guest-RAM carry test reads the counts through the serving generation
`device.work_counts_now()` on the program's root handle reached the generation's state through
the root, which pins that generation for the root's life (`Device::shared_arc`). The lost
VkDevice then stayed live past its rest (m3-max-11782: 2 against 1 at the live check).
`Device::work_counts` asks the serving generation and lets it go.

Verification: to run on lavapipe with the recovery tests.
(cherry picked from commit 4b9b7ed8b03ae82fa9fcb81a422e469480d12958)
2026-11-09 06:01:14 -08:00
Anees Iqbal 435a52906c No-copy carry tests read the host importer through a generation handle they let go of
The tests asked `device.shared().host_import` on the program's root handle. A root handle's own
reach of a generation's state pins that generation for the root's life (`Device::shared_arc`),
so the lost VkDevice stayed live past the recovery whatever the carry did. The probe run
(m3-max-11758) showed it: a device with no buffer at all kept two VkDevices live after a
recovery, as every carried kind did. `import_page` reads the importer through the serving
generation's handle (`Device::current`) and drops it at once.

Verification: to run on lavapipe with the recovery tests.
(cherry picked from commit 2c0747382c43eeb50d85e721d08ecf77d44fc710)
2026-11-09 06:01:14 -08:00
Anees Iqbal 086e684cb8 A buffer that lies in another's import keeps what it was made of on its own pages
Each buffer over a live import has pages of its own (`HostCell` over `HostPages`), so the
shared-import path has to give its pages the parts too. After a5222925b2 it gave them nothing,
and the recovery left such a buffer on the lost generation as a detached no-copy buffer: the
probe run (m3-max-11758) reported "2 buffers with their contents" for the pointer import, its
alias and the gate-refused copy. The parts are kept at the path's existing look at the pages,
so the making still looks once.

Verification: to run on lavapipe with the recovery tests.
(cherry picked from commit e22110a9a63f2f61f0a2a1ba90fb0d6ea7cf7f15)
2026-11-09 06:01:13 -08:00
Anees Iqbal 56382cbd95 A buffer's pages keep what they were made of from the making's one look at them
buffer_over_host_parts looked at where the new buffer lies a second time to give its pages
what they were made of (`HostPages::made_of`), so making a no-copy buffer looked twice
(`tests::no_copy_lies` read 2 against 1). What it was made of is now given to the pages with
their log, runs and copy name from the one look (`keep_in`, `kept`), and the wrapper folds
into the function it wrapped. A buffer that lies in another's import leaves its pages the first
buffer's parts, over the same bytes.

The guest-RAM carry test compared the device's bound-buffer counts, which are kept across its
generations, against 1 after the recovery: it now compares the recovery's own, from before it.

Verification: to run on lavapipe (the recovery tests and the runtime's whole suite).
(cherry picked from commit 0f89fe34b5e7f0116fe35b4593ab2fb344c4bb74)
2026-11-09 06:01:13 -08:00
Anees Iqbal 24546230e0 Carry test: a second recovery carries the no-copy buffers on, the deallocator still waiting
The deallocator now waits for one import more (the HeldBack's count). The
test checks that the buffers serve after a second recovery, that the gate is
asked a third time, that one VkDevice is left live, and that the deallocator
still runs once, at the release.

(cherry picked from commit e1cf7674275590802c352c7cbcc32459ddacdb21)
2026-11-09 06:01:13 -08:00
Anees Iqbal 0fa576badc A carried use of guest RAM is kept for the next generation's recovery in turn
RamUseCell::carry registers the cell with the new generation's carry
registry, so a later recovery carries it again. Where that registry was taken
already (a late carry after a further loss), the use is carried on at once,
as a late maker carries what it makes.

Verification: the lavapipe runs of the carry tests.
(cherry picked from commit 3868551689cc78de74431a7b5e86da65c4a2441f)
2026-11-09 06:01:13 -08:00
Anees Iqbal 15923d88c0 Docs: a recovery carries no-copy buffers and uses of guest RAM
The DeviceRecovered cost text (and docs/API.md's catalogue entry, which states
it), the runtime README's recovery section, new_buffer_with_bytes_no_copy, and
the contracts of the import gate, the run resolver and the dma-buf source now
say the following. A recovery carries a device's uses of guest RAM and its
no-copy buffers. Each buffer is made again over the same pages. The caller's
callbacks are asked again on the thread that recovers, before the new device
serves, so they must make no call on the device. The deallocator runs at the
buffer's release once no VkDevice's import of its pages is left (the
keep-alive's contract says the same). Detached no-copy buffers and a no-copy
heap's buffers stay refused. HostRamUse's doc says the use goes on.

(cherry picked from commit 58ba0931b857a9dcf9a6124138c81fc31a259552)
2026-11-09 06:01:13 -08:00
Anees Iqbal 6c4ac9f3b4 Carry tests: no-copy buffers and a use of guest RAM across a recovery
device_recovery_no_copy:
- a_recovery_carries_no_copy_buffers_over_the_same_pages: a buffer imported
  by its pointer, with a deallocator; a second over the same bytes; and one
  whose import the caller's gate refuses (a copy). After the recovery each
  serves on the new generation with its contents pointer, Metal address,
  backing and bytes as before, and the gate is asked again. The host's writes
  reach the GPU and the GPU's reach the pages. The lost VkDevice goes at rest.
  The deallocator runs once, with the buffer's range, at its release and not
  before.
- a_recovery_carries_a_use_of_guest_ram_and_the_buffers_over_it: a RAM use
  and a buffer over one run of the RAM. The notice counts the use. The
  resolver is asked again. The buffer lies in the RAM on the new generation
  (bound in its chunk, or in an import of its run alone). Bytes go both ways.
  The lost VkDevice goes at rest, and the RAM's keep-alive goes once the
  program lets go.

Verification: the lavapipe run that follows.
(cherry picked from commit d591429b244d81f0d0249f7f98f01fac3ad8ae6e)
2026-11-09 06:01:13 -08:00
Anees Iqbal 446f9ebc8d Recovery carries no-copy buffers, made again over the same pages
A recovery now makes a no-copy buffer again on the new generation, over the
caller's pages it lies in, from the memory they were given as
(HostPages::made_of). It goes through the same making as before: an import of
the pointer or of the source's dma-bufs, a run of a guest RAM the new device
uses (carried just before), a copy, or a read-only view. The caller's gate and
resolver are asked again there. The made buffer keeps the buffer's ObjectId,
identity, label and purgeable state, its Metal address (a share of its range)
and its range token. Its contents pointer and bytes are as they were.

Release order: the deallocator and keep-alive move to a HeldBack
(Release::carry_on). It now counts the imports of the pages still mapped (the
lost generation's, then each later one's) rather than a single flag. The
pages made on the new generation carry a release that tells the HeldBack the
buffer's release came and that their own import went
(Release::carried, HeldBack::released). So the deallocator runs at the
buffer's release, or at its next rebind, once no generation's import maps the
pages, or at once where a keep-alive keeps them mapped. A detach of the
carried buffer holds back the same wait, as a detach holds back a
deallocator.

At the lost generation's rest, the buffer's parts there go (LostHost). It
leaves that generation's live buffers and its registries of no-copy buffers.
Its cell's pages go (Lying::Gone, which nothing reads from then on). The cell
and the buffer let go of their handles of the generation (HostCell::device is
now a MadeOn). A call under way that holds the parts defers this, as for any
carried buffer, and a handed-out VkBuffer keeps them until the buffer goes.

Left the lost generation's: a detached no-copy buffer, one whose last detach's
deallocator still waits for its next rebind, a no-copy heap's buffers, and any
buffer whose making on the new device fails.

Verification: none yet. Tests follow.
(cherry picked from commit 3a7ea4834d47fac623ef36a325a265b6d4a11e5b)
2026-11-09 06:01:13 -08:00
Anees Iqbal e35a85e725 No-copy buffers keep what their pages were made of, and a making names who it makes
No change in behaviour; the plumbing a no-copy buffer's carry rests on.

- HostParts is clonable. A no-copy buffer's pages (not a heap's own) keep the
  parts of the caller's memory they were made of (HostPages::made_of), at
  making and at each rebind: what a recovery makes the buffer again of on the
  next generation.
- buffer_over_host_memory resolves its release and hands over to
  buffer_over_host_parts, which a carry calls with the parts kept.
- Naming says who a making makes: a new buffer, or a buffer a recovery carries,
  whose ObjectId, identity and attributes it keeps. It goes through
  BufferParts, buffer_in_import, copied_buffer and buffer_lying. Every other
  making names a new buffer.

Verification: none yet. Builds and tests come with the carry that uses it.
(cherry picked from commit 0417e783cc14a6bed17a54fac07df00075a48862)
2026-11-09 06:01:13 -08:00
Anees Iqbal 4ed1565b3a Recovery carries the program's uses of guest RAM
A HostRamUse is now a handle to a cell holding its use on the generation it
was carried to last. The carry registry keeps the uses weakly, as it keeps
events. A recovery carries them before the buffers, so that a no-copy buffer
over a RAM's pages can lie in its chunks on the new generation. The carry
makes the use again on the new device. The lost generation's use is then
let go of as a drop lets it go: its thread ends, and each chunk there is freed
once nothing holds it. A use made after the recovery took the generation's
objects is carried by its maker. The recovery's notice counts the uses carried
and those the new device refused, where any lived.

Verification: none yet. The no-copy carry that rests on this, and its tests,
come next.

(cherry picked from commit af1a320643ea370ce0d16edb87527f44e04c5e25)
2026-11-09 06:01:12 -08:00
Anees Iqbal 1571c220d7 Host-RAM ordering tests keep their run-bound buffer in its run's import
a_run_bound_buffer_and_a_copy_of_its_pages_order_by_their_host_bytes failed on lavapipe in
development's suite at 612f5dcfba: (1,0,0,0) against (1,0,0,1), the run's import no longer live.
The device releases a buffer's import of its run once it has been idle for 2 s
(host_residency.rs, IDLE) and binds the buffer in its chunk at its next use. The test waits for
the device's thread to import the chunks ahead (`settled`). Under the whole suite's load that
wait can outlast the 2 s, so the run's import was gone when the test counted it. The test was
then left with one import of the pages instead of the two whose ordering it checks.

Both ordering tests over a run-bound buffer now hand out its Metal address as soon as it is made
(`kept_in_its_run`). That keeps its import for good, as Buffer::gpu_address documents, so the
two imports the tests order stay under any load. The product's behaviour is unchanged.

Verification: under induced CPU load on lavapipe, against development without it (see the
flake report).

(cherry picked from commit 3462a26e6c39fd600ccdee70ad86438aeb24fe5b)
2026-11-09 05:58:17 -08:00
Anees Iqbal 0c17e50fad SEMANTICS_VERSION 2004 for an explicit imageblock's cell that holds the widest access
nvreds a1ab4018d8: an explicit (not aliased) imageblock's cell is the larger
of air.imageblock_data_size and the widest bounded access through a cell
pointer (load, store, atomic, slice write), rounded to the alignment; a
{half v} cell storing a half2 and writing a v2f16 slice plans 4 bytes and
translates, where it was Imageblocks NotImplemented. Metal on the M3 runs that
kernel and writes each pixel its own (x, y) (512 bytes of imageblock memory
for 8x8, 8 a pixel). Refused inputs now translate: SEMANTICS 2003 -> 2004.
golden_hashes and public_fixture_expectations_engine re-blessed on
development after this.

Verified by nvreds: M3 11797 at the same tree minus the golden on 97fd8d0fe8:
clippy, 296/296 tests matching imageblock|slice|provenance|memory|air_input|
tile, golden bless moved no other golden; the new engine test requires
cell_bytes 4 for both kernels and each pixel its own (x, y) on every
committed profile. Here: signatures --check, refusal surface and
METAL-COVERAGE regenerate unchanged.
2026-11-09 05:58:17 -08:00
Anees Iqbal f95c6e6f33 An explicit imageblock's cell holds the widest access through its pointer
What: a kernel's explicit imageblock spaced its cells air.imageblock_data_size apart (rounded
up to its alignment). A cell pointer can reach past that size: a {half v} layout (data size 2,
align 2) whose threads store a half2 through air.imageblock_data(tid) and write a v2f16 slice
(air.write_imageblock_slice_to_texture_2d.i16.v2f16) from the cell's start. The slice check
needs field + bytes <= cell_bytes, so the kernel was refused (Imageblocks, NotImplemented),
while its {half2 v} twin translated. The planner now sizes the cell to the larger of the data
size and the widest access through a cell pointer (Planner::imageblock_reach: the highest end
of a load, store, atomic, or slice write at a bounded, non-negative offset from a cell's
start), then rounds it to the alignment as before. Provenance records a slice write's reach,
one element of the type its name spells (4 bytes for v2f16), where it recorded none. An
access the analysis does not bound adds nothing, and lowering still checks each access
against the cell and refuses what it does not hold. An implicit imageblock aliased by an
explicit layout keeps the layout's cell.

Why: Metal on the M3 runs both kernels and writes each pixel its own (tid.x, tid.y);
imageblockMemoryLengthForDimensions(8x8) is 512 for both, 8 bytes a pixel, so Metal pads the
cell (the orchestrator's replica). The runtime's answer for a 4-byte cell is the same 512
(imageblock_memory_length rounds a cell to 8).

Tests: the owned fixture engine/kernel_imageblock_wide_access (ib_half_cell and its
ib_half2_cell twin) and engine_imageblock's a_cell_holds_the_widest_access_through_its_pointer:
both kernels plan RuntimeFact::ImageblockSize { cell_bytes: 4 } and, on every committed
profile, thread (0, 0)'s slice writes each pixel of the 8x8 block its own (x, y). The
air_input golden kernel_imageblock_wide_access.txt is blessed on the M3 with llvm 21.
Ran on the M3 (llvm 21): clippy, the golden bless (no other golden moved), and the
metal2vulkan tests matching imageblock, slice, provenance, memory, air_input and tile: 296
of 296 passed.

SEMANTICS: kernels whose cell pointer reaches past the data size used to fall back and now
translate.

(cherry picked from commit a1ab4018d83acb0386144a3afd2c6ef08b56688a)
2026-11-09 05:57:41 -08:00
Anees Iqbal ab3f53c6a3 Re-bless the authored compile census at 97fd8d0fe8
Its product fingerprint follows development's versions at 97fd8d0fe8. Blessed on the
M3 (s37-pl.sh censusbless --bless, dv-m3).

(cherry picked from commit 699273afe59610e1f8fd0d0c1b760e22725400ad)
2026-11-09 05:53:38 -08:00
Anees Iqbal 042c282889 dma_buf_imports: a view past one udmabuf on ANV is the device's refused-pointer copy
What: a_reversed_view_of_single_pages_takes_the_route_its_device_answers expects, on ANV, a
copy of the 1025-page view mapped through udmabufs (ViewRoute::Copied, which replaces
Refused): the source asked once for one dma-buf of the whole view and answering none, the
buffer made with HostBacking::Copied, counted as one copied host buffer and one copy for the
device's refusal (WorkCounts::copied_host_buffers_device_refused), and the GPU reading the
CPU's bytes. The other routes are unchanged: RADV's two dma-bufs past its list_limit (the
source answers, so no copy), ANV's pointer import from the file and its one dma-buf where one
udmabuf holds the view, lavapipe's pointer.

Why: f36d32dfd3 made no-copy memory whose pointer the device refuses and whose source fails a
copy, the device's refusal, as with no source (rule 2: Metal makes the buffer, and the pages
are readable). ANV refuses a udmabuf mapping's pointer and assembles no buffer of several
dma-bufs, so past list_limit its source fails, and the buffer is now that copy; the test still
asserted the old refusal (Iris, 11718 at 612f5dcfba: made.err() = None at the
is_err_and(not_importable) assert). The expectation is the product's documented route for a
refused pointer with a failing source, not a driver case of its own: any device that refuses
the pointer and whose source cannot answer takes it.

Verified (Iris Xe, ms01; Mesa 26.2.6, kernel 7.3.1-1-cachyos, udmabuf list_limit 1024; the
test alone with --no-capture, 11766, at a tree identical to this commit's):
- 1025 single pages through udmabufs (2 mappings): made; source calls [(granule 4198400 =
  the view's length, 0 chunks answered)]; dma-buf imports, sparse buffers, pointer imports
  and copies (0, 0, 0, 1). The test passes.
- 64 pages through one udmabuf: one dma-buf import (1, 0, 0, 0); 64 and 1025 pages from the
  file: the pointer imported (0, 0, 1, 0).
- The host matches the 11-08 measurement (list_limit 1024, Mesa 26.2.6): the change is the
  product's route, not the host.

(cherry picked from commit 801cab749e73351e73471bd6e6b07eecee0883d7)
2026-11-09 05:46:27 -08:00
Anees Iqbal 97fd8d0fe8 RUNTIME_VERSION 1973 and the runtime-sources pin for a lost generation's rest that waits each queue under its lock
exitcrash b557220835: keep_nothing (a lost generation coming to rest) called
vkDeviceWaitIdle, which needs every VkQueue externally synchronized (vkspec
7.8), while the generation's m2v-submit-check thread could be in
vkQueueSubmit under its queue's lock. DeviceShared::queues_idle now waits
each queue idle under its QueueSlot lock; keep_nothing and drain_queues use
it. Runtime behaviour changed: RUNTIME_VERSION 1972 -> 1973, pin recomputed.

Verified by exitcrash (m3-max-11745, ms01 Iris Xe, runtime_lane::
device_recovery under the validation layer, 5 runs each): base 19276dd2a5
fails all 5 (1-4 tests a run, THREADING ERROR both directions); tip 5/5
green, 6/6 tests, 0 THREADING lines. lavapipe and the runtime suite run in
development's post-merge checks.
2026-11-09 05:32:17 -08:00
Anees Iqbal 62861b32e9 A lost generation's rest waits its queues idle each under its lock, not the device at once
keep_nothing (a lost generation at rest) called vkDeviceWaitIdle. That call
needs every VkQueue of the device externally synchronized (vkspec 7.8). The
generation's submission-check thread can still be submitting on one of its
queues under that queue's lock. Iris under the validation layer reported it
(UNASSIGNED-Threading-MultipleThreads-Write): the m2v-submit-check thread's
vkQueueSubmit raced a handler thread's (or the test thread's) vkDeviceWaitIdle,
in four of the validation lane's device_recovery tests (development's job
m3-max-11718 at 612f5dcfba).

The rest now waits each queue idle under its lock, as every use of a queue is
made. DeviceShared::queues_idle is the loop the recovery's drain already ran,
and drain_queues now calls it. No queue wait holds a lock that a signal the host
has yet to make waits behind (drain_queues' contract), so neither can block
the other.

Verification: the Iris lane run under the layer, against development as the
negative control, follows.

(cherry picked from commit b5572208356db948b35aed4f1f52146eae08c57c)
2026-11-09 05:31:41 -08:00
Anees Iqbal 3f2dd3a702 Re-bless the golden tables at fe45983658
Translation changed at fe45983658 (SEMANTICS_VERSION 2003). Blessed on the M3
(s37-pl.sh bless, dv-golden).

(cherry picked from commit 4a2517f975ce787fde0bc61b8811c4e0a82d4238)
2026-11-09 05:27:25 -08:00
Anees Iqbal fe45983658 SEMANTICS_VERSION 2003 for MSL's integer median3
nvreds 20ceaa1206..b186b771e1: air.median3.<s|u> (i8-i64, scalars and
vectors) is a row of the integer table, lowered as
max(min(a,b), min(max(a,b),c)), two-word compare-and-select without
shaderInt64. Inputs that were refused (UnknownIntrinsic) now translate, so
SEMANTICS 2002 -> 2003. golden_hashes and public_fixture_expectations_engine
gain the new fixture: re-blessed on development after this.

Verified by nvreds: gem10 11743 clippy -D warnings (metal2vulkan,
metal2vulkan-air, all targets/features) and the 5 median3 tests; M3 11739
engine answers on moltenvk-m3 (int64 and two-word paths); authored case
integer-median3-words qualified on Metal (M3 Max, macOS 27.0.1, metal
32023.922; 2048 words equal an independent model) and the MoltenVK candidate
matches (sha256 53621a0c...). Here: signatures --check, refusal surface,
METAL-COVERAGE regenerate unchanged.
2026-11-09 05:24:33 -08:00
Anees Iqbal e028da502b Add the integer-median3 authored case, qualified on Metal
What: one loop-free authored case, `integer-median3-words`, over
`median3_ops` of the owned fixture `engine/kernel_integer_median3`
(b7ae380659 adds the fixture; this commit needs it), its Metal row and
its MoltenVK candidate row. 64 threads in two threadgroups of 32; each
thread reads three 64-bit words and writes 32 words: every air.median3
form Metal's compiler emits from MSL's integer median3 (s and u of i8,
i16, i32 and i64, s.v4i8, u.v2i16, s.v4i32, u.v4i32, s.v2i64 and
u.v2i64). The triples are the six orders of each width's minimum,
maximum and all-ones word, ties of two and of three, 0/1/all-ones mixes,
and splitmix64 words for the rest.

Why: the Metal evidence for the median3 lowering of 88600b4e9c.

Verified (M3 Max, macOS 27.0.1, Xcode 27B52, Metal 32023.922):
- The case qualifies on Metal (apple-m3-max-macos27.0.1). Metal's 2048
  output words equal an independent Python model (sort the three
  operands of each width and sign, take the middle one): 0 mismatches.
- The MoltenVK candidate (apple-m3-max-moltenvk, moltenvk-m3, MoltenVK
  1.4.2, the product at b7ae380659) is a Match on the stated leg, output
  sha256 53621a0c5f779cb2bee4a05f21a346e394cd9e72bc943d9f7fa4530022f13027
  on both sides.
- The two-word path (no shaderInt64) is checked against the same rule by
  the engine test `the_integer_median3_fixture_answers_the_middle_one`
  on the M3, and by the wide lowering's unit tests.

(cherry picked from commit b186b771e1f254fd02355cffd377849ed287e640)
2026-11-09 05:23:42 -08:00
Anees Iqbal 3d5c862851 The integer median3 fixture's air_input printout, under the pinned LLVM 21
Blessed with tests::air_input::bless_engine_goldens and Homebrew's
llvm@21 llvm-as (21.1.8); no other printout moved. Every air.median3 call
prints as Math { f: IMedian3(Signed|Unsigned), .. } at its type.

(cherry picked from commit d99de31196e6855afdcd065433e1dc85315d475d)
2026-11-09 05:23:42 -08:00
Anees Iqbal ad20f10f09 An owned fixture of MSL's integer median3, run on the interpreter
What: engine/kernel_integer_median3 (MSL written for this project; .ll and
.air.ll from scripts/regen-air-fixtures, Metal 32023.922, SDK 27.2) holds
every air.median3 form Metal's compiler emits from MSL's integer median3:
s and u of i8, i16, i32 and i64, s.v4i8, u.v2i16, s and u of v4i32 and of
v2i64. Its kernel median3_ops reads three 64-bit words per thread and
writes 32 words: each scalar type's median of the words cast to it, then
the vectors' lanes, each over other operands (the words' bytes, halves and
complements), so a lane that took another's answer shows.

tests::engine_integer_median3:
- the fixture translates, links and passes spirv-val on every committed
  profile in both spellings, with no precision note;
- on the interpreter, 64 threads' 32 words equal the middle one of the
  three operands (sorted as signed or unsigned values) on moltenvk-m3 with
  shaderInt64 and without it (two 32-bit words), in both spellings. The
  words: for each width, the six orders of (INT_MIN, INT_MAX, all ones),
  four ties, all three alike; zeros, all ones, 0/1 mixes; and 20 threads
  of splitmix64 words. The authored cases use the same words.

(cherry picked from commit b832b50364db33a107348c856cebe1369c98ed6d)
2026-11-09 05:23:42 -08:00
Anees Iqbal 3afd2a3b1e Translate MSL's integer median3: air.median3.<s|u> joins the integer table
What: `air.median3.<s|u>.<type>` decodes as `MathFn::IMedian3(Sign)`, a
sign-sensitive integer row beside min3 and max3, so it takes every type the
integer rows take (i8 to i64, scalars and vectors). It lowers to
`IntFn::Median3`: max(min(a, b), min(max(a, b), c)) on the operands as their
signed or unsigned values. In a container it is four of the GLSL integer
min and max; on wide values without shaderInt64 (two 32-bit words) three
pair compares and their selects. Every answer is exact, so no precision note.

Why: Apple's metal 32023.922 compiles MSL's integer median3 to
air.median3.s.i32, .u.i32, .s.i16 and .s.v4i32, and the translator refused
every one as UnknownIntrinsic (a one-line kernel fell back).

Tests:
- metal2vulkan-air: the table test decodes the row at every integer type
  and sign; the four names Apple's compiler emits decode explicitly.
- int_ref gains median3 (the middle of the three sorted values), and it
  joins the integer-function sweep (8 to 64 bits, both signs) and the wide
  sweeps (values and word bounds).
- integer_median3_answers_the_middle_one_at_ties_and_extremes and its wide
  twin: every ordered triple of a width's edges (0, 1, all ones, all ones
  - 1, INT_MIN, INT_MAX, INT_MIN + 1), so every order, every tie, all three
  alike and the extremes beside each other, at 8, 16, 32 and 64 bits (wide:
  64 and 40), signed and unsigned, scalar and 4 lanes.

api_signatures gains the IMedian3 variant.

(cherry picked from commit 20ceaa12063c83683d71336f8a998322089f6c4d)
2026-11-09 05:23:42 -08:00
Anees Iqbal 19276dd2a5 Half reads: a zero of either sign, or 2^-14, as NativeHalfQuantize's bound says; the conversion note's flush too
The RX 550 run of e5553fa2a0 (potluck 11647) found two answers the first change held too tightly:

- tile_normalized: RG16Snorm's code 0xffff (-1/32767, -3.05e-5) read as +0. NativeHalfQuantize's
  recorded bound is a zero of either sign for a value below 2^-14, or 2^-14 from just below it
  (NIR's fquantize2f16 flushes every one); flushed() now takes exactly that.
- ycbcr: read_half's stage on the RX 550 does not quantize: it narrows by the device's conversion,
  recording NativeHalfConversion, whose bound lets a half denormal read as a zero on a device that
  may flush 16-bit denormals (no DenormPreserve for 16 bits, as there). Kernels::flushing now holds
  the half kernels recording either note, and prints each half kernel's notes (HALF-KERNEL).

(cherry picked from commit 6c80165070a97febfb95f5ec0a4fedf63204fb58)
2026-11-09 05:12:12 -08:00
Anees Iqbal 8c19e8bf97 ycbcr_textures: Kernels::quantizes asks the list with contains, as clippy's manual_contains asks
(cherry picked from commit ec5bbee96a13ac7496f1088bb6fc9b3885c11008)
2026-11-09 05:12:12 -08:00
Anees Iqbal 8fc9e3dd68 Half reads through the device's quantize may read a value below 2^-14 as the zero of its sign
On a device without shaderFloat16 (the RX 550, RADV POLARIS12: shaderFloat16 and the 16-bit float
controls all false) a half is rounded by the device's OpQuantizeToF16, whose result below the
smallest normal half Vulkan leaves to the device as that value or the zero of its sign; every such
stage records PrecisionNote::NativeHalfQuantize (lower::arith::narrow::quantizes) and its making
announces native-half-quantize. RADV gives the zero, and four lane checks held Metal's denormal:

- tile_normalized's reads through halves (RG16Unorm code 1, 1.5258789e-5, read 0);
- ycbcr_device_reads' half read() and nearest half sample of a device-converted texture
  (-5.4e-5 and an sRGB twin's 4.86e-4, read 0), through its two callers' tests;
- ycbcr_textures' half gathers of a device-converted texture (-1.09e-5, read -0).

Each now asks the stage's notes (made_tile_kinds, stage_notes) and, where it records
NativeHalfQuantize, takes a zero of the right sign for a value whose device float may lie below
2^-14; anything else stays a failure, and tile_normalized prints how many channels read such a
zero. Where the stage records no such note the checks are as before.

(cherry picked from commit 758edd19354d1d1982c63c960648c87343018824)
2026-11-09 05:12:12 -08:00
Anees Iqbal 7324384287 dma-buf lane: a heap texture is an image only where the device lists the modifier extensions
What: the lane expected every heap texture over dma-buf pages to be an image
over a dma-buf of its own pages wherever the device imports dma-bufs (keyed on
RADV). The runtime makes that image only where the device enables
VK_EXT_image_drm_format_modifier and VK_EXT_queue_family_foreign beside its
imports; elsewhere the texture is a shadow of the heap's bytes, counted as a
fallback and announced as shadowed-texture naming the two. The lane now reads
which route to expect from the device's own extension list
(`makes_dma_buf_images`, which prints what is missing):
- the no-copy heap texture: an image, or one fallback with the source not
  asked for the texture; the heap's pages are compared only for the image;
- the source-fails fallback: the source is asked twice for an image route,
  once for a shadow, and the notice names the failed dma-buf or the missing
  extensions;
- the rebind: an image made again where the device makes them, the new
  source asked once more for it; the new pages compared only for an image;
- the source-runs-unlocked heap texture: an image or a fallback.

Why: on the RX 550 (RADV, POLARIS12) these four tests failed. A probe
printed the shadow's notice: "the device enables no
VK_EXT_image_drm_format_modifier and VK_EXT_queue_family_foreign beside its
dma-buf imports: its image is a shadow of the heap's bytes". That is the
runtime's documented route for such a device, so the expectation was wrong,
not the product.

(cherry picked from commit 7aecc7e810ac6fb75d2904f9c4c43ee560e1c58e)
2026-11-09 05:12:12 -08:00
Anees Iqbal c8a41e013d Fetch gate: the alpha_in_red color inputs, color_groups' fetch scene and four extended-range blends
The RX 550 run of development (potluck 11625) found seven more tests unwrapping the typed
FramebufferFetch refusal: alpha_in_red's two A8 color-input tests, the device-width color_groups
scenes (whose fetch scene and cg_fetch pipeline need a fetch form) and four extended_range_blends
tests (a blend into an extended-range color holds its shadow in the pixel interlock). Each opens
with framebuffer_fetch::fetches; color_groups skips only its fetch scene and requires cg_fetch's
refusal to be FramebufferFetch where the device has no form.

(cherry picked from commit a63850737a463164609dc0ba99c53cf21d7156e0)
2026-11-09 05:08:51 -08:00
Anees Iqbal 64815698b5 Fetch gate: every framebuffer_fetch submodule that opens with the gate imports it
The gate's calls landed in twelve submodules without their import; the um790 build of 43b7948cc0
(potluck 11622) failed on them (E0425).

(cherry picked from commit 2d545658fcb41408e73c8cc896098b6cbd667b72)
2026-11-09 05:08:51 -08:00
Anees Iqbal 268df0f603 Fetch, imageblock and stencil-output lane tests skip a device with no form, after its typed refusal
On the RX 550 (RADV POLARIS12, GCN4) neither rasterization-order colour attachment access nor the
fragment shader pixel interlock is there, so every fetching, imageblock and shader-side-stencil
pipeline is refused as Unsupported, the device's honest answer; the lane tests unwrapped those
refusals and failed (sweep's survey: 56 framebuffer_fetch-family tests and 3 fragment_imageblocks).

One test-level gate per capability, which every such test opens with:

- framebuffer_fetch::fetches(device) replaces blend16's per-draw fetch_unavailable skip;
- fragment_imageblocks' Fixture::imageblocks;
- shader_stencil's Lane::outputs_stencil, per run (as opened, and with
  VK_EXT_shader_stencil_export withheld).

Where the profile has the form (input attachments or the interlock for fetch; the interlock and
fragment stores for imageblocks; the extension or the interlock for the stencil output) the gate
makes nothing, so a test's count of makings stays its own (assert_made_once). Otherwise it makes
one state of the capability, requires Unsupported of that feature, prints a FETCH-SKIP,
IMAGEBLOCKS-SKIP or STENCIL-SKIP line naming the refusal and the device, and the test returns.
Any other answer there fails the test. Shared helpers gate once (blend8's srgb_blends, the
cases_at of returned_stencil, shader_depth and stencil_stand_in, storage_forms' beside, now an
Option).

(cherry picked from commit 43b7948cc0255728e921cfd8aa96770a6fe735e5)
2026-11-09 05:08:51 -08:00
Anees Iqbal 612f5dcfba SEMANTICS_VERSION 2002 for a front_facing argument held in an integer
nvreds 0950743006: an older front end's i8 [[front_facing]] argument
(i8 + trunc to i1, seen in an iOS-simulator library from metalfe-32023.884)
now translates: the Bool builtin is OpSelect'ed to 1/0 in the argument's
integer form. Inputs that were refused now translate, so SEMANTICS 2001 ->
2002. Golden hashes expected unchanged (no committed fixture has an integer
front_facing; not checked here).

Verified by nvreds on gem10 (debug): clippy -D warnings for metal2vulkan and
metal2vulkan-air, all targets/features; 100/100 tests over front_facing,
stage_io, engine_fragment, air_abi, engine_line_band (11689); negative control
4dd15ecbd1 fails the new engine_front_facing_byte test with the reported
refusal (11690). Here: signatures --check and refusal surface unchanged.
2026-11-09 05:05:54 -08:00
Anees Iqbal 7c6e9d1fcf Read an i8 [[front_facing]] argument as the face, 1 or 0
What: a fragment argument whose `air.front_facing` metadata names the
builtin and whose type is an integer scalar (an older front end's ABI:
metalfe-32023.884 at air64-apple-ios13.0.0-simulator passes
`bool [[front_facing]]` as `i8`, read through `trunc i8 %0 to i1`) now reads
the FrontFacing builtin and holds it as 1 or 0 in the argument's integer
form (a select of the loaded bool). Before, `input_builtin` took the
argument only as a `bool`, so the i8 form was refused
`NotImplemented(StageIo)` at the argument's metadata. The decision is the
argument's type with the builtin's metadata; no name is read. The
`i1 zeroext` form is unchanged.

Test: tests::engine_front_facing_byte, a module written here (today's
compiler emits no such shape and regen-air-fixtures cannot make one) with
`ff_bool` (i1 zeroext) and `ff_byte` (i8 + trunc) side by side: both
translate, link and pass spirv-val on every committed profile with no
precision note; ff_byte's module selects 1 or 0 on the FrontFacing load,
ff_bool's selects nothing on it. Without the fix ff_byte is refused.

(cherry picked from commit 0950743006c6011c5c136f80f4b48d2d0a43b392)
2026-11-09 05:04:59 -08:00
Anees Iqbal fc668f8ec6 RUNTIME_VERSION 1972 and the runtime-sources pin for carried buffers' calls that hold the lost generation's parts
The race fix (exitcrash 8910b47c56..5ccc385768): a Buffer call outside command
buffers' work (textures over its bytes, exports, did_modify_range,
set_purgeable_state, vk_buffer/vk_host_memory) holds the parts it read, and
the lost generation's release at rest waits for the last hold. Runtime
behaviour changed, so RUNTIME_VERSION 1971 -> 1972 and the pin is recomputed.

Verified by exitcrash: lavapipe 11680 at 5ccc385768 runtime recovery 27/27
(new test included), lane recovery 6/6, clippy plain/cpuicd/gpucfg, rustdoc,
refusal check; negative control 5c523b175c fails the new test at
!first_parts_freed; Iris 11673 26/26, 7 recoveries end at 1 live VkDevice.
Here: signatures --check, refusal surface and coverage regenerate unchanged.
2026-11-09 05:04:58 -08:00
Anees Iqbal 3e81231551 Carried buffers' held parts: clippy clean
LostBuffer::release_now takes the parts by value (clippy's boxed_local), and
the device tests' helpers (Buffer::first_parts_freed, Carry::at_rest) compile
only with the device tests, as the crate's other such helpers do.

Verification: lavapipe 11672 at 3b4443dc3b ran the recovery tests (27/27, the
new held-call test among them), the lane's (6/6), and the negative control
(the held-call test fails: the parts went under the parked call); this commit's
clippy in the three configurations follows.

(cherry picked from commit 5ccc3857687af7ffe57c54f2cdb4d04462287f94)
2026-11-09 05:03:58 -08:00