Commit Graph
569 Commits
Author SHA1 Message Date
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 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 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 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 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 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 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 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 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 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 135df83657 RUNTIME 2357: Textures over buffers: an image over a buffer's texels may take its whole placement; an unobserved buffer lies on the linear image alignment
Intel's driver for the UHD 630 on Windows (101.2145) rounds a small
linear image's VkMemoryRequirements size up to its 4096-byte alignment:
BGRA8 73x8 at a pitch of 320 has a 2560-byte subresource and a 4096-byte
image, 16x16 1024 -> 4096, RGBA16F 88x8 6144 -> 8192. The in-place check
(linear_plan::aliases) bounded the image's size by the buffer's VkBuffer
bytes from the texture's first, so a texture over a padding-unobserved
Private buffer of exactly its rows was a shadow, and a buffer placed on
256 bytes failed the image's 4096 start too.

The room an image over a buffer's texels may take is now the buffer's
own placement from its byte 0 (Buffer::memory_room: bytes no other
resource is placed in), in texture.rs's two aliasing checks and the
two-plane YCbCr check. A buffer whose maker declares its padding
unobserved is placed on the device's linear images' memory alignment
(Device::linear_image_alignment: one probe image's alignment, a 64x8
R8G8B8A8_UNORM linear image, kept for the device), its start and size
whole units of it; the recycler's BufferMaking keys on that alignment,
and a device recovery's carry places such a buffer so again. Where the
alignment is 256 or less (RADV, lavapipe, MoltenVK), every placement met
it already and nothing changes. Cost: at most alignment - 1 bytes more
for each such buffer on the UHD 630, plus the start's padding.

Still a shadow: an image the driver sizes past its alignment's rounding,
R8 4096x1 over 4096 bytes taking 16384 on the UHD 630 (FAST-PATHS known
gaps), and on that driver textures over buffers that do not declare
their padding unobserved where the image is larger than the placement or
starts off 4096.

Tests: padding_unobserved's a_texture_whose_rows_fill_an_unobserved_buffer_is_in_place
makes a 73x8 BGRA8Unorm texture at the device's own linear pitch over a
Private padding-unobserved buffer of its rows alone and asserts the
placement lies on the alignment, the texture is the image over the
buffer, and no shadow is counted.

Docs: BufferDescriptor::padding_unobserved, the runtime README entry,
FAST-PATHS known gaps.

Checks: on the UHD 630 (Windows, m3-max-32630, at the same diff before
its rebase), padding_unobserved's new test passed: 73x8 at a pitch of 320
over 2560 bytes, 4096 of room on 4096, an image over the buffer, 0
shadowed. At cb7660c625: clippy plain, m2v_gpu and rustdoc 0
(m3-max-32602); lavapipe touched set 153/153 and m2v_cpu_icd clippy 0
(m3-max-32603).
2026-11-15 08:28:49 -08:00
Anees Iqbal f4c9902c63 FAST-PATHS: the cold Shared making's range on this tree is 95-97 ms
The previous commit gave 92-97 ms; m3-max-32595's two runs of this tree
made the cold round in 97.0 and 94.6 ms.
2026-11-15 08:15:57 -08:00
Anees Iqbal 9ee682344f FAST-PATHS: the 16 KiB allocation's measured cost
A 16385-byte buffer's VkBuffer requires 32768 bytes where 16400 did, on
RADV PHOENIX and lavapipe (m3-max-32595, m3-max-32558). On the Radeon
780M, release, exclusive, the base (d2ee5bca5b) and this tree run twice
each in one job (m3-max-32595): 1000 buffers of 16 KiB + 1 to 4 MiB
required 763.3 MB against 754.8 MB and took one more 64 MiB block in
their second round; making them took the same time within the runs'
spread, Shared ones cleared on the host and Private ones' first fills
alike.
2026-11-15 08:15:57 -08:00
Anees Iqbal a1175662e7 RUNTIME 2355: Textures over buffers: a buffer of 16 KiB or more holds Metal's allocation, a heap's buffer its heap
A texture over a buffer whose texels run past the length was always a
copy: a shadow image or a staged texture buffer whose bytes past the
length lay in a tail of its own. Metal's texels there are the
allocation's: a buffer of 16 KiB or more holds its length rounded up to
16 KiB (allocatedSize), zero when made, and a heap's buffer reaches its
heap's end, whose bytes are the heap's.

