Commit Graph
998 Commits
Author SHA1 Message Date
Anees Iqbal 71a5393966 Translator: an imageblock refusal names its cause (ImageblockCause)
Feature::Imageblocks covered about ten structures with one untyped refusal, so a walk's counts
could not tell them apart. Each site now names the structure it met, in Unsupported::cause
(Cause::Imageblocks), as Cause::Access and Cause::Tessellation do:

- MultisampleOperation: the front end's undecoded multisample operations (get_imageblock_samples,
  get_imageblock_num_colors, get_color_coverage_mask, the masked implicit store), set where the
  front end's refusal converts;
- Stage: an explicit imageblock or an imageblock intrinsic outside a kernel or tile function, or
  an imageblock view outside a fragment function (param_family, use_imageblock);
- TwoImageblocks, DataSize, Layout: why the planner gives the kernel's explicit imageblock no
  region (more than one; no or zero data size; an alignment that is not a power of two, cells past
  4 GiB, or an unaliased explicit one beside the implicit one). The planner's imageblock() returns
  the cause and ArenaLayout keeps it (imageblock_refused) for use_imageblock to refuse with;
  Missing where the kernel declares no imageblock at all;
- DataOperands: air.imageblock_data operands other than (coord, 0, 0);
- ParameterValue: the imageblock parameter's value selected (access::select_param);
- CellPointer: an imageblock-space pointer that air.imageblock_data does not make, outside a tile
  function (the planner);
- FragmentData: a fragment function's [[imageblock_data]] input (fragment::select_param) or
  output (stage_io);
- SliceWrite: a slice write of a shape not modelled (texture::select, texture::slice).

