Commit Graph
5620 Commits
Author SHA1 Message Date
Anees Iqbal 2818c1fcd0 RUNTIME 2303: a committing or waiting thread's pass leaves other queues' batches behind an unshared head it cannot send
A thread about to block (Scheduler::submit_before_waiting) or one that just committed with
commit_and_submit (Scheduler::submit_at_commit) takes the inbox in and submits only the batches
that need nothing of the scheduler's thread (submit_plain_ready, plain_ready). take_in counts
the unshared commit taken, so RUNTIME 2300's gate in plain() lets other queues' batches through;
Order::next puts the unshared queue's head first but skips any head `ready` refuses and goes on
to the next. So where that head is ready for the scheduler's own look but not plain for this
pass (a submission or scheduled handler for a waiting thread, a host step already recorded, a
switch of storage forms riding on it), another queue's batch on its VkQueue whose room had come
was submitted ahead of it, where the scheduler's pass sends the unshared one first
("Heads put first").

The rule: such a pass notes the VkQueue of an unshared head it leaves that the scheduler's look
would find ready (first_for_the_thread: nothing of submit_ready's holds, every event value
reached), and leaves the other queues' batches held back there to the scheduler's thread too
(left_behind_unshared), which its caller already wakes for what it left: that thread's next pass
sends the unshared one first and them next. Bound: one wake and one pass of that thread. An
unshared head not ready for that thread either holds nothing, as its own pass lets the batch go
then. submit_ready's five holds move into holds_back(), shared by both, with the same order and
the same counts; CommandBufferShared::held_back_on() factors what held_for_unshared and
unshared_commits both tested. No switch, no counter, no public item, no Degradation kind.

Not covered, a known limit now written in unshared_hold.rs ("Deferred commits"): a commit left
to the lowering thread under RenderLoweringPolicy::Worker; counting it posted at the call would
hold other queues' batches through the lowering backlog, leaving the GPU idle.

Tests (queue_share_device, lavapipe): a waiting thread's pass with the scheduler's thread held in
a submission handler (waiter_submits::Held, now shared) takes in an application's fill and an
unshared fill with a scheduled handler; a committing thread's pass (commit_and_submit, default
Grouped completion: the fill goes alone where the device groups) takes in an application's fill
while the unshared queue's dispatch waits with its host step recorded (the pool's making held,
the steps' thread held at new trace points Step and Stepped while the scheduler's thread is held
in a submission handler). Each asserts that the pass ran and that the unshared one began first.
Docs: unshared_hold.rs ("Passes of other threads", "Deferred commits"), FAST-PATHS unshared
isolation row, submit_plain_ready.

Verified (msi lavapipe, m3-max-29578 at 258953844d): clippy plain and --cfg m2v_cpu_icd 0;
91/91 of unshared_hold, queue_share, queue_share_device, scheduler, scheduler_held_wakes,
scheduler_wakes, inbox, waiter_submits, commit_and_submit, hold_sites, dispatch_pending.
Both new tests: passes 1, batches the pass submitted 0, the other queue's buffer began
0.100/0.108 ms after the unshared one. Negative control m3-max-29586 (rule off): both fail,
the pass submitted 1 and the other buffer began 0.35/0.34 ms before the unshared one.
2026-11-14 09:01:26 -08:00
Anees Iqbal 2216540a68 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-14 09:00:37 -08:00
Anees Iqbal d8666d430f RUNTIME 2302: render encoders record into the VkCommandBuffer of the encoders before them
A render encoder took a VkCommandBuffer of its own at every open, so a compute, render
and blit step began 2.71 and submitted 4 VkCommandBuffers per step (dispatch_chain
renders, lavapipe). A render encoder with a log of its calls now takes part in the
encoder fold:

- One whose pass records at its end (draws in a secondary) joins the group before it;
  one whose first instance records inline joins none and may lead a group.
- No barrier records inside a pass: a joined render encoder records one barrier from
  everything of the group's earlier encoders (FoldOrder::everything) at its open,
  counted in command_barriers.
- Color groups, rasterization-rate maps and a depth attachment out of GENERAL take no
  group; segments, fence updates and Overwrites end the group after the encoder.
  Logless devices keep one VkCommandBuffer per render encoder.
- A folded member's layout moves go before its group's first part (GroupPlaces).
- A check splits a group with a render member at its pass's submission (as RUNTIME
  2297 does for blits).
- A group's order is built as its second encoder joins, not as its first ends.

A/B (lavapipe, dispatch_chain, per step, base vs tip): renders 2.71 -> 1.35
VkCommandBuffers begun, 4 -> 2 submitted, GPU 119.5 -> 97.7 us; renders-apart
3.71 -> 1.00, 4 -> about 0, 143.6 -> 94.6 us; passes unchanged in buffers, the
encoder's open about 250-480 ns more on the host (the group an inline pass begins),
the whole pass within the host's noise.

Tests: tests::render_fold (device), tests::held_depth, shadow_runs' rebind expectation
(a rebind encodes a group whole). Docs: encoder_fold.rs, API.md, FAST-PATHS known gap
and ANV row.

Verified (msi, lavapipe): the full runtime suite 2683/2684 at c502efba29, the one
failure the race test fixed in ca5042567b; clippy plain and --cfg m2v_cpu_icd, rustdoc,
fast_paths 0. Negative control (the explicit order removed, renderfold-negctl): the
hazard tests fail on their barrier counts; lavapipe shows no wrong texel because it
completes each command as it runs, so the texel proof is a GPU that overlaps work.
2026-11-14 08:59:50 -08:00
Anees Iqbal a91629c1a6 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-14 08:57:35 -08:00
Anees Iqbal ca5042567b encoder_fold: the race test waits for the check's failure to be noted, not for its call
a_check_that_fails_a_submission_before_its_group_is_split_keeps_it_failed
let the commit's encodings again go once the check closure signalled from
inside its call. The scheduler notes the failure (State::fail_submission,
which marks the encoders unrunnable) only after the closure returns, so the
encodings again could build their units and splice the blit's in between:
the full lavapipe runtime suite at the render fold's tip (m3-max-29520)
counted 4 encoded again against 3. The blit still ran nothing there (the
failure, noted after the splice, cleared its part), so this is the test's
race, not the product's.

The test now holds the turn until the command buffer's failure is noted
(failure_noted, a test-only reading of State::failure, set under the state
lock after the encoders are marked), then lets the encodings again go.

Verified (msi lavapipe): encoder_fold 22/22; clippy 0 (--cfg m2v_cpu_icd and plain); control
m3-max-29567 (unrunnable marks removed) fails the test (4 vs 3).
2026-11-14 08:56:54 -08:00
Anees Iqbal 1a44a6d198 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-14 08:55:29 -08:00
Anees Iqbal 51e506adde RUNTIME 2301: an encoder holds once per command buffer what the encoder before it held
Each one-dispatch encoder of a folded group took its own references to every
object its command buffer already held (state, variant objects, the made
pipeline, the argument table's objects: about 7 Arc clones and a boxed holds
entry), and the completion thread then dropped those entries one per state
lock. A folded dispatch cost about twice a serial one on the host.

Now an encoder the program opens starts from what its command buffer's last
ended encoder held lately (16 addresses at most) and holds none of those
again. Encoders recorded apart (segments, encodings again, captures) start
empty and hold everything they name. Only complete_rest removes a command
buffer's retained entries (part completion clears only the SubmittedHolds
counters; failures and re-encodes add entries), so a seeded address names an
object the command buffer holds until it completes, across parts. Release
order is unchanged. Also a cheaper hand-on of the recent addresses at an
encoder's end.

Tests: tests::held_lately (8 encoders over the same objects give 1 holds
entry; an object an earlier part holds lives until the later part completes;
a seeded encoder re-encoded apart after commit_failed Set{1} keeps its
objects alive and writes its output) and a tests::retained unit test.
Negative control (the seed ignored): all four fail (8 vs 1 entries, 3 vs 2,
2 vs 1, 8 holds vs 0).