Now a buffer the device makes in the Metal address space with a length
of 16 KiB or more takes that allocation (buffer.rs's metal_allocation):
its VkBuffer and placement are its length rounded up to 16 KiB, which
its first fill clears with the rest (Buffer::clear_first: the host's
clear of a Shared or Managed buffer, the device's fill of a Private
one), with no command of its own. A texture keeps in place the bytes the
buffer's memory holds for it (Buffer::texel_reach: the allocation, a
heap's buffer's heap to its end, a no-copy buffer's length), so such a
texture is made as one inside the length is: an image over the buffer's
memory where the device makes one, a texture buffer viewed in place. The
shader-visible ranges, robustness, copy reach (a blit past the length is
still refused) and exported sizes stay at the length. Heap, no-copy,
wrapped and exportable buffers, and every buffer under 16 KiB, take
their length; past what the memory holds a texture keeps its tail, as
before. The runtime has no buffer allocatedSize; a heap's size and a heap
texture's allocated_size are unchanged.

The tails conformance cases now lie in place: their comments say so,
and the texture buffer case drops its staged-texture-buffer allowance,
which no device can fire there any more (its view starts at 16384).

Tests: buffer_tail_device's last-texel case lies as over a buffer that
holds it inside its length, with no tail; a new case over a 20000-byte
buffer (64x128 packed, ending at 32768) reads zero in the padding as
made, lies as inside the length, lands a kernel's writes past the length
in the buffer's memory, takes no copy where it is an image over the
buffer, and refuses a blit past the length; the heap case lies in the
heap, its kernel writes landing in the heap's other buffer; a new case
over a heap's second buffer keeps its texels past the heap's end in a
tail; the no-copy and 4096-byte cases keep their tails.

Docs: buffer_texture.rs's Tails, linear_plan.rs's Length, docs/API.md's
accepted difference and StagedTextureBuffer entry, and a FAST-PATHS
cost-of-matching-Metal entry for the padding.

Checks: the jobs that compiled and ran this commit are named in the
lane's report.

Evidence (lane jobs): m3-max-32551 (msi): clippy runtime+conformance -D warnings 0; 2632/2632 runtime+conformance; fast_paths +
api_surface 34/34. m3-max-32578 (lavapipe) at the tip: touched 56/56 (buffer_tail_device incl. the allocation, heap and
heap-end cases, texture_placement_device, linear_plan, buffer_texture, degradation_catalogue); runtime+validation partition
1/4 1572/1572. VkMemoryRequirements on lavapipe for a 16385-byte buffer: 32768 (alignment 64). The padding is cleared by the
buffer's existing first fill (no new command). allocatedSize: no buffer API; heap sizes unchanged. The PHOENIX run, the
release creation bench and lavapipe partitions 2-4 follow in the lane. Conformance: buffer-tails cases now in place; the M3
venue's cost records for buffer-tails-* re-bless on development.

Lane commits: d2ee5bca5b (bench), a8f3796f59, ee54952340 (heap cases in a placement heap).
2026-11-15 08:14:12 -08:00
Anees Iqbal b7053280de RUNTIME 2346: 4:2:2 textures over IOSurface planes: an image of their texels, decoded from the pairs in place
A GBGR422 or BGRG422 texture made over a buffer's bytes (Buffer::new_texture_with_iosurface_plane,
a CoreVideo 2vuy or yuvs plane, over a Shared buffer or a no-copy buffer's host pages) had no
decoded twin: twins are attached only to textures whose image is their own for good, so every
dispatch or draw that read or sampled it was refused, with a "needs R8G8B8A8_UNORM SampledImage"
line naming a format every device samples.

Such a texture is now an R8G8B8A8_UNORM image of its texels, the converted shadow a two-plane
YCbCr texture over planes already is (ShadowSource::Converted, its conversion now an enum of the
planes' and the pairs'): its copy in, before the first command of a command buffer that reads it
and after a command wrote the bytes, is one dispatch of the new bind::chroma_convert_module that
reads the pairs where they lie, at any byte of their VkBuffer, through one storage-buffer binding,
and writes Metal's texels (ChromaDecode, exact) through the image's R32_UINT view. Copies, blits
and CPU calls keep moving the plane's bytes. Where the device converts the pairs' format with
Metal's reconstruction (MoltenVK), the copy in is that conversion instead: the plane's rows copied
into the pairs' image, sampled through the conversion (chroma_sample_module) into a scratch,
copied into the image; announced decoded-texel-precision at the copy in's planning. The set binds
the buffer's VkBuffer, so the planning makes it again after a rebind gave the buffer another one,
and each command buffer holds the set it took. The placement query answers OtherShape. A plane
the window cannot take (past maxStorageBufferRange, a last word past the buffer, rows that share
bytes, texels past the buffer; with the device's conversion, a first byte or rows off 4 bytes)
keeps the carrier, its reads refused; FAST-PATHS records it as a known gap.

Per frame, per texture (w x h texels): before, no read ran at all; the texture was an R8G8_UNORM
carrier of the plane, 2 bytes a texel. Now no byte is copied: one dispatch reads the w*h*2 bytes
of pairs in place and writes w*h*4 bytes of texels (1920x1080: 4147200 read, 8294400 written).
Memory: one R8G8B8A8_UNORM image, w*h*4 bytes (1920x1080: 8294400), in the carrier's place; with
the device's conversion also the pairs' image (w*h*2) and the scratch (w*h*4), and per copy in a
w*h*2 copy in and a w*h*4 copy out. Announced carried-decoded-twin (an existing kind) with that
cost. No new Degradation kind, no new WorkCounts field.

A carrier's binding without a twin is now refused NotImplemented(Format) naming the texture's
format (pvrtc::holds_for_copies), not a need of the twin's view format.

Public surface: metal2vulkan::bind::{chroma_convert_module, ChromaConvertModule} added
(api_signatures.tsv blessed, api_surface table); docs/REFUSALS.md regenerated (one more
binding_view site of Format).

Tests: the in-place kernel against ChromaDecode's decode under the interpreter (both orders, first
bytes off a word, odd sizes, rows apart); a carrier's binding refusal (binding_view unit test);
a device test of both formats over a Shared buffer and over host pages reading Metal's measured
bar values (an Apple M3 Max, macOS 27.0.1) and Metal's decode of a random frame written on the
CPU before the next command buffer, OtherShape from the placement query, and the device's
conversion counted and announced where it converts. Verification jobs follow in the lane report.

Evidence (lane jobs): msi m3-max-32240 at 94f603bf35, --cfg m2v_cpu_icd on llvmpipe: 130/130 touched tests, clippy -D warnings 0;
the device test fails without the fix (placement not OtherShape, the read's dispatch refused). PHOENIX gem10 m3-max-32260
(archive m3-max-32241): all 4 cases (GBGR422/BGRG422 over a Shared buffer and over host pages) "Metal's texels, exact"
for the M3's measured bars and a random CPU-written frame; ycbcr_device, ycbcr_refresh, twin_reads 7/7. MoltenVK (device form)
run on the M3 follows.

Lane commits: 735234d5f4, d59f44baa6, 94f603bf35.
2026-11-15 06:48:09 -08:00
Anees Iqbal a9dce911e7 Known gaps: drop the first commit's translation; held_step_order's numbers from a release build
9aadbdf281 rewrote the known gap from the test profile's numbers. A release build of the same
test on the same idle Radeon 780M (RADV PHOENIX, m3-max-31944, 2 processes x 3 runs) puts the first
commit of a host-step pass, which translates the variants its step draws with, at 4.5 and 5.4 ms,
and a later one at 0.11 to 0.19 ms; the unoptimized test build takes 23 to 25 ms and 1.0 to 1.3 ms
there. Nothing measured holds a guest's commit past a frame's 16 ms any more: the 406 and 10.5 ms
were the test build inside a suite that loaded the host's cores. So the known-gap row goes, and
CHANGELOG's known-failing line names only the teardown test. The test's COMMIT doc carries the
release and the test build's numbers.

Docs and a test comment only. Verified: the numbers are m3-max-31944's printouts.
2026-11-15 05:45:35 -08:00
Anees Iqbal 9aadbdf281 held_step_order: time Scheduled from the commit's return; hold the commit call to a frame
command_buffers_behind_a_waiting_step_read_scheduled failed 3 of 3 on the Radeon 780M (PHOENIX)
inside the whole device suite (m3-max-31782): the long command buffer's commit returned 405.95,
23.66 and 10.50 ms after its call, and the test bounded the call plus the scheduler's pass to
`Scheduled` by 10 ms together. Scheduled itself came 19.6, 1.6 and 2.3 ms after the commit
returned: the ordering the test is for held.

What holds the call (probes m3-max-31832 and m3-max-31876, gem10's 780M idle, step marks in the
commit path): no pipeline wait (commit_pipeline_wait_nanos 0) and no lowering; Recording,
Deferred::prepare of the host-step pass. Its first commit translates the variants the step draws
with on the program's thread (DeferredPass::settle: the step's buffer forms and the fan-out's,
the route's replay variant; record_on_gpu's decision and, once a device, the notice's rules past
its cause): 24.1 / 23.7 ms cold, 49.8 in an earlier run. A later commit finds them made: 1.0 ms
(2.4 in the earlier run), about 30 lookups of 5 to 35 us, no single repeated item. The suite on
the host's cores stretched the same work about tenfold. The translation cannot move earlier
(whether the pass is a host step and its route are decided at the commit) nor off the program's
thread (the device keeps only what the program's calls make, in its order).

So the test's one bound mixed two properties. Now:
- `Scheduled` is timed from the long commit's return, still within 10 ms (the long work ends
  100 ms or more after it);
- the commit call is asserted apart, by its own clock (WorkCounts::commit_nanos), within a frame's
  16 ms in one of the runs at least (the later runs are warm), the test's own work_counts()
  snapshot outside the timed span.

docs/FAST-PATHS.md's known gap is rewritten to what is measured (the first commit of a host-step
pass translates its step's variants, why it stays there), and CHANGELOG's known-failing line with
it.

Verified: see the lane's report (PHOENIX 5/5, negative control with a sleep in the commit path).
2026-11-15 05:36:51 -08:00
Anees Iqbal d9236a8a11 Known gaps: a commit held past 16 ms on a Radeon 780M; a teardown wait past 16 ms on an RTX 2080
Two latency tests fail on some GPUs at the 0.2.0 release candidate, recorded where a user reads
open gaps (docs/FAST-PATHS.md, Known gaps) and in the 0.2.0 CHANGELOG entry, at the owner's call to
document them as failing and release:

- tests::held_step_order::command_buffers_behind_a_waiting_step_read_scheduled: on the Radeon 780M
  (Phoenix, m3-max-31782, exclusive) the long command buffer's commit returned 405.95 / 23.66 /
  10.50 ms after its call over the test's three runs (bound 10 ms); pin 97's XTX printout shows the
  same shape (315.68 -> 12.59 -> 17.11 ms). The ordering the test is for held in every run.
- tests::teardown_threads::a_running_queue_switch_check_leaves_the_device_to_the_program_s_thread:
  on an RTX 2080 (620.70.06) it failed 3 of 3 alone (m3-max-31777): the teardown waited 33.1 / 23.3
  / 19.8 ms for the check, 19.6 / 22.0 / 18.4 ms of it the check's objects' release; it passes on
  the RTX 3090, RX 7900 XTX and Radeon 780M. That host's driver calls on the 2080 ran several times
  slower than usual during the measurement (cause open).

Docs only.
2026-11-15 02:15:21 -08:00
Anees Iqbal b585744208 Boxed draws: the constant's numbers count the three draws the patches frame still fanned out
GEOMETRY_TRIANGLE_WORK's doc (5983bb3e72) split the patches frame's boxed piece
time as if the 3 draws still fanned out held 3/64 of its triangles. By the
lane's layout they are its three largest commands (161,820 and twice 89,184
indices, boxes of 110, 99 and 72 regions), 112,356 of its 301,150 triangles; a
simulation of its patches, map and bucket rule boxes the same 61 at 180, into
14,816,646 vertex-regions against the 15,286,908 counted. With their fan-out
taken out, a boxed vertex-region cost 0.49 / 0.48 ns on the Iris Xe, 0.73 ns on
the Radeon 780M and 0.13 ns on the RTX 3090, so a fanned-out triangle's geometry
stage is worth 31 / 32, 29 and 72 of them, not 26, 25 and 49. The boxed draws
held about 84 vertex-regions a triangle and took about 2.5, 2.8 and 1.1 times
their fan-out, as those ratios predict (2.7, 2.9, 1.2).

