Commit Graph
6001 Commits
Author SHA1 Message Date
Anees Iqbal af372e849c Lane busy work: one GPU job stays under the kernel's timeout; host copies past the window ask again
What: the runs behind running work (behind_running_work, behind_another_queue_s_handler,
behind_a_kept_signal) calibrate A's fills by the GPU's time of the calibration command buffer
(first_use::gpu_took) instead of its commit-to-completion wall time, and cap every stretched A
(and behind_a_kept_signal's long B) at A_MOST, 1 s of GPU time at the measured rate. A stretch
past the cap repeats at the cap. Each run writes a GROUPED-A line with A's fills, the time they
take at the calibration's rate and A's GPU time.

Why: round e8d0bfc33c's PHOENIX lane leg 2/4 (gem10, m3-max-34259) failed
a_held_group_goes_before_another_queue_s_submission_handler_runs with "buffer 0: bytes off its
fill: left 4096": all four command buffers completed with no error, yet B's whole fill was never
run. A ended before Y's handler in runs 1 to 3, so the loop doubled A to 8 times its calibrated
fills, one kernel job. At 17:18:48 the node's kernel logged "ring gfx_0.0.0 timeout ... Ring
gfx_0.0.0 reset succeeded", naming a metal2vulkan_validation process. amdgpu's default job
timeout on that kernel is 2 s (Linux 7.3.3-cachyos, modinfo: "lockup_timeout ... default:
2000"; no override on the command line). The reset ended A and dropped B, which A's context had
emitted behind it; RADV 26.2.6 reported neither (radv_device_check_status checks only
OpAbortKHR, and the kernel did not refuse the context's later submissions: X and Y ran).
Measured on a Radeon 780M (um790, same kernel, m3-max-34394): one 128 MiB fill takes 2.09 ms of
GPU time; A of 192 fills took 0.39 to 0.45 s, of 384 fills 0.80 s, so 8 x 192 fills is about
3.2 s, past the timeout. The wall-time calibration also stopped at 4 fills (12 or 24 returned,
28 to 50 ms of GPU work) in 3 of 10 quiet runs, where the others took 192: the first
calibration command buffer carries first-use costs, so a short A ends early and the loop doubles.
Windows' default TDR is 2 s too, so the cap is half of it.

Not a regression of c218071502..e8d0bfc33c: both shas passed every run of m3-max-34394 (3 quiet,
1 at stretch 2 and 3 beside 8 busy CPU threads and lane partition 2/4, each), with no stretch
past 2 and no ring timeout.

Test: a_stretched_command_buffer_stays_within_its_job_bound (no GPU) asserts that every stretch
the loops reach keeps one command buffer within A_MOST at the leg's measured rate (192 fills at
2.09 ms), where 8 x 192 fills would take about 3.2 s, and that a calibration already past the
bound is cut to it. It fails without the cap.

first_use: a host copy whose busy window the host outlasted is asked again

What: shared_textures_copy_on_the_host_while_the_gpu_is_busy runs each storage mode's calls
through busy_premise's until_premise_held, as device_copies' did_modify_range steps do. Each try
makes a new texture and new busy work, checks its bytes and the copies' counts on every try, and
where the busy work's end mark turned before the calls (or, for copies on the host or the staging
queue, before they returned) writes a LANE-BUSY-MISS line with the time to the busy work's
scheduling, each call's time and the busy work's GPU times, and tries again, at most 3 times. A
copy that waits for the busy work misses every try and fails with each try's times, as before.

Why: round e8d0bfc33c's PHOENIX lane leg 2/4 (gem10, m3-max-34259) failed it with "Ok(Shared) on
AMD Radeon 780M: a host copy waited for the busy work (get_bytes 139.749us, replace_region
666.597us)": the end mark read 0 right before the calls and ENDED after a get_bytes of 140 us.
The calls did not wait for about 2 s of busy work; the test's thread was held past the busy
window between the check and the call, in a leg at its 3 GiB memory limit (peak 3.0 of 3 GiB)
while a virtual machine booted on the node. The test passed at both e8d0bfc33c and c218071502 in
every run of m3-max-34394 (Radeon 780M on um790: 3 quiet runs, 1 more and 3 beside 8 busy CPU
threads and lane partition 2/4, each), its calls taking 20 to 222 us; the miss did not recur.

docs/VALIDATION.md and busy_premise.rs name the test beside device_copies.

Verified in the lane: lavapipe 10/10 (m3-max-34415, GROUPED-A stretch 1: 48 fills, 447 ms of GPU, cap 1 s) and
clippy under m2v_cpu_icd 0; the m2v_gpu archive built (34416). Not a regression of c218071502..e8d0bfc33c:
both shas pass quiet and loaded on PHOENIX (m3-max-34394), and the red leg's ring timeout followed the
stretch to 8x (~3.2 s in one job, past amdgpu's 2000 ms lockup_timeout). PHOENIX run follows.
2026-11-15 18:03:50 -08:00
Anees Iqbal 28aaeb2721 heap_trimmed's docs: the wide chain's free heap on the Radeon 780M, measured alone
70409f0ea2 gave RADV's free heap for the 20,000-step, 600-live chain as
an extrapolation from the 40,000 and 80,000 rows (about 1.4 times the
trim floor). Measured, the kernel made alone in a process of its own on
the Radeon 780M (RADV, Mesa 26.2.6; probe archive of scratch 648efdb10f,
job m3-max-34324): 345,583,872 bytes free after its first making, 1.6 s,
a trim after each of its two makings. The docs now say that: 346 MB,
1.3 times the floor.

Verified: cargo fmt; comment only. The lint job follows.

Verified: clippy plain, m2v_gpu and m2v_cpu_icd and rustdoc of the runtime crate passed (m3-max-34352).
2026-11-15 17:43:44 -08:00
Anees Iqbal cc1d619c7a heap_trimmed takes ANV's stage-bound refusal of the long chain; the wide chain is 20,000 steps
On the Iris Xe (ANV) the test panicked at its first kernel: the long chain
(320,000 steps, 64 live) weighs 320,038, past COMPILED_STAGE_WEIGHT
(99,109), and the device refuses it honestly (Unsupported { StageSize,
DriverDefect(CompilerMemoryGrowsWithStageSize) }, rounds ef313200e2 and
c218071502, leg iris:gputime). The shapes NVIDIA's compile frees past the
trim floor are all past that bound (the module's table: 303 MB at
240,000 steps, 189 MB at 80,000 with 600 live), so no long chain serves
both.

The test now goes by the device's answer: state() returns None only for
that exact refusal, whose symbol names an entry weight past its bound;
every other error fails the test. trims > 0 and the resident bound stay
asserted on every device, so some in-bound kernel must trim on ANV.

A probe (scratch 648efdb10f, never landed; Iris job m3-max-34234), each
shape made once in a process of its own, free heap from mallinfo2 after
the making: 20,000 steps at 600 live freed 794 MB in 145.7 s (peak 3.0
GiB); 40,000 and 80,000 at 600 live did not finish their first making in
240 s; 96,000 at 64 freed 289 MB in 160.9 s at a 7.2 GiB peak. So the
wide chain takes 20,000 steps: three times past the floor on ANV, and on
RADV, at about 18.6 KB a step at 600 live (739 MB at 40,000, 1,506 MB at
80,000 on the 780M), about 1.4 times; NVIDIA's trim comes from the long
chain, and the shorter wide chain halves its time there. The test line
now prints the free heap after each kernel's first making and each
kernel's time, so every device's run shows its premise.

Verified: cargo fmt. The build, clippy and the runs on the Iris Xe, a
PHOENIX and an NVIDIA GPU follow.

Verified: the test passed on the Iris Xe (m3-max-34319: the long chain refused past the stage bound,
the wide chain 4 trims, 372 s), the Radeon 780M (m3-max-34316, and the wide chain alone trims 1.29x
the floor, m3-max-34324) and the RTX 5080 (b5080 entry trimiris-heaptrim-173211); clippy under
m2v_gpu 0 (m3-max-34306).
2026-11-15 17:40:26 -08:00
Anees Iqbal 45af992f33 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 17:39:13 -08:00
Anees Iqbal 0427b71281 RUNTIME 2400: Uniform views keep their residual form where storage views read at their bind offsets
On the profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV, Mesa 26.2.6,
Iris Xe RPL-P) the runtime read every view at its bind offset, a uniform view's included. A
uniform view read so compiles there to a constant-cache block read (send.hdc_ro
oword_block_read:owords4, job m3-max-34232) in place of the untyped read the residual form takes,
which cost about 18 us a dispatch more than the push word it saved. Now the device reads its
uniform views at their residuals, as on every device without
DriverFact::ConstantOffsetUniformReadsPreloaded, and the plan keeps the storage views' key:
reads_views_at_bind is the fact's alone again, and the plans and dispatch regions take
uniform_residual_form (each uniform view's RangeAtBindOffset at 0, a storage view's as the plan
gives it), which is residual_form wherever no storage view declares the key. Runtime only: no
translation output moves.

Measured on the Iris (job m3-max-34275, dispatch_chain, 4480 groups of 256, 200 dispatches a
command buffer, 7 interleaved rounds, medians in us a dispatch; every run checked its words):

  arm                   base f4082938de   landed d3b1dbdbe0   this change
  binds 1, serial            120.15             55.90             55.84
  binds 1, raw-barrier        55.74             55.75             55.75
  binds 4                    142.71            161.78            142.77
  fixed                      143.19            161.77            143.17
  moved                      143.10            165.23            143.04
  tex                        119.63            128.29            119.40

The storage-only kernel stays at raw speed, and every other arm is within 0.25 us of base.

Tests: general_form's a_plans_key_zeroes_its_uniform_views_and_keeps_its_storage_views (the
uniform-only residual form keeps a storage view's constant, the residual form zeroes both);
pipeline's every_committed_driver_reads_its_uniform_views_at_their_residuals again; and
uniform_bind_offsets' two kernel creation tests now key the kernel's own pipeline where its
output, a storage view bound at offset 0, declares the key (keys_its_own), on the workaround's
profile as on a device with the fact. Docs: residual.rs, the workaround's doc, the bind state's
uniform_views_at_residual, and docs/API.md.

Also: the test suites follow the Iris Xe's new workaround (its profile fingerprint differs from the
UHD 770 RPL-S by it; the stage-bound test's reference profile). Verified in the lane: clippy for
metal2vulkan and the runtime, all targets and features (m3-max-34321); the Iris run of
uniform_bind_offsets and inline_continues follows from the lane.
2026-11-15 17:38:32 -08:00
Anees Iqbal a50148491b Runtime lane: heap storage reads by the formats' bits without the feature
What: runtime_lane/heap_storage_reads.rs makes the cfg's device without
shaderStorageImageReadWithoutFormat (withheld) and runs a kernel that
reads an argument buffer's read_write texture into a buffer and writes
(1, 0, 1, 1) back through the same handle, for the six float read-write
tier formats and BGRA8Unorm, RGB10A2Unorm, RG11B10Float. Each read is the
uploaded texel where the heap's view has STORAGE_READ_WITHOUT_FORMAT and
zero where it lacks it (asserted never for a tier format); each write
stores its bytes either way; the validation layer reports nothing.

Why: device evidence for the bits-alone route (lavapipe with the feature
withheld; the Iris Xe as it is, where the three non-tier views lack the
bit).

Verified: lavapipe with the feature withheld (m3-max-34302): 3/3 lane tests, the six tier formats read
their uploaded texels and every write stored, no layer report; clippy under m2v_cpu_icd 0. The Iris
run (m3-max-34313) follows from the lane.
2026-11-15 17:32:00 -08:00
Anees Iqbal bffeca8021 Re-bless the golden hashes and fixture expectations at SEMANTICS 2129
The heap storage-read change (4a06ce915d) moves 52 rows: the heap fixtures' modules on every profile
(48 cells each on most), and the a8r_buffers expectations, now translated on the profiles that read by
the formats' bits. Blessed on the M3 at a3c1f190cb (m3-max-34299: inventory, golden hashes and
printouts 0). Merged-tree clippy, plain and m2v_gpu, passed at a3c1f190cb (m3-max-34300).
2026-11-15 17:30:08 -08:00
Anees Iqbal a3c1f190cb Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 17:26:42 -08:00
Anees Iqbal 4a06ce915d SEMANTICS 2129, RUNTIME 2399: Heap storage reads by the formats' own read bits on a device without the feature
A compute pipeline that reads a read_write argument-buffer texture was refused
Unsupported{ArgumentBufferTextures, needs ShaderStorageImageReadWithoutFormat}
on a device without shaderStorageImageReadWithoutFormat (ANV on Gfx12.0, the
Iris Xe), so the guest's work waited on a nil pipeline. Vulkan 1.3 and
VK_KHR_format_feature_flags2 enable the SPIR-V capability
StorageImageReadWithoutFormat, and a read of a view without a format is then
valid wherever the view's format has STORAGE_READ_WITHOUT_FORMAT_BIT (spec
19.9.3, VUID-vkCmdDispatch-OpTypeImage-07028). The slot path already took
that route; the heap path checked the feature alone.

