Commit Graph
1494 Commits
Author SHA1 Message Date
Anees Iqbal 4ac52bf082 rt: a kernel's threadgroup memory arguments come from its length constants
The device legs of the tile (m3-max-41638/41639/41640) refused every
observing kernel with Gap::KernelInput: the runtime took a kernel's
[[threadgroup(n)]] arguments from PipelineInterface::threadgroup, which the
translator leaves empty, so a TgLength specialization found no argument. The
arguments are now the TgLength constants the module specializes on, by
their index.

With threadgroup memory reaching a pipeline, a dispatch checks it: the
kernel's static part (and a predicated walk's 4-byte vote word,
RuntimeFact::PredicationVote, now accepted) plus each length set rounded up
to 16 bytes must be within maxComputeSharedMemorySize, else the new
Limit::ThreadgroupMemory, Metal's maxThreadgroupMemoryLength counterpart.

The precise kernel's test found on the 780M and the XTX one word apart
between a tile and the app's shape: a NaN/NaN division (0xffb86e83 /
0x7f9fc206) answers the first operand's payload in one pipeline and the
second's in the other. The state carries NativeNanEncoding, so two NaNs are
alike there; every other word must be equal.

README: the threadgroup memory limit, and NVIDIA 615.71.09's sign-extended
narrow clamped sum on GA10x (the planner's wording). REFUSALS.md and the API
signatures regenerated.
2026-11-17 10:46:51 -08:00
Anees Iqbal 2930583b47 rt: the cache directory keeps lowered kernels and pipeline data
DeviceOptions::pipeline_cache_dir names a directory a device keeps two
things in, for compute pipeline states. translations/ holds each lowering,
named by its FunctionCompileKey (the kernel's AIR, entry, constants and linked
functions, its lowering inputs, the profile fingerprint and the translator's
semantics version), in the translator's self-checking encoding; a state reads
a lowering there in place of lowering (Metrics::translations_loaded beside
the new Metrics::translations), and a partial-threadgroups variant the
translator refused is kept as a marker so it is not tried again. The files
take at most 256 MiB, least recently used evicted first. pipelines-<uuid>
holds the VkPipelineCache data, framed with a length and a checksum since
the initial data must be exactly what vkGetPipelineCacheData returned; every
VkPipeline is made through the device's cache, the reaper writes the data 10
seconds after a VkPipeline was made at most once per 10 seconds, and the
device's end writes it a last time. Writes go through a temporary file
renamed over the name; a file that does not check is a miss and nothing the
cache does fails a call.

The tile commit's README, refusal table and API signatures follow here:
direct dispatches past maxComputeWorkGroupCount are split, and
Gap::PartialThreadgroups names the variant refusals by the deciding queries.

Tests: a store filled past its cap keeps the most recently used files within
it, stores on one directory share files, and pipeline data cut short or
flipped is a miss (host); a second device on the same directory lowers
nothing at creation, reading all three lowerings, and the pipeline data file
is there (device). Not yet compiled: the lint follows.
2026-11-17 10:46:51 -08:00
Anees Iqbal 37cc7ac829 matrix: harness counts compare under one harness; six old-runtime lavapipe flakes parked
The 7fa6662170 run failed every GPU leg on harness-old/authored/pipelines_created 8 -> 10. That
was the harness itself gaining two workloads (eddc9b80bf), not the runtime. The harness's counts
sum over its workloads, so like its times they now compare only with a base whose harness tree is
the same; the other records still compare.

Its lavapipe leg failed on one old-runtime test that passed in the runs around it, as a different
one did in most runs today (cfa389aa9b, c944d63548, bfe63b5097, 73e0af4b66), the old runtime's
code unchanged between them. The old runtime is frozen and its regressions parked, so the six met
so far join PARKED_TESTS with the run each failed at; they stay named on the leg's line.

Tests: scripts/matrix/test_results.py, 17 pass (the new one: a harness count compares under the
same harness and not under a changed one, while a runtime count compares in both).
2026-11-17 10:45:01 -08:00
Anees Iqbal a17eb26a6b matrix: the old path moving fails a leg unless its fix says so
The old runtime is frozen until the cutover: the translator's output through Device::new must not
move. Today it moved three times through the shared path (half outputs widened, the half pair
workarounds dropped, the stage-size rows dropped) and nothing caught it, because the golden table's
failure read as "needs a bless" whatever moved.

The golden table compiles through Device::new. Its test's stale message now counts each kind
(new, gone, under a changed fixture source, under a changed profile fingerprint), from one tested
function. The matrix reads the counts: a cell changed under an unchanged key, or one under a
changed profile fingerprint, fails the leg with OLD PATH MOVED, unless a commit since the table's
last bless says "old-runtime regression fix" (the fix of such a move, or a fix the old-runtime
lane lands). New, gone and re-keyed fixture rows still only need a bless.

Tests: scripts/matrix/test_results.py (16 pass; the new one feeds both panics as nextest prints
them, a new-rows-only failure and a passing run, with and without the phrase);
golden_hashes::only_a_cell_changed_under_its_key_needs_a_bump checks the counts' text.
2026-11-17 10:37:10 -08:00
Anees Iqbal 576a7348bc translator: one stage bound on every device; the two stage-size workarounds go
A module whose entry weighs more than COMPILED_STAGE_WEIGHT (99,109, the
heaviest stage measured to compile within host-sized memory, on ANV) is
now handed to no driver, whatever its identity. A kernel that emulated
its simdgroups only in place of the widest mode's pin (the subgroup size
range decides it) is planned again keeping the pin, as before; every
other module past the bound is refused with Feature::StageSize and a new
Needs::StageBound, its symbol naming the weight and the bound. The
refusal is permanent for the input on the device (its plan decides the
weight), so it is not NotImplemented; validation reads it as the
translator's own gap.

DriverWorkaround::SerializedStageWrapsLargeModules and
CompilerMemoryGrowsWithStageSize go, with ANV's identity entries for
them and the serialized bound (786,432), which the single bound sits
far below. Why: the workaround ladder takes one form for every device,
the slowest compiler's; a device whose compiler would take a heavier
stage is refused it, recorded in FAST-PATHS' known gaps.

Measured before this change, with a scratch build that applied the
bounds and the re-plan to every profile: the corpus on the Iris Xe's
description without its identity refused nothing (largest planned
module 91,399, job m3-max-41496), and RADV and NVIDIA nothing either;
without maximal reconvergence 12 rows were refused, 6 distinct
simdgroup-matrix modules of 198 to 285 products whose lockstep pairs
force emulated simdgroups (jobs m3-max-41474, m3-max-41523).

The owned fixture stage_bound/stage_bound_matrix (512 simdgroup matrix
products beside a lockstep pair in divergent flow, our own MSL) has
their structure: on the Iris Xe its emulated module weighs 123,307 and
its pinned one 37,646; without maximal reconvergence it is refused at
123,308 (scratch weighing, job m3-max-41602). The new test
the_stage_bound_fixture_keeps_the_pin_or_is_refused asserts both paths
and that the re-planned kernel is under the bound.

The old runtime's heap-trim test loses its long chain, now refused on
every device; it asks for a trim where the making left more than the
floor free (NVIDIA's compile never does under the bound, 189 MB at
most measured). SEMANTICS_VERSION 2150; REFUSALS.md regenerated; the
API table loses the two variants and gains Needs::StageBound.
2026-11-17 10:24:59 -08:00
Anees Iqbal 9cb90de8cc replay: a group that held a Private-range split reports its executed counts apart
Leaving out what the runtime counted while the player's own calls ran
did not keep the split out of the executed counts: the old runtime
records the barriers a split needs at the program's next command and at
the commit. Device legs at 0b882f337c (jobs m3-max-41605, m3-max-41608)
counted 8 barriers on the RX 7900 XTX, RX 550, 780M and lavapipe and 10
on the RTX 2080 for the test stream, against 5 for the same stream
without the records. A background pipeline that landed inside an
uncounted window also left pipelines_made out (RX 550, 780M,
lavapipe).

The runtime's work for a split cannot be told apart from the program's,
so a group whose command buffers held a split now reports no executed
counts. Those counts are added up apart, in Report::split_executed and
on the `split N executed COUNTS` line, and the total leaves them out
with the readbacks. The player's own calls around the dispatch are no
longer measured on their own.
2026-11-17 10:12:59 -08:00
Anees Iqbal 4862a521e0 replay: the player's encoder splits are in no count; the report counts them
The encoders, blits, buffer and fence the player adds around a dispatch
an m2v.privateBytes record names are its own work: what the runtime
counts while those calls run is left out of the group and total
executed counts, as its readbacks are, and the report counts the splits
(split N). The comparison takes its completed snapshots from a queue.
2026-11-17 09:58:05 -08:00
Anees Iqbal 68789f62a5 replay: the player puts a Private range's bytes in before its dispatch and compares them after
The host records m2v.privateBytes for each dispatch of a pipeline with
linked functions: each bound Private buffer range's bytes before and
after the dispatch, which no CPU can read and no other record holds.
The player played these records as nothing.