The constant stays 24, below the least (29.4): a draw it boxes costs at most
about 0.82 of its fan-out on each of the three. The doc, docs/FAST-PATHS.md's
row and the two tests' docs carry the corrected numbers; tests::rate_mapped_boxed_rule
checks the boxed draws' own average (9285 indices, 27 regions a box), fanned out
at 24 and boxed at 180.

Verified: arithmetic from m3-max-30553/30686/30687's warm pieces; the rule test
and clippy in the job that follows this commit.
2026-11-14 18:02:57 -08:00
Anees Iqbal 5983bb3e72 RUNTIME 2324: Boxed draws: a fanned-out triangle's geometry stage is worth 24 vertex-regions, not 180
The boxing rule (RUNTIME 2318) took GEOMETRY_TRIANGLE_WORK = 180 from the pieces
lane's bands frame, whose 22-by-10-pixel triangles cost 132 ns each fanned out on
an Iris Xe: mostly their fragments, which every route shades, not the geometry
stage boxing saves. Its 61 boxes on the patches frame (2-pixel quads, about 18
regions a box) lost on every device measured, the pass's warm piece:
  Iris Xe (Mesa 26.2.6)    4.64 ms fanned, 9.21 / 9.06 ms boxed  (m3-max-30553)
  Radeon 780M (Mesa)       6.47 / 6.46 ms, 13.57 / 13.57 ms      (m3-max-30687)
  RTX 3090 (620.70.06)     2.80 / 2.77 ms, 3.01 / 3.00 ms        (m3-max-30686)
On that frame, whose fragments cost little, a fanned-out triangle cost 15.4,
21.5 and 9.3 ns, a boxed vertex-region 0.59, 0.87 and 0.19 ns: 26, 25 and 49
units. The constant is the least, 24.7, rounded down, so a draw it boxes costs
no more than its fan-out on each of the three; a lower constant only boxes
fewer draws than 180 did. The doc and docs/FAST-PATHS.md's row carry the numbers.