Golden tables are unchanged (their outcome text names no cause). REFUSALS.md regenerated, the
signatures table blessed (ImageblockCause, Cause::Imageblocks), the api_surface list and
docs/API.md's Unsupported row name the new enum. SEMANTICS_VERSION 2354 (main renumbers at
landing): a refusal's text changes. runtime-sources.sha256 follows from the job.
Verified: pending (the red tests and the suites).
2026-12-03 08:40:39 -08:00
Anees Iqbal 69033afcd4 rt: a Shared heap's texture on a device without unified memory is an image of its own
The L21 ruling, the third use of rule 2's unified-memory query (Vulkan's device type). On an
integrated or CPU device a Shared heap's image texture lies in its heap, as before. Elsewhere it is
an optimal image of its own in device memory, made as new_texture makes one but not zeroed (Metal's
heap textures are not), and its heap range is left unused. Before, a discrete device either
refused the placement (Gap::HeapTexture where its optimal images take no Shared type: the RTX 2080
and 3090 on NVIDIA 620.70.06) or bound the image in system memory, which every read crossed the
link for (97 times a Private heap's time on an RX 7900 XTX, job m3-max-79841).

How: heap_source decides by core.unified_memory() and the block's class. The own form checks the
placement against heap_texture_size_and_align's answers by the same rule the in-heap form uses
(heap_place, factored out of make: a heap range past its block, a texture past the heap's end, a
byte off the alignment are Refusal::HeapTexturePlace), then makes Source::HeapOwn: Bind::Pooled
(a place in a texture block or an allocation of its own, which spills as a texture's does), the
heap's hazard id kept, no alias Placement, and Under::Heap with at None, so use_heap still covers
it (heap_block) and blits see no shared span (bound). Texture buffers and textures over heap
buffers are untouched.

Docs: AGENTS.md rule 2's unified sentence gains the clause (the count stays fourteen); the
runtime README's heap text and known gaps (the device memory sum beside the heap's block, where it
runs out, and the earlier speed row); new_heap_texture(_for_views), heap_texture_size_and_align,
has_unified_memory and Gap::HeapTexture docs; docs/API.md and the conformance heap-size side's
step 2; docs/REFUSALS.md regenerated (HeapTexturePlace's site is heap_place).

RUNTIME_VERSION 2564 (renumbered at landing: development held 2563). runtime-sources.sha256 unchanged (guard PASS, m3-max-84127).
Verified: red FAIL / new PASS on the RTX 3090 (build m3-max-84138, run 84144), the RX 7900 XTX (84137, 84221; rt suite under m2v_gpu 993 passed, 4 skipped, 84222) and the Iris Xe (84227, 84238); CPU suites 84127 (conformance + rt 1279 passed, 2 skipped); clippy plain 84180, m2v_gpu 84172, m2v_cpu_icd 84181, rustdoc + api-docs 84182, all EXIT=0; states-only play on lavapipe 84256 equal to the base (gb-3090-r2 10643 render / 15299 compute, windrag-780m-b4-um790 8972 / 225, 0 refused). The consumer's arm64 guest walk on the RTX 3090 at pin S (m3-max-84046) asked for no texture on a Shared heap, so the evidence is the device tests and timing.
2026-12-03 08:40:29 -08:00
Anees Iqbal 23193c9bf1 Translator: the padded forms' linear mip filter blends two levels, a bfloat form's reads one
Two measured changes to an extended-range sample's level, each from the M3 Max on macOS 27.0.1:

- A padded form's linear mip filter (R10Unorm_X6, RG10Unorm_X12 and their _sRGB twins) now
  blends its two levels as BGR10_XR's and BGRA10_XR's do, through a constexpr sampler and through
  a runtime one, and records PrecisionNote::BicubicFilterArithmetic. Before, a constexpr sampler's
  was refused NotImplemented(Format), and a runtime sampler's read one level with no refusal. The
  probe extended_linear_mip_blends (job m3-max-82967; 16,384 lanes per form and filter, 2D, five
  levels, random codes) puts Metal's sample within 0.0157 of its own two levels' samples blended
  by mix at the fraction truncated onto sixty-fourths. The note's doc and its docs/API.md
  catalogue line gain that bound.
- A bfloat form's linear mip filter (R16Bfloat, RG16Bfloat, RGBA16Bfloat) is now its nearest mip
  filter, which Metal's equals on every lane whose two levels differ (4,096, 8,192 and 16,384
  lanes, nearest and linear filters). Before, a constexpr sampler's was refused. A runtime
  sampler's already read that level.

What stays refused through a constexpr sampler:
- A two-plane form's linear mip filter (not measured). The probe only shows that a five-level
  texture is made.
- RGB10A2Unorm_sRGB's linear mip filter (not measured). Jobs m3-max-83026 and m3-max-83029
  explain why. A texture of five levels holds each level's own code, which a blit reads back per
  level. Yet the M3 samples level 0's code at every explicit level, at gradients under a nearest
  mip filter, at every level under a linear one, and in a 2D array's layer 1. RGB10A2Unorm, the
  control, samples each level's code. Documented Metal samples the level asked for. So this is a
  driver defect, which is not emulated (an Apple bug report is drafted), and the format's samples
  keep reading the level the mip filter names. No conformance case samples that format's levels
  today.

Docs: three comments named binder refusals that no code makes, and none of the three exists
(ResourcePlanner is gone):
- a runtime sampler word that states mixed filters;
- a runtime linear mip filter's clamp maximum below the last level;
- a runtime linear mip filter of an unmeasured form.
The comments sat in lower/sampler/extended.rs, select.rs and the extended-range tests'
module docs. They now state what happens: the word samples as nearest, the maximum is not read,
and a two-plane form's or RGB10A2Unorm_sRGB's runtime linear mip filter reads the nearest mip
filter's level. They also say this is an open gap that no consumer meets while the runtime makes
no texture of these formats (the runtime's Gap::TextureFormat).

The probe crates/metal2vulkan-conformance/probes/extended_linear_mip_blends.m gains the nearest
mip filter at the point's level, the two-plane question and each texture's level count.
SEMANTICS_VERSION moves to the next number, because refusals are removed and samples' answers
change. runtime-sources.sha256 is re-pinned because metal/format/mod.rs is a runtime input.

Tests (tests/engine_extended_range/levels.rs):
- unmeasured_linear_mip_filters_are_refused now builds a padded and a bfloat linear mip filter,
  and still refuses a two-plane and an RGB10A2Unorm_sRGB one.
- measured_linear_mip_filters_blend_or_read_one_level: every padded and bfloat form's constexpr
  sampler compiles, valid, under either mip filter, with the note on a padded linear one alone.
  On the CPU interpreter, at 64 levels between two, through a constexpr and a runtime sampler, a
  padded form's sample lies between its two levels' nearest-mip samples on every lane and
  strictly between on some. A bfloat form's equals its nearest mip filter's, bit for bit.

Verified on the CPU with no device (job m3-max-83908): with metal/format/mod.rs,
lower/sampler/extended.rs and select.rs at 8e912a905d the two changed level tests fail, and here
the extended-range tests pass; the golden table differs from development's (semantics 2346) in 90
cells here and at 8e912a905d, so the change moves no existing cell by count; the refusal surface
check passes; cargo fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd), Rustdoc, the API
reference check and the doctests pass; the suites pass 3753 of 3754 (24 skipped), the one failure
golden_hashes_match_the_table, bless due as at 8e912a905d; the validation suite passes 1346 (3
skipped) and the conformance suite 1052. The states-only plays of this tree (m3-max-83910) make
what 8e912a905d's make (m3-max-83909): the gb-3090-r2 stream 10643 render and 15299 compute
states, the 780M windrag stream 8972 and 225, none refused.
2026-12-03 07:25:45 -08:00
Anees Iqbal 5b3bd800c0 Translator: under the identity domains a runtime sampler's LOD query outside a fragment function reads its minimum level from the sampler's word
A clamped calculate_clamped_lod in a kernel or a vertex function through a runtime sampler
argument was refused on every profile under the identity domains ("a sampler argument whose
minimum level or emulated filter the function specializes"): the query read the slot's
SamplerMinLevel specialization, which no binder chooses there.

The query now reads the word of the resource ID the sampler slot already pushes (SlotGuestBase):
0 where the word states no mip filter, else SamplerWord::LEVEL_MIN, the level a nearest mip
filter reads at lodMinClamp, bounded by the texture's last level as before. A bind-time clamp
(setSamplerState:lodMinClamp:lodMaxClamp:) binds a variant whose word is made of the clamped
descriptor, so it is read too. That is the M3 Max's and M4's measured answer
(metal::sampler::query_min_level) for no mip filter and a nearest one, and for a linear one where
lodMinClamp is a whole level or past the texture's last level. Under a linear mip filter with a
clamp between whole levels Metal answers the clamp on its sixty-fourths grid, which the word does
not hold. MSL 4.1 section 6.13 leaves both queries undefined outside a fragment function ("Only
call the calculate_unclamped_lod and calculate_clamped_lod functions from a fragment function or
a function you call with a fragment function; otherwise, the behavior is undefined."). So, per
the planner's ruling, there is no precision note; docs/API.md's accepted differences states the
answer. The resident-table path keeps its specialization.

SEMANTICS_VERSION 2347. The runtime-sources pin does not move: pin-compute.py gives a92fe0a8...
for this tree, the same as before. docs/REFUSALS.md does not move either: the refusal text
remains for an extended-range sample's linear-mip blend. The runtime README's known-gap entry
names the lowered query. Verified by the lane's red/green job, named in the lane's report.

Landed with SEMANTICS_VERSION 2347 (renumbered above development's 2346: written 2343 on its base,
then 2346 at the lane's rebase onto 0f4114c882, which development's HandleUse also took).
2026-12-03 06:46:38 -08:00
Anees Iqbal 011540217d Translator: a mode-2 fragment write to a texture buffer held as words rounds half and small floats to nearest even
A texture buffer of a format a device holds as words is written by lower/texture/words.rs's
write_texel, which rounded a half-float or RG11B10Float channel toward zero at either
textureWriteRoundingMode. Metal's texture buffer rounds those to nearest even at mode 2, as its
storage texture does (the probe below). So a fragment function in a mode-2 pipeline that wrote a
half-float or RG11B10Float texture buffer on a device holding that format as words stored a code
one below Metal's on 36% to 44% of the probe's channels, and 65504 where Metal stores the infinity.

Now, where Write::half_up marks the write (a fragment function's, in a pipeline of mode 2):
- a half-float channel (R16Float and RG16Float, the half-float formats a device may hold as
  words) takes ChannelWrite::FloatNearestEven, a finite value past the largest to the infinity, as
  Metal's RGBA16Float texture buffer stores it;
- an RG11B10Float channel takes nearest even too, and a lane that rounds to the infinity from a
  finite value is held at its format's largest finite value (65024 for the 11-bit channels, 64512
  for the 10-bit one), as Metal's stores it; an infinity stays, and a NaN is the quiet NaN still.
The RGB9E5Float word's half-up rounding is unchanged; the probe shows Metal's texture buffer
storing the same bytes as its storage texture there. A write at mode 0 or 1, and every kernel's
write, still rounds toward zero.

The probe is committed as crates/metal2vulkan-conformance/probes/texture_buffer_write_rounding.m:
texture_write_rounding_storage.m with texture_buffer<T, access::write> targets, made from a Shared
buffer with MTLTextureTypeTextureBuffer and written at texel y * 256 + x, over the same 65,536
texels. On an Apple M3 Max under macOS 27.0.1 (job m3-max-83395), mode 0 matched toward zero on
every channel, and mode 2 matched nearest even on every channel that is not a NaN: RGBA16Float
float texels 262,112 of 262,112 (to the infinity past the largest), RG11B10Float float and half
texels 196,583 of 196,583 each (held at the largest), and RGB9E5Float 65,536 of 65,536 at both
texel types (half up, its hashes equal to the storage texture's).

Docs: words.rs's module doc, Write::half_up and write_texel; API.md's words line names mode 2.

SEMANTICS_VERSION moves above development's: a texture buffer write's answer changes.

Verified on the CPU with no device (job m3-max-83575): the color_write and words tests pass (79), the
golden table differs from development's (semantics 2334) in 109 cells, as at a535f1dc17, and the
refusal surface is unchanged; cargo fmt, clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd),
Rustdoc, the API reference check and the doctests pass; the suites pass 3740 of 3741 (24 skipped),
the one failure golden_hashes_match_the_table, bless due; the validation suite passes 1340 (3
skipped) and the conformance suite 1052. The states-only plays of this tree (m3-max-83669) make
what 126ee4fdf5's make (m3-max-83443): the gb-3090-r2 stream 10643 render and 15299 compute
states, the 780M windrag stream 8972 and 225, none refused.
2026-12-03 05:55:06 -08:00
Anees Iqbal 9211eb3c10 Translator: half +, -, *, / and fma on the 16-bit instructions record NativeHalfConversion
Under the 16-bit float controls, a half +, -, * or / and a half fused multiply-add run on the
device's 16-bit instructions, between exact conversions. By the Vulkan spec their results are
Metal's. A driver's compiler may still compute them in float and leave them unrounded. Intel's
Windows driver 101.2145 on a UHD Graphics 630 does:

- A standalone tree of three 16-bit OpFAdds, or Fmas of a product, each decorated NoContraction
  under all three 16-bit controls, ran on 4,096 invocations. 2,284 sums and 4,080 products
  matched neither the half tree nor the float tree rounded once (job m3-max-83092).
- The Iris Xe under Mesa ANV 26.2.6 gave the half tree on every invocation (job m3-max-83093).
- In the runtime's quad test on the UHD, 112 of the 1,536 compared halves are the float chain
  rounded once at the store (job m3-max-82918).

Per the planner's ruling, the operation carries the static note on every device, with no device
check. narrow::computes_half_arithmetic looks in the emitted module for a 16-bit OpFAdd, OpFSub,
OpFMul, OpVectorTimesScalar or OpFDiv, or a GLSL.std.450 Fma. Where it finds one, the pipeline
records NativeHalfConversion, beside the conversion pair's existing cases. A Sqrt alone records
nothing, and neither does the simdgroup half tree's ClusteredReduce.

The note's reach in validation narrows to half arithmetic. Until now it reached every word fed by
any float family. The AIR word scan now feeds a new family, HalfArithmetic, beside the
operation's own family, from these operations:
- an fadd, fsub, fmul, fdiv, frem or fneg with a half result;
- a float cast whose result or operand is a half;
- a call of a modelled family whose result or an argument is a half.
NativeHalfConversion reaches only that family. A half word that only float arithmetic fed,
through a move, is no longer reached. The note stays unbounded at the word, now on the
comparison's stay-unbounded list with its reason. A driver may leave the chain unrounded and
round it once at the store, and with cancellation the two answers differ by more than the stored
value's ulps (40 codes measured on the UHD). How far rests on the operands, which a word does
not carry.

Docs:
- The note's API.md catalogue entry and its PrecisionNote doc said those operations "take no such
  rounding". They now say the operations record the note, and give the UHD 630 measurement beside
  NVIDIA's fold and RADV's fusion.
- The DeviceHalfDenormals entry points to it.
- VALIDATION.md names the half family among those the word scan reads.

Tests:
- engine_native_half: the controlled-conversion test's sum kernel now records the note, as every
  kernel there does.
- engine_float_call_notes sets the module-level note aside for 16-bit arithmetic, as it does for
  the conversion pair.
- half_simd_reductions accepts, where the quad pipeline records the note, a quad word whose
  every half is Metal's or the float operations rounded once. The model is the new devtools
  quads_once.
- In validation:
  - the scan's packed-halves test expects HalfArithmetic on the half word alone;
  - a words test shows the note reaching a half word only when half arithmetic feeds it;
  - the reach row is pinned.

SEMANTICS_VERSION 2340 -> 2341 (precision notes added).
ENGINE_EXECUTOR_ABI vulkan-engine-v215 -> v216 (the word scan feeds HalfArithmetic, and the
note's reach narrows to it).

Golden hashes: no cell moves. The cells hash the final SPIR-V, which the note does not touch.
Job m3-max-83293 (Linux) ran golden_hashes_match_the_table twice: at this change, and with
compile.rs and cache/mod.rs at f42e61aa84. Both failed with the same 2 changed-cell lines, 0
lines differing between them: development's table is due its own bless. The fixtures that need
metal-as were skipped on Linux.

runtime-sources.sha256 is unchanged: no edited file is a fingerprint input.

Note-bounds figures (noted / matched within bounds / mismatches over the 1,168 public cases),
each arm built in one job, at 702916d9d3 and at this change on it (6edabebff2):
- lavapipe (Mesa 26.2.4, LLVM 23.1.1; job m3-max-83272): 151 / 27 / 15 before and after;
- Radeon 780M (RADV PHOENIX; job m3-max-83273): 166 / 24 / 21 before and after.
Every case's outcome and bounded line is the same in both arms, so no row is new. Only the per-note
word attribution moves: NativeHalfConversion's noted words fall from 3,267 to 1,168 on lavapipe and
from 3,558 to 1,276 on the 780M, as other notes reaching those words now take them.

Verified, at the probe db2bceb3f6, whose tree is this commit's (gate job m3-max-83293):
- the four red tests pass here and three fail with compile.rs at f42e61aa84 (EXIT=100);
- STEP clippy_plain EXIT=0, clippy_gpu EXIT=0, clippy_cpu EXIT=0;
- doc EXIT=0, privdoc EXIT=0;
- the translator's and AIR's suites minus the bless-due tables: EXIT=0;
- on lavapipe (host Mesa 26.2.6):
  - runtime: 983 passed, 4 skipped; half_simd_reductions 0 differ in all three pipelines;
  - validation: 1338 passed, 3 skipped, the runtime-sources guard among them.
- The conformance replay in the pinned lavapipe image (CI's venue, LLVM 23.1.1), at f42e61aa84
  and at this change (job m3-max-83337): 0 ledger drift in both arms, 4661 rows as expected.
  On the gate job's host lavapipe (Mesa 26.2.6, LLVM 23.1.4) its replay printed 12 drift lines,
  the bicubic-texel-classes rows among them. That run has no base arm.

The device legs of the half test:
- UHD Graphics 630, Intel's Windows driver 101.2145, at 6edabebff2 (this change on 702916d9d3;
  job m3-max-83288): every_device_sums_and_multiplies_half_simdgroups_as_metal passed.
  - The quad pipeline records NativeHalfConversion. 0 of 768 words differ from Metal's, and 96
    more are the float result rounded once.
  - The simd and masked pipelines: 0 differ.
- Apple M3 Max, KosmicKrisp (Mesa 26.3.1), at db2bceb3f6 (archive m3-max-83294, run
  m3-max-83297): passed. 0 words differ in each pipeline and none takes the rounded-once
  admission.

Landed with SEMANTICS_VERSION 2342 (renumbered above development's 2341); runtime-sources.sha256 recomputed on development, unchanged (a92fe0a8). States-only plays at the change (job 83345): gb-3090-r2 render 10643 and compute 15299 made, 0 refused; windrag-780m-b4 render 8972 and compute 225 made, 0 refused, equal to pin R.
2026-12-03 04:14:29 -08:00
Anees Iqbal d0fb4f3381 Translator: delete StageModule::level_reads, which nothing reads
StageInterface::level_reads and StageModule::level_reads stated, per texture slot, the levels of
its bound view the stage's reads reach (LevelReads, SampledLevels, SamplerLevels and the
structural analysis spirv::requirements::level_reads). Nothing reads them:
- the runtime: git grep -nw -e level_reads -e LevelReads -e SampledLevels -e SamplerLevels
  -e finite_texels -e highest_lod -e lowest_lod at 401d9d5949 over every crate but the translator
  finds one hit, the runtime's translator_fields test, which lists the field as a fact the runtime
  does not apply;
- the consumer: the same search at a20576e1fd finds 0 hits.
Under the identity domains, which the runtime ships, the analysis also seeded nothing, since no
variable holds one slot's image there. Rule 4: deleted rather than seeded.

Removed: the two fields, the three public types with their methods, the analysis and its tests,
their codec entries and footprint, their rows in tests/api_signatures.tsv and the api_surface
table, the API guide's "Levels a slot reads" section and HOWTO's mention of it, and the runtime
test's listing. own_pixel's helpers that the analysis shared are private again.

ARTIFACT_FORMAT_VERSION moves to the next number above development's: StageInterface's and
StageModule's encodings lose a field. No translation answer changes, so SEMANTICS_VERSION stays.

Verified on the CPU with no device and on lavapipe (llvmpipe, LLVM 23.1.4), job m3-max-83281 at
the next commit, which holds this one: fmt, the signatures, clippy plain, with --cfg m2v_gpu and
with --cfg m2v_cpu_icd, rustdoc, the private rustdoc, the refusal surface check and the API
reference check passed; the suites 3737 of 3738 passed (24 skipped), the one failure the golden
table, which fails at the base on the same 80 cells (a bless due on development); validation 1337
passed (3 skipped); conformance 1052 passed; the doctests passed.
2026-12-03 04:13:32 -08:00
Anees Iqbal f42e61aa84 Docs: the helper-thread words' four mechanisms, and what a split quad's helper query answers
The read of the ten cases held as helper_thread_words (lavapipe, job 83263; Radeon 780M, jobs
83264 and 83267) explained 454 of their 455 differing words by four mechanisms: Apple's partial
quads, lavapipe's clip seam, RADV's lane order and x86 lavapipe's 8-lane subgroup. The docs said
otherwise in two places:

- QuadsSplitByClipping said each run of a split quad combines fewer active lanes than Metal's.
  Each piece's run keeps all four lanes; what differs is the helper query, which names the other
  piece's covered pixels as helpers where Metal's quad, shaded once, names none. The note's doc
  comment, its API.md catalogue entry and the validation gap's doc now say that.
- FragmentSimdgroupGrouping gains the fill past a subgroup under 32 lanes: it reads an inactive
  lane, which MSL 4.1 section 6.10.2 leaves undefined, and the device reads the calling lane in its
  place (lower::simd's PartialFragment read).

docs/VALIDATION.md's verdict section names the four mechanisms and what lavapipe and the 780M do
under each, where the next reader of a held case looks. The gap's doc in c3.rs no longer says the
cause is unread.

Docs and doc comments only. pin-compute.py over the tree gives the committed runtime-sources
fingerprint (artifact.rs is not one of its inputs), so no re-pin. cargo fmt --all is clean.
2026-12-03 03:48:23 -08:00
Anees Iqbal f683293b4b Docs: a fetch may read the texel from before its draw, so overlapping read-modify-writes leave one
UnorderedFetchWithinDraw's words said a pixel that overlapping fragments of one draw fetch and
write "holds the result of some order of the draw's fragments", "not necessarily Metal's". The
Radeon 780M (RADV, Mesa 26.2.6) shows otherwise. Job m3-max-83259 ran the eight authored cases
the ordered_fetch_within_draw gap holds (n instances of the companion's fullscreen triangle in
one draw, so n identical fragments at every pixel or sample) five times at 702916d9d3. All five
outputs were identical. Every differing word is the fragment function applied once to the
texel as it stood before the draw. Each case's chain f^k(initial), computed from its own inputs,
gives Metal's stored output at k = n on every word, and the 780M's at k = 1 on every word that
differs, all four lanes of each texel alike. All n fragments are identical, so every order of
them gives Metal's value: the 780M's value is no order's result. Lavapipe matches Metal on the
seven cases it runs (job m3-max-83255).

The note now says what a fetch can observe there: it may read the texel from before its draw,
so overlapping read-modify-writes of one draw may leave one application. Changed in docs/API.md's
precision-note catalogue, PrecisionNote::UnorderedFetchWithinDraw's doc comment and the runtime
README's known gap. Docs only, no behaviour change. The runtime-sources pin is unchanged
(pin-compute.py gives a92fe0a8...).

Verified: cargo fmt --all; nothing built.
2026-12-03 03:35:47 -08:00
Anees Iqbal 41712a1ec5 Translator docs: NativeNanEncoding covers a NaN's payload moved through loads, stores and selects
What: NativeNanEncoding's rustdoc and its docs/API.md catalogue entry say what validation now
reads it as covering: a NaN's payload moved through loads, stores and selects as well as one an
operation computes. Validation excuses a word in any float lane only where Metal's answer and
the device's are both NaNs of the lane's format.

Why: the planner accepted reading the note as reaching every float lane, bounded to two NaNs.
The public case nan-model-loads-stores-and-selects-of-nan-halves differs on lavapipe only in
half NaN payloads its entry moves without an operation (e.g. Metal 0x7e01 against 0x7e00,
m3-max-82836), which the note's own text already records at every read of a half from its bits.

Text only: no output and no recorded note changes, so SEMANTICS_VERSION stays; artifact.rs is
not a runtime source input.
2026-12-03 03:27:51 -08:00
Anees Iqbal 2c61e4fc52 Translator docs: NativeFma states that an unfused half product can overflow
What: NativeFma's rustdoc and its docs/API.md catalogue entry state the one case its recorded
bound does not cover: an unfused product can overflow where Metal's fused result is finite, and
the overflow stays the device's answer. A 16-bit product of magnitude 65520 or more rounds to
the infinity of its sign, so the result is that infinity where Metal's is finite, or a NaN
where the addend is the infinity of the other sign and Metal's result is that infinity.

Why: the bound (half an ulp of the product plus half an ulp of the result) read as covering
every input; the public cases fused-multiply-add-rounding-and-fmuladd-without-fast-math and
fused-multiply-add-rounding-and-contraction-under-fast-math show the other answer on lavapipe:
fma(256.0h, 256.0h, -65504.0h) is inf where Metal answers 32, and fma(65504.0h, 65504.0h,
-inf) a NaN where Metal answers -inf (job m3-max-82667's rows against the committed Metal rows
of the Apple M3 Max). No lowering changes; the note stays unbounded in validation.

Text only: no output and no recorded note changes, so SEMANTICS_VERSION stays. artifact.rs is
not a runtime source input, so runtime-sources.sha256 stays.
2026-12-03 03:27:51 -08:00
Anees Iqbal e31bc61172 Validation: a precision note excuses only the words its operations feed, within its bound
What: a candidate's output is judged against Metal's one 32-bit word at a time
(observation_contract::words). An equal word matches. A differing word is excused only by a
recorded note that reaches it: a note with a bound makes a word within it a match, a note with
no bound makes it a noted word, and a word no reaching note excuses is a mismatch.

- Reach is read from the case's AIR (check::output_words): for each output word, the float
  lanes it holds and the operation families whose results feed it, followed byte by byte
  through bitcasts, lane moves and the zext/shl/or that pack two halves. A store placed at
  A * thread_position_in_grid + B bytes gives each thread's words their own facts. A note of the
  module that writes the output reaches the words its operations feed; a note of another module
  reaches every word, and so does every note of a word the scan cannot follow (a load of memory
  the entry writes, a call outside the intrinsic families).
- Bounds a word can carry are checked there, and a word within one matches: DeviceDenormals
  only where Metal's and the device's lanes both lie at or below the smallest normal (2^-126,
  2^-14 for half), of one sign unless one is a zero; NativeNanEncoding only two NaNs of the
  lane's format (it reaches every float lane: a half read from its bits is no operation);
  HalfTexelConversion its recorded one half ulp, or +-65504 beside the infinity; the lane
  tables and the reassociation bound as before.
- NativeFma, NativeDot, NativeMix and NativeDivision keep no value bound (each states its bound
  over the operands, which a word does not carry) and reach only the words their operations
  feed. The fixture knows its inputs, so a per-case bound from the operands is a later form.
- SimdgroupAccessOrder reaches only a word another thread of the kernel may write: one a store
  the scan cannot place in its own thread's bytes writes.
- Rows record the output's word facts (census output_words). The batch report prints, per case
  and in total, the words matched exactly, within each note's bound and only noted, by note,
  the unexcused words, and the cases with a word on the fall-back.
- DeviceDenormals's rustdoc states Metal's measured answer per operation: it flushes before
  rounding on some (a product, fma, dot and mix just below 2^-126 answer a zero) and keeps a
  denormal on others (sin, tan, asin, sinh, asinh, atanh of a denormal), from the public cases
  float-products-flushed-before-rounding and nan-model-float-denormals-per-operation. Its
  recording rule already covers plain multiplies; no rule changed.

ENGINE_EXECUTOR_ABI is v215: how a match is decided changed and rows record word facts.

Why: a noted difference was excused whole by any recorded note, so a note that could not cause
a word's difference (a division's note beside a product, an access-order note on a kernel whose
threads write disjoint words) hid it, and a bounded note never matched.

Verified on lavapipe (Mesa 26.2.4, the lavapipe image), the 1,168 public cases, job
m3-max-82854 (this tree with the next commit's doc text) against m3-max-82667 at b3d7464945: match 746 -> 773, noted_difference
188 -> 161, mismatch 5 -> 5 (each held open by clipped_primitive_split, as before); words
2,859,015 exact, 30,212 within a bound, 352,820 noted, 0 unexcused. Of the 188 cases noted
before, 34 have an output word on the fall-back (26 every word) and 32 a differing one.
Tests: the validation suite at an earlier tree, m3-max-82839 (1,331 passed, 3 failed; the three
are fixed here), and the touched modules at the same tree as m3-max-82854, m3-max-82855 (136
passed).
2026-12-03 03:27:51 -08:00
Anees Iqbal 1c68dd10f4 Texture buffers: a read-write one is words where its format's own view reads none without a format
A texture buffer's form (rule 2's texture buffer formats, metal::format::texel_buffer_form) asked
three accesses of a format's own view: a uniform texel buffer, a storage texel buffer, and a storage
texel buffer written without a format. A function that reads a texture buffer through
access::read_write reads its storage element without a format, which Vulkan asks of the view's
format (VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT, VUID-vkCmdDispatch-OpTypeImage-07030),
so on a device whose own view of a format lacks that bit the runtime refused the draw or dispatch
(Gap::StorageElement, ReadWithoutFormat). ANV on the Iris Xe (RPL-P) lacks it for BGRA8Unorm,
B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm (jobs m3-max-81883, m3-max-82116); its committed profile
(intel-irisxe-rplp-anv) answers the same for RG11B10Float, RGB10A2Unorm and RGB10A2Uint, and so do
intel-irisxe-anv and intel-uhd770-rpls-anv for all seven (job m3-max-82025). Holding those formats
as words for every texture buffer would cost one made to be read 31.6% and 31.7% on that Iris
(texel_buffer_bgra8_read and texel_buffer_b5g6r5_read, job m3-max-82136).

The form now asks a fourth access, the storage read without a format, only of a texture buffer
whose usage, fixed at its making, holds both MTLTextureUsageShaderRead and
MTLTextureUsageShaderWrite, or is MTLTextureUsageUnknown (metal::format::texel_buffer_read_write):
Metal lets a function reach a texture buffer through access::read_write only where its usage holds
both. texel_buffer_form(pf, usage, profile) is one answer per format and usage per device; one made
to be read or written alone keeps the three-access answer. On the three ANV profiles the seven
formats move to words for such a texture buffer and nowhere else. AGENTS.md's rule 2 says so in
the same commit: the three accesses, plus the storage read without a format for a texture buffer
made with both usages, one answer per format and usage per device; it is still one query-chosen
form, and the count of fourteen is unchanged.

The word says the usage, as it says the format, so a shader that meets a texture buffer through a
handle, as one at a slot, tells which answer holds: bit 11 of a texture buffer word of a format
with a word layout, TextureWord::TEXEL_BUFFER_READ_WRITE, is set where it was made both to be read
and to be written. It lies within the 14 low bits an argument buffer's handle carries
(HANDLE_WORD), and the word stays the same on every device. The translator holds the codes a
profile holds as words per usage (WordCodes: alone, read_write); the words twin's held test tests
bit 11 beside the code only where some format is words for the one usage and not the other
(read_write & !alone), and where the two sets are equal the test and the module are what they
were. The runtime asks texel_form of the texture's usage at its making, and
Device::minimum_texture_buffer_alignment, Metal's query of a format alone, answers the larger of
the two forms' alignments: on the three ANV profiles (uniform offset alignment 1, storage 16, a
single texel enough for both) B5G6R5Unorm and BGR5A1Unorm go from 2 to 4 bytes (a word against a
2-byte texel), and BGRA8Unorm, BGR10A2Unorm, RG11B10Float, RGB10A2Unorm and RGB10A2Uint stay 4;
every other profile's two forms are equal, so its answer is unchanged (computed from the committed
profiles' limits, not measured apart).

Public contract, in this commit: TextureWord::of_texture_buffer(pixel_format, width, usage),
texel_buffer_form(pf, usage, profile), the new texel_buffer_read_write and
TextureWord::TEXEL_BUFFER_READ_WRITE (api_surface, api_signatures.tsv); docs/RESOURCE-ID.md's bit 11
row, its texture buffer word section and its test vectors: tests/resource_words.tsv gains a usage
column, each format with a word at read (1) and read-write (3) usage with its widths, and at write
(2) and unknown (0) at width 1. Consumer search: reims-vgpu at 4f46e27e3b (main's) and at its
current e447795571 (mine): no guest computation of words; of_texture_buffer, texel_buffer_form,
TEXEL_BUFFER_ and resource_words have no hit, and TextureWord's one hit is link-order.txt, a symbol
order list naming TextureWord::of. The runtime README's known gap now says the read is served for a
texture buffer made with both usages, and keeps the measured words' cost scoped to those; its form,
alignment and words-cost paragraphs, docs/API.md and docs/REPLAY-STREAM.md name the usage.

The zero for amd-rdna2-apu-radv, intel-arl-anv and nvidia-pascal-linux is unaudited: those
committed profiles report all 39 word formats as words, so no format can move there by this rule
(main opens a row to re-record them).

SEMANTICS_VERSION 2339 (development holds 2338): the words twin's module on the three ANV profiles
and the form's answers move. RUNTIME_VERSION 2558: a texture buffer's form, its word and the
alignment the runtime answers move. runtime-sources.sha256 re-pinned (metal/format/texel_words.rs
and metal/format/mod.rs are runtime inputs). docs/REFUSALS.md does not move (refusal_surface.py
--check passed).

Verified at 0cbe4dfc70, a commit of this same tree on a try branch (tree dd16b6a2f7):
- red: the test before this one (rebased here as 5900eb8642), at ed24bac82a, job m3-max-83041 on
  the Iris Xe (RPL-P, Mesa 26.2.6): every_device_runs_texture_buffers_made_to_be_read_and_written_at_every_slot
  failed with B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm "not dispatched", the read-written slot's
  ReadWithoutFormat refusal;
- the Iris Xe (RPL-P, Mesa 26.2.6), the runtime's texture buffer tests (--cfg m2v_gpu, filter
  test(texture_buffer)), job m3-max-83121: 12 run, 12 passed; the new test alone, job m3-max-83127,
  passed, every one of the 15 formats answering the CPU's at every slot. It asserts, per texture
  buffer made, that the words gauge (Gauges::word_texture_buffers) moved exactly where the form
  answers words for its usage, and that the words twin ran once per dispatch where one bound is
  words; every_device_reads_and_writes_texture_buffers_of_formats_held_as_words printed
  B5G6R5Unorm, BGR5A1Unorm and BGR10A2Unorm "own view; made to be read and written, words: every
  answer the CPU's", where they were refused before;
- the Iris Xe, rt_replay's texture_buffers_play_with_their_recorded_ids_and_the_cpu_s_texels
  (--cfg m2v_gpu), job m3-max-83115 (at 9eb68e9c2c, which differs from this tree by a test
  helper's name in the runtime's texture_buffer_words.rs alone): BGRA8Unorm and B5G6R5Unorm play
  as "own view, read_write words" with the recorded IDs (each word with bit 11 where made to be
  read and written), the CPU's texels and values, where the play ended in the refusal before;
- the Intel UHD 630 (Windows driver 101.2145, validation layer 1.4.363.0), job m3-max-83145 (the
  win-cross build m3-max-83134): the runtime's whole suite, 985 run: 984 passed, 1 failed, 4
  skipped; every_device_runs_texture_buffers_made_to_be_read_and_written_at_every_slot and
  every_device_reads_and_writes_texture_buffers_of_formats_held_as_words passed. The one failure,
  half_simd_reductions' every_device_sums_and_multiplies_half_simdgroups_as_metal, fails the same
  way at pin Q (m3-max-82853) and at 2e9f9866be (m3-max-83061) and is outside this change;
- job m3-max-83128 (Linux): the runtime's, devtools' and harness's suites 280 run, 280 passed, 2
  skipped; validation 1323 run, 1323 passed, 3 skipped; conformance 1052 run, 1052 passed;
  doctests; on lavapipe (--cfg m2v_cpu_icd) the runtime's texture buffer tests 12 run, 12 passed,
  and rt_replay's texture buffer play passed, every format the same form for both usages there;
- the Linux gate, job m3-max-83122: cargo fmt --check, signatures --check, refusal_surface.py
  --check, clippy -D warnings (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc all clean;
  the translator's and AIR suites 3459 run: 3458 passed, 1 failed, 22 skipped, the one failure
  golden_hashes_match_the_table, a bless due of 80 cells under 2339 (the 78 below and
  development's own 2); the runtime guard (the_runtime_sources_are_the_committed_ones) passed;
- golden cells (job m3-max-83165: the golden test's every changed cell at this tree and at
  development's 401d9d5949, the same build, listed in full): 26 cells move on each of
  intel-irisxe-anv, intel-irisxe-rplp-anv and intel-uhd770-rpls-anv (every fixture that reaches a
  texture buffer: a8r_buffers, abt_descriptor_sets, hlf_half_buffer, hsw_storage_writes,
  kernel_read_through, ob1_texel_buffer, rlm_runtime_limits, tb_word_formats, texture_ops'
  texel_buffers, tob_renders, trh_forward, unk_size_queries,
  kernel_texture_variant_leftovers, kernel_write_one_dimensional_textures), and 0 on each of the
  other twelve committed profiles (amd-780m-hawkpoint-radv, amd-780m-radv, amd-rdna2-apu-radv,
  gate-lavapipe, gate-lavapipe-x86_64, intel-arl-anv, lavapipe, moltenvk-m3, nvidia-pascal-linux,
  nvidia-rtx50-linux, nvidia-rtx5080-laptop, runtime-floor): there the two code sets are equal and
  the module is what it was. Development's own two due cells (runtime-floor's a8r_buffer_read_write
  and tb_word_formats) are the same at both. The .air.ll rows need macOS's metal-as and were not
  compared. The table is re-blessed on development;
- the authored compile census (jobs m3-max-83117 at 9eb68e9c2c and m3-max-83118 at
  401d9d5949, checks; m3-max-83148, a bless in its own workspace at this tree, diffed): 0
  differences and 0 failures at both, 21321 cells; 14 artifact digests move, every one on
  intel-irisxe-rplp-anv (a C3 venue), 0 on gate-lavapipe and amd-780m-radv, against 0 at
  401d9d5949;
- the bit test's cost where nothing moves, on the Iris Xe (exclusive, job m3-max-83168): the
  release harness of 401d9d5949 (before, and a copy of it, before2) against this tree's (after),
  built by job m3-max-83124, 8 rounds of 500 runs each, the arms' order rotating: the read-only
  own views texel_buffer_bgra8_read and texel_buffer_b5g6r5_read take a GPU p50 (median of the 8
  rounds) of 9009.0 us and 9215.8 us after against 9009.0 us and 9215.6 us before, +0.00% each,
  before2 against before -0.01% and 0.00%; every run matched its CPU reference.
2026-12-03 03:22:23 -08:00
Anees Iqbal 401d9d5949 Translator: an extended-range 3D texture's linear mip filter blends its two levels, under BicubicFilterArithmetic
A BGR10_XR or BGRA10_XR form's (or _sRGB twin's) 3D sample under a linear mip filter now blends
its two levels' 3D filters as a 2D sample blends its levels: the device's FMix at the clamped
level's f32 fraction, through a constexpr sampler and through a runtime sampler whose word states
the filter. It records PrecisionNote::BicubicFilterArithmetic, as every level blend does
(the runtime sampler's under its linear-mip clause). Metal's blend of a 3D texture's two levels
fits no rule tried; the XR mip probe (an Apple M3 Max on macOS 27.0.1) put the closest 284 of
8,192 samples apart. The note's doc and its catalogue line in docs/API.md now state this, with a
new measure committed as crates/metal2vulkan-conformance/probes/extended_linear_mip_blends.m (the
M3 Max, macOS 27.0.1, job m3-max-82944). At 16,384 lanes per form, filter (nearest, linear) and
shape, Metal's own two levels' samples blended by mix at the fraction truncated onto
sixty-fourths lie within 0.033 of Metal's 3D linear-mip sample of BGR10_XR, BGRA10_XR and their
twins, and within 0.031 of its 2D sample, the blend the module has shipped. The module blends at
the f32 fraction instead, which moves its blend by under 1/64 of the two levels' difference from
that rule.

The select_extended doc no longer lists a 3D texture's linear mip filter among the refusals.

Before this change:
- A constexpr sampler's linear mip filter on such a 3D texture was refused
  NotImplemented(Format).
- A runtime sampler's linear mip filter on one had no refusal at all. The emitted sample read the
  nearest level, and its comment named "the binder's refusal", which no binder or runtime code
  makes (ResourcePlanner::extended_sampler no longer exists).

The same gap holds for a 2D sample of a form whose levels' blend is not built (another XR form,
ExtendedRange::blends_levels false) through a runtime sampler that states a linear mip filter. That
case is left to the oracle measure that will build it.

Red test: tests/engine_extended_range/volumes.rs volume_linear_mip_filters_blend_two_levels
replaces volume_linear_mip_filters_and_padded_forms_are_refused. A constexpr linear mip filter
compiles, valid, with the note. On the CPU interpreter, a runtime sampler's linear-mip sample at
64 levels between two lies, on every lane, between the nearest mip filter's samples of those two
levels, and strictly between on some. A padded form's 3D sample stays refused. At the base, the
constexpr case is refused, and the runtime sampler's sample is one level's.

SEMANTICS_VERSION moves to the next number: a refusal is removed and a sample's words change.

Landed with SEMANTICS_VERSION 2338 (renumbered above development's) and runtime-sources.sha256 4361761c, recomputed on development.
2026-12-03 02:55:10 -08:00
Anees Iqbal 6191bf763d Translator: mode-2 fragment storage writes run: Metal's RGB9E5Float word, the device's half and RG11B10 rounding
Under TextureWriteRoundingMode::NearestEven (Apple's textureWriteRoundingMode 2) every fragment
storage write now runs; the refusal NotImplemented(PrivateRenderState(TextureWriteRounding)) and
the facts RuntimeFact::StorageTextureWriteRounding and HeapWriteRounding are deleted.

Measured first, by the probe committed here as
crates/metal2vulkan-conformance/probes/texture_write_rounding_storage.m (an Apple M3 Max under
macOS 27.0.1, jobs m3-max-82793 and m3-max-82824): a fragment function writes 65,536 texels of
float and of half texels into RGBA16Float, RG11B10Float and RGB9E5Float storage textures, once in
a pipeline of mode 0 and once of mode 2. Mode 0 rounds every channel toward zero. Mode 2 rounds
a half-float channel to nearest even, a value past the midpoint above 65504 to the infinity
(262,112 of 262,112 non-NaN channels); an RG11B10Float channel to nearest even, held at the largest
finite value (196,583 of 196,583, float and half texels alike); and an RGB9E5Float texel's
mantissas half up under the largest clamped channel's exponent, moved up where that mantissa
rounds to 512, which is Vulkan's own rule for the format (65,536 of 65,536 texels, float and half
alike). Every mode-2 code lies within one unit of mode 0's.

- RGB9E5Float: the word is the module's own arithmetic (texture::rgb9e5_word), so under mode 2 it
  is now Metal's mode-2 word exactly: the product times 2^(25 - e) converted toward zero keeps the
  half's bit, one added and a shift right round half up, and a largest mantissa of 512 moves the
  exponent up before every mantissa is rounded again. Write::half_up carries it to a
  SharedExponentBits slot's write (emit::to_image) and WordsPlan::half_up to the texture-buffer
  words' write routine. A kernel, tile or other function, a word attachment and the default mode
  keep the truncation.
- RG11B10Float, float and half texels: the device's conversion as at the default mode, recorded
  as PrecisionNote::DeviceColorConversion (unconditionally for a declared format, under
  small_float_storage's clauses for a formatless slot or a heap). A half-float channel's note for a
  float texel stays half_storage_facts's. The note's storage clause and its catalogue line in
  docs/API.md state the measured counts.

Red tests:
- lower/arith/tests/color_write.rs rgb9e5_words_are_metals_at_either_mode: the emitted word, run
  in the SPIR-V interpreter over the probe's 65,536 texels (probe_texels rebuilds them from the
  probe's SplitMix64; its input and half hashes are checked against the probe's), hashes (FNV-1a)
  to the texture Metal wrote, bit for bit, for float and half texels at either mode. It is red with
  the half-up arm disabled.
- tests/engine_link.rs mode_two_fragment_texture_writes_round_as_metal_or_the_device replaces
  mode_two_refuses_fragment_texture_writes_it_would_round. It draws over an RGBA32Float attachment,
  whose output records no note (the previous test's RGBA8Unorm attachment recorded
  DeviceColorConversion itself, which made the earlier commit's note check vacuous). Every case
  compiles and links valid at either mode. A declared R16G16B16A16 slot records
  DeviceColorConversion at both modes, a B10G11R11 slot under mode 2 alone, and an RGB9E5 word
  slot at neither. It is red with the product files at the base, which refuse.

Public surface: PrivateRenderField::TextureWriteRounding and the two RuntimeFact variants are
removed (api_signatures.tsv rows). The consumer's checkout at a20576e1fd has 0 hits for
PrivateRenderField, StorageTextureWriteRounding or HeapWriteRounding (git grep). The mechanism
test's variant indices move StencilBitDraws and RobustStorageBuffers into the two freed places.
docs/REFUSALS.md is regenerated.

Not in scope, a follow-up: a texture buffer of half-float or RG11B10Float held as words
(texel_buffer_form) converts by the module's own toward-zero routine, recorded under the same note.

SEMANTICS_VERSION (refusal removed, notes and words under mode 2) and ARTIFACT_FORMAT_VERSION (two
RuntimeFact variants removed from the codec) each move to the next number.

runtime-sources.sha256 re-pinned (4361761c): the edited translator sources are runtime inputs.

Landed with SEMANTICS_VERSION 2337 (renumbered above development's) and runtime-sources.sha256 4361761c, recomputed on development.
2026-12-03 02:55:10 -08:00
Anees Iqbal a03b74c95c Translator: a fragment float write to a half-float or RG11B10Float storage texture under mode 2 is the device's conversion
Under TextureWriteRoundingMode::NearestEven (Apple's textureWriteRoundingMode 2), a fragment
function's float texel written to a storage texture whose slot declares a half-float or
RG11B10Float format was refused NotImplemented(PrivateRenderState(TextureWriteRounding)). It now
runs with the device's conversion, as at the default mode, and records
PrecisionNote::DeviceColorConversion: Metal's mode 2 rounds such a channel to nearest even
(RG11B10Float held at the largest finite value), the device's store toward zero on every measured
driver. The half-float note comes from half_storage_facts, which every float write runs; the
RG11B10Float note from mode_rounded_write, under the clauses of small_float_storage (unconditional
for a declared format, by the bound format for a formatless slot, by the heap's small-float family
for a heap element). The note's storage clause in artifact.rs and its catalogue line in docs/API.md
state the mode-2 case.

The writes whose mode-2 rounding was not measured keep the refusal: a float texel into
RGB9E5Float, and a half texel into RG11B10Float or RGB9E5Float. RuntimeFact::
StorageTextureWriteRounding and HeapWriteRounding stay for a slot whose bound texture decides and a
heap handle, their docs narrowed to those cases; their field `halves` (a float texel, which also
refused half-float textures) is renamed `float`, since a half-float texture no longer refuses
(api_signatures.tsv's two variant rows follow). The consumer's checkout at a20576e1fd has 0 hits
for StorageTextureWriteRounding or HeapWriteRounding (git grep).

Fixed with it: a slot declaring RGB9E5Float through its word alias (R32_UINT,
StorageImageClass::SharedExponentBits, the choice every profile makes for the format) was not
seen as a mode-2 target at all, so under NearestEven it compiled with the default's word, no
refusal and no mode recorded. It now records the mode and is refused under NearestEven, as a
declared E5B9G9R9_UFLOAT_PACK32 was.

SEMANTICS_VERSION 2333 -> 2334: a refusal class changes (mode-2 storage writes), and a fragment
stage writing an RGB9E5Float word slot now records the mode in StageIo.

Red test: engine_link's mode_two_refuses_fragment_texture_writes_it_would_round gains a
SharedExponentBits case (refused under mode 2) and expects the declared R16G16B16A16_SFLOAT and
B10G11R11_UFLOAT_PACK32 cases to compile under mode 2 with DeviceColorConversion, no fact, and to
link valid.

runtime-sources.sha256 re-pinned (2ac17122): lower/texture/mod.rs and the other edited sources
are runtime inputs.

Landed with SEMANTICS_VERSION 2336 (renumbered above development's) and runtime-sources.sha256 2ac17122, recomputed on development.
2026-12-03 02:55:02 -08:00
Anees Iqbal 699f1167d6 Translator: a Converted half rounding's conversion pair is decorated NoContraction, as the Controlled one is
A `half` rounding in `QuantizeForm::Converted` (a profile with shaderFloat16 whose float
controls do not make the conversion Metal's) was an undecorated OpFConvert to 16 bits and
its widening. Vulkan assumes AllowTransform on every operation not decorated
NoContraction ("Precision and Operation of SPIR-V Instructions"), and Mesa's NIR folds
`~f2f32(f2f16(a))` into `a` wherever the instruction is not exact (nir_opt_algebraic.py;
vtn marks NoContraction exact), so the value went on unrounded. On KosmicKrisp (Mesa
26.3.1, Apple M3 Max) that broke half_simd_reductions: each round of the half tree kept
float precision, and 224 of 256 words differed from Metal's (job m3-max-82540, pin P's
leg). The MSL KosmicKrisp emits showed no half() between rounds; with the pair decorated,
0 words differ (job m3-max-82662).

`narrow::converted` now emits each conversion with `convert_no_contraction`, as
`narrow::controlled` does. The pair relies on Vulkan's environment rule, which reaches a
conversion, where the SPIR-V specification words NoContraction for an arithmetic
instruction only; the docs state that reliance at the Controlled pair's (narrow.rs), on
QuantizeForm::Converted, and in docs/API.md's native-half-conversion entry, and that a
driver which folds a decorated pair leaves the device's own answer, within
PrecisionNote::NativeHalfConversion, which a Converted module already records. NVIDIA's
measured fold of the decorated Controlled pair stays as recorded. SEMANTICS_VERSION 2333
-> 2334: every Converted module's words change (moltenvk-m3 is the committed profile on
that form; KosmicKrisp takes it at run time).

Evidence, all on the arms of this change before the ruling:
- KosmicKrisp conformance replay on the Apple M3 Max: 53 sites that differed from Metal
  at the base now match, none added (job m3-max-82685).
- Cost: +0.46% host wall on half_mix on the M3 under KosmicKrisp, job 82685, three
  alternated rounds of 200, spread 0.03%.
- Golden tables: 216 moltenvk-m3 cells change, no other profile's (job m3-max-82679).
  They re-bless at the next named pin.

The red test (the commit before) asserts both forms' conversions are NoContraction;
it fails before this change and passes with it (the gate's jobs are in the READY note).
2026-12-03 02:10:22 -08:00
Anees Iqbal 333ae1b40f Translator: PrecisionNote::code states each note's stable degrade code
A precision note's stable code, `metal2vulkan-degrade-` and the note's
name in kebab case, was written only in the conformance crate
(degradation.rs), which is unpublished. So no published item gave a
caller the code to announce a note by, and README.md said the runtime
announces each note once with a stable code, which it does not: the
runtime records each state's notes when the state is made, exposes them
through its getters, and prints and sends none (docs/API.md section 9
says so).

- PrecisionNote::code (pipeline/artifact.rs) returns the code, one arm a
  note, as docs/API.md's catalogue names it.
- The conformance crate reads it from there: Degradation::code is its
  note's code, through Degradation::note, the inverse of
  from_precision_note. Each kind's doc names its note, not a second copy
  of the string.
- README.md's "Recorded differences" says what is true: the runtime
  records each state's notes at creation and exposes them with a stable
  code; the caller announces them. docs/API.md's catalogue lead names
  PrecisionNote::code.
- The signature table takes the method under both crates that export
  PrecisionNote.

The 83 codes are unchanged: each equals the conformance crate's string
before this commit (checked by script against its code() table), and
every_kind_is_a_catalogued_precision_note still finds each in the
catalogue. New tests: every_precision_note_code_is_its_name_in_kebab_case
(translator, serde feature: every variant read from the enum's source,
its code the kebab rule, no code twice) and every_kind_is_its_notes_kind
(conformance: note() takes from_precision_note back for every kind).
No translation, runtime or refusal changes; no runtime input changes, so
runtime-sources.sha256 stays.

Verified: rustfmt --check on the four .rs files; the job named in the
handover.
2026-12-03 01:35:25 -08:00
Anees Iqbal 7be9f00a3f Docs: only tests build the resident-table domains
The docs of DevicePolicy::RESIDENT_TABLES, PointerDomain::ResidentTable,
HandleDomain::Table, the lockstep module, docs/API.md and three test
comments said the resident form was the validation executor's alone and
that the executor builds the resident root and handle table itself, or
called it "the old runtime's, until the cutover deletes it". Neither is
true: the validation executor (engine.rs), the runtime, the command line
and the compile worker all build their device under
DevicePolicy::default(), and every RESIDENT_TABLES in the tree sits in a
test (the translator's src/tests and device tests, the validation
crate's #[cfg(test)] modules including coverage::tier_table, the
harness's tests and the validation integration tests).

The comments now say that: nothing outside tests builds the form, and
the runtime, the tools and the validation executor take the default.
Comments and docs only; no code changes.

Verified: git grep of RESIDENT_TABLES, PointerDomain::ResidentTable and
HandleDomain::Table at 8140229b9c, each hit outside the translator's own
tests read for its #[cfg(test)] scope; cargo fmt --all; the workspace
rustdoc check with -D warnings, doc 0 and private-items doc 0 on all seven crates (job
m3-max-82621).
2026-12-03 00:23:31 -08:00
Anees Iqbal 28e4da1f17 Docs: Metal's resolve rounds a tie as its GPU does, and the alpha-to-coverage note's devices at 8 samples
The planner's ruling on resolve rounding: rule 1 counts a resolve among the device's own answers,
and two Macs round an average that lies exactly halfway between two codes differently, so Metal
fixes no answer there for a guest. An Apple M3 Max (macOS 27.0.1) rounds the tie up, as the
conformance recordings sample-positions-default-2x and -4x hold (red 1/255 over half the samples
resolves to 1); an AMD Radeon Pro 5300M (macOS 26.7.1) rounds it to the even code (red 0 at 1 of
2, 2 of 4 and 4 of 8 samples, an alpha of 127.5 to 128; m3-max-82284). The device's own rounding
stands; no behaviour changes and neither Mac's rounding is emulated.

- PrecisionNote::DeviceRoundedResolve's doc and docs/API.md's catalogue entry name both measured
  answers with their sources.
- The seven known-gaps-rt.tsv rows of sample-positions-default-2x and -4x (Iris Xe, RADV, NVIDIA,
  llvmpipe) say they differ only by how a tie rounds, and why that stands;
  docs/CONFORMANCE-COVERAGE.md regenerated from them.
- PrecisionNote::DeviceAlphaCoverage's doc and its catalogue entry say exactly which devices are
  measured at 8 samples: the 5300M (m3-max-82239); the M3 Max, which renders no 8 samples and so
  has no answer there; no device the runtime runs on. They said before both that the 5300M was
  measured at 8 and that 8 was unmeasured on every device.
2026-12-02 23:19:49 -08:00
Anees Iqbal efe893738c Translator, runtime: supportsTextureSampleCount: answers 8 where the device renders it into a colour, a depth and a stencil attachment
The planner's ruling: raster_sample_counts, which supportsTextureSampleCount:,
getDefaultSamplePositions:count: and programmableSamplePositionsSupported read, is the device's
framebufferColorSampleCounts, framebufferDepthSampleCounts and framebufferStencilSampleCounts,
intersected with 1, 2, 4 and 8. A query answer, not a second form: a device that renders 8 into
all three attachments answers yes for 8, as a Mac's AMD GPU does (an AMD Radeon Pro 5300M under
macOS 26.7.1, job 82204) and Apple10 does, where the Apple9 table answered 1, 2 and 4 alone.
TEXTURE_SAMPLE_COUNTS leaves the apple_gpu table, whose other answers are Apple9's.

Nothing else capped at 4: a texture's samples are its format's own (Limit::TextureSamples), the
pipeline link maps 8, the sample mask takes a word, Vulkan's standard locations hold 8, and
interpolate_at_sample reads index & (n - 1).

Metal at 8, measured on the 5300M (job 82239), and where ours can differ:
- interpolate_at_sample: indices 0 to 9, 15, 16, 100, 2^31 - 1 and 2^32 - 1 read sample
  index mod 8, the runtime's answer; InterpolantAt::Sample's doc says so.
- Alpha to coverage: the 5300M covers a pixel at one sample at an alpha of 1/2 or above, every
  pixel alike, and at two, four and eight samples floor(alpha * n + 1 - t), t 1/8 and 3/8 at even
  and odd x of an even row, 5/8 and 3/8 of an odd one; every pixel floor(alpha * n) or
  ceil(alpha * n). The device's own mapping may differ: PrecisionNote::DeviceAlphaCoverage (and
  docs/API.md's catalogue) now states the 5300M's rule beside the M3 Max's and that eight
  samples are unmeasured on every device.
- Default positions at 8: the 5300M's answer is Vulkan's standard 8 locations.

Docs that said 1, 2 and 4: Device::supports_texture_sample_count and default_sample_positions,
the floor's standardSampleLocations line, RenderPassDescriptor::sample_positions, positions.rs,
the runtime README (default positions, the floor table) and metal_properties' field.

Verified: the stacked gate (m3-max-82337, this change on the (i)+(b) hand-over): fmt, clippy in
three configurations, rustdoc, doctests, the validation suite 1322 passed (3 skipped), the
product suite 3725 passed with the five reds development's next bless takes (none of this
change's), the runtime's lavapipe suite 974 passed (4 skipped); the red commit's tests green on
lavapipe (2 translator, 9 runtime). On an RTX 3090 (m3-max-82314), an RX 7900 XTX and a 780M
(m3-max-82315) and an Iris Xe (m3-max-82316), the same patch on 8a2acc84fb: the runtime's 9
sample-count and sample-position tests pass, each device answers yes for 8 with Vulkan's
standard 8 default positions and answers programmableSamplePositionsSupported yes.
2026-12-02 23:12:42 -08:00
Anees Iqbal 0cd07d6612 Docs: API.md states the local size contract of a kernel on subgroups, which its shuffles rely on
A translator consumer that is not metal2vulkan-runtime read nowhere in docs/API.md that a
kernel stating RuntimeFact::LocalSizeConstraint runs only threadgroups whose size is a multiple
of it, and that a dispatch at any other size runs the kernel's EmulatedSimdgroups variant. A
half simdgroup sum or product on the Direct and Cluster32 tiers now reads its sibling lanes by
xor shuffles in a block every lane executes, which name an inactive lane in a partial subgroup.
Section 6 now says so, and that the emulated variant gives Metal's answers for the partial
simdgroup, as the runtime's variant choice does (pipeline.rs: a module with multiples gets
KernelVariant::EmulatedSimdgroups).

Verified: docs only; the contract read from device::subgroup::requirement and the runtime's
variant choice.
2026-12-02 22:40:50 -08:00
Anees Iqbal a1f82878ff Translator: a half simdgroup sum or product is Metal's tree of rounded half operations on every tier
Metal's simd_sum and simd_product of half operands work as a tree. In round d (1, 2, 4, 8, 16),
each aligned block of 2d lanes holds its lower and upper halves' results, combined and rounded
to half. A lane that takes no part counts as the identity. Measured on an M3 Max, macOS 27.0.1,
our own MSL, fast math on and off alike:
- sums: m3-max-80839;
- products: m3-max-80879;
- three masks of active lanes: m3-max-80890.

The Direct and Cluster32 tiers folded the f32-held values with OpGroupNonUniformFAdd or FMul and
rounded once. Rounding once misses five of the eight measured sums (0x3c10 where Metal answers
0x3c0f), four of the eight products, and ten of the 48 masked results. The emulated tier's
exchange rounds already were the tree.

group::half_fold:
- New form. Five rounds; each combines the lane's partial with its sibling block's partial
  through half_step.
- In a block every lane executes, the sibling partial comes from OpGroupNonUniformShuffleXor
  by d. A mask below 32 stays inside a Cluster32 cluster.
- Where the group may be partly live, the sibling partial is the first active lane of the
  sibling block, read with the live lanes' ballot. A block with none leaves the lane's own
  partial: the identity, as the masked probe measured.

half_step:
- On a module that computes half under the 16-bit float controls, it is ops::f16_binary. That
  is the device's 16-bit instruction, whose rounding survives a driver that folds a
  conversion's round trip (NVIDIA's does).
- Elsewhere it is ops::float_binary.
- This is the same choice half + and * make.

There is no 16-bit route for group operations: half group ops run on f32-held values on every
profile, so this covers every route.

Other changes in this commit:
- reads_lanes is true for these operations, so partly_live tracks them.
- direct_ops and cluster_ops need the shuffle class; partly_live adds the ballot.
- words() bounds the five rounds.
- A half simdgroup sum or product no longer records PrecisionNote::ReductionOrder. float and
  double sums and products, every float prefix sum or product, and the matrix and AGX
  multiply-adds still record it.
- The note's doc and docs/API.md's catalogue entry say this per route. They also record that
  Metal's half prefix-sum order is not measured: it matches none of f32 rounded once per lane,
  a lane-order chain of half additions, or a Hillis-Steele scan of them (m3-max-80839).
- Validation's REDUCTIONS table drops simd.reduce.fadd.half and simd.reduce.fmul.half, so a
  comparison holds them exactly. Its tests now name the half scan.
- bfloat has no group operations: decode refuses them.

SEMANTICS_VERSION 2325 -> 2326.

Tests:
- lower::simd::tests::half_sums_and_products_are_shuffle_trees covers the classes and the
  lane reads.
- engine_simd's float_sums_record_their_precision now holds that a float sum records the note
  and a half sum does not.
- The red tests of the previous commit carry Metal's bits.

Verified: cargo fmt only on this host. The red and green device jobs, and the timing on a real
half-reduction kernel, follow before landing.
2026-12-02 22:40:48 -08:00
Anees Iqbal 740d12b3a6 Texture buffers: the twin's docs, the player's twin gauges and metrics, and B5G6R5Unorm harness rows
AGENTS rule 2's texture buffer form and the runtime's README name the stage constant, the words
twin made in the same make as each plain pipeline, what picks it, and its second compile and
memory as the form's known gap; docs/API.md and RESOURCE-ID.md name the gate.

The replay player prints the word pipelines' and word-held texture buffers' gauges and the
twins' makes and time beside pipeline_creation_nanos.

The harness's texel_buffer_b5g6r5_write and texel_buffer_b5g6r5_read rows time a format the lab's
cards hold as words, a 2-byte texel written by two atomics and read through the words' routine,
checked against the CPU's exact conversion and decode.

Not built yet.
2026-12-02 22:11:25 -08:00
Anees Iqbal 7cdaa1cc3f Texture buffers: each device holds a format as words only where it lacks the format's own view for an access
metal::format::texel_buffer_form is the one place that decides, per format and device: the
format's own view where the device holds it directly as a uniform texel buffer, a storage texel
buffer and a storage texel buffer written without a format; else words where it has a word
layout; else its own view of the first two (whose writes the runtime refuses). The resource ID
word is unchanged and the same on every device; a module takes the codes its profile holds as
words (texel_buffer_word_codes) and tests a word's code against them, emitting nothing of the
words where the profile holds none so. The routines' cases and the precision notes follow those
codes. The runtime's texel_form takes the same answer. AGENTS.md rule 2 gains the fourteenth
form; the runtime's README records the words' cost (7.3x the own view's GPU time for an R8Unorm
texture buffer written on an RTX 3090, job m3-max-80580).

This commit alone was not built; the series is checked at its tip.
2026-12-02 22:11:24 -08:00
Anees Iqbal 0ad55e1468 Docs: the texture buffer word, the formats held as words, their notes; test vectors of the texture buffer word
RESOURCE-ID.md gains the texture buffer word (TextureWord::of_texture_buffer: bits 0-1 padding,
2-7 the code, 8-9 texels per word, 10 a texel of two words; the 39 codes in order) and drops its
stale line that a texture buffer has no index. The runtime's README says which formats a texture
buffer holds as words and which it still refuses; the KosmicKrisp BGRA8Unorm gap is gone. API.md
and PrecisionNote's docs say a texture buffer held as words records SrgbTexelDecode and
DevicePackConversion for its float reads and writes, and that its other conversions are exact.
tests/resource_words.rs writes texture buffer lines (format, width, word); the table is blessed
in a later commit. REFUSALS.md regenerated (one more TextureFormat site).
2026-12-02 22:11:24 -08:00
Anees Iqbal 39423d92f1 ICB: a kernel's indexed patch draws into an indirect command buffer, executed through a layout of indexed patch draws
The owner's 3406 order, the planner's next indirect command kind: MTLIndirectCommandTypeDrawIndexedPatches.

The records (pipeline::IndirectDrawLayout) grow by 8 bytes a command for every kind. The
control-point indices' address is a third u64 that an execution pushes, and VUID 11103 asks each
token's offset to be at or past the one before it, with the draw token last (VUID 11100). So the
address cannot go after the draw; it lies past the index token's 16 bytes, at index() + 16.
Every command's tail is now 16 + 8 + 4 + 20 = 48 bytes: the stride is index() + 48 (was + 40),
the sequence index's place index() + 24 (was + 16), and the draw's arguments index() + 28 (the
translator's DRAW_AT, was 20). The cost is 8 bytes a command in every buffer: 160 bytes for 7
vertex and 7 fragment slots (was 152, 5% more), 48 for none (was 40), 544 at most (was 536),
which the floor's stride and token-offset limits are checked against. One record shape for every
kind stays: a kernel cannot know a buffer's kind when it is translated, so it writes one shape
whatever buffer it reaches. The main lane accepted this on the condition that the
already-landed kinds' rows run again at the new layout.

Translator (lower/access/icb.rs): a render_command's draw_indexed_patches writes what
draw_patches writes (the draw's VkDrawIndirectCommand of patches, the factors' and the patch
indices' Metal addresses) and the control-point indices' Metal address at the new place
(CONTROL_POINTS_AT, IndirectDrawLayout::control_point_indices). Its operands are draw_patches's,
with the control-point indices at operand 6.

Runtime: Device::new_indirect_command_buffer takes DRAW_INDEXED_PATCHES alone
(CommandDraw::IndexedPatches), refused as patch draws are on a device whose executions run no
tessellation stage (TessellationStages). Its layout pushes the control-point indices' address
where the control stage reads it (FieldValue::ControlPointIndices), holds no index buffer token,
ends in TOKEN_DRAW and names the tessellation stages. An execution checks the state's
control-point index type against the buffer's kind, as a direct draw checks it against the call:
patch draws with a state of an index type are Refusal::PatchDrawWithIndexType, and indexed patch
draws with a state of none Refusal::IndexedPatchDrawWithoutIndexType. This replaces the patch
draws' check through an empty PatchReads.

Docs: the runtime README's ICB section (records, tokens, refusals, floor limits); the API guide's
section 1; METAL-COVERAGE (coverage.tsv); CONFORMANCE-COVERAGE and REFUSALS.md regenerated (the
two refusals gain the draw site); the API signature table blessed for control_point_indices.

Tests: the red commit's engine and runtime device tests; the layout's unit tests at the new
offsets, the reset command's control-point place among them; a unit test of the indexed patch
tokens.
2026-12-02 21:09:00 -08:00
Anees Iqbal 08447f8aff ICB: a kernel's patch draws into an indirect command buffer, executed through a layout of patch draws
The owner's 3406 order, the planner's next indirect command kind: MTLIndirectCommandTypeDrawPatches.

Translator (lower/access/icb.rs): a render_command's draw_patches writes VkDrawIndirectCommand (the
patch count, the instances, the patch start and the base instance) where a plain draw's goes, and
in the index token's 16 bytes, which a buffer of patch draws does not read as a token, the
tessellation factors' Metal address and the patch indices' (0 for the null pointer). The records
stay one shape for every kind (pipeline::IndirectDrawLayout::factors and ::patch_indices name the
two places). The control-point count is not read, as a direct patch draw does not read it; the
factors' instance stride and the factor scale are read only under a per-instance step function or
tessellationFactorScaleEnabled, which the runtime refuses at the pipeline state. A
post-tessellation vertex function of a state made for indirect command buffers is compiled under
LoweringInputs::indirect_range (pipeline/compile.rs), so each evaluation tests its command against
the execution range as a plain vertex function does.

Runtime: Device::new_indirect_command_buffer takes DRAW_PATCHES alone, the buffer's kind
CommandDraw::Patches. Its command layout pushes the factors' and patch indices' addresses where
the state's control stage reads them (FieldValue::TessellationFactors, FieldValue::PatchIndices),
holds no index buffer token and ends in TOKEN_DRAW; the layout and each execution name the
tessellation control and evaluation stages beside the vertex and fragment ones
(dgc::PATCH_STAGES). An execution of patch draws draws a patch list with a post-tessellation state
and reads no tessellation factor buffer of the encoder's; a state that is not post-tessellation
is Refusal::PatchDraw, as is a post-tessellation state with a buffer of other draws, and a state
of a control-point index type Refusal::PatchDrawWithIndexType, as for a direct patch draw.

VUID-vkCmdExecuteGeneratedCommandsEXT-supportedIndirectCommandsShaderStages-11060 requires the
bound stages in the device's supportedIndirectCommandsShaderStages, so the floor reads whether
they hold the tessellation stages (IndirectCommandLimits::tessellation_stages) and a buffer of
patch draws is refused without them, a new kind, IndirectCommandsKind::TessellationStages.
Mesa's source answers VK_SHADER_STAGE_ALL_GRAPHICS on RADV and VK_SHADER_STAGE_ALL on lavapipe.

Two draw kinds together, DRAW_INDEXED_PATCHES and the rest stay CommandTypes.

Docs: the runtime README's ICB section and refusal line; the API guide's section 1; METAL-COVERAGE
(coverage.tsv); CONFORMANCE-COVERAGE regenerated; the API signature table blessed for the new
field, methods and variant. REFUSALS.md regenerated with no change.

Tests: the red commit's engine test and runtime device test, with the device test's arm for the
TessellationStages refusal; a unit test of the patch tokens; the floor's limits test reads the
tessellation stages.
2026-12-02 21:06:54 -08:00
Anees Iqbal 3f6967e92a API guide: a function's draw_primitives of triangles writes an indirect command's record too
docs/API.md section 1 listed the render_command operations a function writes under the identity
domains; draw_primitives of triangles joined them in d14977bfcf. Its arguments go where an indexed
draw's do. Docs only.
2026-12-02 21:06:03 -08:00
Anees Iqbal 59326c8dff Translator: half computes in 16 bits where only 16-bit DenormPreserve is missing, noting half denormals
The planner's ruling (T3). On a device with shaderFloat16, 16-bit RoundingModeRTE and 16-bit
SignedZeroInfNanPreserve whose only missing 16-bit control is DenormPreserve, the half operations
narrow::half_controls gates take the 16-bit route: a half + - * / sqrt and fused multiply-add on
the device's 16-bit instructions, half values held at 16 bits, the controlled pair for a float
rounded to half, and a half widened from and narrowed to its bits by the device's conversion.
It is the 16-bit floats query's existing form, read from one more of its properties.

narrow::controlled_modes declares RoundingModeRTE and SignedZeroInfNanPreserve for 16 bits there
and no denormal mode: not DenormPreserve for 16 bits (VUID 06296), nor the 64-bit one the
independence for 32 bits only ties to it (VUID 06289 asks for the same denormal mode at 16 and
64 bits). The independence rules decide which devices take it as before, and a device missing any
other 16-bit control keeps half in float.

MoltenVK on the M3 stays off the route: its denormal modes are not independent at all
(denormBehaviorIndependence NONE), where the form would tie float's denormal mode to half's and
change how the module's float arithmetic reads denormals, which Metal flushes; and its rounding
modes are not independent while it offers no 64-bit RoundingModeRTE, so the 16-bit
RoundingModeRTE the form declares cannot be declared at every width as VUID 06292 asks.

Every module that declares those controls on such a device (narrow::flushes_half_denormals)
records the new static note PrecisionNote::DeviceHalfDenormals, "half denormals may flush to
zero where Metal preserves them": the Vulkan spec leaves a 16-bit denormal to the device in an
entry declaring no 16-bit denormal mode. No other module records it. The conformance suite holds
its code, metal2vulkan-degrade-device-half-denormals, among the native notes beside
device-denormals (the device's own denormals, the one form built there); validation allows it
unbounded, as it does NativeHalfConversion.

Run on lavapipe, whose committed profile has this shape: its half arithmetic moves from float to
16 bits. Turnip on an Adreno GPU before the 8xx series reports the same controls (Mesa 26.3.1,
tu_device.cc lines 534, 1038-1048: shaderFloat16, RTE and SignedZeroInfNanPreserve for 16 bits,
DenormPreserve for 16 bits false below A8XX, independence ALL): not measured on a tile-based
phone GPU; no such device in the lab. No performance claim is made.

Tests: engine_native_half's new test (the red commit before this) now also asks for the note on
each such module and for none under all three controls or without another one. The tests that
held lavapipe as the conversion form now hold it under the controls (engine_native_half's
rounding kinds, memory and decode widenings and controlled modes; engine_half_hold's held values
and division; engine_arith's 16-bit fma profiles), and the conversion form on lavapipe's
description without 16-bit RoundingModeRTE.

SEMANTICS_VERSION 2325 (development holds 2323; 2324 is mad's), and ARTIFACT_FORMAT_VERSION
601 -> 602 (the new note's codec member). Golden rows are blessed at the pin.

Docs: the precision-note catalogue (docs/API.md, the new entry and the conversion entry's
controls), docs/HOWTO.md, the runtime README's shaderFloat16 row and its half fma line, the
NativeHalfConversion note's device list, api_signatures.

The conformance ledger. The form moves lavapipe, whose float controls lack only 16-bit
DenormPreserve, onto the 16-bit route. The conformance replay in the pinned lavapipe image (Mesa
26.2.4, LLVM 23.1.1) then answers 79 of the runtime ledger's llvmpipe rows otherwise:

- 47 now match Metal and are dropped: vertex-format-half4 28 and integer-vertex-attributes 16
  (the rows said lavapipe folds the unrounded OpFConvert pair, with no 16-bit DenormPreserve to
  make it Metal's; the pair now rounds under the 16-bit controls), and half-texel-nans-rg11b10f's
  3 (nearest-sample, read, widened).
- 32 now answer otherwise and are replaced, each with the answer and a reason written from this
  run's printout (first differing element):
  - vertex-format-half4, 8 rows (Float..Float4, Half..Half4): only the NaN differs now, Metal
    0x7fc00000, the device 0xffc00000; one element per component, where the rows recorded the
    unrounded values (Float, the largest difference inf) or the kept payload (Half).
  - half-texel-nans, 18 rows (nearest-sample, read and widened of r16f, rg16f, rgba16f, r32f,
    rg32f, rgba32f): a 16-bit float texel's NaN now narrows to 0x7e00 (the payload dropped, as
    read-through-sample already answered; Metal hands back the texel's code); a 32-bit one to
    0xfe00 (Metal 0x7e00); the widening answers 0xffc00000 (Metal 0x7fc00000). Six rows count more
    elements than before (the 16f nearest-sample and read rows: 215 -> 472, 428 -> 940,
    852 -> 1874), twelve fewer.
  - bicubic-texel-classes, 6 rows: fewer elements at every site, each count and largest
    difference the one the 780M and RTX 5080 rows record; within the bicubic note's bound.
  None of the 79 is a half denormal.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py): ledger rows
7932 -> 7885. The image is the pinned one, so the ledger's llvmpipe line does not move.

Not replayed, a follow-up: the six bicubic-texel-classes rows of venue "llvmpipe (LLVM 23.1.4,
256 bits)", a lavapipe outside the pinned image; this commit leaves them as they were.

Verified: the replay of this tree without the ledger edit, job m3-max-80972 (pinned lavapipe
image): exit 1 with row differs 32, now answers otherwise 32, now matches 47; the rows are written
from its printout. The same counts in job m3-max-80871 (the pre-rebase fix, against its base,
which exits 0). coverage.py --check: as derived.

No lab card's translation moves. The golden blesses at development (15898e612e) and at this
change, over the committed profiles plus the RX 7900 XTX's vulkaninfo --json capture (job
m3-max-80916), compared cell for cell, job m3-max-81006 (macOS, every fixture, 3624 rows): every
column but lavapipe, gate-lavapipe and gate-lavapipe-x86_64 (471 cells each) is equal, among them
the XTX capture, amd-780m-radv, amd-780m-hawkpoint-radv, intel-irisxe-rplp-anv,
intel-irisxe-anv and moltenvk-m3; no profile fingerprint moves (job m3-max-80958, the
same over the 1910 rows a Linux host assembles, agrees). Not run on an RTX 3090: its column is
owed until the card is back.

Gate at this tree, job m3-max-80990: clippy -D warnings plain, under m2v_cpu_icd and under m2v_gpu
0; rustdoc -D warnings 0, and with private items for metal2vulkan 0; the runtime's suite on
lavapipe 945 passed, 4 skipped (whole suite); translator and AIR 3415 passed, 37 skipped (the
golden hash table, the fixture inventory and the engine printouts excluded: their bless is due at
the pin); validation 1319 passed, 3 skipped; conformance 1048 passed. CI's lavapipe steps in the
pinned image, job m3-max-81012: device tests 841 passed (843 listed), the conformance replay exit 0
(the 4640 gaps the ledger expects, exactly), public case qualification exit 0.
2026-12-02 17:49:23 -08:00
Anees Iqbal 9f42b4c1f3 Translator: OpenCL C's mad is its multiply and its addition, each rounded on its own
Apple's OpenCL compiler spells OpenCL C's mad(a, b, c) as air.mad.<T>. No
family decoded it, so a kernel that calls it (a real OpenCL workload's
image-scaling kernel, air.mad.f32 in AIR 2.8) was refused as
UnknownIntrinsic. OpenCL C leaves how mad rounds its product to the
implementation. The M3 Max's GPU rounds the product and then the sum.

- Decode: MathFn::Mad, which Math::parse reads from air.mad.<T> for the
  three types the compiler was measured to spell (MAD_TYPES: f32, v4f32,
  f16), each T (T, T, T), always Precision::Precise. Every other type
  (v2f32, v3f32, v8f32, v4f16, bf16, i32) and spelling (fast_mad,
  native_mad, a sign token) stays undecoded, as the planner ruled. mad is
  not a TABLE stem, so Math::float_stems (Metal's own functions) is
  unchanged.
- Lowering, the planner's option (2): canon::routine, which already
  rewrites the frexp and ilogb routine calls into plain AIR after SCCP,
  now replaces each mad call with an fmul of a and b followed by an fadd
  of that product and c. Both carry no fast-math flags, whatever the
  call's own flags are. Lowering then gives them exactly what an
  unflagged fmul and fadd get: NoContraction on each, the profile's half
  form, and no new note. air_math's invariant arm (Frexp, Ilogb) now
  takes Mad too.
- Which form is smaller: the canonicalization. The families rows need a
  DeclClass::Air, so MathFn::Mad cannot be avoided, but the rewrite
  reuses the routine pass's expander, about 40 lines. A lowering of its
  own would need a new FloatFn and its half forms.

Evidence, with its caveat as it is:
- Spellings come from Metal's OpenCL mode (newLibraryWithSource with
  sourceLanguage 1, macOS 27.0.1, AIR 2.9), over our own kernels on the
  M3 (job m3-max-80752).
- Answers come through the OpenCL framework on the M3 Max's GPU (job
  m3-max-80759), not through a Metal pipeline of OpenCL mode:
  - float, at a = b = 1 + 2^-12 and c = -(1 + 2^-11): mad answers 0,
    fma 2^-24, and a*b+c 2^-24;
  - float4: each lane of mad answers 0;
  - half, at a = b = 1 + 2^-6 and c = -(1 + 2^-5): mad answers 0 and
    fma 2^-12.

Tests:
- families_tests OBSERVED rows (previous commit, red).
- intrinsics::tests::opencl_mad_decodes_in_its_measured_types_alone.
- engine_arith::opencl_mad_is_its_multiply_and_its_addition, over our
  own .ll on the three profiles:
  - each mad kernel's linked SPIR-V has the same opcodes as its twin
    written as an unflagged fmul and fadd, with the same notes;
  - the float and float4 kernels have OpFMul and OpFAdd, each
    NoContraction, and no Fma;
  - the interpreter answers 0 on the probe's inputs.
- runtime opencl_data::opencl_mode_mad_rounds_its_product_and_its_sum, a
  kernel of OpenCL mode: +0 on the float, on each float4 lane and on the
  half, under a device cfg.

Public surface: MathFn gains Mad (api_signatures.tsv blessed), so an
exhaustive match over MathFn in a consumer breaks. docs/REFUSALS.md was
regenerated and is unchanged. docs/API.md lists mad beside the OpenCL C
native_ and half_ functions.

SEMANTICS_VERSION 2323 -> 2324: a module that calls air.mad translated to
a refusal before and translates now. The authoring classification follows
on its own, since its key fingerprints the product's sources
(ANALYZER_ABI), so no census version needs a bump.
2026-12-02 17:49:11 -08:00
Anees Iqbal dec74d9cf7 Translator: a tessellation refusal names the structure it met
Feature::Tessellation with Needs::NotImplemented covered fourteen refusal
sites behind one name, so a walk's log line ("the translator refused the
feature Tessellation, needing NotImplemented", cause None) could not say
which without the AIR. A tessellation refusal now carries
Cause::Tessellation(TessellationCause), one variant per structure the
sites refuse, the way an access refusal names its AccessCause; sites that
refuse the same structure share a variant, none is named by a file, a line
or a string of its own:

- PatchStep: a layout stepping per patch or per patch control point read
  by a vertex function that is not post-tessellation (metal/vertex.rs
  fetch_as, fixed-function input; lower/stage_io/fetch.rs, the pulled
  fetch).
- PatchInterface: a patch input or a patch builtin in a function that is
  not post-tessellation (lower/stage_io/plan.rs, two arms).
- UncountedPatch: [[patch(kind)]] with no count, or a count of 0 whose
  control points are read (lower/tessellation plan_entry and select).
- InstanceStepRate, AttributeStep: a patch attribute per instance at a
  rate above 1; a step the attribute's input has no element for.
- Builtin, VertexInput, SimdGroup: another builtin, a vertex input, or
  SIMD-group semantics in a post-tessellation vertex function.
- ControlPointInput: the AIR front end's Tessellation, which is that one
  structure (its two arms in canon post_check); the conversion from the
  front end's refusal names it, so the front end's types are unchanged.

lower/tessellation's not_implemented() helper takes the cause, so the
compiler makes each of its sites name one; thirteen of the fourteen arms
name a cause. The fourteenth, the control-point index type
on the address form (pipeline/link/tessellation control_plan) is left as
it is: the drawIndexedPatches change removes that arm.

Feature stays Tessellation, so validation's outcome key (feature_key, the
Debug of the feature) and the census are unchanged; nothing stores the
cause (as for the access cause). No version bump.

Tests: the error module's Display test of a tessellation refusal and of
the front end's conversion; the cause asserted at the fixed-function and
pulled patch-step refusals (metal/vertex.rs, engine_vertex_fetch), the
uncounted patch (reflection), post-tessellation SIMD-group functions, and
a new test of a control-point layout stepping per patch, a patch layout
stepping per vertex (AttributeStep) and per instance at 2
(InstanceStepRate). The commit before this one adds those tests against
the cause-less sites.

runtime-sources.sha256 rewritten: metal/vertex.rs's refusal names its
cause, and no run behaves otherwise. api_signatures blessed
(TessellationCause, Cause::Tessellation), api_surface lists the enum,
REFUSALS.md regenerated (the sites are built through error/mod.rs's
Unsupported::tessellation), docs/API.md's error table names the cause.

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 33784022f1 and its lane tips of the last day):
Feature::Tessellation and TessellationCause, 0 hits.
2026-12-02 16:51:29 -08:00
Anees Iqbal 082248f947 Translator: the address form reads patch and control-point indices through their pushed addresses; a fragment's primitive id is the patch's position
Under the identity domains (the runtime's), a post-tessellation function's
control stage reads its factors through their pushed address and binds no
buffer. It had no way to read a patch index buffer or a control-point
index buffer, so it took each patch's index from its position and refused
a control-point index type (NotImplemented(Tessellation)). The viewer's
two pipelines are UInt32 control-point indices drawn by
drawIndexedPatches, and both were refused.

The control stage's push range now holds, at its offset:
- 0: the factors' address (u64), as before;
- 8: under a control-point index type, the control-point index buffer's
  address plus its offset (PushField::ControlPointIndexAddress, u64);
  otherwise the per-instance step's stride at 8 and the scale at 12, as
  before;
- 16: the patch index buffer's address plus its offset
  (PushField::PatchIndexAddress, u64), 0 for a draw without one.
24 bytes in all, below the post-tessellation function's window
(push::TESSELLATION_BASE). A control-point index type beside a
per-instance factor step or an enabled factor scale has no room for both,
and stays NotImplemented(Tessellation) (control::address_fits); the
runtime refuses those two at state creation anyway.

What the stage reads, from the Apple M3 Max's tables (jobs m3-max-80366
and m3-max-80398):
- the patch at position p (patchStart plus its place in the draw) reads its
  factors at p, whatever its patch index;
- its [[patch_id]] is the uint at index p of the patch index buffer where
  the pushed address is not 0, else p;
- control point j of patch pid is the vertex the index at pid * N + j of
  the control-point index buffer names (a ushort read out of its aligned
  word for UInt16, a uint for UInt32), else pid * N + j.
Each read goes through the address unchecked, as the factor reads do. No
check form is added.

A fragment function's [[primitive_id]] behind the stage is the patch's
position, with a patch index buffer or without (the same tables): the
control stage writes p to a flat varying at PATCH_POSITION_LOCATION (3),
which the evaluation stage hands on, and the control point varying moves
to location 4. Before, the varying carried the patch index, which equals
the position only without a patch index buffer.

The cache codec carries the two new push fields: ARTIFACT_FORMAT_VERSION
601. Translation output changes for every post-tessellation pipeline
under the identity domains: SEMANTICS_VERSION 2323 (2322 is split-store's).

Tests: control/tests.rs runs the address form's patch index and control
points on the SPIR-V interpreter (both index types, a nonzero and a zero
patch index address) and checks the pushed fields of each form;
engine_tessellation compiles the stream's state under UInt16 and UInt32
on every committed profile with the identity domains, with the fields at
0, 8 and 16, and refuses UInt32 beside a per-instance step or a scale;
lower::push checks the range fits below the window for every step, scale
and index type the form takes.
2026-12-02 16:25:21 -08:00
Anees Iqbal a3fb852de3 rt: a heap makes texture buffers in place in its bytes
Metal's heap makes a texture buffer (MTLTextureTypeTextureBuffer): heapTextureSizeAndAlign
answers its texels' bytes at an alignment of 16, and newTextureWithDescriptor:offset: lays the
texels linearly in place at the offset (m3-max-80369, m3-max-80398). rt refused both with
Refusal::TextureBufferNotOverBuffer.

Now:
- Device::heap_texture_size_and_align of a texture buffer answers width x texel bytes, unrounded,
  at 16, or at the device's texel-buffer offset alignment for the format where that is larger
  (minimum_texture_buffer_alignment). No Vulkan call.
- Device::new_heap_texture and new_heap_texture_for_views of a texture buffer place a buffer of
  those bytes at the offset as new_heap_buffer places one, and make the texture buffer over it as
  Buffer::new_texture makes one, through the same texel_texture: one buffer view, one form on
  every device, no query. It takes the heap buffer's heap id and placement, so its uses are the
  heap's in the hazard sets and its writes mark the heap's aliasing textures stale.
- Its backing is TextureBacking::Texture, as Metal answers its buffer with nil.
- A placement past the heap or off the alignment is Refusal::HeapTexturePlace. A heap in an
  exported block makes one too: a buffer view needs no image.
- texel_texture's descriptor checks move to texel_shape and texel_width, shared with the size
  answer.

TextureBufferNotOverBuffer stays for new_texture, new_texture_for_views, new_managed_texture and
new_drawable_texture. The test also checks HeapTexturePlace at offset 8 and past the heap's end.

Docs: the runtime's README (textures, heaps, exported blocks), docs/API.md's heap-size accepted
difference, the refusals' docs; docs/REFUSALS.md regenerated.

Conformance ledger (docs/CONFORMANCE-COVERAGE.md regenerated):
- 22 rows of a one-level RGBA8Unorm, R8Unorm or RGBA16Float texture buffer's heap size in the
  texture-pairs cases are dropped: the replay now matches them;
- 6 rows of a texture buffer of 2 or 7 levels now record Refusal::TextureLevelCount, as
  Buffer::new_texture refuses it, where Metal's heap answers one level's footprint;
- 11 rows of RGBA16Float_XR, YCBCR8_420_2P, Unspecialized and BGRA4Unorm texture buffers' heap
  sizes now record Gap::TextureFormat;
- the device's newTextureWithDescriptor: rows keep TextureBufferNotOverBuffer, their reason
  naming the heap as the other way to make one.

Verified (the change at 6d5f748347 on 787fbbb061, then this commit rebased onto development
8a2f155883, the same change):
- red: the test fails at heap_texture_size_and_align on llvmpipe (job m3-max-80460) and on the
  RX 7900 XTX and the 780M (m3-max-80461);
- green: it passes on llvmpipe, whose 6 dispatches reach the buffers at their addresses
  (m3-max-80460), and on the RX 7900 XTX and the 780M, bound (m3-max-80461). Each device's
  texel-buffer alignment for R32Uint is 4, so all three answer 16 at 16;
- the conformance replay matches known-gaps-rt.tsv: llvmpipe, every case (m3-max-80487, and on
  this tree m3-max-80503); the RX 7900 XTX, the 8 cases the ledger edit touches (m3-max-80488);
  the conformance suite, 1047 passed (m3-max-80493);
- on this tree (m3-max-80502): signatures, refusals, both coverage checks, fmt, clippy plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc and private rustdoc, all 0; the runtime suite on
  llvmpipe 942 passed, 1 failed, 4 skipped. The failure,
  private_sinks::every_device_keeps_a_store_past_a_private_array_off_its_words, fails the same
  at development 8a2f155883 without this change (m3-max-80535) and passed at 787fbbb061 with it
  (m3-max-80462, 940 passed).
2026-12-02 16:25:21 -08:00
Anees Iqbal 511f31b0ba Translator: an index past an array field's array sends its private-arena access to the sink, not onto the last element
a992aa6929 bounded a GEP into an array field of a thread variable to its
array, so a struct holding handles beside a run-time-indexed array closes
as a forwarding cell. In the private arena it held every run to that bound
by clamping each run-time index to the array's last element. A store past
the array then landed on the array's own last word. The runtime's
private_sinks contract wants such a store kept off every word a thread
reads, as a store past a private array is. On lavapipe at development
8a2f155883 (job m3-max-80535),
every_device_keeps_a_store_past_a_private_array_off_its_words failed: the
fold over the arrays moved by about 193,700, which is b[k]'s store of
t + 200000 over b[N - 1]. The same test at 8a2f155883 with a992aa6929
reverted (scratch tree, job m3-max-80554) is the cause check.

The bound only promises that no run reaches outside the variable; where an
out-of-range index lands is undefined in MSL. So the GEP's offset is now
the sink's, 2^32 - 1, where any run-time index is above its array's last
element: ULessThanEqual per index, LogicalAnd across them, and one select.
No arena holds that offset, so the access's existing containment check
makes it a zero load or no store, as an access past a private array is,
off the array's words and every other's. The forwarding analysis keeps
relying on the in-field assumption alone (memory::provenance, unchanged).
parked_heap_handles' run-time-indexed array fields stay bounded and the
struct still closes (access.private.gep.array, 3 uses).

docs/API.md's accepted difference says it: a read past the end of an array
field reads zero and a write is dropped, in the private arena as in a
variable of its own. The local, provenance and parked-handles docs say the
same. The device-arena budget test's run-time-index shapes cost one
instruction more than the clamp (a compare and a select in place of a
UMin): bounds 14, 13 and 25. SEMANTICS_VERSION 2321 (development holds
2320).
2026-12-02 15:16:20 -08:00
Anees Iqbal e93d7e6b1b Docs: a fragment's primitive id behind tessellation is the patch's position without a patch index buffer
The evaluation stage's varying carries Metal's patch index, which is the
patch's position in its draw only where no patch index buffer is bound. With
one, Metal's [[primitive_id]] stays the patch's position while its patch
index is the buffer's entry (an Apple M3 Max, job m3-max-80366), so the
docs now say which draws the varying's value is Metal's for, and that the
runtime records no patch draw through a patch index buffer
(DrawKind::PatchIndexBuffer stays refused). The translator module docs,
lower_inputs, the tessellation link module, docs/API.md and the runtime
README say so; no code changes.

Doc lines past 100 columns in stage_io/plan.rs, lower_inputs.rs, the
tessellation link module and the engine_device_arena and engine_draw_bases
tests are rewrapped, and the patch test's println is shortened under the
limit.
2026-12-02 14:41:35 -08:00
Anees Iqbal 5689683788 Translator: a fragment function's primitive id behind a post-tessellation function is the patch's position
Behind an evaluation stage, Metal's [[primitive_id]] is the patch's position
in its draw, patch start included, the same in every instance and for every
triangle the tessellator makes of the patch (an Apple M3 Max, job
m3-max-80266: draws of two patches from patch 0 over two instances read 0
and 1 in both instances; two patches from patch 2 read 2 and 3). Vulkan's
PrimitiveId there counts the draw's patches from 0 and restarts in each
instance (the specification's PrimitiveId: "The index of the first primitive
generated by a drawing command is zero ... reset to zero between each
instance drawn ... In a fragment shader, it will contain ... the value that
would have been presented as input to the geometry shader had it been
present"), so it differs once patchStart is not 0. The translator refused
such a pipeline at link, NotImplemented(Tessellation), which a walk's
pipeline met behind its post-tessellation [[base_instance]].

The fragment function now reads it through the primitive ID's flat varying
(IoRole::PrimitiveId), on every device, one form: a post-tessellation
vertex function compiled under LoweringInputs::primitive_id_varying writes
Metal's patch index, its patch input at PATCH_INDEX_LOCATION, to that
varying at each return (stage_io::PrimitiveIdStore::Patch). Without a patch
index buffer the patch index is the patch's position; the runtime draws no
patches through one (DrawKind::PatchIndexBuffer stays refused), and the docs
state the value for draws without one. The same value
reaches every vertex of the patch, so the provoking vertex does not matter.
Device::compile_render_pipeline and the render keys decide the varying for a
post-tessellation vertex stage as they do on a device without a fragment
PrimitiveId; the library answers that without decoding the function (a
metallib function's TESS tag, a module entry's air.patch), and a compiled
stage from its interface. Link refuses a fragment function compiled to read
Vulkan's PrimitiveId behind an evaluation stage as NeedsInput(PrimitiveId),
where it refused every such fragment as NotImplemented(Tessellation);
docs/REFUSALS.md is regenerated.

The varying takes a location as any other: the evaluation stage's outputs
are held to maxTessellationEvaluationOutputComponents when it is planned,
and link numbers the fragment's inputs below maxFragmentInputComponents / 4,
each a typed InterfaceComponents limit refusal past it.

Tests: a_fragment_primitive_id_behind_tessellation_is_the_patch_index_varying
(MoltenVK's and RADV's profiles: the evaluation stage reads the patch-index
input, the fragment stage one flat input and no PrimitiveId, L3), the link
test of a fragment that reads Vulkan's PrimitiveId, and the runtime test
every_device_reads_a_patch_s_position_as_its_fragments_primitive_id, green on
lavapipe (llvmpipe), job m3-max-80338.
2026-12-02 14:41:35 -08:00
Anees Iqbal a992aa6929 Translator: a GEP into an array field of a thread variable stays inside its array
A thread struct that holds pointers or heap handles beside an array field
indexed at run time was open to pointer forwarding: provenance made the
offset of any run-time index unknown, so the data access could overlap a
pointer slot. A heap handle stored into such a struct then fell to the
handle family's catch-all, Lowering(Access). That is the refusal of a
post-tessellation vertex function a walk met (two render pipeline states
refused).

The Metal Shading Language leaves an index past an array undefined. So a
thread-space getelementptr whose first index is a constant, each of whose
run-time indices steps over an array its own type path names, and whose
every use is a load or store address, is a GEP into an array field
(provenance::array_geps). Over a base whose roots are stack allocations at
constant offsets, its offsets are its displacement plus at most
(len - 1) * stride per run-time index. These keep unknown offsets: a
flattened offset (a run-time pointer index), a run-time vector lane, an
address another GEP offsets or that is merged or stored, a base that may
be null, and memory outside the thread space. A run-time index at a struct
level has no IR form.

Lowering holds every run to the bound. In the private arena, where
objects lie side by side, such a GEP takes each run-time index as
min(index, len - 1) (access.private.gep.array). A typed object's access
already never leaves its levels. docs/API.md records the accepted
difference: an index past the end of an array field of a local struct
does not reach its neighbouring fields; it is undefined in MSL. The
struct then closes as a forwarding cell, and its heap-handle stores that
no load reads take the cell's unread store (the previous commit).

Verified:
- red: m3-max-80079, b9d9dfc9ba (parked_heap_handles refused at its
  handle store, block 0 instruction 11).
- green: gate m3-max-80143 at the same tree on a scratch branch
  (lavapipe tests 47 passed; validation 1315 passed, 3 skipped;
  conformance 1047 passed; the translator suite's only failures are the
  tables development re-blesses: the engine inventory with four new
  parked_heap_handles rows, the golden printout, and 315 golden hash
  cells under SEMANTICS_VERSION 2319).
- L0: a_gep_into_an_array_field_is_bounded_to_the_array (the bound, and
  each disqualifying shape staying unknown).
- read-back, whole-struct copy (a memcpy) and a stepped address stay
  Lowering(Access).
- the walk's two metallibs on the XTX node (m3-max-80156): the handle
  store's refusal is gone; the vertex function next met the two
  refusals the following commits remove.

Cost: one UMin per run-time index into a private-arena array, the bound
itself. The device-arena budget test's word bounds move by one each (13
for a word load, 12 for a word store, 24 for a float4 load).
SEMANTICS_VERSION 2320 (development holds 2319).
2026-12-02 14:41:34 -08:00
Anees Iqbal f124b1489f Translator: an access refusal names the structure it met
Feature::Lowering(LowerFamily::Access) with Needs::NotImplemented covered
about 235 refusal sites behind one name, so a walk's log line could not say
which without the AIR. Unsupported gains `cause: Option<Cause>`; an access
refusal carries Cause::Access(AccessCause), one variant per structure the
sites refuse: the access's shape, the type it moves or the memory it
reaches. Sites that refuse the same structure share a variant, wherever
they are; none is named by a file, a line or a string of its own.

The five helpers that build the refusal (lower/access/mod.rs refuse() and
memory/{alloca,leaf,plan,provenance}.rs not_lowered()) take the cause, so
the compiler makes every site name one; the three direct constructions in
memory/handles.rs and lower/access/handle.rs do too, through
Unsupported::access. Feature stays Lowering(Access), so validation's
outcome key (feature_key, the Debug of the feature) and the census are
unchanged. Display prints the cause after the feature:
"Lowering(Access): PointerStore; needs NotImplemented at ...".

Storage: nothing stores the cause. Validation keys a refusal by
feature_key(&u.feature) (engine.rs); a FALLBACK repro bundle keeps the
failure as text (repro.rs, whose only serde record is the device); the
runtime's cache marks a refused translation with fixed bytes. No version
bump.

A buffer argument of a count other than one outside an argument table
names BufferArray, apart from an index or count the metadata does not fix
(UnfixedLocation).

Tests: the error module's Display test of an access refusal; the plan's
table gaps assert ArgumentTable, and its typed-depth, initializer and
buffer-array refusals PrivateType, Initializer and BufferArray.
runtime-sources.sha256 rewritten: memory/handles.rs's two refusals name
their cause, and no run behaves otherwise. api_signatures blessed (Cause,
AccessCause, Unsupported.cause), api_surface lists the two enums,
REFUSALS.md regenerated (the access refusals are built in error/mod.rs),
docs/API.md's error table names the field.

Consumer uses (consumer-uses.sh, read-only, plus git grep, over the
consumer's development 22cfe51a54 and its lane tips of the last day): no
struct literal or exhaustive destructuring of the translator's Unsupported
("Unsupported {" hits only its video crate's own Unsupported(String),
codec/encode.rs:494-502). Its rt platform builds refusals in tests with
Unsupported::not_implemented (rt_platform/diag.rs:3076, 3078, 3490;
rt_platform/unbuilt.rs:1203, 1293), whose cause is None, so their keys
("Translation-Lowering") hold. It reads u.feature where it names a refusal
(rt_platform/diag.rs:1082) and where it says one (rt_platform/unbuilt.rs:
507); each shows the cause once it reads u.cause too.
2026-12-02 14:24:11 -08:00
Anees Iqbal c1f999eb06 rt: pipeline states answer Metal's allocatedSize as their translated SPIR-V's bytes
ComputePipelineState::allocated_size and RenderPipelineState::allocated_size
answer MTLAllocation's allocatedSize, which both Metal pipeline states adopt.
The answer is our code's size, not the driver's compiled binary, which the
runtime does not measure. A compute state answers its kernel's module, the
one its interface is read from. A render state answers its stages' modules,
summed. Both numbers are taken from the translation when the content is made
and kept as a u64 in the content (a compute content's Answers, a field of
RenderCompiled); no module is kept for them. Every device takes the same form.

No variant counts: not the emulated-SIMD-group or partial-threadgroups
variant lowered with a compute state, not one made at a dispatch (the
emulated-partial variant), and not a render content made later for a pass.
So the answer never changes once a state is made, and two states of one
content answer one size.

docs/API.md's accepted differences (Heaps and memory) gets the entry.
MTLAllocation.allocatedSize stays missing in the coverage ledger: buffers,
textures and heaps still lack it. Its note now names the pipeline states'
answers, and docs/METAL-COVERAGE.md is regenerated. api_signatures.tsv is
blessed with the two methods.

Tests:
- state_answers: a new test. block_scan (plain module) and sample_down
  (partial-threadgroups variant) answer non-zero. Each equals the bytes of
  the module the state keeps (a test-only Kernel::module_bytes). The
  render state of first_texel_fragment answers the sum of the translator's
  compile_render_pipeline stages' SPIR-V lengths. Two states of one content
  answer one size.
- translate.rs: the ragged-grid test on emulated SIMD groups now also checks
  that a state's answer is the same after the dispatches that make the
  variant later.

Verified: job m3-max-79929 on lavapipe, a check of this tree.
- signatures --check, coverage --check, clippy (plain, m2v_gpu,
  m2v_cpu_icd), workspace doc and the runtime's private doc: all 0.
- The runtime suite: 928 passed, 3 skipped.
- The two tests rerun with output: both pass. On lavapipe the variant
  already emulates its SIMD groups, so the ragged test makes nothing at a
  dispatch there. No card run yet.
2026-12-02 14:24:11 -08:00
Anees Iqbal 06d2d22bf7 Translator: a library keeps each module in an allocation of its own, and a function keeps its module, not its library
A pipeline state keeps its descriptor's functions to lower its later variants from, and a
function held its whole library through an Arc: a guest that made a state of one function of a
metallib of many, then released the library, kept every module of it alive as long as the
state lived.

At load, a library now splits the one copy it makes of the loaded bytes: each module (each run
of bytes one or more functions' bitcode covers, so functions over one module, as a Core Image
kernel library's or a dynamic library's exported functions, share one) in an allocation of its
own, and every other byte (header, function list, metadata, other sections, padding) in one
more. A function holds its library's function table (rows, content hash, type, install name,
dependencies), its own module's allocation and its index, and the library weakly. So a state
keeps exactly its functions' modules whether the library lives or not: while it lives, the
same allocations the library holds, each module once; nothing is copied at a state's make.

Public changes (api_signatures.tsv, docs/API.md, the doc comments):
- Library::bytes() returns an owned Vec<u8>, assembled from the allocations, equal byte for
  byte to the loaded bytes (of a universal file, its AIR slice, as before); content_hash() is
  their SHA-256, computed at load as before.
- Function::library() returns Option<Library>: the library while a Library value of it lives,
  None after; MTLFunction names no library either.
- Function::library_content_hash() (new): the library's content hash, kept with the table.
- Function::bitcode() (now public, infallible): the function's own module (a metallib
  function's wrapped module, a bare module's whole module, a dynamic library's one module); its
  doc says the bytes are the guest's shader, never committed or sent anywhere.
- Function's PartialEq and Eq: equal tables (each holding its library's content hash) and
  indices.
The translator's own uses of a function's library read the table (compile.rs's dependency
order and EntryNotFound's count); linked_sources no longer fails.

The consumer's call sites (reims-vgpu development 53e7385993, read only; search: git grep -n -E
'\.(bytes|library)\(\)' over crates/reims-vgpu-vulkan and crates/reims-vgpu, and \.library\(\)
over the whole tree; every other hit is a string's, a NAL's, a staging buffer's or
graphics().library()): crates/reims-vgpu-vulkan/src/rt_platform/diag.rs:1860 and :1863 (the
kept-AIR bundle: the container while the library lives, else the function's own module through
bitcode(), the line naming which), diag.rs:1934 (FunctionName::of: library_content_hash()),
diag.rs:3495 (test; unchanged, the bytes compare equal) and unbuilt.rs:653 (test; a function
keeps bitcode().len()).

Tests: the red test's two states (lavapipe; their test accessors now read a kept function's
library where it lives, else its own module); a_live_library_and_its_states_hold_each_module_once
(two compute states and a render state share the library's own allocations);
tests/library_modules.rs: bytes() equals the loaded input for a plain metallib, a Core Image
kernel library (shared module), a dynamic library, each universal header and a bare module, the
content hash their SHA-256; a function holds its module (one allocation per module, shared over
a shared module), names no library once it is released, keeps the content hash and compiles
under the same keys to the same words. The runtime's README says what a state keeps.
2026-12-02 14:24:11 -08:00
Anees Iqbal ac220d6f52 rt: the heap size query answers every storage mode alike; a Shared heap's texture is refused at its placement where the image takes no Shared type
On the RTX 2080 (NVIDIA 620.70.06, job m3-max-79682) the device's optimal images take no Shared
memory type. Two things followed from that:
- The parent commits' size query, which checked a Shared descriptor against the Shared type,
  refused Shared descriptors there. heap.rs's two Private-block tests size Shared descriptors, and
  both failed at their size query.
- A guest that sizes a texture with a Shared descriptor would have lost an answer it had before.

The size query now checks the Private type for every descriptor, as it did before this series.
Its answer does not depend on the storage mode. The Shared type is checked where the texture is
placed in a Shared block, and the placement is Gap::HeapTexture where the image does not take
it.

Follow-on changes:
- The Shared-heap device test expects the size query to answer on every device and the placement
  to be refused exactly where `Device::heap_image_fits` says the image does not take the Shared
  type.
- The conformance side holds a Shared query to the placement and read-back steps in a Shared heap,
  and to step 1 where that placement is Gap::HeapTexture (docs/API.md section 10 says so).
- churn_rest finds out once, by placing a texture for views in a Shared block and releasing it,
  whether the device places its Shared heap texture. Where it does not, the row leaves the kind
  out, naming it with the reason.
- The rt README's known gaps of textures name where a Shared heap's texture is placed: lavapipe
  and the Radeon 780M take it (jobs m3-max-79654 and m3-max-79685); the RTX 2080 does not. The
  Gap::HeapTexture doc says the same.

Ledger: the five rows of the RGB10A8_2P_XR10 heap cases (texture-fills-550, texture-fills-551,
texture-fills-heap-run-550-b5, texture-fills-heap-run-551-b5 and two-plane-heap-blits) take the
Err the replay at 1e1c3f39b8 pasted (lavapipe, job m3-max-79680). Their Shared heap no longer
refuses first, so the format's own Gap::TextureFormat answers. Their venue stays *, since the
format check comes before the placement on every device, and their justification already names
Gap::TextureFormat. CONFORMANCE-COVERAGE.md is regenerated and unchanged.
2026-12-02 14:24:09 -08:00
Anees Iqbal 13951e8daf rt: a texture is placed in a Shared heap as in a Private one, where the device's image takes the Shared type
Metal places textures in a Shared heap: the M3 Max makes them, in automatic and placement heaps
(job m3-max-79576). The runtime refused every texture in a Shared block as Gap::HeapTexture. Now
new_heap_texture and new_heap_texture_for_views bind the device's optimal image in a Shared block's
memory exactly as in a Private block's. That is one form, with no linear image and no copy.

- heap_source refuses an exported block alone, whose memory is dedicated to its buffer.
- heap_fit takes the heap's memory class. At the placement, the class is the block's (Bind::Heap
  carries it). At heap_texture_size_and_align, it is the class the descriptor's storage mode names:
  Shared for Shared, Private for any other, as before.
- Gap::HeapTexture stays typed for an image the device requires an allocation of its own for, or
  whose memoryTypeBits leave out the heap's type, at the size query and at the placement. The
  consumer counts it.

The host reaches such a texture as any texture's, through replace_region and get_bytes. Their
copies go through the GPU and flush or invalidate only their staging bytes. The block's mapping
over the image holds the device's own layout, so the image's range needs no flush or invalidate of
its own. A command buffer that uses the heap (use_heap) flushes and invalidates its whole Shared
block, as it did for the heap's buffers.

Nothing in the runtime asks which Mac the guest has. Whether a guest may make a Shared heap at all
is the consumer's decision; the runtime has no heap object and hands a Shared block to any take.

Docs:
- the rt README's heap paragraph covers Shared heaps;
- the Gap::HeapTexture doc is updated, and REFUSALS.md regenerated;
- docs/API.md's heap-size entry: a Shared descriptor is now held to the placement and read-back
  steps in a heap of a Shared block, as the conformance side's heap_sizes::hold now does;
- the known-gap sentence of the UHD 630 Windows texel-buffer refusal gains its trigger: a second
  device above the floor whose formats lack those buffer features, or a walk that meets the
  refusal.

The test is the parent commit's. Verification is to follow in the handover: lavapipe red then
green, one card per vendor, the gate, and the conformance replay.
2026-12-02 14:24:09 -08:00
Anees Iqbal ce471296d5 rt: an Accumulate pass writes its visibility results as a Reset pass does, on every device
set_visibility_result_mode refused Boolean and Counting in a pass whose
visibilityResultType is Accumulate (Gap::Draw{AccumulatedVisibilityResults}, counted in
Metrics::accumulated_visibility_refused). MTLRenderPass.h documents Accumulate in one
sentence, "Accumulate visibility results data across multiple render passes." Measured
(the conformance recordings, values.rs VisibilityResultType): Metal on an Apple M3 Max
(macOS 27.0.1) adds a Counting result into the word's low 32 bits and ORs a Boolean one,
while Metal on a Radeon Pro 5300M and a UHD Graphics 630 (macOS 26.7.1) writes it in
place of the word, as Reset does. The documented sum needs an add of a query's count into
a buffer word: a scratch copy of the query results and a kernel of the runtime's own after
the rendering, which is not built. The planner ruled that the runtime answers Accumulate
as Reset on every device until that sum is built, which then replaces it everywhere.

So the setter takes every mode in an Accumulate pass as in a Reset pass, and the
encoder no longer keeps the pass's visibilityResultType, which nothing reads now.
Removed public items: DrawKind::AccumulatedVisibilityResults and
Metrics::accumulated_visibility_refused (the consumer's checkout names neither in code;
two doc comments and one test of its rt platform describe the refusal:
rt_platform/render.rs:76 and its test at :2299, rt_platform/descriptor.rs:21).
DrawKind::VisibilityResultInterrupt stays refused, its doc now saying why: its answer
needs the same add. docs/API.md's accepted differences records the measured answers; the
rt README, VisibilityResultType's doc, the validation replay's docs and
docs/REPLAY-STREAM.md follow. The validation replay test of an Accumulate stream now
holds that its modes write as a Reset pass's, nothing skipped. REFUSALS.md regenerated
(Gap::Draw loses one site); api_signatures blessed (the two removed records).
2026-12-02 14:24:08 -08:00
Anees Iqbal 2dc8b1c002 rt: the triangle fill mode of raw value 2 draws as Fill on every device
set_triangle_fill_mode refused TriangleFillMode::Points, the raw value 2 that no SDK
header declares (MTLRenderCommandEncoder.h declares Fill and Lines alone), as
Gap::Draw{FillMode} on every device. Apple's OpenGL renderer sends it for
glPolygonMode(GL_POINT). Metal refuses it on no Mac measured, and the Macs disagree: an
Apple M3 Max and an Intel UHD Graphics 630 draw a triangle's vertices as points, an AMD
Radeon Pro 5300M fills the triangle. The planner ruled that the runtime takes the Fill
answer, which needs no device feature, no pipeline of its own and no precision note.

The setter now takes Points as Fill. DrawKind::FillMode keeps one case, Lines on a
device without fillModeNonSolid. docs/API.md's accepted differences records the
measured answers and that a points form waits for a guest's report that the points
answer matters; the rt README's fill modes and known gaps say the same. REFUSALS.md
regenerated, unchanged (it lists no DrawKind text).

Verified: tests::raster::on_device::every_device_draws_the_fill_mode_of_raw_value_2_as_fill
on lavapipe, red at the test's commit (the setter refused), green here.
2026-12-02 14:24:07 -08:00
Anees Iqbal 7a1da6cb22 rt: a draw through buffers bound at a multiple of 4 below their alignment draws the state's word-bound content
Row L97 (the draw residual). A dispatch of a function's kernel whose buffer
argument of 8 or 16 is bound at a multiple of 4 below that alignment runs a
variant of its kernel that holds the slot to 4 (8 where a 64-bit atomic may
reach it). A draw refused such a bind (Refusal::BufferOffsetAlignment). It
now draws the same way.

- RenderPipelineState::for_words(device, words) makes the state's content
  with LoweringInputs::word_bound_buffers set for its vertex function (bits
  0..31) and fragment function (bits 32..63). The device's map of contents
  keeps it under the state's key with that mask (KernelKey.words widens to
  u64). Like a pass's 2D-array content, it has no cache record of its own.
  Its samplers are numbered at the state's indices; a mismatch is
  Gap::KernelInput (ConstexprSampler).
- RenderCommandEncoder keeps the state set (`base`) apart from the state it
  draws through (`pipeline`). Where a draw's facts are not held (a bind or
  the state changed), bind_words reads the base's buffer address fields. A
  slot of mask 7 or 15 whose bound address is a multiple of 4 but not of
  its alignment sets its bit. The mask is ANDed with the slots the state
  lowers from AIR (word_slots: a function the consumer compiled has none,
  and its bind stays refused). A new mask switches `pipeline` to that
  content, or back to `base`. An execution of an indirect command buffer
  draws through `base`.
- The draw's own checks then hold each slot to the content's alignment: an
  address off a multiple of 4 is still refused, as is one off 8 that a
  64-bit atomic may reach.

Cost: a draw bound aligned keeps the state it was set with, and the scan of
its address fields runs only where the draw's facts are found again
(expected from the code, not measured). The first draw of a new mask lowers
both functions again and makes the content's VkPipeline (a first-use wait),
as the compute variant does. A later draw of that mask finds the content.

Docs: the runtime README (Render encoders: the draw bullet; Compute
encoders: the variant's paragraph); error.rs's BufferOffsetAlignment;
docs/API.md section 1 and its accepted differences. REFUSALS.md unchanged
(refusal_surface --check 0); api signatures --check 0.

Verified:
- Green on lavapipe, m3-max-79015 (at this commit's tree before its rebase
  onto 8dd00ec58c). Over tests::draw, render_offsets and indirect: 67 of 67
  passed, 838 skipped. The new test draws every case through the content,
  and the second draw of a bind finds it.
- The two draw-alignment tests on a card per vendor, 2 of 2 passed on each:
  - Radeon 780M (RADV PHOENIX, Mesa 26.2.6), m3-max-79076, at this commit;
  - RTX 3090 (NVIDIA 620.70.06), m3-max-79043, and Iris Xe (ANV, Mesa
    26.2.6), m3-max-79051, both before the rebase.
- m3-max-79086, at this commit: workspace clippy (all targets, all
  features, -D warnings) EXIT=0 in all three configurations (plain,
  --cfg m2v_cpu_icd, --cfg m2v_gpu); Rustdoc EXIT=0; the runtime's private
  Rustdoc EXIT=0. The runtime suite on lavapipe: 903 tests run, 903 passed,
  3 skipped.
2026-12-02 09:30:59 -08:00
Anees Iqbal 5d6ac696d0 Runtime and translator: a framebuffer fetch from the first slice of a 2D array that its pass renders alone
Row L223: a fragment function's fetch ([[color(n)]]) of a one-slice 2D array
attachment of a layered pass was refused (Gap::Draw FetchedAttachment), where
Metal reads the attachment at the fragment's pixel. The fetch reads the
texture's second element, which for a 2D array texture holds a 2D_ARRAY view.
Vulkan reads such a view only through an arrayed image (vkspec, image view
validation). The function read every element as a 2D image.

Form (ruled B, the per-state variant, as L97's compute variant):
- Translator: LoweringInputs::arrayed_fetches names the colours read through
  such an element. The fragment function declares that element's class arrayed
  and fetches it at (x, y, 0). The key takes the field only when it is set,
  so every existing function keeps its key and its bytes. No SEMANTICS bump.
- Runtime: set_render_pipeline_state binds, for a pass whose fetched attachment
  is a 2D array texture (a multisample one too), the state's content lowered
  with those colours (RenderPipelineState::for_pass, which also makes the
  content without colours past the pass's last attachment, as before). The
  content is kept in the device's bounded map of contents under the
  descriptor's key and its colour mask (KernelKey::arrays). The cache
  directory's render record is neither read nor kept for it. A failed variant
  leaves the state itself, whose fetching draws are then refused.
- attachment_reads accepts a 2D array texture whose first level and slice the
  pass renders, one layer, where the bound content fetches that colour
  arrayed.

Still refused (README, error.rs): an array whose pass renders more than one
layer, a slice past an array's first, and a view whose first slice is not the
rendered one.

REFUSALS.md and the api_signatures table are regenerated (the new
LoweringInputs field). API.md and the runtime README are updated.

Verified:
- Red, lavapipe, m3-max-78542: the test commit alone fails at fetch.rs:396
  (FetchedAttachment): 10 tests run, 9 passed, 1 failed.
- Green, lavapipe, m3-max-78570: 45 of 45 passed (832 skipped); the one-slice
  array is fetched exactly through the feedback loop.
- Radeon 780M (RADV), m3-max-78604; RTX 3090 (NVIDIA 620.70.06), m3-max-78609;
  Iris Xe (ANV, Mesa 26.2.6), m3-max-78649: the fetch and unattached-colour
  tests, 6 of 6 each, the array fetched exactly through the feedback loop.
- States-only play, m3-max-78602, lavapipe, this change against 118bd0dff7:
  identical on both replay streams (one recorded on the 3090: 10643 render and
  15299 compute states made; one on the 780M: 8972 and 225), 0 refused.
- m3-max-78600 (at the pre-rebase 90726b13b7): clippy, Rustdoc and private
  Rustdoc EXIT 0; runtime 874 of 874 passed (3 skipped), translator 3393 of
  3393 (37 skipped).
- Workspace clippy in all three configurations (plain, --cfg m2v_cpu_icd,
  --cfg m2v_gpu; all targets, all features, -D warnings): m3-max-78645 at
  this change alone on development, and m3-max-78677 at this tree on top of
  the row-1166 tests. Every EXIT=0.
2026-12-02 07:52:24 -08:00
Anees Iqbal 2f16658ac2 Translator, runtime: an OpenCL-mode kernel's 1D images read their 2D textures under the identity domains
L61. A kernel of OpenCL mode that takes a 1D image stated RuntimeFact::OpenClLineTexture for each
such slot. That fact marks the variant in which the table domains read a 1D texture bound there,
as a Radeon Pro 5300M answers. The identity domains source no such fact, so every such kernel's
pipeline was Unsupported{IdentityDomains} when made, whatever else it did.

Apple's OpenCL binds a 2D texture of height 1 for an image1d_t and a 2D array of that height for an
image1d_array_t, and never a 1D texture. The kernel already reads its 1D images as those 2D textures
at row 0 (canon::opencl_1d), as the M3 Max and the 5300M answer. A 1D texture bound there is
outside documented Metal, and the Macs disagree on it: the M3 Max reads texel 0 at every
coordinate, the 5300M the 1D texture's texels, a UHD Graphics 630 layer 0 of an array.

- Translator: under the identity domains a kernel states no OpenClLineTexture and has no such
  variant; it reads the 2D textures. The table domains keep the fact and the variant.
  identity_unsourced no longer names a fact the identity domains never state.
- Runtime: a state records whether its kernel is of OpenCL mode (RuntimeFact::OpenClMode). A
  dispatch of one with a 1D or 1D array texture bound at any of its texture slots is the new
  typed Gap::OpenClLineTexture { slot }, not a read: Apple's OpenCL binds none, and Metal defines
  no reading of one. It is checked where the swizzle and bicubic checks run, when the state or a
  binding changes. Its doc ends in "Basis: ours".
- Docs: the runtime README's known gap is rewritten for the dispatch's refusal. API.md and the
  fact's doc say what the identity domains do. docs/REFUSALS.md and error/basis.rs are regenerated
  (Gap 30 to 31), and api_signatures.tsv is blessed (one variant).
- The runtime test opencl_lines now also binds a 1D texture at each of the kernel's three slots in
  turn. Each dispatch answers Gap::OpenClLineTexture naming that slot and writes nothing.

A refusal becomes a module, so SEMANTICS_VERSION 2316. The translator's refusal sites are
unchanged.
2026-12-02 07:25:18 -08:00
Anees Iqbal 5806b10c13 Translator: a sampled cube read by face samples its cube element under the identity domains
L215 (a). A texturecube or texturecube_array read by face was declared as the binder's 2D-array
view of its faces (RuntimeFact::ImageViewShape), since SPIR-V's OpImageFetch takes no cube. The
identity domains hold a sampled cube's element as its cube view and source no such fact, so
every such read was Unsupported{IdentityDomains}.

Under the identity domains a sampled cube (not a depth cube) that is read is now declared as its
cube element, and the read samples it. It goes through element 0 of its numeric type's sampler
array (binding 2, or 4 for an integer texture), which no ID reaches: the default sampler. It
samples at the direction of the read texel's centre on its face, with the read's level as the
explicit Lod.
- On face f the centre is (sc, tc) = ((2x + 1 - w) / w, (2y + 1 - h) / h), whose numerator is an
  exact integer.
- The direction is Vulkan's cube map face selection read backwards, the table Metal's faces share.
  With m the face's sign, it is (m, -tc, -m*sc), (sc, m, m*tc) or (m*sc, -tc, m).
- Its major axis is the face's, at magnitude 1, so (s, t) on that face is the texel's centre, half
  a texel inside its cell, and nearest reads that texel. Integer Lod l under nearest mip selects
  level l.
- A sample clamps every operand, so the read is checked in the shader on every device
  (ReadCheck::Shader). x and y are tested against the extent at the level, the face against 6, the
  cube index against the cube count, and the level against the level count, with Metal's
  out-of-bounds texel outside (its alpha from the ID's word).
- slot::samples_cube_element is the one rule the declaration and the read's check share.
  SlotPlan::face_sampler gives the sampler use the sampler family declares.
- A depth cube read by face, and a cube whose faces an emulated filter fetches, keep the 2D-array
  view and stay refused under the identity domains. The table domains are unchanged.

The runtime's default samplers now reach every level (maxLod VK_LOD_CLAMP_NONE, was 0), so an
explicit level past 0 reads that level. A sampler element nobody owns holds the default, as do
nil, freed and out-of-range sampler IDs. Their samples could reach only level 0 before; they now
reach the level they ask for.
Existing tests that cover the default samplers:
- tests::arrays' set_1_is_filled_at_creation (both live with set 1);
- tests::device's gauge check (set 1's two default samplers and nothing else);
- tests::argument_sampling's argument_sampler_edges (an argument buffer's sampler against the
  default's answer).
RESOURCE-ID.md states the default sampler and the cube read's contract for a consumer that lays
the arrays out itself. API.md and the runtime README say so too; the README's known gap now names
only the depth cube read.

A refusal becomes a module, so SEMANTICS_VERSION 2315. The golden table's cube_faces cells
change from the refusal, a bless at the next pin. No refusal site was added or removed:
docs/REFUSALS.md regenerates unchanged.
2026-12-02 07:25:18 -08:00
Anees Iqbal 0bb092f8ff API docs: a kernel's write through a channel-permuting swizzled view is stored as written
Section 10's Kernels gains the accepted difference: the runtime stores a kernel's write
through a texture view whose swizzle permutes its format's channels as written, where the
M3 Max stores it through the swizzle (an RGBA8Unorm (Blue, Green, Red, Alpha) view's write
of (0x33, 0x66, 0xb3, 0xcc) leaves (0xb3, 0x66, 0x33, 0xcc); swizzled_view_stores.m, job
m3-max-76829) and Metal's validation refuses the write, the view reporting no ShaderWrite
usage. The OpenCL images paragraph said a write stores the value with the swizzle undone,
which is the M3's answer, not the runtime's; it now states the runtime's rule and points
to the entry.

Docs only; the rule is the runtime's README's ("A swizzle reaches a texture's sampled
element alone") and the lane's write test asserts it.
2026-11-27 05:11:10 -08:00