Commit Graph
1046 Commits
Author SHA1 Message Date
Anees Iqbal eb16ce79c9 docs: a plain fptosi or fptoui of a NaN answers the device's conversion
The translator lowers LLVM's plain fptosi/fptoui to a bare OpConvertFToS or
OpConvertFToU, whose answer for a NaN or an out-of-range value SPIR-V
leaves undefined, while MSL 8.6 sends a NaN to 0. No accepted difference
said so.

Metal's compiler never emits the plain cast: probe job m3-max-55309 compiled
int(), uint(), static_cast and two-lane vector casts of float and half in a
kernel and in fragment functions, with fast math on and off, and every one
is an air.convert call (which the translator saturates). Over the indexed
corpus (29446 modules, job m3-max-55344) and the replay streams on every
node that holds them (jobs m3-max-55344, 55346, 55348, 55349, 55350, 55351)
no function holds a plain fptosi or fptoui; the same walk counting
air.convert float-to-integer calls finds 35606 in the corpus and 19840 in
the M3's streams (job m3-max-55356), so the scan reads real IR.

So the plain cast stays the device's conversion, stated in docs/API.md's
accepted differences under Conversions.
2026-11-19 18:14:14 -08:00
Anees Iqbal 90a02e250d identity domains: a checked access's domain is its buffer, not its bind window
Metal's domain for a buffer argument is the buffer: an access before the bind offset reads the
buffer's bytes there. The containment check measured the offset from the bind offset against
the bytes from there to the buffer's end, so a checked access before the bind offset read zero
and a store there did nothing, where Metal reads and writes the buffer.

- PushField::SlotRemaining (u32) becomes PushField::SlotBounds (uvec2): the buffer's bytes
  before the bind offset (the bind offset), then its length; a set*Bytes copy 0 and its length;
  nil 0 and 0. The check is psb::in_buffer: (len >= n) && (m + before <= len - n) in u32, m the
  offset from the bind offset read as signed. Before the buffer's start the sum wraps to at least
  2^31, past every length (no buffer is longer than 2 GiB). One add more per checked access and
  one more pushed u32 per checked slot.
- Offsets are signed on every identity form: the word-below form (psb::prepare_at, also the
  pulled fetch's) now sign-extends the offset instead of reading it from the slot's window start,
  as the direct form already did through its 2^31 bias.
- The new runtime's encoders push the bounds (encoder::bounds, Tables::bounds); the old runtime's
  binder writes them from the bound buffer and still refuses ZeroAddress.
- The old runtime's lowering is unchanged; SEMANTICS_VERSION 2195.

Tests: engine_identity_domain (new, interpreter): on both identity forms a run-time -4 at bind
offset 16 reads the word at 12 and at bind offset 0 reads zero, a constant -4 at bind offset 16
reads the word at 12, and the default domains read the word at 12 as docs/API.md says.
engine_identity_contain adds an access before the bind offset (inside the buffer: read and
written) and one before the buffer's start (outside). The identity tests push the bounds.

Docs: API.md sections 1 and 5 and the new runtime's README state the domain and the cost.
2026-11-19 17:24:00 -08:00
Anees Iqbal a010d17c6b translator: a fetch's element index first among the floor's fragment fields, from the vertex function's end
On the floor a fragment function's push fields started at the vertex function's push end rounded
up to 8. Where that end is a multiple of 4 and not of 8, the four bytes below the base went
unused, and a fetching fragment function placed its four-byte element index
(PushField::FetchedColor) after its eight-byte fields: a pair that fits the floor's 256 bytes
with those four bytes used was pushed past them. The fragment base is now the vertex function's
push end, and FetchedColor sorts after SlotBindOffset and before the slot addresses
(SlotGuestBase): a fragment function that pushes no parameter block's address places it in those
four bytes. Each field is still placed at the next offset aligned to it, so a fragment function
whose first field is eight bytes, the spilled block's address included, starts where it did, and
the vertex function's window still ends at 248. The fixed windows read no base: the old runtime's
modules are unchanged.

The docs that stated the rounding say the base is the vertex function's end: the push module,
VERTEX_FLOOR_END, LoweringInputs::push_base, docs/API.md section 5, rt's README, and the render
identity test's notes; the spill test reads the base unrounded (its vertex function ends at 248).
2026-11-19 17:22:28 -08:00
Anees Iqbal 7934b405d8 fetch (draft): surfaces read through the loop where their query offers it; loop reads counted; tests and docs
A surface plane whose texture is a shader-read render target takes the feedback
usage where the handle's image format query offers it with the export features
alike (Query::plane; a D3D11 import's query the same), and the in-place make
retries without it where the images with it do not hold the layout; a plane
without it reads through its shadow, the counted copy. The fetch and the texture
read choose the loop or the shadow by the image, not the device.
Metrics::attachment_loop_reads counts every draw that reads an attachment of its
own pass through the loop. Device tests (tests/fetch.rs): N fetching draws exact,
N-1 barriers or copies more than one; a surface plane of each fetched format.
RenderPipelineKind::FramebufferFetch removed. SEMANTICS_VERSION 2193,
ARTIFACT_FORMAT_VERSION 550 (PushField::FetchedColor). REFUSALS.md and
api_signatures regenerated; README and API.md.

Draft: the old render key re-pin follows the compile check.
2026-11-19 17:22:28 -08:00
Anees Iqbal adf59be4a7 rt: multisample resolves in the pass, by Vulkan's own resolve
A store action that resolves (MultisampleResolve, StoreAndMultisampleResolve, and
Unknown where the attachment names a resolve texture) resolves in the same rendering:
the attachment's VkRenderingAttachmentInfo names a view of the resolve texture's
resolveLevel and resolveSlice and a resolve mode, so the pass adds no pass, copy or
barrier of its own. Color resolves by AVERAGE, the mode Vulkan requires of a float,
normalized or sRGB format, under the new static note PrecisionNote::DeviceRoundedResolve
(RenderPassDescriptor::precision_note) on every device. Depth resolves by its
MultisampleDepthResolveFilter: Sample0 always, Min and Max where the device's
supportedDepthResolveModes has them; stencil by Sample0. Refused as Metal refuses them:
a resolving action with no resolve texture (Refusal::ResolveTexture) and an integer
format's resolve (Refusal::ResolveFormat). Gaps: RenderPassKind::Resolve (another
format, one sample, an emulated encoding, two depth-stencil views), ResolveFilter
(a mode the device lacks, DepthResolvedSample, an unpaired aspect) and LateStore (a
later store that does not resolve an attachment that began resolving).

The old runtime maps the new note to its device-rounded-resolve degradation; the
validation allowance, the conformance suite's rt side and the replay player carry the
resolve fields and filters.

Evidence, draw_full_4x: 64 full-screen draws in one pass into a 4-sample RGBA16Float
target, resolved as the pass ends (MultisampleResolve) into the 1-sample texture the row
checks texel by texel against the draw colour before its timed runs. Each arm records, a
run, 64 draws, 1 pass, 1 barrier and no copy: new's Metrics::resolves 1; old's 1 render
pass instance, 1 vkCmdBeginRenderPass, 64 draws, 1 barrier, no image copy or blit
(m3-max-55061). GPU p50 in us, old,new then new,old, one harness build each:
780M new 259.0/258.7 against old 1933.6/1827.4, new is 86% faster; RX 550 new
1643.5/1643.8 against old 7207.8/7209.3, new is 77% faster (harness at 1ff6574894,
m3-max-55050, 55061); RTX 3090 new 170.0/171.0 against old 188.7/190.0, new is 10%
faster; Iris Xe new 1006.4/1007.7 against old 1022.1/1019.8, new is 1.4% faster
(harness at 5af66e2c4e, m3-max-54928, 54938, 54939). Why old is slower on AMD is not
traced.

Verified: see the check job named in the landing.
2026-11-19 16:56:15 -08:00
Anees Iqbal 3fc316d576 identity domains: a render pipeline's functions spill past their shares of the floor's push range
Under the identity domains a vertex or fragment function whose push fields passed its share of
the floor's one 256-byte range was refused (Unsupported{IdentityDomains} needing
maxPushConstantsSize). Once containment added each checked slot's length (SlotRemaining) and the
zero range's address (ZeroAddress), pairs reached 272 bytes and were refused: 3 render states of
windrag-780m-b2 (223 draws) and 4 of syncview (259 draws), and the guest's GL-layer pipelines on
reims's walks. A render function now spills as a kernel does: it pushes its parameter block's
address first (PushField::ArgumentTableAddress) and reads every field past its window from the
block, each loaded once, in the function's first block (EmitCx::load_push_fields). The refusal and
its REFUSALS.md row are gone.

- Order: the check's fields are last in the derived Ord of PushField, after
  TessellationFactorAddress (ZeroAddress, then each SlotRemaining), so what every access reads is
  placed ahead of what only a checked access reads, and the check's fields are the first to move
  to the block. The codec's list is unchanged.
- The vertex function's floor window is [0, 248) (push::VERTEX_FLOOR_END). A vertex function is
  lowered without knowing its fragment function, and a fragment function that spills pushes its
  block's address (8 bytes, 8-aligned) from the vertex function's end, so the vertex function
  leaves that room. Cost: only a vertex function whose own fields pass 248 bytes spills where it
  used to fill the last 8.
- metal2vulkan-rt: Draws holds each field's place (the push range or its function's block) and
  each function's block (length, the push offset of its address). A draw that fills its pushed
  values anew writes each block into the parameter ring and its address into the range;
  ring_writes counts it. A block longer than a ring chunk stays Gap::RenderPipeline(DrawInput).
- SEMANTICS_VERSION 2194 (placement changed).

Tests: push.rs's edges (a vertex function ending at 248 with a spilling fragment function, whose
address goes at 248; a fragment base of 244, whose address is still at 248; a vertex function
whose fields would reach 252, which spills); engine_identity_spill: a vertex function of 25 slots
pushes its block's address first and every slot's address, spills only the check's fields, passes
L3, and loads each spilled field once in its first block; the pair with a fragment function from
248 compiles and validates on every identity profile; on the interpreter its sums are Metal's, and
lengths pushed one word short, in the window and in the block alike, read zero.

Docs: push.rs's module text, docs/API.md (section 1) and the rt README state the shares, the 248
and its reason, and the spill.
2026-11-19 15:59:29 -08:00
Anees Iqbal 5573e16f00 docs: the identity domains check run-time-offset slot accesses against the pushed length
docs/API.md: the policy's identity-domain text and section 5 state SlotRemaining and
ZeroAddress, the normative check in u32, what an outside load, store and atomic do, that an
offset before the bind offset is outside, and what stays unchecked (constant offsets, pointers
loaded from memory or made from integers). The rt README's known gaps say the same for buffer
arguments, the nil buffer's length 0, and the pulled fetches.
2026-11-19 15:38:33 -08:00
Anees Iqbal 2b8b894101 docs/API.md: the translator's own Workgroup words, the binder's index-rewrite kernels among them
The list named the binder's scan and merge kernels; its index-rewrite
kernels hold Workgroup words too, each written before it is read.
2026-11-19 13:52:36 -08:00
Anees Iqbal d4241114cc conformance: compute-threadgroup-memory-reads-zero recorded on the M3
Metal on the M3 Max (macOS 27.0.1, job m3-max-53825, three runs, one
outcome) answers metal2vulkan_devtools::threadgroup_start::answer in each
of the six dispatches: no word of the declared array or of the
[[threadgroup(0)]] region read nonzero before the program wrote it, in
the later threadgroups of 2048 of 16 KiB and in the second dispatch;
every pattern read back (0xffa00000); its SIMD groups of 32 in thread
order. docs/API.md states that answer, the engine fixtures' README lists
tgz_reads, and CONFORMANCE-COVERAGE.md is regenerated.
2026-11-19 13:52:36 -08:00
Anees Iqbal a69cb43486 translator: threadgroup memory reads zero until the program writes it, on Device::from_queries
On the new runtime's profile every Workgroup variable that holds a
function's threadgroup memory has a null initializer: the threadgroup
arena (declared threadgroup variables, [[threadgroup(n)]] regions and the
imageblock, memory::arena) and the typed threadgroup objects
(lower::access::local). One form on every device: the Vulkan 1.3 floor
requires shaderZeroInitializeWorkgroupMemory; a profile without it
refuses such a function, Unsupported{ZeroedThreadgroupMemory}.
Device::new's profile is unchanged (ProfileFacts::ROWS keeps
ThreadgroupStart::Unwritten), so the old runtime's SPIR-V is too.