tests::rate_mapped_boxed_draws: the 120-by-40 strip across ten regions (50
units a triangle, the patches frame's boxes about 55) is now fanned out, and a
patch across four regions' corner is boxed in its place, so the test still
boxes a draw across region borders: counts [1, 0, 3, 4, 4]. At 180 the strip is
boxed and the counts fail. tests::rate_mapped_boxed_rule checks the rule on the
patches frame's average draw: 18 regions fanned out, 4 boxed. The lane's patches
frame no longer asserts that it boxes a draw.

RUNTIME 2324: an unchanged artifact's rate-mapped draw that boxed at 180 fans out at 24.
2026-11-14 17:37:51 -08:00
Anees Iqbal 8a374ba0e5 RUNTIME 2318: Rate-mapped draws whose triangles lie in few regions are boxed, not fanned out
At a host step under RateMapRegionPolicy::FanOut, a probed draw the probe flags nothing of
goes through the fan-out variant, and so does a flagged draw's fanned part. Its geometry
stage emits a copy of each triangle per region it touches. On the pieces lane that stage costs
a fanned-out triangle what 371 to 739 vertex invocations for one region cost. On an Iris Xe
that is 130.7 ns a triangle, against 0.352 ns an index-region through the region-copy variant.
On a 3D renderer's frame there (tm91-iris), about 68 of the 125 ms of rate-mapped pieces a
frame tracks the probed and fanned geometry, which is 383 fanned draws a frame.

Such a draw is now boxed when that holds no more work: drawn through its region-copy variant
into the boxes of the regions its triangles reach by the probe's bounds (fan_out::run_boxes of
Probed::reach, a part's from its own blocks), as a run is.
- The rule: rate_mapped_pass::boxes_cheaper, regions x (vertices + REGION_DRAW_WORK) <=
  GEOMETRY_TRIANGLE_WORK x triangles (a direct draw; a strip's triangles counted at
  vertices / 4).
- GEOMETRY_TRIANGLE_WORK = 180: about half the least that a fanned-out triangle cost against a
  vertex for one region on the four devices measured (Iris Xe 371-500x, Radeon 780M 739x,
  RX 7900 XTX 570x, RTX 3090 654x; the constant's doc has the numbers). The rule is
  device-independent, keyed to no app, map or shader.
- No new pass, variant or readback. fan_out_asked asks for the region-copy variant (settled at
  commit already) and the recording takes the boxes (RenderLowering::boxed_reach).
Pixels: the routes already share a pass and put a vertex at one window position. A pixel lies
in one region, whose copies keep the draw's order of instances and primitives in either route.
The bounds are widened as the probe's are, so a box holds every pixel a copy would cover: the
same pixels and depth wherever today's routes agree.
A boxed draw rides whole in its piece, as a fanned-out one does; its work is no more than its
fan-out's.
Counts: WorkCounts::rate_map_boxed_draws and rate_map_boxed_vertex_regions (CopyRoute::Boxed).
A boxed part is not a run, so rate_map_region_runs and rate_map_parted_region_triangles leave
it out.
Test: tests::rate_mapped_boxed_draws, 6 commands blended at half alpha:
- boxed: a 10-pixel patch, a 120x40 strip across region borders, a patch of two instances,
  and a patch without indices;
- fanned out: a whole-target grid and one wide quad.
It checks probes 1, flagged 0, fanned 2, boxed 4, region-copy draws 4, and boxed vertex work
under the whole table's. The pixels equal the encoder's bit for bit. Under Exact nothing is
boxed.

Also (2f82e025be): The pieces lane draws each command's own patch: rate_mapped_pieces_host_step_patches; (01d8344d2a): A command's settle at commit boxes no draw; the boxed test's counts keep their function's name.

Verified (lane ratemap3, msi m3-max-30513 at 01d8344d2a, llvmpipe): rate_map|fan_out
26/26, the new rate_mapped_boxed_draws among them (probes 1, flagged 0, fanned 2, boxed 4,
region-copy draws 4, boxed vertex work 10752 against the whole table's 997056; pixels equal
the unboxed execution; nothing boxed under Exact); rate_mapped_fan_out, region_boxes, pieces
and depth_equal unchanged. Landed (main) at once: clippy x3 (m3-max-30514), the Iris A/B
and the hand negative control run after landing.
RUNTIME 2318: what a run records and draws changes. No Degradation kind.

API: two WorkCounts fields added (rate_map_boxed_draws, rate_map_boxed_vertex_regions);
api_signatures.tsv blessed. A consumer building WorkCounts by struct literal must name them.
2026-11-14 16:05:31 -08:00
Anees Iqbal 497e1f4ec0 SEMANTICS 2116: NVIDIA's float denormals under the 16-bit float controls are the device's, noted
What: a new DriverWorkaround, FloatDenormalsKeptUnderHalfControls, with rows for NVIDIA's driver on
the RTX 3090 and the RTX 5080 Laptop GPU (the GPUs its MetalFloatDenormals rows name). In an entry
that declares the 16-bit float controls (narrow::controlled_modes) on such a profile, the float
operations the deviation covers record PrecisionNote::DeviceDenormals and the module requires no
VkProperty::MetalFloatDenormals. An entry that declares no float-controls mode keeps the
deviation, and so does every other driver.

Why: runtime_lane::driver_deviations::fused_pairs_answer_metals_nans_and_denormals failed on the
RTX 5080 Laptop GPU (615.71.09) and the RTX 3090 (620.70.06) at pin 93b. The same 33 of 4,096
words in each fixture kept a denormal where Metal answers zero (thread 0x11: 1e-20 * 1e-20 gives
0x116c2; thread 0x29: the smallest denormal times 2^30 gives 0x04000000). That held for the lone
product a * w as much as for the fused pairs, so the fused pairs are not the cause. The fixtures
compute half in 16 bits, so their entries declare RoundingModeRTE, DenormPreserve and
SignedZeroInfNanPreserve for 16 bits. The deviation's probes (nan_denormals,
nan_denormals_fast) declare no mode and flush on the same GPUs. Vulkan leaves 32-bit denormals to
the implementation when no 32-bit mode is declared (the NVIDIA profiles report independence ALL),
and NVIDIA states no shaderDenormFlushToZeroFloat32. So the device's answer stands (owner rule 1),
scoped and noted; nothing is flushed in the shader. RADV on the Radeon 780M (Phoenix and Hawk
Point, Mesa 26.2.6) declares the same modes there and passed the test at pin 93b, so it keeps the
deviation. MoltenVK states no shaderDenormPreserveFloat16, so its entries declare no 16-bit mode.

The device test now decides "Metal's" per kernel (requires_property), as the float_denormals tests
do, and asserts DeviceDenormals where the kernel does not require the property. The new unit test
float_denormals_under_the_half_controls_are_the_devices_where_its_driver_keeps_them checks the
5080 Laptop GPU, the 3090, the desktop RTX 5080 and the 780M against fmx_fma_precise,
fmx_fma_fast and nan_denormals. It fails without the rows.

Docs: the workaround's doc, the DEFECTS and MetalFloatDenormals table docs, the deviation and
property docs, PrecisionNote::DeviceDenormals, docs/API.md's device-denormals entry,
docs/FAST-PATHS.md's denormal row, the signature table. SEMANTICS_VERSION 2116: NVIDIA modules'
notes and requirements change. No new Degradation kind.

Landed (main) at once, before its check: the lane's check (clippy plain
and cpu_icd, the touched unit tests, the two denormal device tests on
lavapipe) and the NVIDIA device proof run after landing.
2026-11-14 15:44:20 -08:00
Anees Iqbal 1858a2fb34 RUNTIME 2316: Rate-mapped passes count their region-copy and fanned-out vertex work by box size
What: new WorkCounts fields
- rate_map_whole_copy_vertex_regions, rate_map_own_copy_vertex_regions,
  rate_map_run_vertex_regions: vertices x regions drawn through the
  region-copy variant into the whole table, by the encoder's own draws,
  and by a host step's runs;
- rate_map_fanned_vertices, rate_map_fanned_box_vertex_regions: vertices
  fanned out through the geometry stage, and those times the regions of
  their probe-bounded boxes;
- rate_map_fanned_vertices_boxed_16, _64, _256: fanned-out vertices whose
  boxes hold at most that many regions.
render::fan_out::Probed::of also ORs every block's bounds (its reach).
FAST-PATHS' FanOut row, docs/API.md and rate_mapped_pass.rs list them.

Why: on Iris a whole-table region copy costs about 16x a geometry-stage
fan-out a triangle, and the consumer's 127 ms a frame of rate-mapped GPU
time cannot be split between the encoder's own whole-table draws, runs and
fanned draws from today's counts. A plain sum cannot say how much fanned
work lies in small boxes, which a cheaper route for few-region draws
would take.

How verified (lane ratemap3, msi m3-max-30401 at 7a17a61829): render::fan_out
unit tests 6/6; rate_map device tests on lavapipe 19/19, with exact counts
in a_host_step_fans_out_the_commands_the_probe_does_not_flag (encoder frame:
own == whole == (5 x 3072 + 9) x table regions; host step: no whole-table
work, fanned vertices exact; under Exact all zero); clippy -D warnings
plain, cpu_icd and gpu; api_signatures --check clean.
RUNTIME 2316: what a run records changes. No Degradation kind, no
behaviour change.
2026-11-14 15:16:31 -08:00
Anees Iqbal 057b794f5b SEMANTICS 2115 / RUNTIME 2315: rate-mapped region copies record a box of regions per multi-draw
What: a draw through its region-copy variant recorded its regions 16 at a time (the device's
viewports). Each recording set 16 scissors, pushed its first region and stored DrawIndex as
ViewportIndex. On a guest frame the host step made about 4.7k such recordings a frame (Iris and
RTX 3090), while the GPU sat idle waiting for the step.

