Commit Graph
2349 Commits
Author SHA1 Message Date
Anees Iqbal 5eeeb8d752 Conformance ledger: the KosmicKrisp venue's 30 held lines, each under its read cause
The Apple M3 Max venue (KosmicKrisp, Mesa 26.3.1) held 30 lines after its re-record, kept back
until their causes were read. Each now has a row whose text names that cause:

- a2c and a2one, 8 texel sites: KosmicKrisp computes alpha-to-coverage in the fragment shader with
  NIR's nir_lower_alpha_to_coverage (kk_shader.c, msl_nir_lower_common.c). The mask is Mesa's
  mapping, not Metal's. Note device-alpha-coverage.
- half-output-blends-r32f sa-1msa: KosmicKrisp blends in the fragment shader (kk_lower_fs_blend,
  nir_lower_blend), compiled under Metal's fast math, so the products round in Mesa's order.
  Note device-color-conversion.
- pixel-downscales frac/slot digests, 7 sites: ours, not the device's. The slot's pixel
  coordinate goes to the normalized sampler as coordinate over size (pixel-sampler-scaling). The
  norm control matches Metal on this venue.
- The venue's 11 downscale frac/slot head and tail rows, landed with the earlier re-record, now
  carry the same "ours" text in place of "the device's own answer".
- pixel-samplers rgba8 and rgba16f linear-mirror, slot and arg, 4 sites: ours, the same scaling
  under mirrored repeat. KosmicKrisp maps mirrored repeat to Metal's own mode, and norm and const
  give Metal's digest.
- texture-buffer-fill-groups, -fill-streams and -long-fills: KosmicKrisp's
  minTexelBufferOffsetAlignment of 16 (KK_MIN_TEXEL_BUFFER_ALIGNMENT) refuses the offset-4 texture
  buffer typed (Refusal::TextureBufferAlignment), before the fillTexture step.
- texture-fills-41: A1BGR5Unorm is not made on this venue.
- texture-fills-236: KosmicKrisp offers ASTC HDR, so the case reaches fillTexture (Unavailable).

Those five cases' every-venue rows split into llvmpipe, NVIDIA, RADV and Intel rows, since
KosmicKrisp answers otherwise there. In the split texture-fills-236 rows, "on any venue" now
reads "on this venue". docs/CONFORMANCE-COVERAGE.md is regenerated (coverage.py).

Answers taken from the KosmicKrisp replay of job m3-max-82902. The KosmicKrisp replay at this commit
(Apple M3 Max, job 83133) reports 0 unexpected lines. docs/CONFORMANCE-COVERAGE.md re-run with
coverage.py on development: unchanged.
2026-12-03 03:06:36 -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 965e707277 Conformance ledger: the Apple M3 Max venue (KosmicKrisp) re-recorded, but the sites still to be read
The M3's conformance replay on KosmicKrisp (Mesa 26.3.1) at 6989666062 (job m3-max-82902; the
product of development's 13c6ba8a91, which adds one rt test change) printed 269 lines the ledger
did not expect. The venue had 14 rows; every other row it held was another venue's or every
venue's. This commit records what is mechanical and leaves the rest as it is.

- 197 rows added at sites another venue already lists: 158 with that venue's answer, 39 with the
  same answer but for its numbers. Each takes that venue's gap text, except 18 whose text named
  another device:
  - 6 indirect-range cases: KosmicKrisp does not list VK_EXT_device_generated_commands;
  - 11 pixel-downscales frac sites: the device's sampler, within the 2/255 recorded on lavapipe;
  - 1 half-tanh site: the other venue's first-element values are dropped.
- 14 every-venue rows (astc-*-hdr zero-blocks/texture) split into llvmpipe, NVIDIA, RADV and Intel
  rows. KosmicKrisp makes ASTC HDR textures (textureCompressionASTC_HDR in kk_physical_device.c),
  so the M3 now matches Metal there.
- 1 M3 row removed: discard-quad-sum-placement hoisted_known/pipeline, which the venue now reads as
  lacking the feature.
- 15 rows added for refusals no venue listed, each from a device query:
  - 10 surface-textures cases: KosmicKrisp exports no dma-buf, opaque fd or Win32 memory;
  - 2 lines and facing draws: no fillModeNonSolid;
  - 3 A1BGR5Unorm textures (fresh-pattern-41, extended-swizzles-a1bgr5unorm,
    texture-round-trip-41): not made for the usage.
- 6 bicubic-texel-classes M3 rows: the answer is the one the 780M, RX 550, RTX 5080, RX 7900 XTX
  and Iris Xe rows record. The M3 answers it since the Converted half pair is decorated
  NoContraction (699f1167d6).

Left as they are, to be read first (30 lines):
- alpha-to-coverage texels: a2c-* and a2one-*, 8;
- pixel-downscales frac digests, 7;
- pixel-samplers linear-mirror sites, 4;
- texture-buffer fills refused off KosmicKrisp's 16-byte texture-buffer alignment, with
  texture-fills-41 and -236 (5), plus the 5 every-venue rows they no longer hold;
- half-output-blends-r32f sa-1msa, 1.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py).
Verified: the edit is derived from that replay's lines; the conformance suite and a replay on the
M3 with this ledger are in the READY note.
2026-12-03 02:50:42 -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 1ee4cd95d5 Runtime: the caller's RestoreFence is called around a restoring make's save, move and write-back
What: Device::texture takes the fence that Buffer::new_texture_fenced and
Buffer::new_texture_in_place_fenced pass. On a restored make alone (in place over host memory's
import, Keep::Restore), after the refusals ahead of the restore, the make runs on its own thread:
it waits for the progress already submitted (Work::progress), calls the fence's before, adds the
image's move home to the upload (Work::home), flushes, waits for that value, and calls after.
before comes ahead of home and not just ahead of flush because a commit from another thread can
carry the upload out as soon as the move is in it (take_uploads). after is called from a drop
guard (Fenced), so it runs on every exit once before returned Ok: the make done, Quiesced from
home, a lost device in the wait, or a panic unwinding. A before that answers Err(reason) refuses
the make with Refusal::RestoreFenceRefused { reason }. Then nothing is recorded, saved, moved or
written back, the texture made so far is dropped, nothing counts, and after is not called: before
undoes its own work, and after always pairs with a before that returned Ok. Every other make, and
every make with no fence, takes the match's other arm, so an unused seam costs one branch. The
make itself is unchanged.