The translator's own Workgroup words get none, as it writes each before
any read: the emulated SIMD-group scratch and vote word, the object
stage's mesh grid, the mesh wrapper's count and staged indices, the
emulated payload and the binder's scan and merge kernels.

The builder refused a null of an array whose length is a specialization
operation (spirv/ir/constant.rs, ConstRule::NullType); an arena with
regions, and the emulated scratch, have such lengths. spirv-val's
IsTypeNullable reads an array's element type alone, so the builder now
takes it. That refusal is what made rt report a probe's emulated variant
as missing (Gap::PartialSimdgroups after Later::lower's Refused).

The profile verifier also refuses a Workgroup initializer other than a
null (VUID-StandaloneSpirv-OpVariable-04734).

docs/API.md states the form with Metal's words on threadgroup memory;
SEMANTICS_VERSION 2192; REFUSALS.md and api_signatures regenerated.

Tests: engine_zeroed_threadgroup (null initializers through from_queries
on four profiles, zeros on the interpreter in both orders and two
threadgroups, the emulated variant's arena zeroed and scratch not,
Device::new uninitialized, the vk12 floor refused),
a_specialization_sized_array_has_a_null, a_workgroup_initializer_is_only_a_null,
the profile facts' fingerprint.
2026-11-19 13:52:35 -08:00
Anees Iqbal 567b959429 conformance: a DontCare row's texels are unchecked on metal2vulkan-rt, which Apple's page leaves arbitrary
The three buffer-target-clears-*-dont-care cases were divergent on every rt venue at
case/buffer-after-the-pass: 64 elements, the target's 16 texels. Metal (Apple M3 Max, macOS
27.0.1) left the buffer's pattern there. rt stores the clear: its README says a DontCare store
stores, "one of the outcomes Metal allows".

Metal's documents. MTLRenderPass.h says only that DontCare is the default store action. Apple's
page for MTLStoreAction.dontCare: "The GPU has permission to discard the rendered contents of
the attachment at the end of the render pass, replacing them with arbitrary data." and "Some
GPUs may still store the contents back to the texture, but you can't rely on that behavior. You
need to assume that GPU discarded the texture's contents." So Metal documents those texels as
arbitrary, and the fix is the case's, not a ledger row.

The fix:
- A DontCare row declares each of its 64 texel bytes Unchecked, at case/buffer-after-the-pass/
  <offset>, under the new accepted difference "The new runtime's DontCare store writes what the
  pass rendered" (docs/API.md, render passes; it quotes the page and the M3's answer).
- The justification is NewRuntimeAccepted, so the old runtime's run, whose answer is the M3's,
  still compares every texel exactly. The padding and the bytes before and after the target
  compare on both runtimes.

Test: a_dont_care_row_leaves_its_texels_unchecked_on_the_new_runtime_alone. Against the M3's
kept bytes and ours with the clear in every texel, it expects:
- no divergence on rt's run, and no bad allowance (the slug is in docs/API.md);
- one 64-element divergence on the old runtime's;
- a divergence on rt for a moved byte at 0, just before the target, just after a row, or the
  last byte;
- no declaration for a Store row.
2026-11-19 11:35:31 -08:00
Anees Iqbal 4c21a8d38a translator: a render pipeline into an RGB9E5Float attachment records SharedExponentKept on Device::from_queries
metal2vulkan-rt's conformance side read shared-exponent-store divergent on the Radeon 780M at
case/drawn/texels (16 words, Metal 0x6e020080 where the device kept 0xa00c0401; whole-set
m3-max-52928, then 53116): Metal's tile store writes an RGB9E5Float word whose largest mantissa is
below 256 back normalized, and the device's pass keeps the word. The case loosens that site on
the `shared-exponent-kept` notice, but only the old runtime announces it, at the draw, from its
encoder (render.rs); rt has no such encoder step and the translator recorded no note, so the
device's answer went unannounced. A missing static note is a bug (rule 1). Its twin,
SnormMinimumKept, already has the static form; this gives the shared exponent the same one.

- `PrecisionNote::SharedExponentKept` (appended): the note of a render pipeline that draws
  single-sampled into an RGB9E5Float color attachment.
- `pipeline::private_state::note_tile_store` (was `note_snorm_minimum`) records it as it records
  SnormMinimumKept: on the fragment stage (the vertex stage where there is none), whatever the
  pass loads, and only where the profile's existing `SnormMinimumNote::Noted` says so, which is
  `Device::from_queries`. No new fact, switch or device check: `Device::new`'s modules, keys and
  the old runtime's announcement are unchanged.
- The old runtime's `Degradation::from_precision_note` maps the note to its existing
  `shared-exponent-kept` kind: one arm, which its exhaustive match requires to compile, as
  DepthDenormals and CompressedTexelDecode did. It adds no switch, fact row or device check to the
  frozen runtime, and nothing it does changes.
- The codec takes the variant; ARTIFACT_FORMAT_VERSION 548 -> 549. fast_paths lists the note under
  Elsewhere. Validation's comparison allowance is Unbounded, as for the other device-answer notes.
  api_signatures gets the two variant rows and the macro row. docs/API.md's `shared-exponent-kept`
  entry says where the static note is recorded.

Test: engine_private_render_state's
a_shared_exponent_attachment_notes_the_words_metal_s_pass_normalizes. On lavapipe and moltenvk-m3
the note is on the fragment stage alone through Device::from_queries, on no stage through
Device::new, and on none at four samples or into RG11B10Float, RGBA16Float or RGBA8Snorm. The
conformance case shared-exponent-store on the 780M through the rt side is the end-to-end test.
2026-11-19 11:35:30 -08:00
Anees Iqbal 5d3d55ef90 rt: a texture the runtime places reads zero until written; the fresh-texture declaration deleted
The guest's own code reads textures it never wrote (two 1x1 ShaderRead
textures, read before any write). The M3 and the old runtime answer zero;
rt answered whatever the range held before, which followed process
history. Metal does not say what a new texture holds, so zero is rt's
choice, stated as such in the README, not as Metal's rule.

What changes:
- A new texture of new_texture, new_texture_for_views and
  new_managed_texture (Source::Plain and Source::Managed) carries a Zero:
  a colour clear, a depth-stencil clear (every aspect), or copies from the
  zero source for a format of texel blocks wider than a texel, which no
  clear writes (VUID-vkCmdClearColorImage-image-00007, -01545).
- The upload records it with the move home: one barrier from undefined
  to the transfer destination layout (with the moves home of every image
  not zeroed), the clears and copies, then one barrier to the home
  layouts. No tracking, and no check on any bind or draw. Textures in a
  heap, over a buffer, of a surface plane, drawables and shadows are not
  cleared.
- The zero source grows from 16 bytes to 64 KiB, a row of 16-byte blocks
  16,384 texels wide; fill::zero_regions copies in bands of whole rows of
  at most that, and in runs along a row where one row is larger.
- Metrics::texture_clears and texture_clear_bytes count the clears; the
  replay player reports them per frame.
- The declaration of 2f4c9fc9dc is deleted: replay::new_texture_contents,
  its slug and docs/API.md entry, and its uses at the fresh sites of the
  fresh-texture, fresh-pattern, texture-round-trip and format-footprints
  rows, which compare exactly on rt again. Its test goes; its unknown-slug
  check moves to the remaining rt-only declaration's test.
- README: "not for a heap's memory or a texture's" now says a texture rt
  places reads zero until written, as rt's choice with its reason; heap
  memory is unchanged.

Old runtime, for comparison: crates/metal2vulkan-runtime/src/texture.rs
4805-4806 decides a clear where clears_to_zero (5191) holds, else copies
of the device's zeros (zero_copies, 5541), recorded at 4936-4942 into the
image's first move (texture/first_move.rs), taken by the next submission.

Tests: the_zero_source_s_copies_write_every_element_once (pure), and
every_device_reads_zero_from_a_new_texture_where_another_was_written
(device): a Shared texture written 0xa5 in every subresource, read back,
released; a new Shared and a Private texture at the same place read zero
in every subresource, one clear counted each, of its image's bytes.

Verified: not yet; the lint, suites and negative-control jobs follow.
2026-11-19 10:02:47 -08:00
Anees Iqbal 6eb83eabff rt README: a command buffer is scheduled once the one submit thread's earlier calls return, whatever their queue; the Iris Xe's figures
The known gaps of queues gain the rule behind the running-signal case's
declaration. Every queue's command buffers go to the device's one VkQueue,
which takes one vkQueueSubmit2 call at a time, since Vulkan requires a queue's
host access to be externally synchronized. The device's one submit thread
makes every call (submit.rs has one call site, reached only from the thread's
pass), and it schedules a command buffer once its earlier calls have
returned, whichever queue they were for. So one long driver call delays every
queue's scheduling by its length. The API.md accepted difference the
declaration cites now states the same ground.

Measured on an Iris Xe (RPL-P, ANV):
- m3-max-52564: the device's first submission, 192 fills of a new 256 MiB
  block, spent 27-30 ms in vkQueueSubmit2. The other queue's waiter was
  scheduled 0.02 ms after that call returned, in 3 of 3 runs.
- m3-max-52745, the separating run with the probe's block size as a scratch
  switch, never committed: the first call took 2.1 and 2.5 ms with 1 MiB,
  9.1 ms with 64 MiB and 28.4 ms with 256 MiB. Its time grows with the new
  block the submission first uses. The probe's later submissions took at most
  0.18 ms.
- In the same job, the 256 MiB run (the case's own shape) read Committed and
  the case's declaration fired at both MTLEvent sites, verdict 'announced'.
2026-11-19 08:21:53 -08:00
Anees Iqbal 1e583d5e0c conformance: the running-signal case's MTLEvent reading may be Committed on rt alone, where its submit thread is still busy
On the Iris Xe, event-wait-behind-a-running-signal's MTLEvent row read the
waiting command buffer Committed with no handler run, where the M3 Max had
scheduled it while the signaller ran. This held in 3 of 3 runs (m3-max-52564).
The trace showed why. The waiter's wait was met at once by the signal's
staging. rt's one submit thread was still inside the signaller's
vkQueueSubmit2, the device's first submission, which took 27-30 ms on ANV. The
waiter was scheduled 0.02 ms after that call returned. Apple defines Scheduled
as all dependencies resolved and the command buffer scheduled for execution,
and promises no time between the two. The planner ruled this a timing
difference and not a conformance bug.

The case now declares, on rt's run alone (Justification::NewRuntimeAccepted),
that the MTLEvent row's waiting status while the signaller runs may be
Committed or Scheduled, and its handlers none or the scheduled one. The
declaration cites a new accepted difference in docs/API.md, 'The new runtime
schedules a command buffer once its submit thread is free'. The shared event's
row is not loosened: both runtimes hold its waiter until the value is reached.
The old runtime's run compares both sites exactly.

New test: a_wait_met_by_a_running_signal_may_read_committed_on_the_new_runtime_alone.
It checks that the Iris answers are no divergence on rt and are rows on the old
runtime, that the shared event's sites still diverge, and that a status other
than the two still diverges.
2026-11-19 08:21:39 -08:00
Anees Iqbal 0fa1b8f14c conformance: case 6's declaration says why rt reads 1024 and that Metal's 0 was measured
A reader of "0 or 1024" could take it for a race in rt. The docs/API.md
entry and the case's comment now say why 1024 is rt's answer (a writer
whose queue has fewer than three submissions in flight is submitted at
once, so the later reader reads it on every device and run), and that
Metal's 0 there was measured on the M3 Max (jobs m3-max-52432 and, behind
three, m3-max-52415), not documented. The entry's lead-in, and so its
slug, is unchanged.

