Commit Graph
1400 Commits
Author SHA1 Message Date
Anees Iqbal c2aedcd64c Diagnostics: encoder times count draws again; the pass log watches states by label hash
METAL2VULKAN_ENCODER_TIMES counted a render encoder's draws only where a draw
took every step: a draw drawn again as before (render/draw_again.rs) or rebound
(render/draw_again/rebound.rs) bumped the encoder's draw calls but not its
timed work, so a row named a fraction of its draws (a measured guest run: rows
of about 2300 draws/s against about 36k indexed Vulkan draws/s). Both paths now
count as the program's draws, as every step's do.

METAL2VULKAN_LOG_PASSES watched only textures by format and size, and its
256-line bound was spent before the pass of interest ran: in that run every
2768x1570 pass before the measured step printed (256 lines distinct even with
object IDs left out, 171 by attachments and states alone), so the pass the
encoder times ranked first never printed. A `state:HASH` entry now watches a
render pipeline state by the label hash the encoder times name their rows by
(encoder_trail::label_hash), so a run can name exactly the pass it needs; each
state in a line carries its hash, so a line maps encoder-time rows to states.
The hashes are worked out only where the log watches a state or prints a line.
The bound and the once-per-pass rule are as before.

Both are default-off diagnostics and change no work while off.

Tests: tests::encoder_times::an_encoder_s_draws_again_count_among_its_draws
(draws again as before and rebound, each counted, in a line of all its draws;
fails without the fix: the line names only the draws that took every step);
tests::pass_log state-entry parsing, refusals and matching.
2026-11-16 03:29:01 -08:00
Anees Iqbal f3390be7f0 RUNTIME 2441: Scheduler: a committing thread's pass keeps only its own command buffer's submission handlers; gated completions post with one look
What: commit_and_submit's own pass (and the pass the lowering thread makes for one left for a
render encoder's end) keeps inline only its own command buffer's submission handlers, which run
on the committing thread inside the call, in their turn, as before. Every other command buffer's
handlers whose last batch the pass submits go to the device's handler threads right after that
submission, as one segment with its Turns ticket; the committing command buffer's ticket is taken
as its batch goes, so submission order holds. Both of submit_plain_ready's places that take
handlers (a submitted last batch and one held in the group) go through keep_or_hand_off.

A transition to Completed or Error whose transition to Scheduled is still owed is posted behind a
gate only where its submission handlers have not run (gate_for_handlers); otherwise plainly. The
gated post pushes the item behind the gate and opens the poster's closing under one lock with one
look for a thread (Contexts::post_gated), where post_behind and open made one each. FAST-PATHS
records the hand-off's own cost (19.1 wakes a frame).

Why: on PHOENIX, in the guest-shaped submit-cost leg after the scheduler-pass hand-off
(RUNTIME 2437), a submission's return to its own handler was p50 991 / p99 5231 us where a
committing thread ran it (978 handlers), against p99 380 on handler threads: a committing pass's
handlers waited for the rest of that pass's submissions. The gated post's second look for a thread
cost 4.4 wakes a frame.

Tests (submission_turns): a_committing_pass_keeps_only_its_own_submission_handlers_{exact,grouped}
(fails at control C2 m3-max-35888, the hand-off reverted: the earlier command buffer's handler ran
on the test thread); a_gated_completion_is_posted_with_one_look_for_a_thread_{exact,grouped} (fails
at control D m3-max-35877, post_behind + open: [(true,2)] against [(true,1)]). The check takes the
device's queue plan.

Verified: msi m3-max-36014 at bd810397db: build, runtime clippy plain and --cfg m2v_gpu, unit
44/44, sigs, lavapipe suites 126/126 (encoder_holds TextureWrite passes). Workspace clippy x3,
rustdoc and lvpval 30/30 at the pre-rebase tip 2d09ed2392 (m3-max-35927). PHOENIX m3-max-35923
(suites at df21628b0f): handler-thread wakes per frame 50.2 -> 48.37 (post_behind + open 8.9 ->
post_gated 6.72); seen to seen-handler p50 11, p99 3658 us.

Degradation kinds added: none.
2026-11-16 03:21:03 -08:00
Anees Iqbal 528379dad5 RUNTIME 2439: Merge on the host whole up to 1 MiB of rows; count host steps
On the Iris Xe (RPL-P, ANV) the split merge's own GPU work (two buffer
copies of the pieces beside the texels, three barriers and the kernel's
dispatch) cost about 0.6 ms a command buffer for the guest's 34x34
RGBA16Float target (m3-max-35898: draw minus clear 0.69 ms, against
0.10 ms when the merge went on the host whole), while the host step's
word loop costs about 0.30 ns a byte (4.97 ms for a 1920x1080 target's
16.6 MB, half its texels changed). So the split pays only past about
2 MB of rows.

A merge on the host whose cut rows hold at most HOST_WHOLE_BYTES (1 MiB,
half the break-even) now goes on the host whole again; larger ones
split. A merge none of whose rows' lines holds a byte beside its texels
still goes by its kernel alone, as on any device. The whole merge is
also the exact form for the unmeasured case (a CPU write to a texel the
commands left in a line whose other bytes they changed), so the known
gap now applies only where the kernel stores: past the bound, and where
no row's line holds a byte beside the texels. Both forms keep the
measured padding contract, so there is no switch and no FAST-PATHS row.

WorkCounts::shadow_host_steps counts the host steps that ran for
encoders' copies back spliced and merges on the host: against
command_buffers_submitted, the GPU-to-CPU round trips a command buffer
pays, for a walk to read before any deferral of them.

Tests:
- shadow_runs::merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it:
  over pages 16 bytes into a page, a 512x512 BGRA8Unorm target (1 MiB
  of rows) compares every byte of its rows on the host, and a 512x513
  one each row's first and last lines alone; each one host step.
- shadow_write_lines: the contract test's draw merges now compare every
  byte of their rows; the cost test alternates its verdict arms round by
  round, so clock drift and order weigh on both alike (the 1080p gap
  35898 showed, equal in Clear and Draw, with the same work recorded in
  both arms by every count); a new test prints, for a render target
  whose rows end a texel short of a 4096-byte page (1023x256 and
  1023x1024 BGRA8Unorm), under the device's own check and default
  policy, over pages imported by pointer and as dma-bufs: every host-page
  class's renders and copies verdicts for those row ends and its memory
  flags, the form the texture takes with its notices, and the median per
  command buffer of a clear-and-store and of a draw.

Degradation kinds added: none.

Verified: msi m3-max-35933 at f763e15338 (same tree): CLIPPY=0, CLIPPY_GPU=0, API=0 (15/15), release archive built. PHOENIX, lavapipe and the Iris run follow on development.
2026-11-16 02:57:29 -08:00
Anees Iqbal 438fdd4eee RUNTIME 2438: Merge on the host only the lines beside a texture's texels
A shadow's merge in place into host pages, on a device whose stores
write back the lines they end in (the Iris Xe under ANV) or whose check
has not answered, went on the host whole: the host step compared and
stored every byte of the merge's rows. On the Iris that cost 12.7 ms a
merge for a 1920x1080 RGBA16Float draw (17.7 ms a command buffer
against 3.7 ms by the GPU kernel), and the guest's scene has about 73
such shadows.

The merge now splits as the splice of a copy back does:

- Its kernel stores the changed words of each row's bytes in the lines
  that hold the texture's texels alone (ShadowMergeStores::Words, never
  whole blocks).
- The host step merges only each row's bytes in the lines that also
  hold a byte of no row of the texture's: the bytes between the rows and
  around them (shadow_splice::beside_texels; at most a row's first and
  last line).
- Before the kernel the GPU copies those pieces' kept bytes into a
  region of the command buffer's arena, then their changed bytes over
  them in the kept part, so the kernel finds them unchanged and stores
  none of them; the host step compares the region's bytes with the
  changed part's.
- The host step compares 4-byte words and stores a changed word with one
  AtomicU32 store (the changed word where all four bytes differ, else
  the word as it holds it with those bytes changed, as the kernel's
  Words form does); bytes outside whole words go one by one.
- A merge none of whose rows' lines holds such a byte (rows that start
  and end on lines, as the 1920x1080 plane's 15360-byte rows do) goes by
  its kernel alone, with its fetch view and kept image where it has
  them. A merge not cut to its texels' rows stays on the host whole.

The measured contract is the padding: row_padding_writes found the M3
Max, the 5300M and the UHD 630 keeping CPU writes to the bytes between
and around a texture's rows under clears, stores and draws, and over
IOSurfaces under kernels. No probe measured a CPU write to a texel the
commands left inside a line whose other bytes they changed, while the
command buffer runs; the kernel now stores into such lines, so that
write may be put back on the Iris. FAST-PATHS's known gaps record it,
beside the measured contract.

WorkCounts::shadow_merge_bytes_on_host counts the bytes the host steps
compared. Buffer::own_pages_flags gives a buffer's memory type flags,
which the cost test prints for a buffer made as the host scratch is,
beside the host loop's time over plain heap memory and over that
memory (1920x1080, half the texels' red and blue changed).

Tests:
- tests::shadow_splice (pure): the pieces equal the rows' bytes in
  lines beside the texels, found byte by byte, over 9 shapes and 6 page
  phases (wrapping among them); the host loop stores the differing bytes
  alone at every alignment.
- tests::shadow_write_lines: each draw merge's host step compares 16
  bytes a row (the row's last texels, in its padding's line); the cost
  test's 1920x1080 draw no longer merges on the host.
- tests::shadow_runs: the rebind test of host merges puts its pages 16
  bytes into a page, so every row's first and last lines hold bytes
  beside its texels, and asserts the bytes compared (a line a row).

Degradation kinds added: none.

Also (65db6f5b40): the old device-local query, left with no callers, is gone; the probe prints
the scratch's memory flags by name.

Verified (fplend): msi m3-max-35872 at a5289d8132 (same tree as 65db6f5b40): clippy 0, clippy
--cfg m2v_gpu 0, api_signatures + api_surface 15/15, debug and release archives built; 35850:
tests::shadow_splice 5/5 (host pieces against a byte-by-byte answer over 9 shapes x 6 page
offsets; the CPU word loop at every alignment). PHOENIX, lavapipe, rustdoc and the Iris run follow.
2026-11-16 02:29:15 -08:00
Anees Iqbal 2feb4e70f1 RUNTIME 2437: Scheduler: hand a pass's submission handlers to the device's handler threads as it goes on
What: the scheduler thread's passes no longer run the submission handlers of the command
buffers they submit (or hold in a group, or make Scheduled behind a host step) at the end of
the pass. Each time the pass is about to look for its next batch, it hands the handlers taken
so far, as one segment with its Turns ticket, to the device's handler pool (one context of the
"metal2vulkan-handlers" threads, made at the first hand-off), and goes on submitting. The
segment runs there in its turn, so submission order holds across passes and with
commit_and_submit's own pass, which still runs its handlers inside the call on the committing
thread. A pass that settled a switch of storage forms keeps the handlers it took from then on
and runs them itself after the switch ended, as before, since the switch must end before those
command buffers are Scheduled.

The blocking wait in run_scheduled (a Finished that found Scheduled owed waited on a pool
thread for the submission handlers) is gone: such a Finished is posted behind a context gate
(finish_after_handlers), its place kept, holding no thread, and the thread that ran the
handlers opens the gate; the Finished then runs the owed Scheduled first. So no handler thread
waits for a submission handler, and the pool's cap cannot be exhausted by such waits.

A held group is cut short for another queue's submission handlers (Alone::Handlers) only where
the pass keeps them (a settled switch): handed-off handlers hold back no pass.

Why: in the guest-shaped submit-cost leg on PHOENIX, a command buffer's submission handlers
started 1683/5299/5776 us (p50/p99/max) after its own vkQueueSubmit returned, behind the rest
of the pass; 4561 of 5280 command buffers were seen complete before their own submission
handler ran, and seen -> seen handler was 1.4 ms p50 / 5 ms p99 against Metal's 0.28 ms p99.

