Commit Graph
5946 Commits
Author SHA1 Message Date
Anees Iqbal dc77ffbb55 in_place_textures: the lent render targets' print keeps its line continuations
The IN-PLACE-LENT line of render_targets_whose_copies_lose_their_padding_lie_in_place
printed runs of spaces where its string's line continuations had collapsed when
it was written (lavapipe job m3-max-33512 shows them). Print only; no
assertion changes.

Verified: compiled under --cfg m2v_gpu by the clippy job that follows.
2026-11-15 13:40:10 -08:00
Anees Iqbal fb33065288 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 13:33:05 -08:00
Anees Iqbal 5813fe6743 RUNTIME 2381: a render target whose copies lose its padding lies in place
On the Iris Xe (ANV), a render target over host pages whose rows end
inside a 64-byte line (nonCoherentAtomSize) failed the in-place check's
renders: the clear and store, and draws, write back the line holding a
row's last texels whole, so a CPU write to the padding in that line can
be lost. Such textures were shadowed (733 in reims's walk: RGB10A2
66x66@512 572, RGBA16F 55, R8 49, A8 49, BGRA8 3). But the shadow keeps
nothing more: its copy back writes the same lines, and on this device a
plain buffer copy, a copy of texels into a buffer's rows and a kernel's
stores all write back that line too (Iris probe, job m3-max-33417:
clear+store 15/15 rounds changed padding bytes, draw 15/15, product
shadow copy back 14/15, buffer copy 15/15, kernel stores 6/6; every
changed byte in the row's tail line, none past it; rows on lines 0).

The check gains an access, Copies: a blit copies a zero texture's texels
into the class's buffer's rows while the CPU writes beside them (every
shape but the 3840x2160 surface; no rounds over the runtime's own
memory). A texture that renders over host pages whose rows' padding is
free (not declared unobserved), whose renders failed for its row ends,
now takes the verdict of renders that let that padding change where the
class's Copies failed for those row ends too (pending while they are),
announced as Degradation::LineWriteBack (line-write-back, Precision).
Copies failures carry across classes as the other GPU writes do. The
check notes each class and access's rounds' time. CHECK_VERSION 19.

Docs: FAST-PATHS host-pages row and a known gap for the Iris line
write-back (nonCoherentAtomSize 64; buffer copies, texel copies, kernel
stores, passes); API.md section 1 and the catalogue entry; the in-place
lane's VERDICTS 98 -> 112 and a lane test with the kind's site.

Verified: msi m3-max-33510 at the lane tip 47b06c9f0d: clippy (runtime + translator, all features,
all targets) 0; runtime tests 29/29 (the decision, a_texture_that_renders_lends_its_free_padding_
where_the_copies_change_it_too, carry, degradation_catalogue, degradation_sites, texture_placement);
translator api_signatures, fast_paths, api_surface 34/34; --cfg m2v_gpu archive of runtime +
validation built (33511). Pending: negative control 33520, lavapipe 33512, the Iris proof.
2026-11-15 13:32:18 -08:00
Anees Iqbal ecd43305a5 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 13:19:12 -08:00
Anees Iqbal 369835f951 RUNTIME 2380: the submitting thread's CPU time is read only where queue times are noted
RUNTIME 2379's WorkCounts::batch_submit_cpu_nanos and submit_long_call_cpu_nanos read
CLOCK_THREAD_CPUTIME_ID twice on every submission call on every driver. That clock is a system
call on Linux, not a vDSO read: 459 ns a read against the host clock's 19 ns (thread_clock_bench,
Ryzen 7 7840HS, Linux 7.3, fastest of 3 rounds of 1M reads, m3-max-33486), so 0.9 us a call always
on, against a whole NVIDIA submission call of ~12 us. The thread's CPU time is now read only where
the device notes queue times (METAL2VULKAN_QUEUE_TIMES, the existing default-off diagnostic); the
CPU fields read 0 elsewhere and their docs say so with the measured cost. The wall-time fields,
the long-call counts included, stay on. The long-call bench turns queue times on and gains its
unfenced arms (one VkCommandBuffer against 47); thread_clock_bench measures the reads.

Verified: msi m3-max-33490 at the lane tip 57e916e1c6: clippy (all features, runtime + translator)
0, clippy --cfg m2v_gpu 0, lavapipe kernel_end_device + submit_stalls 16/16 (the queue-times device
test checks the CPU time stays unread when not asked and is counted once asked).
2026-11-15 13:18:30 -08:00
Anees Iqbal e37fbf2c50 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 13:06:48 -08:00
Anees Iqbal f938dfae91 RUNTIME 2379: WorkCounts count the submitting thread's CPU time across the driver's submission calls
A guest compute loop's vkQueueSubmit calls on the Radeon 780M averaged 601 us, 293 of them 1 ms or
more in 32 s, and nothing told a call that works from one that waits on a driver without the stall
fact. WorkCounts::batch_submit_cpu_nanos sums the thread's CPU time (CLOCK_THREAD_CPUTIME_ID; on
Windows GetThreadTimes, sampled at the clock's ticks) across every call batch_submit_nanos times;
submit_long_calls, submit_long_call_nanos and submit_long_call_cpu_nanos count the calls of 1 ms or
more. Benches (test-only): a guest compute loop's submissions term by term, chained encoders and a
host-set event's wake, growth per VkCommandBuffer with fenced chains, import and free churn apart,
and long calls split by the GPU's work and the listed dma-bufs, with and without a warm-up spin.

Finding (PHOENIX, release, m3-max-33442): the long calls work, they do not wait: thread CPU is
about wall time in every arm (360 listed, 3 in flight: mean 867 us, 861 us CPU). A 500 us spin
before the call cuts it 7-12%, so most of the doubling after a 3 ms GPU step is cold caches.

Verified: msi m3-max-33446 at the lane tip f67314bade: clippy (all features) 0, clippy --cfg
m2v_gpu 0, submit_stall tests 12/12. Windows clippy not run (thread_cpu, the existing
GetThreadTimes path, only made pub(super)).

Public surface: WorkCounts (for the lanes, not part of the API) gains four pub fields, blessed in
api_signatures.tsv; a struct literal of WorkCounts must name them, Default and readers are unaffected.
2026-11-15 13:06:05 -08:00
Anees Iqbal d64e988624 host_ram_copy_device: the recovery test copies into a buffer made after the recovery
a_recovery_starts_a_ram_s_plans_and_their_tables_anew copied into a Shared buffer made before
recover_for_test(). Where the device keeps Shared buffers in pooled memory (the RX 7900 XTX on
RADV, whose check finds that a held import taxes submissions), the recovery leaves such a buffer
with the lost generation, as device/carry.rs documents, so the first copy after it was refused
with NotImplemented(MadeBeforeRecovery) (round ef313200e2, XTX runtime leg). The test is about
the RAM use's plans and tables, which the recovery carries; the copies after it now go to a
buffer made after it.