Public shape: a trait object (&mut dyn RestoreFence, before -> Result<(), &'static str> and after)
on two new twins, not an Option argument on new_texture and new_texture_in_place. This tree has
about 90 four-argument calls of those two, and the consumer's development has 6, of which 2 need
the fence; the twins leave every other call unchanged. A &mut trait object lets before keep a guard
or a token in the fence for after to release. The reason is &'static str so that the refusal stays
Copy, as Refusal is.

Docs: the runtime README (Imported blocks, "The caller's fence"; the known gap of memory blocks;
the API list) states the contract. Between before and after the runtime saves, moves and writes
back the block's bytes, so a host write to them in that span is lost; the span holds the whole
submission that carries the upload, a group's included. A caller with such a writer fences it
there; one without passes nothing. Vulkan documents no form that keeps the bytes without the
write-back (sections 12.10.1 and 7.7.6: an acquire keeps bytes only after the other owner's
release; section 11.2.6: host-pointer memory is shared with the host under host access
synchronization). The rustdoc of the trait, the twins, the refusal and Buffer::new_texture says
Metal has no such span. Refusal::InScheduledHandler's doc names the twins. docs/REFUSALS.md is
regenerated (RestoreFenceRefused, one site). Not touched: RUNTIME_VERSION and runtime-sources.sha256,
whose inputs are the translator's listed files (metal2vulkan/src, metal2vulkan-air/src); this change
edits none of them.

Verified, red: at 4e941d8015 (the fence passed nowhere) the new test failed on lavapipe (llvmpipe,
LLVM 23.1.1, Mesa 26.2.4), job m3-max-82710. With no fence, 632 of 86,252 stamped words were lost.
With the unwired fence, 7,507 of 98,879 were lost, 0 writes found the gate held, and before and
after ran 0 times. Green runs and the gate follow in the lane's report.
2026-12-03 01:06:30 -08:00
Anees Iqbal b3d7464945 Validation: a threadgroup target is checked nowhere, so its case is refused before it runs
What: executor_contract::out_of_bounds::containment() reports a threadgroup target as the arena
unchecked (Check::Unchecked), on every profile and under either domains. out_of_bounds_run then
refuses the case before anything is made, as not_supported{uncontained:unchecked threadgroup},
as it refuses a loaded pointer under the identity domains. The read rule's in-shader arm no
longer names the arena. The module docs, the Unchecked variant, ContainmentForm::Threadgroup,
the coverage note on which accesses the encodings govern, and docs/VALIDATION.md say so.
ENGINE_EXECUTOR_ABI moves to vulkan-engine-v214: the executor records a refusal for a case it
ran before.

Why: since 990328afe1 no profile checks a threadgroup access (lower::access::local::contained;
docs/API.md, "Threadgroup memory": one past the memory is undefined, as in Metal; the runtime
README states it too). The contract still reported the arena as checked in the shader, so the
candidate ran the only authored case with a threadgroup target, tg-twice (7efae163,
loads-and-stores-past-a-threadgroup-allocation), and read what the device held past the
allocation. On the Radeon 780M (RADV, Mesa 26.2.6) job m3-max-82582 ran it 10 times at
f606e43b30 and got 10 different output hashes: word 6, a load of tg[40], which no thread
writes, held a different value each run. The kernel's SimdgroupAccessOrder note made the failed
zero rule a NotedDifference. Vulkan does not define an access past a Workgroup array either, so
no part of that run is evidence.

What else moves: no other authored case declares a threadgroup target (all case shards
searched for "form":"threadgroup": one hit), so only tg-twice moves from noted_difference to a
refusal. The case, its AIR and its Metal row are unchanged. No classifier input changes
(executor_contract/out_of_bounds.rs, coverage.rs and case/out_of_bounds.rs are not in
build.rs's classifier list), and the authored compile census compiles the case as before
(case_compile reads no containment), so neither census version moves.

Verified: see the green job named with this commit's READY.
2026-12-03 00:30:04 -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 4a96499072 Translator: an unknown runtime-library routine is refused as its family, and AGENTS.md allows the families
AGENTS.md's name rule now also allows the body-less runtime-library routines Metal's compiler
links by symbol: the ___metal_* maths routines and the __tensorops_impl_* family. Their
declarations have no body, so the symbol is the only thing that says what the routine is. An
unknown member of such a family is a typed refusal.

Both families were already gated on that structure. The bitcode reader classifies a routine
name only on a declaration, and the matmul2d lowering takes a __tensorops_impl_matmul2d_op_*
function only when it has no body and is in air.externally_defined. Two tests now show that a
defined function of either name is the module's own:
- a_defined_function_named_as_a_runtime_routine_is_the_modules_own (bitcode, through llvm-as);
- a_defined_function_named_as_a_tensor_op_is_the_modules_own (canon).
Both tests pass at the base as well.

An unknown member used to be refused as Linking, the refusal for an undefined function that
linking could supply, which these never are. Now the post-check refuses a surviving call to a
body-less declaration as its family:
- an unmodeled ___metal_* routine as an unknown intrinsic, the same refusal an unknown air.* name
  gets;
- a __tensorops_impl_* function in air.externally_defined, outside the matmul2d ABI, as Tensors,
  which is how the matmul2d lowering already refuses its own unmodeled functions.
The same name outside that section is not a family member, and still needs linking.
intrinsics::is_routine_family and tensor_ops::in_family state the two families. docs/REFUSALS.md
lists the new Tensors site.

Verified on the CPU with no device, in job m3-max-82525 at a commit of the same tree
(4974c671a8):
- an_unknown_runtime_library_routine_is_refused_as_its_family is red with this change's product
  files at a0d2d2efdd (___metal_ldexp_float: Linking, expected UnknownIntrinsic) and green with
  them;
- the two look-alike tests and surviving_calls_are_refused_by_family_naming_the_callee pass in
  both runs;
- the refusal surface regenerates to these files exactly, and its --check passes;
- the metal2vulkan-air and metal2vulkan suites: 3455 passed, 22 skipped.
2026-12-02 23:56:01 -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 c1e6805526 Conformance: the sample positions family at 8 samples, carried from an AMD Radeon Pro 5300M
The oracle, an Apple M3 Max, renders no 8 samples (supportsTextureSampleCount: answers no for 8),
and a Mac with an AMD GPU does. Three rows run the family's pass at 8 samples: the device's own
positions against an edge at 5/8 of the pixel (5 of 8 samples), eight positions at x 0.25 (8 of
8) and one at 0.25 with seven at 0.75 (1 of 8). Their Metal answer is carried from an AMD Radeon
Pro 5300M under macOS 26.7.1, plain and under Metal's API validation layer, which passed the
passes (job 82284, the usage-edges probe sample_positions_8.m): the resolved texels
01 00 00 9f, 01 00 00 ff and 00 00 00 20, record mode forbidden on the oracle.

Each row's coverage avoids a resolve halfway between two codes: there the 5300M rounds to the
even code (4 of 8: red 0, alpha 128; and 1 of 2 and 2 of 4: red 0) where the M3 Max rounds a half
up (red 1), which is the device's own rounding (PrecisionNote::DeviceRoundedResolve), not where
the samples are. The probe's sweep of the default positions, an edge at each even sixteenth,
covered 0 to 8 samples in order, as Vulkan's standard 8 locations do.

The rows are sample-positions-8x-default, -8x-custom-left and -8x-custom-mixed, one prefix that
tests::a_carried_answer_taken_on_another_chip_names_it lists beside managed-named-* as the 5300M's.
Their recordings were written on the oracle by record mode's carried path, which runs no Metal,
with the timing record `times --write` keeps for a case whose Metal leg is forbidden
(m3-max-82412).

Verified: the conformance suite and its clippy (m3-max-82421); the rows replayed through the
runtime on lavapipe (m3-max-82337, m3-max-82421), an RTX 3090 (m3-max-82314), an RX 7900 XTX
(m3-max-82315) and an Iris Xe (m3-max-82316): every byte equal to the 5300M's, each row announced
only by the device's own colour conversion or point size notes. The 2x and 4x default rows, whose
resolve halves a code, stay the known gaps the ledger holds on those cards.
2026-12-02 23:12:41 -08:00
Anees Iqbal 11c211ca64 Translator, runtime: no texture buffer access takes an own view a texture buffer held as words lacks; the own-view fact and gap go
The planner's ruling (b) after (i): with a read through a sampler built by the words, no access
MSL writes leaves a texture buffer on its own view on a device that holds some format as words,
so the runtime's Gap::TexelBufferOwnView and its plumbing (the kernel interface's own views, the
render content's, the encoders' checks before binds_words) go, and with them
RuntimeFact::TexelBufferOwnView, which nothing produces now.

Each access the words do not build now has an outcome that is not wrong output:
- A read that observes its residency is the words': its status word is 0, Metal's for a texture
  that is not sparse, as a texture buffer never is (with_word's 0); words::wrap no longer sends it
  to the own view.
- A read of an sRGB texture's codes is never a texture buffer's: srgb_texels answers false for a
  buffer's shape, so Read::raw is false there. Were one met, the compile refuses it.
- A read or write in another numeric class (LoweringInputs::cross_class): the runtime never sets
  it, and under the identity domains no variant is chosen; on a profile that holds some format
  as words the compile refuses such an access (Feature::Format, not implemented).
- A write of fewer than four lanes: the AIR front end takes a colour texture's write of four lanes
  alone (texture.rs, texel_ok), so such a call is an unknown intrinsic on every profile. The new
  authored case a_texture_buffer_write_of_two_lanes_is_refused_on_every_profile (an inline .ll of
  a8r_buffer_write narrowed to <2 x float>) checks Feature::UnknownIntrinsic on lavapipe and
  moltenvk-m3 under the identity domains.

Docs: words.rs module docs and wrap's doc, the runtime README's known gap rewritten as the
refusals; REFUSALS.md and the error basis regenerated (Gap 32 -> 31); api_signatures drops the
fact's and the gap's variants. The mechanism test's variant count returns to 87.

The fixture census at (i)'s tip, the condition the ruling set before this deletion (scratch job
m3-max-81238, steelbrain/scratch-tb-census): 18 fixtures naming texture buffers, 1477
compilations, no own-view fact on any profile that holds a format as words.

Verified with (i) at 355c902082 (gate m3-max-82186): fmt, clippy in three configurations, rustdoc,
the validation suite 1322 passed (3 skipped), the conformance suite 1050 passed, doctests; the
product suite 3723 passed with four reds a bless clears (the golden printout, the golden hashes,
the inventory, and llvm_as part_3_of_8 for tb_word_formats.ll, which has no rows until then),
the new authored case among them passing; the card legs as (i) lists them.
2026-12-02 23:05:54 -08:00
Anees Iqbal c56000f9e4 Translator: a texture buffer held as words is read through a sampler by the words
A read through a sampler (MSL 4.1's read(sampler, coord)) of a texture buffer took the texture's
own view alone, and where the device held the bound format as words the runtime refused the
draw or dispatch (Gap::TexelBufferOwnView). The words now build it: the site reads the
sampler's state (through::state), addresses the index against the words' width the way the own
view's read addresses it against its size (through::buffer_index, which address() now calls for
a texture buffer: the first texel outside, the nearest where a runtime slot sampler's s mode is
clamp_to_edge, the border where the t mode is clamp_to_zero or clamp_to_border), calls the read
routine at the addressed index, and where it reads the border hands back the border texel of
the format the word's code names (words::border_texels), the alpha 1 of a format without alpha
included. Such a read no longer records RuntimeFact::TexelBufferOwnView; the remaining own-view
accesses are a read that observes residency, a read or write of another numeric class, a read of
an sRGB texture's codes and a write of fewer than four lanes.

The site's word estimate adds the sampler's addressing again and THROUGH_WORDS (the view's size,
the width, the border texels by code).

Tests: engine_identity's read-through test now asserts no own-view fact and a words routine
where the profile holds formats as words. The runtime test reads rt_buffer (mirrored_repeat),
rt_buffer_ow (clamp_to_border, opaque white) and rt_arg_buffer through three runtime sampler
states (clamp_to_edge; t clamp_to_zero; t clamp_to_border opaque black) over six formats in
either form, against Metal's texel in bounds and outside.

Docs: words.rs module docs, the fact's and the gap's docs and Display, the runtime README's known
gap, RESOURCE-ID.md; REFUSALS.md regenerated.

Verified at the hand-over tip 355c902082, with (b), on development 8a2acc84fb: clippy in the
three configurations and the translator's tests (gate m3-max-82186; the read-through and words
tests 120 passed, m3-max-82186's focused step); on lavapipe the runtime's texture buffer tests 13
passed and the stream test passed, and the runtime's whole suite 972 passed, 4 skipped; the
read-through test over the three sampler states and six formats on an Iris Xe (m3-max-82187), an
RTX 3090 (m3-max-82193) and an RX 7900 XTX and a 780M (RADV, m3-max-82282), each format in its
form there (B5G6R5Unorm as words on the 3090, the XTX and the 780M); the read-through-buffer
conformance replay on lavapipe, base 8a2acc84fb against the tip, 0 of 1 cases differ
(m3-max-82188).
2026-12-02 23:05:54 -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 cb98ac0cb5 Conformance: srgb-storage-fragment-writes recorded on Metal, the coverage regenerated
Metal's run on an Apple M3 Max with its validation layer (job m3-max-82183, record then times
--runs 8 --write): each fragment's write stores the same bytes the kernel case's writes store, all
four stored sites equal to srgb-storage-writes' recording. On the runtime at development's tip the
case's draw is Gap::StorageElement; the runtime's draw test is red on lavapipe (job m3-max-82181,
filtered, 3 tests: 2 passed, 1 failed, the new one, refused StorageElement Absent).
2026-12-02 22:21:37 -08:00
Anees Iqbal c06f7e89db Translator, runtime: a texture buffer access the words do not build keeps its own view; a texture buffer held as words there is a gap at the draw or dispatch
The planner's ruling on (A)'s read-through loss, option (ii). Under the identity domains on a
profile that holds some format's texture buffers as words, words::wrap refused the whole module
for a texture buffer access its routines do not build: a read through a sampler, one that
observes residency, one in another numeric class, an sRGB code read, a write of another class or
of fewer than four lanes. The ceilings run (job m3-max-81042) lost three fixture rows that compile
on the base, development 530fb4ea4c: kernel_read_through's rt_buffer, rt_buffer_ow and
rt_arg_buffer, on lavapipe and on the runtime floor.