Tests: submission_turns gains a_pass_s_submission_handlers_run_while_it_goes_on_{exact,grouped}
(a handler of an earlier submission starts before the pass's later submission returns plus the
pause) and completions_before_their_submission_handlers_hold_no_handler_thread_{exact,grouped}
(6 queues with owed Scheduled on a pool of 2 threads, all complete within a bound; test hook
contexts::TEST_LIMIT). waiter_submits::Held now holds the scheduler thread with a test hook
after the pass that handed off its command buffer's handler (trace::hold_after_hand_off,
Point::HandedOff), since a submission handler no longer runs there. Tests and lanes that held
the scheduler thread in a submission handler hold it in a submission check instead
(unsubmitted, host_memory's deallocator lane); queue_order's take-up probe notes from the
check, which still runs on the scheduler thread; commit_and_submit's held-check test asserts
the orders that hold (A's handler before B's, B's check before B's handler) instead of one
interleaving; the submission_handlers lane expects the handler threads; grouped_submissions'
cross-queue handler lane counts X and Y's one submission once all completed.

Docs: add_submission_handler names the threads (inside commit_and_submit: the committing
thread; otherwise the device's handler threads), README, RUNTIME-PORTING, FAST-PATHS (the
grouped-completion row's handler rule, the commit cost entry), scheduler, inbox, group,
submit, contexts.

Also: the completion_latency guest-shaped leg times each submission handler from its own
submission's return; the unsubmitted check and the deallocator lane hold the scheduler thread
where an empty opener runs no submission check.

Verified (complat): msi m3-max-35809 at 0e0c55e4e8: build, clippy -D warnings (runtime, plain and
--cfg m2v_gpu), unit 44/44, signatures, lavapipe suites 122/122, all 0; gem10 35797 at 4aa9c2ac29:
workspace clippy x3 and rustdoc 0. Negative controls (msi 35811, lavapipe): with the blocking wait
back, completions_before_their_submission_handlers_hold_no_handler_thread fails under Exact and
Grouped (5 of 6 never completed with 2 handler threads); with no hand-off,
a_pass_s_submission_handlers_run_while_it_goes_on fails under both. PHOENIX suites and the
submit-cost leg before/after follow.
2026-11-16 02:01:45 -08:00
Anees Iqbal be720853a5 Name no consumer benchmark in comments, tests or docs
Eight comments and docs (dispatch_chain, compute_instantiated, spares_compute, unshared_hold and
its tests, FAST-PATHS) named the guest compute benchmark a workload came from, and two named a
consumer's job labels. AGENTS.md keeps consumer apps and benchmarks out of the tree; the shapes
and numbers stay, described by what they are (a guest compute benchmark's super-resolution
workload, its fluid simulation).

Verified: git grep finds no such name; cargo fmt. Comments and docs only.
2026-11-16 01:39:25 -08:00
Anees Iqbal 2824464479 Storage twin docs: NonWritable states read-only memory, nothing more
What: views::declare_twin, DriverWorkaround::PushReadsLengthenThreadPayload and docs/API.md
section 5 no longer say that the twin's NonWritable decoration lets ANV fold or merge its loads, or
that the twin without it read more than the uniform view. They keep the fact: the twin binds the
uniform view's own range of a constant buffer, which the dispatch only reads, so its views are
decorated NonWritable. The decoration and its test stay.

Why: a585a74686 gave that as the cause of the Iris regression between pins 825997e49c and
44505b3807. The evidence since says it is not:
- Iris A/B m3-max-35592 (ANV, Mesa 26.2.6, 5 rounds): dispatch_chain --binds params ran
  358.8 us a dispatch with and without the decoration.
- Iris walk m3-max-35628 at bd3c1a8c37 (the decoration in): the two regressed workloads did
  not move (19.72 -> 20.01 s and 28.53 -> 28.36 s GPU).
- ANV's own stats (INTEL_DEBUG=cs, m3-max-35722) for a kernel of ours that reads its constant
  blocks through helpers and a private struct: twin at key 1 without the decoration and with it
  compile alike (SIMD16, 722 instructions, 79 sends, no spills).
The regression's cause is under investigation separately: a scratch build without storage twins
(68e39640e9, walk m3-max-35702) brought the workload back, so the twins are involved, not their
decoration.

No behaviour change: doc comments and docs only, no version bump. The runtime-sources pin
re-pins at landing (views.rs and profile.rs are hashed).
2026-11-16 01:34:11 -08:00
Anees Iqbal 518d6d8443 RUNTIME 2432: Shadows: merge on the host over host pages on devices that write lines back
What: a shadow's merge in place into a no-copy buffer's host pages, on a device whose
check of those pages failed, or has not answered, the copies or the shader writes of
texels whose rows end inside a line (the same rule as the copy back's splice), now goes
on the host. Its keep and the copy of the texels the commands left go into two parts of
a Shared scratch (ScratchKind::ShadowHost; the fetch view is not used, so the changed
texels are always copied). The encoder records only that copy, and a host step of a
batch of its own (Deferred::ShadowSplice, now carrying HostWrite::Splice or ::Merge)
compares the parts eight bytes at a time and stores each byte that differs into the
pages with atomic byte stores. Such a texture joins no run of passes (render.rs), so
each pass merges as its encoder ends. Devices where both checks passed keep the
kernel merge.

Why: the Iris probe (m3-max-35510) showed the merge kernel's stores losing CPU writes
to padding bytes in the line that holds each row's last texels, as the copy back did.
A CPU store changes only the bytes it stores, so the bytes the commands left, and
every byte the CPU writes meanwhile, stay. Metal keeps those bytes
(conformance probe row_padding_writes.m).

Where the merge stays on the GPU (FAST-PATHS known gaps): merges recorded between a
pass's instances, before a tile dispatch, into a held command buffer, at a segment's
end, merges through a copy, and the runtime's own Shared memory.

New WorkCounts fields: shadow_merges_on_host, shadow_merge_host_nanos.

Tests: shadow_write_lines now asserts the Draw rounds (keep + merge) put back no byte
and go on the host under unanswered verdicts, and follow the measured verdicts in the
second test. A new test, costs_of_a_write_back_spliced_or_not, prints the median
command-buffer time of a copy back and a merge for 34x34 and 1920x1080 RGBA16Float,
with verdicts unanswered and passed.

Degradation kinds added: none.

Verified (fplend): msi m3-max-35675 at bdb1e2cbae clippy (runtime, all targets/features, -D warnings) 0,
touched unit tests 3/3, api_signatures + fast_paths 34/34; msi 35689 clippy --cfg m2v_gpu 0.
PHOENIX suites (35711), lavapipe, rustdoc and the Iris cost run follow.
2026-11-16 01:05:03 -08:00
Anees Iqbal 9ea0a9c1f6 RUNTIME 2431: Shadows: splice a copy back into host pages on devices that write lines back
What: a shadow's copy back (Step::Back) of a 2D texture's image, or of a texture
buffer's staging buffer, into a no-copy buffer's host pages is spliced where the
device's check of those pages (DmaBuf or Pointer) failed, or has not answered, the
copies or shader writes of texels whose rows end inside a line (Access::Copies or
Access::Writes of RowEnds::InLines, Failed or Pending). The GPU copies only the
columns that fill whole lines of memory (nonCoherentAtomSize): one region a slice
where its rows are a multiple of a line apart, else one a row. Each row's head and
tail columns go by the GPU into a line-aligned region of the command buffer's arena,
and a host step of a batch of its own (Deferred::ShadowSplice, after the work before
it completed) copies them into the pages a byte at a time, as the CPU's stores go.
The encoder notes the truth's writes after the step. A copy whose texels fill whole
lines alone copies back as before; a device where both verdicts passed copies back
as before. New count WorkCounts::shadow_copies_back_spliced.

Why: on the Iris Xe (ANV) a copy of texels into a buffer's rows writes back the
64-byte line holding each row's last texels whole, putting back older values over
the CPU's writes beside them. The lane's probe (m3-max-35510) lost 3,539 to 14,319
bytes a kind in 300 command buffers through a shadow's copy back and merge, where
Metal keeps every such byte (row_padding_writes.m). This breaks Metal's contract on
the guest's bytes; the merge is the next change.

Where the copy stays (docs/FAST-PATHS.md, known gaps): a copy back between a render
pass's instances or before its tile dispatch, into a held pass's command buffer, at
a segment's end recorded at a commit or a host step, of rotated, two-plane, tiled or
heap depth/stencil textures, and into the runtime's own memory.

Tests: tests::shadow_splice (the cut run as GPU and CPU over a map of host bytes:
every texel once, no GPU byte in a shared line, every shape of texel, width, pitch
and phase); tests::shadow_write_lines (the probe made a device test: the guest's
34x34 RGBA16Float target over dma-buf pages, buffer and plane forms, a clear's copies
back put back no byte the CPU wrote beside them and are spliced; and a copy back
spliced exactly as the device's measured verdicts say).

Degradation kinds added: none.

Verified (fplend): msi m3-max-35614 clippy 0, tests 0, signatures 0; 35623 clippy m2v_gpu 0;
lavapipe 35625 clippy m2v_cpu_icd 0, 216 passed, rustdoc 0; PHOENIX 35632 (um790) in-place +
shadow suites 287/287, shadow_write_lines 2/2: under the measured verdicts (Copies and Writes
Passed) 0 spliced; under HostPageTexturePolicy::Shadow (no check, verdicts Pending) every copy
back splices (+300 in 300 rounds, 0 bytes put back). The Iris run follows.
2026-11-16 00:46:56 -08:00
Anees Iqbal a585a74686 SEMANTICS 2134 / RUNTIME 2427: A uniform view's storage twin is decorated NonWritable
What: memory::views::declare_twin states the twin's binding unwritten
(ModuleBuilder::unwritten_buffer). The serializer then decorates the twin's variables NonWritable,
its word view and its uvec4 view, where its own walk finds no store reaching them. No store goes
through a twin: TwinMem's write, write_bits, write_unit and write_vec all refuse.

Why: on the Iris profile (DriverWorkaround::PushReadsLengthenThreadPayload, ANV, Mesa 26.2.6)
RUNTIME 2413 reads a kernel's constant slot through its storage twin where the slot's
RangeAtBindOffset holds. The twin was not decorated NonWritable, because serialize::non_writable
only takes the bindings the lowering states unwritten. ANV runs nir_opt_access
(anv_shader_compile.c), which marks a storage buffer's loads reorderable only where the variable
is NonWritable or the shader writes no buffer. A kernel that writes its output therefore kept
every twin load apart, wherever it stood: no CSE, no hoisting, no merging. The uniform view's
loads, a uniform buffer's, are always reorderable, and the driver folded them.

Metal's compiler leaves a constant buffer's repeated loads for its own backend to fold. One guest
depthwise convolution kernel loads its params.srcSize (<4 x i32>) four times in every iteration
of its tap loop and its dstSize about ten times, and every inlined sample reads its ndArrayParams
again. Read through the twin, each of those loads ran per thread. A benchmark's Iris walk rose
from 754 to 1120 us a dispatch on that workload between pins 825997e49c and 44505b3807, and
825997e49c rebuilt matched the old walk (771). dispatch_chain's bump_wide reads its constant
word once, so the 2413 A/B could not show this. --binds params now can.

Aliasing (why NonWritable states nothing the uniform view did not):
- storage_twins gives a twin only to a slot whose form is a uniform view by its own window. That
  is view_kind's uniform view: a Metal constant address-space slot that no store or atomic of the
  function reaches, with a Bounded window, never the per-stage storage-buffer fallback.
- bind::instantiate::bind_buffers writes the twin's descriptor with the uniform binding's own
  buffer and DescriptorRange, pushed once for both.
- So the twin's bytes are exactly the uniform view's, under the same rule that chose a uniform
  view before the twin existed (the base form, 825997e49c).
- A uniform buffer is read-only to the module, and nothing orders it with a write through another
  descriptor of the same dispatch. Metal's constant address space is read-only for the dispatch.
  A guest that binds one MTLBuffer range as both a constant and a written device slot got no
  ordering from the uniform view either; the decoration claims no more than that.
- The runtime binds a twin nowhere the uniform view is not bound. A slot bound to nothing binds
  both from the device's zero buffer (RUNTIME 2420), which no command writes.

Docs: views.rs (the module docs and declare_twin), ModuleBuilder::unwritten_buffer,
serialize/non_writable.rs, the workaround's profile doc, docs/API.md section 5.

Test: engine_access's
a_kernel_uniform_view_reads_its_storage_twin_at_its_bind_offset asserts that every variable bound
at the twin's binding is decorated NonWritable. It fails without the change, where no twin
variable is.

SEMANTICS_VERSION 2134: translation output changes on the Iris profile alone (the twin's
decoration). The golden hashes and the authored compile census re-bless on development. New
Degradation kinds: none.

Also: dispatch_chain gains --binds params and params-off (bench only), a kernel that reads its
constant block again in a loop: params reads it through the twin at its bind offset
(RangeAtBindOffset 1), params-off through the uniform view at its residual (the base form).

Verified (ftreg, msi m3-max-35578 at 00a41f052f): clippy -p metal2vulkan -p metal2vulkan-runtime
--all-targets --all-features -D warnings 0; twin/NonWritable tests 44/44; negative control
(views.rs before the change) fails engine_access's twin test with [(12, false)]. Release A/B
arms built (35573/35574/35576); the Iris A/B follows. RUNTIME 2427: the translation changed.
2026-11-16 00:20:20 -08:00
Anees Iqbal 8b70cf1ca7 FAST-PATHS: what listing a render target's sibling formats costs its compression
The view bullet now states the measured cost of cdcd787fb8's listing of
a render target's channel-order sibling formats (BGRA8Unorm and
BGRA8Unorm_sRGB of an RGBA8Unorm texture) in its image's format list,
which lets a pass render into such a view of the image in place.

Measured with tests::reordered_list_compression (ignored probe, carried
archive of d6366dcf65 built in m3-max-35552 on msi), the runtime's own
plan of a 2048x2048 Private ShaderRead|RenderTarget texture, its
VkImageCompressionPropertiesEXT::imageCompressionFlags, Mesa 26.2.6:
- Radeon 780M (PHOENIX, m3-max-35557) and RX 7900 XTX (NAVI31,
  m3-max-35558): DEFAULT as planned, without the sibling's formats and
  not mutable, for RGBA8Unorm and BGRA8Unorm.
- RX 550 (POLARIS12, m3-max-35556): DISABLED in all three forms,
  the not-mutable control included: the driver compresses no render
  target image of the runtime's usage there, so the list costs nothing.
- lavapipe (m3-max-35553): no VK_EXT_image_compression_control.
ANV and NVIDIA not measured.
2026-11-16 00:09:12 -08:00
Anees Iqbal b034129644 RUNTIME 2426: Grouped: count each batch that went alone by why, and unshared queues' batches
Under CompletionPolicy::Grouped a batch refused a place in a group while no group
was held went alone and was counted nowhere: group_ends_* count only groups that
held a batch. So the consumer's steady Launchpad walks (batches_grouped 0,
group_ends_drained 1 a window) could not say why nothing grouped.

Each batch on a VkQueue whose batches group that goes in a kernel submission of
its own now counts once, by the first reason in group::Alone's order
(WorkCounts::batches_alone_* and batches_held_alone_*): an unshared queue's
batch, a binary wait or signal (a completion sync file), a sparse update, pieced
work, a fence, an unknown or too long expected run, first work or a wrapped image
with no group held, a committing thread's submission; or, held in a group that
went holding it alone, what sent that group (at most one earlier submission in
flight, an unshared queue's hold on the VkQueue, a head waiting for the GPU,
another queue's handlers, a waiter, kept with none joining, a batch that could
not join, or other). Group::keeps answers why it does not keep. And
batches_of_unshared_queues counts unshared queues' batches on every device, so a
walk under either policy gives their share.

The validation lane's alone_batches checks one batch per reason it can make
deterministic (unknown run, at commit, one pending, a completion sync file, an
unshared queue, beside an unshared queue) on a device that groups, and none
counted elsewhere; steady_presents (ignored, a measurement) runs a steady
present shape with an unshared compositor queue and prints the spread.
Conformance classes the counts that follow what the host had seen complete as
not the case's own. API signatures blessed.

Also 4d71df7f28 (a type alias for clippy) and 5e04b74b48: FAST-PATHS: grouped submissions' measured lateness, the unshared exclusions and the alone counts

Row 38 edited in place, docs only. It now states:
- the measured cost of the fast form in the consumer's guest walks on RADV at
  ca6259f7d1 (lateness of command buffers seen complete after a later one's
  end, p99 18.4 ms against Exact's 2.1 ms on the 780M, 5.1 against 2.4 ms on
  the XTX), against the Metal oracles' p99 of at most 0.28 ms;
- that the bounds are on expected runs, so a later batch running longer than
  its queue's recent ones makes earlier members late by its actual run, which
  no bound set ahead can cap;
- that CompletionPolicy::Exact adds none of this lateness;
- that an unshared queue's batches join no group on a VkQueue held back for it
  and no group is kept there, which on a device of one graphics VkQueue (RADV,
  ANV, lavapipe) keeps no group of any queue: read from group.rs (Group::keeps,
  CommandBufferShared::groups) and create.rs's queue plan;
- the new per-reason counts (batches_alone_* and batches_of_unshared_queues).
The fast form's bounds are unchanged (owner's call, AGENTS.md rule 1).

Verified in the lane: m3-max-35367 at 71158a8ea4 plain clippy (runtime, validation, conformance,
metal2vulkan) 0, api_signatures 3/3, conformance 119/119, runtime group tests 12/12;
m3-max-35394 at 5e04b74b48 lavapipe clippy m2v_cpu_icd 0, alone_batches + grouped_submissions
16/16. Still running when landed: clippy m2v_gpu, plain clippy + fast_paths + rustdoc at the tip,
one PHOENIX run of the counts (path-ran evidence). Bounds unchanged.

New Degradation kinds: none.
2026-11-15 23:15:15 -08:00
Anees Iqbal 59fc85ea83 SEMANTICS 2133 / RUNTIME 2425: OpenCL mode: a 1D image bound to a real 1D texture reads it, through a variant
An OpenCL-mode kernel declares each image1d_t / image1d_array_t slot as the 2D texture of
height 1 Apple's OpenCL binds (canon::opencl::entry, canon::opencl_1d). A real 1D or 1D array
texture is a VK_IMAGE_TYPE_1D image, which takes only 1D views (Table 18,
VUID-VkImageViewCreateInfo-subResourceRange-01021), and a 1D view cannot sit in the slot's
Dim 2D descriptor (VUID-vkCmdDispatch-viewType-07752). So the binder wrote the declared 2D
type's neutral (PlanDiagnostic::IncompatibleBinding) and every read answered zero, outside
both measured answers (Radeon Pro 5300M: the 1D values; UHD 630: layer 0 of the array).

Now a per-slot variant keyed by the bound texture's type:
- air: Entry::open_cl_1d_images records the texture indices of an OpenCL-mode kernel's 1D
  images; SpecRequest::open_cl_lines names those a 1D texture is bound for, whose parameter
  keeps its texture1d type (opencl::entry) and whose operations stay 1D (opencl_1d::expand
  skips a call whose texture operand is that parameter).
- The kernel states RuntimeFact::OpenClLineTexture { slot } (Mechanism::Variant) per 1D image,
  in the base and the variant alike; nothing else states it.
- The compute plan puts such a slot in VariantKey::open_cl_lines where the shape binds a
  Type1D (Type1DArray) texture at a 1D (array) image read by the kernel
  (bind::plan::slots::open_cl_line_variant). VariantKey::lowering_inputs carries it to
  LoweringInputs::open_cl_lines, the specialized-entry cache key and SpecRequest. The variant's
  interface states the slot Type1D / Type1DArray, so its plan binds the 1D view and states the
  same key. The answer is the 5300M's.

With the set empty (Apple's 2D bindings) canon, the SPIR-V and the VariantKey are as before;
the base artifact gains only the OpenClLineTexture facts. The reflection still states the 2D
types. No runtime source changes.

Tests: canon::tests::opencl::opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations,
engine_opencl_mode::an_opencl_mode_kernel_reads_real_1d_textures_through_its_variant and
a_plain_2d_texture_slot_given_a_1d_texture_binds_the_neutral; the runtime's
opencl_mode_1d_images_read_real_1d_textures (the repro).

SEMANTICS_VERSION 2133. api_signatures blessed (5 records); REFUSALS unchanged; docs/API.md's
OpenCL images paragraph.

Also e1aba1ad67 (the repro test), 9f3b309b65 and 8f2677c0ae (compile fixes: an Idx import; every SpecRequest literal names open_cl_lines).

Verified in the lane at 8f2677c0ae: lavapipe (m3-max-35393) OpenCL-mode runtime tests 19/19, the
new opencl_mode_1d_images_read_real_1d_textures among them (it failed at e1aba1ad67, m3-max-35348:
[0,0,0,0] for [10,11,12,13]); the 2D height-1 read and write tests pass at both. air OpenCL tests
9/9 (m3-max-35386). Still running when landed: the translator's engine_opencl_mode and api tests,
clippy x3, rustdoc, executor parity (runtime_lane::executions, runtime_run), the probe comparing
the guest 2D path's SPIR-V, facts and plan at base and tip, the PHOENIX run.

RUNTIME 2425 because the runtime's variant choice moves (bind::plan::slots); no runtime source
changed. New Degradation kinds: none.
2026-11-15 23:13:43 -08:00
Anees Iqbal 662460fe5e RUNTIME 2424: Storage twins take 0 where their kernel reads any other word the binder writes for it
What: the runtime's uniform_residual_form sets every twin's RangeAtBindOffset to 0, as it does
beside a residual read, also where the twin's stage reads under the key another word the binder
writes for it (residual::reads_other_words, from the interface's PushPlacements): a field placed in
its push range or its ArgumentTable, but a slot's SlotBindOffset residual where the key sets its
RangeAtBindOffset, and the DispatchRegion words where the key leaves the stage's MultiRegion 0 on a
variant that does not run a flat grid (a flat grid's one region reads them whatever MultiRegion
says). A root table's or execution status's address, a replay's region record, a slot's guest
base, a texture's levels and every other placed field count wherever placed. keyed_regions passes
the variant's flat_grid; the render callers pass false (render stages have no twins).

Why: RUNTIME 2419 kept a twin's key wherever no other RangeAtBindOffset of the key was 0, so a
kernel with a twinned constant view that also reads a root table's address (a pointer through an
argument buffer, dispatch_chain --binds ptr), or a multi-region region (dispatchThreads' edge
regions and group-count splits, tile and partial-threadgroup plans), or a flat grid's region kept
reading the twin at its bind offset while its thread payload stays long: the 2419 mechanism (ANV,
Mesa 26.2.6, Iris Xe RPL-P: moved arm 154.0 us through the twin against 143.1 us through the
uniform view, job m3-max-34864), whose cost is the stage's push reads (job m3-max-34063).
dispatch_chain --binds 4 reads thread_position_in_grid but dispatches threadgroups with
MultiRegion 0, so its measured twin gain (102.1 against 142.8 us) is kept.

Runtime only: no translation output, plan or artifact moves (the executor and the execution
record's plan check compare plans and artifacts, which the runtime's region keys are not), and no
creation key. Only dispatch keys of a kernel with a twin and such a word move, on the Iris profile
alone.

Docs: residual.rs's module docs and functions, keyed_regions, the workaround's profile doc and
docs/API.md section 5.

Tests: general_form's a_twin_takes_0_where_its_stage_reads_another_word (the twin zeroed where its
kernel reads another word, kept where it reads none, another stage's word ignored) and
a_stage_reads_its_region_under_multi_region_and_every_other_word_it_places (reads_other_words'
cases: MultiRegion 0 and 1, a flat grid, a residual held or not, an unkeyed residual, a root
table's address, another stage's field).

Verified in the lane (m3-max-35286, msi, at def6a68f94; each step's own exit code): clippy
-p metal2vulkan-runtime --all-targets --all-features -D warnings 0; tests::general_form 6/6;
lavapipe runtime_lane::executions + candidate::engine::runtime_run 34/34 (executor parity).
Still running when landed: clippy m2v_gpu and m2v_cpu_icd, rustdoc, the Iris A/B (a twinned
constant view beside a root table address / multi-region region, --binds 4 as control).

New Degradation kinds: none.
2026-11-15 22:36:33 -08:00
Anees Iqbal 92a77c7025 RUNTIME 2421: Continued passes on a device that splits at aliases, where no buffer write meets their images
What: on a device whose driver has DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer
(NVIDIA's 620.70.06 on the RTX 3090), an inline pass's last instance may now stay open, and
the next render encoder may continue it, as on every other device. Before it continues,
EncoderCore::continue_pass checks the group's byte writes (FoldOrder::byte_writes, the
leader's summary or the group's order) against every image the continuing pass uses:
its draws' images (AliasWrites' images noted apart), its attachments, and the uses of the
copies and steps before its later instances (render/inline_splits.rs, waiting_uses), all
of which record into the tail after what the group wrote there. Where one meets, the pass
begins its own instance in its own VkCommandBuffer, the measured form, counted in
WorkCounts::command_buffers_split_at_aliases. Where none meets, it continues and takes
the group's writes as its own (AliasWrites::continues), so what it records into the tail
after its pass is checked as a joining encoder's is.

Why: continuation cut the glass-panel frame's GPU time 11-26% on the 780M and Iris but was
off on the 3090. The open instance itself never holds a buffer write: its draws touch only
attachments, and anything else that records into the tail ends it first. The tail before
it can hold one, though (the leader's earlier inline instances and what records between
them), so the check is what the fact needs.

Also: render_fold's Lane::continuing (622368ab37) goes, since its lanes continue on every
device now. A test-only DeviceShared::aliases_split_forced lets lavapipe take the 3090's path.
New tests: tests::alias_split's continues unit test; tests::alias_split_device's count case,
a copy out of a texture after a continuation, a later instance of one pass reading an
earlier one's buffer write, and a texture over another buffer of the same host pages
(the last two are byte cases for two possible gaps on the 3090).

Also e818e7b442: Continued passes: a pass's uses of bytes count in the alias check, as an aliasing texture's are.
What: AliasWrites notes the bytes of buffers that the commands noted apart use (bytes_apart).
AliasWrites::continues now refuses a continuation where those bytes, or a Bytes use among
the pass's other uses, meet the group's byte writes, besides its images.

Why: a texture whose linear image aliases a buffer's bytes (Storage::Alias) names them as
the buffer's bytes (Texture::image_use), not as an image range. The lavapipe run with the
split forced (m3-max-35002) showed a pass sampling such a texture over bytes the leader had
just written continuing anyway: (1, 1, 1, 2, 0) where (2, 1, 0, 3, 1) was expected. A
continuation is refused rather than guessed at: a draw that reads, through a buffer, bytes
the group wrote also begins its own instance on such a device.

Tests: the count case now reads the written bytes through a texture over a buffer and

And dae7c2cad8: alias_split_device: the counted and copy-after cases read a texture over a buffer alone.

Verified in the lane (m3-max-35085, msi, at dae7c2cad8): clippy -p metal2vulkan-runtime --all-targets
--all-features -D warnings exit 0; lavapipe (m2v_cpu_icd) alias_split and render_fold 36/36; the
count test forced: written read (2,1,0,3,1), quiet read (1,1,1,2,0), unforced (1,1,1,2,0), texels
right. Still running when landed: the 3090 correctness job (alias_split, render_fold; F1-F3 byte
cases), PHOENIX render suites, clippy m2v_gpu and m2v_cpu_icd, rustdoc, the 3090 glass A/B.

New Degradation kinds: none.
2026-11-15 21:33:46 -08:00
Anees Iqbal cceefacfa7 RUNTIME 2420: A storage twin's neutral shares the device's zero buffer: the plan says which buffer writes are read-only
What: a new public BindingPlan::read_only_buffer(&DescriptorWrite): true for a uniform buffer and
for a uniform view's storage twin (DescriptorView::UniformWithStorageTwin, PlannedBuffer::twin),
which no function stores through. The runtime asks it where it used to read the descriptor type
alone (binding::descriptor's neutral arm, make_neutrals, binds_own_zeros), and makes the device's
zero buffer a storage buffer too, so a twin bound to nothing binds it.

Why: on the Iris Xe RPL-P profile (DriverWorkaround::PushReadsLengthenThreadPayload) RUNTIME 2413
gave a kernel's constant slot a storage twin. Left unbound, the plan writes the twin from the
ZeroBuffer neutral at a STORAGE_BUFFER binding, which the runtime took for a writable binding: every
dispatch took a fresh 64 KiB upload region, a dedicated VkBuffer allocated and zeroed, held until its
command buffer completed. Round 5974320352's Iris leg:
neutral_zeros_shared::dispatches_share_the_devices_one_zero_buffer, 8 dispatches made 8 VkBuffers
and 16 made 16.

Translation output and plans are unchanged (no SEMANTICS bump); the API addition is blessed in
api_signatures.tsv, and docs/API.md section 5 says it.

Test: engine_access::an_unbound_constant_slot_s_storage_twin_is_a_read_only_write plans
buffer_end_byte_load_constant with nothing bound on intel-irisxe-rplp-anv (the twin's STORAGE_BUFFER
write read-only, the written slot's not) and, as the negative control, on four other profiles (no
twin; read-only exactly at uniform buffers). The device check is the neutral test itself on the
Iris, which fails at the base.

Also, test premises on the Iris profile (round 5974320352's iris:runtime reds):
- a20c0a26d8: the compute creation test counts the forms its profile makes (1 + keyed storage views
  since RUNTIME 2410) and holds the pool only where completion is bounded (under Exact the second
  form runs on the pool).
- 88b8d31a32: set 0 at offsets counts the pipeline binds (draws past offset 0 take the residual form)
  and the push after each where the driver forgets pushed descriptors after a pipeline bind.

Verified in the lane (msi): m3-max-35051 clippy -D warnings -p metal2vulkan -p metal2vulkan-runtime
--all-targets --all-features exit 0, translator tests 71/71 (api_signatures 3/3); m3-max-35053
lavapipe (cpuicd) deferred_calls, neutral_zeros_shared, set_zero_at_offsets, uniform_bind_offsets
43/43. Still to run: clippy gpucfg and cpuicd, rustdoc, ONE Iris run of the three tests.

New Degradation kinds: none.
2026-11-15 21:23:17 -08:00
Anees Iqbal da08882991 RUNTIME 2419: Storage twins keep their key only where no other view reads its residual
On ANV (Mesa 26.2.6, Iris Xe RPL-P) a kernel's uniform view with a storage twin read the twin at
its bind offset wherever its own key held, also beside a storage view bound past offset 0, which
keeps reading its pushed residual word. There the thread payload stays long, and the twin's
per-lane storage read cost more than the uniform view's block read at its residual:
dispatch_chain --binds moved ran in 153.96 us a dispatch against base's 143.14 (job
m3-max-34864, 7 interleaved rounds, medians; ref's branch-free storage module 154.01), while
--binds 4, fixed and tex gained 28 to 38 %.

The runtime's uniform_residual_form now sets every twin's RangeAtBindOffset to 0 too where
another RangeAtBindOffset constant of the key is 0 (uniform_residual_form_of): a storage view
bound past offset 0, a twin at an offset no alignment divides, or a uniform view of no twin. The
kernel then reads its uniform views at their residuals, as base does. Where every view holds its
key, nothing changes.

Runtime only: no translation output moves, and no creation key (a creation's prediction binds
nothing, so its storage views and twins all hold). Only dispatch keys of a kernel with a twin and
a view off its bind offset move, on the Iris profile alone.

Docs: residual.rs, keyed_regions, the workaround's profile doc and docs/API.md section 5.

Test: general_form's a_twin_keeps_its_key_only_where_no_other_view_reads_its_residual (fails
with the cut sabotaged, the negative control in the check job).

Verified in the lane at 6d68983cc6: release build of the runtime and its dispatch_chain (m3-max-34932,
BUILD=0). Still running when landed: clippy plain, m2v_gpu and m2v_cpu_icd, rustdoc, the touched
runtime tests and the negative control (34931, 34933), the runtime suite on lavapipe, and ONE Iris
A/B of the arms and native code (base bcd50aba9f / opt2 680fc8997e / cut 6d68983cc6).

New Degradation kinds: none. Fixes the opt2 (SEMANTICS 2132 / RUNTIME 2413) regression of the moved arm.
2026-11-15 20:39:53 -08:00
Anees Iqbal c053f814b1 RUNTIME 2418: The in-import dma-buf class takes the dma-buf class's copies verdicts
The check's DmaBufInImport class makes its pages exactly as DmaBuf's
(dma_buf_pages, plus the gate that its buffer lies in one import dedicated
to nothing), and a copies round puts no image over the pages: its copies
rounds repeat DmaBuf's over pages made alike. At its copies turn it now
takes DmaBuf's copies verdicts for both row ends, and runs no rounds of its
own, where DmaBuf's were measured this run or known before (passed or
failed) and both classes' noted memory flags are known and equal, the
same-memory-type rule of RUNTIME 2417's crossing; otherwise its own rounds
run as before. The note names the source verdicts and the flags
("DmaBufInImport copies: DmaBuf's verdicts, Failed and Passed for rows on
lines, its pages made as DmaBuf's in memory of property flags 0x..: no
rounds of its own"). A shared failure is a proof for pages made alike; a
shared pass is one draw of the rounds' race fewer, which errs to the shadow.
CHECK_VERSION 22: a record of 21 may hold the in-import class's own copies.

Tests: tests::in_place's unit test of shared_copies (shared where measured
and memory alike; the control: coherent against cached either way, either
memory unknown, a row end unchecked or pending, every other class: none);
tests::in_place_check's device count (the shared note once and no rounds of
its own where the rule holds, the dma-buf class's verdicts taken; printed
with both classes' memory and the check's wall time).

Also 00ba762437 (test only): the lent targets' test prints every host class's memory on a device made
with VK_EXT_external_memory_host too (LENT-TARGETS-POINTER lines).

Verified in the lane (m3-max-34930, msi, at 937274ec72): runtime clippy --all-targets --all-features
-D warnings plain, m2v_cpu_icd and m2v_gpu exit 0; touched tests 39/39; gpucfg archive built.
On the Iris Xe (RPL-P, m3-max-34910 at 00ba762437): lent_dma_buf_targets passed; Pointer, Fresh,
DmaBuf and DmaBufInImport check pages all lie in memory of flags 0xf. Still to run: the PHOENIX
check wall time base against tip, and the Iris count test with the in-place suite.

New Degradation kinds: none. CHECK_VERSION 21 -> 22: every device runs one fresh in-place check.
2026-11-15 20:35:31 -08:00
Anees Iqbal b63bfbfac7 RUNTIME 2417: A render target's lend takes copies' failures through memory of one type
On the Iris Xe walk, a game engine's renderer made 73 RGBA16Float render
targets with free rows' padding over a no-copy buffer's dma-buf pages, and
each was a shadow: their renders failed for rows that end inside a line,
and the dma-buf classes' copies' verdict they lend that padding by
(`in_place::lent_to_copies`) was not failed in the recorded check, while
fresh checks fail it. A class's rounds catch a copy's line write-back only
as often as the CPU's writes race it, so the verdict hangs on a race.

The lend's copies verdict (`in_place::copies_verdict`, through
`InPlaceChecks::decided` at every decision site) now takes another host
class's copies failure, its reads passed, where the class's own kept every
byte or was unchecked, but only where the check's pages of both lay in
memory of a type of the same VkMemoryPropertyFlags as the driver reports
them: a write-back measured through memory of other flags says nothing of
this memory. Each class's memory flags are noted by the check and kept in
its record (CHECK_VERSION 21, eight words more). A shadow that renders with
free padding over host pages names the copies verdict it took in its
shadowed-texture notice. The line-write-back reason and docs (FAST-PATHS
host-pages row and the Iris known gap, API.md section 1 and the catalogue,
the kind's rustdoc) say so.

Tests: the unit test of the rule on the exact shape (same memory in place,
coherent against cached apart in both directions a shadow, unknown memory,
reads not passed, own-memory classes, own failed or pending kept, the
record's memory words); and a device test over a no-copy dma-buf buffer
(tests::lent_dma_buf_targets) whose control notes the pointer class in
memory of other flags and keeps the shadow.

Also 6e1f7b369d: the lend's memory flags are compared and printed as raw bits (ash's
MemoryPropertyFlags has no Debug impl here; clippy's chunks_exact_to_as_chunks).

Verified in the lane (m3-max-34875, msi, at 6e1f7b369d): runtime clippy --all-targets --all-features
-D warnings plain and --cfg m2v_cpu_icd exit 0; tests::in_place, tests::degradation*,
tests::texture_placement 38/38. Still to run: the device test on the Iris, PHOENIX and lavapipe
in-place suites, a sabotaged-build negative control, clippy m2v_gpu, rustdoc.

New Degradation kinds: none. CHECK_VERSION 20 -> 21: every device runs one fresh in-place check.
2026-11-15 20:15:41 -08:00
Anees Iqbal 45296d9b50 RUNTIME 2416: DmaBufRequest names the alignment of a one-chunk answer apart
A no-copy buffer's, heap's or rebind's request longer than the device's
sparse granule asked every chunk at a multiple of the granule (64 KiB on
RADV of Mesa 26.2.4), one chunk included. That rule was ours: one chunk
is bound to a plain buffer, which vkBindBufferMemory takes at any
multiple of the buffer's memory alignment (VUID-vkBindBufferMemory-
None-10739). The granule binds only an answer of several chunks, as a
sparse buffer is bound at multiples of its alignment in both the buffer
and the memory (VUID-VkSparseMemoryBind-resourceOffset-09491). So a
consumer whose guest buffers lie in a 64 MiB region's dma-buf at page
offsets off 64 KiB (15 of 16 such starts) answered them with dma-bufs of
their own, each one more import on every RADV kernel submission's list.

Expected effect on the consumer (reims's diagnosis of 1910 refused asks
on the 780M, m3-max-34841): only the 212 asks that are one run of pages
inside one region (30 of them 2 MiB heaps) were refused for this rule
alone; about 33 of their objects are live at a time, about 7% of the
~450 imports on each submission's list, and the walk's dma-buf imports
fall about 4092 -> 3900. The other 1698 asks are scattered 4 KiB guest
pages (runs per ask p50 6, 1317 crossing region ends): no piece of a
region holds them (a plain buffer is one range of one memory) and no
split does (the 64 KiB granule needs 64 KiB-aligned runs), so they stay
dma-bufs of their own.

DmaBufRequest gains one_chunk_alignment (the host page, or the plain
dma-buf buffer's memory alignment where larger; it divides alignment
and equals it where the granule is the length); a lone chunk is checked
against it, several against alignment, as before. Answers valid before
stay valid. The rustdoc and HOWTO say how a source picks between them.

How it is verified: tests::dma_buf_shared_files::one_piece_off_the_
granule_binds_a_plain_buffer_at_its_offset (the previous commit's,
refused Invalid without this one) and two_pieces_off_the_granule_are_
refused (its control, refused before and after) on a device whose
granule is coarser than the page (PHOENIX, RADV); tests::one_piece_bench,
a release bench of submission cost with 128 buffers over one region
answered by each rule. The evidence is in the lane's report.

Also: 51768bf6ab (tests: one piece off a device's sparse granule is taken; two such pieces stay refused),
and an ignored release bench, tests::one_piece_bench.

Verified in the lane (m3-max-34863, msi, same tree as 832c48ad2c): api_signatures 3/3; lavapipe
-E 'test(/dma_buf/) | test(/host_memory::a_source/)' 76/76 (lavapipe's granule is a page, so the two new
tests print "shows nothing" there); clippy m2v_cpu_icd --all-targets -D warnings. Still running when
landed: PHOENIX (64 KiB granule) base refusal, tip suite and bench; clippy plain and m2v_gpu.

API: adds the field DmaBufRequest::one_chunk_alignment (additive; a source that checks alignment alone
still answers validly).
2026-11-15 20:10:21 -08:00
Anees Iqbal 97da82174b RUNTIME 2414: WorkCounts times the device's dma-buf imports and pieces' joins
The consumer asked for the time its dma-buf import calls take: each
vkGetMemoryFdPropertiesKHR and vkAllocateMemory of a dma-buf import, and
each piece's join of a live shared import.

Three new WorkCounts fields:
- dma_buf_import_calls: imports of dma-bufs of host pages tried, made or
  failed, wherever made (buffers', heaps', rebinds' chunks, shared files'
  imports at a first piece, ahead by a handle or again after the
  residency released them, guest RAM chunks and run lists, images).
- dma_buf_import_nanos: their nanoseconds, on the threads that made them.
- dma_buf_join_nanos: the nanoseconds of the joins dma_buf_pieces_joined
  counts (a map look and a hold, no driver call).

Every import goes through one timed helper (Device::import_timed) that
queries the dma-buf's types and imports it; the four call sites (a
chunk of its own, a shared file, the two image imports) use it.

Verified: the shared-file tests assert one timed import and a positive
join time for four buffers over one file, and four timed imports with
no join time for four dma-bufs of their own.

Why: the consumer's ask (reims dmabufapi): their A/Bs could not report the time the dma-buf import
calls take from WorkCounts.

Verified in the lane (m3-max-34812, msi): clippy -D warnings -p metal2vulkan-runtime --all-targets
--all-features; api_signatures 3/3; lavapipe -E 'test(/dma_buf/)' 73/73: four buffers over one shared
file count import calls 1 with nanos > 0 and 3 joins with join nanos > 0; the control (four dma-bufs of
their own) counts import calls 4 and join nanos 0. Still running when landed: clippy m2v_gpu and
m2v_cpu_icd, the PHOENIX dma-buf suite.

API: adds the fields WorkCounts::dma_buf_import_calls, dma_buf_import_nanos and dma_buf_join_nanos (additive).
2026-11-15 19:58:43 -08:00
Anees Iqbal 765997d91f SEMANTICS 2132 / RUNTIME 2413: Kernel constant buffers on the Iris: a uniform view and its storage twin
What: on a profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV on the Iris Xe of
RPL-P), a kernel's uniform view (a read-only constant buffer whose window fits maxUniformBufferRange)
also binds its range as a storage buffer, its storage twin (DescriptorView::UniformWithStorageTwin,
ResourceKind::StorageTwin, BindingSource::StorageTwin). Each load selects, on the slot's
RangeAtBindOffset key, the twin read at the bind offset alone (key 1: a bind at an offset the class
divides, inline bytes, or unbound) or the uniform view at its residual (key 0). Specialization folds
the selection. The binder writes the twin from the slot's own source with a second descriptor range
starting at the bind offset. A twin's kind sorts last, so link numbers put a stage's twins after its
other bindings (docs/API.md section 5). Render stages and every other profile are unchanged: no twin
is declared and translation output is the same.