- declare_heap takes a storage (and storage texel buffer) read by the
  feature or by the formats' bits (DeviceProfile::storage_reads_by_format_bits),
  and on such a profile needs the read bit of the class's neutral, which a
  null handle reads.
- The binder keeps each storage view as before (writes unchanged). On such a
  profile, a member whose view's format lacks the read bit is held for its
  writes and flagged (new entry flag FLAG_STORAGE_UNREADABLE, bit 28: the
  texel-class field narrows to the 12 bits its indices use), and a storage
  read through its handle reads the null element, as a nil texture's read
  does. A member of one of Metal's read-write tier formats, whose read
  Metal's contract defines, is refused without the bit instead.
- handle_entry_flags takes the profile (the flag is the device's).

On the committed Iris profile every Metal read-write tier format has the
read bit; RGB10A2, BGR10A2, RG11B10Float, BGRA8 and the 16-bit packed
formats do not (Mesa's isl: no Gfx12.0 typed reads).

A read-write tier format whose view lacks the bit is not refused at the member (binding runs for
every shader-writable texture of the runtime's device-wide heap, so a refusal there dropped the
texture's writes on a profile such as roadmap-2022, job m3-max-34236): lower::texture::slot::
declare_heap refuses the function that reads a heap storage class where any tier format would be
held in that class through a view without the bit, naming each view's bit; the member is held for
its writes, flagged. Docs: API.md accepted difference, FAST-PATHS known gap and device-gap row,
REFUSALS.md.

Verified in the lane (m3-max-34272): clippy -D warnings for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation, all targets and features; nextest over the heap, handle, storage, profile,
fast_paths, without_format, texel_class and tier tests plus api_signatures, refusal_surface and
api_surface: 317 passed. A synthetic Iris profile with RGBA16F's read bit cleared refuses the
reading kernel naming that format; the committed Iris compiles it. The lavapipe lane with the
feature withheld and the Iris run follow from the lane.
2026-11-15 17:26:02 -08:00
Anees Iqbal a79d16b428 Re-bless the golden hashes at SEMANTICS 2128
The ANV at-bind workaround (d3b1dbdbe0) re-keys the intel-irisxe-rplp-anv profile (fingerprint
6d95bb254f9f9d66 -> 2f820bef4bfb9669). Blessed on the M3 at 726532bd21 (m3-max-34227: inventory,
golden hashes and printouts 0); every changed cell (1939 rows) is in that profile's column, no other
profile's cell moved.
2026-11-15 17:11:33 -08:00
Anees Iqbal 726532bd21 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 17:08:25 -08:00
Anees Iqbal d3b1dbdbe0 SEMANTICS 2128, RUNTIME 2398: Buffer views read at their bind offset where a pushed word lengthens every thread's payload
On ANV (Mesa 26.2.6) on the Iris Xe RPL-P, a compute function that reads a client push word
gets a longer per-thread payload (the base workgroup id moves 17 registers further), and a
light kernel runs about 2.2 times as long: 120.2 us against 55.7 us a dispatch on the same
module with the push read removed (raw Vulkan chains, jobs m3-max-34063 and m3-max-34038).
The 780M (RADV) shows no such gap (m3-max-34031). The runtime's storage views read their
SlotBindOffset residual on every access, so every kernel paid it there.

A measured DriverWorkaround row, PushReadsLengthenThreadPayload, on that driver and GPU:

- the translator declares SpecKey::RangeAtBindOffset for storage views too on that profile
  (access plan's storage_at_bind; the pulled vertex fetch of a shared slot folds its residual
  under the same key), so a key at 1 reads no push word once the driver folds it;
- the binder sets a storage view's key only at bind offset 0, where the runtime tells offset 0
  apart at the slot (StageTable::zero_offset_views, class ZERO_OFFSET_CLASS), and only where
  instantiation's range starts there (starts_at_bind), so the bytes before a bind offset stay
  reachable through the range from the buffer's start at every other offset;
- the runtime keeps the zero-offset slots beside the uniform ones (AtBindViews), leaving out a
  slot once it is bound at another offset, and reads views at their bind offsets on that
  profile (reads_views_at_bind), the uniform views' existing form included.

Every other profile declares no new key and its modules are unchanged; its stage tables leave
zero_offset_views 0, so its shapes and plans are as before.

Also a FAST-PATHS known gap: on the Iris Xe, kernels over exportable or host-pointer-imported
memory run about 2.2x (125.53 and 122.95 us against 55.73, m3-max-33760), cause unobserved;
zero copy stays.

Tests: engine_access (a storage view's module at key 1 reads no SlotBindOffset, at key 0 it
does, answers on the interpreter; no key on the other profiles), the binder's offset-0 rule and
class, the committed profiles' form choice, and a runtime device test of a storage view at
offset 0 and past it.

Verified in the lane: touched tests in msi jobs 34174/34198 (engine_access, bind::, fast_paths,
api_signatures, the runtime pipeline and argument_table tests); lavapipe m2v_cpu_icd 21/21 (34190:
uniform_bind_offsets and the new storage test, answers at offset 0, past it and at 0 again); clippy
plain 0 (34198), m2v_cpu_icd and m2v_gpu 0 (34200); rustdoc 0 (34213). golden_hashes reads stale only
for intel-irisxe-rplp-anv (re-keyed: 1788 cells, fingerprint 6d95bb254f9f9d66 -> 2f820bef4bfb9669); no
cell under an unchanged key moved. The table is re-blessed on development.
2026-11-15 17:07:41 -08:00
Anees Iqbal 244fa02286 SEMANTICS 2127, RUNTIME 2397: Generic pointers move with whole-struct copies of thread memory
A generic pointer stored into a thread struct that a constant-length memcpy or memmove copies
to another alloca was refused as GenericPointer(Memory) when loaded from the copy: the generic
pass counted every copy into a cell as a write of other bytes over its slots. A struct holding
a generic table pointer, copied whole into each callee's argument object, hits this.

canon::generic::cells now has slot copies, mirroring the memory plan's: a copy of a constant
length between two allocas at constant offsets moves each source slot the copied bytes hold
whole to the destination slot at the same distance, along chains of copies, and the
destination slot takes the source slot's pointers in the plan's union-find (nullness flows
from source to destination). It is a slot copy only where neither cell has a generic access
at an unknown offset, no slot straddles either end of the copied bytes, every destination
slot inside them is a moved one and the source is not open; any other copy still writes its
bytes, and a copy from an open cell opens its destination as before.

Tests (canon::tests::generic_pointers): a struct holding a generic pointer, 7 and null copied
whole, and copied on again, is loaded as the device pointer stored with its queries answered;
a copy that splits a slot, and one into a struct read at an unknown offset, still refuse as
Memory.

Verified in the lane: a negative control with generic.rs, generic/cells.rs and generic/plan.rs at their
base refuses the whole-struct copy test while the splitting and unknown-offset test still passes
(m3-max-34173); clippy in all three configurations, rustdoc and the metal2vulkan-air suite 572/572
(34187, 34188). A release linked census of 265 system kernels (34178): 244 translate (was 234),
slowest 1.20 s, largest 198.8 MiB.
2026-11-15 17:02:04 -08:00
Anees Iqbal e8d0bfc33c heap_carried_reads: a heap shadow's decode expectations follow its twin
runtime_lane::heap_carried_reads::a_heap_s_carried_textures_read_as_outside_a_heap failed on the
Iris Xe (round c218071502, iris_lane_1_2): for ETC2RGB8 at Metal's heap answer, "two reads in one
command buffer, shadowed true: Counted { copies: 1, decodes: 0 }" and "a sample after
replaceRegion decoded nothing". ANV samples ETC2 itself, so that texture is a shadow of the heap's
bytes with no twin ("twin none" in its HEAPDECODE line). The test took every shadow to have one: it
asked decodes == copies of the reads and a decode after replaceRegion. Its counts are the
product's rule: read x2 copies 1 (one copy in, the second encoder carrying the image), sample 1,
blit+sample 1, replace+sample 1, as the same Iris's twinned 4:2:2 shadows copy (each plus one
decode). PHOENIX and lavapipe passed because RADV and lavapipe lack ETC2, so their ETC2 shadows
have twins.

Now the case reads whether its texture took a twin (carried-decoded-twin at its making, as its
HEAPDECODE line already did). The two reads in one command buffer must take exactly one copy in
for a shadow, decoded once with a twin and never without; before, a twinned shadow passed with
any number of copies. A Shared shadow's samples after replaceRegion must show a decode with a twin
and a copy in without one. An image in the heap's memory still decodes nothing. So a second copy
inside one command buffer fails both branches. The FORMATS and module docs say ANV samples ETC2.

Verified: the test passed on the Iris Xe (ANV, m3-max-34147: ETC2RGB8 shadows twin none, read x2 copies 1
decodes 0, replace+sample copies 1 decodes 0), PHOENIX (m3-max-34145) and lavapipe (m3-max-34118); clippy in
all three configurations and rustdoc passed (34118, 34146).
2026-11-15 16:55:52 -08:00
Anees Iqbal aaeb7fa475 SEMANTICS 2126, RUNTIME 2396: Static initializers evaluate integer vectors lane by lane
A static initializer's integer arithmetic, comparisons and casts of vectors were left
unevaluated (the folder's integer folds take scalars), so a module whose initializer builds a
vector global from its function constants refused at specialization: Unsupported
StaticInitializer. MPSCore's stitchable functions are such modules (their initializer stores
<4 x i32> and <4 x i8> globals built from two ushort constants by scalar bit tests inserted
into undef vectors and a zext of a <4 x i1>), so every kernel linking them, 257 of the census's
265 refused MPS rows once linked, refused there.

Folder::lanewise applies a scalar integer fold to each lane of constant vectors of the result's
lane count; the static-initializer interpreter takes it for integer binops, icmp and integer
casts. A vector with an undef or otherwise unknown lane is still not evaluated (the module is
refused as before). SCCP's folds are unchanged: only static initializers evaluate vectors.

Test: canon::tests::static_vectors builds that initializer's shape (lanes inserted into undef,
scalar compares into <4 x i1> then zext, trunc/lshr/and of a scalar, and splat/lshr/and/icmp/
zext/trunc on vectors throughout) and checks the kernel's stores fold to the lanes' values;
a vector with an undef lane still refuses.

Verified in the lane: canon::tests::static_vectors 2/2 and a negative control without the fold
(it refuses); metal2vulkan-air clippy clean and its suite 570 passed (m3-max-34114); a release
linked census of the 265 refused MPS rows with this commit (m3-max-34128): 234 translate and pass
spirv-val, slowest 0.39 s, largest 199 MiB.
2026-11-15 16:44:14 -08:00
Anees Iqbal 44904ec1fe Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 16:43:07 -08:00
Anees Iqbal 7049627f79 RUNTIME 2395: Managed no-copy buffers: the caller's promise of zero bytes is zeroed on the device, not copied in
What: `HostMemory::with_zero_from(offset)`, a runtime extension with no Metal counterpart. The
caller promises that a no-copy buffer's bytes from `offset` to its length read zero when it is
made (a buffer its program made with no bytes, or with fewer than its length). A `Managed` one on
a device without unified memory then makes its GPU copy's bytes from `offset` to the length as
zeros the device writes in its own memory (one word-aligned vkCmdFillBuffer registered before the
making's copies in, `Buffer::zero_device_copy_first`). Only the bytes before the offset, and the
rest of the last page past the length, are copied in from the pages, so no import is held for the
zeros. New counters: `WorkCounts::managed_device_copies_zeroed`, `managed_bytes_zeroed`. Nothing
else takes the promise: a buffer that lies in its pages, a copied host buffer's first read, heaps,
rebinds, recoveries (the pages' `made_of` parts keep no promise), `did_modify_range` and
`synchronize_resource` behave as before.

Why: on a discrete GPU behind a 4.8 GB/s link, a compute workload's 131 ms GPU job was the making
copy of six new `Managed` buffers (631 MB across the bus, 12 MB of it named by
`did_modify_range`), and a 72 ms kernel wait for the imports preceded it. A guest's buffer made
with no bytes holds zero pages, which the consumer knows and the runtime cannot.

How verified: tests::managed_copy_device's zero-promise legs (through an import and over pages no
import maps): no promise, and a promise at the length, copy the pages in whole (negative control);
a promise from byte 0 over zero pages copies in and stages nothing, counts one zeroed device copy
of the buffer's bytes, reads zero, and a later did_modify_range copies in as ever; a promise from
an offset inside a word over pages that hold other bytes copies in exactly the bytes before it and
reads zero from it, which only the device's fill can have written. A buffer in its pages reads
them under the promise. The device runs are in the lane's jobs (lavapipe, which has unified
memory, runs only the in-place leg; the XTX runs the two-copy legs).
2026-11-15 16:42:22 -08:00
Anees Iqbal 48c7296fcb device_copies: a did_modify_range step whose calls outlasted its busy work is asked again
runtime_lane::device_copies::exact_answers_take_a_did_modify_range_at_the_commit failed once on the
RX 7900 XTX (round c218071502, m3-max-33927): "the runtime's, step 4: the busy work ended first".
Each oracle step commits about 2 s of busy work (8 links of 250 ms at the kernel's measured rate)
and then makes its calls; the end mark reading 0 as they return is the step's premise, that the GPU
has not run its command buffer yet.

The cause is the host, not the runtime. Host times around each act (probe jobs) show no act waits
on the GPU at ef313200e2 or at c218071502: from the busy work's first commit to the mark check a
step took 13-47 ms alone on the XTX and 5-36 ms in its lane leg 2/2 (m3-max-34065), against links
that spun 240-268 ms each (their GPU times, about 30 samples). On the RX 550 (m3-max-34044, 3 runs
of each sha) per-act times swung with the node's load, the busy work's commit from 3 to 280 ms,
equally at both shas. c218071502 passes alone and in the lane; the failure was one step in one of
8 XTX rounds, in a leg whose node's 16 CPUs also ran the RTX 2080 runtime suite, the PHOENIX
replay and lavapipe 2/4. round.py now runs one round job per node, so rounds no longer pack suites
so; this guards the nodes we don't control.

The window cannot be stretched to fit a host: its length rests on a rate measured once, and Vulkan
does not promise that a running shader sees the host's release (on the XTX alone the first link
never saw it and spun its whole cap). So a step now asserts its premise and asks again, as
device_room's with_room does for a device: runtime_lane/busy_premise.rs's until_premise_held runs
a try, and where the busy work ended before the calls returned the try still checks the bytes it
read (one of the answers allowed whatever the timing), writes a LANE-BUSY-MISS line with each
act's host time, the calls' total and each busy command buffer's GPU time
(BusyWork::gpu_span), and runs the step again with fresh busy work, at most 3 tries. A step that
misses every try fails with each try's times, so a call that waits for the GPU's earlier work
still fails as before, and the next real miss shows which side moved.

Tests: busy_premise's a_held_premise_is_tried_once, a_missed_premise_is_tried_again and
a_premise_missed_on_every_try_fails (no GPU). docs/VALIDATION.md names the rule.

Verified: m3-max-34107 (msi) clippy -p metal2vulkan-validation --all-targets --all-features -D warnings under --cfg m2v_gpu, and on lavapipe 5/5 (busy_premise unit tests x3, device_copies exact_answers_take_a_did_modify_range_at_the_commit and a_did_modify_range_reaches_the_bytes_the_next_commit_finds). Running at landing: the XTX run (m3-max-34117).
2026-11-15 16:39:22 -08:00
Anees Iqbal f4082938de artifact tests: the translator's repro writer is a default-off diagnostic, not a runtime input
RUNTIME 2366 made the runtime's FALLBACK repro bundle (metal2vulkan-runtime/src/repro.rs) use
metal2vulkan::repro (ReproBundle, ReproDevice), so the runtime's inputs reached
metal2vulkan/src/repro.rs, which is neither a listed input nor a listed non-input:
candidate::engine::artifact::tests::the_runtime_sources_are_the_committed_ones failed in the
round at c218071502 (validation, m3-max-33994). The writer acts only where METAL2VULKAN_REPRO_DIR
names a directory and its bundle changes no run's answers, as env_vars.rs's diagnostics, so it is
listed with them as reached but not a runtime input; the runtime-sources pin is unchanged.
2026-11-15 16:04:43 -08:00
Anees Iqbal ddb4bcbfaa Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 16:02:32 -08:00
Anees Iqbal f143091069 RUNTIME 2394: an owned kernel is looked up under the lock and made outside it
Device::owned_kernel held the device's owned-kernels lock across a
kernel's whole making: its module's build and its VkPipeline's
creation, which on ANV can take hundreds of milliseconds to seconds.
So every lookup of a kernel made already waited for an unrelated
kernel's compile: an encoder's rows copy, ICB reset, shadow copies and
merges, YCbCr sample and index kernels on encoding and committing
threads, ycbcr_conversion and made_ycbcr_conversion at a texture's or
a pipeline's creation; and route_counts_kernel's try_lock answered None
while any making ran, so the frame's routed draws took the region-copy
route. The pool's begin_draw_replay_kernels makes three kernels in a
row and begin_route_counts_kernel one, each a trigger.

Now the lock covers only a lookup, a settle and a Y'CbCr conversion's
creation:
- A kernel made is answered at once.
- A kernel in flight (OwnedKernels::making, one InFlight per kernel) is
  waited for: its asker waits on that making's answer alone, holding no
  turn of the budget's (budget::without_turn lends a pool piece's), and
  takes the same kernel or a clone of the same error. No second compile.