Such an access now keeps its strategy, the texture's own view, as on a profile that holds no
format as words, and the stage records RuntimeFact::TexelBufferOwnView { stage, texture }: the
slot, or None for a texture buffer reached through a handle. The fact's mechanism is a plan-time
check. The runtime's kernel interface and a render content's draws read it, and a dispatch or
draw that binds a texture buffer held as words at such a slot is Gap::TexelBufferOwnView of the
slot and its format; through a handle, any such dispatch or draw while a texture buffer held as
words is live (the gauge the words twin's handles test reads). Binding no texture buffer held as
words there changes nothing.

Tests: engine_identity's a_read_through_a_sampler_of_a_texture_buffer_takes_its_own_view compiles
the three entries under the identity domains on lavapipe and moltenvk-m3, passes L3, and checks
the fact where the profile holds a format as words and nowhere else (red before this: lavapipe's
compile refused). The runtime's a_read_through_a_sampler_refuses_a_texture_buffer_held_as_words
runs rt_buffer_ow over six formats. Each held directly answers its texels and Metal's white
border: three without a word layout, and three with one, whose border comes from the code. Each
held as words is refused at its dispatch with the gap of slot 0 and its format, and the same
state's next dispatch runs.

docs/REFUSALS.md and the error basis are regenerated. The runtime README's known gaps state the
refusal. api_signatures gains the fact's and the gap's variants.

Verified: not yet built; the ceilings, the gate, lavapipe device tests and the read-through-buffer
conformance replay follow.
2026-12-02 22:11:26 -08:00
Anees Iqbal e46643db97 Translator: a texture buffer's word keeps its border texels unless its format has a word layout
The words change cleared bits 0-11 of every texture buffer's word, on the premise that no texture
buffer is read through a sampler. Metal 4.1 reads one so (`read(sampler, x)`, the fixture
kernel_read_through's rt_buffer, rt_buffer_ow and rt_arg_buffer, the conformance case
read-through-buffer), and under the identity domains such a read takes the border texel from
those bits. So every texture buffer read through a bordered sampler read a zero border on every
device, and one of a format with a word layout read its fields as border texels. The base,
development 530fb4ea4c, kept the bits; found by reading, before any run.

Now TextureWord::of_texture_buffer is the texture word, border texels included, for a format
without a word layout, which is the base's word. A format with a word layout sets bit 13
(TextureWord::TEXEL_BUFFER_LAYOUT, 0 in every other word) and carries its fields in bits 0-10 on
every device. The words' held test requires bit 13, since a plain word's bits 2-7 are border
texels; a handle carries 14 bits of the word (HANDLE_WORD 0x3fff). A slot's read through a
sampler of a texture buffer takes the border texels from bits 0-11 where bit 13 is clear, else
from its format's code (words::border_texels, a choice among the values the word layouts'
formats have, grouped from WORD_FORMATS and metal::sampler::border_texels).

RESOURCE-ID.md and resource_words.tsv state the new word: the texture buffer lines of a word
layout gain bit 13, the others carry their border texels (the texture line's word at the default
swizzle).

Consumer search, the consumer's development 2221a41c20 (git grep -w over *.rs, *.c, *.h, *.m,
*.mm, *.cpp, *.py, *.tsv, *.md): TextureWord, of_texture_buffer, resource_word, resource_words,
BORDER_TEXELS, TEXEL_BUFFER, border_texels, OUT_OF_BOUNDS_ALPHA_ONE, PIXEL_FORMAT_SHIFT: 0 hits
each. The consumer takes each texture's ID from the runtime's gpu_resource_id.