Why: on the Iris (m3-max-34275, dispatch_chain, us a dispatch) reading a kernel's constant buffer
through a storage view at its bind offset measured binds 4 142.7 -> 102.1, fixed 143.2 -> 101.3, tex
119.6 -> 74.4; at a non-zero residual the storage view lost (moved 143.1 -> 154.0), so the uniform view
keeps the residual case. Creation makes the key and its general form together (RUNTIME 2410), so no
first-use making.

Also: the cache codec lists the new variants; the interpreter binds a twin with no buffer of its own
to its slot's buffer; the device-replay tests name the twin's symbol. Docs: API.md section 5, the
workaround, the DEFECTS row, residual.rs, views.rs.

Verified in the lane: m3-max-34780 (at 7a862493b8) clippy -D warnings, metal2vulkan, runtime and
validation, all targets and features; the metal2vulkan suite 3626 passed, 11 failed: golden_hashes
(re-blessed on development) and 10 fixed at fca91cb055. m3-max-34804 (at fca91cb055) clippy 0. Still
running when landed: nextest over the three crates (34804), the authored compile census on the Iris
profile base against tip (M3), the Iris device tests and dispatch_chain A/B (every arm against base,
the branch-free reference for the folding check).

API: adds DescriptorView::UniformWithStorageTwin, ResourceKind::StorageTwin, BindingSource::StorageTwin
and BufferForm::storage_twin (additive to the enums: a consumer matching them exhaustively must add the
arm; a consumer binding set 0 itself fills the twin as docs/API.md section 5 says).
2026-11-15 19:48:21 -08:00
Anees Iqbal 725d2913d7 RUNTIME 2412: Bind shapes tell buffer length classes apart only as far as the device's range limits do
What: a new public bind::BufferRanges (a device's maxUniformBufferRange and
maxStorageBufferRange, BufferRanges::of(limits)), carried on each StageTable (buffer_ranges,
serde default), which the runtime sets on every table it reads (argument_table's AtBindViews,
beside the view base alignment: stage_table_reading, refresh_reading and the in-part
refreshes, AtBindViews::holds, and the debug check of a kept table). A buffer's shape states its
length class rounded up to the greatest class that fits the same limits
(BufferRanges::length_class); a class past both stays its own. BoundBuffer::shape and same_shape
take the ranges; BoundKind::of_bound and instantiate::bound_buffer class the bound length under
the table's ranges, so the instantiation's kind check takes a binding exactly where its class is
the plan's. The default (both 0) tells every class apart, as before.