The variant's four clip distances already keep each copy to its region's pixels, as a fanned-out
copy's are kept; the per-region scissor only culled. Now:
- The vertex function draws region first + (DrawIndex / c)*nx + DrawIndex mod c from a pushed
  box (PushField::RegionBox, renamed from RegionFirst, now [first, columns]).
- It stores 0 as ViewportIndex, the recording's one viewport, so it writes every output the base
  variant wrote.
- The recording sets one viewport and its box's union scissor.
- A direct draw records a box as many regions at a time as one vkCmdDrawMultiEXT takes
  (maxMultiDrawCount - 1), its rows in order. A run records one recording per box its bounds
  reach; any other draw records the whole table in one or a few.
- Indirect draws keep one region a recording, under that region's scissor.
- The variant still needs shaderOutputViewportIndex and shaderDrawParameters; it no longer
  needs multiViewport.

Exactness: a border between two regions of a recording holds no pixel centre and no sample at
Vulkan's standard sample locations (at least 1/16 px inside a pixel, up to 8 samples), while each
copy's clip distance there is zero up to rounding. A box is recorded one column (row) at a time:
- in a pass whose custom sample positions put a sample on a pixel's left (top) edge;
- on a device without standardSampleLocations;
- in a 16-sample pass.
See render/fan_out.rs, folds.