Verified (msi lavapipe, release, frame pointers, base 3310061de3 md5 d804d4eb
vs tip md5 b8839827, own target dirs, medians of 4 interleaved runs, host ns a
dispatch): long folded encode 4438 -> 3880 (dispatch 2090 -> 1770, end 1404 ->
1298), queue-waiters 661 -> 378; long folded over pages 3710 -> 3613,
queue-waiters 607 -> 480; short folded 3815 -> 3662, queue-waiters 707 -> 590;
short folded over pages even, queue-waiters 774 -> 718; serial unchanged (n=8).
Touched suites 93/93; clippy -D warnings (runtime; plain, m2v_cpu_icd,
m2v_gpu) 0; rustdoc 0.
2026-11-14 08:54:48 -08:00
Anees Iqbal 4c97bf0af1 queue_share: the active hold's test asserts the 2 ms budget only while the queue is active
an_unshared_queue_s_command_buffer_goes_ahead_of_other_queues_held_work
asserted that no head was let go under the 16 ms idle budget. The 2 ms
budget holds only while the unshared queue's last commit is less than
unshared_hold::ACTIVE (50 ms) old; then the 16 ms one does, as for a quiet
queue. In the checks job m3-max-29383 on a loaded msi, lavapipe ran the
'30 ms' long command buffers in 149, 161 and 50 ms: the unshared one was
committed at 1.4 ms, the queue went quiet at 51.4 ms, and the second was let
go at 148.8 ms, the first's expected end (164.8 ms) less 16 ms, under the
idle budget, as unshared_hold.rs specifies.

The test now records when the queue went quiet (its last commit as the
runtime noted it, plus ACTIVE) and asserts what the runtime bounds: a second
let go while the queue was active went no more than 5 ms before the 2 ms
budget lets it (the first's end, or 2 ms before its expected end, whichever
is first; the 16 ms budget is about 16 ms early), and a head was let go
under the idle budget only where one was let go once the queue was quiet.

Verified (msi lavapipe): the old form fails under 192 nice-19 burners (m3-max-29431:
'none let go under the idle budget' 1); the new form passes under the same load and
unloaded (m3-max-29462); clippy -D warnings (runtime) 0 under --cfg m2v_cpu_icd and plain.
2026-11-14 08:39:35 -08:00
Anees Iqbal 8b20339b4b draw_reads and dispatch_chain: commit-to-completion time beside the GPU time
Examples only (neither is a consumer's example). Both now also print, for
the runtime's shapes, the median time from the commit to the command
buffer's completion on the host: draw_reads as wall_us_per_draw,
dispatch_chain as wall_us_per_dispatch. That time also holds the GPU work
the runtime records before the command buffer's own, such as host calls'
staged copies (command_buffer/submit.rs), which the command buffer's
GPU time does not show.

draw_reads also takes --idle MS, which leaves the device idle that long
before each run's encoding, and prints each run's encoding time (encode_ms,
median and most): on a GPU that powers down when idle (the RTX 5080 laptop
GPU after about 20 s) an encoding that waits for it to wake shows there.

These are the figures the arena mirror experiments were judged by; the
mirror itself was dropped (its A/Bs on the 3090 and 5080 left a measured
shape slower in every form). Verified: msi build and clippy follow.

Verified: msi m3-max-29465: release build of both examples 0; clippy -p
metal2vulkan-runtime --all-targets --all-features -D warnings 0.
2026-11-14 08:36:40 -08:00
Anees Iqbal 3310061de3 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-14 08:21:01 -08:00
Anees Iqbal 76cef9e9af Shadow log: a dispatch's first use of a shadowed texture, and a read twin not in place, with its reason
The shadow log (METAL2VULKAN_LOG_SHADOWS, default off) named a shadowed
texture's first draw only, so a texture bound only by kernels never said
whether its function fetches, samples or writes it; and a read twin whose
texture is not in place was counted (read_twin_textures_not_in_place) with
no reason anywhere. A consumer's runs need both to size the texel-buffer
route for shadows: whether the kernels over 600 list_limit shadows read or
sample them, and why 233 twins are not in place.

- shadow_log::dispatched: the first dispatch that binds a shadowed texture
  names it as the draw line does (one line per texture, whichever command
  bound it first); the draw and dispatch lines share first_binds and
  samplers_named, which now takes a pipeline's modules and layout.
- shadow_log::twin_not_in_place: one line per texture whose read twin is
  not in place, naming the texture, its buffer, offset and pitch, and why:
  the twin's placement (asked again only with the log on) where its making
  made a shadow, or the making's error. The twin's making now runs under
  the call make_twin_texture, so its own shadow line is told apart from the
  program's.
- Off, nothing changes: enabled() is read once. A test-only switch turns
  the log on in a device test's process.

Verified: the msi job (build, clippy -D warnings all features and
targets, read_twin_device on lavapipe) reported with the tip;
the_shadow_log_names_a_twin_not_in_place_and_a_dispatch_s_first_read
asserts a line per twin not in place and the dispatch line exactly where
the texture is a shadow.

Diagnostic only: both lines print only under METAL2VULKAN_LOG_SHADOWS; no product
path changes. Verified: msi m3-max-29434 at the tip: clippy -D warnings (metal2vulkan +
runtime, all targets and features, --cfg m2v_cpu_icd) 0; read_twin_device 15/15 incl.
the_shadow_log_names_a_twin_not_in_place_and_a_dispatch_s_first_read.
2026-11-14 08:20:13 -08:00
Anees Iqbal 5d33e0c74a Device replay tests write the header's binding counts, as the runtime does
SEMANTICS 2111 (eed5f3d84b) made the compute replay read a record's kernel
bindings only below the header's packed count (layout::COUNTS, byte 0). The
runtime's header always carries it: CommandDescriptor::encode_header writes
the descriptor's max_buffer_bind_count there, at the indirect command
buffer's making (indirect_command_buffer/home.rs, indirect_commands/host.rs),
and Metal's setters cannot set a kernel buffer at or past that count, so a
real record never holds a binding the count leaves out.

tests::engine_device_replay built its records' header by hand with the
capacity alone, a count of 0, so after 2111 its replays read no binding and
six tests computed zeros (pin 90b's CORE suite, m3-max-29378, profile
amd-780m-hawkpoint-radv). bind::replay's tests had been given the count in
2111; this file was missed. Its header now carries every kernel binding's
count, as bind::replay::tests' run_preprocess writes it. A test-only change.

Verified next on msi: tests::engine_device_replay, the 72 interpreter tests
of 2111 (engine_indirect_commands, bind::replay), clippy.

Verified: msi m3-max-29430: nextest -p metal2vulkan (engine_device_replay,
engine_indirect_commands, bind::replay) 87/87 incl. pin 90b's six; clippy -p metal2vulkan
-D warnings (all targets and features) 0.
2026-11-14 08:18:18 -08:00
Anees Iqbal c1f0176651 Host-step lane tests expect the staged-records notice where a host step staged records
Since RUNTIME 2294 (5dd3668a4f), a device without unified memory places an
indirect command buffer's records by their first use: records a kernel
writes first lie in device-local memory, and a host step that reads them
while its command buffer holds them stages them through the staging queue,
announced once as staged-indirect-records. The tests in
runtime_lane::indirect_host_steps expected only the host replay and
shared-in-system-memory, so on an RTX 5080 laptop GPU 17 of them failed on
the notice alone ("announced past [...]: [StagedIndirectRecords]"); their
results were right.

on_device_forcing_with now also expects StagedIndirectRecords where the
test's steps staged a records access (WorkCounts::icb_records_staged_accesses
moved), and asserts that a device with unified memory staged none.