Why: a guest compositor's serial compute encoder of ~1,140 fix-up dispatches over buffers of
many sizes made a new bind shape at 46% of its dispatches and planned again at 69% (the
consumer's XTX walks). A plan reads a length class only through class_fits against those two
limits (storage_view_variant and large_view_candidates against maxUniformBufferRange,
psb_variant and range_variant against maxStorageBufferRange); otherwise it only stores the class
for the kind check. On an RX 7900 XTX both limits are 4294967295, so every buffer below 4 GiB
takes the same plan decisions, and the dispatch_chain bench's 44 length-class shapes were one
plan. The bench there (job m3-max-34605, interleaved) matched the walk's split exactly (made
46%, found 18%, kept 36%) at 7.1-7.6 us a dispatch, against 4.1-4.4 us for the same stream of
one shape.

Exact: under the device's own limits, every class_fits answer of the rounded class is the exact
class's, so every plan decision, variant key and specialization is the same; under any other
limits the rounded class still bounds the padded length from above (padded < 2^class), so no
plan reads a range past a limit (it may take only a longer buffer's form).

Digests, cache keys and stored records: none carries the class. BindShape keys only in-memory
memos (Variant::plans, a state's kept Planned entries, the dispatch memo, the render draw
shapes); artifact digests and region keys are functions of the variant key and specializations,
which this leaves equal; validation and executor states keep the default ranges, so their shapes
and plans are unchanged; no pipeline record or warm record holds a shape. The serde form of
StageTable gains a defaulted field. So no SEMANTICS bump, in my reading.

Tests: bind::plan::slots length_classes_are_told_apart_as_far_as_a_plan_reads_them (4 GiB
limits, 64 KiB/128 MiB both ways round, 16 KiB, and none: every length's class answers both
limits' class_fits as the exact class does, bounds its padded length, is exact under none, and
bound_buffer takes a binding for another length's kind exactly where the classes are one, only
where the exact classes answer both limits alike); bind_shape_of's has_shape states and
same_shape pairs over range limits; runtime grid_classes
lengths_the_device_tells_apart_nowhere_plan_once (outputs of four length classes under 16 KiB,
one shape, 23 of 24 dispatches planned as before; 20 without this), and
shapes_and_classes_in_turn_each_plan_once re-made from the constant's binding (inline bytes, a
buffer, a buffer with a per-bind stride), since its three length classes are now one shape.
API: signatures blessed, api_surface, docs/API.md.