Verified: see the landing check job.
2026-11-15 12:54:02 -08:00
Anees Iqbal 4515cc0250 first_use: a heap making's name passed by value (clippy needless_borrows_for_generic_args)
Job 33403: clippy under --cfg m2v_gpu and m2v_cpu_icd flagged the borrowed
format! passed to Calls::time, which takes impl Into<String>.
2026-11-15 12:52:11 -08:00
Anees Iqbal ae895a5729 first_use: the heap's carried makings are PVRTC and ETC2, which take a twin; ASTC is refused there
The commit before made the heap's carried texture an ASTC_4x4_LDR one. A
heap refuses that texture where the device lacks ASTC
(NotImplemented(DecodedHeapTexture), job 33372 on lavapipe). A heap's 4:2:2
texture is a shadow of the heap's bytes (AliasRoute::MemoryShadow), so it
takes no twin and stages no decode. The heap's carried kinds that take a
twin in its own memory, and stage its whole decode as they are made
(heap.rs, decode_whole), are ETC2/EAC and PVRTC. So the timed heap makings
are now a PVRTC_RGBA_4BPP texture and an ETC2_RGB8 one. Every device but
PowerVR's carries PVRTC. The test prints the whole decodes those makings
staged (WorkCounts::block_decode_passes), which shows the route was taken.
The no-commit get_bytes test uses a PVRTC texture in a Shared heap. Its
rows are unpitched, as Metal takes PVRTC's.

Verified: nothing yet; the msi job (clippy x3, rustdoc, lavapipe) and the
PHOENIX run (tip x3 plus the control) follow.
2026-11-15 12:52:11 -08:00
Anees Iqbal eaaacae33e first_use: the staged whole decode is an ASTC heap texture's, which PHOENIX and lavapipe carry
A GBGR422 texture in a heap took no staged decode on PHOENIX: the control
(runtime at 18c640a85d) built nothing at that making, so the check could not
fail there without the fix. An ASTC_4x4_LDR texture in a heap is carried
where the device lacks ASTC (PHOENIX, lavapipe), and its making stages its
twin's whole decode (heap.rs, decode_whole), so the timed making and the
no-commit get_bytes test now use one. The 4:2:2 texture of its own stays
among the makings.

Verified: nothing yet; the msi job and the PHOENIX run (tip x3 plus the
control) follow.
2026-11-15 12:52:10 -08:00
Anees Iqbal 3b7bcfa367 least_queue_plan: the least plan's making the driver refuses under load is asked again
On the RTX 2080 (job m3-max-33373, 34 queue tests at 16 threads)
a_device_refused_once_takes_its_least_plan_where_it_takes_fewer_queues
failed: the stand-in refused the plan's 18 VkQueues as the test asks,
and the driver itself then refused the least plan's 3
(ERROR_INITIALIZATION_FAILED), the other test processes' devices
holding its channels, so the test read a refusal of a least plan that
takes fewer.

plan_room's wait is now a generic with_room (device_with_room is built
on it, unchanged in what it does), and the test asks the stand-in's
refusal and the least plan's making again while the driver's own
answer to the least plan is a refusal (two attempts on a GPU whose least
plan takes fewer), with the same pauses and bound and a
PLAN-DEVICE-ROOM line each. The probe's making again, where the least
plan takes no fewer, goes through device_with_room.

Verified: cargo fmt; build, clippy and the tests in the lane's jobs.
2026-11-15 12:39:51 -08:00
Anees Iqbal 187127bd04 Runtime lane: a making made again leaves the loader's errors about its refused vkCreateDevice behind
The 2080 lane leg 1/2 at c1747ff89 (job m3-max-33322, 1,040 tests,
830 s) waited 35 times for room, 12.0 s of pauses in all, and every
device it waited for was then made with its plan. 16 of those tests
then failed on the loader's errors, which the wait had left in the lane's
message list: kernel_textures x10, layered_passes, made_at_creation x2,
math_routines, mesh_commands and ycbcr_in_place. The loader reports each
refused vkCreateDevice as two errors through the instance's messenger
("terminator_CreateDevice: Failed in ICD ... vkCreateDevice call",
"vkCreateDevice:  Failed to create device chain."), and those come from
the making the lane drops and makes again, not from the device the
test keeps.

Messages::failing_kept and Messages::drop_failing_since: the lane marks
the failing list before each making, and where it makes that one again
it drops what was kept since the mark. The kept making's messages, the
layer's included, stay. validated_device_with and made_lane_device both
do it.

Verified: cargo fmt; build, clippy and the 2080 lane leg in the lane's
jobs.
2026-11-15 12:32:12 -08:00
Anees Iqbal 111a086b82 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 12:29:42 -08:00
Anees Iqbal c471372f87 RUNTIME 2378: Decoded twins: no making builds a decode kernel; a decode pass's kernel is made at its first recording or before the submission's lock
What: a DecodePass keeps what its sets bind as it is made; its kernel (TwinDecode, or a
4:2:2 twin's ChromaSample) and its sets are a FirstUse (owned_kernel.rs), made:

- by its maker where it records the pass at once: a blit's decode, and the decode a blit's
  write makes for a second twin, as the blit is encoded; a replace_region's own submission,
  before the submission;
- for every pass staged for the device's next submission (a heap texture's whole decode, a
  host call's staged copy's) or queued for a second twin (its whole decode, a host write's),
  by Device::make_pending_decodes on the submitting thread before the submission takes its
  lock: commit_as before the scheduler's section, submit_internal_taking before the device's
  internal lock. The passes are listed under the first-move registry's and the queue's locks
  and made after those are free, so a making that stages one never waits behind a compile; an
  atomic note, set after each registration, makes the walk one swap where nothing is pending.

Inside the sections, a submission takes no pass whose kernel is not made: a staged copy whose
decode is unmade waits for a later submission with every staged copy after it (the copies keep
their order), and a queued second decode stays queued. Such a pass was staged after the
submission's walk began, so its texture was made after the commit began, and none of the
submission's commands reads it. Each DecodePass::record debug-asserts that its kernel was
made. PairsSampling makes the device's conversion alone (made_ycbcr_conversion) and names its
kernel (module()), which surface_pairs' first-use making and the decode passes make.
make_second_twin no longer builds the kernel at the view's making.

Why: Metal's making compiles nothing. A carried texture's making in a heap compiled TwinDecode
(or ChromaSample), a 4:2:2 texture's making compiled ChromaSample where the device converts
its pairs, and a view of an ASTC carrier in its other colour space compiled TwinDecode. The
submissions record staged and queued decodes inside the scheduler's section (submit_batch,
record_second_decodes) or the internal lock (submit_internal_taking), so the compile goes to
the submitting thread before those locks, where no other queue's submission waits for it.
Where the cost lands: the first commit or internal submission after a carried heap texture's
making, a second-twin view or a carrier's staged write, once per device per decode kind.
commit's doc says so. A making whose staged decode passes the staging bound makes an internal
submission at once, as before, whose walk then compiles in that making.

Test: first_use's per-call built-nothing check covers three more makings: a GBGR422 texture
(a ChromaSample build where the device converts pairs), one in a heap (its whole decode), and
an ASTC_4x4_LDR texture's sRGB view (a second twin where the device lacks ASTC); the next
commit (a blit out of each 4:2:2 texture) takes the decodes, and the line names what the uses
built. a_carried_heap_texture_reads_its_bytes_with_no_commit: a GBGR422 texture made in a
Shared heap builds no kernel, then replace_region and get_bytes with no commit between read
the bytes written, the internal submissions among them making the staged decode first.