Verified: not yet built. The unit test words::each_code_takes_its_format_s_border_texels holds
each code to its format's border texels; the runtime test and the lavapipe replay of
read-through-buffer come with the next commit.
2026-12-02 22:11:26 -08:00
Anees Iqbal 5a933f58cf Docs: REFUSALS.md regenerated: the render content's stage_module builds RenderPipeline refusals
The words twin moved the stage-module refusals of RenderCompiled::of into stage_module
(python3 scripts/refusal-surface/refusal_surface.py).
2026-12-02 22:11:26 -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 dc3e5ab673 Texture buffers: the site reads the profile's word codes from the plan; the player's word of a texture buffer; a replay stream of texture buffers
The site test read the codes from the module's declarations, which do not hold them; it reads
the plan's. The player compared a texture buffer's recorded ID with TextureWord::of, whose border
texels a texture buffer's word does not carry; it takes TextureWord::of_texture_buffer of the
descriptor's format and width, as RESOURCE-ID.md and REPLAY-STREAM.md now say. rt_replay gains a
stream of texture buffers of five formats (RGBA8Unorm, R8Unorm, BGRA8Unorm, B5G6R5Unorm,
RGBA16Unorm) over a Shared buffer, read, written and read-written by tb_word_formats with the IDs
the program saw recorded, each played on the cfg's device: no id line, the CPU's texels and
values, and each format's form on that device printed. Unbuilt.
2026-12-02 22:11:24 -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 432bbb0a60 Replay player: a noted word in a buffer reached only as texels plays as recorded
The player moved every written word whose value lies in a buffer noted
escaped (AddressMap::move_noted), whatever the buffer it was written into.
In rec-m3-max-80463 it moved 3 RG8 mask words of no-copy buffer #1960,
which the program reads only as texels through texture #1962 over it. Each
play wrote its own host address there, so two plays read different texels
(audit lane, m3-max-81898 and m3-max-81914).

Now the move is decided by the stream's structure:
- read_ahead, which already walks the whole stream, notes each buffer's
  life, keyed by the object and its making's position (as recorded_ids
  is):
  - whether a texture is made over it (it receives
    newTextureWithDescriptor:offset:bytesPerRow:, the tiled form or the
    linear form);
  - whether any call names it as an argument, at any depth of lists and
    maps, but a copy between a buffer and a texture (copyFromBuffer:...
    toTexture:..., copyFromTexture:...toBuffer:...), whose bytes are texels.
  A buffer with a texture over it and no such naming is reached only as
  texels.
- At an object's making the play marks it live as such, or unmarks the id.
- place_words takes the write's target (none for set*Bytes data). Into a
  buffer reached only as texels, the words move_noted would move play as
  recorded and are counted as texel_only_words (AddressMap::count_noted,
  which shares move_noted's pass). The census is unchanged.
- Unchanged: a buffer with no texture over it, including one the stream
  never names (the existing noted-word test), set*Bytes data, and any
  buffer bound, encoded, used, copied buffer to buffer or added to a
  residency set.

texel_only_words is a new stream counter: in FIXED, frame and group lines,
and the report's addresses line. Docs: REPLAY-STREAM.md section 5's
noted-word paragraph and section 10's counts and addresses line. The
counter lists the replay tests spell out gain it.
2026-12-02 21:56:36 -08:00
Anees Iqbal 3ecfe8f034 Conformance ledger: the BGRA4Unorm texture buffer's rows follow the device's texel-buffer query
a3fb852de3 (a heap makes texture buffers in place) sizes a heap's texture buffer through the
format's texel form, which takes a format whose buffer features hold both the uniform and the
storage texel buffer. On the Iris Xe, whose ANV holds A4R4G4B4_UNORM_PACK16 so, the heap's size
and alignment of the format-footprints-plain-stragglers BGRA4Unorm texture buffer now answers
(Metal's 128 at 16), and the case reaches its makes-texture site, which the runtime's side refuses
as Refusal::TextureBufferNotOverBuffer, the consumer's contract. The ledger's one row for every
venue refused the size-and-align site, so the Iris's conformance replay went red at pin M
(m3-max-82006: an unlisted makes-texture refusal) while the RTX 3090's held (m3-max-82034).

Now:
- the size-and-align row is one per venue whose device lacks the storage texel buffer of both of
  the format's Vulkan formats (NVIDIA, RADV, llvmpipe, Apple M3 Max, UHD Graphics 630), naming
  a3fb852de3;
- the Iris Xe has a makes-texture row with the consumer's-contract reason the other texture
  buffers' rows carry, naming a3fb852de3;
- each says Metal's validation layer refuses this format for a texture buffer, so what such a
  texture reads is outside documented Metal and no value comparison is owed for it;
- the runtime's README says a texture buffer's answer, the heap's size included, follows the
  format's texel-buffer features: the devices differ by query, not by form.

docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py; --check
clean), as are the metal-coverage and refusal-surface checks.
2026-12-02 21:47:08 -08:00
Anees Iqbal bbdf8d4d90 Conformance recordings: the five managed-named cases, carried from the 5300M's measurement
Each recording holds the case's carried answer as record mode writes a carried case's: the
transcript of the reader's content as an AMD Radeon Pro 5300M under macOS 26.7.1 read it, 8
rounds a reader (jobs 81602 and 81644), measured_on amd-radeon-pro-5300m, validated not run. The
compute slot, the declaration, the vertex slot and the blit source read the bytes as of the
reader's commit; the reach through the address alone reads the bytes the GPU's copy last took.
The oracle's own run is forbidden by the cases (one copy), so nothing here ran on Metal.

They were written by record::carried and record::write, the calls record mode makes for a
carried case, through a scratch test of a CPU-only job's own workspace (job m3-max-81916, at
c098a9848e), never committed. docs/CONFORMANCE-COVERAGE.md is regenerated with them
(scripts/conformance-coverage/coverage.py): 192 case modules, 1347 recordings, 85 carried.

Verified: in the same job the conformance suite ran 1050 tests, 1048 passed; the two failures are
the coverage document, regenerated here, and the cases' missing Metal time records, which the
oracle's times run adds next.
2026-12-02 21:46:14 -08:00
Anees Iqbal 8be5365553 Player: a two-copy stream's announcement is taken at the first commit that names the buffer
The runtime now takes a Managed range at the first commit whose encoders name
its buffer, as Metal on an AMD Radeon Pro 5300M does (jobs 81602, 81644). The
player's own second copy, which a two-copy stream's Managed buffers take on a
device with unified memory, took every range named at the next commit of any
command buffer; it now follows the runtime's rule.

- second.rs: Seconds keeps, for each command buffer not yet committed, the
  buffers with a second copy its encoders named, themselves or through a
  texture over one (made over the buffer, a tiled one, or a view of one), and
  a commit takes only those buffers' ranges. A released buffer with ranges
  pending stays only while a command buffer not yet committed that named it,
  or a texture over it, can take them; otherwise its place goes back at once.
  A command buffer released uncommitted takes nothing.
- mod.rs: each encoder call's named objects, a render pass's attachments,
  resolve textures and visibility result buffer at its encoder's making, and
  the textures and views made over a second copy feed it. render.rs keeps the
  pass's resolve textures and visibility result buffer by stream id.
- encoders.rs: copy_named takes the committing command buffer's ranges alone.
- stale.rs: a didModifyRange: is pending until a commit whose uses name the
  object takes it, with the bytes written by then (an indirect command
  buffer's command takes it where it is encoded); writes between the
  announcement and that commit are not stale.
- docs/REPLAY-STREAM.md says so.

Tests: rt_replay a_two_copy_stream_s_announcement_is_taken_at_the_first_
commit_that_names_the_buffer (zeros announced, a commit of another buffer, 7s
written with no announcement, a copy of the buffer reads the 7s); tests
an_announcement_is_taken_at_the_first_commit_that_names_its_buffer (the
census counts one stale use where it counted two). Not yet compiled.
2026-12-02 21:46:13 -08:00
Anees Iqbal 2b335a8174 rt docs: the memoryless refusal's basis says what is true now
Gap::MemorylessTexture's basis read "render passes are not built", which stopped being true
when render passes were built. It now names the reason the refusal stays: a memoryless
attachment keeps its contents for the whole render encoder, across the renderings the runtime
ends and restarts inside one encoder (barriers after writing draws, the feedback-loop barrier,
copies for textures over buffers and Managed copies, shadow copies), and the image that would
hold them is not built. docs/REFUSALS.md regenerated (scripts/refusal-surface).

Docs only: no behaviour changes. refusal_surface.py --check exits 0.
2026-12-02 21:43:32 -08:00
Anees Iqbal e4195ee560 Conformance recording: indirect-range-gpu-written-indexed-patch-draws on Metal
Metal's answer for the indexed-patch-draws range row, recorded on the Apple M3 Max (macOS 27.0.1,
26A434) by job m3-max-81637 at 992794d8bd (the AIR commit, d244877fb2 after the rebase onto
685bde8009, the same patch), with its times (8 rounds, the same job). The execution completes, and
commands 1 to 5 draw rows 2 to 11 whole: each command's quad, whose four corners are stored out of
order and named in order by its 16-bit control-point indices, covers its two rows. Each texel
holds the command's mark, the patch index i, the instance and the base instance i, the patch-draws
row's texels exactly.