Verified: the 5080 run of these tests follows (the 17 failed there at
the mirror branch's tip, whose indirect command buffer code and these test
files are the same as development's).

Verified: 5080 (b5080 m3-max-29429): runtime_lane::indirect_host_steps 20/20 incl. the 17
that failed, icb_records_home, 27/27; msi m3-max-29415: clippy -D warnings (runtime +
validation) 0, lavapipe indirect_host_steps 20/20 (unified memory stages nothing).
2026-11-14 08:14:57 -08:00
Anees Iqbal 6e92453ecb 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-14 08:13:50 -08:00
Anees Iqbal df4cee2e01 RUNTIME 2300: Unshared hold: a batch whose room comes during a pass waits for an unshared commit posted before it
A scheduler pass takes the inbox in once, at its start (scheduler/inbox.rs), then submits one
batch after another, about 0.3 ms each on the Radeon 780M. An unshared queue's commit posted
during the pass waits in the inbox until the pass and its handlers end, and "Heads put first"
only orders heads already in the order. Meanwhile each further look of the same pass asks the
other queues' held heads again, and one whose room came (the oldest batch's credit grew, or its
queue's previous batch went) was submitted ahead of the compositor's commit.

reims's traced ld-auto walks (um870 780M, guest compositor beside a load app) show the path:
the compositor's command buffer committed at +1.97 ms from the take, the same pass then
submitted the app's long command buffer's last batch (+2.16) and its short one (+2.49), and the
compositor's went at +2.81; that frame finished behind the short one, a refresh late. Frames where
a batch let go after one of the frame's unshared command buffers was committed went in ahead of it:
106 (pin 86), 127, 121, 129 (pins 88, 89) of about 611, carrying 7 of 9, 12 of 17, 23 of 27 and
15 of 19 of the frames answered more than a refresh late.

The rule: SlotShare counts each VkQueue's unshared commits posted to the inbox
(Scheduler::commit, before the post) and taken into the order (take_in). A held batch notes the
posted count at the first look that finds its room (unshared_hold::behind_commits) and is held
(HeldFor::UnsharedIsolation, new WorkCounts::heads_held_for_unshared_commits) until the taken
count reaches its note. The passer never sleeps while the inbox holds a commit, so the next pass
takes the commit in, sends the unshared head first where it is ready, and lets the held batch go
in the same pass. Commits posted after the room came never hold it, so a compositor posting during
every pass holds it one pass at most. Committing and waiting threads' passes leave such a batch to
the scheduler's thread. No new switch; UnsharedIsolationPolicy::Off is untouched; the documented
bounds (2 ms and 16 ms budgets, about one batch ahead) still hold.

Not covered: the commit call's own work before its post (15 us at the median in the traces), and
commits deferred to the render lowering thread (RenderLoweringPolicy::Worker; AtCall is the
default).

Tests: unshared_hold unit test of the note's bound; queue_share_device
an_unshared_commit_posted_during_a_pass_goes_before_work_let_go_after_it (the scheduler paused
after each vkQueueSubmit; the unshared command buffer committed during the pass that submits the
app's first goes before the app's next; the unshared queue's next commit, posted after that room
came, does not hold it). Docs: unshared_hold.rs, FAST-PATHS unshared-isolation row, API.md,
WorkCounts; api_signatures.tsv (signatures.py --check passes).

Verified (msi lavapipe): m3-max-29410 at the tip: clippy -D warnings (runtime, plain) 0;
74/74 under --cfg m2v_cpu_icd (unshared_hold, queue_share, queue_share_device, scheduler,
scheduler_held_wakes, scheduler_wakes, inbox). Negative controls: the hold off (29412)
fails with the slip reproduced (next 501.3 ms before drawn 752.6, 0 holds); a hold with
no note (29413) fails starved (next 1007.1 behind later 756.4). The workload proof is a
traced compositor-beside-load walk on the 780M after landing.
2026-11-14 08:13:09 -08:00
Anees Iqbal 65a32d771a 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-14 08:09:08 -08:00
Anees Iqbal 38673ec995 RUNTIME 2299: a check that fails a submission before its group is split keeps it failed
A check may run on the scheduler's thread while a commit's encodings again
are pending: the scheduler takes the checks of the batches it holds before
the first submission, which waits for the encodings, is submitted. With a
check split (RUNTIME 2297), a group whose VkCommandBuffer holds commands of
two of Metal's submissions is encoded again apart at the commit; where the
check failed one of those submissions first, the split's splice put the
failed encoders' encodings into parts the failure had cleared, and they ran.
Found by the render fold's check test (a render pass between two compute
encoders: the pass drew).

fail_submission now marks the failed encoders unrunnable, as a rebound or
detached submission's are. The commit's split and a rebind's turn encode no
unrunnable encoder again, and an encoding again whose encoder became
unrunnable meanwhile takes no place while the unit's others take theirs
(before, splice_fits refused the whole unit for a rebound one).

Test: encoder_fold's
a_check_that_fails_a_submission_before_its_group_is_split_keeps_it_failed
holds the command buffer's turn of encodings again (a test-only guard) until
the check failed the blit's submission, then expects the blit's fill not to
have run and the three compute encoders to have.

Verified (msi lavapipe): m3-max-29383 at the tip: clippy -D warnings (runtime, all
features and targets) 0 under --cfg m2v_cpu_icd and plain; runtime fold/rebind/
reencode/check/commit tests 374/375 (the other: a queue_share idle-budget timing test
under load, no check or re-encode, fixed apart); validation submission_checks and
failed_commits 16/16. Negative control m3-max-29384 (unrunnable marks removed): the
new test fails, the blit re-encoded (4 against 3).
2026-11-14 08:08:29 -08:00
Anees Iqbal 92e08a50a4 Two timing tests assert what the runtime bounds, not a loaded host's clock
Pin 90's full lavapipe suite failed both; each passes alone at pin 90's
commit (m3-max-29307) and at 2293's (m3-max-29287). Neither is a product
error.

- gpu_times::a_command_buffer_of_two_submissions_is_timed_from_its_first_work_to_its_last
  slept 200 ms after the commit and then signalled the event the second
  submission waits for, taking the first 64 MiB fill to have begun by
  then. Under the full suite lavapipe's queue thread took the first
  submission up 268 ms after it was submitted: its GPU start, the first
  fill's, read 70.4 ms after the signal and its end 115.7 ms (the 64 MiB
  fill's run), so the start was the first fill's, as the runtime promises,
  and the assertion's premise failed. The command buffer now signals an
  event of its own after the first fill, and the host signals only once
  that landed: the first fill ran before the signal on any host, and a
  start taken from the second submission still fails the assertion.