Also: 674c995a42 (dispatch_chain --zero-classes and --stay: a guest's fix-up dispatches over buffers of
many sizes), ad406afa87 (clippy in the new test).

Verified in the lane (m3-max-34674, gem10, at ad406afa87): clippy -D warnings -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features; translator tests 21/21 (the new
length_classes test, bind_shape_of, the slots tests). Still running when landed: the XTX bench before
and after (release, interleaved), the lavapipe bench, the runtime suite under m2v_cpu_icd on lavapipe,
the negative control (AtBindViews ranges set back to the default fails the new runtime test), clippy
gpucfg and cpuicd, rustdoc.

API: adds bind::BufferRanges and StageTable::buffer_ranges (serde default); additive.
2026-11-15 19:20:06 -08:00
Anees Iqbal 66de1cabbc SEMANTICS 2131 / RUNTIME 2410: At-bind storage views: creation makes the offset-0 key and its general form
On a profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV on the Iris Xe of
RPL-P) a storage view bound at offset 0 reads at its bind offset alone (RangeAtBindOffset 1). Every
plan made before a bind (a render state's creation prediction, a compute state's predicted region,
a warm pass's replay of a recorded dispatch) bound nothing, and an unbound storage view took 0, so
the creation made the general form and the commonest command, every storage view at offset 0,
made a second pipeline at its first use; the warm records named the other form.

- bind::plan::slots::range_at_bind_offset: a storage view bound to nothing takes what a bind at
  offset 0 takes; a uniform view keeps 0. Elsewhere no storage view declares the key.
- Render creation (pipeline/predicted.rs): the predicted key keeps its storage views' constants
  (uniform_residual_form) and the creation makes that key and, where it differs, its general form,
  together (RenderVariant::make_at_creation: pooled and waited for within one bound under Bounded,
  joined under Exact). The pool-ahead making of the key is deleted; the creation log names the
  general form's line.
- Compute creation (pipeline/dispatch_making.rs): the predicted region and its residual form,
  made together the same way. A warm pass's dispatch replay makes each region's residual form too
  (pipeline/dispatch_record.rs).
- The executor tells offset 0 apart at every slot (views_told_apart), so its plan of a case on the
  row is the runtime's (runtime_lane::executions).
- Tests: per-row expectations where offset 0 is its own shape or the creation makes two
  (made_at_creation, pipeline_records' Makings, grid_classes, dispatch_work, warm, the kernel
  creation counts in uniform_bind_offsets); the draw-again general-form test now binds
  colored_vertex's positions at 16 and colors at 0, a key neither creation form matches; a new
  device test, storage_views_at_offset_0_make_nothing_at_their_first_use, counts that a draw and a
  dispatch of storage views at offset 0 make, pool and take nothing but the creation's pipeline;
  an ignored timing test, storage_creation_times, times such a state's creation cold, from the
  memo and from the directory.
- Docs: DriverWorkaround::PushReadsLengthenThreadPayload, the DEFECTS row, residual.rs,
  predicted.rs, dispatch_making.rs, dispatch_record.rs, the warm pass, docs/API.md.

Also: c1d0b47a10 (WorkCounts docs name both creation forms; the first-use test types its positions),
6377eafa09 (storage_creation_times prints each round).

Why: fix forward for RUNTIME 2398-2400. Round cc1d619c7a's Iris legs failed about 16 tests on the
pipeline the creation made not being the one first use takes (made_at_creation, pipeline_records,
warm, restart, ycbcr_textures, executions, grid_classes, dispatch_work).

Verified in the lane: m3-max-34579 (at 2e6fbef8f2) clippy -D warnings, metal2vulkan, runtime and
validation, all targets and features; bind::plan::slots tests 14/14. m3-max-34603 (at 6377eafa09)
clippy --cfg m2v_gpu of runtime and validation; validation candidate::engine + worker::compile 103/105:
the runtime-sources pin (re-pinned at landing) and
candidate::engine::guards::tests::no_venue_runs_a_guarded_target_under_robustness_1_alone
(guards/tests.rs:125, under investigation: present on development or not). Still running when landed: the
Iris suites (made_at_creation, pipeline_records, restart, ycbcr_textures, executions, dispatch_work,
grid_classes, warm, uniform_bind_offsets, draw_again) and the creation-time A/B, cold and warm.
2026-11-15 19:02:47 -08:00
Anees Iqbal 8d617591f8 RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages'
source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import
dedicated to nothing (no sparse buffer over several imports, no import the driver made
dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the
texels' pitches is bound in that import at the texels' offset, beside the buffer
(vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is
asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory-
image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its
alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737)
and its memory types take the import's. An import dedicated to the buffer binds no image
(-memory-10926): DmaBufPages now notes that.

A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the
check's textures of each dma-buf class take that class's image alone (a thread-local of the
class the check runs). texture/route.rs takes the new class where its verdicts take the
texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making
refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take
it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept
imported for good, as an image in a pointer import's is. A rebind remakes such an image in the
new pages' import by the same order. RADV requires a dedicated allocation of every such image,
so its check leaves the new class unchecked and it never takes the route.

New WorkCounts field: dma_buf_images_in_import. No new Degradation kind.

The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency)
fail the new class's verdicts first, so they keep measuring today's image on any device. A new
device test (tests/dma_buf_in_import.rs) counts the route and its negative control.

Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for
dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b
(docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs).

Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on
the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated
allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the
Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact;
first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453).

Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime
--all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe
in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the
Iris count test with its negative control.

