Commit Graph
2297 Commits
Author SHA1 Message Date
Anees Iqbal e1e6f52848 Conformance ledger: the shared-texture rows are not built yet, as a guest meets the call
The 31 rows of shared-creator-padded-format-storage, shared-creator-extended-range-samples,
texture-shared-handles and texture-view-descriptors that the rt side refuses with
Unavailable(shared_texture) gave "no stream uses it yet" (the 11-19 census) as their reason.
That is stale: on 12-02 a viewer's render process called newSharedTextureWithDescriptor:
about 2.5 s after its window opened, and its consumer answered nil. Their reason is now the
ledger's "refused: not built yet (fix-l155)", so every replay counts them as open work, and
the row says what is to be built: on rt's one device a shared texture is a Private texture
and the texture its handle opens a clone of the same Texture, the handle the consumer's.

Docs only: no row's case, venue, site or answer changes. CONFORMANCE-COVERAGE.md is
regenerated (coverage.py --check: as derived).
2026-12-02 18:34:56 -08:00
Anees Iqbal 6b939ef793 Replay player: copyFromTexture:...sliceCount:levelCount: as the runtime's region copies
Metal's copy of whole surfaces between textures has no runtime call of its
own; the player refused it as not played on a blit encoder, which ended a
viewer stream's play on the XTX in its first seconds (job m3-max-81089). It
now plays as the runtime's copy_from_texture, once for each slice and level
of the counts, each the source level's whole extent from the origin to the
origin, as a bind of a range plays as single-slot binds. The runtime's own
checks refuse a level or slice past either texture. REPLAY-STREAM.md says so.
2026-12-02 18:17:42 -08:00
Anees Iqbal 8ac91a9b33 Docs: REPLAY-STREAM.md's render encoder paragraph rewrapped at 100 columns
The patch draws' sentence left two lines past the paragraph's width.
2026-12-02 18:17:41 -08:00
Anees Iqbal b6c6997cfa Replay player: drawPrimitives and drawIndexedPrimitives from an indirect buffer
The player refused both of Metal's indirect draws of primitives as not
played on a render encoder, so a stream whose program draws from an indirect
buffer lost each such draw. Each now plays as the runtime's call
(draw_primitives_indirect, draw_indexed_primitives_indirect), its arguments
and index buffer at their offsets. The patch draws' buffer helper becomes
draw_buffers, which both arms share: a draw naming a skipped index or
indirect buffer is a skipped draw, and one skipped by its state or a bound
object is counted as before; patch_draw keeps the patch draws' count of
draws through a state whose record lacks tessellation. REPLAY-STREAM.md says
the draws play direct or from an indirect buffer.
2026-12-02 18:17:41 -08:00
Anees Iqbal 59326c8dff Translator: half computes in 16 bits where only 16-bit DenormPreserve is missing, noting half denormals
The planner's ruling (T3). On a device with shaderFloat16, 16-bit RoundingModeRTE and 16-bit
SignedZeroInfNanPreserve whose only missing 16-bit control is DenormPreserve, the half operations
narrow::half_controls gates take the 16-bit route: a half + - * / sqrt and fused multiply-add on
the device's 16-bit instructions, half values held at 16 bits, the controlled pair for a float
rounded to half, and a half widened from and narrowed to its bits by the device's conversion.
It is the 16-bit floats query's existing form, read from one more of its properties.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

SEMANTICS_VERSION 2323 -> 2324: a module that calls air.mad translated to
a refusal before and translates now. The authoring classification follows
on its own, since its key fingerprints the product's sources
(ANALYZER_ABI), so no census version needs a bump.
2026-12-02 17:49:11 -08:00
Anees Iqbal 0c12c606fa Translator: the address form's indexed patches name their cause
The last cause-less Feature::Tessellation refusal of the translator, the
address form's in pipeline/link/tessellation control_plan
("addressed && !fits"), now names TessellationCause::IndexedPatchFactors:
a control-point index type beside a per-instance factor step or a factor
scale where pointers are device addresses used directly, where the
control-point indices' address takes the control stage's push words that
hold the factors' instance stride and scale (control::address_fits).
Every Feature::Tessellation NotImplemented refusal now carries a cause:
the translator's through Unsupported::tessellation, the AIR front end's
through its conversion.

Tests: the link test of the commit before this one (each such pair on
every committed profile of the identity domains); the engine test of the
address form's stepped and scaled descriptors asserts the cause too.
api_signatures blessed (the variant), REFUSALS.md regenerated (the
control_plan site moves under error/mod.rs's Unsupported::tessellation).
runtime-sources.sha256 unchanged: neither file is a runtime input.
2026-12-02 17:39:09 -08:00
Anees Iqbal 530fb4ea4c Validation: the runtime route refuses no patch draw through index buffers, which no case makes
The engine candidate's runtime route required a patch draw to name no patch
or control-point index buffer, and refused one that did as
executor_not_implemented. No case reaches that refusal: the case mapping
(graphics::patch_draw) names neither buffer for every patch draw, the case
schema has no field for them, and the AIR states nothing about a draw's
index buffers. The conformance suite's tessellation-patch-indices case
compares drawIndexedPatches and patch index buffers against Metal.

The route now takes every patch draw, its refusal message and
VALIDATION.md's sentence drop the clause, and the routing test drops its
patch draw through a patch index buffer. The runtime platform's draw keeps
its own check of the translator's DrawCall fields, which fails a draw that
names an index buffer visibly.
2026-12-02 17:26:54 -08:00
Anees Iqbal 7dff42d6a5 command-replay: SIGTERM stops the play at its next frame end
A watchdog's SIGTERM killed a play inside a frame; on a 3090, plays killed mid-frame were
followed by a wedged card (11-23), which is why a play on an NVIDIA card ends at an
--until-frame. The player now takes a stop flag (Player::stopping_on): once it is set, the
play stops after the frame then playing ends, as at --until-frame, and command-replay tears
the device down as at any end. The SIGTERM handler writes its progress line and sets the
flag instead of re-raising; after the stop the play writes `progress stopped after SIGTERM:
frame N of M ended last at T s`, no judged metric, the report verdict `stopped SIGTERM after
frame N, short of its range` and exit status 1. A frame that never ends (a call that never
returns) is left to the caller's kill (timeout -k).

Not yet built: a lavapipe job plays one stream under a forced 150 s watchdog with the player
before this commit (red: killed inside a frame) and with it (green: ends at a frame).
2026-12-02 17:21:11 -08:00
Anees Iqbal ac99c98778 Replay player: drawPatches from an indirect buffer, and drawIndexedPatches direct and indirect
The player refused three of Metal's four patch draws as not played on a
render encoder, so a stream whose program draws patches through an indirect
buffer or a control-point index buffer lost those draws. Each now plays as
the runtime's call (draw_patches_indirect, draw_indexed_patches,
draw_indexed_patches_indirect), beside drawPatches, through one helper the
four share: a nil patch index buffer is none, a draw naming a skipped buffer
(patch index, control-point index or indirect) is a skipped draw, a draw
skipped by its state or a bound object is counted as before, and a draw
through a state whose record lacks the tessellation key is counted.
REPLAY-STREAM.md names the patch draws among what render encoders play.
2026-12-02 17:12:14 -08:00
Anees Iqbal ce337e89a7 Docs: the overlap refusal's basis cites the Mac readings; a DontCare store is a known gap
Refusal::BufferCopyOverlap's Basis line kept "ours" with no reading of
Metal behind it. It now cites the two: on an Apple M3 Max, macOS 27.0.1,
arm64 and x86_64 under Rosetta (job m3-max-80419), and on a Radeon Pro
5300M, macOS 26.7.1 (job m3-max-80501), every overlapping copy equals
memmove's, forward and backward, Shared and Private, 64 bytes to 16 MiB,
five runs each; on that Mac's UHD Graphics 630 a forward overlap of 64 KiB
and up differs from memmove's in each of five runs, at the same first byte
and the same count of bytes. Metal's validation layer was on in both and
stopped none. The kind stays "ours": the readings show plain Metal takes
the copy, which the refusal-surface script calls metal-takes, and the
runtime's RefusalBasis has no variant for it, so naming it is a public type
change, not this docs commit. REFUSALS.md regenerated.