- queue_share_device::a_quiet_unshared_queue_s_first_command_buffer_waits_behind_the_idle_budget_and_one_batch
  measured the second long command buffer's let-go against the first's
  GPU end. The idle budget lets it go once the first has under 16 ms of
  its queue's expected run left (unshared_hold::Flight::ahead), and the
  expected run is the host's view of recent runs. Under the full suite
  the expected run was 144.4 ms and the first ran 130.9 ms; it was let go
  at 130.2 ms (the scheduler's wake a little late on a loaded host), 14 ms
  before its expected end and 0.77 ms before its actual end. The test now
  measures from the expected end (its kernel start plus the expected run
  the run records), with the same 7 ms; heads_let_go_unshared_idle still
  shows the idle budget, not the 2 ms one, let it go.
2026-11-14 07:33:49 -08:00
Anees Iqbal e13e871687 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-14 07:28:33 -08:00
Anees Iqbal 618e452a38 RUNTIME 2298: a depth StoreAndMultisampleResolve into write-dropping memory completes without its resolve
store_out.rs faulted a pass whose depth attachment stored and resolved
(StoreAndMultisampleResolve) into a resolve texture over memory whose GPU
writes are dropped (Metal's private bit 24, or pages mapped read-only):
PageFault, and a queue's second fault revokes it. Metal does not: on an M3
Max under macOS 27.0.1, a 4x Depth32Float attachment cleared to 0.25 and
stored-and-resolved into a 16x16 Depth32Float at the start of a bit-24 heap
completed 6 of 12 command buffers and ended 6 as innocent victims, never a
page fault and never a revoked queue, its resolve texture's bytes kept;
depth MultisampleResolve into the same heap faults every time.

Now, as a pass's store actions settle at its end (render.rs end_pass, before
the fault check), store_out::drops_depth_resolve takes a depth at
StoreAndMultisampleResolve whose resolve target drops writes, beside a
stencil that resolves nothing: its store becomes Store and its resolve goes.
The pass completes, the depth's samples are stored, and the resolve texture
is never written. Every other store-out fault stays: a depth attachment
itself in such memory, depth MultisampleResolve, Store and
CustomSampleDepthStore into it, colour and stencil
StoreAndMultisampleResolve, and a depth whose stencil resolves too (that
pairing is unmeasured). Docs: store_out.rs, docs/API.md, docs/FAST-PATHS.md.

Tests (store_out_device): a depth stored and resolved into a private-bit heap
completes without its resolve (descriptor's and encoder's action; pages and
resolve bits unchanged; a later pass reads the depth's 0.25); depth
MultisampleResolve into the same heap faults (control); colour
StoreAndMultisampleResolve faults.

Verified (msi lavapipe, m3-max-29338 at the tip): clippy -D warnings
(runtime, all features and targets, --cfg m2v_cpu_icd) 0; store_out_device
9/9. Negative control m3-max-29343 (the settling removed): the new test
fails with PageFault, the other 8 pass.
2026-11-14 07:27:50 -08:00
Anees Iqbal 18d67a5f86 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-14 07:24:20 -08:00
Anees Iqbal 8c5a1d592a RUNTIME 2297: fold groups split at Metal's submissions where a check or a rebind fails one
RUNTIME 2293's blit fold records a blit encoder and the compute encoders
around it into one VkCommandBuffer, and those are separate Metal
submissions, which a submission check or a rebind's EncodedUseRebound fails
one at a time. Pin 90's lavapipe suite failed two tests on it (m3-max-29286
at 2293's parent passes; m3-max-29287 at 2293 fails these two):
- submission_checks::a_submission_detached_behind_a_wait_fails_alone: the
  check failed the blit's submission, whose part holds no VkCommandBuffer,
  and its fill ran inside the compute encoder's;
- rebind_reach::a_unit_s_encoder_that_laid_its_first_step_fails_encoded_use_rebound:
  the group could not be encoded again whole (the compute encoder laid its
  unit's first predication step and keeps no log), so the rebind refused
  the blit too, which Metal runs over the new pages.

Now:
- Each encoder notes whether a command of its own recorded into the
  group's shared tail (EncoderCore::in_tail; a group's first encoder always
  does). With a submission check set, the commit encodes again apart only
  those tail encoders, where they span more than one Metal submission and
  each can be re-encoded exactly (log kept, no segment). Otherwise a check
  failing one of those submissions fails all of them (State::widened), so
  the tail runs whole or not at all. Encoders whose commands all lie in
  their own VkCommandBuffers fail with their own submission alone.
- A rebind of a group that cannot be encoded again whole splits it where
  each encoder that cannot lies in a submission the rebind fails anyway
  (State::split_rebound); the group's other encoders are encoded again
  apart and run.
The FAST-PATHS known gap and API.md's committed-as-failed section say what
still differs from Metal: a shared recording that cannot be split fails
every submission whose commands it holds, and a rebind is refused where an
encoder that cannot be re-encoded sits in a submission that still runs.
No application of ours sets a submission check (reims-vgpu does not).

New test: submission_checks::a_check_failing_one_submission_a_shared_recording_holds_fails_each_it_holds.

Verified (msi lavapipe, --cfg m2v_cpu_icd): m3-max-29331 at the tip:
clippy -D warnings (all features and targets, runtime + validation) 0 under
m2v_cpu_icd and plain; 402/402 tests (rebind_reach, submission_checks,
failed_commits, predication, rebinds, indirect, encoder_fold, command_buffer,
fast_paths and pin 90's four). Negative controls on development's runtime
sources (m3-max-29315, 29330): rebind_reach, wcdc and the new test fail.
2026-11-14 07:23:37 -08:00
Anees Iqbal f2d3b54e1a Re-bless the golden hashes at SEMANTICS 2111
The ICB density change (SEMANTICS 2111) moves 14 golden hashes: the
modules that reset or replay indirect command records. Blessed by the
M3 bless job m3-max-29290 at e6379ea27a (inventory 0, golden 0,
printouts 0).
2026-11-14 06:51:56 -08:00
Anees Iqbal e6379ea27a 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-14 06:49:18 -08:00
Anees Iqbal eed5f3d84b SEMANTICS 2111 / RUNTIME 2296: indirect command buffer GPU work touches only the bindings a descriptor counts
A record holds 128 buffer bindings (4 stages x 32 slots, 2 KiB) whatever its
descriptor counts. The draw replay's preprocess read all 128 of every command
to refuse a binding set past its stage's count, the compute replay all 128
for its inheritance check, and a GPU reset (air.reset_*_command) wrote all
2248 bytes of the record. On a discrete GPU those reads crossed the link.

A binding past its stage's count is zero in every record: the storage is made
zero, an encoder's write past the count faults and writes nothing, the CPU's
setter refuses one, a compute command has no other stage's setter, and a copy
takes a source of the same descriptor. So:
- the render preprocess reads a binding only below its stage's count and
  writes a slot table entry past it as null, unread;
- the compute replay reads the kernel bindings below the header's count alone
  (clamped to 32) and writes the entries past it null;
- a GPU reset writes the command's words (64 B), the bindings below each
  stage's count (16 B each) and the words past the bindings (136 B).
The replay's check of a binding set past the count goes: it never applies.

Tests: interpreter (metal2vulkan) render and compute cases with garbage past
the counts draw/dispatch as without it, the same garbage in a counted slot is
refused (negative control); a reset clears the command words, counted bindings
and tail and leaves a mark past the counts, where no reset leaves every stale
byte (negative control). Runtime device test: a GPU reset, an encode of the
even commands and an execution leave the odd commands empty and draw the even
cells alone; without the reset every command keeps its earlier draw (control).
icb_reads gains a gpu-reset shape.

Verified: msi m3-max-29281 at the tip: clippy -D warnings (all targets and
features) 0, interpreter tests 72/72, lavapipe ICB/indirect 34/34, m2v_gpu
build 0. 5080 (b5080 entry, at the change before a test-only lint fix): device
ICB/indirect 34/34; icb_reads 8192 commands, GPU us a command, two alternated
rounds: gpu-shared execute 0.0295/0.0171 -> 0.0109/0.0109, gpu-reset encode
0.0143 -> 0.0031 and execute 0.0130 -> 0.0109, gpu-private execute 0.0169 ->
0.0107, cpu-shared unchanged. The 780M A/B follows.
2026-11-14 06:48:34 -08:00
Anees Iqbal 9c1994c7f5 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-14 06:35:16 -08:00
Anees Iqbal 23f84517cb RUNTIME 2295: kept padding in an exportable block asks the device for its pitched image
A texture over a Private buffer's rows with bytes between them, at a pitch
the device's linear image does not lay them at, was a shadow by fiat where
the buffer lay in a block of the runtime's buffers allocated exportable as
an opaque file descriptor; over a plain block the same texture is a
DRM_FORMAT_MOD_LINEAR image at Metal's pitch, in place.

texture.rs's alias_unbound now asks the device for that image made for the
block's handle type. Where the device makes one, the texture binds in place
and its first move is kept by copies (GpuKeep). Where it refuses, the
texture is a shadow naming the device's refusal (InPlaceRefusal::Image),
its reason text naming the exportable block, so a shadow log can count the
case.

On RADV it refuses: every image for external memory whose tiling is not
linear asks a dedicated allocation, which a block is not. The FAST-PATHS
known gap records the cause and the two in-place routes with their
measured costs (a dma-buf import per texture; plain blocks' making stalls),
for the owner to trade. fd_blocks_cover.rs's docs and FAST-PATHS's in-place
and Private rows no longer claim such blocks hold every image a plain block
does.

Verified: Radeon 780M (RADV PHOENIX), kept_padding, exported_textures,
ordered_renders and shadow_causes_device 15/15. Rows 768 bytes apart over an
exportable block answer Shadow(Refused(Image)) counted (0,1,0); over a
Private heap's buffer the texture is in place with its first move kept; every
byte of both buffers reads back. The heap assertion (second commit) was
printed on the 780M, asserted on lavapipe. msi: clippy -D warnings
(--cfg m2v_cpu_icd and m2v_gpu) 0, lavapipe kept_padding 7/7, rustdoc 0.
2026-11-14 06:34:32 -08:00
Anees Iqbal cce4c67f02 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-14 06:15:22 -08:00
Anees Iqbal 5dd3668a4f RUNTIME 2294: indirect command buffer records are placed by first use on discrete GPUs
On a device without unified memory, an indirect command buffer's records
lived in host-visible system memory. A kernel writing 8192 records and the
render encoder executing them both crossed the PCIe link: on a 3090 behind
an x4 link, 17 ms and 26 ms a frame at the link's ceiling, where device
memory takes about 0.004 and 0.03 us a command.

Now the first use decides where the records live:
- a GPU use (an encoder executing, encoding through an argument buffer, or a
  blit resetting, copying or optimizing it) places them in device memory,
  written with a header and zeroed flags through the staging queue;
- a Shared buffer's first host access moves them to host memory once, while
  no unfinished command buffer holds them: an empty move when the GPU wrote
  nothing, else one copy waited for;
- a host access while a command buffer holds them, and every host access of
  a Private buffer, is staged through the staging queue (read back, written
  back), counted and announced once per device as the new
  `staged-indirect-records` (performance) degradation.
The host never writes device memory. Every encoder use takes a hold that
its command buffer drops at completion.

Counters: icb_records_moved_to_host, icb_record_bytes_moved,
icb_records_staged_accesses. docs/API.md has the catalogue entry; the API
table is re-blessed.

Tests: src/tests/icb_records_home.rs (GPU-encoded Shared records stay on the
device across executions; CPU-encoded move once with no bytes; a getter
after a GPU encode moves the bytes; Private records never move; a held
buffer stages until its holder completes; a blit reset between GPU encodes
keeps them on the device, with a reset-then-execute negative control) and
a runtime-lane test for the Private form's notice. Verification: the msi
build, clippy and the lavapipe and 5080 runs follow in the next commits'
messages.

Also: examples draw_reads (the GPU time a draw pays for reading its own data: bytes, a bound buffer,
a pointer resolved in the resident set) and icb_reads (an ICB's records' cost on the GPU and host,
GPU- and CPU-encoded, Shared and Private). Follow-ups folded in: placing fills only the storage's
bytes; a setter's in-place access allocates nothing and its batch carries the access in two words.

New Degradation kind: staged-indirect-records (Performance, once per device; docs/API.md catalogue:
touch a Shared ICB from the CPU before the GPU uses it, or use Shared rather than Private for CPU
access). New WorkCounts: icb_records_moved_to_host, icb_record_bytes_moved,
icb_records_staged_accesses. api_signatures.tsv re-blessed; refusal surface unchanged.

Verified (arenavram): msi m3-max-29217 at bd9994a6a3: clippy plain (runtime + validation, all
targets/features, -D warnings) 0; lavapipe ICB/indirect/degradation/carry tests 65/65. m3-max-29188 at
0980b78c47: clippy plain/m2v_gpu/m2v_cpu_icd 0, rustdoc 0, lavapipe 65 + icb_records_home 6 +
catalogue/sites + 30 lane tests, api tables 15/15. 5080 (m3-max-29179) at 87ea86309b: 95/95 incl. the
6 icb_records_home tests (GPU-encoded Shared stays, 0 moves; CPU-encoded moves once, 0 bytes; getter
after a GPU write moves with bytes; Private never moves and is staged; held then staged then moved;
blit reset between GPU encodes, with a negative control) and
runtime_lane::blits::private_indirect_records_follow_the_memory_model. 3090 A/B m3-max-29178 (base
17a0355935 md5 cac5b460 / tip 87ea86309b md5 4322acb2, two alternated rounds, 8192 commands):
GPU-encoded Shared encode 0.448 -> 0.0039 us a command, execute 3.03 -> 0.031; link rx about 3-4 GB
-> 12 MB a shape run; tip counts moved 0, staged 0. CPU setters on lavapipe: base vs tip within
noise at bd9994a6a3 (not separable; not shown zero). The suites run after landing.
2026-11-14 06:14:41 -08:00
Anees Iqbal 419c74f743 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-14 06:00:15 -08:00
Anees Iqbal 12cd9c6f79 RUNTIME 2293: blit encoders fold into the shared VkCommandBuffer as compute encoders do
A command buffer that mixes compute and blit encoders (the image workloads:
Photo Filter, HDR, RAW) began a VkCommandBuffer for every blit encoder, which
also ended the compute encoders' fold: dispatch_chain's blits shape (200
one-dispatch compute encoders each followed by a blit copy) went to the queue
as 799 VkCommandBuffers in one vkQueueSubmit (542 begun) on lavapipe, against 1
for compute encoders alone. On ANV each begin costs 16-20 us of host time.

A blit encoder now joins the group of encoders its command buffer's tail holds
by the rules compute encoders follow (encoder_fold.rs): same batch, the earlier
member one part with no segment, no fence update and nothing failing, no
command predication yet, the encoder trail off, protection options 0; a
compute encoder joins where the group's compute encoders are of its dispatch
type (Joining::{Compute, Blit}). Blit commands take the per-command FoldOrder
barrier through track(). What differs for blits:

- Blit encoders now always log their calls (replay.rs), as compute encoders
  do, so a failure that splits a mixed group encodes its running members
  again apart.
- A blit encoder ends a unit of command predication, so a group can hold two
  units' compute encoders: an unbalanced record whose left-out work begins
  past the group's first encoder (State::left_out_from, set by
  leave_out_ended) now splits the group at the commit as a partial failure
  does, the shared VkCommandBuffer never submitted. split_failure and the
  rebind's encoded_together take one check, State::encodes_again_apart: no
  predication, a non-compute encoder, or Predication::alone. A rebind in a
  command buffer that used predication now encodes a group again where each
  member is alone, where before it refused (EncodedUseRebound).
- An encoder whose part writes an ASTC carrier (its second twin's decode goes
  after the part) or notes an Overwrite (judged by its part's summary, which
  a group widens) ends its group. A folded blit's Overwrite goes to the
  group's first part only where every earlier member is a blit encoder that
  named nothing of the texture (Fold::overwrites_join), which is what
  first_overwrites decided before folding.
- Spares tests that need one VkCommandBuffer per blit encoder update a fence
  in each.

Tests (tests::encoder_fold): a compute/blit/compute chain is one
VkCommandBuffer with every copy and read right; an event signal, a dispatch
type change across a blit, predication, a whole-texture overwrite and an ASTC
carrier write each end a group; failures inside a mixed group run exactly
the encoders they leave; an unbalanced End past a group's first encoder
splits it; a rebind encodes a group again in a predicated command buffer.

Also: dispatch_chain gains the `blits` shape (a blit copy after each one-dispatch compute encoder)
and the `copies` shape (a command buffer of blit encoders only).

Verified (blitfold, msi lavapipe): m3-max-29164 at 5845456c61: clippy (runtime, cfg m2v_cpu_icd,
all targets/features, -D warnings) 0; 185/185 including the encoder_fold tests and
a_rebind_encodes_a_group_again_in_a_command_buffer_of_command_predication (the narrowed refusal:
words right, reencodes_refused 0; REFUSALS.md regenerated, unchanged). A/B m3-max-29165 (own target
dirs, md5 c2157758 base 45fdc3e601 / a2214763 tip, ABAB): VkCommandBuffers begun/submitted per Metal
CB, 200 dispatches: blits 542/799 -> 1/1, copies 271/399 -> 1/1, encoders 1/1 -> 1/1; lavapipe GPU
us a dispatch blits 54.98 -> 37.35, copies 9.25 -> 2.36, encoders unchanged; host thread CPU blits
~-1.1 us a dispatch, copies even (logging ~+300 ns a blit encoder paid back by no new
VkCommandBuffer and a shorter commit). No WorkCounts field or Degradation kind. Negative control,
lint in the other configurations and the suites run after landing.
2026-11-14 05:59:35 -08:00
Anees Iqbal 8783a6a8fe SEMANTICS 2110 / RUNTIME 2292: a tree reduction's guard meets its core through the extensions of its order
A tree reduction over a ushort position (if (x < h) tg[x] += tg[x + h]) tests x widened to
32 bits, while its address widens x straight to 64. The group core of tg[x] is the ushort x,
and the guard's below fact named zext32(x), so the tree-reduction clearance missed a pair
that cannot meet: under x < h the store writes below h and the load reads at h or above.
The pair took an Emulated order, which the tangle makes a subgroup barrier, pinning the
kernel to 32-lane full subgroups, and kept the one-row variant pinned as well.

Group cores and the smaller sides of below facts now compare through the extensions that
keep their value in the fact's order (zero extensions unsigned, sign extensions signed),
each operand settled. An extension of the other kind stays, its value differing there.
This is exact: zext keeps unsigned values and sext signed ones.

Test (llvm-as kernels written for it, on the 780M profile): a ushort index with an unsigned
guard and a short index with a signed guard each leave the one-row variant without a
simdgroup barrier, simd class or pinned subgroup, with the sum at 8, 16 and 32 lanes, while
the own pipeline keeps its pin and records RowLockstep (rows share tg[x]); a signed guard on
zero-extended indices keeps the one-row variant's barrier and pin.

Verified (codegen): msi m3-max-29121: clippy -D warnings (translator, runtime, all targets/features)
0; engine_simd + lockstep tests 129/129 with llvm-as present; negative control (extension strip
disabled) fails the new test at the one-row variant's simdgroup-barrier count (1 vs 0). On the 780M,
compile-only, the guest's particle kernel at 64x1 (one-row variant, no required size; um870
m3-max-29173, read in place): wave 64 (was 32), s_barrier 0 (was 7), instructions 241 (306 in the
pre-A/B capture, ~307 with A+B pinned), VGPRs 8 (16). Over the capture's 34 pinned no-simd modules
that reproduce the pin (m3-max-29167, counts only): 7 unpinned (2 functions); 23 stay pinned, most by
a guard over an `add nsw` core with no provable unsigned sum (17). Golden tables re-blessed on
development next.
2026-11-14 05:58:08 -08:00
Anees Iqbal 90747d6a70 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-14 05:57:12 -08:00
Anees Iqbal 738d3fb2ba RUNTIME 2291: the host residency counts a shared dma-buf file once and releases its pieces together
With buffers grouped into shared dma-buf files (RUNTIME 2290), the residency
still counted and released one buffer at a time. On RADV a shared file's
import leaves the submissions' list only with its last holder, so releasing a
piece of a file other buffers still hold took nothing off the list and cost a
VkBuffer and a bind at the piece's next use. The 780M run of the shared_files
example (job m3-max-29062) released and rejoined 936 of 1,000 pieces of one
file that way, once the cap of 64 applied.

Now every pass groups the releasable imports by the shared files their pieces
lie in (union-find over the files each holds), and a group goes whole or not
at all: every member released together under all their locks (taken in
address order; no other path holds two), and only where every hold of each of
its files is a member's, so that the release frees each file's import. A file
a heap, a buffer kept for good or a command buffer still holds stays imported
with all its pieces. The cap counts the imports on the device's list: a
group's files once each plus each import of its own. The wake trigger counts
each import's listed weight, less a gap the last pass found (pieces past a
file's first), so pieces of one file wake no thread; the periodic pass
catches what a race misses.

Tests: src/tests/host_import_groups.rs (no device): grouping, joining through
an import over two files, a file held elsewhere, holds read apart.
src/tests/dma_buf_shared_files.rs (device, no-pointer route): four buffers
over one file past a cap of 1 see no release and no import again over three
rounds of blits; the negative control, four buffers of their own dma-bufs,
has three released past the most and imported again; two files of two
buffers have the least recently read file's pieces released together, its
import freed once, the other file's kept, and once one of its buffers is
exposed the other is released no more, even forced.

Verified (dmagroup, msi lavapipe --cfg m2v_cpu_icd, no-pointer device): m3-max-29116 at the same
content: 102/102 (dma_buf, host_residency, host_import_groups, pointer_residency, no_pointer_import,
host_ram_dma_buf, host_aliases, dropped_uncommitted, chunks_cover, copied dma-buf tests). 4 buffers
over one file, cap 1: released 0, past the most 0, imported again 0 over three rounds; negative
control (4 own dma-bufs, cap 1): 3 released past the most, 6 by the end, 3 imported again; two files
of two buffers, cap 1: the least recently read file's 2 buffers released together, shared imports
live -1, an exposed buffer's file not released. m3-max-29139: clippy cpuicd/plain/m2v_gpu 0,
private-items rustdoc 0, touched tests 12/12. No WorkCounts field, Degradation kind or API change.
2026-11-14 05:56:32 -08:00
Anees Iqbal bef9da6b60 Probe readonly_gpu_writes: its runs share one queue, which a second fault revokes
An older record read this probe's multi-run output as "every later command buffer of the process
errors after a fault". Measured on the M3 Max, macOS 27.0.1 (m3-max-29110, plain Metal): one
faulting colour store into bit-24 memory leaves the next command buffer on the same queue
Completed (twice, a process each; readonly_encode_answers' store shape likewise on the same queue,
a new queue and 100 ms on); four faulting runs on this probe's one queue answer Error/Completed
for run 0 and Error/Error for runs 1-3, the read-back never run; the writable control completes
throughout. That is the queue revocation the runtime models (command_buffer/revocation.rs): the
queue's second caused error revokes it. A comment at the queue says so. Comment only.
2026-11-14 05:29:10 -08:00
Anees Iqbal 20f7e82bbe Runtime example shared_files: settle the submission checks first, print residency releases
The 780M run of the example (job m3-max-29062) reported 1,935 pieces joined in
its 1,000-a-file phase where 999 were expected, and none extra in the 8-a-file
phase before it. The import-tax verdict that turns on the residency's most of
64 releasable imports (`pointer_imports_tax_submissions`) is false until the
device's submission check answers, and the example never waited for it: the
check answered between the two phases, so the 1,000-a-file phase released
the 936 (1,000 - 64) buffers past the most while they were made, and each
joined its file's import again as its address was handed out. The first
phase also ran beside the check's own work.

The example now waits for the submission checks (Device::settle_submit_checks,
60 s) before its first phase and prints their verdict, and each line adds the
imports released past the most and those imported again
(host_imports_released_over_most, host_imports_reimported), so every join is
accounted for.

Verified: cargo fmt only here; build and clippy in the msi job that follows.

Verified (dmagroup, msi m3-max-29088 at 633613136f): clippy -p metal2vulkan-runtime --all-features
--all-targets -D warnings plain 0 and m2v_gpu 0; the example builds (release). Example only: no
RUNTIME bump.
2026-11-14 05:23:56 -08:00
Anees Iqbal 723e34e01f hold_sites: wait for the scheduler thread's count of the held dispatch's host step
a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first asserted
heads_held_for_host_steps had grown the moment the fill on the other queue completed. That count
is made only at a look of the scheduler's thread (scheduler/mod.rs, HeldFor::HostStep in the
look's Order::next). The fill goes in a pass of the test's own thread, as it commits or as it
waits (Scheduler::submit_before_waiting through submit_plain_ready): plain_ready leaves a head
with a host step without counting it, and the scheduler's thread, woken after that pass, counts
the held dispatch at its next look. On lavapipe under the whole suite's load that look can come
after the 64-byte fill completed, and the assertion read the count first: pin 89's lavapipe lane
(at 5716203e5d) failed it at hold_sites.rs:100; pin 88 passed it.

The assertion now waits for the count (eventually, WAIT), as the fence sibling in this file does.
The scheduler's order and counts are unchanged; the test only stops asserting a moment the
product does not promise.

Verified on msi lavapipe (--cfg m2v_cpu_icd), the test alone: at f073427f9b without the change
5/5 passed (m3-max-29075), so the failure is a race, not a deterministic regression; with the
change 5/5 passed (m3-max-29076).

Verified (dispatch2, msi lavapipe --cfg m2v_cpu_icd): the test alone 5/5 at f073427f9b without the
change (m3-max-29075: it races, it does not fail every time) and 5/5 with it (m3-max-29076). The
failure was pin 89's lavapipe lane (m3-max-29034). Test only: no product change, no RUNTIME bump.
2026-11-14 05:22:36 -08:00
Anees Iqbal 4cdae42a8f HOWTO: which calls block their thread while a runtime-suspended GPU resumes
Rewrites the runtime-D3 host note of section 8 in place from d3wake's probe on an RTX 5080
Laptop GPU (driver 615.71.09, Linux 7.2; b5080 entry d3wake-probe-050814, probe branch not landed):
bare Vulkan calls made after 25 s idle with the GPU suspended hold their thread for the resume
(empty vkQueueSubmit 982 ms, a host write to device-local memory 986 ms, a device-local
vkAllocateMemory 988 ms, a pool reset and the recording of 8192 dispatches 987 ms); `commit`
returns in 0.03-0.43 ms and the resume lands on the scheduler thread's submit
(batch_submit_nanos 979-986 ms); a commit that records a CPU-written indirect command buffer on
its own thread holds it 951-952 ms (arenavram's entry); commit_and_submit and the making of an
object that takes a new device-local allocation are stated as expected, not measured.

Drops the old advice to set the PCI device's power/control to `on` (a runtime-PM setting the
runtime must not ask of its users). Docs only: no product change.
2026-11-14 05:20:50 -08:00
Anees Iqbal 9423ac789f 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-14 05:13:35 -08:00
Anees Iqbal 045ae9caa8 RUNTIME 2290: pieces of a shared dma-buf file bind in one import of the file
On RADV every guest no-copy buffer and heap is a dma-buf import of its own
(the shared mapping's pointer is refused), and RADV lists every import in
every submission: the 780M's vkQueueSubmit cost ~0.45 us per live import
(the consumer's Super Resolution: ~1,010 imports, p50 531 us a submit).
The lever agreed with the consumer: a source answers pieces of files it
shares, and the runtime imports each file once.

- DmaBufChunk is { file: Arc<OwnedFd>, offset, length } (was { fd, length }).
  A chunk at offset 0 whose Arc the runtime alone holds (Arc::try_unwrap) is
  a dma-buf of its own, imported exactly as before; any other is a piece of
  a shared file (dma_buf.rs Piece).
- DmaBufRequest gains `alignment` (the host page, a plain dma-buf buffer's
  memory alignment, asked once, or the granule where the request may split)
  and `shared_files` (false for an image's dedicated import, a guest RAM's
  chunk and its probe, and a list of runs: those take a dma-buf of its own
  at offset 0, as before). A misaligned piece, or one past its file, is
  misuse (Invalid, Problem::DmaBuf).
- Each device generation keeps DmaBufFiles: the address of the file's Arc
  (never the inode) -> Weak<DmaBufFile>, one import of the whole dma-buf,
  dedicated to nothing, made with no lock held and entered under a leaf
  lock (a racer's import freed). Each buffer's DmaBufPages holds one Arc
  per piece; the last holder takes it out of the map under the lock
  (Arc::into_inner) and frees it through its own device handle.
- A plain buffer binds at its piece's offset (Placement::dma_buf takes the
  offset), a sparse one each piece at its memory offset.
- Residency keeps pieces: a dup of an own descriptor (counted against the
  fd budget, as before), an Arc clone of a shared file (no descriptor).
- import_dma_buf borrows the descriptor (it always handed the driver a
  dup).
- WorkCounts: dma_buf_pieces_joined, dma_buf_shared_imports_live (new);
  dma_buf_imports counts imports made (own chunks and first pieces).

Tests: tests/dma_buf_pieces.rs (Piece classification, the map's holds, no device);
tests/dma_buf_shared_files.rs (device: four buffers over one file -> one import, three joined,
bytes and fills in their pieces, freed with the last; the negative control of own files; two pieces
of one file in a sparse buffer at their offsets; release and import again; a misaligned piece
refused). Example shared_files: the 780M submit-cost A/B (own files, 8 a file, 1000 a file).
Docs: dma_buf.rs module, with_dma_buf (a shared-file import is never dedicated: where a device
needs that, the buffer is a copy, the source not asked again), HostRam::with_dma_buf, HOWTO,
runtime README; api_signatures.tsv; REFUSALS regenerated (unchanged).

Public API change (runtime): DmaBufChunk { file: Arc<OwnedFd>, offset, length } (+Clone), was
{ fd, length }; today's behaviour is `file: Arc::new(fd), offset: 0` with no clone kept.
DmaBufRequest gains `alignment` and `shared_files`. No Degradation kind.

Verified (dmagroup, msi): m3-max-29050 at 51e7f6b569: tests 72/72 on lavapipe (--cfg m2v_cpu_icd;
Mesa 26.2.4 takes the no-pointer dma-buf route with /dev/udmabuf), clippy -p runtime -p validation
--all-features --all-targets -D warnings plain 0 and m2v_cpu_icd 0, example builds (release). Seen:
4 buffers over one file -> imports 1, joined 3, shared live +1; own files -> imports 4, joined 0;
sparse reverse-order pieces -> one import, bytes in order; misaligned (2048 vs 4096) -> Invalid
DmaBuf, nothing imported. The 780M submit-cost A/B runs after landing.
2026-11-14 05:12:55 -08:00
Anees Iqbal f073427f9b 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-14 05:10:32 -08:00
Anees Iqbal 59fb0f9c93 RUNTIME 2289: Compute encoders keep a dispatch's instantiated commands with their bind state
A program that opens a compute encoder for each dispatch (Geekbench's compute workloads, and
dispatch_chain's encoders shape) instantiated every dispatch's commands again. The dispatch memo
goes when its encoder ends. The textures such a program binds in turn change the bind state at
every dispatch, though a compute plan's commands read no texture binding except a texel buffer's
range, a texture's in-place planes or a handle table's member. At development dd1481cfa0,
instantiate_dispatch was 6.4% of the calling thread's CPU (profile m3-max-29022, msi lavapipe,
encoders shape, tex --heap). The keyed regions, the move of the commands into the memo and their
drop at encoder end were about 2% more.

- Translator: BindingPlan::dispatch_reads(class), whether a compute plan's commands may read the
  values bound at slots of a class past their shape. Buffer slots: always. Texture slots: only
  through a texel buffer's range, a YCbCrInPlace push field, or a handle table's member bound at a
  slot. Sampler slots: never. New test bind::dispatch::tests::dispatch_reads_names_the_slot_values_the_commands_read:
  equal commands for states that differ only in texture and sampler values where it answers false;
  other commands for another texel range or handle-table resource ID where it answers true.
  docs/API.md section 6.
- Runtime: live_bind::Reshape notes the kinds of values each bringing in place changed
  (ValueKinds: each slot class's bindings, and every other field). stage_in_region and the
  constant fields now go through Reshape::unshaped. compute::Instantiated, on LiveDispatch, keeps
  the last direct dispatch's Arc<DispatchCommands> with its Planned held weakly, and goes on with
  the state to the next encoder. A moved kind the plan may read lets it go. KeptDispatch shares
  the Arc. Builds with debug assertions instantiate again at every dispatch that takes the kept
  commands, and assert they are equal.
- WorkCounts: dispatches_instantiated and dispatches_instantiated_as_before (new).
  api_signatures.tsv (+3). host_ab lists the two counters.
- New tests::compute_instantiated (m2v_gpu / m2v_cpu_icd):
  - textures of one shape in turn, an encoder each, keep the commands and sample their own
    texels;
  - an output bound at another offset instantiates again;
  - a buffer made resident instantiates again;
  - texture buffers in turn, for a plan that reads texel ranges, instantiate at every dispatch and
    read their own texels.

Verified (dispatch2, msi lavapipe; tree d43025b439): check job m3-max-29038 under --cfg m2v_cpu_icd:
clippy of the runtime and translator, --all-targets --all-features -D warnings 0; touched tests
40/40 (compute_instantiated 4/4, compute_bind_memo 3/3, live_bind 2/2, bind::dispatch::tests 15/15,
api_signatures, api_surface). Negative control m3-max-29048 (texture changes ignored):
texture_buffers_bound_in_turn_instantiate_again fails on the debug assertion; the other three pass.
Release A/B m3-max-29047 (own target dirs, md5 efd53108 base 3e0262099b / 0c57ca78 tip, one run
each, encoders shape, 2300 dispatches): dispatches_instantiated_as_before 1.00 per dispatch; --binds
tex dispatch 3467 -> 2868 ns, thread CPU 6586 -> 5882 (-10.7%); --heap 3834 -> 3123, 6827 -> 6044
(-11.5%); end_encoding unchanged. Lint in the other configurations and the suites run after landing.
2026-11-14 05:09:52 -08:00
Anees Iqbal 5716203e5d Re-bless the golden hashes for SEMANTICS 2109
SEMANTICS 2109 (27ed85dfc2) moves an 8-byte leaf at a proven 8-aligned offset as one uvec2, so 376
modules' SPIR-V hashes moved. Blessed on the M3 at 3e0262099b (job m3-max-29027: inventory=0,
golden=0, printouts=0; only golden_hashes.tsv changed).
2026-11-14 04:45:59 -08:00
Anees Iqbal 8b9b2875ab 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-14 04:45:29 -08:00
Anees Iqbal fd53ee25b9 RUNTIME 2288: kept padding in a block of the runtime's exportable buffers is held in place, its first move kept by copies
A texture over rows whose bytes between them only the device's ordered commands write
(Between::Kept) was a shadow when its buffer lay in a block of the runtime's buffers allocated
exportable as an opaque file descriptor and never exported (Holds::FdBuffers,
BoundMemory::Blocks). alias_unbound refused kept rows in any memory allocated exportable, because
an image there names the handle type and starts UNDEFINED. Now such a texture takes the device's
linear image made for the block's handle type, and its first move keeps the bytes it is bound to
by copies around the transition (GpuKeep), as the DRM_FORMAT_MOD_LINEAR image over such rows in a
plain block already did.
- The keep now follows the image's initial layout (UNDEFINED), not the pitched route alone.
- Kept rows in memory the runtime exported stay refused.
- blocks_linear_image takes kept rows whatever the FdBlocks verdicts, as pooled_pitched_image does.

Why: pin 88's regression. reims-vgpu's test made a texture over a plain Private buffer after one
over a padding-unobserved buffer. At pin 86 the plain buffer took the parked buffer of the
unobserved one, which lay in a plain block, so the texture kept its padding in place. Since
RUNTIME 2279 the unobserved buffer parks in a Holds::FdDmaBufs block, which a plain buffer never
takes. So the plain buffer got a fresh exportable block, and the texture became a shadow. A fresh
plain Private buffer on the 780M was already a shadow there before 2279. This removes the
dependence on that recycle.

Docs: alias_unbound, blocks_linear_image, alias_image, linear_plan's Between::Kept and holding,
first_move's GpuKeep, fd_blocks_cover's module docs, API.md's kept-padding paragraph, the

Tests (kept_padding.rs, ecd3e3dfd5): the consumer's order (a texture over a plain Private buffer
made after one over an unobserved one is kept) and the first use of each kind over Blocks.

Verified (expbuf; debug archives built on msi from per-sha source and target dirs):
- um870 780M RADV 1002:1900, A at ecd3e3dfd5 (tests only) m3-max-28998 (md5 9985c2be): 2 run,
  2 FAILED (plain buffer in Blocks (0,1,0) vs expected (0,0,1); blit over Blocks a shadow).
- Fix at 3446d50cd7 m3-max-28999 (md5 574d7b59): 14/14 pass over kept_padding, ordered_renders,
  exported_textures, shadow_causes_device; blit, clear and load over Blocks in place (kept 1,
  shadowed 0), the bytes between rows unchanged; ordered_renders runs its in-place branch (1 kept
  padding alias, 0 shadows); validation layer present, nothing reported.
- lavapipe m3-max-28971 at the fix: 7/7.
No Degradation kind added.
2026-11-14 04:44:37 -08:00
Anees Iqbal 3e0262099b 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-14 04:43:02 -08:00
Anees Iqbal 27ed85dfc2 SEMANTICS 2109 / RUNTIME 2287: an 8-byte leaf at a proven 8-aligned offset moves as one uvec2
A buffer slot's 8-byte leaf (half4, float2, long, a chunked uchar8) whose AIR alignment is at least
8 and whose offset is proven a multiple of 8 (MemoryPlan::proven_align) is now one element of a
StorageBuffer { uvec2[] } view at the slot's binding, as a 16-byte leaf at a proven 16-aligned
offset already is one uvec4. Elsewhere it stays two words.

Why: under robustBufferAccess2 RADV's load/store vectorizer does not merge two word loads it cannot
prove 8-aligned, so a half4 read was two buffer_load_b32 where a native kernel reading f16vec4[]
has one buffer_load_b64 (780M Geekbench kernels run ~1.4x native's GPU time per job).

- Path::Vec2 beside Path::Vec4, Units::vec2, UnitViews::vec2; WordMem's vector read/write take the
  lane count; views::declare_vec declares either width. Uniform views get no uvec2 view (std140
  stride 16); device addresses and the threadgroup arena keep no vector unit.
- Exact under rule 1: the same bytes move. Descriptor bases are 16-aligned and a bound range is a
  whole number of 16-byte units, so the word view's containment check is the unit's.
- The dynamic-views self-check module declares a uvec2 variable too (RUNTIME bump).
- docs/FAST-PATHS.md, multi-variable dynamic binding row: "narrow, uvec2 or uvec4 unit view".
No switch, Degradation kind, refusal or public type change.

Verified (codegen): ISA compile-only gfx1103 RADV 26.2.6 (amdgpu noop drm-shim) on our own half4
column convolution: the loop's read and store are buffer_load_b64 / buffer_store_b64 as the native
twin's; VMEM 5 -> 2 (native 2), instructions 88 -> 83 (native 56). msi m3-max-28997 at ae8ac29436:
clippy -D warnings all targets/features (translator, runtime) 0; touched tests 292/292
(engine_access incl. eight_byte_leaves_move_as_one_uvec2: views, OpStore counts, exact bytes on the
CPU interpreter at every residual, both encodings, every tested profile); metal2vulkan suite 3578
passed, 1 expected failure golden_hashes_match_the_table (re-blessed on development next).
2026-11-14 04:42:19 -08:00
Anees Iqbal dd1481cfa0 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-14 04:39:37 -08:00
Anees Iqbal cbb1b1f02d RUNTIME 2286: live buffers compare the parts in place where the last set is shared
When a table's parts equal the last table's, LiveBuffers::make compared them by collecting ~68
Arc parts into a Vec and dropping it again. It now compares them in place
(SortedChunks::derived returns an ExactSizeIterator). No behaviour change; no Degradation kind or
WorkCounts field.

Verified (livebuf2, msi): tip check m3-max-29008: clippy -D warnings 0, translator 33/33, runtime on
lavapipe 13/13. A/B 29006 (md5 f223eed3 development / 9c8336c2 tip, one run each, lavapipe):
end to end neutral within noise (sr-4k commit 16170 vs 16160 ns per CB); perf: LiveBuffers::table
~26% -> ~20% of commit_and_submit (~4.9 -> 3.9 us per CB). Lint and the suites run after landing.
2026-11-14 04:38:58 -08:00
Anees Iqbal 4ab75eaf32 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-14 04:27:09 -08:00