API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane).
2026-11-15 18:55:56 -08:00
Anees Iqbal 873c255ded RUNTIME 2407: Grouping bound: a queue's expected run follows its command buffers' own GPU times
What: the group bound (GROUP_RUN, 16 ms) reads a per-command-queue estimate of its own
(QueueGen::group_run), with the same rule as before: raised at once by a longer run, halved
toward a shorter one. It is fed at each command buffer's completion in place_gpu_times:
- from its GPU duration by its timestamps, the value the long-queue mark already reads;
- where the device answers GPU times from the host, from those placed host times.
Device::flies goes back to the Flight for a VkQueue an unshared queue holds only, so the unshared
hold's Expected and its feed are as they were before 37b1ca8563.

Why: 37b1ca8563 fed the bound from the host's view of each batch's run as its VkQueue's oldest.
That view holds other VkDevices' work on the GPU and the host's latency. Under nextest's parallel
suite on the Radeon 780M (m3-max-34541, at bf0ca5902a), the warm fills' commit-to-completion
times read 0.6 to 825 ms. Queues read past 16 ms, grouping stopped, and five grouping tests
failed. The hazard the bound guards is our own kernel job's length. A command buffer's two
timestamps bracket its own work, and other clients' work does not lengthen them.

Docs: group.rs and the grouping FAST-PATHS row say where the estimate comes from. With
gpu_times_from_host it follows host times, which hold other clients' work too, so under contention
there a queue's batches may stop grouping.

Test: scheduler_held_wakes::a_late_completion_of_short_gpu_work_leaves_its_queue_grouping. A warmed
queue's fill has its completion held unpublished 40 ms (Point::Publish) while its GPU work is
short by its timestamps, then the queue's next group must be kept. Under the host-view estimate
that run reads 40 ms and no batch of the queue would join a group.

Fix forward for RUNTIME 2405 (5021e3b4ac): its regression showed on the 780M as five grouped tests
failing under the parallel suite (m3-max-34541).

Verified in the lane (m3-max-34562, tip c90332ba5e): clippy -D warnings m2v_cpu_icd, runtime and
validation, all targets and features. Still running when landed: the lavapipe set (dropped_work and
the new test), clippy plain and m2v_gpu, rustdoc, and the 75-test 780M rerun under the parallel suite.
Expected, not yet shown: the new test fails against 5021e3b4ac's estimate.
2026-11-15 18:48:54 -08:00
Anees Iqbal 2a13f503ce FAST-PATHS: the grouping row measures its run bound on the Radeon 780M
frame_costs_over_imports, release with --cfg m2v_gpu, before (dcd5b6fc96) and after (37b1ca8563)
on the same node (job m3-max-34529): grouped vkQueueSubmit calls a frame barely move, and no
group went for a batch's expected run.
2026-11-15 18:41:06 -08:00
Anees Iqbal aa5511f61e SEMANTICS 2130 / RUNTIME 2406: 16x16x16 simdgroup matrix products: refused as their own feature, Metal's rule below Apple10
What: `air.simdgroup_matrix_16x16x16_[widening_]multiply_accumulate` is now refused in every stage
as `Unsupported{SimdgroupMatrix16x16x16, NotImplemented}` (a new `Feature`), ahead of the 8x8
lowering's kernel-only check. The runtime's `compile_error` answers it as Metal does:
`Needs::MetalGpuFamily(1010)` on a device that does not claim Apple10, `NotImplemented` on one
that does (as `IndirectRenderState`). The owned fixture engine/simd_matrix16 shrinks to one form
per class (float, half, widening signed int8), each with the four transpose-flag pairs, 12
kernels; the probe carries the M3's answer in its header.

Why: Metal itself refuses these products below Apple10. The M3 Max (macOS 27.0.1) refused every
pipeline of the fixture at creation, AGXMetalG15X_M1 code 3, "simdgroup_matrix<T,16,16x16>
operations are supported by GPUFamily10 and later" (job m3-max-34410). No device the runtime
presents claims Apple10: the family lists the "SIMD-scoped matrix multiply operations" row (from
Apple7), refused NotImplemented(SimdgroupMatrix) on every device, and the lod-bias row, a gap. So
the refusal is Metal's own answer, not a device gap: no FAST-PATHS known gap.

Tests: engine_simd_matrix::products_of_16x16x16_are_refused_as_their_own_feature (every
committed profile, the fixture's 12 kernels); runtime_lane::simd_matrix16 (the device's compute
pipeline creation answers MetalGpuFamily of Apple10). REFUSALS.md regenerated, api_signatures
blessed, reach mark added. The engine fixture expectation table and golden hashes take the
fixture's rows on development.

Also: f639b74288 adds the owned fixture (MSL we wrote, compiled by scripts/regen-air-fixtures) and
its Metal probe; 5dbfa3d3d5 imports AirLibrary in the runtime-lane test.

Verified in the lane: m3-max-34499 (msi, at 38d4694b12) clippy -D warnings for metal2vulkan, runtime
and validation (all targets and features) and 45/45 tests, incl. the new engine_simd_matrix test (12
kernels on every committed profile), the error tests, refusal_surface, api_signatures, api_surface;
m3-max-34514 (gem10, at 5dbfa3d3d5) clippy m2v_cpu_icd and runtime_lane::simd_matrix16 on lavapipe
(Needs::MetalGpuFamily(1010) for all 12). Clippy m2v_gpu (34516) still running when landed.

API: adds Feature::SimdgroupMatrix16x16x16 (additive; api_signatures blessed in the lane).
2026-11-15 18:32:00 -08:00
Anees Iqbal 5021e3b4ac RUNTIME 2405: Grouped submissions: a group's summed expected GPU run stays within 16 ms
What: a batch joins a held group only where its queue's expected run is known and keeps the
group's expected runs, summed, within GROUP_RUN (16 ms). Otherwise the group goes first
(GroupEnd::Long, WorkCounts::group_ends_long), and the batch leads the next group where its own
run is known and within the bound, else goes alone. The expected run is unshared_hold::Expected,
which was fed only on a VkQueue an unshared queue holds. It is now fed on every VkQueue whose
batches group: Device::flies enters each batch there in the Flight. The hold's decisions still
read the Flight only where other queues' batches are held back.

Why: the driver runs a group as one kernel job, and Linux's amdgpu ends a job past its 2 s default
timeout with no error the device reports. On a Radeon 780M a single 3.2 s command buffer was ended
and the one behind it dropped. Four batches that each finish alone could cross the timeout
merged. With the bound, merging adds at most 16 ms of the others' expected work to any job. 16 ms
is the owner's line for an intolerable wait, and it also caps how late grouping makes a member's
completion seen (the FAST-PATHS row said about 20 ms behind a 20 ms batch). A queue none of whose
batches was seen complete has no expected run, so its batches go ungrouped until one completes.

Tests:
- tests::group_run: the admission rule (unknown, alone, a full group of quarters, 12 + 5 ms,
  overflow).
- runtime_lane::grouped_submissions::a_queue_s_batches_group_within_their_run: on a grouping
  device with one VkQueue, behind running work on another queue, a fresh queue's batches group
  none, a warmed one's group, and none after a 40 ms command buffer of its own.
- The grouped lane scenarios, and submit_check_device's paths test, warm each grouping queue with
  one completed fill first. The behind-running-work tests measure the fills' rate on a queue of
  its own, so the B queue's expected run stays its first fill's.
- Every place that sums the group ends counts the new end, and frame_costs prints it.

Docs: group.rs and unshared_hold.rs module docs, the grouping FAST-PATHS row (its bound and its
cost line), and WorkCounts::group_ends_long.

Verified in the lane (m3-max-34508, tip 37b1ca8563): clippy -D warnings with m2v_cpu_icd, runtime and
validation, all targets and features. Still running when landed: lavapipe tests (group_run, the
grouped lane, unshared_hold, submit_check_device, kernel_end_device, commit_and_submit,
queue_share_device, frame_costs), clippy plain and m2v_gpu, rustdoc, and the 780M before/after.
Expected, unverified: conformance cost records' grouping counts (not the cases' own, never gated)
may drop in cases that commit on fresh queues.

API: adds the field WorkCounts::group_ends_long (additive; api_signatures blessed at landing).
2026-11-15 18:29:57 -08:00
Anees Iqbal 1acb205fb0 RUNTIME 2403: Runtime: a command buffer whose timestamps read unavailable after its queue passed it fails as Metal's victim
What: in complete_seen, a command buffer that would complete with no error, but whose own
timestamps read unavailable (Stamped::Read(None)) once its queue's timeline passed its last batch,
now fails with GpuRecoveryVictim. Its GPU times read 0, the new WorkCounts::unrun_command_buffers
counts it, and nothing counts against its queue. Its host-page logs hear of it as of a failed
command buffer.