It now reads the stream ahead once (a second reader of the same
segments) and indexes the records by the dispatch each names, since
they come after it, at the command buffer's completion. At that
dispatch it puts each range's bytes before (relocated as a write's
are) in a Shared buffer of its own, ends the guest's compute encoder,
copies them into the ranges in a blit encoder, makes the compute
encoder again by the call that made it with every set.../use... call
the program made on it, dispatches, then ends it, copies the ranges
out in a second blit encoder and makes it again. A fence of the
player's own orders each piece after the one before, so untracked
resources are ordered too. Once the command buffer completed it reads
the bytes after back, counts the 4-byte words of each range that
differ from the recording's, and reports a `private ID DISPATCH
LOCATION+LENGTH match|differs N/WORDS` line; the play goes on.

The readback helper check() and the comparison share now shifts the
group baseline by the readback's own growth rather than setting it to
the counters after it, so work recorded since the last group stays in
the next group's executed counts.

REPLAY-STREAM.md sections 8 and 10 state the read-ahead, the split,
the report line and what the counts include.
2026-11-17 09:58:05 -08:00
Anees Iqbal 31c1161940 rt: SIMD groups at Metal's width, and robustImageAccess, at the floor
The floor requires Vulkan 1.3's subgroupSizeControl, computeFullSubgroups and
robustImageAccess, enabled on every device; the translator's profile takes
them through the enable set. Where a device lists compute in
requiredSubgroupSizeStages with 32 between its sizes, the translator pins a
kernel's SIMD groups to subgroups of 32 (the Direct tier); the compute
pipeline state now takes such a kernel: each VkPipeline chains
VkPipelineShaderStageRequiredSubgroupSizeCreateInfo where the tier pins a size
(the translator pins only a stage the device lists, VUID-...-pNext-02755) and
carries the stage's REQUIRE_FULL_SUBGROUPS. "A stage that pins a subgroup
size" leaves Gap::KernelInput. A flattened tier's LocalSizeConstraint is
supplied: a dispatch whose threadgroup is not whole SIMD groups is refused at
the dispatch as the new Gap::PartialSimdgroups, since the emulated-SIMD-group
variant is not built. With robustImageAccess on, the translator drops its
image write and atomic guards on every device; robustImageAccess2,
robustBufferAccess, robustBufferAccess2 and nullDescriptor stay off.

Tests: the floor names each new missing feature; the translator's enable set
holds robustImageAccess and none of a reported geometryShader,
samplerMirrorClampToEdge or VK_EXT_robustness2 (host); every device's
translator profile has robustImageAccess and none of robustImageAccess2,
robustBufferAccess, robustBufferAccess2, nullDescriptor (device); and
simd_float_products runs Direct, pinned at 32, wherever compute can pin 32,
refusing a 16-thread threadgroup and answering Metal's products (device).

REFUSALS.md and the API signatures regenerated. Verified: cargo fmt; the lint
and the device legs follow.
2026-11-17 09:55:14 -08:00
Anees Iqbal fa52012831 identity: texture slots are the set-1 elements their pushed resource IDs name
Under the identity domains a kernel's texture slots now lower. A slot's
gpuResourceID is pushed as its PushField::SlotGuestBase (the index in the
low word, the word in the high one). Its texture is the element at that
index of one of set 1's two fixed arrays: binding 0, SAMPLED_IMAGE x
65,536, and binding 1, STORAGE_IMAGE x 4,096. Each is partially bound,
updated after binding and while unused elements are pending, and seen by
every stage, with the same layout for every pipeline
(BindingSource::IdentityArray). Each image class the kernel declares
(shape, numeric type and depth comparison, sampled, or storage without a
format) is a variable of its descriptor type's binding. The slot binds no
descriptor and declares no specialization constant:
- is_null_texture answers whether the index is 0. Nil needs nothing
  else in the shader, since element 0 of each array is a null descriptor
  (the device test of ba4454b05b).
- A read the shader checks itself takes Metal's out-of-bounds alpha of 1
  from bit 12 of the word (TextureWord::OUT_OF_BOUNDS_ALPHA_ONE).
- The ResourcePresence and OutOfBoundsAlpha facts are not stated there.

No binder chooses a variant under identity, so a slot reads whatever
texture its ID names through the plain form:
- the variant facts (cross-class reads, planes read in place, texel rows,
  texture-buffer parts) are not stated;
- a float or half read takes the device's sRGB decode with
  PrecisionNote::SrgbTexelDecode (VkProperty::MetalSampler on MoltenVK),
  as a heap element's does, with no SrgbTexture twin;
- no texture is sparse (the consumer refuses one): no write-dropping
  SparseTexture constant and no ConstantLanes;
- a storage slot is formatless with no StorageTextureFormat fact. Where
  the device cannot access it without a format, the slot is refused as
  Unsupported{IdentityDomains} instead of asking for an input no consumer
  gives there.

Admission stays typed. Under identity, a function is refused as
Unsupported{IdentityDomains}, not implemented, if it:
- samples (any sampler plan; Metal's own sampler as a requirement is
  allowed);
- reaches textures through argument buffers (any heap group);
- declares a slot with no identity class: texture buffers, level views,
  cube-as-array, planes, extended range, RGBX, ulong, or a storage
  image with a format;
- uses a slot whose state comes from anything but its ID: border texels,
  sparse residency arms, a half conversion by the bound format, swizzles,
  offset bases;
- carries a fact naming such state (identity_unsourced).
That keeps the arm64-only forms (two-plane, extended range, sRGB twins)
out of the identity domains, as the x86 scope wants. The old binder
refuses an identity array as an internal error, since the consumer
writes those arrays.

SEMANTICS_VERSION 2150 (identity output changes), ARTIFACT_FORMAT_VERSION
529 (BindingSource gains IdentityArray). docs/RESOURCE-ID.md says what the
arrays are and what the shader reads of an ID. docs/API.md says what the
identity domains lower. The refusal surface and the API signatures are
regenerated. The blessed table also gains
metal2vulkan-rt::PrecisionNote::CappedLodBias, a variant development's
table lacked.

Verified, on development cfa389aa9b (check commit 564d131163, same tree):
- msi, job m3-max-41519: clippy -p metal2vulkan --all-targets
  --all-features -D warnings, rustdoc -D warnings, and nextest of
  metal2vulkan's whole suite: 3672 tests run, 3672 passed, 20 skipped.
- msi, job m3-max-41520: clippy of metal2vulkan under --cfg m2v_gpu and
  --cfg m2v_cpu_icd, both clean.
- The new test, texture_slots_are_the_set_1_elements_their_pushed_resource_ids_name,
  runs on lavapipe, moltenvk-m3, and moltenvk-m3 without
  robustImageAccess2. Its words come from tests/resource_words.tsv rows
  70 and 10, checked against TextureWord::of. It checks the fixed set-1
  layout and that the pushed fields are exactly the buffer, the three
  texture IDs and the region. On the interpreter, with the source at
  sampled element 3 and the destination at storage element 2, it checks
  the reads, the writes, the width and is_null_texture both ways (index
  0 and index 1). On moltenvk-m3 without robustImageAccess2, where the
  shader checks the read, the source image traps any access outside it
  and the out-of-bounds alpha comes from bit 12 of the word: 1.0 for
  R8Unorm, 0.0 for RGBA8Unorm. On the other two profiles the device's
  robust texel answers.
- The same change on the earlier base 9a3b6587b2 (jobs m3-max-41478 and
  41479): 3670 of 3670, clippy clean in all three configurations.
2026-11-17 09:51:53 -08:00
Anees Iqbal 1ceaea8eec replay: the player plays m2v.privateBytes records as nothing
The host now records m2v.privateBytes: a Private buffer range's bytes
before and after one dispatch of a pipeline with linked functions,
written at the command buffer's completion (so after the dispatch,
possibly after the buffer's release), with blobs in the blob directory
alone. The player sent the unknown selector to the backend, which
refused it on a buffer receiver and stopped the play. It now joins the
records the player plays none of; REPLAY-STREAM.md section 8 states the
record's receiver, arguments and order.

Verified: private_bytes_records_play_nothing, a synthetic stream with
the record on a released buffer and absent blobs, plays to the end
with no backend call for it.
2026-11-17 09:46:22 -08:00
Anees Iqbal 07e62aa306 translator: a controlled half pair is noted on every device; the two half workarounds go
What: a half rounded through the device's conversion and its widening under the 16-bit float
controls (QuantizeForm::Controlled) now records PrecisionNote::NativeHalfConversion on every
device, as a static note of the operation. Every profile with shaderFloat16 and those controls
takes that form, NVIDIA's included. DriverWorkaround::HalfConversionPairFolded (NVIDIA, identity)
and DriverWorkaround::HalfConversionFusedWithArithmetic (RADV, identity) are deleted, with
narrow::rounds_arithmetic, which only the second read.

Why: rule 2 of the owner's rules (one path for every device, no identity-keyed branch) and the
planner's ruling on these two rows of the workaround ladder. The pair is Metal's half(float) by
the Vulkan spec, but a driver's compiler may fold it (NVIDIA's) or fuse the float operation into
the narrowing (RADV's). Recording the note statically on every device covers both drivers with no
identity check, and it never refuses. NVIDIA's modules move from the Converted form to the
Controlled one (NoContraction on the pair, the entry declaring the 16-bit modes), so its golden
cells move. ANV's and RADV's modules gain only the note, which is not hashed. SEMANTICS_VERSION
goes to 2149.

Tests: engine_native_half, device::tests::profile (half_rounding_follows_the_queries_alone replaces
the two identity tests), engine_float_call_notes, and the native_maths and half_conversions
lanes, updated to expect the note on every controlled profile. Docs: API.md's
NativeHalfConversion entry and HOWTO.md. api_signatures.tsv loses the two variants, and
REFUSALS.md is regenerated unchanged.
2026-11-17 09:45:26 -08:00
Anees Iqbal 35fbfb4f2e matrix: the old runtime's time outliers are parked like its gauges
The UHD 630's harness-old/frame time swung to 1.58x its base at a68d520bee and 1.47x at
9af29fbb20, with no change to the old runtime between them; the owner parked the old runtime's
regressions until the cutover deletes it. PARKED_GAUGES becomes PARKED_RECORDS: a key under
one of its prefixes has its gauge flatness and its cross-GPU time outlier named on the leg's
line as parked, failing no leg. A gauge's @drop still fails, and every rt time still fails as
an outlier.

Verified: scripts/matrix/test_results.py, 15 tests pass, one new (a parked time outlier is
named and fails no leg).
2026-11-17 09:44:26 -08:00
Anees Iqbal ac4b2370f5 rt: the consumer names the core Vulkan features its own work needs
DeviceOptions::features takes ConsumerFeature values (SamplerYcbcrConversion
for now). Device::new enables each one the device reports, once, in the
consumer's order, and Device::features lists those enabled, so the consumer
can refuse its own path. The runtime's own work and the translator read only
the floor's features. No Metal counterpart.

The floor test's device creation chains the maximal-reconvergence and
subgroup-uniform-control-flow structures where their extensions are listed,
as Device::new does (the device cfgs failed to compile without the fields).
The consumer-extensions device test also expects the optional extensions the
device lists, and asks for the feature twice.

REFUSALS.md takes the renamed site of VulkanVersion (derive.rs derived).
API signatures blessed.

Verified: cargo fmt. Lint and device legs follow.
2026-11-17 09:21:08 -08:00
Anees Iqbal 6e08f5aaef metal2vulkan: PrecisionNote::DeviceReconvergence, a stage's implementation-defined reconvergence as a static note
A stage whose reconvergence is ImplementationDefined (a tangled instruction in
its entry on a device without maximal reconvergence) records
PrecisionNote::DeviceReconvergence, static per stage and as coarse as the field.
metal2vulkan-rt forwards it through ComputePipelineState::precision_notes and
adds none of its own; metal2vulkan-runtime announces its note kind beside its
existing ImplementationDefinedReconvergence kind. The note is in API.md's
degrade-notice catalogue, the fast-paths ledger's Elsewhere class, the cache
codec (ARTIFACT_FORMAT_VERSION 528) and validation's Unbounded allowance.

SEMANTICS_VERSION 2149: a stage's notes change on devices without maximal
reconvergence; the golden tables are re-blessed on development.

Tests: engine_simd reconvergence_follows_the_profile and the uniform-control-flow
case assert the note exactly where the field is ImplementationDefined.
2026-11-17 09:21:08 -08:00
Anees Iqbal 136fb66907 metal2vulkan-rt: map the identity ABI's parameter block and grid region; translated-kernel device test
Identity steps 2 and 3 are on development: ArgumentTableAddress is the ring
block's address in the window, fields placed in the ArgumentTable go to the
block, and every dispatch reads Metal's grid from its pushed region (a zero
grid for an indirect dispatch), with no MultiRegion constant to specialize.
The README gains the pipeline states' section and its known gaps; REFUSALS.md
and the API signature table are regenerated.
2026-11-17 09:20:31 -08:00
Anees Iqbal 5617449350 metal2vulkan-rt: the encoder's refusals in REFUSALS.md and its API in the surface table
Generated by refusal_surface.py and signatures.py --bless.

Verified: the generators ran clean (0 variants without a reach mark or a
basis).
2026-11-17 09:20:30 -08:00
Anees Iqbal 001cc5ae8a matrix: a lint leg runs the gate's fmt check, clippy in three configurations and Rustdoc
The matrix ran the suites but none of the gate's lints, so a public doc linking private items
(eaac55bd36) left the workspace Rustdoc failing on development with every leg green. The lint
leg runs cargo fmt --all --check, clippy -D warnings plain, under --cfg m2v_gpu and under
--cfg m2v_cpu_icd, and Rustdoc -D warnings, each reported as its own suite, in a workspace of
its own on the builder beside its other jobs, so it adds no wall time to the run.

Verified: the script parses; the first run is the matrix on this commit.
2026-11-17 09:18:51 -08:00
Anees Iqbal 159154d5a9 PrecisionNote::CappedLodBias: a sampler state's capped or withheld lodBias carries a static note
Where the presented GPU adds a sampler descriptor's lodBias to every sample's level
(SamplerUse::lod_bias), vk_sampler hands the device device_lod_bias's answer: past the device's
maxSamplerLodBias it adds that limit, and a NaN, or any bias where a portability subset withholds
samplerMipLodBias, adds none. Only the old runtime said so (Degradation::CappedLodBias, announced as
it makes the state); the translator's vocabulary had no note for it, so a runtime built on the
translator alone could not report it. The lab's own reports put the limit at 15 on the 2080 and
both 3090s and 16 on the other target devices.

The translator now states it as PrecisionNote::CappedLodBias, which DeviceLodBias::note gives for
every variant but Exact. It is fixed by the state's bias and the device's limit; no pipeline stage
records it, so translation output does not change (no SEMANTICS_VERSION bump).

Classed where every note is: the artifact codec, tests::fast_paths (Elsewhere: docs/API.md section
9 states it), validation's comparison allowance (unbounded). The old runtime's degradations! macro
maps the note to its existing runtime kind CappedLodBias with one hand-written from_precision_note
arm. That change is mechanical, with no behaviour change: the kind keeps its code, category, cost
and announcement site, and its precision_note() stays None, so the site tests' rule (a kind with a
note is a stage's) still holds. docs/API.md: section 9's intro, the capped-lod-bias catalogue entry
and the accepted difference name the note. api_signatures.tsv re-blessed; refusal_surface.py
--check passes, REFUSALS unchanged.

Test: metal::sampler::tests::the_device_lod_bias_carries_its_note_where_it_is_not_the_bias, over
every committed device: no note for 0, -0 or a bias within the limit, the note past it, at the
infinities and for a NaN, and for every nonzero bias where samplerMipLodBias is withheld.

Verified: cargo fmt; signatures.py --bless; refusal_surface.py --check. Lints and tests follow as
potluck jobs.
2026-11-17 09:14:26 -08:00
Anees Iqbal eaac55bd36 replay: the recorder's commitPart cut, object 0, copied contents and gpuResourceID
The recorder now writes four things a player must read:

- m2v.commitPart answers `cut`: "Cut" where the host committed the command
  buffer as a part, "Fails" or {Whole: reason} where it committed nothing. The
  player commits only at "Cut", or where the answer is absent, as before.
- The pass descriptor's setters write object 0 for an object property set to
  nil (visibilityResultBuffer, rasterizationRateMap, texture, resolveTexture);
  nil still means left as it was. The old runtime's backend clears the
  property at object 0.
- newBufferWithDescriptor: of a buffer copied from host memory carries its
  starting bytes as the descriptor's `contents` (a blob or inline bytes). The
  player makes the buffer with the contents nil, then puts the bytes at its
  first byte as a write's: relocated where it answered a gpuAddress, counted
  in written_bytes.
- `gpuResourceID` records carry the ID the program saw of a texture, sampler,
  depth-stencil state, pipeline, ICB or function table. The player compares
  each object's first answer with its runtime's ID (Backend::resource_id) and
  reports each object where they differ as `id #OBJ RECORDED PLAYED`.