The runtime README's render encoder gaps gain the DontCare store: it
stores, because Vulkan fixes a rendering's store operation as it begins
and a pass may become several renderings for commands met after it
begins, so a tile-based GPU writes back attachments Metal lets a program
discard; not measured on a tile-based phone GPU, no such device in the
lab. The counts are from the store census over two replay streams (jobs
m3-max-80663, m3-max-80681 and m3-max-80720, the last the one the README
quotes, after the census also followed descriptors made by
renderPassDescriptor): 6,401 of 80,906 passes over 1,115 frames (5.74 a
frame, 7.9%) and 4,886 of 73,212 over 1,036 frames (4.72 a frame, 6.7%),
each such pass storing one colour attachment and not caring about a second
or its stencil attachment.

Docs only: a doc comment, the generated REFUSALS.md and the README.
refusal_surface.py --check passes.
2026-12-02 16:52:24 -08:00
Anees Iqbal dec74d9cf7 Translator: a tessellation refusal names the structure it met
Feature::Tessellation with Needs::NotImplemented covered fourteen refusal
sites behind one name, so a walk's log line ("the translator refused the
feature Tessellation, needing NotImplemented", cause None) could not say
which without the AIR. A tessellation refusal now carries
Cause::Tessellation(TessellationCause), one variant per structure the
sites refuse, the way an access refusal names its AccessCause; sites that
refuse the same structure share a variant, none is named by a file, a line
or a string of its own:

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

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

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

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

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

Consumer uses (consumer-uses.sh, read-only, over the consumer's
development 33784022f1 and its lane tips of the last day):
Feature::Tessellation and TessellationCause, 0 hits.
2026-12-02 16:51:29 -08:00
Anees Iqbal c50fd04219 rt: drawIndexedPatches, and patch draws through a patch index buffer
The runtime refused a patch draw through a patch index buffer
(Gap::Draw of DrawKind::PatchIndexBuffer) and had no indexed patch draw.
The viewer draws every patch with drawIndexedPatches, indirectly, through
a nil patch index buffer and a UInt32 control-point index buffer (reims's
walk at development 8a2f155883, job m3-max-80637 on the XTX: 4202
draw_indexed_patches calls left unbuilt).

The encoder now:
- takes a patch index buffer in draw_patches and draw_patches_indirect;
- has draw_indexed_patches and draw_indexed_patches_indirect, whose two
  index buffers come as one PatchIndexBuffers (the patch index buffer or
  none, and the control-point index buffer, each with its offset), as the
  indexed primitive draws take an IndexBuffer;
- pushes each index buffer's address plus its offset beside the factors'
  (FieldValue::PatchIndices, FieldValue::ControlPointIndices, 0 for none),
  and fills the push bytes again when they change. The control stage reads
  the indices through those addresses, unchecked, as it reads the factors;
- counts each index buffer among the draw's reads, as an index buffer
  (a Managed one's device copy brought up to date first), and keeps it until
  the command buffer retires.
Metal's validation refuses four things (an Apple M3 Max, job
m3-max-80366), and the runtime refuses them typed, direct and indirect:
- drawIndexedPatches through a state of index type None,
  Refusal::IndexedPatchDrawWithoutIndexType;
- drawPatches through a state with an index type,
  Refusal::PatchDrawWithIndexType;
- a patch index buffer offset that is not a multiple of 4,
  Refusal::PatchIndexBufferOffset;
- a control-point index buffer offset that is not a multiple of the index
  size, Refusal::ControlPointIndexBufferOffset.
Indices at a byte of the buffer's allocation off that multiple (a no-copy
buffer over such a pointer) are Refusal::ArgumentPlace, as an indexed
draw's are.

DrawKind::PatchIndexBuffer is deleted: nothing returns it. consumer-uses
at the consumer's development db87b77b07 (104 refs) finds PatchIndexBuffer
at 0 code hits; the consumer's DrawKind uses construct AttachmentRead and
LineWidth, and its one match on DrawKind has a wildcard arm
(render.rs:283-287), so the deletion breaks nothing there.

The conformance suite's runtime side draws RenderStep::DrawIndexedPatches.
Its tessellation-patch-indices case now compares on lavapipe (announced:
only the declared winding notice), so its four refused rows leave
known-gaps-rt.tsv; indirect-render-commands-patch-draws now makes its
indexed patch pipeline and reaches its command buffer, whose
indirect_command_buffer call the side answers Unavailable as the case's
siblings do, so its row moves there. docs/CONFORMANCE-COVERAGE.md is
regenerated. The runtime README, docs/REFUSALS.md, the refusal bases, the
API signature table and the Metal coverage map say the same.
2026-12-02 16:25:48 -08:00
Anees Iqbal 082248f947 Translator: the address form reads patch and control-point indices through their pushed addresses; a fragment's primitive id is the patch's position
Under the identity domains (the runtime's), a post-tessellation function's
control stage reads its factors through their pushed address and binds no
buffer. It had no way to read a patch index buffer or a control-point
index buffer, so it took each patch's index from its position and refused
a control-point index type (NotImplemented(Tessellation)). The viewer's
two pipelines are UInt32 control-point indices drawn by
drawIndexedPatches, and both were refused.

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

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

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

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

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

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

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

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

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

Verified (the change at 6d5f748347 on 787fbbb061, then this commit rebased onto development
8a2f155883, the same change):
- red: the test fails at heap_texture_size_and_align on llvmpipe (job m3-max-80460) and on the
  RX 7900 XTX and the 780M (m3-max-80461);
- green: it passes on llvmpipe, whose 6 dispatches reach the buffers at their addresses
  (m3-max-80460), and on the RX 7900 XTX and the 780M, bound (m3-max-80461). Each device's
  texel-buffer alignment for R32Uint is 4, so all three answer 16 at 16;
- the conformance replay matches known-gaps-rt.tsv: llvmpipe, every case (m3-max-80487, and on
  this tree m3-max-80503); the RX 7900 XTX, the 8 cases the ledger edit touches (m3-max-80488);
  the conformance suite, 1047 passed (m3-max-80493);
- on this tree (m3-max-80502): signatures, refusals, both coverage checks, fmt, clippy plain,
  --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc and private rustdoc, all 0; the runtime suite on
  llvmpipe 942 passed, 1 failed, 4 skipped. The failure,
  private_sinks::every_device_keeps_a_store_past_a_private_array_off_its_words, fails the same
  at development 8a2f155883 without this change (m3-max-80535) and passed at 787fbbb061 with it
  (m3-max-80462, 940 passed).
2026-12-02 16:25:21 -08:00
Anees Iqbal 2e5503c0f7 Translator: a store moves into the ways of a branch only under a key that orders nothing
The sink (lower::access::quad::sink) ran on the specialized entry, before lockstep's order, on
every profile. Lockstep pairs only accesses that reach each other on one path, so a store moved
into each way of a branch whose lanes diverge lost its pairs with the other way's accesses:
under a key that orders lanes (the resident-table domains), a pair the program has, which
lockstep would have ordered, went unordered. The sink now runs on the ordered entry, and only
under a key that orders nothing (OrderKey::orders_nothing, the identity domains, which order no
pair and so lose none); under a key that orders, the store stays in its block. Under the
identity domains the same stores move; the order, which inserts nothing there, now finds the
pairs behind its SimdgroupAccessOrder note in the program as written.

engine_store_quad's descriptor-profile test now asks for sst_split's seven word stores there.

Verified: the test fails before this change, on moltenvk-m3 with seven stores where six are
expected (filtered, 3 tests), and passes after (filtered, 47 tests), with clippy clean
(m3-max-80575). Under the identity domains the change moves the same stores: the row_tail module
is byte-identical before and after it on the committed rtx50, lavapipe, 780M and Iris Xe profiles
(m3-max-80635). At the branch's last commit: clippy in all three configurations, rustdoc, the
runtime's suite on lavapipe (942 passed, 4 skipped), the translator's (3412 passed, 37 skipped,
the tables a bless is due for left out), validation's (1319 passed, 3 skipped) and
conformance's (1047 passed) (m3-max-80665).
2026-12-02 16:24:50 -08:00
Anees Iqbal 8e2fc13cfe Translator: four word stores of one block at consecutive words are one 16-byte store where aligned
A row of floats written four at a time from a float4, with its tail guarded, stores the first
float in one block and the other three in the block its branch takes when the row holds them.
Each store was its own word store. Now the specialized entry moves such a block's last store
into both successors of its branch, where one of them opens with the three stores after it
(`lower::access::quad::sink`). Selection then finds, in one block, four plain word stores at
byte offsets k, k+4, k+8 and k+12 from one base with nothing between them that touches memory,
all reaching one slot (`quad::plan`). The last of them emits the four; the others emit nothing.

At emit each invocation tests the first word's offset: where it is a multiple of 16 and the 16
bytes pass the slot's containment check, the four words are one uvec4 store (through the slot's
uvec4 view where the kernel binds its buffers, at the device address with Aligned 16
elsewhere); otherwise the four word stores run as selected, each checked by itself. At a device
address the 16 bytes are checked in the shader, so a store that straddles the buffer's end keeps
every in-range byte. One form on every device: the memory decides only where the store goes, as
for every other access. Under the descriptor profiles, where lockstep orders lanes, a barrier it
puts between the stores keeps them words.