Why: Linux's amdgpu ends a job past its timeout (2 s by default) with no error RADV reports. On a
Radeon 780M (Mesa 26.2.6, Linux 7.3.3) a 3.2 s fill was ended, and the command buffer queued
behind it on the same queue never ran, yet both completed with no error. Read-only from Mesa
26.2.6:
- radv_device_check_status checks only OpAbortKHR;
- syncobj waits pass no fence error;
- VK_KHR_device_fault reports only GPUVM faults and shader aborts (radv_device.c:2145).
The timestamps are the documented signal. A signal's first scope holds "all commands that occur
earlier in submission order" (Semaphore Signaling), and "a query is made available by the
operation of ... vkCmdWriteTimestamp" (Queries). So a query read unavailable after the signal was
never written. The completion turn already reads both queries with availability: the check adds
no Vulkan call, one comparison.

Docs: gpu_time.rs, the GpuRecoveryVictim and WorkCounts docs, the runtime README's lost-device
section, and two FAST-PATHS known gaps:
- work a driver drops is found only where the command buffer writes timestamps (not with host
  GPU times, MoltenVK on Apple's GPUs, a family of no timestamp bits, no free slot, or an
  adopted device);
- amdgpu's 2 s default job timeout fails a single command buffer that Metal's longer watchdog
  runs.

Test: tests/dropped_work.rs injects the unavailable read (completion::trace::unstamp_of), with no
GPU hang. A command buffer whose stamps read as written completes and counts 0. The injected one
fails as GpuRecoveryVictim with GPU times 0 and counts 1. The queue's next command buffer
completes and its fill lands.