- Otherwise the asker records an InFlight, lets the lock go, takes its turn
  (program_turn: what helper_turn took once the kernel was known
  unmade), builds, makes the sampler of a YCbCr or 4:2:2 sample kernel
  under a short lock (the order and the one conversion per sampler that
  the views and the samplers baking it share, as before), and makes the
  objects. Its settle, under one lock, counts the kernel
  (WorkCounts::owned_kernels_made, as before), keeps it, and removes the
  making from those in flight, then answers the waiters. A making whose
  thread unwinds is settled with an internal error by its guard, so no
  asker waits for ever. A failed making is not kept: a later asker makes
  it again, as before.
- route_counts_kernel locks (briefly) in place of try_lock: it answers
  Some once RouteCounts is made, whatever else is being made.

keep_nothing (device/carry.rs) is a LOST generation's recovery step: the
line serves past it, its objects were carried to the new generation,
none of its command buffers records, and no work is made on it again;
it destroys the generation's owned kernels (OwnedKernels::destroy sets
`destroyed`). The only other caller of destroy is DeviceShared's drop,
which no making can overlap (a making holds a &Device). Before, destroy
waited on the lock for a making in flight and then destroyed its kernel;
now a making settled after it destroys its kernel at once and answers
Error::DeviceLost, which is what that generation is. A live device never
has `destroyed` set, so no asker on a live device that got a kernel
before gets DeviceLost now.