docs/REPLAY-STREAM.md carries the spellings. Each addition has a synthetic
stream test on the player's mock backend, and the old runtime's backend has
two device tests (an attachment set to nil left untouched by its pass; a
copied buffer reading back its contents, with a placed texture's ID matching
and an unplaced one's reported).
2026-11-17 08:34:44 -08:00
Anees Iqbal a68d520bee matrix: times compare under one harness; the old runtime's met failures are parked
At 8a07d62b97 six GPU legs failed on time and one on a gauge, none of them
the new runtime's (rt 38/38 on every leg):

- The harness landed its settled warm-up and steadiest-window time between
  the base (b216007f0a) and this run, so most GPUs' times fell to about 0.69x
  and the ones that fell less read as outliers. Times now compare only when
  the base's crates/metal2vulkan-harness tree is the commit's; a harness
  change sets the base for the next run.
- harness-old's memory_blocks gauge went 3 -> 2 between iterations 100 and
  200 on the Iris and the UHD 630: the old runtime frees idle blocks when it
  will. lavapipe failed two old-runtime tests: cross_queue_shadows' GPU
  hazard (its spin ended before the host's write on a loaded host, twice
  now) and compute_inherited_buffers' barrier count (2 against 3, which
  moves with the old runtime's background pipeline builds).

The old runtime takes no fixes until the cutover, so these are parked:
PARKED_TESTS and PARKED_GAUGES in results.py, each with its reason. A parked
failure is named on the leg's line and in the note's `parked` field and
fails no leg; a parked gauge's @drop still fails. docs/VALIDATION.md says
both rules.

Verified: the rule tests (14, two new: a suite whose failures are all
parked passes and names them, an unparked one beside it still fails; a
parked gauge may move between iterations but must reach zero at drop);
the harness trees differ between b216007f0a and 8a07d62b97 (038009feec
against d25ef7d25d) and match between 8a07d62b97 and the tip.
2026-11-17 08:33:59 -08:00
Anees Iqbal 50c5bd0fe1 identity: every dispatch reads Metal's grid from its pushed region
Under the identity domains a kernel that reads a grid builtin no longer declares the MultiRegion
specialization constant. It tells a region from an indirect dispatch by the region's grid
(RegionSelect::Grid in lower::dispatch):
- Every dispatch the host knows (dispatchThreads, dispatchThreadgroups, and each piece of a split
  of either) pushes DispatchRegion with Metal's threads_per_grid in region[1].xyz and its piece's
  first threadgroup in region[0].xyz. So the pieces of a split read Metal's whole grid, and every
  compute pipeline takes the base offset.
- An indirect dispatch pushes a zero grid. Its kernel then takes the single-region form, its grid
  NumWorkgroups times L, which needs its workgroup size to be Metal's threadgroup size.
- One pipeline runs every dispatch of a threadgroup size, with no constant to specialize.

A flat variant (LoweringInputs::flat_grid), bound as any other kernel, reads its grid from the same
pushed field rather than from a record at ReplayRegionAddress (plan_replay, EmitCx::push_field).
The consumer runs non-observing kernels in a fixed shape with it, and invocations past the grid
return before the body. A replay or folded variant keeps its record and stays refused under the
identity domains.

The runtime lane takes this ABI as agreed: the zero grid marks an indirect dispatch, which runs
the per-size pipeline.

SEMANTICS_VERSION 2148: modules under the identity domains change.

Tests (src/tests/engine_identity.rs), on lavapipe and moltenvk-m3:
- every_dispatch_reads_metals_grid_from_its_pushed_region. A generated kernel reads
  thread_position_in_grid, threads_per_grid and threadgroups_per_grid. It declares no MultiRegion
  constant and passes L3. On the CPU interpreter, with L = (4, 2, 1) over an 8x6 grid, it stores
  the same answer at every position in three forms: one whole dispatch, a split into two pieces at
  region base (0, 1, 0), and an indirect dispatch with a zero grid.
- a_flat_variant_reads_its_grid_from_its_pushed_region. Its flat variant reads a 7x5 grid from
  the pushed region in three workgroups of 16. The 13 invocations past the grid store nothing.
- The buffer-kernel test runs once, with its region pushed.

Verified:
- m3-max-41225 (msi, check commit 7fe9bc780c: this tree's metal2vulkan files, which equal those
  here on 1bb5fe5bf8): clippy -p metal2vulkan --all-targets --all-features, rustdoc -D warnings,
  and nextest -p metal2vulkan --all-features, exit 0 (every test passed; the count's log was
  lost to the scratch path two of the lane's jobs shared, since fixed).
- m3-max-41226 (msi, 7fe9bc780c): clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
2026-11-17 08:26:40 -08:00
Anees Iqbal 227b118bd9 identity: fields past the push window go to a parameter block at a pushed address
Under the identity domains the stage's ArgumentTable is not a uniform buffer. It is a parameter
block in memory that the consumer writes for the call, and its device address is the new push
field PushField::ArgumentTableAddress, a u64.

How it works:
- The placement is the one the translator already makes. Fields fill the 128-byte window in kind
  order; the first that does not fit, and every field after it, go to the block at
  PushLoc::ArgumentTable offsets, and argument_table_size is the block's size.
- ArgumentTableAddress sorts first among the kinds. A kernel whose fields spill inserts it, so the
  window always holds it, at offset 0 under the identity domains, where RootTableAddress never
  appears.
- The function reads each spilled field through the address (table::read_block): a
  PhysicalStorageBuffer load at the field's offset, aligned to its shape.
- No descriptor is declared or counted, and maxUniformBufferRange does not bound the block.
- Selection now admits a kernel whose slot addresses or region spill, with the address in the
  window.

The variant goes at the codec's end, since tags are by name. The api_signatures table gains it,
and the kind-order and status-address placement tests name it. SEMANTICS_VERSION 2147: a refusal
under the identity domains became a module.

The new test, slot_addresses_past_the_window_are_read_from_the_pushed_parameter_block, uses a
generated kernel with 20 read buffers and an output. On lavapipe and moltenvk-m3:
- ArgumentTableAddress is at Push{0}, 15 slot addresses fill the rest of the window, and 6 go to a
  48-byte block;
- there is no descriptor;
- it passes L3;
- on the CPU interpreter, with the block and every buffer above 4 GiB, it stores the ordered fold
  of the 20 words, which a swapped address would change.

Docs: docs/API.md's identity-domain bullet names the parameter block (added after the check
runs; no code differs from what they built).

Verified:
- m3-max-41196 (msi, check commit 9c6102b5ad on step 1's tree: this commit's metal2vulkan tree, with
  the same translator files as here on 1bb5fe5bf8, where only the runtime crate's signature rows
  differ): clippy -p metal2vulkan --all-targets --all-features, rustdoc -D warnings, and nextest -p
  metal2vulkan --all-features, exit 0 (every test passed; the log of the count was lost to a
  second job on the node writing the same scratch path, since fixed).
- m3-max-41197 (msi, 9c6102b5ad): clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
2026-11-17 08:20:24 -08:00
Anees Iqbal 46e3215e55 identity: kernels over buffers lower under the identity domains
Under PointerDomain::Identity with HandleDomain::Identity every buffer slot of a kernel is its
device address used directly. Each slot is the Psb form, its address read from its own push
field, PushField::SlotGuestBase(slot): gpuAddress plus the bind offset, which under the identity
domains is the Vulkan device address. No root table is read, and no access is contained, as Metal
contains no device-address access (psb::prepare_at). Selection admits, under the identity domains,
only the plans lowered so far (select::identity_admits): a kernel whose push fields are its slot
addresses and its dispatch region, all in the push window, with no descriptor and every slot
addressed. Anything else is still Unsupported{IdentityDomains}, not implemented, now refused there
rather than for every function at analysis. SEMANTICS_VERSION 2146: a refusal under the identity
domains became a module.

The new tests (src/tests/engine_identity.rs):
- a1_bool_from_float under the identity domains on lavapipe and moltenvk-m3 has no descriptor,
  no root table and three SlotGuestBase fields. It passes L3, and it computes the program's
  answer on the CPU interpreter, with its buffers above 4 GiB at bind offsets 32, 16 and 4. It
  writes nothing past its output, with its region pushed.
- a2_dynamic_texel_offset, which samples a texture, compiles under the default domains and is
  refused under the identity ones.

Verified:
- m3-max-41149 (msi, check commit eeecc4492b, the same tree but for the test's region bytes):
  clippy -p metal2vulkan --all-targets --all-features, rustdoc -D warnings, and nextest -p
  metal2vulkan --all-features, 3664 of 3665. The one failure was this test, which met the kernel's
  DispatchRegion field and did not fill it.
- m3-max-41195 (msi, a5dbfd408f, this tree): clippy and rustdoc; tests::engine_identity and the
  domain pair test, 3 of 3.
- m3-max-41150 (msi, eeecc4492b): clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
2026-11-17 08:13:46 -08:00
Anees Iqbal 6769c2eaaf known-gaps: the RTX 3090's and the Iris Xe's half-output blend rows
The six half-output blend cases differ from Metal on the RTX 3090 (59 sites) and on the Iris Xe
under ANV (62 sites). The ledger had no rows for either venue, so the conformance replay failed
there. Every site is the device's own blend, which the native-arithmetic contract makes the
answer, so each gets a row: 59 scoped `NVIDIA GeForce RTX 3090`, with answers equal to the
RTX 5080 Laptop's rows (no venue pattern covers those two without the RTX 2080, which no run
here measured), and 62 scoped `Iris(R) Xe`. docs/CONFORMANCE-COVERAGE.md is re-derived for them.

How the sites were shown to be the device's blend, by a measurement build (not committed) that
read every stored code back and set it beside plain float models of the blend:
- The `one-zero`, `min` and `max` sites store the source or the destination through the
  attachment alone, and store Metal's codes on both devices, so both operands reach the blend
  exact.
- RTX 3090 (NVIDIA 620.70.06): the exact blend rounded once to the attachment's precision gives
  98.0% of the 16-bit words and 98.7% of the 32-bit ones. Into a 16-bit target the blend colour is
  truncated to `half`; the runtime hands vkCmdSetBlendConstants Metal's float colour unchanged, so
  the truncation is the device's. Every word that differs from Metal's is within 1.01 ulps of
  that model at the largest operand's magnitude. A -0 + +0 sum stores -0, which is the 32768 and
  2147483648 of the zero-1msa and sas-1msa rows.
- Iris Xe (Mesa 26.2.6): the float blend truncated toward zero into a 16-bit target gives 97.6% of
  those words. The exact blend rounded to nearest gives every 32-bit word.
- On both devices every differing word is within two ulps of Metal's at the largest operand's
  magnitude. That is inside the bound of the `half-output-fast-math-blend` precision note (three
  half ulps, two float ulps). The note is announced on both devices: the cases' allowance for it
  fired on all six cases (3090: 12 of 12 allowances fired; Iris: 6 of 12, the six silent ones are
  shared-in-system-memory, which an integrated GPU does not announce).

Verified:
- conformance replay of the six cases exits 0, each run holding one GPU: ms01 RTX 3090
  m3-max-41210, ms01 Iris Xe m3-max-41211, um870 RTX 3090 m3-max-41218.
- cargo nextest run -p metal2vulkan-conformance --all-features: 1043 passed (m3-max-41208).
  The first run, before the document was re-derived, failed only
  the_conformance_coverage_document_is_what_the_sources_derive (m3-max-41199).
- Measurements: m3-max-41151, 41171 and 41176 (um870 3090), 41174 (ms01 3090), 41175 (Iris).
These ran at tree 9326ca7fd8, which this commit's tree equals.
2026-11-17 08:11:23 -08:00
Anees Iqbal b415aae947 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-17 07:46:54 -08:00
Anees Iqbal 94071f82a2 device: the identity pointer and handle domains, taken as a pair
The new runtime's form: pointers are device addresses used directly and a texture's or sampler's
handle is its gpuResourceID (docs/RESOURCE-ID.md). The variants come beside the old domains,
which stay until the cutover; nothing lowers under them yet.

- PointerDomain::Identity and HandleDomain::Identity.
- Device::new refuses one identity domain without the other (InvalidDescriptor) and the identity
  domains on a device without bufferDeviceAddress and shaderInt64 (Unsupported{IdentityDomains},
  naming both features as one alternative).
- A compile under the identity domains is Unsupported{IdentityDomains}, not implemented, at the
  start of analysis, so no old form is ever emitted under them. Later steps lift it as the
  lowering lands.
- The profile fingerprint covers the domains (tested).
- docs/API.md's policy section names the domains; docs/REFUSALS.md and the reach table carry the
  new refusal; api_signatures regenerated.

Verified (this commit's tree, rebased with the ledger commit before it onto b216007f0a):
- msi 41071: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc -D warnings,
  nextest -p metal2vulkan in full, 3,663 of 3,663 (the golden table included: no cell moved; the
  new test the_identity_domains_come_as_a_pair_on_a_device_with_addresses among them).
- msi 41072: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- msi 41073: the conformance crate's ledger tests, 7 of 7.
2026-11-17 07:46:08 -08:00
Anees Iqbal b6077a933a docs: REPLAY-STREAM.md says how much the old runtime's executed counts move
A play of one recorded stream on a 780M with an empty translation cache and an empty Mesa
cache (m3-max-41100, at a8ad095897) recorded 2523 dispatches, 71967 draws, 28321 render passes
and 8503 submissions; the two warm plays after it recorded 2079, 71742, 27871 and 7036. The
stream's counts were equal in all three, every group and frame line (0 of 7932 differ); the
executed counts differ in 285 lines cold against warm and in 11 between the two warm plays.
So cold caches change the totals, not only where a few draws land, and the spec now says so.
2026-11-17 07:45:21 -08:00
Anees Iqbal c97dbd66ea validation: the replay report keeps what the stream fixes apart from what the runtime executed
Each report line (completed group, frame, total) now holds two sets of counts. `stream`: the
calls played, the command buffers committed, the encoders made, the draws and dispatches their
calls issued, and the player's own relocated, misaligned and written counts, all fixed by the
stream, so equal on every play on any runtime. `executed`: the runtime's counters (for the old
runtime, the Vulkan commands it recorded and the pipelines it made). The separate `calls N` line
goes: the total's stream calls are the calls played.

Why: the old runtime's executed counts are not repeatable at one tip. Seven plays of one
recorded stream on a 780M at one tip gave equal totals, but in some plays a few draws (with
their barriers) moved from one group to a group 15 later, and once from one frame to the next.
The moving groups are the ones that make a pipeline, and they differ in `draws_unkept_making`
(2 against 1): draws recorded through a pipeline's general form while its own was still being
made on the runtime's pool, which keep nothing to draw again
(metal2vulkan-runtime's pipeline/render/residual.rs). Where a background making lands is
timing. The commits, submissions per group and the player's waits did not differ. The matrix
compares the stream's counts only.
2026-11-17 07:45:21 -08:00
Anees Iqbal 077c9722e3 metal2vulkan-rt: command queues, command buffers and events on the submit and completion threads
Step (c) of the new runtime's compute core.

What:
- CommandQueue (newCommandQueueWithMaxCommandBufferCount:, its bound on uncompleted command
  buffers), CommandBuffer (enqueue, commit, handlers, waits, status, error), Event and
  SharedEvent (signaled_value, set_signaled_value, wait_until_signaled_value,
  notify_listener).
- A command buffer records at once into segments split at event waits and signals. The submit
  thread holds a segment whose waits are not met, and its queue behind it, while the segments
  before it run (reims F1). A wait the host's value meets submits no semaphore wait; a GPU
  signal not above the highest value submitted or set is left out, so the semaphore only rises.
- The completion thread retires by a progress semaphore, follows submitted event signals (a
  listener runs at a mid-buffer signal, reims F2), runs handlers with no lock held, and is
  woken through a host-signalled timeline semaphore only when a wait needs it.
- A command buffer keeps each block it uses until it retires. A zeroed Private buffer's fill is
  an upload submitted ahead of every later commit, whose segments start with a barrier; each
  segment ends with a barrier to the host.
- Device::quiesce(timeout) (F9), with every wait bounded, no join of a thread still running, no
  thread-local that exit() tears down, idempotent, freeing nothing; unmap runs on the caller for
  every block handed out, once (a handed set replaces the per-idle flag).
- The last handle dropped in a handler: the completion thread finishes the teardown itself (F8).
- CommandQueue::abandon (F14); a loss ends held work, in-flight work once the device is idle,
  host waits on pending signals, and later commits, with DeviceLost { in_flight } (F13).
- Refusals Committed, OtherDevice, NoCommandBuffers with their basis; Error::Quiesced;
  docs/REFUSALS.md and the API signature table regenerated; the README's contract.

Verified: cargo fmt; refusal_surface --check. The compile and device jobs follow.
2026-11-17 07:25:30 -08:00
Anees Iqbal 4e8784ad14 refusal surface: the new runtime's own refusal enums, one section each
What: refusal_surface.py reads the new runtime's Error and makes a section of
docs/REFUSALS.md for each variant whose payload is one enum the runtime
declares: today Refused(Refusal) and Limit(Limit), and any family added later
(a Gap included) without a list of names to keep. Each of their variants
declares its basis, as Problem's do, and --check fails on one that does not.
The translator's Limit section no longer counts rt's Limit sites. A rustdoc
link [text](path) in a summary reads as its text; three existing rows lose a
link the file could not follow.

Why: AGENTS.md wants every new refusal in REFUSALS.md, and the scan of rt read
the floor's Missing only, so EmptyBuffer, BufferPastBlock, BlockLen and
BlockIds were missing. Their basis lines cite the M3 Max measurements the old
runtime records for the same answers (newBufferWithLength:0 and a placement
past the heap's end answer nil), the device's limits, and our 32-bit numbers.

How verified: the script regenerates, --check and --selftest pass locally;
the refusal_surface test runs in the compile job.
2026-11-17 07:25:30 -08:00
Anees Iqbal d3b0f2f580 validation: a played no-copy buffer drops the read-only option
A no-copy buffer plays as a buffer of its length (its host memory is not in the stream), and the
runtime refuses option bit 24 on such a buffer, as Metal ends the process there; b2 stopped at
its 354th call on one. The bit is dropped for a no-copy buffer alone, so the replay keeps the GPU
writes Metal drops from that memory; the spec says so. A heap keeps the bit, which the runtime
takes.

Found by the b2 play on gem10's 780M (job m3-max-40908).
2026-11-17 07:18:19 -08:00
Anees Iqbal 2dda92f5e0 validation: a buffer in a block is the block's call, as the recorder writes it
The recorder renames a placement on a block (newBufferWithLength:options:offset:) and keeps its
receiver, the block; the backend took it on the device, and b2 stopped at its 88th call. A no-copy
buffer, [nil, length, options, nil], plays as a buffer of that length.

Found by the b2 play on gem10's 780M (job m3-max-40905).
2026-11-17 07:18:19 -08:00
Anees Iqbal a28aca8889 validation: the replay report counts the calls played, so a stop names its call
The stopping call is the one after the count: on a long stream the selector alone does not say
where the play stopped.

Verified by the unit test of a refused selector (the count stops before it).
2026-11-17 07:18:19 -08:00
Anees Iqbal e99ec291b5 validation: the replay player plays the recorder's format, renders included
The spec and the player follow what the recorder writes (reims-vgpu bec103226; b2 was recorded
at 50fc14009, the same format but for refused guest-RAM copies): structs and descriptors are maps
keyed by the recorder's camelCase field names, nil for an unset optional field; f32 values are
f64; descriptors Metal makes as objects (texture and render pass descriptors) are platform
records changed by setter records; a drawable never seen made is a texture of its descriptor;
the host's plumbing (padded, exportable and dma-buf buffers, an unshared queue) plays as the plain
Metal call it stands for; the host's scheduling records play as nothing; no call answers a
resource ID, and a descriptor's resource index places its object.

The guest-RAM copies are [buffer, [[byte, data], ...]] in and [buffer, [[byte, [start, end]],
...]] out. m2v.copyBytes:toBuffer:offset: and m2v.copyToHost: are gone: the host has no such
methods. The gpuResourceID answer check and PlayError::ResourceId are gone with the answers.

The old runtime's backend becomes a module: argument and map readers (args), descriptors
(texture, render pass setters, render and compute pipelines, depth-stencil, sampler, buffer and
heap descriptors, function constants and descriptors, surface planes), and the command buffer,
compute, blit and render encoders' calls. Each mapping follows how the host's platform applies the
recorded value to the runtime.
2026-11-17 07:18:19 -08:00
Anees Iqbal 21082c0094 Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-17 07:02:13 -08:00
Anees Iqbal 6f5bd20321 stage io: one 32-bit form for every stage output
The translator declared a `half` color output with 16-bit float lanes where the device enabled
storageInputOutput16 and shaderFloat16: a second form chosen by a query that is not one of the four
the owner's rule 2 allows (the 3090, 2080, RX 550 and lavapipe lack it; MoltenVK, RADV and ANV
have it). Every interface variable is now 32-bit on every device: a `half` output is widened to
`float`, which holds every `half` exactly, and no module needs StorageInputOutput16.

- lower::stage_io: plan::half_variable, IoObject::User::half and the 16-bit store are gone, and
  io_elem takes no width. StageIo::half_outputs and the profile's input_output_16bit are gone;
  the link contract checks 32-bit float lanes only.
- SEMANTICS_VERSION 2145 and ARTIFACT_FORMAT_VERSION 527 (the artifact codec lost a field). The
  golden table needs its re-bless on development: every profile's key moved with the profile's
  lost field.
- The HalfOutputPrecision and HalfOutputFastMathBlend notes, docs/API.md's degrade catalogue,
  docs/FAST-PATHS.md and the half-output-blends conformance case say what the device receives
  now; their statements about the 16-bit form are gone.
- known-gaps.tsv: 52 rows for MoltenVK on the Apple M3 Max. With the 16-bit output MoltenVK stored
  Metal's codes at every word of half-output-blends-*; with the `float` output its blend is the
  device's own (half-output-fast-math-blend) at 17, 17 and 18 sites of the R16Float, RG16Float and
  RGBA16Float cases, largest differences 1 to 1,582 codes at the stored value (the blend-colour
  sites the largest). Its 32-bit float cases still store Metal's codes.

Verified (code at c55bc28e43, ledger rows added at 2754676210, this commit's tree):
- msi 40877: clippy -p metal2vulkan --all-targets --all-features -D warnings, rustdoc
  -D warnings, nextest -p metal2vulkan in full: 3,661 of 3,662 pass; the one failure is
  golden_hashes_match_the_table (every profile's key moved), for the re-bless on development.
- msi 40827: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- XTX (RADV NAVI31) 40843: runtime_lane color_writes (every `half`, NaN and infinity included),
  half_output_blends and extended_range_blends, 16 of 16 pass; the conformance replay of the six
  half-output-blends cases exits 0 against the RADV rows, so every row's count and largest
  difference held.
- RTX 3090 (ms01) 40844: the same 16 lanes pass; the replay's 59 divergent sites are exactly the
  RTX 5080's 59 rows (the ledger holds no 3090 rows; NVIDIA never had the 16-bit form).
- M3 Max on MoltenVK: 40833 before the rows (52 new gaps, all in the 16-bit float cases), 40862
  with them (exit 0, every count held on the second run).
- msi 40875: the conformance crate's ledger tests, 7 of 7.
2026-11-17 07:01:32 -08:00
Anees Iqbal 737ccbf81a metal: the resource ID word, its spec and test vectors
Under the identity binding domains a guest computes a texture's or sampler's gpuResourceID itself,
with no round trip: the index the consumer grants in the low 32 bits and a word in the high 32 bits
that is a pure function of the Metal descriptor. The guest's port needs the word specified and a
file of vectors both sides check.

- metal::resource_word::TextureWord::of(pixel_format, swizzle): bits 0-11 Metal's border texels
  after the swizzle (the existing border_texels rule), bit 12 the out-of-bounds alpha of a format
  without alpha, bits 16-31 the MTLPixelFormat raw value, so a texture's word is never 0. None for
  the placeholders and the formats the translator holds no texture of or only copies.
- The sampler word is the existing SamplerWord, unchanged.
- docs/RESOURCE-ID.md: the ID's layout, the index classes (0 nil; storage-capable textures 1 to
  4,095, valid in both arrays; other textures 4,096 to 65,535; samplers 1 to 3,999), both words'
  bits and the level rule, and the vectors file. README's documentation table lists it.
- crates/metal2vulkan/tests/resource_words.tsv: 392 vectors (every pixel format with a word under
  the default swizzle, each channel of seven formats from each other source, every sampler field
  through its values, the level clamps around the points the nearest level turns at, and one
  descriptor with every field changed). tests/resource_words.rs recomputes every line through the
  public API and holds the file equal to what the generator writes; an ignored test blesses it.
- api_surface lists the new module; api_signatures regenerated.

Verified:
- msi job 40810 at the same tree: clippy -p metal2vulkan --all-targets --all-features -D warnings,
  rustdoc -D warnings, nextest 18 of 18 (resource_words, the TextureWord unit test, api_surface,
  api_signatures).
- msi job 40811 at the same tree: clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd.
- msi job 40809: the bless test wrote the vectors; the combined sampler line (0x58f6ab53) and the
  A8Unorm and R8Unorm texture lines checked by hand against the bit tables.
2026-11-17 07:01:32 -08:00
Anees Iqbal 4406486e8c docs: the matrix's harness suite and time records 2026-11-17 06:19:58 -08:00
Anees Iqbal b4b22c7b2c matrix: the per-commit matrix runner and the user-space instruction counter (WIP) 2026-11-17 06:19:57 -08:00
Anees Iqbal 84fc9a95fc validation: replay streams name the guest RAM copies; a present reads nothing
The recorder writes the host's copies between the guest's RAM and a buffer as blit-encoder
records: m2v.copyFromGuestRam ([runs, buffer, offset, data]), m2v.copyFromGuestRamAt ([placed runs,
buffer, data]) and m2v.copyToGuestRam ([buffer, placed runs]), a run being [start, end] host
addresses of which only the length counts. docs/REPLAY-STREAM.md names them, with the data the
next recording carries. The player relocates the data of every upload (these two and
m2v.copyBytes:toBuffer:offset:) by one rule, where its buffer answered a gpuAddress, and counts its
bytes as written; the old runtime's backend copies them through a staging buffer, piece by piece,
and copies m2v.copyToGuestRam into host memory nothing reads.

m2v.present is now recorded wherever the device's display shows a guest present, a nil texture
where the stream never made it, so frames are counted once: the player closes the frame and
reads nothing (a readback per frame would add a copy Metal does not make).

Tests: a unit test plays the three copy-ins into a block and an addressless buffer (relocated,
counted apart 4 past 8, untouched) and refuses data of another length than its runs; a device
test lays a buffer out with a fill, both guest RAM copies, a fill copy and a copy back, and reads
it back as expected.
2026-11-17 06:14:55 -08:00
Anees Iqbal 964ae2c241 validation: replay streams v2, their player and the old runtime's backend
What: docs/REPLAY-STREAM.md specifies the binary replay stream (version 2): segments of records
(names, blobs by SHA-256 of the exact bytes, calls), tagged values, the address and resource-ID
model, CPU writes, surfaces before the platform cutover, commits, events and frames. The new
`replay` module of the validation crate holds its reader and writer, the address map, the player
(relocation of 8-byte-aligned address words in live recorded ranges, counting rewritten words and
the 4-mod-8 values it leaves; exact resource IDs; waits only for command buffers that can
complete, so one held on an event never stops another queue; counters per waited group, per frame
and in total, readbacks excluded; SHA-256 checks), and a backend over the old runtime's public API
(compute and blit encoders, blocks as placement heaps, textures at recorded IDs, events). A
selector it does not play is a typed refusal naming it.

`command-replay` now plays and dumps v2 streams; the v1 JSON manifest runner is deleted (nothing
in the tree or the lanes used it).

Tests: unit tests write their own streams (round trip, segments and a cut tail, refused kinds and
versions, the blob directory and its hash check, nested ranges, relocation counts, event-held
command buffers, frames, releases and host splits). Device tests (`runtime_lane::replay_streams`,
under m2v_gpu or m2v_cpu_icd) play written streams on the old runtime: a device pointer written
at a recorded block address is relocated and the kernel's output is the case's Metal output, on
two devices alike; a command buffer held on a CPU-set shared event does not stop another queue's;
textures are made at recorded resource IDs 77 and 5 and read back as written.
2026-11-17 06:14:54 -08:00
Anees Iqbal ec40b7de6d Interface: what a function reads and writes beyond its bound slots
Each stage interface, and a pipeline's together, states whether its
function may read or write a resource through anything but its bound
slots: a pointer or texture it loads from memory or makes from an
integer (an argument buffer's resources, an address stored in a buffer,
a resource ID), an indirect command buffer, ray tracing, or a call it
cannot see into. Decided from the specialized entry's memory plan: an
access whose pointer or texture handle may have a dynamic or call root.
With each slot's access, these are the two static facts the new
runtime's compute encoder needs to place a barrier only on a hazard.

SEMANTICS_VERSION 2144 (interface facts), ARTIFACT_FORMAT_VERSION 526
(two fields in StageInterface and PipelineInterface).
2026-11-17 06:14:08 -08:00
Anees Iqbal 374e29a988 metal2vulkan-rt: the floor's shader features, queue family, timestamps and memory types
The floor now also requires what the translator's shaders and the runtime's
core need of every device:

- shaderInt16, shaderInt8, storageBuffer16BitAccess (Vulkan 1.1 features,
  now read and enabled through Features::vulkan11), storageBuffer8BitAccess,
  scalarBlockLayout, vulkanMemoryModel and vulkanMemoryModelDeviceScope. The
  translator emits 8- and 16-bit access only in storage and physical storage
  buffers in practice (uniform views are u32 or uvec4, push fields are 32- or
  64-bit), so the uniform and push-constant 8/16-bit features stay out; it
  does use device scope.
- timestampComputeAndGraphics, and timestampValidBits of at least 36 on the
  first queue family with graphics and compute, which Capabilities names
  (queue_family). A device with no such family is Missing::QueueFamily.
- a host-visible, host-coherent, host-cached memory type (Shared storage)
  and a device-local, host-visible, host-coherent one (the parameter ring),
  each usable by a buffer of BUFFER_USAGE: every Vulkan 1.3 buffer usage plus
  device addresses. Vulkan answers buffer memory types only for a created
  device, so check() finds a type with each set of flags and carries the
  memory properties, and memory_types(device, &capabilities) chooses the
  first usable type of each with vkGetDeviceBufferMemoryRequirements.
  Missing::MemoryType names the flags.

Each shortfall is named in BelowFloor, with a unit case; the README's Floor
section states every item and tests::floor holds it to the code. The device
test now also creates each device with the floor's features and extensions
and chooses its memory types on it.

CI's lavapipe step (ci.yml and scripts/linux-gate-ci) runs the rt crate's
device tests too. refusal_surface.py reads metal2vulkan-rt and writes the
floor's Missing as section 10 of docs/REFUSALS.md; signatures.py pins
metal2vulkan-rt's public surface in api_signatures.tsv.

Verified: see the lane report (compile job, device legs on every lab GPU,
lavapipe and the Windows UHD 630).
2026-11-17 05:33:25 -08:00
Anees Iqbal 017ff31e2f wip harness crate 2026-11-17 05:22:15 -08:00
Anees Iqbal 28b6b0b9df metal2vulkan-rt: the new runtime's crate, and AGENTS.md's rules for one path on every device
What: a new, unpublished workspace crate, crates/metal2vulkan-rt, that will replace
metal2vulkan-runtime and take its name at the cutover. It has no public API yet. Its first test,
tests::one_path, reads the crate's product sources (line comments removed) and fails on:
- a vendor, device or driver identity name (vendor_id, deviceID, DriverId, driver_name ...);
- a GPU vendor's ID as a hex literal (0x1002, 0x10de, 0x8086 ...);
- an environment read (env::var, option_env!);
- a struct or enum named as a policy.
Two more tests prove the scan finds each form and passes prose and unrelated numbers.

AGENTS.md takes the owner's new rules, in priority order:
1. correct for documented Metal, with the device's arithmetic and static notes per operation;
2. one path for every device;
3. native-like speed;
4. small.
It also takes:
- the workaround ladder, the never-list and the thresholds;
- the matrix rules: every check fans out one leg per GPU at once, and the replay matrix runs on
  development after each merge with deterministic metrics and leak gauges;
- the freeze: the old runtime, DevicePolicy switches, driver-fact tables, device checks and
  docs/FAST-PATHS.md get regression fixes only until the cutover deletes them, and nothing new
  of those kinds is added;
- the scope rule: below the floor is a typed refusal, and a Metal feature no replay stream uses is
  a typed refusal until a stream needs it.
The crate table, the doc table, CI's crate lists and the gate commands in AGENTS.md,
CONTRIBUTING.md and docs/VALIDATION.md name the new crate.

Why: the owner's plan replaces the runtime with one that has no per-device code paths. These are
the rules every lane of that work follows from its first commit.

Verified: cargo fmt. Build, clippy and the crate's tests run on development after this lands.
2026-11-17 03:09:06 -08:00
Anees Iqbal 96e1041dbf RUNTIME 2538: submission checks: an answer that load could have made stands only for now
What: a merge or import tax answer now stands as far as it earned
(`Stands`). A merge `Holds` clear of the load and repeated, an import tax
`Holds` past its margin and repeated, and an `Unchecked` of a refused call
or a device with no pointer import are recorded. A `Fails` clear of the
load whose every try ran quiet stands for the device's life and is never
recorded. Every other answer stands for now: the checks' thread keeps its
command buffers and fence and checks it again 1, 2, 4 ... 64 s after the
first answers, then each minute, until none stands for now. A check again
replaces the verdict (tries that all split keep it), so a device whose
first merge answer was a loaded `Fails` groups once a check again answers
`Holds`. A record's `Fails` is a hint and no answer: a device that reads
one checks that check again at its making. Before each round and each
submission of a phase the checks stand by, at most 20 ms, until the
device's work is quiet (`DeviceShared::work_quiet_for`, shared with the
checks' thread through `WorkShare`).

The stop rule's thresholds (`Load::ran_quiet`): every stand-by found the
device's work quiet, no round or submission took past QUIET_ROUND_MOST
(2 ms, from its first call to its fence's reset), and all of them no more
than QUIET_TRY_MOST (30 ms). A merge `Fails` must also be clear
(MERGE_FAILS_CLEAR, 0.75 of the calls apart) and repeated
(MERGE_REPEATS); an import tax `Fails` must agree in its halves with a
held import adding at most half its bound (TAX_FAILS_CLEAR).

Why: on the Radeon 780M beside other jobs (m3-max-39740, load average
18-24 on 16 threads), two of four devices answered merge `Fails` at 0.72
and 0.745, both forms lifted by about the same 58-80 us, short of the
record but held for the device's life, so those processes grouped no
batch at all. At 0.75 and up with its repeats, the same load would have
written a `Fails` record that every later device of that release read
without checking. Threads of the process's own spinning or touching fresh
pages (m3-max-39786, 2x the host's threads) lifted every call alike and
left all eight devices at `Holds` (0.23-0.64), so the device test injects
the observed shape instead (`lift_next_merge_tries`: 70 us on the first
call of every round, its stand-bys not quiet).

Costs: a driver that does not merge or whose imports cost nothing pays
that check at every device's making, as before any record, and once more
at least where no try of its first answer ran quiet. An answer for now
costs a check again at each step of the schedule. The import tax is
included: a loaded tax `Fails` placed the device's long buffers in fresh
pages for its life on a driver whose imports do cost (39740's
b202c-bench run: 148.6 against 121.5 us, short of its margin).

CHECK_VERSION 9 (a record may hold no answer of a check, and a `Fails` in
one is no answer). Tests: unit tests of what each answer earns, the
schedule, the quiet bounds and the record; device tests that a recorded
`Fails` is checked again and that a lifted merge answer is checked again
and comes to the answer of a device beside it, with no `Fails` recorded.
in_place_check takes its answers through `answer_next_device`, since a
record can no longer hold a `Fails` as an answer. Forced verdicts
(`SubmitChecks::force`) stand for the device's life.

With it: the drag bench reports the submission checks' answers before and after its measurements
(test only); a lifted try's count goes down by AtomicU32::try_update (fetch_update's new name).

Verified (launchreg lane, tip 942672e8cb = these three commits on development 01415e33d6):
m3-max-39884 (msi): clippy -D warnings plain, m2v_cpu_icd and m2v_gpu 0; lavapipe submit_check,
in_place_check, teardown_threads, relay_facts, fresh_pages, padding_unobserved, host_ram_dma_buf,
dma_buf_parked_images, exported_textures, icb_records_policy, pointer_residency, fast_paths,
queue_quiet and view_check 114/114; view_check_device's stand-by test 3/3. The control (the fix
without the re-check of loaded and recorded answers) fails the new device tests as meant: lavapipe
(m3-max-39818) 2 of 2, RX 550 (39863) 2 of 2, Radeon 780M (39885) the recorded-Fails test; the fix
passes 26/26 on the RX 550 and the 780M. On the 780M (39907, the fix on an earlier base) a device
made under host load answered merge Pending (one try split), then "Holds, recorded (14.4 us in one
call of 4 against 39.4 us apart)" after its re-checks, and grouped; every later device answered
Holds in 3 tries.
2026-11-17 02:01:04 -08:00
Anees Iqbal 94e3f50b3e RUNTIME 2524: name and count each reader's snapshot image
What: a reader's snapshot (render/snapshot.rs, Texture::snapshot_texels) is a storage image of
the read texture's level-0 extent beside the texture's own image, which no log line named and no
count counted as an image. Each snapshot a draw takes is now counted
(WorkCounts::reading_snapshots_taken; reading_snapshots_recycled for those whose image was the
recycler's parked one, which placed no memory) and named in the shadow log
(METAL2VULKAN_LOG_SHADOWS): the draw's call, the texture it binds (format, size, levels, usage,
object ID, the texture it is a view of), the snapshot's format and extent, and whether its image
is the recycler's or one placed for it. Image records whether the recycler handed its VkImage
back (Device::recycled_image now says so).

Why: a consumer's Iris walk (RUNTIME 2485) showed a second Private image of each image cache's
size placed about 1 ms after the cache and returned with it, 109 of them, named by nothing: the
snapshot of a draw that samples the cache's view at its own pixels while its own pass renders the
view and writes that color. RUNTIME 2508 already releases it with its command buffers; it stayed
unnamed and uncounted.

Test: tests::snapshot_goes turns the shadow log on and checks one line per snapshot taken, the
recycler's named so, each naming the view, its texture and the snapshot's extent; the second
pass takes 1 snapshot, the recycler's. On a device without the path: none taken or named, and
the reader's copy is the usage shadow the log names for the attached read.

Verified (twinplace lane, tip 2e160c176e on fe3f09f569): m3-max-39527 (msi): clippy -D warnings
plain, m2v_gpu and m2v_cpu_icd 0 for metal2vulkan-runtime and metal2vulkan, rustdoc 0, lavapipe
snapshot_goes, snapshot_reader*, snapshot_area, leading_snapshots, swapped_out_book 10/10
(the copy route: snapshots taken 0); m3-max-39554: api_signatures, api_surface, env_registry
19/19; PHOENIX (RADV) m3-max-39555: the same 10/10, snapshots taken 3, recycled 2, lines 3.
New WorkCounts fields reading_snapshots_taken and reading_snapshots_recycled; no new
Degradation kind; no route change.
2026-11-16 23:52:28 -08:00
Anees Iqbal 7dcde89ddb RUNTIME 2522: a head whose line signals what another queue's head awaits takes no turn
Under the default Fair queue turns, a later command buffer of a queue sharing a
VkQueue is held for its turn while its queue's earlier one is in flight. Where
that later one signals a value another queue's held head waits for, and the
earlier one waits on the GPU for a signal the program gives only once that
waiter is scheduled (a caller's reserved signal, Event::reserve_vk_signal), the
program waited for the watchdog, where Metal schedules them all at once.

Each look now first gathers the values the line heads wait for that no
submitted signal or host set reaches (EventShared::landing), and, only where
there are any, marks each turn-taking line's head by whether a batch of its
line signals such a value for another line (one read per command buffer).
Such a head takes no turn (scheduler/mod.rs mark_awaited_signals; Held
signals_awaited); once the signal went, its line takes turns again. The
awaited values live in State and are emptied after each look, so a look
allocates nothing. queue_turns.rs gains the "Awaited signals" rule and the
FAST-PATHS queue-turns row says it.

The lane test runtime_lane::events::a_signal_another_queue_waits_for_takes_no_turn_behind_a_gpu_wait
(queue B's first command buffer waits on the GPU for a reserved gate, its second signals W=1,
queue A's waiter waits for W=1; the gate opens once A's waiter left Committed) comes with it.

Verified (evwait lane, tip b77e692259 on fe3f09f569): m3-max-39516 (msi): clippy -D warnings
plain, --cfg m2v_gpu and --cfg m2v_cpu_icd 0, rustdoc -D warnings 0, runtime unit tests
queue_turns|unshared_hold|fast_paths|scheduler|order 222/222. The lane test's before/after
on the XTX (m3-max-39536) and PHOENIX follows on development; unverified there until then.
No new Degradation kind, WorkCounts field or public signature.
2026-11-16 23:42:39 -08:00
Anees Iqbal d0714ec9a6 RUNTIME 2518: queue turns hold only a command buffer's first batch; its later batches follow
What: under QueueTurnPolicy::Fair, CommandBufferShared::held_for_turn now holds only a
command buffer's first batch (index 0). Once that one went, each later batch of it (a
command buffer splits at an event wait after its work or at a signal before more) goes as
it is ready, as Metal schedules a command buffer whole. queue_turns.rs gets a "Whole
command buffers" bullet and loses the claim that the turns add no wait that can close a
cycle; the FAST-PATHS queue turns row says it.

Why: a REGRESSION of RUNTIME 2490 (Fair, the default). A queue with no run seen keeps one
batch in flight, so a command buffer whose first batch waits on the GPU for a signal not
yet given (the caller's reserved signal, Event::reserve_vk_signal, or another VkQueue's)
had its later batch held for the turn until that first batch completed: it read
Scheduled only then, and another queue's command buffer waiting for its later signal was
held for EventValue meanwhile. A program that gives the signal once that waiter is
scheduled (Metal schedules both at once) waited for the runtime's 20.2 s watchdog, which
failed the signaller (GpuHang / victim) and recovered the device: the XTX lane's
runtime_lane::submission_checks reds. Every device whose command queues share a VkQueue
(RADV, ANV, lavapipe) takes Fair.

Verified before the fix (carried --lib gpucfg archives, alone, --test-threads 1):
development 68c456e5ba on the RX 7900 XTX (m3-max-39361) and the 780M PHOENIX
(m3-max-39362): a_submission_detached_while_a_gpu_signal_is_in_flight_fails,
a_wait_the_host_meets_is_checked_without_waiting_for_the_gpu and
an_event_wait_a_gpu_signal_in_flight_meets_is_checked_at_once FAIL (signaller Error after
the watchdog); the same tree with QueueTurnPolicy::CommitOrder (a probe, not landed):
4/4 pass in 0.1 s each on both. RUNTIME 2493 and 2503 fail alike on the XTX.

Verified after (evwait lane, tip c435183fba): clippy -D warnings on runtime + validation,
all targets, all features (m3-max-39391, msi), queue_turns + unshared_hold + fast_paths
unit tests 61/61; PHOENIX 780M (m3-max-39414): runtime_lane::submission_checks 9/9 as a
module in parallel, the three reds included (1.4-2.1 s each), and the runtime's
queue_share_device, queue_turns, scheduler_held_wakes, submission_turns and unshared_hold
tests 56/56. Clippy under the GPU cfgs, rustdoc and the XTX run follow on development.
No new Degradation kind, WorkCounts field or public signature.
2026-11-16 23:05:56 -08:00