engine_word_phases's alignment test now allows the two tested 16-byte stores of vwp_words's
two runs of four word stores. SEMANTICS_VERSION 2322 (development holds 2321): the SPIR-V of
such kernels changed.

Verified: engine_store_quad, engine_word_phases and the access tests pass on the interpreter
in both forms at bind offsets 0, 4, 8 and 12 (m3-max-80331, m3-max-80352); clippy in all three
configurations, rustdoc, the runtime's suite on lavapipe (937 passed, 3 skipped) and the
translator's (3404 passed, 37 skipped, the tables a bless is due for left out) at the change
(m3-max-80386).

Timed with the harness's row_tail workloads, the harness commit against this change, the arms
alternated in one job per card; GPU time, the median of the rounds' medians:
- NVIDIA GeForce RTX 3090 (m3-max-80449, 4 rounds): the Shared rows fell from 46.3 to 2.12 ms
  (224 floats a row), from 52.4 to 3.29 ms (49) and from 24.8 to 19.4 ms (27,730, bimodal in
  both arms); the Private rows took 0.2 to 0.4% longer.
- AMD Radeon RX 7900 XTX (m3-max-80450, 4 rounds): every row within 1.1% of the base.
- AMD Radeon 780M (m3-max-80482, 8 rounds): the times fall in two clock states, the change's
  runs in the slower one in 5 of 8 rounds and the base's in 2 to 4; within a state the change
  takes 0.973 to 1.014 of the base's time.
Not run on an Intel card. Those jobs ran an earlier build of this change on an older
development; its row_tail module equals the one at this branch's last commit byte for byte on
the committed rtx50, lavapipe, 780M and Iris Xe profiles (m3-max-80707, m3-max-80705).
2026-12-02 16:24:50 -08:00
Anees Iqbal f1689ad668 conformance: a ledger row lists each answer its venue's hosts give, where they part by what the venue does not state
The CI's ubuntu leg at da37e9e5df (run 46984549568) failed its conformance replay: on an x86-64
AVX-512 runner, llvmpipe of Mesa 26.2.4 and LLVM 23.1.1 gave five sites the counts the ledger keyed
to AVX2 hosts, where the AVX-512 runners of runs 46969176610 and 46974578786, in the same image,
gave the AVX-512 rows' counts. The count follows a property of the host finer than its widest
vector set, which the venue does not state, so no venue key separates the two.

Ruled by the planner: for those five sites only, the llvmpipe row accepts the set of counts
recorded there, each named with the run it came from; any other count on those sites, and any
difference on any other site, still fails. The venue string carries no new property.

Now:
- known_gaps: a row's answer field may list more than one answer, with ` | ` between them
  (ANSWER_SEPARATOR). KnownGap::answers lists them; the row covers each and no other, in both
  directions: a run holding any of them holds the row, a third answer is a new gap and reads the
  row as no longer held, and a site that no longer diverges reads it as fixed. A row of one answer
  is compared as before.
- known-gaps-rt.tsv: the AVX2 and AVX-512 rows of each site become one llvmpipe row:
  - fetch-ordered-bgra8unorm-srgb and fetch-ordered-rgba8unorm-srgb at case/x3 and case/x3-depth:
    6304 or 6496 elements (U8), the largest difference 2;
  - blend-interaction-format-srgb8 at case/blended/one-one-subtract: 81 or 78 elements (U8), the
    largest difference 3.
  Each row's gap names the runs of each count, from the commits that wrote the rows and CI's runs:
  6304 by the lavapipe legs of m3-max-55331 to 55337 (x3) and m3-max-55569 to 55574 (x3-depth),
  m3-max-56427 (LLVM 23.1.1) and CI run 46984549568; 6496 by m3-max-56238 and m3-max-56342
  (LLVM 23.1.4) and CI runs 46969176610 and 46974578786 (LLVM 23.1.1); 81 by m3-max-50686 and
  m3-max-56427 (LLVM 23.1.1), m3-max-63645 (LLVM 23.1.4) and CI run 46984549568; 78 by
  m3-max-56238 and m3-max-56342 (LLVM 23.1.4) and CI runs 46969176610 and 46974578786. The venue
  is llvmpipe, as the same cases' x1 and x2 rows are, so the lab's LLVM 23.1.4 hosts, which gave
  the same counts, stay covered.
- Docs: the ledger's header, the conformance README and known_gaps's module doc describe the form;
  Venue::host's doc and the README no longer say a CPU venue's answers follow its vector set.
  CONFORMANCE-COVERAGE.md regenerated (5 ledger rows fewer).

Verified: coverage.py --check, refusal_surface.py --check and metal-coverage --check pass here;
the red test, the CI replica and the lint are in the jobs named on the ready line.
2026-12-02 16:24:22 -08:00
Anees Iqbal 511f31b0ba Translator: an index past an array field's array sends its private-arena access to the sink, not onto the last element
a992aa6929 bounded a GEP into an array field of a thread variable to its
array, so a struct holding handles beside a run-time-indexed array closes
as a forwarding cell. In the private arena it held every run to that bound
by clamping each run-time index to the array's last element. A store past
the array then landed on the array's own last word. The runtime's
private_sinks contract wants such a store kept off every word a thread
reads, as a store past a private array is. On lavapipe at development
8a2f155883 (job m3-max-80535),
every_device_keeps_a_store_past_a_private_array_off_its_words failed: the
fold over the arrays moved by about 193,700, which is b[k]'s store of
t + 200000 over b[N - 1]. The same test at 8a2f155883 with a992aa6929
reverted (scratch tree, job m3-max-80554) is the cause check.

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

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

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

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

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

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

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

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

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