Verified: in the jobs named in the landing's report.
2026-11-19 07:52:59 -08:00
Anees Iqbal 57a33a11e9 conformance: fence-none-tracked-behind-one declares the new runtime's word count, an accepted difference
On metal2vulkan-rt the case read divergent at case/order/y/words-written:
Metal 0, ours 1024 (job m3-max-52528, lavapipe). The writer's queue has
one busy command buffer, below the three at which rt holds a group, so
rt submits the fill at once and the later copy on another queue reads
all of it. Metal's tracking orders only against work it has already
submitted, and on the M3 Max it ran the copy first (5 of 5, job
m3-max-52432). rt's answer is the order Apple describes for a tracked
write (later commands wait for it); Metal's there is timing.

docs/API.md section 10 lists it under a new "Command queues" heading,
citing the rt README's measured line, and the case declares the count
on the new runtime's run alone (AnyOf 0 or 1024, NewRuntimeAccepted):
the old runtime's answers still compare exactly, and every status
still compares on both.

Verified: in the jobs named in the landing's report.
2026-11-19 07:52:59 -08:00
Anees Iqbal 2f4c9fc9dc conformance: a new texture's fresh read is unchecked on metal2vulkan-rt, where Metal is silent
rt answers a new texture with whatever its memory last held. Metal's two texture-making sentences
say nothing of a new texture's contents: MTLDevice.h gives newTextureWithDescriptor: only
"Allocate a new texture with privately owned storage.", and Apple's page only "Creates a new
texture instance.". The page for newBufferWithLength:options: promises zeros ("Creates a buffer
the method clears with zero values."). An Apple M3 Max on macOS 27.0.1 read zero from new Shared
and Managed textures.

What changes:
- A new justification, Justification::NewRuntimeAccepted(slug): an accepted difference of
  docs/API.md that holds on the rt run alone. On the old runtime's run it is
  Unjustified::OldRuntime, which faults nothing, so the old runtime's answers still compare.
- The declaration replay::new_texture_contents(site) leaves the site unchecked under the new
  docs/API.md entry "The new runtime's new textures read what their memory last held". It carries
  the four facts above and the words "silent", never "undefined".
- It is named at the fresh site of every texture row:
  - fresh-texture-* and fresh-chain-*, every storage mode;
  - fresh-pattern-*;
  - texture-round-trip-*;
  - each format-footprints round trip.
- It is not named by any buffer row or texture-over-buffer row: Metal promises those zeros, and
  they stay exact on rt. The written sites and the statuses stay exact on both runtimes. rt writes
  nothing to pass a row.

Why: these rows' fresh sites follow process history on rt. m3-max-52251 (lavapipe, rt) ran plain
development at ed2d2295ce and 391db1e57a and the set at be7ff19f8a:
- 73, 74 and 74 rows divergent, all at fresh sites.
- texture-round-trip-1/12/13/14 are exact each alone in a process and divergent after other cases.
- Which Shared/Managed fresh-texture rows read the released texture's 0xa5 changes from run to
  run, even alone.

Tests:
- a_new_texture_s_fresh_read_is_unchecked_on_the_new_runtime_alone: the bytes are unchecked on rt
  and are the site's one row on the old runtime. A written-site difference stays a row. An
  unknown slug fails the case.
- The fresh rows' allowance test now holds the declaration on every texture and pattern row and
  on no buffer row.
2026-11-19 06:55:22 -08:00
Anees Iqbal a36ac51121 translator: the identity domains' refusal names the first form the function holds that they do not lower
The identity gate (lower::select's identity_admits) answered Unsupported{IdentityDomains, NotImplemented}
for every plan it does not admit, with nothing saying which of its conditions failed. It now
names the first form the plan holds, in the refusal's symbol (diagnostics only), by what a
program does that takes it: a stage off the floor's push window, an encoder value it reads as a
push field outside the identity set, a buffer argument not reached by its device address, an
argument buffer's texture of a type, depth comparison, raw or cross-type read the identity arrays
do not take, a handle that reads its table entry beyond its element, a texture argument with
state beyond its resource ID, a sampler form (a texture argument sampled through a sampler the
identity sampling does not take, a sample of an argument buffer's texture, an argument buffer's
sampler, an array of samplers, a bicubic filter, a specialized sampler argument), a runtime fact
of bound state, or a descriptor. The checks and their conjunction are unchanged
(identity_refusal is None exactly where every condition held), so an admitted plan is lowered as
before; only the refusal's symbol is new, and only under the identity domains, which the new
runtime alone takes.

A test confirms which form argument buffers tier 2's pointer indexing takes (engine/ab_tier2's
ab_indexed: thread g reads the texture of element g of the argument buffers a pointer member of
the bound one reaches): on lavapipe and the M3 profile its plan reads the root table
(PushField::RootTableAddress), whose address the identity domains do not push, so it is refused
naming that, while the default domains compile it and the identity domains lower ab_copy and
ab_read. docs/API.md's identity paragraph names the form and says the symbol names the first one.

Verified: probe job m3-max-52000 (gem10, the gate change with the form unpinned) read
"an encoder value the function reads as RootTableAddress" for ab_indexed on lavapipe, and
a_bicubic_kernel_is_refused_under_the_identity_domains passed beside it; refusal_surface --check
is clean. The pinned test's run is the next check job.
2026-11-19 06:37:13 -08:00
Anees Iqbal 71d767c904 translator: the storage-texture fact names the texture access type the air crate now exports
What: metal2vulkan-air exported intrinsics::Access only under cfg(test), so the unbound analysis
of 0a810a7ab5 did not compile (E0432). The air crate now exports Access (Form stays test-only),
the type of Texture's public access field. The analysis counts a read or block read through a
loaded texture as a storage access unless the operation declares access::sample or access::read,
so a read that declares no access (an emitter before AIR 2.0) counts, as the fact's 'false is
proven' needs. The interface and API.md docs say so.

Verified: cargo fmt; signatures.py --check gives no diff. The check job compiles it.
2026-11-19 05:09:37 -08:00
Anees Iqbal 4231c5ba25 rt, translator: a declared write of a texture with no storage element refuses the argument-buffer dispatch
What: bug 4's held path. A compute encoder's use_resource with a usage that writes a texture (or a
view of one) made for shader writes with no storage element (Texture::unstored) now makes every
later dispatch of that encoder whose kernel may reach a texture through its storage image beyond
its bound slots Gap::StorageElement, with no slot and the texture's format. A kernel without such
an access dispatches whatever is resident, and use_heap declares nothing (Apple's header: useHeap
declares the heap's resources read only through an argument buffer), so a write through a
resource ID with no write-usage use_resource stays dropped, outside documented Metal.

How: the translator had no fact for that access (writes_unbound_resources with
texture_writing_stages would also refuse a kernel that writes a bound texture and a buffer through
an argument buffer), so StageInterface and PipelineInterface gain unbound_storage_textures,
decided in compile/unbound.rs beside the read and write facts: a texture write or atomic, or a
read of a texture the operation declares access::write or access::read_write, on a handle that
may come from memory, an integer or a call; an intersection or a call the entry cannot see into
counts; indirect-command and acceleration-structure operations touch no texture.
Gap::StorageElement's slot becomes Option<u32>. The render encoder builds no useResource:, so the
draw half has no trigger; the README says it waits for it.

SEMANTICS_VERSION 2190 -> 2191 and ARTIFACT_FORMAT_VERSION 547 -> 548 (one field in
StageInterface and PipelineInterface). docs/REFUSALS.md regenerated; api_signatures gains the
field and the variant's new shape; docs/API.md states the fact; the rt README's known gap says
what is refused and what stays dropped.

Tests: the translator's unbound-facts test states the new fact (an argument buffer's texture
write and a read_write read count, a sample and a read do not); storage_element gains
every_device_refuses_a_declared_write_of_a_texture_with_no_storage_element over RGBA8Unorm_sRGB,
BGRA8Unorm_sRGB, A8Unorm and an sRGB view of an RGBA8Unorm texture, and the same formats in a heap
under use_heap alone.