The ledger's Iris Xe row is the Extension refusal, as for the other range rows: the Iris Xe lists
no VK_EXT_device_generated_commands. CONFORMANCE-COVERAGE.md is regenerated.
2026-12-02 21:09:01 -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 0539084768 Conformance recording: indirect-range-gpu-written-patch-draws on Metal (red still)
Metal's answer for the patch-draws range row, recorded on the Apple M3 Max (macOS 27.0.1,
26A434) at 0616460f73 by job m3-max-81499, with its times (8 rounds, the same job). The
execution completes, and commands 1 to 5 draw rows 2 to 11. Each texel holds the command's
mark, the patch index i, the instance and the base instance i. The instance a post-tessellation
vertex function reads counts from the base instance: an odd command's second instance reads
i + 1, an even command's only instance reads i.

The ledger's Iris Xe row is the Extension refusal, as for the other range rows: the Iris Xe
lists no VK_EXT_device_generated_commands. CONFORMANCE-COVERAGE.md is regenerated.

Red: the runtime refuses an indirect command buffer of DrawPatches (CommandTypes), so the
row's replay meets a refusal that the ledger does not list.
2026-12-02 21:06:53 -08:00
Anees Iqbal dcf039d472 rt: a copy between two buffers whose bytes meet goes in chunks of the shift, as memmove
Owner 3406 follow-up to L212. A copy between two buffers whose ranges meet
in one block was refused (Refusal::BufferCopyOverlap, basis "ours"). Two
buffers placed over each other in a heap are aliases. Metal's validation
names copies between buffers among the defined copies between aliases in
a placement heap (job m3-max-81493), and plain Metal on an Apple M3 Max
gives memmove's bytes for them (probe overlapping_alias_copies.m, job
m3-max-81544).

Form (blit.rs):
- buffer_to_buffer takes whether the two are one buffer and answers
  BufferChunks.
- Ranges apart are one chunk.
- Two buffers' ranges whose bytes meet are chunks no longer than the shift
  |to - from|, the last chunk the rest. The chunk at the end the shift
  points to goes first: the last first where the destination lies past the
  source, else the first. So no command's source and destination share a
  byte (VUID-vkCmdCopyBuffer-pRegions-00117, which each one-region command
  meets on its own), and no chunk reads a byte an earlier one wrote.
- copy_from_buffer_to_buffer records one vkCmdCopyBuffer a chunk with the
  slabs' execution barrier (between) between two, each counted as a blit
  barrier. Every hazard between two chunks is a write after a read.
- Two ranges on the same bytes copy nothing.
- One buffer's overlapping ranges stay Refusal::BufferCopyOverlap. Its basis
  is now metal-documented: Apple's page for the copy allows the same buffer
  only "if size is less than the distance between sourceOffset and
  destinationOffset". The conformance case buffer-blit-overlapping-copies
  is one buffer, so its ledger row holds. Only its note's wording changed;
  coverage.py regenerated with no change.
- A shift of n bytes takes size/n commands, rounded up. That is the fewest
  any form without an intermediate takes.

Unit test a_copy_between_buffers_takes_ranges_inside_both_and_cuts_two_buffers_bytes_that_meet
(renamed) expects the chunk orders both ways, a partial last chunk, and
nothing for the same bytes. The rest of its cases are unchanged.

Docs: the copy's doc, BufferCopyOverlap (REFUSALS.md and basis.rs
regenerated), the runtime README's blit encoders, the tests' module doc.

Verified: refusal_surface.py --check exits 0. Green under the validation
layer, which fails a test on any message, so each one-region chunk met
VUID-vkCmdCopyBuffer-pRegions-00117 on these devices: the 27 blit tests pass
on lavapipe (llvmpipe, LLVM 23.1.4; job m3-max-81597), the AMD Radeon 780M
(RADV PHOENIX; m3-max-81592), the NVIDIA GeForce RTX 2080 (m3-max-81600) and
the AMD Radeon RX 7900 XTX (RADV NAVI31; m3-max-81671). The runs built the
series before its rebase onto development; the patches are the same.
2026-12-02 21:06:53 -08:00
Anees Iqbal 2416a42d36 rt: copies between a heap texture and memory it aliases are Metal's own refusal, but a whole level between two heap textures
Row L212. Metal's API validation stops a copy between aliases in a placement
heap unless it copies between buffers, between linear textures of one row
stride, or entire texture surfaces. Source: probe overlapping_alias_copies.m
on an Apple M3 Max, macOS 27.0.1, jobs m3-max-81486 and m3-max-81493. The
runtime refused all of these as Gap::OverlappingCopy. It now refuses what
Metal stops as Refusal::AliasingCopy, and records nothing for it.