Cost: one UMin per run-time index into a private-arena array, the bound
itself. The device-arena budget test's word bounds move by one each (13
for a word load, 12 for a word store, 24 for a float4 load).
SEMANTICS_VERSION 2320 (development holds 2319).
2026-12-02 14:41:34 -08:00
Anees Iqbal 4fe41c795d rt: a blit copy with a texture buffer on either side copies its buffer's bytes
Metal makes copyFromTexture:...toTexture: with a texture buffer as the source or the destination.
copy_from_texture refused it as Gap::TextureCopy ("A texture buffer's texels are its buffer's
bytes, which no image copy reaches"). Under the rule that a refusal of what Metal makes is built,
it now copies a texture buffer's texels as the bytes of its buffer (texel_texture_copy):

- Checked as Metal checks any copy: one pixel format and one sample count
  (Refusal::TextureCopyMismatch), and each region inside its texture's level and slice (`place`,
  Refusal::TextureRegion), sizes of 0 taken as copy_from_texture takes them.
- Between two texture buffers: the region's bytes copied between their buffers by
  copy_from_buffer_to_buffer, from each one's offset plus origin.x texels. The same bytes copy
  nothing, as the same region of one image does, and bytes that meet are
  Refusal::BufferCopyOverlap, as that call refuses them.
- Between a texture buffer and another texture: copy_from_buffer into the texture from the texture
  buffer's row in its buffer, or copy_from_texture_to_buffer out of it into that row. That is one
  vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region, checked and ordered as those calls are.

The command buffer keeps both textures. Gap::TextureCopy's doc drops the texture buffer case, and
docs/REFUSALS.md is regenerated. Buffer::new_texture's doc, copy_from_texture's doc and the runtime
README's texture buffer contract say what such a copy does. The texture buffer refusal test no
longer expects the gap from a copy of one into itself; that copy of the same bytes now copies
nothing.
2026-12-02 14:24:14 -08:00
Anees Iqbal c55fd4603c Validation: a video picture landed is the surface's mark of the other API's writes, not an acquire
The play calls Surface::external_writes_done once a picture lands on a video surface's pages. That
call records no acquire: each submission part that uses the planes acquires and releases them
itself, and the call marks the other API's writes on the host side. videos.rs' module doc already
said so, but its counter and report line still named the call an acquire, as did
docs/REPLAY-STREAM.md (the `m2v.externalWriteDone` row in section 4, and the video surface
paragraph and its counters in section 10) and the replay test's doc.

The executed counter video_surface_acquires is now video_surface_writes_done, and the report's
`video surfaces` line says "N writes marked done" for "N acquires". Its one reader in the tree is
rt_replay.rs' a_video_surface_is_waited_for_at_its_ready_point_once, updated; no script in the
tree names it (grep for surface_acquires over *.rs, *.md, *.py and *.sh). The count is unchanged:
one a picture landed in a surface.

Wording and naming only; no behaviour changes.
2026-12-02 14:24:13 -08:00
Anees Iqbal 772441372c rt: a blit between a buffer and a texture buffer copies the region's bytes between the two buffers
A guest's 3D model window stayed blank: it fills an RGBA8Unorm texture buffer placed in a heap by
copyFromBuffer:...toTexture:, which BlitCommandEncoder::buffer_copy refused as Gap::TextureBytes
("A texture buffer's texels are its buffer's bytes, which no image copy reaches"). A texture
buffer has no image: its texels are its buffer's bytes from its offset. So a copy between it and a
buffer, in either direction (copy_from_buffer into it, copy_from_texture_to_buffer out of it), is
now checked as any texture's copy is, by the same checker (`buffer_copy`: the region inside its one
row, level 0 and slice 0, Refusal::TextureRegion past it; Metal's measured layout rules,
Refusal::BufferCopyLayout), and then the region's bytes (origin.x and width in texels times the
texel's bytes, at the texture buffer's offset) are copied between the two buffers by
copy_from_buffer_to_buffer. That path keeps both buffers, takes the Managed copies and the heap
places, and orders the copy as any copy between buffers. A texture buffer's uses take its buffer's
id in the hazard sets, so a later kernel's read is ordered after it. The command buffer also keeps
the texture. Two parts of the generic check don't apply: an image's rows or memory meeting the
region (it has none), and a copy command's offset alignment (vkCmdCopyBuffer takes any). The check
runs without them. Bytes of the texture buffer that meet the other buffer's region are
Refusal::BufferCopyOverlap, as copy_from_buffer_to_buffer refuses them.

Gap::TextureBytes's doc drops the texture buffer case and its basis line ("nor a texture buffer's
copy as a buffer copy; no recorded stream copies a texture buffer"), and docs/REFUSALS.md is
regenerated. Buffer::new_texture's doc, copy_from_buffer's and copy_from_texture_to_buffer's docs
and the runtime README's texture buffer contract now say what a blit with a buffer does. The
texture buffer refusal test no longer expects the gap from copy_from_buffer_with_options. A copy
between a texture buffer and a texture (Gap::TextureCopy) is left as it is.
2026-12-02 14:24:13 -08:00
Anees Iqbal f4f5cc33da rt docs: Metal's validation asks ShaderRead and ShaderWrite at every read_write slot; the runtime asks less where the function only writes
The runtime README's rule (Textures: Texture slots and usage), pipeline::slot_usage's doc and
RESOURCE-ID.md's sentence on slot usage said the runtime asks a texture's usage at a slot as
Metal's validation asks it, ShaderWrite alone at a read_write slot the function does not read.
Metal's validation asks both at every read_write slot, by the declared access, whatever the
function does there. Measured on an Apple M3 Max, macOS 27.0.1 (job m3-max-80068, a scratch
probe of runtime-compiled MSL, R32Float 4x4):
- a read_write slot the function only writes, of a ShaderWrite-alone texture, asserts "Compute
  Function(k_rw_write): reads texture (t[0]) whose usage (0x02) doesn't specify
  MTLTextureUsageShaderRead (0x01)";
- one the function only asks the width of asserts the same of 0x02 and the write of 0x01;
- one it only reads asserts the write of 0x01 and the read of 0x02;
- both usages run.
Plain Metal runs every case, and the written one writes its texels.

The runtime keeps its rule: such a slot asks ShaderWrite alone, as its write reaches the texture
through its storage element alone, so a ShaderWrite-alone texture runs there as plain Metal runs
it. The three texts now say what Metal's validation asks and what the runtime asks. They also
name a texture atomic's slot as one that reads. Metal's validation asks both there: a 0x21
texture asserts the write and a 0x22 one the read; 0x03 runs without ShaderAtomic.

Docs only; no behaviour changes. Verified: cargo fmt. Rustdoc runs as a job.
2026-12-02 14:24:12 -08:00
Anees Iqbal 59d00cd865 Validation: the play's own buffers take each copy-form surface's buffer over its exported block
A surface in the copy form holds a buffer of the runtime's over its exported block
(`Device::copy_form`), which its planes, textures over it, hold too. The play's count of its own
buffers (`NewRuntime::play_holds`) took none of them, so each copy-form surface the program made
between frames 100 and 200 moved `buffers_excess`. The copy-form merge leg's RX 550 (m3-max-79613)
and a rerun on the RTX 5080 Laptop GPU (m3-max-79696, at 2361470bff) failed
the_play_s_own_textures_take_its_video_and_exported_surface_planes on `buffers`: excess 1 at frame
100 and 2 at 200, with both video surfaces copied (Tiling) and both exported surfaces in place.
No leak: the growth is the second video surface's buffer, freed with the surface.