Verified so far: cargo fmt; refusal_surface.py, signatures.py --check and metal-coverage --check
give no further diff. The build, the suites and the device legs follow in potluck jobs.
2026-11-19 05:09:37 -08:00
Anees Iqbal b683148a41 rt, translator: the identity domains give a SIMD-group's threads no lockstep order
What: under the identity domains (the new runtime's profile) the translator no longer inserts the
barriers that make Apple's SIMD-group lockstep explicit (`lockstep::order`): `OrderKey::of` is
`None` there and `ordered_entry` takes the specialized entry as it is. The resident-table domains
(the old runtime's) keep the order until the cutover. With no lockstep barrier on the new
runtime's path, its one-row machinery is dead and deleted: `Compiled::rows`, `pipeline::one_row`,
`encoder::Module::Rows`, `keeps_rows` and `choose`'s `rows`, the `OneRow` and `RowLockstep` arms,
and the translator's `CompiledFunction::runs_lockstep_barriers_in_rows` with
`KernelFacts::lockstep_in_rows` (the API signature table; the version numbers rise in the
branch's last commit).

Why: documented Metal orders the threads of a SIMD-group only through barriers and atomics; the
Metal Shading Language calls two of them that conflict between barriers a data race. The order was
an emulation of undocumented Apple-GPU behaviour (owner's rule 1). Its barriers made 1,443 of 5,368
distinct kernels of the recorded streams observe their threadgroup partition, every pair of them
unproven, and they stopped partial-threadgroup dispatches the variant cannot run (rt's frame-320 and
frame-335 refusals of the 30-wide kernels). docs/API.md's accepted differences gain one entry, the
conformance case `simdgroup_lockstep` leaves its output words unchecked against it, and
CONFORMANCE-COVERAGE.md and REFUSALS.md are regenerated.

Tests: the identity-profile one-row test becomes `the_identity_domains_order_no_lockstep_pair`
(barriers under the default domains, none under the identity domains, the partial variant in
tiles); the harness's cells test keeps the old domains' one-row facts and adds the identity
domains' none; rt's one-row tests and the row-lockstep tree test go, and `row_cells` runs every grid
on its tiles' pipeline made with the state.

Verified: cargo fmt; coverage.py and refusal_surface.py regenerated. Clippy and the suites run on
the check job named when the branch is handed over.
2026-11-19 04:21:14 -08:00
Anees Iqbal ac72291f01 translator: the binder writes a slot's biased word under the identity domains; the slot-pointer test drops ptrtoint; the old render key re-pinned
Three failures of the landed biased slot word (development's suite, job 51276):

- engine_identity::the_binders_edge_regions_set_multi_region_on_from_queries_and_store_metals_grid
  trapped out of bounds at 0x6_8000_0000: the translator's own binder
  (BindingPlan::instantiate_*) still wrote SlotGuestBase as gpu_address + offset, while a
  pipeline compiled under the identity domains adds 2^31 back to that word. This was a code bug in
  the landed change. rt was not affected: it writes its own push (pipeline::address_word) and does
  not use the binder. The binder now writes the word less 2^31 (bind::instantiate::guest_word)
  wherever the plan's device compiles under the identity domains. The flag is
  ResourceTemplate::biased_slot_words, set by the compute and render planners. All three writers
  read it: slot_field, the render rebind's bases and its loose words. RUNTIME_VERSION
  2538 -> 2539: a run of an unchanged plan pushes another word under the identity domains. The
  runtime sources' pin moves with the binder's files.

- engine_identity::a_slot_pointer_used_as_a_value_is_its_metal_address was refused at compile
  (Unsupported{IdentityDomains}, not implemented). Its ptrtoint makes the slot pointer a wide
  pointer, which reads the root table, a push field identity_admits does not admit. The refusal
  is the test's premise, not the bias: select and the plan are unchanged by the bias. The test
  now covers two address compares and two loads, one 4 bytes below a bind address, with the two
  slots on either side of 2^31: their words lie on either side of 0, so a compare of the words
  would answer the other way. A new test,
  a_slot_pointer_converted_to_an_integer_is_refused_under_the_identity_domains, pins the ptrtoint
  refusal on both profiles, where the default domains compile the kernel. docs/API.md section 5
  says so; it no longer claims that a converted pointer reads the bias back.

- pipeline::compile::tests::the_old_render_descriptor_key_keeps_its_value: the key moved only
  because SEMANTICS_VERSION and ARTIFACT_FORMAT_VERSION moved (2186/544 -> 2188/546); the
  fixture's bytes are unchanged. Re-pinned to the value job 51276 computed.
2026-11-19 03:42:31 -08:00
Anees Iqbal f6032c796c rt: a render encoder sets the alpha test reference, and alpha-test states are made
A gap against the old runtime. rt refused every render state whose fragment
runs the private alpha test (PrivateRenderState::alpha_test_enabled with a
compare function other than Never or Always): the translator pushes
PushField::AlphaTestReference there, and render.rs draws() mapped no value for
it, so new_render_pipeline_state answered Gap::RenderPipeline { DrawInput }.
Nothing drew against an unfilled push word; Never and Always states, which read
no reference, were made and drew right.

Now RenderCommandEncoder::set_alpha_test_reference_value(f32) (Apple's
setAlphaTestReferenceValue: SPI) keeps the reference's 8-bit unorm code in the
encoder's state, Metal's 1 until set, not kept across encoders (the old
runtime's rule, from probes on an Apple M3 Max, macOS 27.0.1); draws() maps the
field to FieldValue::AlphaTestReference, and a draw pushes the code. A change of
code refills the push bytes; an equal one records nothing new. The code is the
translator's: bind::alpha_test_code, now public (api_surface row, docs/API.md
line), so rt and the binder compare as Metal does through one function.

Test: tests::alpha_test draws green at alpha 0.6 (code 153) under Greater, one
quadrant a draw through scissor rectangles: the default reference and 0.75
keep the clear, 0.25 (held across draws) draws, and a second encoder starts at
1 again (its whole-target draw changes nothing) until 0 draws. README and the
API signature table updated.

Verified: build and device legs follow.
2026-11-19 03:32:27 -08:00
Anees Iqbal c4b38afdb8 rt and translator: a buffer slot's pushed word is its address less 2^31, and an access adds its offset plus 2^31, zero-extended
Under the identity domains a buffer slot aligned to its argument was reached as its pushed address
plus the access's 32-bit byte offset sign-extended to 64 bits. The sign extension is what keeps an
offset below the bind address exact, but a device cannot split a sign-extended offset into a
scalar base and a vector offset as it does a zero-extended one. Now rt pushes the slot's address
less 2^31, and an access adds its offset plus 2^31 (modulo 2^32) to that word, zero-extended. That
is the same address for every offset in [-2^31, 2^31), which the 2 GiB buffer cap guarantees, in
one 32-bit add that a device fuses with the index's shift. A unit index x + c with a constant c
folds c into the bias: (x + c) * s + 2^31 = x * s + (c * s + 2^31) mod 2^32. The builder notes
each u32 sum of a value and a constant for that; the note changes no emitted word.

One place on each side:
- rt: pipeline::address_word, used by the compute and render push writers for every
  BufferAddress field: a bound buffer, a setBytes copy, or the nil buffer.
- translator: lower::access::pointer.
  - biased_slot_address feeds the direct reach.
  - slot_address (the word plus 2^31) feeds every other reader: an access from the word below
    it, a pointer compare, ptrtoint, the memmove overlap's Metal addresses, and pulled vertex
    fetch.
  - The bias applies only under the identity domains and only where the word is pushed: a
    replay variant reads the true address from its root entry.

Unchanged:
- A texture's or sampler's resource ID and the parameter block's address are not biased.
- A pointer loaded from an argument buffer keeps today's form: the address the buffer holds.
- The default domains, which the old runtime and the golden tables use, take no new instruction:
  the readers there load and bitcast the field in the same order as before.

Argument-buffer pointers left in their form (planner's condition):
- They are 19.6% of the corpus's device and constant accesses.
- Time-weighted, they are 0.8% of accesses on the 780M stream gb-780m-u4 and 2.4% on the RTX 3090
  stream gb-3090-r5.
- Kernels with any such access take 1.9% and 8.4% of those streams' GPU time.

Slot pointers used as values, in the entry functions of the corpus's 11,580 kernels (census over
the local sources shards):
- 781 (6.7%) use one as a value: 14 convert one to an integer, 46 compare one, and 731 store one.
  Every such store but one writes private memory (a pointer cell); the one other writes device
  memory.
- 3,511 (30.3%) pass one to a non-inlined function.
- 33 pass one to an air.* call (command encoding, intersect).
A ptrtoint and a compare read slot_address. A pointer parked in a private cell or passed to a
function stays a fat pointer, whose accesses take the forms above. The one store to device memory
makes a wide pointer, which reads the root table, a field identity_admits does not admit. A new
engine test, a_slot_pointer_used_as_a_value_is_its_metal_address,
runs a kernel under the identity domains with biased pushes on the interpreter. It does a ptrtoint
to i64 and to i32, an address compare, and loads 4 bytes below a bind address and 20 above
another, and checks each against the true addresses.

Probe numbers (measured: one particle kernel run alone on RADV 26.2.6, us per dispatch, best of
forward and reverse; the module's two positions accesses changed by hand). Biased form against the
plain zero-extended offset (inexact below the bind address), at subgroup size 32 and at the
driver's 64:
- RX 7900 XTX: 33.6 vs 33.6, 30.8 vs 30.6; at 4x the grid 374.6 vs 374.0, 273.1 vs 272.9.
- PHOENIX 780M: 168.1 vs 168.3, 121.1 vs 120.5; at 4x 2521.9 vs 2522.8, 1744.6 vs 1752.8.
- HawkPoint 780M: 173.3 vs 173.2, 122.5 vs 122.7.
The sign-extended form it replaces measured, at 32:
- HawkPoint: 189.8 (same job), 9.5% slower.
- PHOENIX at 4x: 2735.3 (same job), 8.5% slower.
- XTX: 35.9 (another job), 6.8% slower.
The XOR form with a host-biased word (V7) measured 178.8 on HawkPoint: the add is the one that
fuses.

The tests:
- The identity engine tests push the biased word through engine_word_phases::slot_word.
- rt's three hand-made test kernels (ADD, STEP, WIDE) add 2^31 to each slot word. Their arrays
  are regenerated from the doc GLSL with glslangValidator --target-env vulkan1.2 and checked with
  spirv-val. Today's GLSL reproduced today's arrays exactly before the edit.

docs/API.md (sections 1 and 5), PushField::SlotGuestBase's doc and rt's README known gap on the
2 GiB cap state the word and the form.

SEMANTICS_VERSION 2186 -> 2188 and ARTIFACT_FORMAT_VERSION 544 -> 546. The identity nolockstep
lane holds 2187 and 545, unlanded; these take the next numbers so the two land separately.
2026-11-19 03:07:44 -08:00
Anees Iqbal e9c324a8f4 conformance: the decode cases' bound loosens metal2vulkan-rt's run alone; the old runtime's rows are as they were
The planner's ruling on the twelve old-side RADV rows f1aa961e34 added: the frozen old runtime
takes no new ledger row, so the case's notice-justified bound is scoped to the new runtime and the
old runtime's side keeps what it had, which was no bound.

A new justification, Justification::NewRuntimeNotice (Justification::new_runtime_notice), holds
on metal2vulkan-rt's run as a degrade notice does, where the run announced it; on the old
runtime's run it holds nowhere and faults nothing (Unjustified::OldRuntime, which faults_the_case
excludes beside VenueCompresses), so the site compares as if the case loosened nothing. The venue
says which side ran (Venue::new_runtime: true on the rt side, false on the old runtime's and on
Metal's), and replay hands it to the comparison (Offered::on_new_runtime). compare's check that a
named justification exists treats it as it treats a notice.

The ten BC1 to BC5 decode cases loosen each round's texels by NewRuntimeNotice
(compressed-texel-decode). known-gaps.tsv is the ledger as it was before ae452ee883: the twelve
RADV rows go, and the 89 BC rows that commit's series removed (lavapipe 44, the RTX 5080 Laptop
40, RADV BC4 and BC5 5) and their comment are back, since the old runtime's sites differ again
as they did.

docs/API.md: the catalogue says the cases' bound is the new runtime's alone.
scripts/conformance-coverage: the justification vocabulary reads new_runtime_notice;
docs/CONFORMANCE-COVERAGE.md regenerated.

Test: tests::a_notice_scoped_to_the_new_runtime_leaves_the_old_runtimes_site_its_one_row (the old
runtime's site is its one divergence, unfired for OldRuntime; rt's announced; rt without the
notice faults).
2026-11-19 02:01:42 -08:00
Anees Iqbal 260163301f conformance: the fresh-texture test counts the decode notice; the catalogue's cost stays the old runtime's words
m3-max-50899's suites named three things of ee0827889e.

fresh_contents' a_row_loosens_the_notices_site_and_a_private_texture_s_fresh_site counted a
texture row's allowances without the compressed-texel-decode declaration its block-compressed
rows now make: it counts it, and holds that only those rows make it.

The old runtime's catalogue test holds an entry's Cost to the words the kind announces, before
whatever more it says: the measured bounds go after the announced cost (the RTX 2080's, and ANV's
and the UHD 630's BC3 alpha 2/255 and BC4/BC5 1.4/255, signed 0.0134, each BC4/BC5 texel within
0.0001 of the specification's exact decode), and the cost is the old runtime's again.

docs/CONFORMANCE-COVERAGE.md regenerated: 89 ledger rows fewer.

Verified: the bcref decode of the per-element dumps (the 2080, the Iris Xe and the UHD 630).
Expected: the suites green on msi with this commit.
2026-11-19 01:40:30 -08:00
Anees Iqbal 3a6eac60d5 conformance: the decode cases' bound takes float rounding; fills and fresh textures declare the decode note; stale BC rows go
The whole-set replays of c83f9b0db1 on lavapipe named three things.

texture-fills-130, -134 and -152 and the fresh-texture-bc1-rgba rows make block-compressed
textures, which rt now notes as CompressedTexelDecode, and declared no such notice: both
families now declare it at the notices site (texture_fills.rs among the native notes it already
declares; fresh_contents.rs where the row's format is block-compressed). Neither loosens a value.

The old runtime announces compressed-texel-decode on lavapipe for BC1 to BC5, so with the
cases' bound justified by that notice its 40 llvmpipe rows (256 bits) no longer diverge, and the
replay said so. Those rows go, with the 128-bit lavapipe rows and the RTX 5080 Laptop rows
(whose recorded largest differences all lie inside the family bounds) and RADV's BC4 and BC5
rows (RADV holds no ChannelBlockDecodeIsMetals, so the old runtime announces there). RADV's BC1
to BC3 sRGB rows stay: RADV holds ColorBlockDecodeIsMetals, so the old runtime announces nothing
there.

Each texel is a float, rounded by up to half an ulp of a value below 1, so two codes exactly a
bound apart can read a few billionths past it (6/255 between 128/255 and 134/255 in float is
6/255 + 3e-8): the bound takes f32::EPSILON / 2 on top. The RTX 2080's BC3 reached
0.023529410362, 1.4e-9 inside 6/255, by that luck alone.

docs/API.md: the catalogue's measured bounds, from the per-element dumps on the RTX 2080
(620.70.06), the Iris Xe (ANV) and the UHD 630 (Intel's Windows driver): ANV and the UHD 630
reach BC3's alpha 2/255 and BC4/BC5 1.4/255 (signed 0.0134), past the 1/255 and 1.3/255
(0.013) it stated; the 2080's BC1 to BC3 3/255 and BC3's alpha 6/255.
2026-11-19 01:40:30 -08:00
Anees Iqbal ae452ee883 rt: a block-compressed texture carries the static note of its decode, CompressedTexelDecode
A read, sample or gather of a BC texel on metal2vulkan-rt is the device's decode of the texture's
own blocks, where Metal interpolates a block's endpoints with 6-bit weights. rt carried no note of
it, so the ten BC1 to BC5 decode cases read divergent on every Linux venue with no notice behind
them. The old runtime announces the same difference as compressed-texel-decode, gated by driver
facts; rt decides by the format class alone, on every device, RADV included.

- PrecisionNote::CompressedTexelDecode in the translator's public enum (codec, and
  ARTIFACT_FORMAT_VERSION 544; fast_paths' "elsewhere" list; validation allows it unbounded).
  No pipeline stage records it, so no translation changes.
- Texture::precision_note: Some(CompressedTexelDecode) for a texture or view whose own pixel
  format has a block extent (metal::format::block_extent: BC1 to BC7, ASTC, ETC2, EAC, PVRTC;
  rt makes the last four only where the device holds the format), None otherwise, as
  DepthStencilState::precision_note is shaped. Device test: a BC1, BC7, ETC2 and ASTC 4x4
  texture (where the device makes it) and its sRGB view carry the note; RGBA8Unorm and its sRGB
  view carry none.
- The old runtime's Degradation::from_precision_note maps the note to its existing
  compressed-texel-decode kind (one arm, which the exhaustive match requires).
- The conformance rt side announces the note of every texture it makes (one keep_texture helper,
  makes_texture, and the work runner's made resources).
- compressed-texel-decode leaves the suite's native notes: its catalogue entry states bounds, and
  a native note loosens nothing. The ten BC decode cases declare it and loosen each round's
  texels by the catalogue's largest bound for the family on any driver (BC1/BC2 4/255, BC3
  6/255, BC4/BC5 7.4/255, signed 0.065; an sRGB form the sRGB decode's largest step over
  4/255). The other families that make a compressed texture declare it at the notices site
  alone: the BC moves and views, ASTC, ETC2/EAC, the read-write tier tables and the usage
  table of the descriptor pairs.
- docs/API.md's catalogue entry covers both runtimes; rt's README states the note;
  api_signatures and CONFORMANCE-COVERAGE regenerated.
2026-11-19 01:40:29 -08:00
Anees Iqbal 2efe8b1582 translator: the fractional-spacing note's measured drivers include ANV
PrecisionNote::TessellationFractionalSpacing's doc and its API.md entry
listed ANV among the drivers not measured. A consumer's tessellation pixel
test (its render_tess_bump device test) passed on its Iris Xe (ANV) leg,
so ANV's fractional partitions matched Metal's answers in that test's
cases. The note now lists RADV (780M, RX 7900 XTX), NVIDIA Turing, ANV
and MoltenVK, and says factors past the device's range are not measured:
no test sets one.

Docs only; no behaviour changes. Verified: cargo fmt --all.
2026-11-18 19:10:23 -08:00
Anees Iqbal f940151891 translator: a fractional partition on the device's tessellator carries a static note
Vulkan leaves where a fractional spacing places its vertices to the implementation ("Tessellator
Spacing": the two shorter segments' length need only fall monotonically with n - f, and their
place on the edge is the implementation's), where Metal's tessellator places them by its own rule.
No note said so: rule 1 wants a static note on an operation whose answer can differ from Metal's.

PrecisionNote::TessellationFractionalSpacing is now recorded on the evaluation stage of every
pipeline of a fractionalOdd or fractionalEven partition drawn through the device's tessellation
stages (Control::notes); the emulation, Metal's tessellator, records none. Its documentation
states the measurement: equal to Metal's by a consumer's device tests on RADV (Radeon 780M, RX 7900
XTX), NVIDIA Turing and MoltenVK; other drivers, ANV and lavapipe among them, are not measured.

The old runtime takes it as a note kind (tessellation-fractional-spacing), validation allows it
unbounded, codec and ARTIFACT_FORMAT_VERSION 542, SEMANTICS_VERSION 2184 (the evaluation stage's
notes change), fast_paths' list, API.md's catalogue; the tessellation engine test expects it on
the fractional cases and on no emulated stage. api_signatures regenerated.
2026-11-18 19:10:23 -08:00
Anees Iqbal 28f2735f52 translator: the tessellation winding's vertex order is measured, on four drivers
Metal's clockwise output winding maps to VertexOrderCcw and its counter-clockwise one to
VertexOrderCw. The control stage's docs, PrecisionNote::TessellationWinding and API.md called
that an unobserved reading of MoltenVK's mapping. A consumer's device test,
tessellation_states_tessellate_as_metals, now matches Metal's bytes (recorded on the M3 Max) for
both windings on RADV (Radeon 780M, RX 7900 XTX), NVIDIA Turing and MoltenVK; the docs say so,
and that other drivers are not measured. The note stays: it is still recorded on every
tessellation pipeline. Docs only.
2026-11-18 19:10:23 -08:00
Anees Iqbal 4df69ca062 rt: generateMipmapsForTexture:, the device's linear blit of each level, under a static note
web3d calls generateMipmapsForTexture: once in each stream, which the player skipped and counted
(mipmaps 1). It is built as Apple defines the call: each level below the texture's first made
from the level above it, over each slice, a view's levels and slices its own.

- BlitCommandEncoder::generate_mipmaps: one vkCmdBlitImage a level with VK_FILTER_LINEAR, the
  first level read and the rest written whole (their old contents discarded) behind the copy's
  first barrier, one barrier between each level and the next, and the last bringing every level
  home, the last level's writes visible to every later command. A texture of one level records
  nothing.
- Refusal::MipmapFormat for a format Apple defines no mipmaps of (a depth or stencil, compressed,
  YCbCr or integer one: not colour-renderable and filterable); Gap::MipmapFilter where the
  device's format query lacks blits from and to the image's format or its linear filtering,
  where the image holds the pixel format through a conversion, and for a view in another format
  than its image's, whose blit would filter the image's.
- PrecisionNote::DeviceFilteredMipmaps, the static note BlitCommandEncoder::GENERATE_MIPMAPS_NOTE
  carries: the filter is the device's, where Apple states none. The old runtime announces it as
  its existing device-filtered-mipmaps kind; validation allows it unbounded; codec and
  ARTIFACT_FORMAT_VERSION 541, fast_paths' list, API.md's catalogue entry.
- The conformance rt side plays Step::GenerateMipmaps and announces the note; the replay player
  plays the call and its skipped_mipmaps counter is gone (REPLAY-STREAM.md).
- Test: an 8x8 RGBA8Unorm texture of four levels, each level below the first within one code of
  the box of the four texels it halves in the level above as the device left them, its first
  level kept, one submission and the chain's four barriers besides the segment's end; one level
  records nothing; RGBA8Uint is Refusal::MipmapFormat. REFUSALS and api_signatures regenerated.
2026-11-18 19:10:22 -08:00
Anees Iqbal 9c40b3cd83 rt: depth tests, writes and bias as dynamic state, under static notes; an unknown store action stores
The render-state lane's depth step (the planner's step 1).

- A depth-stencil state's depth test, write and compare operation are dynamic state, recorded
  where they changed; DrawKind::DepthTest is gone. A pipeline bakes the depth format alone, so a
  change of depth-stencil state or bias makes no pipeline. In a pass without a depth attachment
  Vulkan skips the test, where Metal's documentation states no answer.
- set_depth_bias (setDepthBias:slopeScale:clamp:): the bias and slope scale as given, enabled for a
  draw of triangles where either is not zero and never for lines (Metal biases triangles alone).
  A clamp other than 0 is Gap::Draw of DepthBiasClamp (no stream sets one).
- Static notes, carried by the operation: PrecisionNote::DeviceDepthBias
  (RenderCommandEncoder::DEPTH_BIAS_NOTE: the slope measure, and a fixed-point attachment's unit,
  are the device's; Apple states neither; read from Vulkan's Depth Bias section and Apple's
  setDepthBias page), and PrecisionNote::DepthDenormals (DepthStencilState::precision_note, a state
  that tests or writes depth: every driver measured but MoltenVK on an M4 compares a denormal
  depth otherwise than Metal; RADV and ANV store one as zero). The old runtime maps DepthDenormals
  to its own depth-denormals kind and takes device-depth-bias as a note kind; codec, fast_paths,
  validation's allowance (Unbounded), API.md and ARTIFACT_FORMAT_VERSION 539 follow. No signed-depth
  note: no clear, viewport or upload gives rt a negative or NaN depth, and Vulkan leaves a depth
  past the viewport's range undefined.
- MTLStoreActionUnknown stores (Vulkan fixes the store as the rendering begins); the encoder's
  set_color_store_action, set_depth_store_action and set_stencil_store_action change nothing the
  device does and refuse a resolving action (Resolve). On a tile-based device this stores a
  target Metal would have discarded (README).
- set_triangle_fill_mode, set_depth_clip_mode, set_viewports and set_scissor_rects take Metal's
  defaults (Fill, Clip, one viewport or rectangle) as nothing and refuse the rest, typed
  (FillMode, DepthClamp, Viewports): replay found every stream at the defaults.
- The conformance rt side plays the depth bias, fill, clip and viewport-count steps and announces
  the encoder's notes; the replay player maps setDepthBias:slopeScale:clamp:, the three store
  action setters, setTriangleFillMode: and setDepthClipMode:.
- Tests: a depth attachment cleared to 0.5 with its store action unknown, tested under Less with
  writes, failing at 0.375, passing Greater by its bias alone, every mode setter's refusal, and no
  pipeline made by the state changes; the instructions a depth-tested draw retires beside a plain
  one, printed. REFUSALS.md regenerated, the API table blessed.
2026-11-18 18:02:33 -08:00
Anees Iqbal 6d4ca09039 translator: a render pipeline into a snorm attachment records SnormMinimumKept on Device::from_queries
metal2vulkan-rt's conformance side ran the six snorm-store cases on lavapipe (job 48051). Each
diverged where Metal's tile store writes a loaded minimum code (-128, or -32768) back as the code
above it, and the device's pass keeps the bytes. The old runtime announces that as
`snorm-minimum-kept` at the draw, from its encoder (render/tile_store.rs). The new runtime has no
such encoder step, and the translator recorded no note, so the answer went unannounced. A missing
static note is a bug (rule 1: a static note fixed per operation).

- `PrecisionNote::SnormMinimumKept` (appended): the note of a render pipeline that draws
  single-sampled into a color attachment of R8Snorm, RG8Snorm, RGBA8Snorm, R16Snorm, RG16Snorm
  or RGBA16Snorm.
- `pipeline::private_state::note_snorm_minimum` records it on the fragment stage (the vertex
  stage where there is none), whatever the pass loads. That is static, so it may over-announce
  a cleared pass.
- It is recorded only where the profile's new fact says `SnormMinimumNote::Noted`. That is
  `Device::from_queries` (ProfileFacts::EVERY); `Device::new` (ROWS) stays `Announced`.
  `Device::new`'s modules, keys and the old runtime's announcement are unchanged.
- The old runtime maps the note to its existing `Degradation::SnormMinimumKept` (an explicit
  `from_precision_note` arm). Validation's comparison allowance is Unbounded, as for the other
  device-answer notes. The codec takes the variant, and ARTIFACT_FORMAT_VERSION goes from 536 to
  537. fast_paths lists the note under Elsewhere. api_signatures gets the two variant rows and the
  macro row. docs/API.md's `snorm-minimum-kept` entry says where the static note is recorded.

Test: engine_private_render_state's
a_snorm_attachment_notes_the_minimum_code_metal_s_pass_rewrites. On lavapipe and moltenvk-m3, for
each of the six formats, the note is on the fragment stage alone through Device::from_queries and
on no stage through Device::new. No stage records it at four samples, or into RGBA8Unorm or
RGBA16Float. The six conformance cases on the rt side are the end-to-end test (the check job's
replay, named in the report).
2026-11-18 15:50:11 -08:00
Anees Iqbal d6a1a86d98 translator: the one-row variant leaves out the barriers of pairs apart in rows on every device; CompiledFunction says whether a kernel's lockstep barriers run in rows
LoweringInputs::one_row's lockstep order cleared the pairs that meet only where a SIMD group
spans two rows only where Lockstep::rows held, which needs maximal reconvergence on 32-lane
subgroups without the device's own lockstep: the old binder's condition for asking the variant.
On a device without that tier (lavapipe's 8-lane subgroups, the UHD 630 without the extension,
GCN's 64-lane waves) a one-row compile kept every barrier, though the clearing is exact there
too: in a threadgroup whose SIMD groups each lie within one row, those pairs never meet,
whatever runs the SIMD groups. The order now searches the pairs under the rows facts for every
one-row compile and clears them wherever every pair left wants a threadgroup barrier at most.
Lockstep::rows and RowLockstep keep their meaning, so Device::new's plans, and the old binder's
one-row compiles, which it asks only where rows holds, are unchanged.

CompiledFunction::runs_lockstep_barriers_in_rows (KernelFacts::lockstep_in_rows) says whether a
kernel's lockstep order inserted a barrier that runs where each SIMD group lies within one row:
any but the threadgroup barriers that order only pairs meeting across rows
(Lockstep::across_rows), which the module runs only where its local size lets a SIMD group span
two rows, a test the driver folds. Only where it holds can the one-row variant run fewer
barriers than the kernel's own module at a one-row size, so a runtime asks the variant only
there. It is decided from the plain compile's order and changes no module. docs/API.md states it;
the api_signatures table gains its row.

SEMANTICS_VERSION 2181 -> 2182: a one-row compile on a device without that tier changes. The old
runtime's render descriptor key is re-pinned under it (b3d05d42). ARTIFACT_FORMAT_VERSION 536 ->
537: KernelFacts gains lockstep_in_rows.

Test: a_one_row_variant_clears_the_pairs_apart_in_rows_without_a_32_lane_tier, on lavapipe's
from_queries profile under the identity domains. Three kernels, each with its stores in its entry
block and past a bounds test (six in all), keep lockstep barriers in their plain module and state
no RowLockstep:
- one storing the three words 3 cell + k of its cell y * stride + x in int arithmetic, as Apple
  compiles it (nsw on every step, the index sign-extended);
- the same in uint arithmetic, whose steps carry no flags;
- one whose threads store at x and x + 1.
In the one-row variant the first has none. It states OneRow, takes no simd class, does not
observe its partition with partial threadgroups (the variant without one_row does), and runs its
grid in tiles. The other two keep their barriers: the wrapping index is not proved apart in
rows, and the neighbours meet within one row. Every plain module runs its lockstep barriers in
rows but the unguarded int cells kernel's, whose barriers all order pairs across rows.

Verified:
- Check 48214 (msi) at this series' tip on development 50719da96b: clippy with -D warnings of
  metal2vulkan, metal2vulkan-rt and metal2vulkan-harness (default, --cfg m2v_gpu and, for the
  runtime, --cfg m2v_cpu_icd) and their Rustdoc are clean; their host suites pass 3,863 of
  3,867, and the 4 that fail all name engine/oor_texture_reads, a fixture development added
  (603634f9f9) without its golden-table and inventory rows, whose re-bless development owns; the
  runtime's device suite passes on lavapipe (275 run, 3 skipped).
- The translate probe (jobs 47932, 47952; lavapipe's from_queries profile and three device
  profiles): lcg_step's plain and partial-threadgroups modules are byte-identical before and after
  this change (SPIR-V 3226775232d06722, 649 words, and 991ee4501d037271, 1202 words), and
  runs_lockstep_barriers_in_rows is false for it. The harness fixture's row_cells holds two
  barrier.lockstep.simdgroup (barrier.lockstep.emulated.simdgroup on lavapipe), the kind the
  streams' four row-indexed kernels hold; it runs them in rows, and its one-row variant holds none.
2026-11-18 14:34:01 -08:00
Anees Iqbal 4b781a949c translator: a grid tile tests its edge only inside a branch on its region's ragged flag
On Device::from_queries' profile a kernel that runs its grid in tiles compared every
invocation's position with the grid's last thread before its body, on every dispatch. The
test now sits inside one uniform branch on the region's NONUNIFORM flag, which rt (and the
binder) already set for every region of a grid its workgroups do not divide: a ragged
dispatch runs today's test, and every other dispatch (a grid the workgroups divide, an
indirect dispatch) branches past it, its body deriving its position only where it reads it.
One pipeline serves both, so there is no added compile or first-use wait. Device::new's
profile has no grid tiles, so its modules are unchanged.

The branch is also what keeps a driver's scheduler from spreading a kernel's pushed-word
loads through its body: a form that dropped the branch lost 17-55% on a many-binding row on
RADV and the UHD 630.

SEMANTICS_VERSION 2180 -> 2181. The grid tile tests now run each grid flagged and
unflagged: flagged, no invocation past the grid stores; unflagged, a ragged grid's do, so
the flag alone guards the test.

Verified at the same change on 69af14bd22 (12f3602f1d): lint, the translator suite and rt on
lavapipe (m3-max-47411); rt's device tests 249/249 on the Iris (47443), the 7900 XTX and the
RTX 2080 (47498). Compiled code: the flag test is a wave-level scalar branch over the decode
and compare on RADV (7900 XTX, 47462) and a uniform branch on ANV (Iris, 47407); the
many-binding row's pushed-word loads stay together under one wait. Harness compute rows
against 69af14bd22, losses re-timed alone: UHD 630 (47436, 47449), Iris (47407), 7900 XTX
(47408, 47441), RTX 2080 (47408, 47441), RTX 3090 (47409, 47461), RX 550 and 780M (47406).
2026-11-18 11:13:29 -08:00
Anees Iqbal 990328afe1 translator: from_queries' profile contains no threadgroup access, and an arena of whole float words is a float array
What: a new profile fact, device::profile::ThreadgroupMemory, says whether an access of
threadgroup memory is contained. Device::new's profile keeps Contained, byte for byte: a load past
an arena reads zero, a store past it is dropped, and a typed threadgroup object's dynamic index is
clamped to its level. Device::from_queries' profile takes Native: no threadgroup access is
contained, and an access past a kernel's threadgroup memory is undefined, as in Metal. One
predicate, lower::access::local's contained(), decides it at the six sites that contained one:
an arena's loads and stores, its atomics, memory intrinsics, pointer cells and imageblock, and a
typed threadgroup object's index. Device memory's containment is unchanged.

On the Native profile, a kernel's arena whose every access is a whole, aligned float word (a float
or a vector of 2 to 4, at an offset its alignment makes a multiple of 4, with no atomic, no memory
intrinsic and no access of another type: memory::Leaf::float_words) is a float array of its own
whole words, at least four (memory::arena::FLOAT_LEAST). Each access is one typed load or store per
lane at its word index, with no bounds compare, no select and no bitcast. Every other arena stays
the u32 array of composed words, unchecked on this profile. The census names the float form's
accesses access.threadgroup.load.floats and access.threadgroup.store.floats.
SpecOp::ISub, which only the contained arena's bound used, is deleted.

docs/API.md's threadgroup memory bullet says so. The runtime README's contract states that an
access past threadgroup memory is undefined, as in Metal, and that the runtime does not confine
it. SEMANTICS_VERSION 2180; the old render key's pin moves with it.

Why: Metal leaves an access past threadgroup memory undefined, so containing it changes nothing a
correct program observes. Containment cost GPU time on every card measured: each access paid a
bounds compare and a select, and each composed word paid its bitcasts.

Verified (A = before this change, D = this change, both on from_queries):
- GPU p50 of the harness rows whose kernels use threadgroup memory or SIMD-group operations,
  D over A, the median over 6 rounds of each. threadgroup_floats is a float scan that the probe
  harness adds. No other row's kernel declares threadgroup memory (workloads.metal).
  - UHD 630 (job 47289): threadgroup_scan 0.972, threadgroup_floats 0.892, simd_reduce 1.000,
    vote_loop 1.000.
  - Iris Xe (47290): threadgroup_scan 0.965, threadgroup_floats 0.919, simd_reduce 1.000,
    vote_loop 1.000.
  - Each arm's spread (its largest run over its smallest) is at most 1.013 on both cards.
- Driver compile per kernel on the UHD 630, the median of 5 cold processes per arm, each with a
  fresh store and driver cache and the module bytes salted (47319). Every process exited 0. D over
  A: the float scan 0.716, the typed scan 0.945, the SIMD reduce 0.951; the two kernels whose
  modules are the same in both arms 0.998 and 1.062.
- The same on the Iris Xe (47349): the float scan 0.678. The typed scan (1.108) and the SIMD
  reduce (1.19) are inside the run-to-run spread of 1.164 that a module equal in both arms shows.
- Cold plays of a replay stream up to frame 216, 4 per arm, with the arms alternated. Every
  threadgroup kernel matched by function identity, 16 of 16 in each arm.
  - RTX 2080 (47294): GPU 378.1 ms in A, 307.9 ms in D; driver 1154.8 ms against 1158.8 ms.
    The 128-wide kernels: 0.634 (18 dispatches) and 0.793 (65). The 64-wide kernels: 0.808 to
    0.959. The 1024-wide kernel: 0.933. The 395-dispatch kernel: p50 1.010, its total 0.996.
  - Radeon 780M (47295): GPU 127.8 ms in A, 116.8 ms in D; driver 234.7 ms against 202.6 ms.
    Every kernel's p50 is at or under A's: the 128-wide kernels 0.826 (18 dispatches), 0.799 (65)
    and 0.966 (5); the 64-wide kernels 0.815 to 0.938; the 1024-wide kernels 0.981 and 0.978;
    the 395-dispatch kernel p50 0.981, its total 1.006.
- Rebased on 11dc2d46d5: clippy with all features and with --cfg m2v_gpu clean; the translator's
  and the new runtime's whole suites 3831 of 3832, the one failure the old render key's pin, which
  SEMANTICS_VERSION 2180 moves; re-pinned here, it passes (47341). The golden-hash tests among them pass unchanged.
- No test of this change asserts what an access past threadgroup memory does. The containment
  tests of Device::new's profile stand.
2026-11-18 10:44:29 -08:00
Anees Iqbal 11dc2d46d5 translator: a removed argument's read takes zero and writes no status on from_queries' profile
What: a read of a texture, sampler or threadgroup memory argument the pipeline's function
constants removed (the absent read, lower::access::absent, and texture::AbsentArgument) takes the
same zero of its result's type as before: a read's zeros and a query's size of 0, which the nil
texture, set 1's element 0, answers too, with a write of a removed texture dropped. A new profile
fact says whether it also marks the command buffer's status (device::profile::AbsentReads):
Device::new's profile keeps Marked (StatusBits::ABSENT_ARGUMENT_READ, the ExecutionStatus fact,
its push field or binding), byte for byte; Device::from_queries' takes Nil, where the read marks
nothing and the stage states no AbsentArgumentRead or ExecutionStatus fact, no
ExecutionStatusAddress push field and no status binding. One form per profile, so it holds on
every stage: a fragment function's read, which the replay recordings name, and a kernel's, whose
pipeline the translator refused before on from_queries' profile (IdentityDomains: the status
word's push field is outside what the identity domains admit), now run. The
fact keys from_queries' fingerprint; Device::new's renders its fields alone, unchanged.
docs/API.md's degrade entry and ExecutionStatus bullet say so. SEMANTICS_VERSION 2179.

Why: Metal gives such a read no value, and its compiler drops or folds it; the new runtime writes
no ExecutionStatus words, so the status a read marked was a refusal of the whole pipeline.

Verified:
- f0c676d4f7, this change before its rebase onto a47fc3e69d: clippy with all features and with
  --cfg m2v_gpu clean, the focused tests 66 of 66 (job 46992). The rt device tests of a fragment
  function's and a kernel's read of a removed texture pass with the validation layer on and no
  validation error on the RX 550 (47027), the RTX 3090 (47028) and the Iris Xe (47029); the
  control, built without the change, fails both (47030).
- Rebased on a47fc3e69d: clippy with all features and with --cfg m2v_gpu clean; the touched tests
  (absent, function constants, profile, golden, render descriptor keys, public fixtures,
  fingerprints) 257 of 258, the one failure the old render key's pin, which SEMANTICS_VERSION
  2179 moves; re-pinned here, it passes (47245).
2026-11-18 10:02:42 -08:00
Anees Iqbal a47fc3e69d translator: an argument buffer's texture index is masked to the set-1 image arrays
What: under the identity domains (Device::from_queries' profile alone; Device::new never takes
them, so its modules are unchanged), the handle of a texture whose resource ID an argument buffer
holds is the ID's low word masked to its low 16 bits (IDENTITY_TEXTURES - 1, the two image
arrays' 65,536 elements, a power of two the compiler checks): one OpBitwiseAnd a handle. A bad ID
reads the element at index & 0xFFFF, never one outside the arrays. Nothing else changes: a slot's
index is the runtime's own push (SlotGuestBase), a constexpr sampler's too (ConstexprSampler), and
an argument buffer's sampler is not lowered under these domains, so the sampler arrays stay at
4,000 with no mask. docs/API.md, where that sampler's refusal is listed, and RESOURCE-ID.md say
the change that first lowers one masks its index the same way. The new runtime's README records,
among the known gaps of memory blocks, that a shader uses a buffer's gpuAddress unchecked, so a
stale one can still fault the device. SEMANTICS_VERSION 2178: from_queries' translations of such a
texture change (2177 is the unlanded float-array branch's).

The feedback elements (index + 65,536 in the sampled array, where the device reads attachments):
only a draw's push of a texture slot's index reaches them. The render encoder builds no
useResource: or useHeap:, so no draw makes an argument buffer's texture resident, and Metal reads
an argument buffer's texture only once it is resident; the mask keeps every argument-buffer index
below 65,536 besides. So an argument-buffer texture that is also the pass's attachment is never
offset to its feedback element: the shader reads element index, as before, a read Metal leaves
undefined while the texture is not made resident (only the compute encoder has use_resource and
use_heap).

Why: the ID is the program's word, and an index past the arrays fetches a descriptor outside
them.

Verified:
- Check 46942 (msi) at this change on 98efd4de50: clippy, all features, 0; clippy under
  m2v_gpu 0; the identity, golden, old render key, resource ID and public fixture tests 86 of 87,
  the one failure the old render key, pinned here at 64b84e0f... from that run (SEMANTICS 2178).
- Final check 47056 (msi) at this tree (as 5794117bcb): clippy, all features, 0; clippy under
  m2v_gpu 0; the same tests 87 of 87, the old render key at its pin among them.
- Words per identity texture kernel (base d392d453d6, 46865 -> this change, 46942): without an
  argument buffer 829 -> 829; with one 1172 -> 1191; without robustImageAccess2 942 -> 942 and
  1368 -> 1387.
- Negative control 46864: with the mask taken out, the identity test of IDs 65,536 past the
  arrays fails (rc 100); with it, passes.
- The rt device test, ID 0x1_0005 reading element 5 (index 5 and 5 + 0x1_0000 both answer
  7 x 3 and the texel): RX 550 46854, XTX 46855, RTX 3090 46856, Iris Xe 46857, all pass.
- Harness module hashes, every compute row, the mask (8d9317bef0) against its base (d392d453d6),
  the same harness: XTX 46951 19 of 19 equal; RTX 3090 46952 19 of 19 equal.
2026-11-18 09:37:25 -08:00
Anees Iqbal b527ae9f68 rt, translator: a step above 1 on a device without supportsNonZeroFirstInstance runs from base instance 0
Vulkan's divisor needs firstInstance 0 where the device does not report supportsNonZeroFirstInstance
(VUID-vkCmdDraw-pNext-09461): lavapipe and the UHD 630 among the lab's devices. The translator
refused the step there under the identity domains, as a Metal draw may carry a base instance, so
those devices lost every draw through such a state, base instance 0 included. The WebGL divisor
stream draws 462 times through its two stepped states, every draw at base instance 0 (it calls no
baseInstance form and draws nothing indirectly).

Now, under the identity domains, fetch_as takes the divisor wherever the profile has
vertexAttributeInstanceRateDivisor and the rate is within maxVertexAttribDivisor; outside them the
step is pulled where the property is missing, as before, so the old runtime's path is unchanged.
divided() names the feature or the limit; its not-implemented arm had no caller left and is gone.
The new runtime marks such a state where the device lacks the property
(Draws::first_instance_zero) and refuses a draw through it at a base instance other than 0,
Gap::Draw { DividedBaseInstance }, before anything is recorded; a draw of no vertices or instances
still records nothing. Indirect draws are not built in the new runtime.

Tests: from_queries_divides_an_instance_step_where_the_divisor_feature_is_enabled (lavapipe and
moltenvk-m3 profiles, with and without the property: an instance-rate binding of divisor 2, both
modules L3-valid; rate 5 past a limit of 4 refused naming it). The device test
every_device_with_the_step_rates_fetches_per_instance_at_rate_2_from_the_base_instance draws from
base instance 0 on every device with the step rates (every texel the first mark) and from base
instance 1 where the property is reported (the second mark), expecting DividedBaseInstance where it
is not, and prints which path ran.

docs/REFUSALS.md regenerated (scripts/refusal-surface/refusal_surface.py): VertexStepRate has one
site. The rt README names the draw refusal on those devices; docs/API.md the identity-domain rule.
2026-11-18 07:20:24 -08:00
Anees Iqbal 264c28feef translator: a grid tile's edge test runs on every invocation, against the region's last thread, with no branch on the ragged flag 2026-11-18 06:09:03 -08:00
Anees Iqbal 428c680bdd translator: Device::kernel_observes_partition answers before any lowering
What: Device::kernel_observes_partition(kernel, inputs, budget, entries) answers what
CompiledFunction::observes_threadgroup_partition answers for the compile under the same inputs,
lowering nothing: from the specialized entry StageEntries holds (or one made there now), ordered
for the device as the compile orders it (lockstep's inserted barriers observe the partition).

Why: a runtime can then lower only the variant a creation needs: an observing kernel runs at its
own size and needs no tiles, an oblivious one runs its grid in tiles. Split from the ragged
branch, without its SpecKey::Ragged (ruled out).

Tests: engine_identity's the_partition_query_answers_what_the_compile_does: the query equals the
compile's answer for an oblivious and an observing kernel on both profiles. API table and API.md.
2026-11-18 06:06:37 -08:00
Anees Iqbal 212bba29c6 rt: Metal's constant step is a vertex-rate binding of stride 0, on every device
Under the identity domains (Device::from_queries' profile, the new runtime's), Metal's
MTLVertexStepFunctionConstant was refused as Unsupported{VertexStepRate}, needing
vertexAttributeInstanceRateDivisor and vertexAttributeInstanceRateZeroDivisor, which the floor
does not enable. The constant step needs no divisor: it is now a vertex-rate binding of stride 0,
one form, no query, every device.

Vulkan permits it. The specification's "Vertex Input Address Calculation" (28.4) gives a
vertex-rate attribute's address as bufferBindingAddress + vertexIndex * stride +
attribDesc.offset, so a stride of 0 reads the layout's first element for every vertex and every
instance, whatever the base instance: what Metal's constant step reads. A binding's stride has no
lower bound outside the portability subset: VUID-VkVertexInputBindingDescription-stride-00619
bounds it above (maxVertexInputBindingStride) and is the only other rule on it, and
VUID-vkCmdBindVertexBuffers2-pStrides-06209 names 0 among the strides a bind may set. Under the
portability subset (VUID-VkVertexInputBindingDescription-stride-04456: at least
minVertexInputBindingStrideAlignment) link refuses the stride of 0 as
Unsupported{VertexInputLayout}, as it refuses any stride the subset forbids.

Translator, under the identity domains only (lower::access::identity), so Device::new's profile
and the old runtime are unchanged:
- metal::vertex::fetch_as answers Constant with VERTEX rate, divisor 1;
- pipeline::link::vertex::binding_stride emits stride 0 for any fixed-function fetch of a
  constant-step layout, keyed on the layout's step rather than on a divisor of 0 (on Device::new's
  profile the only such fetch is the divisor-0 one, so its bindings are the same);
- link's check that an attribute the vertex function lists as alike at every vertex of a
  primitive is fetched once per instance also takes a constant step's binding, which reads one
  element at any rate.
- The per-instance refusal (rate above 1) names exactly what the profile lacks:
  vertexAttributeInstanceRateDivisor, else the maxVertexAttribDivisor the rate passes. Its old
  text, and Feature::VertexStepRate's, claimed the constant step needed the divisor; both now name
  the per-instance step alone.

Docs: docs/API.md (identity-domain vertex input), the rt README's vertex lines, REFUSALS.md
regenerated (the VertexStepRate row and its reach mark no longer name the constant step).

Tests:
- engine_identity_render from_queries_fetches_a_constant_step_at_vertex_rate_with_stride_zero:
  on lavapipe (no buffer robustness, no divisor, no supportsNonZeroFirstInstance) ima_vertex's mark
  layout at the constant step links to a VERTEX-rate binding of divisor 1 and Static(0), both
  modules L3-valid; on moltenvk-m3 (portability subset, minVertexInputBindingStrideAlignment 1) it
  is Unsupported{VertexInputLayout}. Fails without this commit (VertexStepRate on both).
- rt draw every_device_fetches_a_constant_step_attribute_for_every_vertex_and_instance: two
  instances of a triangle from vertex 1 at base instance 1, the uint mark at the constant step over
  four distinct marks: every texel holds the first mark, provoking vertex 1, and its instance (1
  above, 2 below). Points are a gap of rt's draws, so the draw is of triangles; the provoking
  vertex is vertex 1, so a vertex-rate stride other than 0 would read the second mark, and an
  instance step the second and third.
- The Device::new-path tests stay as they were: a_constant_step_links_to_a_zero_divisor_binding_of_
  zero_stride, fetch_is_fixed_function_only_when_exact,
  a_constant_step_is_a_zero_divisor_only_where_a_zero_stride_is_legal.
2026-11-18 05:41:17 -08:00
Anees Iqbal 70dffca0c2 Deep threadgroups run as one row: SpecKey::DeepThreadgroup on from_queries, rt keys it on the size
Metal allows 1024 threads along z; a device's maxComputeWorkGroupSize[2] may hold 64 (NVIDIA's),
so rt refused a kernel's threadgroup of 1x1x320 (Limit::ThreadgroupShape) and could not play a
recorded stream past its frame 216 on any NVIDIA card. One form serves every shape on every
device: a threadgroup deeper than DEEP_THREADGROUP (64) runs as one row of its threads.

Translator, on Device::from_queries' profile only (ProfileFacts::deep_threadgroups, OneRow; Device::new
keeps Axes and is byte-equal): a kernel whose workgroup is its threadgroup (LocalSizeForm::Spec,
no compute derivatives) declares the boolean SpecKey::DeepThreadgroup. Its WorkgroupSize is
(Deep ? sx*sy*sz : sx, Deep ? 1 : sy, Deep ? 1 : sz), OpSpecConstantOp selects (the WorkgroupSize
rule now takes spec-constant operations whose defaults are positive), and its position in the
threadgroup Deep ? LocalInvocationIndex unflattened over (sx, sy) : LocalInvocationId. The linear
index, workgroup and grid builtins keep their values, so group counts, regions and indirect
buffers are untouched. The binder sets it for a region deeper than 64 and checks that region as
the flattened tiers' are. MetalDeviceProperties on that profile reports the capped invocations
on every axis (1024 on every floor device) instead of the device's per-axis sizes.
SEMANTICS_VERSION 2172, ARTIFACT_FORMAT_VERSION 536.

rt: the key is a function of the variant's size (size[2] > DEEP_THREADGROUP), so it adds no
pipeline and no cache key. choose() takes no device limit: an image-only kernel's deep tile runs
whole as one row on every device (it ran whole on RADV/ANV and in tiles on NVIDIA). fits(),
ComputeLimits::max_group_size and Limit::ThreadgroupShape are deleted: every workgroup is within
the floor by construction (a const assertion). A module that neither flattens nor declares the
key is a creation gap. README: the deep form, worst-case pipeline counts, the 50-pipeline line.
REFUSALS.md regenerated; API.md; api_signatures blessed; api_surface pins DEEP_THREADGROUP.

Tests: the translator runs a barrier-exchange kernel at 1x1x320, 2x3x100, 1x4x256 (deep) and 4x4x4
on the interpreter, checks the evaluated WorkgroupSize, no key on Device::new, the binder's
setting on an NVIDIA profile, and the reported maxima; rt's choice tests drop the device limit;
the observing-kernel device test adds deep whole, ragged and indirect dispatches; the square
test adds a column 256 deep.

Verified: built and tested under the check job named in the report.
2026-11-18 04:21:18 -08:00
Anees Iqbal 0d1a32436b vertex input under the identity domains: every attribute in fixed function, no pulled form
Planner ruling 11-18 (final): fixed-function vertex input for every attribute on every device,
the form native Vulkan uses and the fastest measured on every device, one form. Nothing of the
pulled form is taken on Device::from_queries' profile. Before this, the translator's
containment rule (contain::encoding is Check::InShader without buffer robustness) moved every
[[stage_in]] attribute into the shader, a form that reads through a descriptor the identity
domains refuse, so every rt render state with a vertex descriptor was refused as
Unsupported(IdentityDomains).

Translator (metal::vertex::fetch_as, pipeline::link::vertex::resolve), under the identity domains
only (lower::access::identity), so Device::new's profile and the old runtime are unchanged:
- the containment rule no longer moves an attribute: the device bounds the fetch as it bounds
  any (no buffer robustness: a fetch outside its buffer reads what the device gives);
- an unnormalized signed-integer format (Char*, Short*, Int*) is fetched in fixed function into
  a variable declared int, VertexFetch::SignedFixedFunction (new): Vulkan's numeric-type match
  lets a SINT format feed only a signed variable, and the device sign-extends as Metal does. The
  module reads the variable's bits by OpBitcast. Elsewhere such an attribute is still pulled and
  sign-extended in the shader;
- every case that pulled is a typed refusal by what it needs, never a second fetch form.

Metal's vertex descriptor on the rt floor:
- Maps directly:
  - formats: every Metal vertex format to the Vulkan format of its layout and conversion, by the
    device's VERTEX_BUFFER format query. 8/16-bit integer formats read into float attributes go
    through USCALED/SSCALED, signed integer formats into int variables, UChar4Normalized_BGRA is
    B8G8R8A8_UNORM, the 10:10:10:2 formats are A2B10G10R10, and FloatRG11B10 is
    B10G11R11_UFLOAT_PACK32. The validation crate's profiles of RADV (780M x2, RDNA3), ANV (Iris
    Xe, UHD 770), NVIDIA (Pascal, RTX 50) and lavapipe report VERTEX_BUFFER for all of them but
    FloatRGB9E5;
  - steps: PerVertex is VERTEX rate; PerInstance at rate 1 is INSTANCE rate;
  - offsets and strides: the descriptor's, baked into the VkPipeline.
- No fixed-function equivalent on the floor, so a typed refusal:
  - PerInstance rate > 1 and Constant: Unsupported{VertexStepRate}, by query. They need
    VK_KHR_vertex_attribute_divisor's vertexAttributeInstanceRateDivisor (plus ZeroDivisor for
    Constant) and supportsNonZeroFirstInstance, which the floor does not enable, so it is
    refused on every rt device today. Its needs name the missing feature, or the
    maxVertexAttribDivisor limit;
  - a format the device does not report for VERTEX_BUFFER: Unsupported{Format} with that format
    usage, by query;
  - FloatRGB9E5: Unsupported{Format}, not implemented, by need. Of the profiles above only
    lavapipe's reports it, and its fetch answers 0 for the fourth component, where Metal and
    Vulkan give 1;
  - an offset or stride off the format's component alignment (Metal takes any byte multiple on
    Apple5+), and an offset, stride, attribute count or layout count past
    maxVertexInputAttributeOffset, maxVertexInputBindingStride, maxVertexInputAttributes or
    maxVertexInputBindings: Unsupported{VertexInputLayout}, with the limit where one is passed;
  - PerPatch and PerPatchControlPoint: Unsupported{Tessellation}, as before.

rt: RenderPipelineKind::StepRate is deleted: the translator's VertexStepRate refusal comes first
on every rt device, so no pipeline states a divisor. README: the vertex input bullets, their
refusals, and the known gap that a vertex fetch outside its buffer returns what the device gives.
docs/API.md: the identity domains' vertex input. REFUSALS.md regenerated, with reach marks for the
two new features (VertexStepRate app, VertexInputLayout rare); api_signatures blessed.

Tests:
- engine_identity_render from_queries_fetches_every_attribute_in_fixed_function (lavapipe and
  moltenvk-m3 profiles with buffer robustness and the divisor withheld): ima_vertex's float2
  and short attributes are R32G32_SFLOAT and R16_SINT, nothing pulled, L3-valid; a rate-2 layout
  is VertexStepRate needing vertexAttributeInstanceRateDivisor. It fails without this commit (the
  attributes were pulled, then refused as IdentityDomains);
- rt draw every_device_fetches_a_signed_attribute_in_fixed_function: a short of -2 reaches the
  fragment's uint output as 0xFFFFFFFE on every texel; a rate-2 layout is refused as
  VertexStepRate. The existing stage-in test (vertex buffer and set_vertex_bytes) now makes its
  pipeline.

Verified: the next lint job and the device legs on every device.
2026-11-18 03:13:48 -08:00
Anees Iqbal 9bec8a977e rt: a dispatch that reaches a buffer bound off its argument's alignment is refused
The planner ruled that the bind-offset mask becomes a typed refusal. The binder pushed a bound
buffer's address, its gpuAddress plus the offset, rounded down to the alignment the kernel takes
it to have (FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), where Metal's
API validation refuses the bind offset ("must be a multiple of 4 but was set to 2" for a uint *
argument, probe vector_access_placement.m in the conformance crate). Plain Metal runs such a
dispatch at addresses of its own: an M3 Max reaches each element at its address rounded down to
the smaller of its alignment and 4. That is not the rounding the binder did for 8- and 16-byte
arguments.

The dispatch now refuses it with Refusal::BufferOffsetAlignment { index, offset, alignment }
before it records or keeps anything. check_alignment runs after the threadgroup size check and
before a kernel without effects returns, so both direct and indirect dispatches take it.
fill_parameters pushes each address as it is. A set_bytes copy sits at a multiple of 16 in the
ring, which every mask divides, so it is never refused.

Docs:
- docs/API.md: the identity-domain paragraph and the section 10 entry (renamed: "A dispatch that
  reaches a buffer bound off its argument's alignment is refused"); no case names its slug.
- RuntimeFact::AddressAlignment's doc and the mechanism comment.
- The rt README paragraph and FieldValue::BufferAddress's doc.
- docs/REFUSALS.md regenerated (44 rt refusals); api_signatures.tsv gains the variant's row.

Tests (device, under --cfg m2v_gpu or m2v_cpu_icd):
- every_device_refuses_a_bound_address_off_its_alignment (was ..._rounds_a_bound_address_down_...):
  at alignments 2, 4, 8 and 16, each of 17 binds 1 to 15 bytes past a multiple of 16 that the
  alignment does not divide is refused and leaves the buffer unchanged, and the same buffer bound
  at 48 runs. Without the check every one of the 17 dispatches returns Ok.
- an_argument_bound_off_its_alignment_is_refused (was ..._runs_at_the_address_rounded_down):
  the translated vector_word_phases kernels with one argument off its alignment are refused,
  naming the index, offset and alignment, and the command buffer completes with every buffer
  unchanged.
2026-11-18 00:14:00 -08:00
Anees Iqbal b0e68fd826 Delete the folded-tile pipeline: a kernel that is not image-only runs every grid in the remap's tiles
The planner's ruling makes the rule two lines. An image-only kernel that does not observe its
threadgroup partition is declared: 16x16x1 on a grid one deep, the grid's tile (grid_tile) on a
deeper one, at MultiRegion 0 with the extent test. Every other such kernel runs today's remap:
256-lane workgroups, each one tile the region carries. The fold no longer serves buffer-touching
kernels. Image-only kernels used it only where the grid's tile is past the device's
maxComputeWorkGroupSize, and that class is too small to keep a form for, so those dispatches take
the remap too.

The census (replay's job m3-max-44582, both recorded streams): image-only non-observer
dispatches whose tile is past a depth of 64 (NVIDIA's, the floor's limit) are 6 dispatches,
1,760 threads in each stream, one (spec, tile) pair of tile 1x1x256. That is 0.0004% of the
image-only non-observer threads in one stream and 0.0033% in the other. No tile is past a side of
1,024.

Deleted: SpecKey::FoldedTile and the select that took it in place of the region's tile
(lower::dispatch), its binder entry, codec tag, signature row and API guide sentence; rt's
Variant::fold, Constant::FoldedTile, Choice::fold and Last::fold. The cache versions stay at this
branch's single bump (SEMANTICS_VERSION 2171, ARTIFACT_FORMAT_VERSION 535, now for
KernelFacts::image_only and the edge test under MultiRegion 0 alone). An image-only kernel's
pipeline per tile stays: its workgroup is the tile, so a deeper grid's first dispatch at a tile
makes it, and waits once, as the square device test's two-deep dispatch checks.

Verified: cargo fmt; docs/REFUSALS.md regenerated (unchanged). The dispatch-choice tests pin a
tiling kernel's grids of every depth in the remap's tiles, and a 1,024-deep column in them past
a depth of 64. The translator's engine test runs the edge kernel at MultiRegion 0 in 16x16x1
workgroups and at the grid's tile.
2026-11-17 23:13:20 -08:00
Anees Iqbal 45b27a7623 WIP square workgroups: docs, refusal surface, device test 2026-11-17 23:13:19 -08:00
Anees Iqbal f1c73d60bc A dispatch of a kernel that writes no memory records nothing
The translator states on a pipeline's interface whether some stage writes memory another
invocation or a later command can read (PipelineInterface::writes_memory, the union of the
stages' StageInterface::writes_memory: a store to a buffer or through a device address, a
texture write or an atomic update, in the entry or any function it calls; the
ExecutionStatus words are the product's and do not count). The cache's artifact format and
semantics versions move with the new field.

rt reads it into the compute state's interface. A dispatch of a kernel without it, direct
or indirect, is checked as Metal checks it and then records nothing: no bind, no push, no
vkCmdDispatch, and the indirect buffer is not kept or read. Metrics gains
dispatches_without_effects, which counts them. Such a kernel has no effect a program can
observe, so the only difference is less GPU and encode time than Metal's.

Tests: the translator's a_compute_pipeline_states_whether_its_kernel_writes_memory (a kernel
that returns at once, one that only reads, one that writes only its own thread's array: no;
a store behind a branch, a noinline callee's store: yes, on the function and the linked
pipeline, each validated), and rt's
every_device_records_nothing_for_a_dispatch_of_a_kernel_without_effects (a direct, an
indirect and an unbound dispatch of a kernel the interface says writes nothing leave the
buffer unchanged and count three).
2026-11-17 20:35:35 -08:00