Verified (m3-max-33342, msi, at a13cf74a78): clippy of the runtime and validation crates (all
targets, all features, -D warnings) 0; lavapipe 376/376 of the first_use, heap, two-plane, YCbCr,
ASTC, chroma pairs, ETC, PVRTC, compressed-decode, first_moves, twin and encoder_fold tests;
first_use: no making built a kernel, the uses built 4; the carried heap texture's making,
replace_region and get_bytes built 0 kernels each and the bytes matched. The PHOENIX runs and
the device-configuration clippy follow on development.
2026-11-15 12:29:01 -08:00
Anees Iqbal 64ce708f46 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 12:28:15 -08:00
Anees Iqbal c37ea84558 RUNTIME 2377: Fresh pages on Windows: the class predicate no longer gates on unix
`class_takes_fresh_pages` answered `host_visible && cfg!(unix)`, a gate from
when `OwnPages::map` returned None off unix. b8bb06bcac gave Windows a
VirtualAlloc `OwnPages::map` (and the page-buffer blocks already use it there
through `own_page_types`), but left the gate. So on Windows no buffer took
fresh pages, even on a device that imports host pointers and whose submission
check found no import tax. In particular, an indirect command buffer's records
lay in pooled memory even under `IndirectRecordsPolicy::Carried`, where a
recovery's carry moves them and resets every command, where Metal keeps them.

Now the predicate is the class alone. Where the system maps no pages, or the
device imports none, the buffer lies where it would have (`OwnPages::map`
answers None; no importer). On unix the expression is unchanged. The module doc
cites VirtualAlloc's MEM_COMMIT zero guarantee beside mmap's.