Form (blit.rs):
- buffer_copy: a region that meets a heap texture's memory, either way, is
  Refusal::AliasingCopy (Metal: "blitting between aliasing resources is
  defined on a placement heap only when using a blit method copying entire
  texture surfaces, or when copying between buffers").
- texture_copy: two textures whose memory meets, one placed in a heap, that
  are not both heap textures copying a whole level into a whole level
  (whole_level: origin 0, size the level's extent, the view's first level
  taken off) are Refusal::AliasingCopy. A texture in place over a heap
  buffer against a heap texture is refused even for a whole level (Metal:
  "... only when both textures are linear and have the same
  bufferBytesPerRow value").
- The whole level between two heap textures stays Gap::OverlappingCopy,
  counted, per the planner's ruling. That is how the consumer reaches
  copyFromTexture:toTexture:, which Metal's validation takes and the M3
  answers with the source's bytes at 0, 128 and 8320 bytes apart. No copy
  command and no cut reads no byte it writes
  (VUID-vkCmdCopyImage-pRegions-00124). The form through an image of the
  runtime's, counted, is built once a guest's run counts the gap.

Docs: blit.rs's module and copy method docs; error.rs's Gap::OverlappingCopy
(REFUSALS.md regenerated); Metrics::overlapping_copies_refused; the runtime
README's blit encoders and their known gaps, which carry the M3's answer
and the VUID. The README also cites the M3's answer for a surface's buffer
and its own plane (job m3-max-81486). No conformance ledger row covers
these shapes.

Verified: refusal_surface.py --check exits 0. Green under the validation
layer, which fails a test on any message: the three tests pass, with the
rest of the 27 blit tests, at the series' tip on lavapipe (llvmpipe, LLVM
23.1.4; job m3-max-81597), the AMD Radeon 780M (RADV PHOENIX; m3-max-81592),
the NVIDIA GeForce RTX 2080 (m3-max-81600) and the AMD Radeon RX 7900 XTX
(RADV NAVI31; m3-max-81671). The runs built the series before its rebase
onto development; the patches are the same.
2026-12-02 21:06:41 -08:00
Anees Iqbal 19d642612d Tests: copies between a heap texture and memory it aliases are Metal's own refusal, but a whole level between two heap textures
Row L212. These copies were all Gap::OverlappingCopy: a copy between a
texture placed in a heap and a resource whose memory meets it.

On an Apple M3 Max, macOS 27.0.1, the conformance probe
overlapping_alias_copies.m (jobs m3-max-81486 and m3-max-81493) shows that
Metal's API validation stops most of these shapes with
"blitting between aliasing resources is defined on a placement heap only
when using a blit method copying entire texture surfaces, or when copying
between buffers":
- a buffer and a texture over its bytes, either way;
- the region method between two heap textures that alias.
It stops a heap texture and a linear texture over a heap buffer at its
bytes with "... only when both textures are linear and have the same
bufferBytesPerRow value". It passes copyFromTexture:toTexture: between two
heap textures that alias. The consumer copies that as whole levels through
copy_from_texture.

The new Refusal::AliasingCopy (Basis: metal-measured) names the shapes
Metal stops. docs/REFUSALS.md, error/basis.rs and api_signatures.tsv are
regenerated. A whole level into a whole level between two heap textures
stays Gap::OverlappingCopy, per the planner's ruling. Nothing produces the
new variant yet.

Tests:
- textures_whose_memory_meets_where_one_is_laid_out_by_the_device_are_refused_or_copy_in_no_order
  (unit, renamed) expects the two heap textures' whole-level copy still to
  copy in no order. It expects part of a level, either way and at an offset,
  and a texture in place over the heap texture's bytes, either way, to be
  Refusal::AliasingCopy.
- a_buffer_copy_over_its_texture_s_own_bytes_copies_in_slabs_or_in_no_order
  (unit) expects a region meeting a heap texture's memory, into it and out
  of it, to be Refusal::AliasingCopy.
- every_device_refuses_a_copy_between_heap_resources_whose_memory_meets
  (device) expects the whole level onto its alias to be the counted gap,
  and part of a level onto its alias and the heap buffer either way to be
  Refusal::AliasingCopy. Nothing is recorded, and one refusal is counted.

Verified: refusal_surface.py --check exits 0, and signatures.py --bless adds
the one variant row. Red as expected, under the validation layer, on
lavapipe (llvmpipe, LLVM 23.1.4; job m3-max-81597), the AMD Radeon 780M
(RADV PHOENIX; m3-max-81592), the NVIDIA GeForce RTX 2080 (m3-max-81600) and
the AMD Radeon RX 7900 XTX (RADV NAVI31; m3-max-81671): the three tests
fail. The device test says "part of a level onto its alias:
Err(Unsupported(OverlappingCopy { pixel_format: RGBA8Unorm }))", the unit
tests "not a refusal: it was checked". The runs built the series before its
rebase onto development; the patches are the same.
2026-12-02 21:06:24 -08:00
Anees Iqbal 62e3835aa1 Docs: CONFORMANCE-COVERAGE.md regenerated for the plain-draws row's notice
5781011f02 gave indirect-range-gpu-written-plain-draws its point-size notice allowance and left
docs/CONFORMANCE-COVERAGE.md one line behind it (coverage.py --check: not what the suite's
sources and recordings derive). Regenerated; --check now says as derived.
2026-12-02 21:06:03 -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 21f0cae67b ICB: a kernel's plain triangle draws into an indirect command buffer, executed through a layout of plain draws
The owner's 3406 order, the planner's first indirect command kind: MTLIndirectCommandTypeDraw.

Translator (lower/access/icb.rs): a render_command's draw_primitives of the constant triangle type
writes VkDrawIndirectCommand (vertex count, instances, vertex start, base instance) where an
indexed draw's VkDrawIndexedIndirectCommand goes, 20 bytes past the index token's place, and
writes nothing else. Both kinds share the records (pipeline::IndirectDrawLayout), so an encoding
writes one shape whatever buffer it reaches. A kernel cannot know a buffer's kind when it is
translated, because it reaches the buffer through an argument buffer. A reset's draw of nothing
reads as either kind's. Points and lines stay refused, as for indexed draws, because an execution
draws one topology.

Runtime: Device::new_indirect_command_buffer takes DRAW alone as well as DRAW_INDEXED alone, and
the buffer keeps its kind (indirect::CommandDraw). An execution's command layout follows the
kind. A layout of plain draws holds no index buffer token, which
VUID-VkIndirectCommandsLayoutCreateInfoEXT-pTokens-11095 forbids there, and ends in TOKEN_DRAW.
Its tokens are one fewer. The execution shapes' cache keys on the kind, and the reset templates
serve both kinds.

DRAW together with DRAW_INDEXED stays a typed refusal, CommandTypes, until the planner rules. A
layout takes one draw token (VUID-...-11100), and no form found draws both kinds in command order
at a bounded cost: two executions reorder the commands, an execution per command costs two a
command, and identity indices hold only as many vertices as a bound buffer of them. The
CommandTypes doc, the runtime README's ICB section and its refusal line say so.

Docs: the README ICB section; METAL-COVERAGE (coverage.tsv: "plain or indexed triangle draws");
CONFORMANCE-COVERAGE regenerated for the new row's recording and ledger row. REFUSALS.md
regenerated with no change.

Not run on an Intel card: the Iris Xe lacks VK_EXT_device_generated_commands, so its ledger row
is the Extension refusal; the four-card proof jobs are named in the hand-over.
2026-12-02 21:06:03 -08:00
Anees Iqbal 16f7bc942e Runtime: a texture over host memory's import is restored inside its make, which waits for it
The planner ruled the seam (ii), for new_texture and new_texture_in_place alike, one form: the
restore pair of a texture in place over host memory's import runs in a submission of the
runtime's own inside the make, and the make returns after it completes. Metal touches no bytes at
a make, and a CPU write to a Shared buffer that no pending GPU command uses is fully defined.
Running the pair at the next submission on any queue let one thread's commit revert another
thread's write (reims: an app wrote its first frame into a fresh pool surface under a lock that
waits on nothing, and a later submission from another process ran the pair mid-write): a lost
write documented Metal never loses. The planner's earlier term (the pair in the texture's first
command buffer, held by an ordering test) is withdrawn. Discrete devices are untouched: they have
no pair.

Device::texture, for a texture whose image restores (Keep::Restore), has the upload that holds
its move home go at once, alone (WorkState::flush), and waits on the progress semaphore for it
(Done::wait), the pattern Texture::get_bytes and new_buffer's Private zeroing use. The upload's
barrier orders the save after the GPU work already submitted, so the make waits for that work
too. An encoded shared-event wait is held on the CPU and never submitted, so it never holds the
make's submission back. The make is refused in a scheduled handler (Refusal::InScheduledHandler),
which runs on the submit thread that the make waits for, as those calls are.

Docs: new_texture's and new_texture_in_place's, InScheduledHandler's list, the counters'
(HostMemoryRestore inside the make), check_over's and the homing comment; the runtime README's
Imported blocks paragraph and its known gap, which now says what remains (a host write from
another thread during the make) and carries the Radeon 780M row (Phoenix, RADV, job
m3-max-81673: 696 against 537 us a frame at one draw, 1025 against 793 at four);
docs/REPLAY-STREAM.md; AGENTS.md rule 2 ("after one counted copy pair at its making") and rule 3
("a counted copy pair at the texture's making restores the bytes"), in the planner's words.
Tests: host_in_place, over_causes and import count the pair at the make.