The play now holds one buffer for each video surface in the copy form while the player keeps it
(`Videos::held_buffers`), and one for each exported surface in the copy form while it or a plane
of it the stream holds lives (`Exported::held_buffers`), as the textures term counts their planes.
The test's first exported surface is a dma-buf's, which NVIDIA's dma-buf takes in the copy form,
so the exported term with a plane outliving its surface runs there too.
2026-12-02 14:24:12 -08:00
Anees Iqbal f124b1489f Translator: an access refusal names the structure it met
Feature::Lowering(LowerFamily::Access) with Needs::NotImplemented covered
about 235 refusal sites behind one name, so a walk's log line could not say
which without the AIR. Unsupported gains `cause: Option<Cause>`; an access
refusal carries Cause::Access(AccessCause), one variant per structure the
sites refuse: the access's shape, the type it moves or the memory it
reaches. Sites that refuse the same structure share a variant, wherever
they are; none is named by a file, a line or a string of its own.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The test is the parent commit's. Verification is to follow in the handover: lavapipe red then
green, one card per vendor, the gate, and the conformance replay.
2026-12-02 14:24:09 -08:00
Anees Iqbal 86386c4873 Refusal surface: --check compares the totals, and REFUSALS.md counts Refusal::TextureUsageAtSlot
docs/REFUSALS.md listed 89 runtime Refusal variants but its two totals tables still counted 88
(and 24 metal-measured where there are 25). A union of two branches' rows keeps every variant row
and one side's totals, and --check compared only the variant rows, so it passed. The totals count
variants alone (no sites, no line numbers), so they are structural: --check now compares them too.