Verified at the base (ef313200e2) on an Intel UHD Graphics 630, Windows driver
101.2145, gnullvm, --cfg m2v_gpu, each test in its own process (m3-max-33325):
tests::icb_carry_race::a_recovery_keeps_the_commands_the_cpu_encoded failed
("render command 0 (Lost)": [None; 4] against [Some(64), Some(80), Some(96),
Some(112)]); a_write_held_across_a_recovery_lands_on_the_records_it_keeps hung
(the pooled carry waits for the write the test holds); tests::fresh_pages failed
3 of 6 (no fresh-page buffer made where the device's check says they pay). The

Also in this landing (tests only): icb_carry_race's a_write_held never holds a write across a
pooled carry (it skips visibly where the device imports no host pointer, and fails at once where
the records still pool); device_recovery's Scratch makes a directory of its own per call, so each
recovery test gets its own device in one process (under cargo test's threads they shared one and
recovered each other's); host_ram_device's logged RAM fixture compiles only where its bench does.

Verified: UHD 630 Windows (m3-max-33356, at 38455c7259): the 7 icb_carry_race tests each alone and
all 7 in one process pass (each recovery generation 1; the carried tests print Kept);
tests::fresh_pages 6/6. Base controls m3-max-33325 and 33334 (above; in one process the 5 pooled
failed 3/5 on one shared line at generations 1-5). Lavapipe, cargo test in one process (33354):
the recovery family, icb_carry_race, icb_records_policy, fresh_pages, stall and labels 56/56. At
9d78e00e30: clippy plain, m2v_cpu_icd and m2v_gpu 0 (33360), Rustdoc 0 (33364).
2026-11-15 12:27:34 -08:00
Anees Iqbal ec88d92702 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 12:26:34 -08:00
Anees Iqbal da6cc554bb SEMANTICS 2125, RUNTIME 2376: Rate maps: a region-copy recording draws one row, its region its first's segments plus DrawIndex
A recording through the region-copy variant drew a box of several rows, so its vertex function
found its region as `first + (DrawIndex / c)·nx + DrawIndex mod c`: it read the table's count of
columns, divided by it and by the box's columns, and only then read its region's terms.

Now each row of a box is its own recording (in parts of at most a multi-draw's draws), and
`PushField::RegionBox` holds the row's first region's segments `[x0, y0]`: the vertex function
draws the region of segments `(x0 + DrawIndex, y0)`, dividing nothing and reading no table word
before its region's own, the row's `y0` the same at every vertex. A row is recorded a region at
a time where a sample may lie on a pixel's left edge (`folds` answers that axis alone: a row's top
and bottom edges are its scissor's). The pixels and positions are the route's as before: the same
copy arithmetic of the same region, under the same viewport, its row's scissor holding the
regions' pixels. A whole-table draw is 34 recordings where it was 2
(rate_map_region_copy_recordings). The docs, the FAST-PATHS fan-out row and the boxes test say
rows; the docs drop the cost claim the Iris A/B disproved.

Kept though neutral on the Iris: the shorter vertex function (42 instructions, 428 estimated
cycles, 8 sends -> 37, 258, 7) did not move the per vertex-region cost, which lies in the fixed
function after it (four user clip distances tested on every copy; 2073 of 2074 rejected there).

Verified: m3-max-33295 (msi, at 72bd8baa20): clippy of the translator and runtime (all targets,
all features, -D warnings) plain, m2v_cpu_icd and m2v_gpu 0; translator 47/47 and runtime
fan_out 6/6 unit tests; lavapipe 24/24 rate-map device tests. m3-max-33355 (ef59a08250, docs):
clippy plain and Rustdoc 0. Iris (ms01) m3-max-33332: 24/24 rate-map device tests
(region_boxes direct [3 draws, 39 recordings] against indirect [3, 624], 0 texels differ;
depth_equal 0 red). Negative control m3-max-33327: the base's divided region restored, the SPIR-V
divisions assertion fails (4 vs 0). Iris A/B m3-max-33262 (warm, no INTEL_MEASURE): whole-table
commit frame 671.1 -> 670.9 ms, Exact 505.7 -> 498.7 ms; per sub-draw 1.068 us + 0.3626 ns x V
-> 0.926 us + 0.3697 ns x V.
2026-11-15 12:25:53 -08:00
Anees Iqbal b6081e2c7e Runtime tests: a device of the queue plan is made again while the driver lacks room for it
On the RTX 2080 (job m3-max-33317, 31 queue tests at 16 threads) the
driver refused 10 of the 12 queue_share_device tests' devices their
queue plan, and the runtime made them with its least plan's 3
VkQueues; the tests passed on one shared VkQueue, so what they claim
about the plan's queues went untested. The runtime's own device tests
had no wait like the lane's (ef66c46a5f): on NVIDIA each VkQueue is a
channel, the 2080 holds about 210 across processes (11 devices of the
plan's 18, job m3-max-19615), and the suite's 16 processes ask more.

src/tests/plan_room.rs's device_with_room makes such a device again,
the one made dropped first, while the driver refuses it for want of
resources (Error::DeviceRefused) or it took its least plan
(DeviceShared::least_plan), with pauses doubling from 0.25 s to 2 s up
to 120 s in all, each a PLAN-DEVICE-ROOM line naming the answer and the
wait. Any other error returns at once; past the bound a refusal is
returned and a device still of its least plan fails its test, so a test
of the plan's queues runs on them or not at all. No lock and no
cross-process coordination.

Every plan-device maker in the runtime's tests goes through it:
blit_holds, caller_queue_writes, commit_and_submit, completion,
completion_wakes, draw_again, hand_out_waits, queue_limits_device,
queue_share_device (5), reserved_queues, scheduler_held_wakes,
scheduler_wakes, store_out_device and video_interop. Left as they are:
the least plan's own tests (least_queue_plan, reserved_queues'
a_device_made_with_its_least_plan_reserves_what_its_plan_spares), which
stand the driver's refusal in with refuse_next_devices; many_devices, a
GPU hazard that fills the GPU on purpose; host_ram_first_fill_bench's
ignored release benchmarks.

Test: plan_room::a_plan_device_refused_once_is_made_again_of_the_plan_s_queues
refuses the first making with the stand-in and asserts the device
helped back is of the plan's round robin and presenting queues (from
queue_plan over its families), not its least plan; a plain making
answers the least plan (NVIDIA) or a refusal (lavapipe, RADV) there.
docs/VALIDATION.md says the runtime's tests wait too.

Verified: cargo fmt; build, clippy and the tests in the lane's jobs.
2026-11-15 12:22:02 -08:00
Anees Iqbal 18c640a85d 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 12:09:12 -08:00
Anees Iqbal 00e1304a7c RUNTIME 2375: Owned kernels: a resource's own moves are made at its first use, never as it is made
What: a shared FirstUse cell (owned_kernel.rs) keeps what a resource's sets of one of the
runtime's own kernels bind as the resource is made; the kernel (once per device, as
owned_kernel's rule says) and the sets are made by make() at the resource's first use, as an
encoder plans a command that uses it (ShadowCopies::prepare), before any of its copies is
recorded. Every record takes them through made(), which debug-asserts that a use made them and
records nothing where none did. Three resources take it:

- the tiled heap texture's moves (HeapTiledCopies), which held this form inline;
- a heap's two-plane extended-range texture's moves (HeapPlaneCopies, RGB10A8_2P_XR10 and its
  sRGB twin, in a heap or over a surface's planes), whose making compiled TwoPlaneTexels;
- a 4:4:4 two-plane YCbCr texture's write shadow's write-back (YCbCrWriteBack), and a render
  shadow's load (YCbCrLoad), whose making compiled YCbCrWrite (and YCbCrConvert's float form):
  a heap set's float storage element makes that shadow as the texture is placed, so the
  texture's making compiled it wherever such a set lived.

Why: Metal's resource creation never waits for anything and compiles no pipeline; on a RADV
APU a compile beside busy GPU work took 10-43 ms in a heap texture's making (the tiled form's
probe). The compile now moves to the first encode that needs the moves, once per device, on
the encoding thread, not on the making's.

Test: first_use's check that no making builds a kernel of the runtime's own
(WorkCounts::owned_kernels_made, per call) covers two more makings while the busy work runs:
an RGB10A8_2P_XR10 texture in a heap, and a YCBCR8_444_2P texture over a surface's plane made
after a kernel that writes through an argument buffer ran (so the device's heap set lives and
its float storage element takes the texture's write shadow), where the device holds textures in
argument buffers. Each is used after (a blit out; a write through its handle), and the line
names the kernels the uses built.

Left: a carried texture's decoded-twin kernels (a 4:2:2 texture's pairs on a device that
converts them, a heap texture's whole decode, a view's second twin) still build at making;
the next change. A multisample heap texture's sample-move trial builds pipelines to decide its
route; a separate follow-up.

Verified (m3-max-33274, msi, at ab77f697ba): clippy of the runtime and validation crates (all
targets, all features, -D warnings) 0; lavapipe 292/292 of first_use, heap*, two_plane*, ycbcr*,
extended_range_planes, shadow*, surface_two_planes and owned*; first_use: the makings built no
kernel, the uses built 3. The PHOENIX runs and clippy in the device configurations follow on
development.
2026-11-15 12:08:30 -08:00
Anees Iqbal 84888808bd Runtime lane: made_lane_device compiles only where its device tests do
validated_device_with no longer calls it, so the lib build outside the
device cfgs warned it unused (msi job m3-max-33276); its two callers are
device tests (degrade_notices, resource_ids).

Verified: cargo fmt; build and clippy in the next job.
2026-11-15 12:06:07 -08:00
Anees Iqbal ab4dacce5c least_queue_plan: read the plan's queues from the queue plan of the device's families
On the RTX 2080 (job m3-max-33087, 18 queue tests at 16 threads)
a_device_refused_once_takes_its_least_plan_where_it_takes_fewer_queues
failed "the least plan took no fewer": it read the plan's round robin and
presenting queues from a device the driver had made, and under that load
the driver refused that device its plan too, so it had taken the least
plan's 1 + 0 and the test compared the least plan with itself.

The plan's queues now come from queue_plan over the device's queue
families, as reserved_queues::spare reads them, so the branch the test
expects (least plan taken, or refused) is a property of the families, not
of the load. The probe that reads the families is made as a loaded GPU's
driver makes it, refused its plan once by the stand-in (so of its least
plan's 3 VkQueues on NVIDIA, made again where the least plan takes no
fewer), and dropped before the test's own device: the test now
reproduces 33087's condition on every run and holds 3 channels, not
18 + 3. The LEAST-QUEUE-PLAN line names what the probe took.

Verified: cargo fmt; the tests on the 2080 and lavapipe in the lane's
jobs.
2026-11-15 12:06:07 -08:00
Anees Iqbal 760f8d045b Runtime lane: a device the driver refused for want of room is made again once other processes may have let it go
The 2080 legs of round 9ce951f521 failed 33 of 2,054 lane tests at device
creation: 27 devices of the queue plan that the driver refused (the
runtime then took its least plan and announced least-queue-plan, which
the lane's creation check rejects) and 6 lane devices of 3 VkQueues it
refused outright (Error::DeviceRefused, ERROR_INITIALIZATION_FAILED or
ERROR_OUT_OF_HOST_MEMORY).

Cause, measured: NVIDIA's driver gives each VkQueue a channel with an
instance block of its own, and refuses a device where it cannot allocate
one (the kernel logs "Could not create Channel"). A device of the plan
takes 18 VkQueues on the RTX 2080 (14 round robin, 2 presenting, the
staging and fill queues; its copy family's 2 queues put the copy queue on
the fill queue's), a lane device 3. With nothing else running the 2080
(NVIDIA 620.70.06) holds about 210 channels across processes: 11 runtime
devices of the plan and 3 of the least plan, the 15th refused (job
m3-max-19615), and 66 bare devices of 3 with room for 18 (19562). The
legs run 16 test processes, 188 of the lane's 408 modules make devices of
the plan, and nextest runs a module's cases side by side: 16 x 18 = 288
VkQueues. Lane 2/2's indirect_executions shards, 64 tests at the plan in
a row, took 22 least plans. Nothing leaks: each lane test is its own
process, every helper drops its device in a scope, and a runtime device
makes one vkCreateDevice whose queues its threads never add to.

Neither answer is the test's: its device is the one it asked for, and
the GPU lacked room only while the lane's other processes held theirs
(the runtime's DeviceRefused docs: a device asked for again once fewer
are live may be made). So validated_device_with makes such a device
again, the one made dropped first, after a pause doubling from 0.25 s to
2 s, for at most 120 s in all (runtime_lane/device_room.rs), and
made_lane_device does the same for a refusal. Only Error::DeviceRefused
and a least-queue-plan announced as the device was made are asked
again; any other answer returns at once, and past the bound the last
answer is handed back, failing the test as before. Each pause writes a
LANE-DEVICE-ROOM line naming the answer, the pause and the time waited.
No lock and no cross-process coordination: the driver's answer is the
only signal. The runtime's least plan and refusal stay its own tests'
(tests::least_queue_plan, the driver's refusal stood in for).

Tests: runtime_lane::device_room's unit tests (no device): a short
answer is asked again with doubling pauses until one has room; an answer
with room returns with no pause; one that never has room stops at the
bound. docs/VALIDATION.md's few-channels paragraph says what the lane
does now; degrade_notices' LEAST_PLANS says why no lane test keeps it.

Verified: cargo fmt; build, clippy and the tests in the lane's jobs.
2026-11-15 12:06:06 -08:00
Anees Iqbal ef313200e2 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 11:46:35 -08:00
Anees Iqbal bb21c14865 compute/live: name SamplerState where the debug check takes it, so a release build imports nothing unused
check_whole, the only user of SamplerState in compute/live.rs, is cfg(debug_assertions), so a
release build under --cfg m2v_gpu warned 'unused import: SamplerState' (live.rs:94), an error
under -D warnings (seen by the gbgap and ratemap3b lanes' release builds). The signature names
the type by its path and the import goes.

Verified: see the landing check job.
2026-11-15 11:44:21 -08:00
Anees Iqbal db50e74588 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 11:42:38 -08:00
Anees Iqbal 7098431fe0 RUNTIME 2374: Dirty pages: a command's run of uses of one key is noted at once
DirtyCommit::note did all its work once a use. A host RAM copy over 128 chunks of a RAM with
a log names 2048 writes, and each chunk's key has a log of its own (RamOnDevice::chunk_key):
each write searched `host` for its log (one entry a chunk's log, about 128), took a Vec of its
own in `reported`, looked its key up in the imports and upgraded the log's Weak again, and put
its key in `used` again. On msi's lavapipe that was 179 us of a 290 us call (release probe,
m3-max-33184, the layer bench's logged case).

note now takes each run of consecutive uses of one key at once: the key goes into `used` once;
its logs are looked up and upgraded, and their places in `host` found, once, at the run's first
write; each kept write's reported logs are a range of one flat list (reported_hosts) that the
run's writes share, so no write takes a Vec of its own. Each write is still kept apart (the
seen check of the last 8, `written`, WRITES) and noted in its logs' ranges (HOST_RANGES, the
whole past it) as alone: written, host, what report_host_writes tells and when are as before.
wrote_host is split into host_place and wrote_at; wrote_unreported reads a write's logs through
its range.

Test: runs_of_one_key_note_exactly_as_their_uses_one_by_one notes 300 generated command
buffers (runs, keys named twice, reads, repeated writes, keys of no log and of two, logs past 64
ranges) and one past 4096 writes and keys, through note and through note_each (the uses one by
one, test-only), and asserts the same NotedWrites: each write with its logs, the keys used, the
overflows and each log's ranges.

The test's evidence bound asks for more than 30 logs written whole past 64 ranges (the rounds
give 43).

Verified: m3-max-33195 (msi, at 65498cb639): the runtime crate on lavapipe 2822/2823 (the one
failure the test's own bound, lowered in d99df37c6a), clippy plain, m2v_gpu and m2v_cpu_icd 0,
Rustdoc 0; m3-max-33205 (at d99df37c6a): 49/49 dirty and host_ram_copy tests, clippy cpu-icd 0.
Release A/B (m3-max-33196, msi lavapipe, 3 interleaved pairs, the same probe on both, us a call,
128 chunks of a logged RAM): note_dirty 200.4/204.1/196.6 -> 75.8/86.6/79.7, the call 324.1 ->
204.4 mean; unlogged unchanged; the log told 4096 runs a copy in every run.
2026-11-15 11:41:52 -08:00
Anees Iqbal 79adf9aef7 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 11:36:03 -08:00
Anees Iqbal cdb708d35f RUNTIME 2373: Heap textures: a tiled heap texture's making builds no kernel; its first use does
What: HeapTiledCopies (a heap texture held as a shadow in Metal's tiles,
AliasRoute::Tiled, and the surface depth textures that use it) no longer
builds the device's TiledTexels kernel or writes its two descriptor sets as
the texture is made. They live in a OnceLock and are made at the texture's
first use, in ShadowCopies::prepare(), which the encoder's plan_shadows calls
before it records any shadow copy. That is the path a converted YCbCr
texture's conversion already takes. dispatch() debug-asserts that the kernel
was made. So the compile moves to the first encode that needs any tiled
shadow, once per device, as owned_kernel.rs's rule says ("made once per
device, when a command first needs it"). That cost is now on the encoding
thread, not on resource creation.

Why: runtime_lane::first_use::new_resources_wait_for_no_gpu_work failed three
times on the Radeon 780M (RADV PHOENIX), always at "new_texture in a heap",
which returned 0.7-0.8 s later, about 65-70 ms after the busy work ended, with
no internal submission. A probe on um790's PHOENIX (9 runs, 3 of them beside
the lane's partition 4/4) showed that this making takes 10-43 ms every time,
while every other making takes about 1 ms. Backtrace samples taken 4 ms into
the call (3 runs) sit in vkCreateComputePipelines under HeapTiledCopies::new,
via Device::owned_kernel(TiledTexels). It is the only timed call that builds a
pipeline. Expected, not verified (the long wait did not reproduce in the probe
runs, nor beside a VRAM hog): the 0.7-0.8 s is that compile waiting in the
driver or kernel for the GPU's in-flight work, on an APU with a 2 GiB carve-out
shared by the lane's parallel processes. Metal's makings compile nothing.

Test: the first-use test records WorkCounts::owned_kernels_made around each
timed call and fails where a making built a kernel. Without this change that
check fails wherever the heap texture takes the tiled route (the 780M:
verified). The test also prints the tiled-heap-texture count and the kernels
the later uses built, as evidence the path ran. The heap texture's copy in and
copy out still read Metal's bytes.

Left alone (main records it): owned_kernel holds the device's owned_kernels
lock across every compile, so a lookup of a kernel already built waits behind
another kernel's compile.

Verified (m3-max-33194, msi, at 01fe19ba22): clippy of the runtime and validation crates (all
targets, all features, -D warnings) 0; lavapipe 132/132 of first_use|heap*|shadow*, including
first_use::new_resources_wait_for_no_gpu_work and every heap_tiled unit test. The PHOENIX runs
(the cause's device) and clippy in the device configurations follow on development.
2026-11-15 11:35:22 -08:00
Anees Iqbal 8bd796ce4f Bench: the layer's download over every chunk of a RAM whose writes a log keeps
A VMM keeps a log of its guest RAM's writes on a discrete GPU, so a download into that RAM
records each command's uses for the commit's report to the log (DirtyCommit::note): a cost the
layer bench's RAM, which had no log, never showed. host_ram_layer_encode_bench now runs its
two cases (the layer in one chunk and over every chunk), lets that RAM go (its keep-alive
dropped, so two RAMs' pages are never held at once), then runs the layer over every chunk of a
second fresh RAM with a log (HostRam::with_dirty_pages of LayerLog, which counts the runs it is
told), alone and beside a fill as the others, and prints the runs the log was told a copy: the
evidence the logged path ran.

The case's body is layer(), shared by the three. host_ram_device gains fresh_logged_ram_in, a
fresh RAM with a log, beside fresh_ram_in (fresh_host_ram_of makes the RAM for both).
2026-11-15 11:28:16 -08:00
Anees Iqbal 87e6846abd 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 11:27:52 -08:00
Anees Iqbal ccf9d5847a RUNTIME 2372: Encoders: a command's joined runs go into the part's tracked uses at once, as note leaves them
order_joined's Joins::of copied every use of a joined run's kept tail into a `noted` list grown
from empty, and took each run's hull twice by folding whole uses; note then walked those uses one
by one (a map entry, a find over the key's ranges, a clone, the room for 9 at the second), though
Joins already holds the run's key new to the part and named once by the command. At a host RAM
copy over 128 chunks (2049 uses, 128 runs of 16) that was about 25 us in Joins::of and 25 us in
note a copy on msi's lavapipe (release probe, m3-max-33112).

Joins now keeps, for each joined run, its key and the list note leaves of it from none (the hull
of its first 9 + 8m uses, then each after, in one Few with room for 9 past the first, as note
reserves), and `noted` holds only the uses no run joined. order_joined orders by `ordered` and
notes `noted` through order_as as before, then puts each joined key's list into the part at once
(note_kept), the map reserved for them. A run's hull is the first's range hulled with the last's
(their bytes past each other: the first's start to the last's end) with the reads and writes of
all folded, no use moved per step. A run with an empty range is not joined (joins), so note's
merge of equal ranges never meets a joined run, and empty ranges order as before.
order, inside_uses and admit are unchanged; the plain path takes none of this.

Test: runs_of_9_and_20_uses_join_exactly_and_one_with_an_empty_range_does_not (a 20-use run that
note collapses at its 9th and 17th, a 9-use run, a buffer use; after a command and as the first;
ordered and not) asserts equal barriers, summaries and the next encoder's cross-queue plan against
order, and that the run with an empty range is not joined. The 600-round
runs_of_one_key_joined_order_exactly_as_their_uses keeps asserting the same over random commands.

Verified: m3-max-33153 (msi, at 83e47c807a): the runtime crate on lavapipe 2823/2823, clippy
plain, m2v_gpu and m2v_cpu_icd 0, Rustdoc 0. Release A/B (m3-max-33160, msi lavapipe, 3
interleaved pairs, the same probe on both, us a call at 128 chunks): note 25.7/23.2/29.3 ->
4.0/4.3/4.5; Joins::of unchanged (about 27); the call 132.0 -> 115.1 mean; one chunk unchanged.
2026-11-15 11:27:11 -08:00
Anees Iqbal b255317a37 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 11:26:06 -08:00
Anees Iqbal 09aee83953 RUNTIME 2371: Compute: a state keeps 16 plans; a lookup compares the latest four in place and keys only the rest
A dispatch takes what its state planned for its bind state's shape and class of grids while the
state keeps it among its latest PLANNED. A stream of dispatches over buffers of several length
classes in grids of several classes cycles more pairs than 4: the bench's moved, heap, ragged
shape of three length classes cycles 6 through 4 entries, so a fifth of its dispatches planned
again (plan_now 4.0% of the encoding thread on msi lavapipe, m3-max-33099). In the consumer's
profile of its compositor's fix-index encoder on the XTX (hvP2, at 2cdfa840b5) plan_now,
BindState::shape and position_of_shape were 25.2% of dispatch_threads, 64% of its dispatches
planned and 47% made their shape anew.

PLANNED goes from 4 to 16. Each Planned carries its shape's key beside its used resources
(BindShape::key_beside_used). A lookup (position_of, used by planned_shape and planned_of)
compares the latest IN_PLACE = 4 entries in place, as the state compared its four before; only
where none is the state's shape does it work out the state's key (which folds every argument
sampler's) and compare whole only the remaining entries of that key. planned_for's fallback,
past the Arc match, compares whole only entries of the shape's key. PLANNED's doc states the
bound: about 290 bytes an entry, and at most PLANNED entries' variants and region pipelines kept
past the state's memos. The dispatch_chain bench's --classes takes up to 12.

Test: grid_classes::shapes_and_classes_in_turn_each_plan_once (six shape-class pairs in turn for
six rounds: each plans at its first dispatch alone, every later one takes its plan, every slice
Metal's words); at PLANNED=4 it fails (grid_classes.rs:346).

Verified at 9b5717e840 (m3-max-33158, msi): clippy plain, m2v_cpu_icd and m2v_gpu 0, Rustdoc 0,
106 lavapipe tests of the compute paths, the PLANNED=4 control failing. Profile (m3-max-33180,
msi lavapipe): 48 samplers, 3 classes: no key pass, plan_now gone; 12 classes (24 pairs): the
keyed path runs. XTX A/B (m3-max-33162, 5 interleaved rounds, load 23, median ns a dispatch,
dev 0ab6927fce / this): no samplers 3 classes 4448/4272; 48 samplers 3 classes 5180/5122, 12
classes 7708/6423; 200 samplers 3 classes 6408/6435 (flat); plain 3753/3554; no samplers 12
classes noisy (median 6151/6547, min 5839/5220, least encode+commit 6166/5543).
dispatches_planned_as_before 0.80 -> 1.00 at 3 classes; at 12 classes 0.61 reused where dev
planned every dispatch.
2026-11-15 11:25:26 -08:00
Anees Iqbal 0ab6927fce 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 11:02:00 -08:00
Anees Iqbal c76dec3f57 RUNTIME 2370: Host RAM copies: a copy's imports name their chunks in one flat list, and a made chunk's import is taken without a list of its own
copy_imports built, per chunk, a Vec in a BTreeMap of the import indices that hold the chunk's
bytes, and for_copy returned a one-element Vec for every made chunk: at 128 chunks two heap
allocations a chunk on every copy, the kept plan's reuse included, before the plan's serials
and maps were compared.

CopyImports::of_chunk (and KeptPlan's copy of it) is now one Vec of (chunk, import index) pairs
in the imports' order, sized for one import a chunk up front. copy_imports takes a made chunk's
import itself, after take_for_copies still moved the window past every chunk left, and
for_copy handles only chunks not made. The reuse compares the two lists as before (same
imports in the same order, each holding the same chunks). The full path sorts a copy of the
pairs by chunk (stable, so each chunk's imports keep their order) and looks a piece's chunk up
in it (imports_of), in place of a table of every chunk's slice.

Test: each_chunk_s_imports_are_found_by_chunk_in_the_order_they_were_given checks imports_of
against the old per-chunk map over 200 generated import lists. The device tests of both copy
paths cover the rest.

Verified: m3-max-33083 (msi, at 9b59c25348): the runtime crate on lavapipe 2821/2821, clippy
plain, m2v_gpu and m2v_cpu_icd 0, Rustdoc 0. Release split at 128 chunks (m3-max-33086, msi
lavapipe, before/after interleaved, the same phase probe on both, us a call): copy_imports
23.1/25.1 -> 4.9/5.1, the reuse's compare 6.7/6.9 -> 2.5/1.9, the imports' drop 4.6/4.0 ->
0.8/0.9; the layer's call 156.7 -> 133.9 mean; one chunk unchanged (one slot).
2026-11-15 11:01:19 -08:00
Anees Iqbal 1328c20270 parity: the corpus path comes from the validation directory at run time, not the build machine's
corpus() joined env!("CARGO_MANIFEST_DIR"), baked at build time, so a carried test archive run
on another node read no Metal records (parity::sequences::lane::sequences_0..7 'no Metal record'
off msi, regr98's 31742). It now joins metal2vulkan_devtools::validation_dir(), as the
runtime lane's corpus readers do.

Verified: see the landing check job.
2026-11-15 10:54:57 -08:00
Anees Iqbal 48ce52b1b9 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 10:54:00 -08:00
Anees Iqbal 421ee18512 RUNTIME 2369: Compute: a dispatch holds its pipeline state, variant objects and pipelines by address first
Each compute dispatch held its pipeline state, its variant's objects and each region's
VkPipeline by another reference (an Arc clone) that Retained::shared then dropped where the
encoder held the object lately, as it does for every dispatch of the objects of the one before
it: an atomic increment and decrement of each object's count, on lines other threads touch too.
In the consumer's profile of its GL fix-index encoder Retained::shared was 3.3% of
dispatch_threads, 2.8% its own.

Retained::shared_of holds an object by the caller's reference, cloning it only where the encoder
does not hold it lately, the same address test shared makes (EncoderCore::retain_shared_of,
ComputePipelineState::retain_in); compute's record holds its three kinds so, and keeps a
reference to the variant's objects rather than a clone of them. ComputePipelineState::held,
unused now, is gone.

Tested: tests::retained's new a_hold_by_reference_takes_another_only_where_none_is_held_lately
(holds and strong counts of shared_of alone and mixed with shared, and the push-out of the eight
looked among).

Verified at 1480a5352c (msi-laptop-w3657): m3-max-33061 clippy plain 0, lavapipe 332 tests of
retained|held|holds|compute|dispatch|grid_|pending passed; m3-max-33066 clippy m2v_cpu_icd 0,
m2v_gpu 0, Rustdoc 0. XTX A/B (m3-max-33058, radeon, 5 interleaved rounds, load 17-23, median
ns a dispatch, dev f452591afc vs the cut on it): 200 samplers 6074/6156, 48 samplers 4738/4641,
none 4398/4357, moved heap 3493/3470: no measurable change in the bench, where the counts stay
in one thread's cache; the in-situ gain is expected only, for the consumer's next profile.
2026-11-15 10:53:14 -08:00
Anees Iqbal 981d3f5f4b 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 10:44:16 -08:00
Anees Iqbal 2332ae096e RUNTIME 2368: Host RAM copies: a kept plan's table goes into a buffer of its own at its first reuse, which each reuse binds
Each copy by a kept plan uploaded the plan's table into its command buffer's arena: 8100
entries of 16 bytes for a layer, past the arena's 32 KiB so a chunk of its own (a new Shared
buffer) and a 130 KB copy, 22.5 us of a 74 us call at 1 chunk and of 191 at 128 (probe
m3-max-32988, steelbrain/dl2-probe4, not landed), for bytes the plan held and never changed.

KeptPlan keeps them in a buffer of its own (table_kept, a OnceLock), made at its first reuse
by KeptPlan::table_buffer: the arena's class (Shared, default cache, untracked, by
unzeroed_buffer_with, so the GPU reads it from the same memory), written once before any
command reads it and never again. record_dispatches takes the table as bytes to upload (the
full path, as before) or as that buffer (Table::Kept), which each command buffer that binds
it retains, so a plan the LRU or the RAM's end lets go of frees it once they complete. Two
encoders' first reuses at once keep the one set first. A plan never reused makes none. The
tables count in MOST_PLAN_BYTES already, so the device memory kept is at most that and each
buffer's rounding. A recovery carries the RAM's use to a new RamOnDevice on the next
generation (RamUseCell::carry), whose plans start anew, so no old generation's table is bound.
New counter WorkCounts::host_ram_copy_tables_kept; api_signatures.tsv blessed; the module
docs, KeptPlan's and HOWTO's say what memory the plans keep.

Tests (device): a_plan_keeps_its_table_in_a_buffer_from_its_first_reuse (planned, first reuse
keeps it +1, later reuses +0, bytes each time); a_kept_table_a_command_buffer_bound_outlives_
its_plan (command buffers held by a shared event bind it, eight other copies push the plan
out, the bytes after the signal); a_recovery_starts_a_ram_s_plans_and_their_tables_anew
(recover_for_test: the first reuse after keeps a table of its own).

Verified: m3-max-33015 (msi, at 612f09e48a): the runtime crate on lavapipe 2811/2811, clippy
cpu-icd, plain and gpu configurations clean, Rustdoc clean; the API tests 15/15 (m3-max-33048),
whose recovery test printed no skip line. Medians (m3-max-33017, msi, before/after interleaved,
us per call): one chunk, copy alone 60.6/59.6 -> 44.4/41.6, the copy after a fill 58.1/58.2 ->
44.3/41.6; 128 chunks about 10 us lower on average, within the runs' spread.
2026-11-15 10:43:31 -08:00
Anees Iqbal cb44fd0030 dispatch_work: a grid of the planned one's class takes its plan, and a ragged grid plans again
RUNTIME 2363 lets a dispatch of another grid of the class a plan was made for (pipeline::GridClass:
form, threadgroup size, whole, one row) take that plan where it names the very variant for the
grid. dispatches_take_what_their_state_planned_for_the_same_shape still expected the step
"the grid" (THREADS to 2*THREADS at the same threadgroup size: both whole, one row) to plan again,
and failed at dispatch_work.rs:516 on lavapipe (found by the synchaz lane, m3-max-33014/33033).

The step now expects the first grid's plan (planned 1, settled 0), and a new step dispatches a
ragged grid (1.5 threadgroups, another class) of the same shape, which must plan again. The later
steps move up two threadgroups to make room for its words; the doc says what the test checks now.

Verified: runtime_lane::dispatch_work on lavapipe and validation clippy (plain and m2v_cpu_icd)
in the potluck job that reports this tip.
2026-11-15 10:37:54 -08:00
Anees Iqbal 5ac7852e20 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 10:37:42 -08:00
Anees Iqbal 85a91d182c RUNTIME 2367: Queue plan: a device made with its least plan reserves what its plan reserves, no more
The 2080 round 9ce951f521-1115-0907 failed
reserved_queues::a_device_with_no_queue_to_spare_reports_the_reserved_queue_absent:
"11 asked, 11 reserved; no message", where queue_plan(families, u32::MAX)
spares 10 (NVIDIA's graphics family of 16 less the round robin's floor of
four and presenting's two). Asked for 11, the plan takes 4 + 2 + 10 plus the
staging and fill queues, 18 VkQueues; the driver refused that for want of
channels (um790's kernel log: "kchannelAllocMem_GM107: Could not create
Channel" 19 times at 10:01 and 13 at 10:02, while the 780 s run that ended
10:04:38 was at the test), and made_within_resources took least_queue_plan:
queue_plan_within(families, options.reserved_queues, {1, 0}), a round robin
of one and reserved min(15, 11) = 11. 11 is what only that path gives.

So a device short of resources gave the caller more reserved queues than the
same device given them, and skipped the reserved-queues-absent message,
though the least plan's notice and the runtime README say it keeps the
plan's reserved queues. least_queue_plan now reserves as many as the
device's own plan (within options.queue_limits) reserves; its round robin
of one always leaves room for them, so no fewer either.

Tests:
- queue_limits::the_least_plan_reserves_what_the_plan_reserves: every
  family shape, reservation (0 to u32::MAX), limit and cached flag; fails
  without the fix on NVIDIA's shape asked for 11 (11 against 10) and on a
  family of 24.
- reserved_queues::a_device_made_with_its_least_plan_reserves_what_its_plan_spares:
  the plan refused through refuse_next_devices(1), the device asked for
  spare + 1 takes its least plan (its notice heard, round robin 1) and
  reserves spare, reporting the rest absent; refused where the least plan
  takes no fewer (lavapipe, RADV).
- The test sink records each message's id name with its text, so the
  least plan's notice is matched by its code.

Docs: the degrade catalogue (docs/API.md), LeastQueuePlan's rustdoc and the
runtime README's "A driver short of resources" say the reserved count is the
plan's.

Also: queue_share_device's pinned test takes a stay the sharing rule
explains, as its siblings do (test only).

Verified (msi, m3-max-33039): clippy plain 0; lavapipe reserved_queues,
least_queue_plan, queue_limits and the pinned test 16/16. The 2080 run
follows on development.
2026-11-15 10:37:01 -08:00
Anees Iqbal 30331a477f kept_textured: the spun copies wait for the spin through a fence
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::kept_textured::a_kept_heap_draw_reads_what_an_earlier_command_buffer_wrote
failed on 1024 reports (512 copies, two cases): "vkCmdCopyBufferToImage(): READ_AFTER_WRITE
hazard detected. vkCmdCopyBufferToImage reads VkBuffer ..., which was previously written by
vkCmdDispatch", copy regions from offset 64, 64 bytes each.

spun_copies encodes the spin's dispatches, which store their count in the source buffer's
first word (bytes 0..4), and then copies the texels from bytes 64 on. Its premise ("so the
copies follow the spin") was Metal's whole-resource tracking of the buffer. The runtime orders
a tracked buffer by the bytes, as its README's "Hazards" says:

  The runtime orders a tracked buffer by the bytes a command reaches: those its translation
  proves a shader reads or writes, else from the bound offset to the buffer's end. Vulkan's
  synchronization validation takes a shader's buffer as accessed over its whole descriptor,
  which spans those bytes widened to 16-byte granules from the device's offset alignment, so
  it reports hazards between commands whose bytes are apart, as it does between untracked
  uses Metal leaves to the program; no order of either changes a result.

So on the runtime the copies did not follow the spin, and the test lost the delay it was built
on (the frame's kept draws waiting for an earlier command buffer's late writes). The layer
reported the copies' reads against the dispatch's whole descriptor.

The spin's encoder now updates a fence and the copies' blit encoder waits for it: an order
Metal keeps too (redundantly, beside its tracking), and one the runtime records as a barrier
from the spin's compute stages (fence.rs, the tracker). The copies follow the spin on both,
and the layer sees that barrier. Spin::encode takes the fence to update; Spin::new's timing
runs pass none.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the reports
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal f67343b44e address_maps: the alpha-code rounds note their dispatches' apart writes
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::address_maps::every_alpha_code_of_a_texture_whose_alpha_reads_one_reads_one
failed on 65280 reports (255 pairs a round, 256 rounds) of one record-time hazard:
"vkCmdDispatch(): WRITE_AFTER_WRITE hazard detected. Shader stage VK_SHADER_STAGE_COMPUTE_BIT
writes to VkBuffer ..., which was previously written by another vkCmdDispatch command", binding
0 of rrp_sw_read_f.

Each round's 256 dispatches write o[0], a float4: 16 bytes each, CODE_STRIDE (256) bytes
apart, in one tracked buffer. The runtime binds the slot over the buffer and orders a tracked
buffer by the bytes the translation proves a shader writes (runtime README, "Hazards"). The
layer takes the whole descriptor as written. Writes that share no byte make no data race
(Vulkan's Memory Model appendix), so no order of them changes a byte, and the claim the test
stated (layer_reported_nothing_at_all) was wider than what the runtime promises.

Each round now notes its 256 writes (NotedWrites, one per round: the rounds write the same
bytes again, after the previous round's wait) and states
layer_reported_nothing_but_apart_writes, which lets a write after write between noted writes
pass only where no two of them share a byte.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the reports
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal b815e51395 Hazard parser: read a transfer command's access as the layer words it at recording
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::memoryless_uses::memoryless_compute_and_blit_uses_fail_as_metal_s failed in
its "unused" case on one write after write the layer reported as the fill was recorded:

  vkCmdFillBuffer(): WRITE_AFTER_WRITE hazard detected. vkCmdFillBuffer writes to dstBuffer
  VkBuffer 0x700000000070, which was previously written by vkCmdDispatch.

The fill writes mark 3 (bytes 12..16) and store_const the mark at 8 (bytes 8..12). The test
notes both, so the report is of the apart form its claim already lets pass (8 of the run's 9
reports passed so). The lane's hazard parser (parity::sequences::hazards::parse) wanted
"VkBuffer " right after "writes to " and returned None for the parameter name ("dstBuffer")
that the layer puts before the memory in a transfer command's record-time wording. The runtime
now records the blit encoder after the compute encoder in one VkCommandBuffer, so the layer
reports the pair as recorded and no longer in the submission form the parser read.

parse() now skips one word between the verb and "VkBuffer "/"VkImage ". parity::sequences'
lane reads the layer's hazards through the same parser, so it gains the record-time transfer
wording too.

Tests: the_lane_reads_the_layers_hazards parses the exact record-time fill wording above and
a read of a "srcImage VkImage"; apart_writes' a_fill_and_a_dispatch_apart_pass_either_way_round
judges the record-time fill wording apart. Both fail without the parser change.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the message
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal f452591afc 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 10:15:32 -08:00