Verified on lavapipe, job m3-max-81704: the seam test failed at the commit before (exit 100) and
passed here (exit 0), with clippy under --cfg m2v_cpu_icd clean. With the series' final code (runs
at its README commits, which change no code), the touched device tests with in_place_views passed on
the Apple M3 Max under KosmicKrisp 26.3.1 (job m3-max-81753, 12 of 12), the Radeon 780M (job
m3-max-81798, 18 of 18), the Iris Xe (job m3-max-81801, 18 of 18) and the RTX 3090 (job
m3-max-81792, 18 of 18), the integrated three restoring in place inside the make (32 restore copies
over sixteen 1080p makes); gate job m3-max-81765 (clippy in three configurations, Rustdoc, the
runtime's private Rustdoc, and the runtime, translator, validation and conformance suites) passed
with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal 2186bd04d1 Runtime: an in-place texture's restore pair counts under OverCause::HostMemoryRestore
A texture in place over host memory's import on an integrated or CPU device costs one save and
write-back of the bytes under its image around its move out of the undefined layout, once, at
its first use. Those two copies counted under OverCause::HostMemory, beside a copied texture's
copies at its uses, so a census could not tell an in-place texture's kind line from a copy's.
The planner ruled (row 1, pin N) that the pair stays counted, in count and bytes and in the
totals, under a cause that says what it is.

The upload's restore now counts under OverCause::HostMemoryRestore, in
Metrics::over_copies_host_memory_restore and over_copy_bytes_host_memory_restore, and still in
over_copies, over_copies_imported and bytes_copied; its OverCopyKind carries that cause.
over_copies_host_memory counts the per-use copies alone. Docs: new_texture's, the runtime
README's Imported blocks and over-copy paragraphs, docs/REPLAY-STREAM.md's over-copy causes (now
twelve beside host memory's) and the frame line's host_memory part, which carries the restore
pairs.

Verified on lavapipe before the rebase onto 9ce9960452, job m3-max-81616: the tests failed at the
commit before (3 of 12 failed) and passed here (12 of 12). Then gate job m3-max-81765 (clippy in
three configurations, Rustdoc, the runtime's private Rustdoc, and the runtime, translator,
validation and conformance suites) passed with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal 5f9287e40e Runtime: Buffer::new_texture_in_place, a texture over a buffer in place or a typed refusal
The consumer keeps a texture of its own where the runtime would make the counted copy of a
texture over a buffer, and needs the runtime's in-place texture everywhere else. Buffer::
new_texture_in_place makes what Buffer::new_texture makes where that texture is in place, and
refuses with Refusal::TextureNotInPlace { cause } where new_texture would make the copy, naming
the OverCause its copies would count under. A refusal makes no texture and counts no copy.

One decision in one place: Source::Over carries what the making does with a texture it would not
make in place (Unplaced::Copy for new_texture and a surface plane's texture, Unplaced::Refuse for
the new call). Device::texture refuses at the same two points where it chooses the copy: where
check_over names a cause, and where the linear image made does not lie as the texture's bytes do
(Unmade::Unfit). No new form and no new query: over host memory's import the choice is still
row 1's unified-memory query alone. A texture buffer is a view, never copied, and is made as
new_texture makes it.

The doc comment names newTextureWithDescriptor:offset:bytesPerRow: and lists what is refused;
texture_copy_cause's doc and the runtime README name the new call. docs/REFUSALS.md regenerated
(the refusal's two sites in texture); api_signatures blessed at the red commit.

Verified on lavapipe before the rebase onto 9ce9960452, job m3-max-81616: copy_cause's test failed
at the commit before (1 of 12 failed) and passed two commits on (12 of 12). With the series' final
code (runs at its README commits, which change no code), the touched device tests with
in_place_views passed on the Apple M3 Max under KosmicKrisp 26.3.1 (job m3-max-81753, 12 of 12), the
Radeon 780M (job m3-max-81798, 18 of 18), the Iris Xe (job m3-max-81801, 18 of 18) and the RTX 3090
(job m3-max-81792, 18 of 18); gate job m3-max-81765 (clippy in three configurations, Rustdoc, the
runtime's private Rustdoc, and the runtime, translator, validation and conformance suites) passed
with the series' final code.
2026-12-02 20:07:40 -08:00
Anees Iqbal cbe89f239d Runtime tests: a texture over a buffer made in place alone agrees with the ordinary make (red)
The consumer asked for an in-place-only make of a texture over a buffer: the linear image in
place wherever Buffer::new_texture takes it, and a typed refusal naming the cause wherever
new_texture would take the counted copy, so that the consumer keeps those bytes in a texture of
its own and counts them.

This commit adds Refusal::TextureNotInPlace { cause: OverCause } (Basis: ours), its Display arm,
docs/REFUSALS.md and basis.rs regenerated, the api_signatures table blessed, and a stub
Buffer::new_texture_in_place that makes the ordinary texture. copy_cause's test now runs each
device in both forms (an integrated or CPU device through its two-copy view too), makes each
case in place alone beside the ordinary texture, and adds a render target over its texels alone,
an R8Unorm texture of 13 x 3 at the device's pitch, and RGBA8Unorm and R8Unorm textures over host
memory's import. It asserts that the in-place-only make is in place where texture_copy_cause
answers in place, and elsewhere refused for that cause with no texture made and no copy counted.

Expected red on every device: the stub makes the counted copy where the answer is a cause (the
pitch case at least, on every device).
2026-12-02 20:07:39 -08:00
Anees Iqbal 0703c09cdb Runtime: a texture over host memory's import in place on an integrated or CPU device alone, the counted copy at each use elsewhere
The planner's ruling on row 1 (a). The in-place form over a host-pointer import is chosen by rule 2's
unified-memory query, Vulkan's physical device type (Core::unified_memory, the query that keeps one
copy of a Managed buffer): in place on an integrated or CPU device, after one counted copy pair at its
first use; on a discrete or virtual device the per-use counted copy stays. The planner's earlier term
that deleted the per-use path is withdrawn by name: that path stays, for discrete devices alone. It
is the same query and the same form, widened, not a new one.

Grounds. On an integrated device a texture over Shared memory is already a linear image in place by
rule 3, on the ordinary Shared-buffer route and on the dma-buf import route, and pays the same linear
read; the host-pointer import was the one case still copying at each use. The speed pair (a scratch
timed test, never landed: a 1920x1080 RGBA8Unorm texture over host memory the CPU writes whole each
frame, read at every texel by a 1080p pass of 1 or 4 draws; base d69a0bda18, in place 99125586fb;
six alternating runs of 300 frames each, frame time in microseconds, per-use copy against in place):
- Apple M3 Max, KosmicKrisp 26.3.1, job m3-max-81356: 1016 against 843 (1 draw), 1043 against 888
  (4 draws).
- Intel Iris Xe (RPL-P), ANV Mesa 26.2.6, job m3-max-81425: 3069 against 2630 (1), 4810 against 5381
  (4): a full linear read costs about 360 more than an optimal one and the copy about 480 to 500,
  so in place costs more from about two full reads a frame. The planner: that loss is against the
  copy being removed, in a kernel built to be its worst case, a recorded cost of the linear form,
  not a guest-shown regression; reims's census B on the M3 is the real-workload row.
- AMD RX 7900 XTX on OCuLink, RADV Mesa 26.2.6, job m3-max-81416: 1602 against 1561 (1), 1743
  against 1579 (4), within the spread: in-place reads at the copy's own rate, about 6.7 GB/s.
- NVIDIA RTX 3090 behind Thunderbolt, 620.70.06, job m3-max-81379: 5219 against 12522 (1), 5291
  against 12564 (4): the copy at about 1.98 GB/s, in-place reads at about 0.72 GB/s.

check_over lays a texture over host memory's import in place only where core.unified_memory();
elsewhere memory_cause names OverCause::HostMemory, the counted copy at each use. AGENTS.md: rule 2's
unified-memory clause gains the planner's words verbatim ("and a texture over a host-pointer import
in place on an integrated or CPU device, after one counted copy pair at its first use, and through
its per-use counted copy elsewhere"), and rule 3's host-pointer-import clause is limited to an
integrated or CPU device. The runtime README's Imported blocks paragraph names the device type, and
its known gap of memory blocks is one entry with the four rows. Buffer::new_texture's doc, the
counters' docs (OverCause::HostMemory, over_copies_host_memory, textures_in_place_over_imports),
REPLAY-STREAM.md and the device tests' docs say the same.

Verified before its rebases, on adba2693a1: on lavapipe, job m3-max-81460, the device-type test
failed at the commit before (1 of 2 failed) and passed here (2 of 2); the touched device tests
passed 15 of 15 on the Apple M3 Max under KosmicKrisp (job m3-max-81454), the Iris Xe
(m3-max-81456), the RX 7900 XTX (m3-max-81503), the RTX 3090 (m3-max-81555, the per-use copy) and
the Radeon 780M (m3-max-81556, in place); gate m3-max-81446 passed. Then gate job m3-max-81765
(clippy in three configurations, Rustdoc, the runtime's private Rustdoc, and the runtime,
translator, validation and conformance suites) passed with the series' final code.
2026-12-02 20:07:39 -08:00
Anees Iqbal 4b7f935a80 Runtime: a texture over host memory's import in place, its bytes saved and written back once
A texture over a buffer in host memory's import (Device::import_host_memory) used to be the counted
copy at every use. Its bytes were copied into an image of its own before each submission that used
it, and back after each write. Now it is in place: the device's linear image, made for host
memory's handle, bound in the import's own memory. The condition is that the external image query
for VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT answers the linear image importable,
compatible and not dedicated-only, and that the image passes the tests of any texture over a
buffer in place.

This is not a new copy. It is the existing last form made smaller: one copy pair in the texture's
life, in place after it, on documented behaviour only.
- Created UNDEFINED: an image bound in imported memory names the import's handle type
  (VUID-vkBindImageMemory-memory-02989), so it starts undefined
  (VUID-VkImageCreateInfo-pNext-01443).
- Saved and written back around the one transition: a move out of the undefined layout may
  discard the bytes (Vulkan 1.4, section 7.1.1).
- Host access by memory-domain operations: host memory has no other side whose release an acquire
  could match (section 11.2.6).

The image's one move home is in the upload ahead of the first command buffer submitted after the
making, from any queue, in this order:
1. a barrier from every earlier command's writes, including earlier submissions on the one
   queue, to the save;
2. a copy of the bytes bound under the image into a Private block taken at the making;
3. the move, in a barrier that waits for the save's reads;
4. the write-back, with a barrier between write-backs, since two imports of the same pages may
   meet;
5. a barrier from the write-backs to every later command and the host.
The block goes back once the upload retires. A later use copies nothing. Where the query offers no
linear image of the format and usage, the texture stays the counted copy at each use. On the Mac
driver that is every render target, since it makes no linear colour attachment.

Counts:
- the two copies count in Metrics::over_copies_host_memory (and over_copies, over_copies_imported,
  bytes_copied), each of the bytes bound under the image;
- new: Metrics::textures_in_place_over_imports counts each texture in place over an import, host
  memory's or a dma-buf's, at its making;
- the replay's frame metrics carry it.

Docs, in this commit:
- AGENTS.md rule 3's first exception gains the planner's clause verbatim;
- the runtime README's Imported blocks gives the form, and states the two VUIDs' rule in plain
  words;
- its known gap gives the pair, the window while the upload runs (a host write may be lost, and a
  host read may see the bytes undefined), and which formats and usages keep the per-use form on
  which driver, by query;
- REPLAY-STREAM.md and Buffer::new_texture's doc follow.

Tests:
- host_in_place gains two checks: a fill submitted before the making and not waited for is in the
  first read, and the texture counts once at its making;
- over_causes, import's texture test and imported_aliases now take either form, asserting in
  place on lavapipe and the copy where the query refuses.

Verified on the system lavapipe (llvmpipe, LLVM 23.1.4), job m3-max-81271, filter host_in_place,
over_causes, import's texture test, imported_aliases, import_overs and layouts: 17 tests.
- Red at the commit before: host_in_place fails at its in-place assertion; the other 16 pass.
- Green, at a tree whose code equals this commit's: 17 of 17 pass. The restore pair is 2 copies,
  512 bytes. In imported_aliases, the Half textures are in place, two pairs for two textures over
  one import. Clippy -D warnings under --cfg m2v_cpu_icd is clean for the runtime and validation.
2026-12-02 20:07:39 -08:00
Anees Iqbal 9ce9960452 Conformance tests: record mode reads the host's macOS release from the side, so its tests run on any Mac
CI run 47018745061 (at 9186e2fe46) passes macOS's validation suite. Its next
step, "Test the conformance suite", fails 2 of 1054 on the macos-26 runner
(macOS 26.7.2, 25G332):
- record_mode_counts_the_outcomes_it_saw_with_their_runs unwraps
  Err(HostMoved { found: "macOS 26.7.2 (25G332)", named: "apple-m3-max on
  macOS 27.0.1 (26A434)" });
- record_mode_refuses_a_case_whose_metal_run_stopped gets the same
  HostMoved where it expects Refused.
These tests check record mode's logic through a stub side, but record mode
read the host's sw_vers directly. So on any Mac but the oracle, the host
check stopped them first.

Form:
- The Side trait gains macos_release (macOS only). Its default answers this
  host's sw_vers -productVersion and -buildVersion (record::sw_vers, the
  same reads check_host made). Metal's side and the runtime's side keep the
  default.
- check_host takes the side and holds its release against ORACLE_OS_VERSION
  and ORACLE_OS_BUILD as before. HostMoved and its text are unchanged. Off
  macOS it is NoMetal, as before.
- watch::Watching forwards macos_release to the side it wraps, as it
  forwards every Side call (the_announcing_side_forwards_every_call reads
  the trait). docs/CONFORMANCE-COVERAGE.md is regenerated: the Side method
  count is 135.
- The test StubSide states the oracle's release, so the record-mode tests
  check record mode's logic on any Mac. on_release moves it.
- New test record_mode_refuses_a_host_that_is_not_the_oracle (macOS):
  - a stub on macOS 26.7.2 (25G332) is HostMoved, naming both hosts;
  - the oracle's release on another build is HostMoved too.

The rest of the macOS job after this step: only "Doc tests" (cargo test
--workspace --all-features --doc). Every later step is Linux-only. No
running doctest touches the host: the only doc code fence in macOS-gated
code is a text block in the conformance binary. Packaging and the
documentation steps run before this one, and passed in run 47018745061.

Verified: see the hand-over. The M3 runs no tests, so the macOS proof is
the next CI run.
2026-12-02 20:00:52 -08:00
Anees Iqbal 094405e9a9 Harness and player: video planes ask shader read and write with no read-alone fallback
Since c850655216, new_exported_surface answers a plane whose image in place lacks storage with
the copy form (SurfaceCopy::Usage) rather than Gap::SurfaceUsage. So the harness's churn probe
and the replay player's video surfaces can no longer reach their fallback to planes of shader
read alone, and this commit deletes it:
- churn.rs: the probe's retry and Video's usage field, replaced by one const usage;
- videos.rs: the retry, its read_only counter, and the report's "with planes of shader read
  alone" count;
- REPLAY-STREAM.md and videos.rs's module doc now say the copy form takes such a device.
A device that lacks storage now shows in the report's copy-form count under its reason.

Checked by the hand-over job: clippy of the harness and validation crates, and the validation
suite.
2026-12-02 19:29:39 -08:00
Anees Iqbal 6d9706769a rt: a surface plane whose image in place lacks a usage its texture asks takes the copy form
new_exported_surface refused a plane whose texture asks a usage that its image in place does
not hold or export, ShaderWrite's storage for one, with Gap::SurfaceUsage. As ruled for row 5,
that plane now takes the counted copy form with its own reason, SurfaceCopy::Usage { plane }.
The copy form's texture over the block's buffer is an optimal image of the usage the texture
asks. The submissions copy it into the image and back (Metrics::over_copies), so a kernel's
write through a view of the plane reaches the exported bytes by that copy before the host or
the other API reads them.

How:
- Query::plane answers usage_verdict's reason in place of the gap. With nothing else to fail,
  its return type drops the outer Result and the pixel_format it carried only for the gap.
- The feedback-loop retry skips Usage, as it skips Tiling and NoModifier, since dropping the
  loop does not change the usage asked.
- Gap::SurfaceUsage stays for the Direct3D 11 import, and its doc now says that alone.

Docs, in this commit: the runtime README (the guide's storage paragraph, the copy form's list
of reasons, and a fifth case in the known gaps), REFUSALS.md regenerated (SurfaceUsage's row
and its sites) and the api_surface table (the new variant).

Tests:
- Verdict unit test a_plane_whose_tiling_lacks_an_asked_usage_takes_the_copy_form, with
  synthetic features: a LINEAR tiling without STORAGE_IMAGE, where the optimal tiling has it,
  takes Usage for a plane that asks storage, and lies in place for one that does not.
- The device test every_device_writes_a_surface_plane_through_a_shader_write_uint_view no
  longer accepts Gap::SurfaceUsage at the make.
- The write-back through the copy form's own copy is the same copy_form path the device test
  already ran at f997a251fc: on the RTX 3090 (NVIDIA 620.70.06, m3-max-81338) the dma-buf row
  took Copy(Tiling) and the copy-form row Copy(Pitch); on the RX 7900 XTX (RADV, Mesa 26.2.6,
  m3-max-81352) and lavapipe (Mesa 26.2.4, m3-max-81341) the copy-form row took Copy(Pitch).
  Each had the kernel's 2,073,600 texels written through the ShaderWrite R8Uint view, read
  back exactly from the surface's buffer.
- No device queried takes Usage for an R8 plane (the row 5 queries m3-max-81308, 81309,
  81310, 81314, 81318, 81322 and 81353).
2026-12-02 19:29:39 -08:00