Verified in the lane (m3-max-34463): clippy plain, m2v_cpu_icd and m2v_gpu and rustdoc of the runtime; lavapipe
35/35 incl. tests::dropped_work (injected unavailable stamps fail the command buffer as GpuRecoveryVictim; the
queue's next command buffer completes), gpu_time, device_recovery, completion and stall.

API: adds the field WorkCounts::unrun_command_buffers (additive; api_signatures blessed at landing).
2026-11-15 18:17:58 -08:00
Anees Iqbal 3442c96054 RUNTIME 2402: Park an in-place dma-buf image with its import for the next texture over the same pages
A texture in place over a no-copy buffer's dma-buf pages made a new
DRM_FORMAT_MOD_LINEAR image and a dedicated import of a new udmabuf of its
pages each time, so the kernel pinned and mapped every page again and the
first submission waited for the page tables: on the Radeon 780M an 84 MiB
texture took 1.4 ms to make and its first command buffer 7.1 ms against
2.2 ms over the device's own memory, every frame for a guest that remakes
its texture over the same pages.

As such an image goes (its texture and every command buffer that used it
gone) it now parks, VkImage and import, under the HostImport of its pages,
keyed by its plan, its texels' address among the pages, pitches and memory
type (dma_buf/parked.rs). The next texture in place over the same pages
tries each plan in its usual order and takes a parked image of that plan at
its texels before asking the source. An image whose first move ran rests in
GENERAL on our queue family (spec 12.10, 7.7.6: ownership stays with the
acquiring family; 7.9: host writes are visible to later submissions), so
the taken one notes no move; one never moved notes the same acquire a new
image notes. Not parked: images whose VkImage was handed out, the in-place
check's, rebind or detach replacements, past 64 per device.

Parked images are released by the residency thread after IDLE (2 s), count
as one listed import each against RESIDENT_MOST (released in park order
among the releasable imports' groups), go on host_range_remapped over their
buffer's bytes, and go with the HostImport before its deallocators.

WorkCounts: dma_buf_images_parked, dma_buf_images_taken,
dma_buf_images_missed, dma_buf_images_parked_released (api_signatures
blessed). New device test tests/dma_buf_parked_images.rs.

Verified in the lane (m3-max-34434): clippy -D warnings of the runtime, all targets and features; on lavapipe
(m2v_cpu_icd) tests::dma_buf_parked_images (6 textures over one buffer: 4 images made, 6 parked, 2 taken with
no source call and the CPU's later bytes, equal to a fresh image's; released on host_range_remapped and with the
buffer), dma_buf_plane_offset and host_residency's releasable-import test. The PHOENIX bench follows.
2026-11-15 18:09:55 -08:00
Anees Iqbal af372e849c Lane busy work: one GPU job stays under the kernel's timeout; host copies past the window ask again
What: the runs behind running work (behind_running_work, behind_another_queue_s_handler,
behind_a_kept_signal) calibrate A's fills by the GPU's time of the calibration command buffer
(first_use::gpu_took) instead of its commit-to-completion wall time, and cap every stretched A
(and behind_a_kept_signal's long B) at A_MOST, 1 s of GPU time at the measured rate. A stretch
past the cap repeats at the cap. Each run writes a GROUPED-A line with A's fills, the time they
take at the calibration's rate and A's GPU time.

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

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

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

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

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

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

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

Verified in the lane: lavapipe 10/10 (m3-max-34415, GROUPED-A stretch 1: 48 fills, 447 ms of GPU, cap 1 s) and
clippy under m2v_cpu_icd 0; the m2v_gpu archive built (34416). Not a regression of c218071502..e8d0bfc33c:
both shas pass quiet and loaded on PHOENIX (m3-max-34394), and the red leg's ring timeout followed the
stretch to 8x (~3.2 s in one job, past amdgpu's 2000 ms lockup_timeout). PHOENIX run follows.
2026-11-15 18:03:50 -08:00
Anees Iqbal 0427b71281 RUNTIME 2400: Uniform views keep their residual form where storage views read at their bind offsets
On the profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV, Mesa 26.2.6,
Iris Xe RPL-P) the runtime read every view at its bind offset, a uniform view's included. A
uniform view read so compiles there to a constant-cache block read (send.hdc_ro
oword_block_read:owords4, job m3-max-34232) in place of the untyped read the residual form takes,
which cost about 18 us a dispatch more than the push word it saved. Now the device reads its
uniform views at their residuals, as on every device without
DriverFact::ConstantOffsetUniformReadsPreloaded, and the plan keeps the storage views' key:
reads_views_at_bind is the fact's alone again, and the plans and dispatch regions take
uniform_residual_form (each uniform view's RangeAtBindOffset at 0, a storage view's as the plan
gives it), which is residual_form wherever no storage view declares the key. Runtime only: no
translation output moves.

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

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

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

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

Also: the test suites follow the Iris Xe's new workaround (its profile fingerprint differs from the
UHD 770 RPL-S by it; the stage-bound test's reference profile). Verified in the lane: clippy for
metal2vulkan and the runtime, all targets and features (m3-max-34321); the Iris run of
uniform_bind_offsets and inline_continues follows from the lane.
2026-11-15 17:38:32 -08:00
Anees Iqbal 4a06ce915d SEMANTICS 2129, RUNTIME 2399: Heap storage reads by the formats' own read bits on a device without the feature
A compute pipeline that reads a read_write argument-buffer texture was refused
Unsupported{ArgumentBufferTextures, needs ShaderStorageImageReadWithoutFormat}
on a device without shaderStorageImageReadWithoutFormat (ANV on Gfx12.0, the
Iris Xe), so the guest's work waited on a nil pipeline. Vulkan 1.3 and
VK_KHR_format_feature_flags2 enable the SPIR-V capability
StorageImageReadWithoutFormat, and a read of a view without a format is then
valid wherever the view's format has STORAGE_READ_WITHOUT_FORMAT_BIT (spec
19.9.3, VUID-vkCmdDispatch-OpTypeImage-07028). The slot path already took
that route; the heap path checked the feature alone.

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

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

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

Verified in the lane (m3-max-34272): clippy -D warnings for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation, all targets and features; nextest over the heap, handle, storage, profile,
fast_paths, without_format, texel_class and tier tests plus api_signatures, refusal_surface and
api_surface: 317 passed. A synthetic Iris profile with RGBA16F's read bit cleared refuses the
reading kernel naming that format; the committed Iris compiles it. The lavapipe lane with the
feature withheld and the Iris run follow from the lane.
2026-11-15 17:26:02 -08:00
Anees Iqbal d3b1dbdbe0 SEMANTICS 2128, RUNTIME 2398: Buffer views read at their bind offset where a pushed word lengthens every thread's payload
On ANV (Mesa 26.2.6) on the Iris Xe RPL-P, a compute function that reads a client push word
gets a longer per-thread payload (the base workgroup id moves 17 registers further), and a
light kernel runs about 2.2 times as long: 120.2 us against 55.7 us a dispatch on the same
module with the push read removed (raw Vulkan chains, jobs m3-max-34063 and m3-max-34038).
The 780M (RADV) shows no such gap (m3-max-34031). The runtime's storage views read their
SlotBindOffset residual on every access, so every kernel paid it there.

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

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

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

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

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

Verified in the lane: touched tests in msi jobs 34174/34198 (engine_access, bind::, fast_paths,
api_signatures, the runtime pipeline and argument_table tests); lavapipe m2v_cpu_icd 21/21 (34190:
uniform_bind_offsets and the new storage test, answers at offset 0, past it and at 0 again); clippy
plain 0 (34198), m2v_cpu_icd and m2v_gpu 0 (34200); rustdoc 0 (34213). golden_hashes reads stale only
for intel-irisxe-rplp-anv (re-keyed: 1788 cells, fingerprint 6d95bb254f9f9d66 -> 2f820bef4bfb9669); no
cell under an unchanged key moved. The table is re-blessed on development.
2026-11-15 17:07:41 -08:00
Anees Iqbal 7049627f79 RUNTIME 2395: Managed no-copy buffers: the caller's promise of zero bytes is zeroed on the device, not copied in
What: `HostMemory::with_zero_from(offset)`, a runtime extension with no Metal counterpart. The
caller promises that a no-copy buffer's bytes from `offset` to its length read zero when it is
made (a buffer its program made with no bytes, or with fewer than its length). A `Managed` one on
a device without unified memory then makes its GPU copy's bytes from `offset` to the length as
zeros the device writes in its own memory (one word-aligned vkCmdFillBuffer registered before the
making's copies in, `Buffer::zero_device_copy_first`). Only the bytes before the offset, and the
rest of the last page past the length, are copied in from the pages, so no import is held for the
zeros. New counters: `WorkCounts::managed_device_copies_zeroed`, `managed_bytes_zeroed`. Nothing
else takes the promise: a buffer that lies in its pages, a copied host buffer's first read, heaps,
rebinds, recoveries (the pages' `made_of` parts keep no promise), `did_modify_range` and
`synchronize_resource` behave as before.

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

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

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

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

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

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

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

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

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

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

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

Verified at a96a3ef68d: m3-max-33936 (msi) clippy -D warnings for metal2vulkan-runtime (all targets, all features) plain, --cfg m2v_cpu_icd and --cfg m2v_gpu; metal2vulkan tests::fast_paths 34/34. Running at landing: the heavy test and small_stack_device on the Iris (m3-max-33948).
2026-11-15 15:38:35 -08:00
Anees Iqbal 2163335121 RUNTIME 2393: a dma-buf source is asked once per texture after its standing refusal
A texture over a no-copy buffer's pages imported as dma-bufs tries its image in place with each
of its plans (wider usages first, its own last) and asks the caller's source for each plan's
pages. On RADV PHOENIX (Mesa 26.2.6) an RGBA8Unorm ShaderRead texture tries four, so a source
that refuses pages past udmabuf's list_limit was asked four times for the same pages
(texture_shadow_bench, m3-max-33878: source calls 4.00, refused 4.00 a texture); a consumer's
trace logged 1,620 such refusals over 765 textures, 367 ms in all.

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

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

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

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

Verified: compiled in m3-max-33918 (msi, release lib-test archive under --cfg m2v_gpu). Running at landing: lavapipe (dma_buf*, no_pointer_import, host_residency, texel_rows, texture_placement) in 33918, clippy x3 next, and a PHOENIX run of the new test and the bench (the 4 -> 1 asks on RADV expected, unverified). The bench's numbers (PHOENIX m3-max-33878 um790, 33898 gem10) came from 2fe80f0a64 and d06fa76b74.
2026-11-15 15:31:24 -08:00
Anees Iqbal c2206c14b0 RUNTIME 2389: Device::import_shared_dma_buf imports a shared dma-buf ahead and keeps it while a handle lives
A runtime extension (Metal has none). A guest's buffers over pieces of one shared file of guest RAM
were each imported as their own dma-buf import and freed with the buffer, so a compute loop that
made and dropped no-copy buffers paid an import and a free per command buffer, and on RADV each
import maps its pages at once (the next submission's CS waits for the page-table job).
Device::import_shared_dma_buf(file, options) (unix) imports the whole dma-buf on the caller's
thread, or joins the device's live import of it, and returns a SharedDmaBufImport; while a handle
lives, the file's entry in the device's map keeps the import, so buffers over its pieces join it
instead of importing again, and it is freed once its last buffer, heap and handle have gone (one
kept import per file a live handle names, per generation). The class comes from `options` as a
no-copy buffer's (Private, Memoryless and undefined options refused, Invalid StorageMode); the
import takes the type a no-copy buffer of that class would get first, so pieces join it.
Refusals use the existing kinds (Unsupported HostMemory, OutOfMemory). A device's recovery lets go
of the lost generation's kept holds and seeds the new one's map, whose first buffer imports the
file again; nothing is imported on the recovering thread. A device without a dma-buf importer
keeps nothing (Debug: imported false). The handle imports whether or not the device's buffers over
those pages take the dma-buf route: on a device that takes the pages' pointer it is one listed
dma-buf a submission for nothing. WorkCounts::dma_buf_shared_imports_kept gauges the kept imports;
the handle's import counts in dma_buf_imports. Docs: rustdoc, dma_buf.rs Shared files, HOWTO
dma-buf section, the runtime README extensions and unix-only lists. REFUSALS.md: the StorageMode
site moved to host_class, which the no-copy call and this one share.

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

Verified: m3-max-33745 at the lane tip 856a1fabae: clippy plain, m2v_gpu, m2v_cpu_icd 0; rustdoc 0;
lavapipe runtime suite 2836 passed. Device tests (lavapipe): three buffers made and dropped in turn
take imports 1 / joined 3 with the handle, imports 3 / joined 0 without; a handle keeps a live
buffer's import; recovery imports nothing and the next buffer's import stays kept; Private refused.
Churn bench, PHOENIX (RADV 780M, release, interleaved, 450 command buffers an arm, a8f297bf11, the
same code but the count): no handle 1 import + 1 free a command buffer, call median 820-907 us, GPU
start median 3026-3037 us; handle kept 0 imports, 0 frees, 1 join, call median 25-69 us, GPU start
median 104-145 us.
2026-11-15 14:48:09 -08:00
Anees Iqbal 4ee4deb737 RUNTIME 2385: a heap's 4:2:2 texture, a shadow of the heap's bytes, keeps a decoded twin
A heap's GBGR422 or BGRG422 texture lies as a shadow of the heap's bytes in Metal's rows (its answer
is Metal's measured rows: 512 @ 16 for 16x16, 8192 @ 16 for 64x64), and heap_texture_at excluded
4:2:2 textures from the decoded twin RUNTIME 2382 gave other carried formats' shadows, so every
kernel read and sample of one was refused, NotImplemented(Format) (56 refusals on PHOENIX and on
lavapipe, m3-max-33636 / 33625), where Metal reads it and the device can decode it.

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

Verified: PHOENIX m3-max-33671 (carried archive of the lane tip 4976a40be3): 5/5 (heap_carried_reads
with GBGR422 and BGRG422 16/64 Private/Shared under both heap answer policies, new_resources_wait_for_
no_gpu_work, a_carried_heap_texture_reads_its_bytes_with_no_commit, four_two_two_heap_textures_take_
metal_s_size_and_layout, a_texture_held_for_copies_a_kernel_s_handles_reach_is_announced_once): every
4:2:2 case shadowed, a use 1 copy and 1 decode, a second encoder 0 and 0; kernel reads, samples,
samples after a blit and a Shared replaceRegion, blit out and getBytes equal the texture outside a
heap; route: Metal's decode (RADV and lavapipe convert no 4:2:2 pairs; the device-pair route in a
heap shadow ran on no device). lavapipe msi 33635: the same 5. Control (test commit alone): PHOENIX
33636 and lavapipe 33625 fail with the 56 refusals. Clippy plain, m2v_gpu, m2v_cpu_icd and rustdoc 0
(33635); runtime lib tests in 33672.
2026-11-15 14:20:58 -08:00
Anees Iqbal df0e7ec05e RUNTIME 2384: a fence update keeps its encoder group; the group orders after it by the narrowest barrier
A guest compute benchmark's encoders each update one fence and wait for one (reims, 780M,
c471372f87: fence updates = waits = encoders in every workload; 63 encoders a command buffer in one
workload), and an encoder that updated a fence ended its fold group, so every encoder began its own
VkCommandBuffer: 47.5 a submission, encoders_folded 54 of 117591. The driver's per-call work grows
with every VkCommandBuffer, and on the Iris Xe a VkCommandBuffer boundary costs 18.25 us of GPU time
against 0.64 us for the least barrier between dispatches (m3-max-33589).

A fence update no longer ends its group. A later member's commands order after the update by a
barrier recorded per command at the narrowest width that covers it: source, the updating encoders'
writes in the stages the update covers (SHADER_STORAGE_WRITE in shader stages, TRANSFER_WRITE in
transfer stages, attachment writes in a pass); destination, what the command can reach of memory
no use names, in its own stages (SHADER_STORAGE_READ | SHADER_SAMPLED_READ | SHADER_STORAGE_WRITE,
TRANSFER_READ | TRANSFER_WRITE), plus its untracked uses' own reads (indirect-argument or uniform
reads only where an untracked use reads them); tracked resources keep the tracker's rule. Between
two compute encoders that is the least barrier, SHADER_WRITE to SHADER_READ | SHADER_WRITE. The
barrier precedes the member's commands whether or not it waits, since a wait anywhere in an encoder
covers all its commands, which enter the shared VkCommandBuffer as they come; independent encoders
that update fences no one in the group waits on so run one after another (accepted: the guest's
encoders all wait). Across command buffers and queues nothing changes: Metal evaluates a fence at
submission, a wait only orders after updates committed before it ("commit the command buffers with
the producing passes before those with the consuming passes", MTLFence), a waiter on another VkQueue
waits for the updater's batch end, and a group never crosses a batch, so no cycle can form.
WorkCounts gains fold_fence_barriers and six folds_refused_* counts (the reason a join was refused:
kind, tail, batch, state, parts, ends; one relaxed add on a refused join, nothing on a join). Tests
that ended a group by a fence update now end it by a change of dispatch type or an event.

Verified: PHOENIX (RADV 780M, release, interleaved, 600 command buffers of 24 encoders, m3-max-33626):
fenced chain 47 -> 1 VkCommandBuffer a submission, mean call 56-79 -> 18-20 us, GPU start median
142-173 -> 101-105 us, GPU time median 146.7 -> 87.8 us (either wait order); independent fence-updating
encoders 74.7 -> 88.0 us GPU (serialised, as accepted); unfenced control unchanged (49.2 us).
fold_fence_barriers 13800 = 600 x 23; no folds_refused_* moved. Long-call bench, small listed:
539 -> 371 us mean call. Lane tip 8ae906a4fd: clippy plain, m2v_gpu, m2v_cpu_icd 0 (33633); lavapipe
runtime suite 2829 passed at 143a0013f8 and tracker unit tests 85 (33621; 8ae906a4fd deletes only the
dead Summary::has_updates); PHOENIX encoder_fold, render_fold, spares, fences 71 passed (33626).
Iris before/after: m3-max-33627, pending.

Public surface: WorkCounts (for the lanes) gains fold_fence_barriers and folds_refused_*, blessed in
api_signatures.tsv; a struct literal of WorkCounts must name them, Default and readers are unaffected.
2026-11-15 14:13:04 -08:00
Anees Iqbal 209f11b467 RUNTIME 2383: rate maps: the GPU routes a fanning pass's own draws (step 1)
- Rate maps: the GPU routes the encoder's own draws of a fanning pass
- rate-map GPU routes: the rebound recording takes no route; the routed-draw count through the device's counters
- rate_mapped_pieces_encoder: the small triangles' commands drawn as the encoder's own draws
- Rate maps: the GPU routes' docs, the depth test's flagged draw between fanned ones
- rate_mapped_pieces_encoder: the draws the GPU routed, fanned out and drew through the region-copy variant
- CountDraws: the indirect-count draw's recording is record_draw
- rate_mapped_depth_equal: the GPU routes the encoder's draws as the host step's probe decides them

In a rate-mapped pass that fans out (RateMapPolicy FanOut, the default), the encoder's own draws
were routed by the host step only for executions; the GPU now routes them: a counts kernel
(bind/fan_out/route_counts.rs, built through the translator's public API) reads each draw's lead
instance probe and writes indirect counts, so each draw either fans out per region or draws through
the region-copy variant, as the host step's probe decides for the same draws. Its kernel is made at
first use; a cold frame, whose variants are still being made, falls back to the region-copy route
alone. Exact (RateMapPolicy::Exact) routes nothing on the GPU. WorkCounts gains
rate_map_gpu_routed_draws, rate_map_gpu_fanned_draws and rate_map_gpu_copied_draws (for the lanes;
blessed in api_signatures.tsv). FAST-PATHS rate-map row updated. No new Degradation kind.

Verified: msi m3-max-33521 at the lane tip 4ee726aa13: clippy (translator, runtime, validation; all
targets, all features) 0; translator route_counts, fan_out, api_surface, api_signatures, fast_paths
62/62; runtime fan_out, every_command_the_runtime_records_is_routed, work_counts, upload,
owned_kernel 10/10; lavapipe rate_map device tests 24/24. rate_mapped_depth_equal (each pass two
ground halves with a w-crossing triangle between): 0 red pixels in every leg under Exact and FanOut;
the warm FanOut encoder frame routed 6/6 draws on the GPU (2 fanned, 4 region-copy), the same as the
host step decides for them executed. Pending: clippy m2v_gpu/m2v_cpu_icd, rustdoc, the Iris A/B.
2026-11-15 13:48:07 -08:00
Anees Iqbal d62e1d2bd9 RUNTIME 2382: a heap's decoded-format texture on a shadow route keeps a decoded twin
Under DevicePolicy::exact_answers (HeapAnswerPolicy::Metal) a heap's PVRTC or ETC2 texture on RADV
PHOENIX misses Metal's answer (its BC1 carrier image takes 4096 B @ 4096, Metal answers 128 @ 128
or 2048 @ 128), so it lies in memory of its own as a shadow of the heap's bytes (MemoryShadow;
Shadow or Tiled where those serve). heap_texture_at gave a decoded twin only to the Direct,
HostTransfer, Linear and Hidden routes, so its sampled view fell to the carrier, which has no
sampled usage, and every kernel read and sample was refused, Unsupported(Format) (8 of 8 cases in
m3-max-33467), where Metal samples it and the device can decode it.

A heap's PVRTC, ETC2 or EAC texture on a shadow route (not over the caller's host pages, not
detached) now gets its decoded twin. ShadowCopy::record_gated records the shadow's decode
(ShadowCopies::decode) after a copy in that moved texels, and only then (record_moves answers
whether it moved any); the pass is set at making (Image::decode_after_copies_in) and its kernel is
made in ShadowCopies::prepare at first use, so no making compiles. WorkCounts::shadow_twin_decodes
counts the decodes. 4:2:2 heap shadows stay twinless; heaps over the caller's host pages stay the
documented copies-alone gap. Docs: decoded_twin.rs, pvrtc.rs, etc.rs, degradation.rs, docs/API.md,
docs/FAST-PATHS.md (heap shadows of decoded formats are no longer for copies alone). New device test
runtime_lane/heap_carried_reads.rs. Public surface: WorkCounts (for the lanes) gains
shadow_twin_decodes, blessed in api_signatures.tsv.

Verified: PHOENIX m3-max-33568 (carried binary of the lane tip d5bf9cac82): heap_carried_reads,
a_carried_heap_texture_reads_its_bytes_with_no_commit, pvrtc_texels_read_as_metal_s and
etc_texels_read_as_metal_s pass. Under HeapAnswerPolicy::Metal all 8 cases shadowed; a use takes 1
copy and 1 decode, a second encoder in the same command buffer 0 and 0; kernel reads, samples, blit
out and getBytes equal the texture outside a heap, and samples follow a blit and a replaceRegion.
Under HeapAnswerPolicy::Device: not shadowed, 0 copies, 0 decodes, equal. Without the fix
(33467 at the test commit) all 8 reads were refused. lavapipe (msi 33535): the 4 tests pass. Clippy
x3 running in 33569.
2026-11-15 13:46:15 -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 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 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 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