The test hold: it stays a field of OwnedKernels (a kernel and a Held,
the same Held type device/holds.rs holds its holders with) rather than
a Holds slot. The holds of device/holds.rs are indexed by Holder, the
runtime's own holders of a device, and are passed in holds_go_on
between a holder's steps, before a making starts, where the lock is not
held. This hold must stop one kernel's making midway (between its
module's build and its objects), on whatever thread makes it, the pool's
or a program's, and be read under the same lock as the lookup, so it is
keyed by the kernel where the kernels live.

The test grows a same-kernel check: a second asker of the held kernel
is seen waiting on its making in flight (a test-only count), the hold
has one making at it, and once let go both askers take one pipeline,
one kernel made.

Verified: at the base f310ebe9ee the test failed on lavapipe (msi job
m3-max-33983: the lookup waited past 5 s, the routes' kernel answered
unmade). This commit's runs follow in the lane's report.

Test: tests/owned_kernel_lookups.rs holds one kernel's making midway and asserts that a made kernel's lookup on another thread returns at once with the same pipeline, that route_counts_kernel answers Some, that a second asker of the held kernel waits on its making, and that the release makes exactly one kernel.

Verified: lavapipe on msi (llvmpipe, LLVM 23.1.1): at the test alone (f310ebe9ee, m3-max-33983) owned_kernel_lookups fails ('a made kernel's lookup waited past 5s for another kernel's making'; the routes' kernel answered unmade); at 2a52418bfc (m3-max-33993) clippy -p metal2vulkan-runtime --cfg m2v_cpu_icd --all-targets --all-features -D warnings 0, and 71/71 tests (owned_kernel_lookups, owned_kernel_builds, owned_pushes, rate_mapped_route_kernel, driver_pipeline_compile, the 15 teardown_threads tests, ycbcr_device, ycbcr_in_place_loop, ycbcr_refresh, described_row_copies, shadow_merge_read, surface_two_planes, icb_carry_race, rate_mapped_*, mipmap_plan). Running at landing: plain and --cfg m2v_gpu clippy, rustdoc. Not run on hardware GPUs; the stall is shown with a deterministic hold, not timed on ANV.
2026-11-15 16:01:47 -08:00
Anees Iqbal 8fee9b86f8 partial_threadgroups: the heavy kernel keeps 8 values live, not 400
ANV's compile time grows with the values live at once. At 94f9436cd8 the heavy test failed on
the Iris Xe (ANV, Mesa 26.2.6; Iris job m3-max-33948): at 10,000 steps with 400 values live a
command buffer waited past the test's 60 s WAIT for its pipelines, and the test failed at that
wait after 224.8 s. With 8 live the same driver is fast at that size: in the same job the
large-kernel test, whose chain is 8,000 steps with 8 values live, made its states' variant and
plain pipelines and passed in 3.6 s in all, and 40,000 steps with 8 live took about 52 s
(m3-max-33783).

WINDOW is now 8. STEPS stays 10,000, which keeps the kernel large by the runtime's measure, and
the test still asserts that premise (`ComputePipelineState::whole_on_partial`: `COUNTED_WORDS`
SPIR-V words or more) for each state it makes. The 400 came with the test and no measurement
chose it. The test's name and docs still say what it checks: the variant's one VkPipeline
against the split's six, with their creation times printed.

Verified at 5a39d9a75f: m3-max-33966 (msi) clippy -D warnings for metal2vulkan-runtime (all targets, all features) plain, --cfg m2v_cpu_icd and --cfg m2v_gpu. Running at landing: the heavy test on the Iris.
2026-11-15 15:51:04 -08:00
Anees Iqbal 18b14cca39 line_beside: a write beside a plane over Private memory keeps its bytes under the plane's writes
On the Iris Xe (ANV), whose GPU writes back the whole 64-byte line its writes end in, a plane's
texture at 0x20 of a Private buffer is in place for RenderTarget and ShaderWrite while another GPU
command may write the bytes beside it in the plane's first and last lines. A device test
(tests::line_beside, under the GPU cfgs) puts two commands with no dependency between them in one
command buffer: a render pass's clear and store, or a kernel's writes, of an R8Unorm plane at
0x20 (a buffer laid by aligned_byte and a plain one; tight rows of 1920 and padded rows of 1000
at 1024; tracked and untracked), and a blit copy or kernel stores into bytes 0x0-0x1f and the
bytes after the plane's last texel to the end of its line; it reads the buffer back. A control
leaves the second command out and must count every one of its bytes lost.

docs/FAST-PATHS.md's Iris known gap now says the line write-back holds over the runtime's own
memory as over host pages (the check's Pooled, ExportedFd and ExportedDmaBuf classes fail renders
for rows that end inside a line, m3-max-33545), and that another GPU command's bytes in the line
are kept.

Verified: Iris m3-max-33919 (ANV, Mesa 26.2.6): 0 bytes lost in all 32 cases x 3 rounds, the
controls counting exactly the left-out bytes ([32, 64], [32, 32], [32, 24], [32, 56]), 0 wrong;
lavapipe m3-max-33912 the same; clippy -p metal2vulkan-runtime --all-targets --all-features
-D warnings under --cfg m2v_gpu (33920), --cfg m2v_cpu_icd (33921) and plain (33926). The doc
commit had cargo fmt only; tests::fast_paths runs on development.
2026-11-15 15:44:07 -08:00
Anees Iqbal 94f9436cd8 partial_threadgroups: the heavy kernel is 10,000 steps, asserted large by the runtime's measure
On ANV (Mesa 26.2.6, the Iris Xe of RPL-P) the heavy kernel's 40,000-step chain took the driver
about 52 s to make with 8 values live (Iris job m3-max-33783: the first ragged grid done at
53.76 s, one VkPipeline) and more than 120 s with the test's 400, and the test makes seven
pipelines of it, so it ran for minutes there. Its compiler took about 3.2 MB of stack for that
chain (3,216,936 bytes measured), about 80 bytes for each value; the runtime now makes every
driver compile on a stack with that room (RUNTIME 2392), so the chain's length no longer stands
in for the stack guard, which tests::small_stack_device and the relay's and the pool's unit
tests cover.

STEPS is now 10,000, and the test asserts the premise that keeps it heavy by the product's own
measure: each state it makes is large (`ComputePipelineState::whole_on_partial`, the module at
`compile_memory::COUNTED_WORDS` SPIR-V words or more), so a smaller chain cannot pass the test
vacuously. LARGE_STEPS (8,000, window 8) already meets that measure, so 10,000 holds it with room.

docs/FAST-PATHS.md records the driver's time and stack as a device gap, with what the runtime
does about the stack: the pool's threads start with 8 MiB, and a call asked for on a thread with
less than 4 MiB of stack left is made on a thread of the runtime's started with 8 MiB.

Verified: an msi job's clippy (plain, --cfg m2v_gpu, --cfg m2v_cpu_icd) and the ledger tests,
and an Iris job running tests::partial_threadgroups (the heavy test prints its ANV times) and
tests::small_stack_device from this commit's archive.

Verified at a96a3ef68d: m3-max-33936 (msi) clippy -D warnings for metal2vulkan-runtime (all targets, all features) plain, --cfg m2v_cpu_icd and --cfg m2v_gpu; metal2vulkan tests::fast_paths 34/34. Running at landing: the heavy test and small_stack_device on the Iris (m3-max-33948).
2026-11-15 15:38:35 -08:00
Anees Iqbal 911692b55d Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 15:32:11 -08:00
Anees Iqbal 2163335121 RUNTIME 2393: a dma-buf source is asked once per texture after its standing refusal
A texture over a no-copy buffer's pages imported as dma-bufs tries its image in place with each
of its plans (wider usages first, its own last) and asks the caller's source for each plan's
pages. On RADV PHOENIX (Mesa 26.2.6) an RGBA8Unorm ShaderRead texture tries four, so a source
that refuses pages past udmabuf's list_limit was asked four times for the same pages
(texture_shadow_bench, m3-max-33878: source calls 4.00, refused 4.00 a texture); a consumer's
trace logged 1,620 such refusals over 765 textures, 367 ms in all.

The runtime cannot infer that one refusal answers a wider range: a source may accept exactly a
range it keeps a dma-buf of, or a wider one split otherwise. So the source marks it: a new public
DmaBufStandingRefusal (a runtime extension), returned as its io::Error, stands for every range
that holds the refused one for the rest of that texture's making. bind_dma_buf_image reads it into
DmaBufRefusal::Source { stands }, and in_place_image refuses each later plan whose request holds
such a range with that refusal, its unbound image released, the source unasked. Plain errors
behave as before: each plan is asked.

Documented in DmaBufSource's and DmaBufStandingRefusal's rustdoc, docs/HOWTO.md's dma-buf section
and the runtime README; api_signatures blessed (the type, new, Display, Error). REFUSALS.md
regenerated, unchanged.

Test: tests/dma_buf_standing_refusal.rs, on a device that imports no host pointer: a source of
plain refusals is asked once per plan, a standing one once, and one that refuses plainly then
gives the pages makes the texture in place on the second ask.

With it, a test-only release bench (ignored, --cfg m2v_gpu, Linux with /dev/udmabuf), tests/texture_shadow_bench.rs: an RGBA8Unorm ShaderRead texture over a no-copy buffer of a sealed memfd's pages, in place over one dma-buf against a shadow over more runs than one udmabuf lists, used by one or two dispatches that read or sample every texel and dropped, at four sizes, with a blit and a Private sample as references, printing host, GPU and CPU time, submission counts and the WorkCounts of each part. Its source marks its list_limit refusal as standing.

Verified: compiled in m3-max-33918 (msi, release lib-test archive under --cfg m2v_gpu). Running at landing: lavapipe (dma_buf*, no_pointer_import, host_residency, texel_rows, texture_placement) in 33918, clippy x3 next, and a PHOENIX run of the new test and the bench (the 4 -> 1 asks on RADV expected, unverified). The bench's numbers (PHOENIX m3-max-33878 um790, 33898 gem10) came from 2fe80f0a64 and d06fa76b74.
2026-11-15 15:31:24 -08:00
Anees Iqbal c218071502 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 15:08:29 -08:00
Anees Iqbal 495aa80968 RUNTIME 2392: a driver's compile runs on a stack with room: the pool's threads and the compile relay start with 8 MiB
On the Iris Xe (ANV, Mesa 26.2.6) two runtime tests aborted with "has overflowed its stack":

- tests::partial_threadgroups::a_heavy_kernel_s_ragged_grids_pay_one_creation, on a pipeline pool
  thread (std's default 2 MiB stack). Under gdb (m3-max-33742) the thread held 25,972 frames and
  2,090,624 bytes when it overflowed, 25,922 of them one function of libvulkan_intel.so, 80 bytes
  each: ANV's compiler recurses about 80 bytes deep for each value of a chain of dependent
  values. The kernel's chain is 40,000 values long, so its vkCreateComputePipelines takes about
  3.2 MB. Our frames above the driver's entry point there are 13 KiB.
- tests::small_stack_device::a_device_is_made_used_and_released_on_a_thread_with_a_small_stack, on
  a 256 KiB thread. Device creation's priming (prime.rs) compiles its kernel through
  vkCreateComputePipelines on the caller's thread: 204 KiB of our frames in this debug build
  (assemble 108,864 bytes, create_on 52,560, Primer::objects 24,688) and then ANV's compile, 52 KiB
  of its frames (one of 49 KiB) when the stack ran out. vkCreateDevice itself took about 55 KiB,
  and the fill, commit and wait at most 74 KiB of the thread (painted stack probe, 33742).

Metal compiles in a service of its own, so no program's stack takes its compiles. Every driver
call that may compile already goes through device/compiles.rs's at_user_initiated
(vkCreateDevice, vkCreateGraphicsPipelines, vkCreateComputePipelines, priming's included):

- this_thread::stack_room reads the room left on the calling thread's stack, where its stack ends
  read once a thread: pthread_getattr_np + pthread_attr_getstack on Linux,
  pthread_get_stackaddr_np - pthread_get_stacksize_np on macOS, GetCurrentThreadStackLimits on
  Windows (gnullvm and msvc alike, windows-sys's Win32_System_Threading), none elsewhere.
- at_user_initiated runs the call on the asking thread only where it is at the user-initiated
  class (macOS) and its stack has COMPILE_ROOM (4 MiB) left; else on its relay thread, which now
  starts with COMPILE_STACK (8 MiB, glibc's default thread stack, which Mesa's own compile threads
  use) on every OS. A Linux or macOS main thread still compiles in place; a Rust thread's 2 MiB,
  a macOS secondary thread's 512 KiB and a Windows main thread's 1 MiB hand the call over, at one
  thread start and join per call. The relay is the one macOS's class already used, unchanged: it
  raises its class to user-initiated on macOS, makes the one call inside an exit-guard section
  with the asking thread's measured diagnostics, holds the driver's messages for the asking
  thread's sink, is joined before the call returns, resumes the call's panic on the asking
  thread, and where no thread starts or the process is exiting the asking thread makes the call.
- The pipeline pool's threads start with COMPILE_STACK, so their pieces' makings run on them.

The stacks are address space; the system commits their pages as they are touched.

Tests: device::compiles::tests::a_pipeline_asked_for_on_a_small_stack_is_made_on_a_stack_with_the_room
(a fake driver reports the room and thread its call ran on: asked on 256 KiB and 2 MiB threads
it runs on the relay with at least 4 MiB left, on an 8 MiB thread on the asking thread; without
the room check it runs on the 256 KiB thread and fails), and
pipeline::pool::tests::a_piece_runs_on_a_stack_with_the_room_a_compile_takes. The existing tests'
asking thread now has the compile stack, so their in-place assertions still hold.

The relay test expects by the room the asking thread has: glibc reuses a cached stack of up to four times the size asked, so a 2 MiB thread may hold the 8 MiB a previous relay thread left and rightly compile in place; the 256 KiB thread must relay and the COMPILE_STACK thread must not.

Verified at a4d5ec0cdf: m3-max-33801 (msi) clippy -D warnings for metal2vulkan-runtime (all targets, all features) plain, x86_64-pc-windows-gnullvm, x86_64-pc-windows-msvc, gpucfg and cpuicd; device::compiles + pipeline::pool unit tests 14/14; the negative control (room check removed) fails at the 256 KiB thread ('made on the asking thread true, 251975 bytes of room'); lavapipe small_stack_device and the two non-heavy partial_threadgroups tests 3/3. Iris (m3-max-33783, the same stack code plus inert probe hooks): small_stack_device passes; the heavy kernel's vkCreateComputePipelines ran on an 8 MiB pool thread at 3,216,936 bytes deep (13,449 ours) without overflowing. The heavy test still takes ANV about 52 s a pipeline at 40,000 steps; its step count follows in its own commit.
2026-11-15 15:07:38 -08:00
Anees Iqbal ad0a4907fc dispatch_work: the changed-only push test makes its pipeline first
Its first encoder's first dispatch recorded later, in a segment of its own, while the pipeline
was being made: the next dispatch pushed whole into the encoder's new VkCommandBuffer and the
segment kept the second encoder from folding (lavapipe, m3-max-33792: [2, 2, 2, 2, 2, 0], 0
folded). One dispatch completed first makes it. The ANV rule PushedSetZero follows is draws'
in render/bound.rs (Bound::pushed_set's forgotten flag).
Verified: m3-max-33819 (msi) clippy -p metal2vulkan-validation, lavapipe 14/14: writes per dispatch [2, 0, 2, 2, 2, 0] with 1 encoder folded pushing, [0, 0, 0, 0, 0, 0] with push withheld, outputs checked under the validation layer.
2026-11-15 15:05:58 -08:00
Anees Iqbal 7caf91a180 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 15:04:51 -08:00
Anees Iqbal 617ebd26d6 RUNTIME 2391: the rate map's route-counts kernel is made ahead on the pool, never on the encoding thread
The encoder's end built the route-counts kernel inline (owned_kernel): a VkPipeline made on the
encoding thread behind a program turn of the pipeline budget, which can wait behind the pool's
makings. On the PHOENIX (RADV, release, probe m3-max-33749) end_encoding took 0.83 to 0.90 ms with
the kernel built there, against 0.22 to 0.27 ms with it made before.

A pass's first draw the GPU routes now begins the kernel on the device's pool, once per device
(Device::begin_route_counts_kernel, holder RouteCountsKernel). The encoder takes it as it ends
only where it is made, without waiting (Device::route_counts_kernel, a try_lock). An instance
whose kernel is not made by then runs no steps: its draws' counts keep what the CPU wrote
(fan-out 0, region-copy MAX_SEGMENTS), so each draws its region-copy route, as a draw whose other
routes did not record does. rate_map_gpu_routed_draws now counts an instance's marked draws as its
steps are planned, so routed equals fanned plus copied whether or not the steps ran. The device
tests' hold array takes its length from the last holder (it had three places, so the kernel's
pool piece indexed past it under the GPU cfgs).

Test: rate_mapped_route_kernel holds the pool while a frame's routed draws begin the kernel and
asserts the encoder made no kernel, routed none, drew every draw by its region-copy route (2897
red, 16 region-copy draws), and that once the kernel is made the same draws are fanned out over
the same pixels ([16, 16, 0]).

Verified at 7ed2805004: m3-max-33791 clippy (runtime, all targets, all features), runtime unit
tests 79/79, lavapipe rate_map device tests 25/25 (depth_equal 0 red in every leg), and the
negative control (the kernel made inline again: the new test fails, 1 kernel made in the held
frame); m3-max-33818 clippy under m2v_cpu_icd and m2v_gpu. PHOENIX (m3-max-33813, release, two
runs): cold end_encoding 204 / 182 us (166 / 158 us with the kernel made before; 826-896 us
before this change), the kernel made on the pool in the cold frame (0.30 ms, off the encoding
thread), the second frame routing 64/64; cold through commit 6.0 / 5.8 ms against 5.8 / 5.2 ms
premade.
2026-11-15 15:04:06 -08:00
Anees Iqbal 738c2bb358 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 15:00:12 -08:00
Anees Iqbal c20a99ca94 RUNTIME 2390: compute dispatches push only the set-0 writes that changed and keep the bound pipeline
A compute dispatch pushed its whole set 0 and bound its pipeline at every dispatch, though draws
already push only what changed (render/bound.rs). On ANV a dispatch's push and the flush of the
dirty push set cost most of the ~5.7 us a dispatch its committing thread spends there beyond
lavapipe (the Iris sizing run, committer 8.5 us a dispatch of the textured shape).

Now an encoder keeps what its dispatches recorded at the compute bind point of its
VkCommandBuffer (binding::PushedSetZero): the pipeline bound last and set 0 as pushed with a
pipeline layout. A dispatch binds its pipeline only where another is bound and pushes only the
writes that differ from those set 0 holds, none where none does. It holds only while nothing
else recorded into that VkCommandBuffer since the encoder's last such dispatch (a count of the
encoder's recordings, bumped by every command, barrier, copy run and gather run that takes it);
another VkCommandBuffer, any other command (which forgets it explicitly), a flat dispatch's
preprocess, set 0 bound from a set and a dispatch of another layout forget it. Each encoder
begins it empty, so an encoder folded into the group's VkCommandBuffer (encoder_fold.rs) pushes
its first set 0 whole, and a dispatch recorded later into a segment of its own pushes whole.

Vulkan's rules it rests on: vkCmdPushDescriptorSet, "Push descriptors can be updated
incrementally and cause shaders to use the updated descriptors for subsequent bound pipeline
commands ... until the descriptor is overwritten, or else until the set is disturbed"; Pipeline
Layout Compatibility, binding a set N disturbs a lower set only where the layouts are not
compatible for it, and binding a pipeline disturbs none. Where the driver's pushed descriptors
go stale across a pipeline bind (RuntimeDriverDefect::PushedDescriptorsStaleAfterPipelineBinds,
ANV), the dispatch binds its pipeline before the push and pushes at least one write after each
bind (set 0's first where none changed), as a draw does; a later region that binds another
pipeline pushes one again.

WorkCounts::dispatch_set_zero_writes_pushed now counts the writes carried (none for a dispatch
whose set 0 is unchanged); dispatches_pushing_set_zero still counts each dispatch of a pushed
set 0.

Tests: tests::pushed_set_zero (carry, forgetting, the stale rule); the device test
runtime_lane::dispatch_work::dispatches_push_only_the_writes_that_changed: writes per dispatch
[2, 0, 2 | 2, 2, 0] over two encoders folded into one VkCommandBuffer (encoders_folded 1), the
second's first dispatch of the buffers the first's last pushed carrying 2, and every output's
words checked, under the validation layer, both ways.

Verified: clippy -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features -D warnings in m3-max-33792 (msi). Running at landing: the lavapipe tests (33792) and the negative control at the base plus the test alone (33803); the Iris A/B follows.
2026-11-15 14:59:27 -08:00
Anees Iqbal c711ed7092 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:48:52 -08:00
Anees Iqbal c2206c14b0 RUNTIME 2389: Device::import_shared_dma_buf imports a shared dma-buf ahead and keeps it while a handle lives
A runtime extension (Metal has none). A guest's buffers over pieces of one shared file of guest RAM
were each imported as their own dma-buf import and freed with the buffer, so a compute loop that
made and dropped no-copy buffers paid an import and a free per command buffer, and on RADV each
import maps its pages at once (the next submission's CS waits for the page-table job).
Device::import_shared_dma_buf(file, options) (unix) imports the whole dma-buf on the caller's
thread, or joins the device's live import of it, and returns a SharedDmaBufImport; while a handle
lives, the file's entry in the device's map keeps the import, so buffers over its pieces join it
instead of importing again, and it is freed once its last buffer, heap and handle have gone (one
kept import per file a live handle names, per generation). The class comes from `options` as a
no-copy buffer's (Private, Memoryless and undefined options refused, Invalid StorageMode); the
import takes the type a no-copy buffer of that class would get first, so pieces join it.
Refusals use the existing kinds (Unsupported HostMemory, OutOfMemory). A device's recovery lets go
of the lost generation's kept holds and seeds the new one's map, whose first buffer imports the
file again; nothing is imported on the recovering thread. A device without a dma-buf importer
keeps nothing (Debug: imported false). The handle imports whether or not the device's buffers over
those pages take the dma-buf route: on a device that takes the pages' pointer it is one listed
dma-buf a submission for nothing. WorkCounts::dma_buf_shared_imports_kept gauges the kept imports;
the handle's import counts in dma_buf_imports. Docs: rustdoc, dma_buf.rs Shared files, HOWTO
dma-buf section, the runtime README extensions and unix-only lists. REFUSALS.md: the StorageMode
site moved to host_class, which the no-copy call and this one share.

Public surface: Device::import_shared_dma_buf, SharedDmaBufImport (Send + Sync, consumer_auto_traits)
and WorkCounts::dma_buf_shared_imports_kept, blessed in api_signatures.tsv.

Verified: m3-max-33745 at the lane tip 856a1fabae: clippy plain, m2v_gpu, m2v_cpu_icd 0; rustdoc 0;
lavapipe runtime suite 2836 passed. Device tests (lavapipe): three buffers made and dropped in turn
take imports 1 / joined 3 with the handle, imports 3 / joined 0 without; a handle keeps a live
buffer's import; recovery imports nothing and the next buffer's import stays kept; Private refused.
Churn bench, PHOENIX (RADV 780M, release, interleaved, 450 command buffers an arm, a8f297bf11, the
same code but the count): no handle 1 import + 1 free a command buffer, call median 820-907 us, GPU
start median 3026-3037 us; handle kept 0 imports, 0 frees, 1 join, call median 25-69 us, GPU start
median 104-145 us.
2026-11-15 14:48:09 -08:00
Anees Iqbal af37f92d91 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:46:37 -08:00
Anees Iqbal 9dc44438fa RUNTIME 2388: WorkCounts count the uses a compute dispatch's tracking walks
What: two default-on counts, one relaxed add each per compute dispatch that records (compute.rs,
before its command_reaching or command_later): the dispatches whose uses hazard tracking took, and
those uses (each resource range the command reads or writes, those reached through what the
encoder made resident among them). Uses over dispatches is what a dispatch's tracking walks
(command_reaching, track, order_as, touch_reaching). Listed in the host_ab example's counts; the
dispatch_work lane test asserts four tracked dispatches of at least two uses each.

Why: a guest compute benchmark's dispatches cost 7 to 38 us each on a Radeon 780M, most of it
inclusive under command_reaching, track, settle_live and order_as, which scale with the uses a
dispatch reaches; the repository's dispatch bench reaches 5 and costs about 1.2K instructions
there. No count said how many uses the costly dispatches reach (dispatch_used_resources_listed
counts listings of what an encoder made resident, not uses per dispatch).

Verified: m3-max-33750 (msi) at the lane tip b7ed24d9a8: clippy (runtime + validation, all targets, all
features) 0; lavapipe runtime_lane::dispatch_work passes (4 dispatches tracked 8 uses, push and bind devices).
clippy m2v_gpu / m2v_cpu_icd and rustdoc follow.

Public surface: WorkCounts (for the lanes) gains dispatches_tracked and dispatch_uses_tracked, blessed in
api_signatures.tsv; a struct literal of WorkCounts must name them, Default and readers are unaffected.
2026-11-15 14:45:43 -08:00
Anees Iqbal 79d9325e44 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:44:32 -08:00
Anees Iqbal aa5e196575 read_twin_device: wait for the in-place check wherever the policy keeps textures in place
On lavapipe (msi job m3-max-33699, the test binary at d7e7eca11f) three tests made their
textures while the device's in-place check was still pending ("pending 2" in the counts), so
the textures and their twins were shadows and "the texture's twin made, in place" read 0:
a_private_bit_buffer_s_texture_is_read_in_place_by_a_kernel,
a_private_bit_buffer_s_texture_is_sampled_in_place_by_a_draw and
a_texture_twin_bound_without_the_slots_proof_is_refused_and_would_reach_the_pages. The tests'
device waited for the check only where its memory types export (fd_buffer_types), which
lavapipe's do not, so whether the check answered before the first texture was a race the
loaded host lost.

device_with now settles the check wherever the policy takes textures over host pages in place
too (Device::settle_in_place_checks), as it did on exportable devices.
2026-11-15 14:43:52 -08:00
Anees Iqbal fd9a9373f4 read_twin_device: the shadow-log shape runs under RADV's plane rule, as its siblings
On the Iris Xe (ANV) the_shadow_log_names_a_twin_not_in_place_and_a_dispatch_s_first_read
reached neither line ("the shape reached neither line on this device", read_twin_device.rs:993):
ANV takes the 64x64 BGRA8Unorm texture at rows of 272 bytes as an explicit
DRM_FORMAT_MOD_LINEAR plane, so its read twin and the texture both lie in place (made: twins 1,
not in place 0, pitched 1). The product is right; the premise "no driver lays rows at 272" did
not hold.

The test forces RADV's rule for such a plane on its own device (`linear_pitch_rule_forced`,
256), as the sibling tests of the same shape (`refused_twin`, REFUSED's (0, 64, 64, 272)) do,
so neither lies in place on any device, and asserts both lines' preconditions exactly: one twin
not in place, the texture a shadow.

Verified: see the lane's report (Iris probe job and the msi build with lavapipe runs).
2026-11-15 14:43:51 -08:00
Anees Iqbal 0d6c6ce5d4 aligned_byte: the control asks the plane's image alignment, not the line-bound answer
On the Iris Xe (ANV) the plane R8Unorm 3840x2160 at byte 0x20 of a buffer made without the
aligned-byte option was in place ("off the alignment without the option", aligned_byte.rs:207).
The test asserted a shadow wherever
`Device::minimum_linear_texture_alignment_for_pixel_format` answers more than 32 bytes. That
answer is at least the device's line of memory (`nonCoherentAtomSize`): ANV answers its 64-byte
line, while its linear image of the plane binds 32 bytes into memory, and the runtime makes a
texture under the answer in place where the device's image takes its layout (as documented).
The product is right; the premise confused the line with the image's alignment.

The control now asserts the shadow where the memory alignment of the device's linear image of
the plane (`VkMemoryRequirements::alignment`) does not divide 0x20, read through
`Device::linear_texture_memory_alignment`, a test-only query that makes the same image
`linear_texture_bytes_per_row` makes (one code path, `own_linear_image`). The public API is
unchanged. The print names both alignments.

Verified: see the lane's report (Iris probe job and the msi build with lavapipe runs).
2026-11-15 14:43:51 -08:00
Anees Iqbal 735834e304 kept_padding: the device's own linear pitch is a texture's only where Metal takes it
On the Iris Xe (ANV, Mesa 26.2.6) four kept_padding tests failed. ANV lays the linear rows of the
tests' textures tight: an RGBA8Unorm image 101 texels wide at 404 bytes a row, a BGRA8Unorm one
65 texels wide at 260 (`Device::linear_texture_bytes_per_row`, the driver's
`vkGetImageSubresourceLayout` row pitch, as documented). Neither is a multiple of 16, which
Metal's `bytesPerRow` must be, so no texture lies at the device's own pitch there:
`Buffer::new_texture` refused 404 (`RowPitchAlignment { bytes_per_row: 404, alignment: 16 }`,
kept_padding.rs:336), and the blocks tests' premise "rows of the device's own pitch hold
padding" failed at 260 (kept_padding.rs:667). The product's answers are right; the premise held
only where the driver pads linear rows to a multiple of 16 (lavapipe, RADV, NVIDIA).

The own-pitch checks now run where that pitch is a multiple of 16 (as padding_unobserved.rs
already does); on ANV each of 416, 448 and 512 is checked as one of the other pitches (a shadow,
or in place with its first move kept). The two blocks tests of the texture at the device's own
pitch print that none lies there and return; the past-pitch test lays rows 256 bytes past that
pitch rounded up to 16 (unchanged where it is a multiple of 16: 528 on ANV).

Verified: see the lane's report (Iris probe job and the msi build with lavapipe runs).
2026-11-15 14:43:51 -08:00
Anees Iqbal 144cad9488 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:38:15 -08:00
Anees Iqbal 9c7013f60b RUNTIME 2387: host RAM copies: a dispatch writes its own imports alone into a partially bound import array
What: the pages copy's owned kernel makes its first storage-buffer binding, the array of
PagesCopyModule::imports(device) imports, VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT where the
array holds more than one and the device enables descriptorBindingPartiallyBound (the runtime
enables it wherever the device has it: device/enables.rs, Vulkan 1.2 features). Each dispatch of a
copy then writes (pushes, or writes into its set) only its own imports, then the buffer's window
and the table: OwnedKernel::first_written accepts a set that writes 1 to the array's length of the
array's elements where the binding is partially bound, every element elsewhere, and buffer_place
places the rest after them. Without the feature the elements past the dispatch's imports hold its
first import again, as before. The kernel's making text carries the flag.

Why: since RUNTIME 2322 every pages-copy dispatch wrote the whole array: on a device of 32 push
descriptors (ANV, RADV, NVIDIA, lavapipe: 30 imports) a dispatch over one import pushed 32
storage-buffer descriptors where 3 serve, through push_set's heap path (past 16 writes) and the
driver's vkCmdPushDescriptorSet, at every copy dispatch (358 to 813 a consumer's boot). No table
entry names an element past the dispatch's imports, so no invocation accesses one.

Vulkan: VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT "specifies that descriptors in this binding
that are not dynamically used need not contain valid descriptors at the time the descriptors are
consumed"; a push descriptor set layout takes it
(VUID-VkDescriptorSetLayoutBindingFlagsCreateInfo-flags-03003 forbids such a layout only
UPDATE_AFTER_BIND, UPDATE_UNUSED_WHILE_PENDING and VARIABLE_DESCRIPTOR_COUNT), and
descriptorBindingPartiallyBound must be enabled for it.

Test: host_ram_copy_device's a_dispatch_over_one_import_writes_its_own_descriptors_alone: rows of
4-byte texels in one chunk, one dispatch, the gathered bytes right, and the storage-buffer
descriptors the owned kernel's set or push wrote (a test-only thread-local count,
owned_kernel::buffers_written) 3 where the array is partially bound, the array's length and 2
elsewhere (32 before this change on lavapipe).

Verified: m3-max-33702 (msi) at the lane tip 238fde9d64: clippy (runtime + validation, all targets,
all features) 0, rustdoc 0; lavapipe host_ram_copy_device 32/32 (m3-max-33686, the same tree before
its rebase), "an array of 30 imports, partially bound true: 3 storage-buffer descriptors written";
PHOENIX (RADV, carried m2v_gpu archive of 238fde9d64) host_ram_copy_device 32/32, 3 written
(m3-max-33733); negative control (the whole array written again) fails the new test with 32
(m3-max-33700). clippy m2v_gpu / m2v_cpu_icd in 33722.
2026-11-15 14:37:33 -08:00
Anees Iqbal 0d87e8e26e Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:27:22 -08:00
Anees Iqbal a2a46d52fd RUNTIME 2386: WorkCounts count the descriptor writes compute dispatches push
What: a default-on count beside dispatches_pushing_set_zero, one relaxed add of the push's write
count per pushing dispatch (compute.rs), so writes over pushes is the descriptors a compute push
writes. Listed in the host_ab example's counts; the dispatch_work lane test asserts every push
carries the same writes, at least one, and that writes are counted exactly where pushes are.

Why: on the consumer's Iris Xe, binding::push_set's instructions over a guest compute benchmark's
timed pass rose 21-36% between two runtime pins with the same Mesa (26.2.6), almost all of it
under compute dispatches' pushes, inside the driver's vkCmdPushDescriptorSet. Whether each push
carries more descriptors, or more dispatches push, needs both counts; draws already count theirs
(set_zero_writes_pushed).

Verified: msi m3-max-33677 at the lane tip 9794e48d50: clippy (runtime, all targets, all features) 0;
lavapipe runtime_lane::dispatch_work::dispatches_push_their_set_zero_where_the_device_pushes passes both
ways (4 pushes carried 8 descriptor writes / 0 pushes carried 0). clippy m2v_gpu/m2v_cpu_icd and rustdoc follow.
2026-11-15 14:26:41 -08:00
Anees Iqbal 82ebc34ae1 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:21:39 -08:00
Anees Iqbal 4ee4deb737 RUNTIME 2385: a heap's 4:2:2 texture, a shadow of the heap's bytes, keeps a decoded twin
A heap's GBGR422 or BGRG422 texture lies as a shadow of the heap's bytes in Metal's rows (its answer
is Metal's measured rows: 512 @ 16 for 16x16, 8192 @ 16 for 64x64), and heap_texture_at excluded
4:2:2 textures from the decoded twin RUNTIME 2382 gave other carried formats' shadows, so every
kernel read and sample of one was refused, NotImplemented(Format) (56 refusals on PHOENIX and on
lavapipe, m3-max-33636 / 33625), where Metal reads it and the device can decode it.

heap_texture_at drops the 4:2:2 exclusion: the shadow keeps the twin with_decoded_twin chooses for
the device, through the device's conversion of the pairs where it converts them (rule 1), else
Metal's decode, one whole-image pass recorded after each copy in that moves its rows, its kernel made
at first use. A 4:2:2 heap texture cannot lie apart from the heap's bytes (held_to_metal sends rows to
Shadow or refuses with HeapTextureMemory; Unaliased is for one-plane and two-plane formats only), so
every 4:2:2 heap texture over device memory now keeps a twin; one over the caller's host pages, and a
detached heap's stand-in, stay twinless and refuse reads. Docs: chroma_pairs.rs contract,
decoded_twin.rs, degradation.rs CarriedDecodedTwin (doc and cost: "moves the blocks or rows"),
docs/API.md; first_use's lines say "decode passes set at the making N, their kernels made at first
use"; the HEAPDECODE line names a missing twin "none".

Verified: PHOENIX m3-max-33671 (carried archive of the lane tip 4976a40be3): 5/5 (heap_carried_reads
with GBGR422 and BGRG422 16/64 Private/Shared under both heap answer policies, new_resources_wait_for_
no_gpu_work, a_carried_heap_texture_reads_its_bytes_with_no_commit, four_two_two_heap_textures_take_
metal_s_size_and_layout, a_texture_held_for_copies_a_kernel_s_handles_reach_is_announced_once): every
4:2:2 case shadowed, a use 1 copy and 1 decode, a second encoder 0 and 0; kernel reads, samples,
samples after a blit and a Shared replaceRegion, blit out and getBytes equal the texture outside a
heap; route: Metal's decode (RADV and lavapipe convert no 4:2:2 pairs; the device-pair route in a
heap shadow ran on no device). lavapipe msi 33635: the same 5. Control (test commit alone): PHOENIX
33636 and lavapipe 33625 fail with the 56 refusals. Clippy plain, m2v_gpu, m2v_cpu_icd and rustdoc 0
(33635); runtime lib tests in 33672.
2026-11-15 14:20:58 -08:00
Anees Iqbal fc99097390 rate_mapped_pieces_encoder: the frame's device fans out
The lane's device options ask for exact answers, RateMapRegionPolicy::Exact among them, and the
encoder frame did not set the policy back, so its draws went region by region through each
region's own viewport: on the Iris Xe (job m3-max-33608) every frame printed 0 draws through the
region-copy variant and 0 routed on the GPU, base and tip alike. It now sets FanOut, as the
pieces frames set their policy. A lavapipe probe of the same pass over the same map under the
default policy took the region-copy variant and the GPU's routes in every case (job m3-max-33629).
2026-11-15 14:18:50 -08:00
Anees Iqbal 1e143ae315 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-15 14:13:49 -08:00