Verified locally (plain script, no build): with the old REFUSALS.md, --check exits 1 naming the
two stale Refusal totals rows; after regeneration it exits 0. The regeneration changes only those
two rows; basis.rs is unchanged.
2026-12-02 14:24:08 -08:00
Anees Iqbal b723c90272 rt: Device::default_sample_positions answers getDefaultSamplePositions:count:
The runtime answered no default positions (its README's known gap). Device::default_sample_positions
answers a count with the positions a pass of that many samples that sets none rasterizes at:
Vulkan's standard sample locations, which the floor's standardSampleLocations makes every such pass
take, and which are plain Metal's answers at 1, 2 and 4 samples on an Apple M3 Max, macOS 27.0.1
(probes/default_sample_positions.m, m3-max-78953). supports_texture_sample_count answers at most
1, 2 and 4, so no other count is answered. A count it does not answer is
Refusal::DefaultSamplePositions (basis metal-measured: plain Metal asserts "count (n) is not
supported on this device." and ends the process, at 0, 3, 5, 6, 8, 16, 17, 32 and 33 on the M3).

README (the device's answers; the sample-positions gap sentence), coverage.tsv (I), and the
generated REFUSALS.md, basis.rs, api_signatures.tsv, METAL-COVERAGE.md and CONFORMANCE-COVERAGE.md.

Verified on lavapipe, job m3-max-79650: clippy, doc and private doc EXIT=0; the runtime suite 923
passed, 3 skipped. Metal's answers: m3-max-78953 (Apple M3 Max).
2026-12-02 14:24:08 -08:00
Anees Iqbal a3a91a10f2 Conformance ledger: the Accumulate cases' rows as the replay of the Reset answer gives them
The rows of visibility-boolean-accumulate, visibility-counting-accumulate (both),
visibility-counting-accumulate-one-command-buffer and visibility-counting-accumulate-revisit
named the Gap::Draw{AccumulatedVisibilityResults} refusal, which is gone. The conformance
replay on lavapipe at efa04c576a (job m3-max-79548) read those five rows as fixed and gave
six in their place, pasted as it printed them with the venue widened to every venue, as the
rows they replace were:
- divergent at case/pass-0/words and case/pass-1/words of the Boolean and the Counting
  shapes, and at case/pass-1/words of the one-command-buffer shape: Metal on the M3 Max adds
  into the words, the runtime writes each result in place of its word;
- refused at case/pass-0/calls/0-render of the revisit shape: its first mode is now taken,
  so the second mode at the same offset meets Refusal::VisibilityResultOffsetTaken, the
  refusal of visibility-counting-revisit's row, whose text it takes.
No other row moved in that run. docs/CONFORMANCE-COVERAGE.md regenerated.
2026-12-02 14:24:08 -08:00
Anees Iqbal ce471296d5 rt: an Accumulate pass writes its visibility results as a Reset pass does, on every device
set_visibility_result_mode refused Boolean and Counting in a pass whose
visibilityResultType is Accumulate (Gap::Draw{AccumulatedVisibilityResults}, counted in
Metrics::accumulated_visibility_refused). MTLRenderPass.h documents Accumulate in one
sentence, "Accumulate visibility results data across multiple render passes." Measured
(the conformance recordings, values.rs VisibilityResultType): Metal on an Apple M3 Max
(macOS 27.0.1) adds a Counting result into the word's low 32 bits and ORs a Boolean one,
while Metal on a Radeon Pro 5300M and a UHD Graphics 630 (macOS 26.7.1) writes it in
place of the word, as Reset does. The documented sum needs an add of a query's count into
a buffer word: a scratch copy of the query results and a kernel of the runtime's own after
the rendering, which is not built. The planner ruled that the runtime answers Accumulate
as Reset on every device until that sum is built, which then replaces it everywhere.

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

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

Verified: tests::raster::on_device::every_device_draws_the_fill_mode_of_raw_value_2_as_fill
on lavapipe, red at the test's commit (the setter refused), green here.
2026-12-02 14:24:07 -08:00
Anees Iqbal 8209b0d83b Harness: two churn rows make and release every kind of their group in each of 200 iterations, their gauges read at 100, 200 and the drop
The thirteen gauge kinds no replay judges and no harness workload recorded now each have a loop,
grouped as the planner ranked them. `churn_all_day` (OwnRow::ChurnAllDay) makes, uses and releases
in each iteration: a host memory import with a buffer over it; an exported block with a buffer
over it; a video surface of each decoder route the device exports (a dma-buf at the VA-API
layout, the host's opaque handle at NVIDIA's), as the replay player makes them, with a view of
each plane at an index, its buffer in place, and plane 0 kept past the surface's release; the
runtime device tests' plane stand-in surface (two RGBA8Unorm planes of the opaque handle) whose
plane 0 a pass renders beside another colour attachment; two render pipeline states; and a
Private target and a target over a Shared buffer, each drawn into, then read through a texture
after a memory barrier. `churn_rest` (OwnRow::ChurnRest) makes a compute state of one of 40
contents in turn (past the 32 stage entries kept), a draw under a Counting visibility mode into 4
samples resolved into a texture over a Shared buffer, a texture over an exported block read by a
blit, and an indirect command buffer.

Each row reads the device's gauges once it settles (no release waiting, no command buffer
unretired, two reads 20 ms apart equal) after the 100th and the 200th iterations, and once more
after its device dropped (own::run, through the counters that outlive it), and the command prints
them as `M2V-MATRIX gauge harness-<runtime>/<row>/<gauge>@100|@200|@drop`: the harness's gauges
and the eleven kinds they left out (imports, exports, surface imports and buffers, plane
stand-ins, shadows, stage entries, resolve images, textures copied over, occlusion pools,
indirect command buffers). The matrix judges them as every gauge. A kind the device does not
make is left out with its reason on the row's lines; the first line gives each of the group's
kinds live in the first iteration before its release. No kind needed a consumer-side object: the
host import's memory is the row's own, as in the runtime's import tests.

The device tests churn_all_day_holds_every_gauge_still_and_frees_all_at_the_drop and
churn_rest_holds_every_gauge_still_and_frees_all_at_the_drop hold the matrix's rule on the
report.
2026-12-02 14:24:07 -08:00
Anees Iqbal d9054b5164 Validation: a play's gauge records are the runtime's objects past the play's own, of each kind the program makes one at a time
A play's frames 100 and 200 are not one loop's iterations: the program makes and releases
objects between them (glbench-3090-r4 holds 62 textures at frame 100 and 690 at 200), so a
runtime gauge held flat there judged the program. The matrix's records of a play are now,
for buffers, textures, samplers and events, the runtime's live objects of the kind less the
play's own (`KIND_excess`): the stream's live objects the backend made, and the backend's own
that stand for them (two-copy Managed buffers' CPU copies and the released ones a commit still
copies, the asides, the guest RAM scratches; the planes' shapes, one texture a plane and shape
that the plane's surface textures and views are views of; the video and exported surfaces'
planes). The settled end lines at frames 100 and 200 carry the play's count of each kind as
KIND_held. An excess below zero is written as it is, which results.py takes for no count.
The runtime's other kinds follow the program's objects and work, not one object each: they are
not replay records (the harness's loops hold those its workloads reach), and every kind stays
held at zero at the device's drop.

Verified: in the hand-over.
2026-12-02 14:24:06 -08:00
Anees Iqbal f4eb47d792 Validation: a play's gauges at frames 100 and 200 go out as the matrix's records, every kind on its end lines
What:
- The runtime backend's end lines (`Backend::live`) carry every count of an object kind the
  runtime keeps live: samplers, LOD clamp variants, level elements, kernel variants and entries,
  render contents, attachment views, descriptor slots, device samplers, shadows, resolve images,
  plane stand-ins, buffer set pools, surface buffers, indirect command buffers, releases waiting
  and handles out join them, and the pipeline cache's bytes.
- At the ends of frames 100 and 200 (GAUGE_FRAMES) the player reads them once they hold still
  (Backend::settled_live): the runtime backend reads them every 10 ms until no release waits and
  two reads in a row agree on every recorded kind, for at most 2 s, a wait no frame's time holds.
  What the program released goes on the runtime's block-maker and reaper threads after the work
  before it retired, so a read straight after the frame's waits could differ between two plays.
- command-replay prints, where the play ended frame 200 and skipped nothing by then,
  `M2V-MATRIX gauge replay-rt/STEM/GAUGE@100` and `@200` for each kind of GAUGED (gauge_records).
  scripts/matrix/results.py judges them as it judges the harness's: equal at 100 and 200, blocks
  no higher at 200.
- Left out, and why: handles_out (1 while the play holds the device), releases_waiting (lowered by
  the block-maker thread whenever it runs), private_units (a layout of memory that follows the
  bytes the program holds), and every byte and age gauge, which follows the program's content and
  the pool's idle clock: the pipeline cache's data (bound 128 MiB), the translator's entries'
  bytes (bound 64 MiB), the staging bytes, the pool's allocated, idle, reserved, reused, taken and
  block bytes, and the shadows', resolve images' and stand-ins' bytes, whose counts are recorded.

Why: the matrix's leak rule (live gauges per resource kind flat between iterations 100 and 200)
reached only the harness's compute workloads. The kinds only draws and passes make (render
contents, attachment views, shadows, resolve images, stand-ins, the samplers draws reach) had no
such check, and a play's end lines lacked 17 of the kinds.

Docs: REPLAY-STREAM.md section 10 (the end line's gauges, the settled read, the records),
VALIDATION.md's gauge row, command-replay's module doc.

Tests: replay::tests the_player_settles_the_gauges_at_frames_100_and_200_alone and
the_gauge_records_are_the_counted_kinds_at_frames_100_and_200; replay::rt_replay
the_end_lines_carry_every_gauge_the_gauge_records_carry (device); test_results.py
test_a_plays_gauges_at_frames_100_and_200_are_held_flat_as_the_harness_s.

Verified: in the hand-over.
2026-12-02 14:24:06 -08:00
Anees Iqbal fcdcffea07 Docs: REFUSALS.md regenerated after the slot-usage refusal met the word-bound draw
The draw now refuses a missing pipeline state at two sites, one from the word-bound content's
path (7a1da6cb22) and one from the slot-usage check (73bb5eb204); each branch regenerated the
table on its own base, so the landed tree counted one. Regenerated with
scripts/refusal-surface/refusal_surface.py; no code change.
2026-12-02 10:12:50 -08:00
Anees Iqbal c25a5b238a rt: a view made with a swizzle keeps its texture's usage at a slot, as its known gap rules
8811dd6790 checked a texture slot against the usage Metal answers, and answered a view made with a
swizzle as ShaderRead and PixelFormatView alone, so a kernel's write through such a view became
Refusal::TextureUsageAtSlot. That reversed the runtime's recorded known gap of swizzles (README,
Known gaps of textures: a view's descriptor reports its base texture's usage, so a draw into such
a view and a kernel's write through it run, the write stored unswizzled; docs/API.md's accepted
differences), on which OpenCL mode stands: Apple's OpenCL binds an image of most channel orders
as a swizzled view and writes it (tests/opencl_swizzles.rs, job m3-max-16336). The runtime suite
on lavapipe at b28f70e076 (job m3-max-78531) failed three tests on it:
opencl_mode_queries_of_a_swizzled_write_only_image_answer_the_view,
opencl_mode_writes_through_a_swizzled_image_store_the_value_as_written and
every_device_reads_through_a_view_s_swizzle_and_writes_past_it, each "the Kernel function uses
texture slot 0, whose texture's usage MTLTextureUsageShaderRead |
MTLTextureUsagePixelFormatView lacks what its access there asks".

The slot check now takes the texture's descriptor usage (TextureObject::metal_usage: Metal's
unknown usage as 0x17, a view's its texture's, a swizzled view's included). The known-gap text
and new_texture_view_with_swizzle's doc are as before 8811dd6790; the refusal's doc, the README's
Texture slots and usage and RESOURCE-ID.md say a view's usage is its texture's, a swizzled one
included. The slot_usage test's swizzled destination is now a case that runs and stores the
texel as written.

The same run failed every_device_gives_an_index_to_the_texture_placed_there_last, whose dispatch
wrote through A, a texture of ShaderRead usage alone, at sample_down's written slot: that is the
refusal Metal's validation gives, and the test's point is that A's placement empties D's storage
element. It now writes through D's ID, the same index, which D's ShaderWrite usage lets the slot
check pass, and D still keeps its texels.

Verified: cargo fmt; refusal_surface.py --check (REFUSALS.md unchanged). The suite run of this
commit follows as a job. The other 865 tests of job m3-max-78531 passed (3 skipped).
2026-12-02 10:12:04 -08:00
Anees Iqbal da03093c0c rt: TextureUsageAtSlot's basis quotes Metal's (t[0]) as code, which rustdoc read as a link
Rustdoc with -D warnings refused the basis line of Refusal::TextureUsageAtSlot: the quoted Metal
validation text "reads texture (t[0]) whose usage ..." holds t[0], which rustdoc reads as an
intra-doc link to an item named 0 ("unresolved link to `0`", error.rs, three times, in both the
public and the private-items build). The three t[0] are now code spans and the lines reflowed
under 100 columns; REFUSALS.md regenerated (the row's text; basis.rs is unchanged).

Verified: the failure is job m3-max-78486's rustdoc steps (doc and privdoc EXIT=101; fmt, clippy
over the workspace and under --cfg m2v_cpu_icd and --cfg m2v_gpu, refusal_surface --check and
the signatures check passed there). Here: cargo fmt and refusal_surface.py --check; the rustdoc
run of this commit follows as a job.
2026-12-02 10:12:04 -08:00
Anees Iqbal 73bb5eb204 rt: a dispatch or draw whose texture lacks the usage its slot's access asks is TextureUsageAtSlot
A function's texture slot bound to a texture whose usage lacks what the function's access there
asks reached no element of the texture's and ran: it read element 0 of set 1 (nil's null
descriptor) or a null element as zeros and dropped its writes, with no refusal and no count. The
textures: one no shader reaches (no index: a Depth32Float target of RenderTarget usage alone, a
texture of PixelFormatView usage alone), a colour target of RenderTarget usage alone (null
elements), a texture not made for shader writes at a written slot (no storage element), and a
view made with a swizzle at a written slot (written unswizzled, where plain Metal writes through
the swizzle).

Each dispatch and draw now checks, once after the pipeline state or a binding changes and before
it records anything, each texture its functions' slots reach against the usage Metal's validation
asks by the access the function declares there (pipeline::slot_usage): ShaderRead for a sample or
read slot, a size query alone included; ShaderWrite for a write or read_write slot; both for a
read_write slot it reads. The texture's usage is Metal's answer (TextureObject::metal_usage):
the descriptor's, Metal's unknown usage as 0x17, and a texture reading through a swizzle other
than the identity ShaderRead and PixelFormatView alone. A texture short of it refuses the command,
Refusal::TextureUsageAtSlot { stage, index, usage }, binding and recording nothing. The binds take
every texture, as Metal's do. Gap::SwizzledReadWrite stays checked first for a read_write slot it
reads. The check reads facts the interface and the texture already hold; nothing runs per draw.

Basis (the previous commit's measurement, an Apple M3 Max, macOS 27.0.1, jobs m3-max-78392 and
m3-max-78422): plain Metal reads and writes the texels; Metal's validation asserts "Compute
Function(k_read): reads texture (t[0]) whose usage (0x04) doesn't specify
MTLTextureUsageShaderRead (0x01)", "writes texture (t[0]) whose usage (0x01) doesn't specify
MTLTextureUsageShaderWrite (0x02)" (an access::write argument asked only its width included), and
"Fragment Function(f_first): Shader reads texture (t[0]) whose usage (0x04) doesn't specify
MTLTextureUsageShaderRead (0x01)".

Docs: REFUSALS.md regenerated (the refusal's site); the runtime README's Textures section states
the rule (Texture slots and usage) and its compute encoder, render encoder and swizzle entries
name the refusal; RESOURCE-ID.md's sentence that a slot binding a colour target of neither usage
reads nil now says what a runtime refuses; the doc comments of set_texture, set_vertex_texture,
dispatch_threadgroups, draw_primitives, gpu_resource_id and new_texture_view_with_swizzle name it.

The test literals of the kernel interface and of a content's draws (tests/compute.rs,
tests/indirect.rs) take the new field.

Verified: cargo fmt. The red and green runs, clippy and the runtime suite on lavapipe follow as
jobs.
2026-12-02 10:12:04 -08:00
Anees Iqbal 9ad296c6cd rt: Refusal::TextureUsageAtSlot, and a test of slots whose texture lacks the usage they ask (red)
A texture slot a function uses, bound to a texture whose usage lacks what the function's access
there asks, reaches no element of the texture's, and nothing refuses it: the slot reads element 0
of set 1 (nil's null descriptor) as zeros and its writes are dropped. A texture no shader reaches
(a Depth32Float target of RenderTarget usage alone, a texture of PixelFormatView usage alone) has
no index; a colour target of RenderTarget usage alone has an index whose elements are null; a
texture not made for shader writes has no storage element. This is the index-free direct bind of
the consumer's row 194 that is still open after f3bb94275b, which refuses the bind of a texture
reached through its views alone.

Metal binds such a texture and its validation stops the command that uses the slot, by the
argument's declared access; plain Metal reads and writes the texels. Measured on an Apple M3 Max,
macOS 27.0.1 (jobs m3-max-78392 and m3-max-78422, runtime-compiled MSL):
- setTexture:atIndex: binds every such texture, under the validation layer too;
- the validation layer asserts at the dispatch "Compute Function(k_read): reads texture (t[0])
  whose usage (0x04) doesn't specify MTLTextureUsageShaderRead (0x01)" for a sample, a read or a
  get_width alone of an access::read or access::sample argument; "writes texture (t[0]) whose
  usage (0x01) doesn't specify MTLTextureUsageShaderWrite (0x02)" for an access::write argument,
  its get_width alone included; both for access::read_write; and at the draw "Fragment
  Function(f_first): Shader reads texture (t[0]) whose usage (0x04) doesn't specify
  MTLTextureUsageShaderRead (0x01)", the pass's own attachment included;
- Metal's unknown usage answers 0x17 and passes every access; a view's usage is its texture's
  (0x14, 0x11); a view made with a swizzle answers 0x11 (ShaderRead | PixelFormatView) of a
  texture of 0x13 and of one of unknown usage, and a write of it asserts;
- with the layer off, plain Metal reads the depth (0.75), the texels (64, 128, 192, 255) and the
  width (4) in every case, and writes a swizzled view through its swizzle.

This commit adds the refusal a dispatch or draw will return (stage, slot index, the texture's
usage as Metal answers it), its basis line, REFUSALS.md, basis.rs and the signature table, and the
device test slot_usage: sample_down (slot 0 sampled, slot 1 written and its size asked),
depth_fill_read and first_texel_fragment over textures of each usage. Its controls (read and
write usage, unknown usage, a view of a read texture, a read depth) run with their texels; a
render-target colour source, a read-only destination, a swizzled view's destination, a
render-target depth with no index and a PixelFormatView-only texture with no index expect the
refusal and their bytes kept. The commands do not refuse yet, so the test is red here: they run
and read zeros (or drop or unswizzle the write). The next commit makes them refuse.

Verified: cargo fmt; the red run is the next commit's job.
2026-12-02 10:12:04 -08:00
Anees Iqbal 15e53e4209 Translator: the emulated simdgroup tier takes the partial-threadgroups variant
select.rs refused a kernel's partial-threadgroups variant in the
Emulated tier (Unsupported{PartialThreadgroups}), which the runtime
reports for a ragged grid as Gap::PartialThreadgroups{Translator}. The
tier is lavapipe's for every SIMD-group kernel (its compute subgroups
are below 32), Intel's for a large kernel the widest-pin rule sends
there, and the emulated variant's on every device.

The variant now walks the tier's synchronizations as the subgroup tiers
walk their barriers. workgroup::check plans the predicated walk for a
kernel of partial threadgroups with any of the tier's synchronizations
(an exchange or a threadgroup barrier), with Predication::partial_groups
set, so emit_entry starts `live` from Metal's threads (lin < n) and the
invocations past them reach each exchange's barriers never live, storing
nothing. The exchanges take Metal's thread count as the threadgroup's
N: KernelDecl::live also answers that count, emit_entry keeps it as
EmitCx::entry_threads, and Emu::n is it in place of the local-size
constant. Every existing rule below N then answers Metal's partial
threadgroup: a read of a lane past it reads the calling lane, folds,
votes, ballots and quad masks take only the lanes below it. The scratch
stays sized from the local size, so every invocation has its slot.

Docs: LoweringInputs::partial_threadgroups, the divergent and workgroup
module docs, PartialThreadgroupsSite::Translator, the runtime README's
partial-threadgroups gap, and docs/REFUSALS.md regenerated.
SEMANTICS_VERSION 2316 -> 2317.
2026-12-02 09:56:19 -08:00
Anees Iqbal 7a1da6cb22 rt: a draw through buffers bound at a multiple of 4 below their alignment draws the state's word-bound content
Row L97 (the draw residual). A dispatch of a function's kernel whose buffer
argument of 8 or 16 is bound at a multiple of 4 below that alignment runs a
variant of its kernel that holds the slot to 4 (8 where a 64-bit atomic may
reach it). A draw refused such a bind (Refusal::BufferOffsetAlignment). It
now draws the same way.

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

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

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

Verified:
- Green on lavapipe, m3-max-79015 (at this commit's tree before its rebase
  onto 8dd00ec58c). Over tests::draw, render_offsets and indirect: 67 of 67
  passed, 838 skipped. The new test draws every case through the content,
  and the second draw of a bind finds it.
- The two draw-alignment tests on a card per vendor, 2 of 2 passed on each:
  - Radeon 780M (RADV PHOENIX, Mesa 26.2.6), m3-max-79076, at this commit;
  - RTX 3090 (NVIDIA 620.70.06), m3-max-79043, and Iris Xe (ANV, Mesa
    26.2.6), m3-max-79051, both before the rebase.
- m3-max-79086, at this commit: workspace clippy (all targets, all
  features, -D warnings) EXIT=0 in all three configurations (plain,
  --cfg m2v_cpu_icd, --cfg m2v_gpu); Rustdoc EXIT=0; the runtime's private
  Rustdoc EXIT=0. The runtime suite on lavapipe: 903 tests run, 903 passed,
  3 skipped.
2026-12-02 09:30:59 -08:00
Anees Iqbal 212d7b2d8e rt: blit copies whose rows meet go a row at a time where no one axis orders them, and a surface's plane lies in its buffer
Row L212. Metal leaves overlapping copies undefined; an Apple M3 Max reads the
source whole before it writes, which the runtime gives as slabs, and no Vulkan
copy command may read bytes it writes (VUID-vkCmdCopyImage-pRegions-00124,
VUID-vkCmdCopyBufferToImage-pRegions-00173,
VUID-vkCmdCopyImageToBuffer-pRegions-00184).

Form (blit.rs):
- Slabs becomes an enum: Across (the existing single-axis cut) and Rows
  (RowSlabs). Where cut() finds no axis, row_by_row() takes the rows one at a
  time. Each row goes before every row whose source its destination lies on:
  descending where every destination row lies on a source row after its own
  (meeting()'s y shifts all positive), ascending where all are negative.
- Within a row, the shift from the destination row to its own source row
  (the first row's, plus the pitch difference per row) decides the cut. Zero:
  the row is its own bytes and copies nothing. Less than the row: slabs of
  |shift| in whole texels, the far end first. Otherwise: one command.
- Slabs::of yields each slab's 3D start, which ImageCopy::regions and
  BufferCopy::slabs add to the other side's origin and to the buffer offset.
- An execution barrier still separates two commands. Every hazard between
  them is a write after a read, as no row reads bytes an earlier row wrote.
- Still refused (Gap::OverlappingCopy): rows of two pitches that cross, where
  one destination row lies on a source row before its own and another on one
  after its own.

Surface (texture.rs, buffer.rs, surface.rs, d3d11.rs):
- An exported surface's plane image keeps its PlaneLayout (Under::Surface
  laid, from SurfaceImage).
- TextureObject::rows_in(buffer) answers the plane's rows in a buffer on the
  surface's memory: BufferObject::surface_range matches the buffer's block
  aliases to the plane's (Arc::ptr_eq) and maps the plane's offset through the
  block's memory range.
- A copy between a buffer and a texture takes those rows where the texture
  has none of its own. A texture over the surface's buffer is always the copied
  form (OverCause::Surface), so a copy between it and a plane shares no bytes
  in Vulkan, and is left as it was.
- The surface's buffer and planes are aliases that read alike in the general
  layout. Surface::buffer's doc quotes the section.

Docs:
- blit.rs and the copy methods' docs; error.rs's OverlappingCopy (REFUSALS.md
  regenerated).
- The runtime README: Blit encoders, their known gaps (only crossing pitches
  remain refused), and the surface's buffer.

Verified:
- Green, on lavapipe, m3-max-78902 (at 70c887a155, before the rebase): the
  blit module, 26 of 26 passed (865 skipped). The plane is in place
  (OpaqueFd); into it and out of it go a row at a time.
- Cards, the blit module at 02421a08a9, 26 of 26 passed (867 skipped) on each.
  That tree differs from this one only by a branch for a texture in place over
  a surface's buffer, now deleted: no device laid one in place, and each
  printed "copied".
  - Radeon 780M (RADV, Mesa 26.2.6), m3-max-78888.
  - Iris Xe (ANV, Mesa 26.2.6), m3-max-78889.
  - RTX 3090 (NVIDIA 620.70.06), m3-max-78896.
  On each, the textures over one buffer are in place: whole rows go a row at a
  time (16 slabs; 256 on the Iris, whose memory alignment is 4), and two
  pitches go a row at a time. The surface's plane is in place (OpaqueFd), into
  it and out of it a row at a time.
- m3-max-78906 at 70c887a155: workspace clippy (all targets, all features,
  -D warnings) EXIT=0 in all three configurations (plain, --cfg m2v_cpu_icd,
  --cfg m2v_gpu). Rustdoc and the runtime's private Rustdoc EXIT=0. The
  runtime suite on lavapipe: 888 tests run, 888 passed, 3 skipped.
- refusal_surface.py --check: 0 at this commit.
2026-12-02 08:42:26 -08:00
Anees Iqbal 9c375eb504 Conformance ledger: the sample-positions cases answer on the runtime, so their seventeen refused rows go
The rt side of the suite now hands a pass's positions to the runtime's RenderPassDescriptor
instead of answering `setSamplePositions:count:` Unavailable, so the answer those rows expect,
`Err(Unavailable({call: "setSamplePositions:count:"}))`, can no longer occur on any venue. The
fourteen `*` rows (custom-left, custom-mixed, custom-right, the three fewer-, high, off-grid,
off-grid-low and the five rounded- cases) and the three venue rows of sample-positions-custom-2x
(Iris(R) Xe, RADV, NVIDIA) are dropped. A venue without VK_EXT_sample_locations, or whose
properties fall short of the answer, would answer at the same site with
`Refusal::SamplePositions` of `Unsupported` or `Gap::RenderPass`, which its replay would print as
unlisted; no venue run here does. docs/CONFORMANCE-COVERAGE.md is regenerated (7979 ledger rows to
7962); docs/METAL-COVERAGE.md is unchanged.

Verified: `conformance replay` of the 19 sample-positions cases and pass-sample-positions at
33865b2a57, before this edit, on each venue: every one of them listed exactly these rows as no
longer held ("now matches: 15", 14 on the Apple M3 Max, which has no custom-2x row) and nothing
unlisted; the custom and rounded cases read announced (justified by notices) on each.
- RX 7900 XTX, RADV NAVI31, Mesa 26.2.6: m3-max-78702
- Radeon 780M, RADV PHOENIX, Mesa 26.2.6: m3-max-78710
- RX 550, RADV POLARIS12, Mesa 26.2.6: m3-max-78713
- RTX 2080, NVIDIA 620.70.06: m3-max-78703
- RTX 3090, NVIDIA 620.70.06: m3-max-78711
- Iris Xe (RPL-P), Mesa 26.2.6: m3-max-78704
- Apple M3 Max, KosmicKrisp Mesa 26.3.1 (VK_EXT_sample_locations revision 1): m3-max-78722
lavapipe's replay with this ledger runs in the green job. Not run: the RTX 5080 Laptop GPU and the
Windows host's UHD Graphics 630.
2026-12-02 08:39:11 -08:00