A box's recording and the recordings of each of its regions alone run one pipeline that writes
the same outputs. They differ only in their dynamic viewport and scissor values and the integer
region each draw selects (Vulkan's Invariance appendix, Rules 2 and 4). The agreement between the
encoder's region-copy vertex function and the host step's fan-out geometry stage stays the
existing FAST-PATHS known gap, checked by running: no new near-equivalent, no new accepted
difference.

SEMANTICS_VERSION 2115 (the variant's module and push layout); ARTIFACT_FORMAT_VERSION 523 (the
PushField tag); RUNTIME_VERSION 2315 (what a region-copy draw records). Docs: rate_mapped_pass.rs,
render/fan_out.rs, bind/fan_out.rs, the translator's region-copy plan and store, docs/API.md, and
the FAST-PATHS fan-out row and known gap. docs/REFUSALS.md regenerated unchanged; api_signatures
blessed. No new Degradation kind, no WorkCounts field.

Tests:
- render/fan_out/tests.rs: run boxes, box recordings, box scissors, the fold rule.
- tests::rate_mapped_region_boxes (device test): the same two passes drawn directly (boxes) and
  indirectly (one region a recording, its own scissor), additively blended into RGBA16Float with
  a ground plane, border-crossing slivers and off-screen and w-straddling triangles, then an
  Equal pass, compared bit for bit, with the recordings counted.

Verified (lane ratemap2):
- msi m3-max-30288 at 9240cc0ea6: clippy -D warnings, all targets and features, plain, cpu_icd
  and m2v_gpu, exit 0; rustdoc -D warnings exit 0; translator touched tests 226/226; runtime
  33/33; lavapipe 13/13.
  - rate_mapped_depth_equal: 0 failing pixels in every pairing under Exact and FanOut. Without
    the ViewportIndex store, FanOut's mixed-route pairings had 2853 of 89483 (m3-max-30235).
  - rate_mapped_region_boxes: direct 3 draws in 3 recordings against indirect 3 in 624, 0 texels
    differ, Equal-pass mismatches [0, 0].
- Negative control (each clip distance widened by one pixel): rate_mapped_region_boxes fails,
  25464 texels differ, Equal-pass mismatches [11019, 0].
- The Iris GPU-time A/B (ms01, m3-max-30315, exclusive) is running; the consumer's renderer run
  at the next pin is the workload proof (rate_map_piece_gpu_nanos a frame on Iris).

Landing note: docs/API.md merged by hand with RUNTIME 2314's probe-parts sentence (both rewrote one
paragraph), and rate_mapped_pass.rs's Fan-out now says the probe runs in parts (RUNTIME 2314).
2026-11-14 14:32:33 -08:00
Anees Iqbal dfda37628d RUNTIME 2311: ICB records lie in pooled memory where a held pointer import taxes every submission
What: DevicePolicy gains indirect_records (IndirectRecordsPolicy, a runtime
choice no profile carries). Under the default, Untaxed, an indirect command
buffer's records and overflow slots take fresh pages of the runtime's own
(a pointer import held for the buffer's life) only where the device's import
tax check has not found that a held pointer import costs every submission, or
has not answered; where it has (RADV, ANV on i915), they lie in pooled
host-visible memory as the runtime's other buffers do. Under Carried, which
exact_answers() selects, they lie in fresh pages wherever the device imports
host pointers, as before, so a recovery keeps them. A recovery of a taxed
device under the default loses pooled records and rewrites them as a new
buffer's (carry.rs's existing pooled path); the device-recovered notice
already counts such buffers ("N indirect command buffers, M of them whose
records were lost"), as on a device without pointer imports and for
device-local records on discrete GPUs. No new Degradation kind.

Why: on a Radeon 780M (RADV, Mesa 26.2.6, Linux 7.3.3) beside a guest game
whose ICB records were the process's only pointer imports (3 buffers, 19.6 MB),
the submission thread had 5 windows of 65-140 ms in 12 s in which every
amdgpu_cs_ioctl waited in mmu_interval_read_begin or returned EAGAIN (373 of
the run's 382 failed calls, retried at once by libdrm). RADV lists every
imported memory in every CS, amdgpu re-faults every userptr page each CS and
adds the CS fence to every listed BO, so a page migration of one of those
pages (kcompactd, khugepaged, and the runtime's own block making in direct
compaction) waits in amdgpu_hmm_invalidate_gfx for all the process's GPU work
in flight while every submission waits behind it. With no userptr BO listed,
compaction migrates pages without waiting on any fence.

Docs: the FAST-PATHS ledger row (default, switch, the recovery cost, the
measured chain), API.md's device-recovered text, HOWTO's residency section,
fresh_pages.rs, indirect_command_buffer.rs and carry.rs, the conformance
crate's Policy::Exact list. API: signatures blessed, api_surface row,
REFUSALS.md regenerated.

Tests: tests::icb_records_policy (Linux, cpu_icd/gpu): the import tax forced
Holds/Fails; under Untaxed+Holds the records lie in pooled memory, no fresh
pages made, a recovery moves them and its notice counts 1 lost; under
Untaxed+Fails and Carried+Holds in the runtime's own pages, kept, 0 lost. The
translator's fast_paths names the choice, checks it keys no profile and that
exact_answers() takes Carried. icb_carry_race's own-pages cases run on a
Carried device (device_recovery::carried_device), so they assert the carry of
own pages whatever the device's verdict.

RUNTIME_VERSION moves: where records lie and what a recovery keeps change on taxed devices.
New public items: metal2vulkan::device::IndirectRecordsPolicy { Untaxed, Carried } and
DevicePolicy::indirect_records.

Verified, msi m3-max-30127 at cba1ec585a (the fix plus a test-only fix: DevicePolicy is
non-exhaustive, so the tests set the field on a copy):
- clippy -D warnings --all-targets --all-features: metal2vulkan + runtime plain 0, runtime
  --cfg m2v_cpu_icd 0;
- translator tests 49/49 (fast_paths with the new choice, its no-profile key and exact_answers
  tests, api_surface, api_signatures);
- runtime under cpu_icd on llvmpipe 34/34: icb_records_policy, icb_carry_race, icb_records_home,
  indirect_command_buffer*, device_recovery_every_kind, device_recovery_carry.
ICB-RECORDS lines:
- Untaxed with the tax forced Holds: records not in own pages, 0 fresh-page buffers, the
  carry moved them, notice "1 of them whose records were lost";
- Untaxed with the tax forced Fails: own pages, 2 fresh-page buffers, kept;
- Carried with the tax forced Holds: own pages, 2, kept.
Workload proof owed: reims's traced loaded-desktop walk on the 780M (per-CS get_user_pages 0, no
-EAGAIN windows).
2026-11-14 12:49:09 -08:00
Anees Iqbal ce54ad8b25 RUNTIME 2310: an unshared commit on its way goes before another queue's batch whose room came after it
A scheduler pass that found another queue's batch's room let it go while an unshared queue's
commit there, taken in, waited only for the runtime: its host step (handed to the steps'
thread in the same pass), its submission checks, or a shared event's value whose signal was
already submitted and had not landed. Order::next refused the unshared head and sent the
other batch; the unshared command buffer then waited for that whole batch on the GPU. In
reims's traced walk ld91 (um870 Radeon 780M, guest compositor beside gameload) another queue's
batch went in while a compositor's command buffer so waited ahead of 33 of the 46 frames
answered more than a refresh late: 20 at its host step (e.g. take 1794684425.009: gameload
#19392 committed -3.0, submitted +2.6, inside WS #19398's commit +2.3 -> submit +2.8), 13
waiting for the landing of its other unshared queue's signal.

The rule (unshared_hold.rs, "Commits on their way"): each unshared commit carries its place
among those posted on its VkQueue (SlotShare::posted_unshared now answers it). Each look
collects the unshared heads on their way (on_its_way: binary semaphores ready, every event
value reached or reached by a submitted signal, held only for its host step with no pipeline
making pending, or for its checks) that wait behind no earlier commit (is_behind), and a
batch whose room came is held (behind_commits) while one posted before its noted count leads
its line so. The step's end, the checks or the landing wake the scheduler's thread, whose
next pass sends the unshared one first. Each look asks again: a head waiting for anything
else (a value nothing submitted reaches, a binary semaphore, a making, a decode, a rebind) or
behind an earlier commit (the held batch's own included) holds nothing, so neither waits for
the other. Other threads' passes leave such batches to the scheduler's thread
(first_for_the_thread widened to heads on their way), which they wake. Counted in the
existing WorkCounts::heads_held_for_unshared_commits (doc widened). No switch, no public item,
no Degradation kind. Docs: unshared_hold.rs, FAST-PATHS unshared-isolation row, API.md.

Tests: unshared_hold unit test of behind_commits with places on their way; queue_share_device
(lavapipe), each leg by the scheduler's pass and a committing thread's:
an_unshared_head_at_its_host_step_goes_before_work_whose_room_came_after_its_commit,
an_unshared_head_waiting_for_a_signal_to_land_goes_before_work_whose_room_came_after,
an_unshared_head_behind_an_earlier_commit_of_the_held_queue_holds_nothing,
an_unshared_head_waiting_for_a_value_nothing_submitted_reaches_holds_nothing.

RUNTIME_VERSION moves: what a run submits, and in what order, changes.

Verified (msi lavapipe):
- m3-max-30046 at 71c8bf7337 (the rule plus a test-only fix), runtime crate, --all-features
  --all-targets -D warnings:
  - clippy plain and --cfg m2v_cpu_icd: 0;
  - 103/103 tests: unshared_hold, queue_share, queue_share_device, scheduler,
    scheduler_held_wakes, scheduler_wakes, inbox, waiter_submits, commit_and_submit, hold_sites,
    dispatch_pending, queue_limits_device, stall.
- New tests, each run once through the scheduler's pass and once through a committing thread's:
  - at its host step: the other buffer began 0.168 / 0.199 ms after the unshared one;
  - waiting for a signal to land: 0.183 / 0.206 ms after;
  - behind an earlier commit: holds nothing;
  - waiting for an unreached value: holds nothing.
  The RV2303 tests still pass.
- Negative controls:
  - m3-max-30021, rule off: both "goes before" tests fail (the other buffer began 1.519 ms
    before the unshared one);
  - m3-max-30036, the two no-hold exclusions removed: both no-hold tests time out at 20 s.
- Test-only fix in this change: RV2303's committing-thread test held its scheduler thread with an
  application batch that now correctly waits behind the stepping unshared dispatch. Its holder is
  now a command buffer on another unshared queue, which nothing holds back.
2026-11-14 12:22:47 -08:00
Anees Iqbal 41bac06524 RUNTIME 2308: no explicit DRM_FORMAT_MOD_LINEAR plane at a row pitch NVIDIA's shaders misread
On NVIDIA's proprietary driver, a DRM_FORMAT_MOD_LINEAR image with an explicit plane at a row
pitch that is no multiple of 32 bytes is made, and vkGetImageSubresourceLayout reports that pitch
back, but its shaders read the rows at another pitch. Measured case: 64 x 64 BGRA8Unorm at rows
272 bytes apart is read by a kernel at 256 and copied out by a blit at 272. Rows 288, 320, 384 and
1024 apart read right.

Measured on:
- the RTX 5080 Laptop GPU (615.71.09): the sweep over every multiple of 16 bytes to 1024;
- the RTX 3090 (620.70.06).
Both over host pages and over the device's own memory.

Vulkan makes the implementation validate an explicit plane layout and refuse one it cannot use
(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT), so no documented rule explains the
misread: it is a driver defect. It caused the 5080's wrong texels on development. A texture in
place over host pages, at rows padded 16 bytes past their texels, read other rows through the
pitched route; a read twin at rows 272 apart was one such texture.

The change:
- RuntimeDriverDefect::ExplicitPlanePitchMisread, on every NVIDIA GPU and release until a probe
  finds a clean one.
- Device::explicit_plane_pitch refuses such a plane at a row pitch that is no multiple of 32 where
  the device has the defect. It does so in both makers of an explicit plane: pitched_image (host
  allocations and the device's own memory) and explicit_plane_image (dma-bufs). The texture then
  takes its shadow (Refusal::Pitch; the shadowed-texture notice names the pitch), or texel rows
  for a slot that only reads.
- The bound is the measurement, not the driver's own linear alignment. The driver's own linear
  images lay rows at multiples of 128, and keying on that would shadow 288 and 320, which read
  right.
- A cfg(test) switch, DeviceShared::explicit_plane_pitch_misread_forced, stands in for the defect
  on a driver that reads such planes right (lavapipe).
- docs: a FAST-PATHS known gap (NVIDIA's pitch, with both measurements); api_signatures.tsv +1.
  REFUSALS.md is unchanged.

No new Degradation kind or WorkCounts field. RUNTIME_VERSION moves because in-place routes change
on NVIDIA, and the linear-alignment records are keyed on it.

Tests:
- textures_at_padded_rows_read_their_bytes: 64 x 64 BGRA8Unorm at 256, 272, 288, 320, 384 and
  1024, over host pages and the device's own memory, each read by a kernel and by a blit. No
  pitched image at 272 where the defect applies.
- The same test under the forced defect: on lavapipe, 272 moves off the pitched image and reads
  right, while 288 stays pitched.
- driver_defects lists the new defect.
- The padded-rows sweep tests, and the shadow log test's twin at padded rows.

Verified:
- msi m3-max-29913 at 7a64d31930:
  - clippy -D warnings, all targets and features: plain, --cfg m2v_gpu and --cfg m2v_cpu_icd all
    exit 0;
  - lavapipe read_twin_device, driver_defects, in_place_check and shadow_causes_device: 43/43;
  - api_signatures, api_surface and fast_paths: 47/47.
- Negative control (rule disabled): the forced test fails with pitched 1 at 272.
- RTX 5080 at 39d564abc4 (archive md5 dd1f3982, b5080 entry roip2-fixarch-5080-112137):
  read_twin_device 20/20. That includes the shadow log test that failed before: its twin at 272
  now takes the twin's shadow.
- The RTX 3090 run of the same archive (m3-max-29951) is queued; its result follows in the lane.
2026-11-14 11:29:56 -08:00
Anees Iqbal 8dd9d3af55 Refusals name what they saw: an unknown ABI key's string or shape, a stage-size refusal's weight and bound
- Every Abi(UnknownKey) that named no key now carries what the reader found: the unknown string
  (an argument's role or attribute, a visible function's key, a node's tag, a compile option, a
  signature kind, a module flag), cut at 64 bytes, or, where there is no string, the operand's
  shape in LLVM spelling. The detail is a crate-private field of InputError (`saw`), printed by
  Display and Debug; it lives there and not in Location because a Location field grew the
  translator's Error past clippy's result_large_err. No public item or refusal kind changes;
  REFUSALS.md regenerated unchanged.
- The ANV stage-size refusal (Feature::StageSize, DriverDefect) names the module's entry weight
  and the bound it passed in its symbol, which Display prints: "entry weight N, past the bound B".
  The bounds and the refusal are unchanged; the FAST-PATHS known-gap row says so.

Why: a consumer's log of a GL-on-Metal kernel refused as UnknownKey at an argument with key None
and of two kernels refused for stage size could say neither which key nor how far past the bound;
one rerun at the pin carrying this names both.

Translation output unchanged: no SEMANTICS or RUNTIME bump.

Verified (msi, m3-max-29879 at 2ddbda8ecf): clippy air + translator 0; metal2vulkan-air 567 passed
incl. abi::tests::an_unknown_key_names_what_it_read (a synthetic node per site, whole location,
seen detail and Display); metal2vulkan a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused
(symbol and Display name weight and bound past each defect's bound), error::tests and engine_handles
compute tests 10 passed, llvm-as present (no SKIPPED).
2026-11-14 10:52:44 -08:00
Anees Iqbal 948b5e37fb RUNTIME 2306: a texture over a bit-24 buffer that no image lies over reads a shadow of its read twin, not of the copy
A no-copy buffer of Metal's private option bit 24 is a copy of its pages off macOS, beside a read
twin over the pages in place. A slot that only reads a texture over such a buffer binds the
texture's read twin, but only where the twin's texture lies in place over the twin's bytes. Where
it did not (RADV lays no DRM_FORMAT_MOD_LINEAR plane whose rows or first byte are off a multiple
of 256: a window server's 48x48 textures at rows of 192 bytes, its 128x128 ones at rows of 512
from 32 bytes in), the twin's texture was made as a shadow and dropped. The slot then bound the
program's texture, itself a shadow of the copy for the same reason, so its command buffer used the
copy and its commit compared the whole copy with the pages.

Workload reason (reims's appwalk17 desktop walks, numbers only): twin textures not in place
780M 362, RTX 3090 304, Iris Xe 1; copies compared 52,537 (2,897 MB), 43,384 (2,138 MB) and 331
(35 MB); the Iris compared in one walk step only, the one that made its one twin not in place.
Copies compared plus twin slot reads come to about the same total on all three (56,775, 52,277,
54,233): every such read that missed a twin read the copy.

Now the twin's texture is kept as a shadow of the twin's bytes where the program's texture is a
shadow too, and the slots that only read the texture bind it under the same proof as before. The
program's texture lists it beside its own shadow (shadow::texture_copies, held weakly), so draws,
rebound draws, dispatches and resident textures copy it in from the pages in place at its first
use in each command buffer, where they copied the texture's own shadow in from the copy (a shadow
of a copy of Shared memory never stands). Where the pages carry a log of their writes only the
changed rows move. The command buffer names the twin's and the shadow image's keys, never the
copy's, so its commit compares nothing. No store reaches the pages: the twin's one GPU access is
the copy in's read, the shadow is the runtime's own image no call returns, the slots only read it,
and a copy back would write the twin's key, which every encoder refuses.

Discrete devices take it too: their copy lies in system memory (MemoryClass::Shared), as the
pages do, so the shadow's copy in crossed the bus before and crosses it now; what goes is the
CPU's comparison. Cost: an image of the texture's size per such texture while it lives.

- WorkCounts::read_twin_texture_shadows (new field). No new Degradation kind.
- The shadow log's twin line says whether the twin's shadow serves the read slots.
- cfg(test) DeviceShared::linear_pitch_rule_forced: RADV's LINEAR plane rule at Device::unplaced.
- Tests (read_twin_device): the two shapes sampled by a draw and the 128x128 one read by a
  kernel through the twin's shadow (compares 0, a CPU write read next, a fill read back through
  the copy, pages kept); over logged pages the second command buffer copies nothing in and a told
  write moves its rows alone. The screen-sized texture lavapipe lays no image of now reads its
  twin's shadow too.
- Docs: read_twin.rs, shadow_log.rs, API.md and the FAST-PATHS row on bit-24 memory;
  api_signatures.tsv (+1).

Verified (msi lavapipe, m3-max-29778 at 69f0a567b1): clippy plain and --cfg m2v_cpu_icd 0;
read_twin_device, copied_device, copied:: units, texel_rows_device, dirty_pages_device and
waited_reads 73/73; api_signatures and fast_paths 35/35. With RADV's LINEAR rule forced (offset
and pitch multiples of 256): 48x48 at pitch 192 and 128x128 at pitch 512 offset 32 sampled by a
draw and read by a kernel: twin slot reads +1, compares 0, texels the pages', a CPU write read
in the next command buffer; a fill in the same command buffer reads back through the copy with
one compare, pages kept; over a dirty log an unchanged twin copies 0 bytes. Negative control
(serves cut back to in-place only): the 3 new tests fail, the commit compares the copy.
2026-11-14 10:22:01 -08:00
Anees Iqbal 933b4e774d SEMANTICS 2112 / RUNTIME 2304: a texture no image can lie over is read and written in place through a texel buffer of its rows
A texture over a buffer is Metal's linear layout: texel (x, y) at offset + y * bytesPerRow +
x * bpp. Where the device refuses the image route over the buffer's pages (a texture over pages
that need more than one dma-buf, a LINEAR plane at a refused pitch or offset) but the buffer is
in place, a slot whose function only reads (read, not sample or gather), writes or asks the
size of that texture now binds a storage (or uniform) texel buffer view over the buffer's bytes,
addressed as rows (the row pitch in texels and the size from a push field), instead of a shadow
image copied in and out. The texel buffer view's format converts as the image's would: the
device's own conversion, no note.

- Translator: a structural fact of the slot (its uses are read/write/size only, proven in
  lowering), a push field and a variant key, after the YCbCr in-place variant's machinery.
- Runtime: the planner takes the rows variant where the image route is refused for a stated
  reason; the tracker sees the slot's writes as writes of the buffer's bytes (rows only, the
  bytes between rows untouched); a buffer with a read twin takes no rows (its twin texture
  stays the shadow of its truth). Sample and gather uses, levels past the first, arrays, 3D and
  compressed formats stay shadows.
- WorkCounts: texel_rows_textures, texel_rows_bound. No new Degradation kind, no precision note.
- Docs: API.md variant section, FAST-PATHS known gap narrowed, the shadow log's rows line.

Workload reason (consumer's 780M diagnostic, numbers only): of the device-gap shadows in three
compute workloads, half the textures are only written by their kernels (1.67 G texels per pass),
the other half only sampled; the written half takes this route.

Verified (msi, lavapipe): texel_rows and read_twin tests 28/28 at f848389cfc (m3-max-29579):
over a copy that lavapipe refuses as an image (pitch 272), no shadow copy, rows bound, texels
inverted in the pages, gap bytes kept, a sample in the same and the next command buffer read the
rows' writes; RGBA8Unorm 1024 codes read / 1024 floats stored and RGBA16Float 65536 / 65536 bit
for bit against the image route. Clippy plain, --cfg m2v_cpu_icd and --cfg m2v_gpu 0; rustdoc 0
(m3-max-29541 at 532be1f473, route code unchanged since). Negative control (the row word swapped
for the width word): 6 of 13 tests fail. Release first dispatch of a new state on lavapipe: base
4.12 ms cold / 0.98 warm, rows 2.80 / 1.56 (the rows side also commits over a copied buffer).
2026-11-14 09:04:48 -08:00
Anees Iqbal 2818c1fcd0 RUNTIME 2303: a committing or waiting thread's pass leaves other queues' batches behind an unshared head it cannot send
A thread about to block (Scheduler::submit_before_waiting) or one that just committed with
commit_and_submit (Scheduler::submit_at_commit) takes the inbox in and submits only the batches
that need nothing of the scheduler's thread (submit_plain_ready, plain_ready). take_in counts
the unshared commit taken, so RUNTIME 2300's gate in plain() lets other queues' batches through;
Order::next puts the unshared queue's head first but skips any head `ready` refuses and goes on
to the next. So where that head is ready for the scheduler's own look but not plain for this
pass (a submission or scheduled handler for a waiting thread, a host step already recorded, a
switch of storage forms riding on it), another queue's batch on its VkQueue whose room had come
was submitted ahead of it, where the scheduler's pass sends the unshared one first
("Heads put first").

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

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

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

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

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

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

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

Verified (msi, lavapipe): the full runtime suite 2683/2684 at c502efba29, the one
failure the race test fixed in ca5042567b; clippy plain and --cfg m2v_cpu_icd, rustdoc,
fast_paths 0. Negative control (the explicit order removed, renderfold-negctl): the
hazard tests fail on their barrier counts; lavapipe shows no wrong texel because it
completes each command as it runs, so the texel proof is a GPU that overlaps work.
2026-11-14 08:59:50 -08:00
Anees Iqbal df4cee2e01 RUNTIME 2300: Unshared hold: a batch whose room comes during a pass waits for an unshared commit posted before it
A scheduler pass takes the inbox in once, at its start (scheduler/inbox.rs), then submits one
batch after another, about 0.3 ms each on the Radeon 780M. An unshared queue's commit posted
during the pass waits in the inbox until the pass and its handlers end, and "Heads put first"
only orders heads already in the order. Meanwhile each further look of the same pass asks the
other queues' held heads again, and one whose room came (the oldest batch's credit grew, or its
queue's previous batch went) was submitted ahead of the compositor's commit.

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

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

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

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

Verified (msi lavapipe): m3-max-29410 at the tip: clippy -D warnings (runtime, plain) 0;
74/74 under --cfg m2v_cpu_icd (unshared_hold, queue_share, queue_share_device, scheduler,
scheduler_held_wakes, scheduler_wakes, inbox). Negative controls: the hold off (29412)
fails with the slip reproduced (next 501.3 ms before drawn 752.6, 0 holds); a hold with
no note (29413) fails starved (next 1007.1 behind later 756.4). The workload proof is a
traced compositor-beside-load walk on the 780M after landing.
2026-11-14 08:13:09 -08:00
Anees Iqbal 618e452a38 RUNTIME 2298: a depth StoreAndMultisampleResolve into write-dropping memory completes without its resolve
store_out.rs faulted a pass whose depth attachment stored and resolved
(StoreAndMultisampleResolve) into a resolve texture over memory whose GPU
writes are dropped (Metal's private bit 24, or pages mapped read-only):
PageFault, and a queue's second fault revokes it. Metal does not: on an M3
Max under macOS 27.0.1, a 4x Depth32Float attachment cleared to 0.25 and
stored-and-resolved into a 16x16 Depth32Float at the start of a bit-24 heap
completed 6 of 12 command buffers and ended 6 as innocent victims, never a
page fault and never a revoked queue, its resolve texture's bytes kept;
depth MultisampleResolve into the same heap faults every time.

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

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

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

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

New test: submission_checks::a_check_failing_one_submission_a_shared_recording_holds_fails_each_it_holds.

Verified (msi lavapipe, --cfg m2v_cpu_icd): m3-max-29331 at the tip:
clippy -D warnings (all features and targets, runtime + validation) 0 under
m2v_cpu_icd and plain; 402/402 tests (rebind_reach, submission_checks,
failed_commits, predication, rebinds, indirect, encoder_fold, command_buffer,
fast_paths and pin 90's four). Negative controls on development's runtime
sources (m3-max-29315, 29330): rebind_reach, wcdc and the new test fail.
2026-11-14 07:23:37 -08:00