Commit Graph
1296 Commits
Author SHA1 Message Date
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 76cef9e9af Shadow log: a dispatch's first use of a shadowed texture, and a read twin not in place, with its reason
The shadow log (METAL2VULKAN_LOG_SHADOWS, default off) named a shadowed
texture's first draw only, so a texture bound only by kernels never said
whether its function fetches, samples or writes it; and a read twin whose
texture is not in place was counted (read_twin_textures_not_in_place) with
no reason anywhere. A consumer's runs need both to size the texel-buffer
route for shadows: whether the kernels over 600 list_limit shadows read or
sample them, and why 233 twins are not in place.

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

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

Diagnostic only: both lines print only under METAL2VULKAN_LOG_SHADOWS; no product
path changes. Verified: msi m3-max-29434 at the tip: clippy -D warnings (metal2vulkan +
runtime, all targets and features, --cfg m2v_cpu_icd) 0; read_twin_device 15/15 incl.
the_shadow_log_names_a_twin_not_in_place_and_a_dispatch_s_first_read.
2026-11-14 08:20:13 -08:00
Anees Iqbal 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
Anees Iqbal 23f84517cb RUNTIME 2295: kept padding in an exportable block asks the device for its pitched image
A texture over a Private buffer's rows with bytes between them, at a pitch
the device's linear image does not lay them at, was a shadow by fiat where
the buffer lay in a block of the runtime's buffers allocated exportable as
an opaque file descriptor; over a plain block the same texture is a
DRM_FORMAT_MOD_LINEAR image at Metal's pitch, in place.

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

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

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

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

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

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

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

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

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

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

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

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

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

Verified (blitfold, msi lavapipe): m3-max-29164 at 5845456c61: clippy (runtime, cfg m2v_cpu_icd,
all targets/features, -D warnings) 0; 185/185 including the encoder_fold tests and
a_rebind_encodes_a_group_again_in_a_command_buffer_of_command_predication (the narrowed refusal:
words right, reencodes_refused 0; REFUSALS.md regenerated, unchanged). A/B m3-max-29165 (own target
dirs, md5 c2157758 base 45fdc3e601 / a2214763 tip, ABAB): VkCommandBuffers begun/submitted per Metal
CB, 200 dispatches: blits 542/799 -> 1/1, copies 271/399 -> 1/1, encoders 1/1 -> 1/1; lavapipe GPU
us a dispatch blits 54.98 -> 37.35, copies 9.25 -> 2.36, encoders unchanged; host thread CPU blits
~-1.1 us a dispatch, copies even (logging ~+300 ns a blit encoder paid back by no new
VkCommandBuffer and a shorter commit). No WorkCounts field or Degradation kind. Negative control,
lint in the other configurations and the suites run after landing.
2026-11-14 05:59:35 -08:00
Anees Iqbal 738d3fb2ba RUNTIME 2291: the host residency counts a shared dma-buf file once and releases its pieces together
With buffers grouped into shared dma-buf files (RUNTIME 2290), the residency
still counted and released one buffer at a time. On RADV a shared file's
import leaves the submissions' list only with its last holder, so releasing a
piece of a file other buffers still hold took nothing off the list and cost a
VkBuffer and a bind at the piece's next use. The 780M run of the shared_files
example (job m3-max-29062) released and rejoined 936 of 1,000 pieces of one
file that way, once the cap of 64 applied.

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

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

Verified (dmagroup, msi lavapipe --cfg m2v_cpu_icd, no-pointer device): m3-max-29116 at the same
content: 102/102 (dma_buf, host_residency, host_import_groups, pointer_residency, no_pointer_import,
host_ram_dma_buf, host_aliases, dropped_uncommitted, chunks_cover, copied dma-buf tests). 4 buffers
over one file, cap 1: released 0, past the most 0, imported again 0 over three rounds; negative
control (4 own dma-bufs, cap 1): 3 released past the most, 6 by the end, 3 imported again; two files
of two buffers, cap 1: the least recently read file's 2 buffers released together, shared imports
live -1, an exposed buffer's file not released. m3-max-29139: clippy cpuicd/plain/m2v_gpu 0,
private-items rustdoc 0, touched tests 12/12. No WorkCounts field, Degradation kind or API change.
2026-11-14 05:56:32 -08:00
Anees Iqbal 4cdae42a8f HOWTO: which calls block their thread while a runtime-suspended GPU resumes
Rewrites the runtime-D3 host note of section 8 in place from d3wake's probe on an RTX 5080
Laptop GPU (driver 615.71.09, Linux 7.2; b5080 entry d3wake-probe-050814, probe branch not landed):
bare Vulkan calls made after 25 s idle with the GPU suspended hold their thread for the resume
(empty vkQueueSubmit 982 ms, a host write to device-local memory 986 ms, a device-local
vkAllocateMemory 988 ms, a pool reset and the recording of 8192 dispatches 987 ms); `commit`
returns in 0.03-0.43 ms and the resume lands on the scheduler thread's submit
(batch_submit_nanos 979-986 ms); a commit that records a CPU-written indirect command buffer on
its own thread holds it 951-952 ms (arenavram's entry); commit_and_submit and the making of an
object that takes a new device-local allocation are stated as expected, not measured.

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

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

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

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

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

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

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

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

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

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

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

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

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

Verified (codegen): ISA compile-only gfx1103 RADV 26.2.6 (amdgpu noop drm-shim) on our own half4
column convolution: the loop's read and store are buffer_load_b64 / buffer_store_b64 as the native
twin's; VMEM 5 -> 2 (native 2), instructions 88 -> 83 (native 56). msi m3-max-28997 at ae8ac29436:
clippy -D warnings all targets/features (translator, runtime) 0; touched tests 292/292
(engine_access incl. eight_byte_leaves_move_as_one_uvec2: views, OpStore counts, exact bytes on the
CPU interpreter at every residual, both encodings, every tested profile); metal2vulkan suite 3578
passed, 1 expected failure golden_hashes_match_the_table (re-blessed on development next).
2026-11-14 04:42:19 -08:00
Anees Iqbal 49215a4b4d RUNTIME 2284: live-buffer tables rebuild only a changed chunk's part, and share an unchanged set
A command buffer's live-buffer table (the resident set every heap-reaching pipeline's root table
names) was rebuilt from the whole sorted list at every commit: ResidentSet::new over ~2-4k listed
buffers, sort and bytes, 77% of commit_and_submit on the SR-shaped chain.

- Translator: bind::ResidentPart and ResidentSet::of_parts (new public items). resident_set is split
  into sort + fold; `joined` joins parts at their heads and re-sorts any parts whose ranges
  interleave, so the joined set equals the set of all their ranges.
- Runtime: each SortedChunks chunk keeps its derived part (a OnceLock, dropped when the chunk
  changes or goes). A table joins the parts. A table whose parts equal the last table's (pointer
  first, value only where the pointer differs) shares that table's LiveSet (set + uploaded buffer)
  and writes nothing. Inner.spare becomes Inner.last: Option<Arc<LiveSet>>, kept only while a
  buffer is listed and dropped at close(), as the spare was. Parts hold no buffers.
No translation output change; no Degradation kind or WorkCounts field.

Verified (livebuf2, msi): tip check m3-max-28960: clippy -D warnings --all-targets --all-features on
the translator and the runtime 0; translator tests 33/33 (resident, including the property test
a_set_joined_of_parts_is_the_set_of_their_ranges, 4000 random lists, >1000 interleaving;
api_surface; api_signatures); runtime tests on lavapipe 13/13 (sorted_chunks with
the_set_joined_of_the_chunks_parts_is_the_set_of_the_list, 6000 random changes, cached == fresh
each step; heap_reach_once now asserts a table after a buffer placed where a gone one lay shares the
earlier set and upload; device_recovery_live_table; live_bind; pending_rebind; rebind_behind_a_wait).
Release A/B m3-max-28959 (lavapipe, own target dirs, md5 a5be4364 base / 99dc49d3 tip, one run
each): commit ns per CB sr-2k 27423 -> 13754, sr-4k 45865 -> 20896 (noisy: a build shared the
host). LiveBuffers::table 77% -> 26% of commit_and_submit. Lint and the suites run after landing.
2026-11-14 04:24:52 -08:00
Anees Iqbal 3fba08c913 SEMANTICS 2108 / RUNTIME 2283: a kernel's unaliased, unwritten buffer arguments are NonWritable
Compute modules never decorated a buffer view NonWritable (serialize/non_writable.rs served graphics
only) and every buffer view was Aliased. RADV keeps a uniform read on vector memory unless the SSBO is
reorderable, so a read-only weights buffer was read with buffer_load_b32 instead of s_buffer_load.

Now a compute buffer argument that AIR marks air-buffer-no-alias (the current Metal compiler marks
every buffer argument) and that the kernel never writes (no store, wide store, atomic, ordered access
or argument-buffer source) is decorated NonWritable. Graphics unchanged. Exact under rule 1, decided
from the IR's structure and AIR's metadata, no names. A dispatch binding the same memory to an
unaliased read argument and to a written one may read the old bytes; Metal's no-alias contract
already allows that (docs/API.md section 10 says so). No Degradation kind, refusal or public type.

Verified (codegen): RADV 26.2.6 compile-only for gfx1103 (PHOENIX) under Mesa's amdgpu noop drm-shim
on msi, our own MSL: a row convolution's weights read becomes s_buffer_load (static latency 3627 ->
3270, inverse throughput 453 -> 409, VMEM 3 -> 2); a half column convolution VMEM 5 -> 4. msi job
m3-max-28950 at 9e9d464cc5: clippy -D warnings (metal2vulkan, runtime, all targets/features) 0;
154/154 touched tests incl. an_unaliased_unwritten_buffer_is_non_writable (unaliased, attribute
stripped, written, volatile) and engine_nonwritable sweeps over every public fixture. Golden tables
are re-blessed on development after landing.
2026-11-14 04:16:38 -08:00
Anees Iqbal a90207f660 Encoder times: a default-off diagnostic of each encoder's GPU time, by its pipeline states
METAL2VULKAN_ENCODER_TIMES (registry; env_vars::encoder_times()): the runtime had GPU times per
command buffer only, so a guest frame's or a workload's GPU time could not be split by pass or by
kernel. When set:
- each encoder writes two bottom-of-pipe timestamps into its own recording (a folded compute
  encoder's into the shared tail at its join; a render pass gets its own continuation so commands
  recorded before the pass stay inside the bracket): no batching or submission changes;
- PLAIN 2-query slots from gpu_time's pool machinery, reset on the host at take; an encoder whose
  recording never runs (re-encoded, predicated out, failed) reads unavailable and counts untimed;
- at completion each encoder's ns is attributed to its kind and the label hashes of the states it
  bound (the encoder trail's SHA-256 of label + function names: no name or shader text printed);
- every 5 s of activity and at device drop: a header and the top 20 rows by GPU ns (encoders,
  dispatches/draws, total, share, p50/p90/max from a bounded log histogram); `<N>ms` also prints one
  line per command buffer of N ms or more with each encoder's offset and time.
Off on adopted devices and MoltenVK. Unset: one relaxed flag load per encoder open and completion;
no query pool, no extra VkCommandBuffer (tested). docs/API.md beside ENCODER_TRAIL/QUEUE_TIMES.

Verified (enctimes, msi lavapipe): m3-max-28867 at 6a94ed14ea: clippy (runtime, cfg m2v_cpu_icd) 0;
encoder_times 5/5: a folded short/long/short compute command buffer reports 3 encoders under 3
hashes (0.098 / 15.018 / 0.109 ms), the summary ranks the long one first (98.6%); off: begun
(encoder cbs, continuations, slots) (3, 0, 0) on two runs vs (4, 1, 2048) on. m3-max-28859:
m2v_gpu build and clippy 0. The 5080 entry, plain clippy and rustdoc follow.
2026-11-14 03:52:04 -08:00
Anees Iqbal c3a2623c6f RUNTIME 2280: a pass's store-out into bit-24 memory faults its command buffer off macOS
Measured on the M3 Max under macOS 27.0.1 (plain Metal, probes/readonly_encode_answers.m, jobs
m3-max-28796/28797, 2 runs a shape, against writable controls, every pair agreeing), memory made
with Metal's private option bit 24:
- a pass storing an attachment there (Store / StoreAndMultisampleResolve), resolving into it
  (descriptor or a late store action) or storing a CustomSampleDepthStore depth there fails its
  command buffer with PageFault (~14-15 ms), its event signal fires, the pages stay unchanged;
- a kernel texture write and a blit copy into a texture over it complete with the write dropped;
- replaceRegion of a texture over it writes the pages (they stay CPU-writable);
- command buffers after the fault (same queue, a new queue, 100 ms on) complete.

Off macOS the runtime completed the store-outs. Now store_out.rs, at the pass's end once store
actions settle: an attachment stored or a resolve target actually resolved into over memory whose
GPU writes are dropped (Buffer::drops_writes of the texture's buffer or heap bytes) calls
EncoderCore::fault(PageFault): the pass and every encoder after it run nothing, every event signal
fires, the fault counts toward the queue's revocation as other faults do. DontCare, an unresolved
resolve texture and writable memory complete. A cfg(test) switch store_out_unfaulted serves the
negative control. Docs corrected in place from the measurement: read_only_view.rs, PRIVATE_BIT
(values.rs), capabilities.rs, the host_page_writes cases' notes, the FAST-PATHS known-gap row, API.md,
HOWTO.md. No refusal, public type, Degradation kind or WorkCounts field changes.

Verified (rocontract, msi lavapipe m3-max-28813): clippy (runtime, cfg m2v_cpu_icd) 0;
store_out_device 6/6 (colour Store with the buffer twinned and untwinned, resolve-into descriptor and
late, depth CustomSampleDepthStore descriptor and late, Store in a bit-24 no-copy heap all fault; the
completing shapes complete; the next command buffer completes and reads the pages); negative control
(fault off): the Store completes. The suites run after landing.
2026-11-14 03:29:43 -08:00
Anees Iqbal b38a5219e5 RUNTIME 2279: padding-unobserved buffers lie in blocks of their own, exportable as dma-bufs, no image bound there
On RADV a block of plain device memory is a buffer object of the process's reservation, and its
making holds every submission of the process while the kernel fills its pages (FAST-PATHS: up to
228 ms under compaction). Buffers whose padding is unobserved (the DRM_FORMAT_MODIFIER_LINEAR
textures over them import the buffer's memory as a dma-buf) now lie in a pool of their own
(Holds::FdDmaBufs) of blocks exportable as dma-bufs, which are not of that reservation. No image
binds there (a texture over such a buffer imports it: exported_dma_buf_alias); images and other
buffers keep their blocks. The FdBlocks blocks of the in-place check are OPAQUE_FD-only, as before.
A two-plane YCbCr texture over such a buffer reads its planes through the texel buffer
(ycbcr_planes_images_kept_exportable_block). The pool keeps room only once it holds a block.

Trade (FAST-PATHS Private row, hold row and a per-import known gap, with the numbers): each live
dma-buf import is listed in every submission: ~0.49 us per import or block per submission.

Verified (expbuf, um870 Hawk Point 780M, RADV, one run each, untraced):
- contract m3-max-28666 (same diff pre-rebase): 29/29 under the validation layer, 0 reports of
  09860/02726/02728; 0 textures lost placing for both kinds; textures over such buffers took the
  dedicated dma-buf import with 0 shadows, refusals or notices and read back right.
- cost, held phases, base m3-max-28790 (own target dir, md5 dd89a7d7) vs arm 28667: 160 textures
  vkQueueSubmit 0.098 -> 0.186 ms, turnaround median 0.261 -> 0.363; 320: 0.097 -> 0.275 ms, median
  0.266 -> 0.420, p99 0.405 -> 0.579; 0 turnarounds >= 8 ms either side.
- stalls while the 160 buffers were made: base 19 and 10 turnarounds >= 8 ms (slowest 9.97 ms),
  arm 0 and 0 (slowest 1.04 ms); traced A/B 28407 vs 28435: 18 vs 0, 118.2 ms vs 0 waited on the
  reservation. The userptr notifier residual (up to 24.4 ms) is independent and stays.
- lint at ee310a3087 (code identical to the tip): clippy x3 0, rustdoc 0, private rustdoc 0.
Also: the reclaim bench's scroll arms (padding-unobserved buffers, with textures, held phases).
2026-11-14 03:26:27 -08:00
Anees Iqbal 89a50bb41b RUNTIME 2276: read twins serve draw and dispatch slots that only read a bit-24 buffer or a texture over one
Steps 1b and 2 of the in-place read-only (bit-24) no-copy buffers on Linux: a slot that only reads
such a buffer, or a texture over one, reads the pages in place through read twins instead of the
buffer's copy.

- Texture slot: takes the texture's twin (a runtime texture over the buffer's twin, made with the
  program's texture where it lies in place) when every use the plan lists reads, as a sampled or
  storage image; every descriptor of the slot is that image; the slot is not snapshot, narrowed or
  attached; and the twin needs no usage shadow.
- Buffer slot: takes the buffer's twin when the command reaches no memory through a root table, every
  use reads (storage or uniform), no descriptor of the slot is a vertex buffer, and the twin starts at
  the buffer's base.
- After a command in the same command buffer may have written the buffer, both read the copy.
- The write guard also covers note_reaching, note_draw and note_moved.
- Fixed on the way: the texture slot proof refused every command binding a second texture (another
  slot's image descriptor answered "not this slot's image" instead of "not this slot").
- WorkCounts: read_twin_textures_made, read_twin_textures_not_in_place, read_twin_slot_reads.
  cfg(test)-only switches read_twin_unguarded / read_twin_unproven; the guard is unconditional
  otherwise. No new Degradation kind.
- docs: FAST-PATHS row and API.md copied host pages, in place; api_signatures.tsv (+3).

Verified (roip): lavapipe m3-max-28746 at c2e1c21d55: read_twin_device, copied_device,
host_ram_copy_device 66/66 (kernel 64x64 texture and buffer-slot reads through twins, draw sampling,
texture and buffer negative controls fail as they should, 3648x2038 screen not in place on lavapipe
and read as before). RTX 5080 at b05d4de30e (same product code): 65/66, the one failure a wrong test
check since removed; screen texture twin in place, draw and kernel reads of 3648x2038 compare equal.
The 5080 run at the tip, clippy and the suites run after landing.
2026-11-14 02:31:34 -08:00
Anees Iqbal 3b2443c8fe RUNTIME 2275: the unshared hold's budget is 2 ms only while the unshared queue committed within 50 ms, else 16 ms
The unshared-isolation hold kept other queues' batches to about 2 ms of expected work ahead of an
unshared (compositor) queue on the same VkQueue at all times. On the 780M that stretched Super
Resolution's command buffers (reims gbo-780m A/B with isolation Off: SR 27.78 -> 24.78 s; 5772 holds).
Now the 2 ms budget applies only while an unshared queue on that VkQueue committed within the last
50 ms; otherwise the budget is 16 ms (the intolerable-wait line), so a quiet compositor's first
frame waits at most about 16 ms plus one batch.

- SlotShare::unshared_committed: one relaxed atomic store per VkQueue at the commit call.
- Flight::ahead takes the budget; Flight::room returns Room::Idle where only the 16 ms budget let a
  batch go; batches enter the flight either way, so the 2 ms bound is exact from the compositor's
  next commit.
- WorkCounts::heads_let_go_unshared_idle (new). No new Degradation kind, no refusal change.
- docs: FAST-PATHS unshared-isolation row (both budgets, reasons, trade, a replay over reims's
  hold-off trace: SR at 2 ms would hold 3,168 of 6,855 CBs, at 16 ms 0), API.md, the
  UnsharedIsolationPolicy::Bounded and new_command_queue_unshared docs.
- queue_share_device: the held-work runs settle their queue's expected run before measuring.

Verified (isohold): lavapipe m3-max-28760 at 337f244d25: unshared_hold, queue_share_device,
scheduler_held_wakes 28/28; quiet compositor: second long CB let go 13.5 ms before the first ended,
the compositor's CB ran between the second and third; active compositor: ran before the second long
CB (Off: after the third). Negative control (window check removed) m3-max-28762: CONTROL_EXIT=100
(device test + 2 unit tests fail). The SR A/B on a 780M is owed. Clippy and the suites run after landing.
2026-11-14 02:30:03 -08:00
Anees Iqbal 2fe01c7ac0 FAST-PATHS: ANV's buffers and every device's textures past one dma-buf stay copies or shadows
What: two known-gap entries in docs/FAST-PATHS.md and the spec's reasons in the doc comments of
`Device::sparse_granule` and `Device::imports_dma_buf_buffers` (dma_buf.rs). No behaviour change.

Why: a consumer's guest buffers over scattered 4 KiB pages need more udmabufs than one (more
runs than udmabuf's list_limit, 1024). The runtime already binds such a buffer as one
SPARSE_BINDING VkBuffer over several dma-bufs where the driver reports the import (RADV:
dma_buf_sparse_buffers in the consumer's 780M runs). ANV does not: it has sparseBinding and a
sparse-binding queue family, but vkGetPhysicalDeviceExternalBufferProperties answers
externalMemoryFeatures 0 for a SPARSE_BINDING buffer (dma-buf, host allocation and opaque fd,
with device-address usage or without) and 0x6 for a plain buffer's dma-bufs, so by
VUID-VkImportMemoryFdInfoKHR-handleType-09862 and VUID-VkSparseMemoryBind-memory-02731 no
buffer over several imports is documented there: such a buffer stays a copy where its pointer is
refused. A texture over such pages stays a shadow on every device: an image made with
SPARSE_BINDING alone has no application-visible mapping between texel location and memory
offset (spec, Sparse Buffers and Fully-Resident Images; Sparse Resource Features), and a linear
image takes no sparse residency (VUID-VkImageCreateInfo-tiling-04121).

Verified: probe job m3-max-28707 on the Iris Xe of RPL-P (Mesa 26.2.6-arch3.1, Linux 7.3.1):
sparseBinding=1, sparseResidencyBuffer=1, queue family 0 flags 0x1f; external buffer features
0x0 with SPARSE_BINDING for all three handle types, 0x6/0x4/0x6 without. Spec text read from the
Vulkan 1.4.366 specification.
2026-11-14 02:16:02 -08:00
Anees Iqbal eccc2e2885 RUNTIME 2274: read twins: fix the four failures RUNTIME 2269 left on development
Pin 87's checks at 09068993d6 failed four ways, all from RUNTIME 2269's read twins:

- tests::fast_paths: the read-twin FAST-PATHS row named `ContainmentPolicy::UnsafeOff`, a
  private item; the row now says "its `containment` is not `UnsafeOff`".
- validation runtime_lane::copied_surfaces: a ReadTwin gate refusal counted in
  host_imports_refused_by_host as well as read_twins_unimported; it now counts only in the
  latter, so the expected [1,0,0,1] holds.
- tests::host_ram_copy_device: twins stay in chunk_bound_buffers_made; the test's expectation
  follows, and its copy reads use a one-word fill in the page the CPU writes plus a copy, read
  through the copy where the twin would serve.
- private rustdoc: two read_twin.rs module-doc links fixed.

Verified (roip, m3-max-28711): fast_paths 32/32, private rustdoc exit 0, lavapipe runtime 88/88,
validation copied_surfaces 4/4. Clippy and the full suites run after landing, on development.
2026-11-14 02:15:12 -08:00
Anees Iqbal 7af3c4228a RUNTIME 2272: a failure inside a group of folded compute encoders fails only the encoders it names
RUNTIME 2268 failed a whole group of compute encoders recorded into one
VkCommandBuffer when a failure (commit_failed's From(n) or Set, a fault, a
recording failure) named only some of them. Metal runs every encoder the
failure leaves, so a From(n) inside a group dropped the work of the
encoders before n: a consumer's protection probe (a compute encoder, then
one made under protection options it fails From) read the first encoder's
words as never written.

Now every compute encoder logs its calls (replay.rs), a closed group keeps
its members' logs until the commit, and the commit splits a group its
failure fails in part (State::split_failure): the members that run are
encoded again from their logs, each into VkCommandBuffers of its own, in
the commit's call before the scheduler sees the batches (the rebind's
encode-again path, held by the same mark); the shared VkCommandBuffer is
never submitted and the failed members run nothing. Groups no failure
splits give their logs back at the commit. The split also works in a
command buffer that used command predication where its encoders are alone.
The one remaining difference (docs/API.md section 10, FAST-PATHS known
gaps): a group whose predication unit later laid a loop
(encode_start_while / encode_start_do_while) or left a record unbalanced
still fails whole.

pending_rebind's test reaches its no-log case through an If opened by the
encoder before (Unlogged::Predicated), since compute encoders now always
log; Unlogged::NoCalls's doc and notice text name what logs nothing now.

Cost (dchain, 5080 node CPU, dispatch_chain --host 20 --runs 9 --only
encoders --dispatches 2300, no host-page buffer, ABAB, ns a dispatch):
thread_cpu 3393/3396 -> 3539/3809; commit 113-126 -> 221-223 (logs held
until commit; a follow-up gives them back under one lock and keeps them as
spares); bind 49-50 -> 96-97 (the log itself, stays).

RUNTIME_VERSION 2272: folded groups split at a partial failure.

Verified (dchain): lavapipe full runtime suite at c118ca6fb6 (m3-max-28648)
2581 passed, 1 failed (host_ram_copy_device private-bit, the same at
09068993d6, owned by roip); pending_rebind negative control (guard removed)
fails on VUID-VkDescriptorBufferInfo-buffer-parameter; RTX 5080 208/208
(encoder_fold, rebind, reencode, command_buffer, dispatch, predication,
replay, fence, indirect, compute, failed); negative control at dd286c7304
(m3-max-28590): the four failure tests fail, the consumer-shaped one
included.

Squashed from steelbrain/dchain2 89480ccfd3..c118ca6fb6.
2026-11-14 01:59:11 -08:00
Anees Iqbal 0043991660 RUNTIME 2269: a bit-24 no-copy buffer's blit copies read its pages in place through a read twin
Off macOS, a no-copy buffer made with Metal's read-only option bit 24 is a
copied host buffer (CopiedFor::ReadOnly) whose copy takes every write; every
commit that used it compared the whole copy against the pages (reims's
12.7.6 walk: 130,448 MiB compared, 34,462 compare threads, copy-in bytes 0).

Now such a buffer also gets a read twin: the runtime's own buffer over the
same pages, imported in place, outside the Metal address space (key bit 63),
made only under the Contained policy and only where the pages import in
place (never a copy). copyFromBuffer:toBuffer and copyFromBuffer:toTexture
read through the twin until an earlier command of the same command buffer
may have written the buffer (a write of its key, writes_unnamed, or unnoted
uses); after that they read the copy, so the command buffer reads its own
dropped write back and the next command buffer reads the pages. Every
encoder refuses a command whose own uses write a twin key: it records
nothing and fails its command buffer. The twin is placed over the bytes
before its buffer, so a twin use does not drag in the copy.

Counted: read_twins_made, read_twins_unimported, read_twins_uncontained,
read_twin_blit_reads, read_twin_reads_after_writes, read_twin_writes_refused,
copied_copy_ins_compared, copied_copy_in_bytes_compared. Docs edited in
place: the FAST-PATHS row "Off macOS, GPU writes into read-only memory",
API.md's copied-host-pages and private-resource-option rows, read_only_view.rs.

RUNTIME_VERSION 2269: blit sources of bit-24 buffers read in place.

Verified (roip, lavapipe m3-max-28537 at ad4ed6a591, 40/40 read_twin_device|copied_device):
a 29,753,344-byte (3648x2038x4) buffer's copyFromBuffer:toTexture + buffer copy
compare [0 copies, 0 bytes, 0 threads] (was [1, 29,753,344, 7]), texels and
bytes match the pages; fill + copy-out in one CB reads the fill back, pages
unchanged, next CB in place; blit fill, blit copy-in and a kernel store through
a loaded pointer at gpuAddress leave the pages; a fill of the twin is refused
(negative control: with the guard off it changes the pages); no twin when the
import is refused, over read-only pages, or under UnsafeOff. Owed after
landing: 5080, clippy x3, rustdoc. Next steps: sampled textures over the buffer,
buffer slots, resident sets.

Squashed from steelbrain/roip 4d4bef55bd..ad4ed6a591 (encoder.rs import
conflict with RUNTIME 2268's encoder_fold resolved by keeping both).
2026-11-14 01:14:50 -08:00
Anees Iqbal dd286c7304 RUNTIME 2268: record consecutive compute encoders of a command buffer into one VkCommandBuffer
A command buffer of N one-dispatch compute encoders went to the queue as
2N - 1 command buffers (each encoder's primary and a kept barrier command
buffer before it). A compute encoder now records on in the tail of the
compute encoder before it where nothing needs a boundary: same dispatch
type and logging, same batch (no event wait or signal, no host step), the
earlier encoder one plain part (no segment, no fence update, nothing
failing or faulting), no command predication, encoder trail off,
protection options 0.

The barrier between the two is recorded per command by the tracker's own
rule between two encoders of a batch (encoder_fold::FoldOrder), joined with
the encoder's own serial barrier into one vkCmdPipelineBarrier. The folded
encoder's uses and fence waits join the group's first part's summary, so
the batch's plan orders the group as a whole; its own part keeps its fence
updates alone. A rebind encodes a group again whole or not at all; a
failure that fails one encoder of a group fails the group (docs/API.md
section 10, "A command buffer committed as failed"). Counted:
WorkCounts::encoders_folded. FAST-PATHS: the ANV command-buffer row notes
folded encoders begin none.

Also: the dispatch_chain example (gbkern, dchain): a chain of dependent
dispatches by how a command buffer holds them (encoders, serial, raw
barrier, raw split), with each shape's first command buffer's counts.

RUNTIME_VERSION 2268: compute encoders fold into one VkCommandBuffer.

Verified (dchain, at d7e4a9ce51, the same diff before its rebase):
- lavapipe (m2v_cpu_icd): 40 tests incl. 8 new tests::encoder_fold (dependent
  chain, independent encoders take no barrier, dispatch-type change, fence
  update ends a group, commit_failed inside/at a boundary, rebind re-encodes
  a group whole).
- RTX 5080 (m2v_gpu, b5080): 190 touched-family tests; FOLD-CHAIN folded 23,
  begun 1, barriers 17, 0 wrong words.
- 5080 dispatch_chain, encoders shape, GPU us a dispatch: 1000: 8.41 -> 2.92,
  2300: 7.43 -> 2.92 (raw barrier 2.92); vkQueueSubmit per command buffer at
  2300: 1007 -> 44.6 us; command buffers submitted 2N -> 2.
Owed after landing: the negative control (fold barrier removed reads wrong
words), clippy x3, rustdoc, the full lavapipe runtime suite at the rebased tip
(m3-max-28507), the 780M and XTX before/after.

Squashed from steelbrain/dchain f51ba34c37..2f2000cfbc.
2026-11-14 00:57:33 -08:00
Anees Iqbal 1443135ad8 RUNTIME 2264: readers after a barrier of a texture without feedback-loop usage take leading snapshots, weighed by area and learned coverage
On NVIDIA's drivers a linear image takes no feedback-loop or input-attachment usage, so a draw
that read such a color at its own pixels after a memory barrier split the pass and copied the
texture's scissor box (the whole surface for a guest that sets no scissor) before the new
instance: in a consumer's autoscroll on an RTX 2080 about 21 readers a present each copied a
3648x2038 surface, ~29 ms of a 45 ms take-to-show.

Such a reader now splits the pass with no copy: its snapshot draws record in an instance of
their own ahead of the reader's (LOAD/STORE_NONE, empty masks), a "leading snapshot". The device
enables VK_KHR_load_store_op_none, else VK_EXT_load_store_op_none, below Vulkan 1.3 (the
runtime's instance is 1.2, so STORE_OP_NONE was core on no device); the version comes from the
device's properties.

A leading snapshot reads the texture at every pixel its draw covers, so over host pages it is
not cheaper than the split at every area: on an RTX 5080 Laptop GPU (split_parts, 8 readers a
frame over a 2648x1658 surface over host pages) whole-surface readers took 22.98 ms a frame
leading against 17.99 split, quarter-surface readers 6.06 against 8.55; the forms cross near
half. weigh_snapshot takes whether the reader leads and skips over_bytes for it, so the area
rule weighs its first pass and, where the device measures readers (occlusionQueryPrecise),
learned coverage decides from the second: a reader keeps the leading form within the existing
bound (SNAPSHOT_PIXEL_COST 20: 20% of a 4-byte color) and splits above it. A rebound kept reader
weighs with the same flag. New WorkCounts: reading_draws_snapshotted_leading,
reading_draws_leading_covered_within / _to_half / _over_half (where the guest's readers fall
against the bound). docs/FAST-PATHS.md's row records the 5080 A/B.

Also: the split_parts lane (ignored by default, run by name) measures what split readers cost and
reads its fixtures from the crate directory the runner names.

From steelbrain/nvscroll (81915c28de..3cdbfe9256, 11 commits). Verified on potluck at 3cdbfe9256:
clippy gpu (28377), cpu_icd and plain (28379) 0; rustdoc -D warnings 0; api_signatures and
api_surface 15/15; lavapipe 478/478 (copy form unchanged there). 5080 A/B nvscroll-ab-233300
(kind t). The tip's 5080 device test and lane (b5080 batch 28393) are pending; the 2080 and XTX
runs wait for um790.
2026-11-14 00:03:40 -08:00
Anees Iqbal 3697a412e9 Name each batch submission that holds its thread 5 ms or longer, phase by phase
What: under METAL2VULKAN_QUEUE_TIMES (a default-off diagnostic that already notes queue head
and submit-return times), a batch submission that took 5 ms or longer from its start to its
vkQueueSubmit call logs one line (id name metal2vulkan-slow-submissions, through the device's
message sink, else stderr): its place in its command buffer, its VkQueue slot, the span split
into the prologue, the first work's take, the staging queue's flush (its waits for the staging
queue's lock and for one of that queue's command buffers counted apart) and the planning and
recording, then the call's own time. slow_submissions.rs holds the watch; submit.rs enters the
phases; device/staging.rs counts the two waits through a thread-local only while a watched
submission runs on the thread. Off, a submission reads one flag; no clock read, no line.

Why: in a guest's Feature Matching trace on the RX 7900 XTX, two one-dispatch command buffers
spent 23.6 ms and 323 ms between kernelStart (submit.rs's kernel.begin) and their driver call,
on the scheduler's thread, holding back every later commit; the trace cannot say which phase.
One rerun with this on names it.

Verified: not yet run; a lavapipe test (kernel_end_device) holds a submission 30 ms at its first
work's take (a new trace::Point::FirstWork) and checks that one line names it with that phase's
time, that a straight submission adds none, and that without queue times none is printed.
2026-11-13 23:43:47 -08:00
Anees Iqbal 1f20452b37 RUNTIME 2263: an execution's compute commands order by their records' barriers alone, in either kind of encoder
Metal's reference for MTLIndirectComputeCommand concurrentDispatchThreadgroups (and
concurrentDispatchThreads): "Compute commands encoded into an indirect command buffer don't
automatically serialize access to resources with other commands in the indirect command buffer.
Use barriers to serialize access to resources within a range of commands." and "If dispatchType
is serial, the compute command encoder adds a barrier before and after the range of commands. If
dispatchType is concurrent, then the compute command encoder does nothing". MSL 6.17.2: "In an
ICB, dispatches are always concurrent." The runtime ordered a serial encoder's execution as the
encoder's own dispatches: a barrier wherever their uses met (the host step and commit's
recording) or between every two commands (the GPU form).

Now a command runs after the earlier ones of its range only where its record sets a barrier, in
either kind of encoder; the segment's barriers from everything before and to everything after it
are the serial encoder's before and after the range (Execute loses `ordered`; ComputeKey loses
`ordered`, so a kept chunk runs in either kind of encoder; the GPU form puts a barrier between
two commands only where a route may set one in the records, CommandWrites::BARRIER; the
tracker's ordered_everything goes). docs/API.md's accepted difference quotes Metal's text. Not a
speed-for-accuracy choice (Metal's contract), so no FAST-PATHS row.

Also: kept_commands' compute tests note each command's own output window as an apart write
(the layer reported write-after-write between disjoint windows); trail_gpu_forms requires a GPU
form's scratch in device-local memory only without unified memory (a Private buffer lies in
system memory before the carve-out by design on the 780M), fixing the 780M lane failure.

From steelbrain/icbbarrier (b3f5e50f94, 7c5e5e60b2, fdfc1e412a; icbinherit). Verified on potluck
at fdfc1e412a: lavapipe 275/278 (28026; the 3 failures were lvpfails-owned and fixed by RUNTIME
2261 on development), clippy plain/m2v_gpu/m2v_cpu_icd and rustdoc 0 (28027), negative control
27962 (both new tests fail on the old runtime). XTX and 780M legs: not run (um790 down), owed at
the next pin's device legs.
2026-11-13 23:41:05 -08:00
Anees Iqbal 4fc0ed0e3e FAST-PATHS: the unshared hold's cost in a game's frames on the RX 7900 XTX
The consumer's game on the XTX counted 5.5 ms a frame of batch_hold_nanos, all of it the
unshared isolation hold, beside a 12 ms gap between its frame and its GPU time. queue_share's
pairs mode runs that shape on the runtime alone: the hold keeps the next batch out of the
VkQueue while the one ahead runs, and the GPU stays busy under both policies (idle 1.9% against
1.4%, a 0.18 ms against 0.12 ms gap before each frame at the median), so the hold is recorded as
costing that, not the frame's gap.

Verified: m3-max-28278 on homelab-um790-xtx-1's XTX, the four pairs runs exiting 0.
2026-11-13 23:14:39 -08:00
Anees Iqbal b3d844f9fb RUNTIME 2261: a commit returns while its batch waits for a held VkQueue; kept draws carry only into passes of the same sample positions and layer count; the lavapipe and AMD lane failures
Runtime fixes, each with a test that fails before:
- A command buffer's queue slot lives apart from its state lock (d159e7a2f1, 78d5a44df2).
  commit() handed its slot over under the command buffer's state lock, which the scheduler
  thread held across vkQueueSubmit; that submit waited for a VkQueue someone else held (a
  compositor sharing the queue), so the program's commit waited as long as the queue was held
  (gdb, m3-max-28123: the lane's checked-commit tests ended in SendError after 60 s). Test:
  tests::scheduler_wakes::a_commit_returns_while_the_thread_submits_its_batch_to_a_held_vk_queue
  (lavapipe, fails before in 20 s: m3-max-28149).
- A render encoder at custom sample positions carries no kept draw (1da568fc43): a kept draw's
  VkPipeline has the positions baked in, and carry_ends never compared the ending pass's, so a draw
  kept from a pass at custom positions was carried into a later pass of the same shape at the
  default ones (runtime_lane::sample_positions on the XTX and the 780M, draw_again.rs:1320).
- A kept draw carries only into a pass of the same renderTargetArrayLength (430fad72b8): the
  layered passes' kept draws were carried across layer counts (runtime_lane::layered_passes, both
  tests, on lavapipe and AMD). The debug check that caught both now names the parts that differ
  and whether the draw was rebound or carried (8bfeebe929, 3973769b86, 9da59ae9e3).

Test fixes (the expectation follows the runtime's documented behaviour):
- runtime_lane::degrade_notices::dispatches_degrade_once_per_kind expects a split where the device
  splits the ragged grid (1b58b69953's partial-threadgroups variant runs it whole elsewhere).
- handed_objects x2 and host_memory: a held import's deallocator runs once its command buffer
  completed, posted to the free thread (41b5430f6a) or not, as Metal's may run after the waiters.
- queue_order's host-step order test commits B once A's gate was taken (b46459080d: a batch whose
  host step has not taken its gate gives way, the order the x86 Macs keep).
- The two dispatches past 2^32 threads compile only under m2v_gpu: a CPU device runs each past the
  watchdog's 20.2 s (docs/VALIDATION.md).
- The held-wakes tests begin once the device's own checks answered.

Verified: lavapipe suite at 430fad72b8 6019/6020 (m3-max-28179; the one failure the runtime-sources
pin this landing re-pins). The XTX and 780M legs (m3-max-28177, 28178) run after the landing.
2026-11-13 21:59:11 -08:00
Anees Iqbal b31c23f7c0 RUNTIME 2257: render targets placed apart in one Private placement heap keep no shadows
A game's render targets placed apart in one tracked Private placement heap (reims gameload G2
rtheap: MSAA colour, MSAA depth and a shadow map) were held as shadows on the Iris and the AMD
GPUs, with attached reads through copies, clears in part and sample moves every frame (+34.9 ms a
frame over native on the Iris guest at pin 77). Four causes, each with a test that fails before:

- C (d1eaec0f47, 792ea614de): a heap's images shared memory wherever their keys met, so a
  texture placed apart was taken as attached to another's pass; images now share memory only where
  their bytes meet, and the heap's own shadow images use their whole key's memory.
- B1 (6f54af68e2, e56bb982d7): a multisample heap texture takes the device's own size and
  alignment answer and lies in its image (the 780M asks at most 64 KiB).
- D (f760b95001): a whole clear of a 2D multisample attachment copies nothing in.
- B2 (317d905449): a heap texture's device answer takes the device's alignment up to the heap's
  own (the XTX's MSAA colour answers 256 KiB: 2375680 @ 256K, depth 1179656 @ 128K, shadow map
  393224 @ 128K), the host GPU's real value as the owner's rule for device-describing answers
  states.
New owned fixture hpr_reads (our MSL; regen-air-fixtures): fragment functions reading a device
buffer; its golden and the compile census are re-blessed at the next pin.

Verified (steelbrain/rtheap at 23fc75a899): release lane heap_placed_targets (320x192, 7
heap-placed targets, Device policy, mean of 10 frames), placed vs device-made: XTX 1.619 vs 0.576
ms before, shadows MsaaColor/MsaaDepth/Shadow, to 0.530 vs 0.594 ms, every shadow count 0
(m3-max-27670); 780M 2.150 vs 0.579 to 0.548 vs 0.599 ms (27671). Metal policy
(exact_answers): XTX 2.033 to 0.683 ms, 780M 2.650 to 1.079 ms, shadows kept as the switch says.
Texels and kernel reads equal the device-made frame on every leg. lavapipe green (27676); XTX
(27687) and 780M (27688) every heap_placed*, attached_levels, tracker, heap and shadow test
passes, the other failures only under the carried archive's compile-time paths and the
shadow_standing layer test fixed separately (4d95375fe2). Per-draw walk_costs on the XTX, one run
a side (27834): barriers 304.5 to 275.0 us a frame, no barrier 178.7 to 251.8 us with identical
draw-path counts; an exclusive alternating re-run (27858) decides whether that is noise.
2026-11-13 20:19:07 -08:00
Anees Iqbal 76855fc0ba SEMANTICS_VERSION 2106, ARTIFACT_FORMAT_VERSION 522, RUNTIME_VERSION 2256: GPU-written indirect command buffers that inherit the encoder's buffers run on the GPU; write routes reach the indirect command buffers of their own command kind
A GPU-encoded indirect command buffer whose records inherit the encoder's buffers took the host
step: the render GPU form refused inherit_buffers (DrawReplayRule::InheritedBuffers) and the compute
GPU form had no inherited-bytes path, so every frame read the records back and replayed them on the
host (gameload's icb: 8,192 indexed draws, ~44 ms of host step a frame on the Iris against 0.29 ms
natively).

- Render (da75a4602f..f3745fd69c): a draw replay's variant takes the encoder's vertex and fragment
  buffers by index as its parent buffers, resolved to device addresses past the parent's record;
  inline bytes (set*Bytes) are planned at their slots; an unaddressed inherited buffer keeps the
  host step with its cause named (parent_entries refuses it rather than writing a zero entry). The
  executor's draw preprocess binds the encoder's vertex buffers.
- Compute (7c148c3995..0a68ac5f15): a GPU-written buffer of dispatches that inherits the encoder's
  kernel buffers runs on the GPU the same way; the new fixture icb_inherited_dispatches (our MSL) and
  its golden.
- Route kinds (2d9f4ac597..2e206952c2): every route of a command buffer joined every indirect command
  buffer it made resident for writing, so a compute ICB's writer (DISPATCH|RESET) refused the render
  ICB's GPU form in the same command buffer (DrawReplayRule::Operations): gameload -b's render ICB
  host-stepped although nothing refused its own shape. A write route now reaches only the ICBs of its
  command kind (render or compute); CommandWrites carries the kinds (ARTIFACT_FORMAT 522).
- host-replayed-indirect-commands is announced once per cause instead of once per device
  (a660b2fe8d), naming the rule that keeps a pass from the GPU form, as copied-host-pages announces
  per reason; no new Degradation kind or WorkCounts field.

Verified on the branch (steelbrain/icbinherit2 at a660b2fe8d): clippy plain, m2v_gpu and
m2v_cpu_icd and rustdoc exit 0 (27886); runtime suite 1538/1539, the one failure the catalogue text
RUNTIME 2253 already fixed on development (27884); lavapipe ICB and notice lanes 214/219 with
render_inherited_buffers, compute_inherited_buffers, write_routes, written_commands and the
beside test (inherited and own buffers: cold (8,8,0), warm (8,8,0,0), pixels as alone) passing, the
5 failures failing the same at the branch's base (27926, 27927); before route kinds the beside
test fails as designed, (0,0,8) against (8,8,0) (27764); XTX 90/101 at 60c85035e3 (27853), the 11
failures fixture paths under msi's compile-time path only, all 11 passing on lavapipe (27807).
2026-11-13 20:11:00 -08:00
Anees Iqbal 1cf0e1910d RUNTIME 2255: cubes and BC rows over an IOSurface plane are made where the x86 Macs make them
reims's oracle_surftex found the Radeon Pro 5300M and the UHD 630 making three IOSurface-plane
shapes that the runtime refused:
- a Cube and a CubeArray over a plane of a surface with planes (cases 119, 188-191). These were
  refused as Metal's own Invalid; the M3 Max asserts "carriesComplexTexture || numFaces == 1", the
  arm64 envelope.
- BC1 64x64 over a 420v luma plane, whose rows of blocks are wider than the plane's row (case 187).
  This was refused as NotImplemented(SurfacePlaneShape); the M3 answers nil.
An x86 guest was answered "made" while the host held no object for it. The x86 envelope is the x86
Macs', and they agree, so the runtime now makes them as those Macs lay them out. Measured with
surface_texture_envelope on both x86 GPUs (m3-max-27621, -27622).

Cubes: face k lies at the plane's offset + k x rows x bytesPerRow, rows bytesPerRow apart. The
planner (linear_plan.rs, faces_at_pitch) lays a colour cube or cube array over a plane, at an offset
and bytesPerRow that are multiples of 16, as a 2D array of its faces at that pitch, for the GPU
and the CPU alike. Faces past the buffer go in the texture's tail, announced as SurfaceTexelsTail,
as a 2D array's texels past it do. The image is cube-compatible, as every cube's is. Every other
cube over such a plane (another format, off 16, several levels, rows wider than the plane's) is
NotImplemented(SurfacePlaneShape) instead of Invalid. Over a surface without planes it stays
BufferTextureProblem::TextureType. The CPUs differ: the 5300M's getBytes and replaceRegion take
every face at the first's bytes, and the 630's take them one image on from the surface's byte 0.
The runtime's CPU calls take the GPUs' layout.

BC rows of 8-byte blocks wider than the plane's row keep to it, as the x86 Macs' blits do: the
blocks in the plane's row lie in place; the blocks past it read zero and their writes are dropped.
There is no tail storage: the shadow zeroes them at its first move, and blits, replace_region and
get_bytes clip to the kept columns. InPlaceRefusal::Rows's doc now also covers rows that hold fewer
of a BC texture's blocks than its row. No Degradation kind and no public item were added. docs/API.md
records two accepted differences: the CPU calls follow the GPUs' layout, and a cube's faces past
the plane's rows lie at the plane's pitch. linear_plan.rs, the RuntimeGap and BufferTextureProblem
docs, FAST-PATHS known gaps and REFUSALS.md (regenerated) are updated.

Verified (planerows, 97de630b9f on 4e694366cc, msi):
- lavapipe (m3-max-27711): 27/27, SURFACE_SHAPES_LVP_EXIT=0. Every surface shape, over Shared and
  over host pages, reads 0 wrong: 119/188/189/190/191, the four probe cube shapes, 187
  (420v.p0.fmt.bc1) and 420v.p0.bc1.32x64. The validation layer reported nothing.
- Planner unit tests (27659): 26/26.
- clippy m2v_gpu 0 (27721), m2v_cpu_icd 0 (27722), plain 0 (27724); runtime rustdoc 0.
- Owed: the XTX leg (27731, queued).

RUNTIME_VERSION 2254 -> 2255.
2026-11-13 19:19:09 -08:00
Anees Iqbal 2bd067d6c7 RUNTIME 2254: a command buffer's completion exports as a SYNC_FD sync file
A consumer that composites one GPU's frames on another vendor's GPU has to order the second
device's work after a runtime command buffer. The only semaphore export was
SharedEvent::export_semaphore_fd: a timeline semaphore as OPAQUE_FD, which Vulkan imports only on a
device with the same deviceUUID and driverUUID, so it cannot cross from NVIDIA to RADV. The consumer
waited on the CPU instead, about 3.5 ms a present on its window thread. A cross-driver handle needs
SYNC_FD, which only binary semaphores export.

New (unix only, no Metal counterpart):
- CommandBuffer::add_completion_sync_file(), before the commit: the command buffer's last batch
  also signals a binary semaphore exportable as SYNC_FD, after its to-host barrier. That batch never
  joins a submission group. A command buffer with no GPU work submits the signal alone, after its
  queue's earlier work.
- CommandBuffer::export_completion_sync_file() -> Result<Option<OwnedFd>, Error>, after the
  commit. It blocks only until the signalling batch's vkQueueSubmit has returned, never on the GPU.
  None means the work already ended, or the driver answered -1; the importer imports -1 or skips
  the wait.
- Spec: the export follows the signal's submission (VUID-03254), with copy transference. One export
  per command buffer. Event::reserve_vk_signal's doc carries the contract for a reserved signal
  that the batch waits on.
- The semaphore goes back to an idle pool of up to 8 per device once the command buffer completes
  with its fd exported, and is released otherwise.

Where the host writes the caller's pages after the GPU work (a copied host buffer's merge back, or a
managed two-copy buffer's copy-out), no GPU signal can come after those writes. There the export
waits for completion and answers None, announced by a NEW Degradation: SyncFileAfterHostCopies
(sync-file-after-host-copies, performance). Also new: WorkCounts::sync_files_exported and
sync_files_after_host_copies; RuntimeGap::SyncFileExport, for a device without
VK_KHR_external_semaphore_fd or without binary SYNC_FD export (MoltenVK, an adopted device without
the extension); Problem::SyncFile(SyncFileProblem { Committed, NotCommitted, Exported }).
docs/API.md (catalogue entry), the runtime README, REFUSALS.md (regenerated), the reach table and
api_signatures are updated.

Verified (syncfile, 8f9caba0ae on d72dc03519, msi):
- Runtime suite: 1538 passed, 6 skipped (27758).
- tests::sync_file on lavapipe (27733). llvmpipe exports and imports SYNC_FD. The no-copy buffer
  was imported by pointer. A second VkDevice imported the fd and read every byte filled. The export
  came while the status was Scheduled.
- The lane test a_sync_file_after_host_copies_waits_for_them_announced (27759): the export over a
  copied buffer's merge back waited, the pages held the fill, and the kind was announced once and
  counted.
- clippy plain, m2v_cpu_icd and m2v_gpu 0 (27709, 27737, 27760); rustdoc 0 (27730).
- Owed: the cross-vendor run on um790, the 2080 writing and an XTX VkDevice importing (27739,
  queued).

RUNTIME_VERSION 2253 -> 2254.
2026-11-13 19:06:19 -08:00
Anees Iqbal 415beb0943 SEMANTICS 2104: loop-invariant loads of uniform views move out of their loops
A new pass, spirv/hoist, runs after the roll pass. It moves a load out of every loop it is
invariant in, into the loop's preheader, in original order and inner loops first. The pure value
ops its indices need move with it. A load qualifies only when all of the following hold:
- It is not volatile and does not make memory visible.
- It goes through an access chain rooted at a Uniform-class Block view. ModuleBuilder declares
  those only for a read-only slot with a bounded window, on a profile whose containment emits no
  check; it refuses a Uniform resource that is not a Block, so no BufferBlock view exists.
- Every index is defined outside the loop, or computed inside it only by pure value ops of
  invariant operands.

A loop is a candidate only where no buffer write can run in any block from which its header is
reachable: the body, what runs before the loop, and an enclosing loop's later code through its
back edge. A buffer write is a store, atomic or image write through StorageBuffer,
PhysicalStorageBuffer or Uniform memory, or a call to a function containing one. Inside a routine,
a loop is a candidate only where the module writes no buffer at all. This also covers another
invocation's write that a barrier inside the loop would make visible.

Speculation: a load in the loop's header block runs whenever the loop is entered, so it moves on
every profile. A load in any other loop block moves only under containment with robust buffer
access (robustBufferAccess or robustBufferAccess2): a uniform view carries no in-shader check to
bypass, and robust access answers in range or zero past the bound range. Under
ContainmentPolicy::UnsafeOff only header-block loads move. Every decision comes from storage
class, view kind, operand definitions, the loop metadata, CFG reachability and the profile's
containment. The values are the same, so the pass is exact and has no FAST-PATHS row.
docs/ARCHITECTURE.md names it in the spirv row and the tidy stage.

Verified (ftk2, 6d6add9acf on 73caf92102):
- The 4 hoist unit tests plus the engine test pass (27487). The engine test reads an authored
  constant struct at fixed words, each under a per-trip branch, in a loop. On all 4 robust
  access-test profiles: the slot is Descriptor(UniformWords), the loop holds no Uniform-class
  load, and the interpreter's sums are right for n = 0, 1, 2, 5, 8. Negative control: with the
  hoist call removed, the test fails ("moltenvk-m3: loads of in in the loop").
- Suite: 3572/3573. The one failure is golden_hashes: 19 cells, engine/tns_mm_flags on the 19
  robust profiles, re-blessed on development. clippy all-features, m2v_gpu and m2v_cpu_icd 0;
  rustdoc 0 (27513-27517).
- Authored compile census (27501, M3): 0 failed, 0 differences, 0 regressions, 768 artifacts
  moved. Slowest compile 590 ms. Peak per-case worker 392 MB, against 391 before.
- Registers on the real modules:
  - RADV XTX: VGPRs 48 both ways, SGPRs 108, no spills, scratch 0, 32 subgroups per SIMD both
    ways; latency -29% (c4) and -26% (c6_8).
  - NVIDIA 2080: registers 64 -> 62 (c4_0, c4_3) and 64 -> 64 (c6_8), stack 0.
- Release timings, cold, one run each, GPU median of 21 CBs at K=1, before -> after in us:
  - The face-tracking conv kernels through the runtime, device-local:
    - XTX: c4_0 22.7 -> 20.8, c4_3 18.3 -> 17.2, c6_8 160.3 -> 133.9 (-16%).
    - 2080: c4_0 29.2 -> 26.7, c6_8 107.9 -> 103.2.
  - One interleaved bare A/B on the 2080 (27567, 6 pairs, P0): the hoist is faster in 5 of 6
    pairs, by 0.8% to 3.7%.
  - Cold "state made in" is unchanged: XTX 8.4-12.1 ms and 2080 20-71 ms in both builds.

SEMANTICS_VERSION 2103 -> 2104.
2026-11-13 18:08:36 -08:00
Anees Iqbal 7e827c1b5e RUNTIME 2251: a two-plane YCbCr texture over IOSurface rows of codes that overlap is made, as Metal makes it
A two-plane YCbCr texture can sit over a plane of a surface with planes whose rows of codes are
wider than the planes' bytesPerRow (a texture wider than its plane, or a 10-bit format over 8-bit
rows). Metal makes it. The runtime refused it at creation: linear_plan's overlap_held answered
NotImplemented(OverlappingSurfaceRows), and the guest got nil. An arm64 guest's oracle run met
one: YCBCR8_420_2P 66x64 over plane 0 of a 64x64 '420v' (luma rows of 64 bytes).

Such a texture's texels are its conversion of the planes' bytes (ycbcr.rs), which reads every code
at the planes' rows, so rows that share bytes need no row rule. The refusal was written for a
plain plane's two-region shadow copies, which a converted texture never uses. overlap_held now
holds a two-plane YCbCr texture over a plane of a surface with planes, whatever its usage.

Still refused, now at use and with the precise gap NotImplemented(OverlappingSurfaceRows) (was
NotImplemented(Format)):
- a blit from a buffer into such a texture: Metal leaves no single row's bytes there (the
  earlier row's at every shared byte of the 8-bit shape; 2047, then 1919, of 4032 for the 10-bit
  one);
- a 4:4:4 texture's stored writes;
- a render pass whose rows of codes overlap (unmeasured).

Over a surface without planes it stays refused at creation (unmeasured). docs/FAST-PATHS.md's
known gaps, the RuntimeGap doc and REFUSALS.md (regenerated) say so. No Degradation kind, no public
item.

Metal's answer (probes/ycbcr_wide_code_rows.m, m3-max-27270, macOS 27.0.1, two processes a shape),
for the 66x64 8-bit shape and a 64x64 10-bit one:
- read() and the nearest sample of every texel equal the same texture over the same bytes laid
  apart, bit for bit (0 of 4224 and 0 of 4096 texels differ);
- getBytes reads the luma rows at the pitch;
- replaceRegion writes them in order, the later row standing.

Verified (planerows, 5fdbf147d5 on 90ced1544a):
- lavapipe lane (27310): 6/6, including the new
  ycbcr_textures_whose_rows_of_codes_overlap_read_what_metal_reads.
- runtime tests::linear_plan (27319): 25/25, including the new
  a_two_plane_ycbcr_texture_whose_rows_of_codes_overlap_is_held_over_a_plane.
- clippy plain 0 (27348), m2v_cpu_icd 0 (27382, after the type_complexity fix); rustdoc 0 (27349).
- The XTX lane run and clippy m2v_gpu are queued (27440/27441/27472).

RUNTIME_VERSION 2250 -> 2251.
2026-11-13 17:31:50 -08:00
Anees Iqbal 63b71d6e2f SEMANTICS 2102: the lockstep device pass takes a pointer loaded from thread, threadgroup or payload memory as naming no object
The device pass treated every device pointer loaded from memory as the object named by the
canonical spelling of its source address (Root::Loaded). That is the right model for argument
buffers, where two loads of one member name one buffer. A pointer loaded from thread, threadgroup
or payload memory is different: it is a copy of a pointer that a store put there, and two slots can
hold the same buffer's pointer. The pass took two accesses through two such slots never to
overlap, and gave them no barrier. A convolution kernel stored through pointers reloaded from
separate byval copies. An authored kernel that stores through one slot and reads its neighbour's
word through another read a word that another chunk had already overwritten.

Such a load now has unknown roots and meets every object, so the pair falls to the address facts
like any other pair. Pointers loaded from device or constant memory still name the member's
object, as the documented binding-overlap reading has it. docs/FAST-PATHS.md's known gaps record
that reading.

Verified (ftk2, 3f8dd8821e on 69c5ab1de6):
- Fail before: the new engine_simd_lockstep::a_buffer_through_two_thread_slots_is_one_object
  fails at development (27084; the chunked schedule read 8..15 where lockstep reads t ^ 8) and
  passes at the tip.
- Suite at the tip (27141, -p metal2vulkan --all-features): 3566/3567. The one failure is
  golden_hashes. Against the table blessed at 69c5ab1de6, the change moves 19 cells, all
  engine/generic_pointers.ll | generic_functor, one per profile. That entry reads its buffer
  through a pointer a functor holds in thread memory, so its accesses now meet the binding's and
  take the barrier. The table is re-blessed on development.
- Authored compile census (27091, M3): differences 0, regressions 0, slowest compile 2663 ms,
  peak case worker RSS 391 MB.
- clippy all-features 0 (27093), m2v_gpu 0 (27095), m2v_cpu_icd 0 (27096); rustdoc -D warnings 0
  (27097).

SEMANTICS_VERSION 2101 -> 2102.
2026-11-13 17:01:49 -08:00
Anees Iqbal c7810a5925 SEMANTICS 2101: the rate-map probe raises a block's bounds once a subgroup where the geometry stage runs subgroup operations
SEMANTICS 2100 (8c89e236d0) had every probed triangle AtomicOr its bounds into its 64-triangle
block's one word, so a subgroup of consecutive triangles hit one address 32 times: the RTX 2080's
probe went from 1.46 to 9.98 ms in runtime_lane::rate_mapped_pieces (plain frame 14.8 -> 17.7 ms).
Two throwaway experiments confirmed same-address contention: loading the word before the Or
9.40 ms; spreading the Ors over 32 lane words 2.38 ms.

Now, where the device runs basic, arithmetic and ballot subgroup operations in the geometry
stage (new VkProperty::SubgroupGeometryStage, from subgroupSupportedStages; appended to the cache
codec), a subgroup's bounded lanes peel off the first lane's word in a loop, OR their bounds
together, and the elected lane does the one AtomicOr (FanOutStage::subgroup_bounds). Elsewhere each
triangle does its own, as before. A geometry module's subgroup operations now require
SubgroupGeometryStage rather than SubgroupStage(Vertex). FAST-PATHS row 50 updated.

Verified (blotch, 8881d61d60..eb549eb558 on 31a07f2867):
- Lane, warm, probe / plain / wide / Exact wide: RTX 2080 1.90 / 10.6 / 15.4 / 79.4 ms (9ec2b198f3:
  probe 1.46, plain 14.8, wide 18.6); XTX 0.20 / 7.2 / 12.7 / 130.5 (probe 0.24 before); 780M probe
  0.62 (frames from a loaded node; rerun owed). Wide frame: 35 runs into 12,241 regions, none
  into every region.
- Translator unit tests 273/273 (msi), including
  a_probe_raises_a_block_s_bounds_once_a_subgroup_where_the_geometry_stage_has_subgroups: on
  nvidia-pascal-linux one BitwiseOr reduction feeds the AtomicOr under an Elect branch and the
  module requires SubgroupGeometryStage; on lavapipe no group ops; Iris Xe and Pascal probe
  modules pass check_words_valid.
- Owed on development: clippy in three configurations, rustdoc, lavapipe/780M/XTX depth_equal and
  fan-out (warm and cold), the 780M frames rerun, the consumer's Iris sample.

SEMANTICS_VERSION 2100 -> 2101, ARTIFACT_FORMAT_VERSION 520 -> 521.
2026-11-13 16:53:13 -08:00
Anees Iqbal cbd2898434 RUNTIME 2249: a recovery's carry of pooled ICB records waits out the setters' unlocked writes; getters hold the overflow slots; reset GPU time counted
RUNTIME 2225 and 2242 let an indirect command buffer's setters write without the lock. RUNTIME
2247 put the records in the runtime's own imported pages wherever the device imports host
pointers, so every carry there keeps the pages, the pointer and the records (Kept; the carry's
forget_keys sends the next named set under the lock), and an unlocked write needs no tracking.
Records that still lie in pooled memory (a device without host-pointer import, or a failed
import) move at a recovery (Lost, every command reset), and an unlocked write could hold their
old pointer across the carry's release: a use-after-free.

- Pooled records only: each unlocked setter call counts itself with one read-modify-write
  (decided per ICB at creation, counted_write #[cold]); the carry waits the count out before it
  releases the old parts. Own-pages records write as before RUNTIME 2247, behind one branch.
- A getter's read of the slots past the records (overflow) holds their parts, as record reads do.
- WorkCounts::indirect_record_reset_gpu_nanos: the GPU time of each resetCommandsInBuffer
  dispatch, timed with the rate-map pieces' timestamp slots (a third kind), read when the command
  buffer lets go of what it retained; no sync added; 0 where timestamps are absent or wait for
  every queue's.
- set_each's setters run inlined in its loop (#[inline(always)] on set_one): the consumer saw the
  set passed by pointer read wide after narrow writes (a store-forwarding stall).
- HOWTO: each live ICB's records are one held import.

Verified (carryrace, 13fd624294 on 31a07f2867, msi lavapipe):
- Suite 27209: 92/92 (ICB carry race, reset timing, rate-mapped, indirect, executions, device
  recovery, fresh pages, no pointer import, recycling); pooled tests print Lost, own pages Kept;
  the reset timing read 0 ns for a copy alone and 1.28 ms for a reset.
- Negative controls: with the count off, the carry-waits test fails (the recovery ended while an
  unlocked write held the records' bytes); with bytes read at batch creation and no getter hold,
  the unlocked-set and getter tests crash (SIGSEGV).
- Bench 27171 (Core Ultra 9 275HX, one core, least of 3 passes), 256 commands, development
  before 2247 / 2247 / this: compute set_compute_command 70.8-74.8 / 70.8-72.4 / 71.2-71.9 ns;
  full slot 95.9-106.1 / 98.1-100.6 / 102.4-105.8; draw only 32.4-33.5 / 32.4-32.9 / 33.3-34.0.
  Pooled path with the count +35 ns a command. Inlined set_one: batched render rows -10 ns, compute
  -3 to -4 ns. Submissions with 0 / 64 / 256 live ICBs: 104.8 / 99.6 / 100.3 us median.
- API tests 15/15, rustdoc 0. Clippy's only errors at this base are development's 2248 lints in
  render.rs and render/fan_out/tests.rs, untouched here.

RUNTIME_VERSION 2248 -> 2249.
2026-11-13 16:38:21 -08:00
Anees Iqbal 8c89e236d0 SEMANTICS 2100 / RUNTIME 2248: a rate-mapped pass's parted run is drawn only into the regions its blocks reach
A flagged draw's runs (blocks of 64 triangles around the triangles the probe flags) were drawn
region by region into every region of the map's plan. With the consumer's rate-map sample on the
Iris Xe that was most of the frame: rate_map_piece_gpu_nanos 382 of 441 ms a frame at pin 74
(232 runs into 2074 regions, 83k run triangles).

Now the probe ORs each 64-triangle block's bounds, widened as before, into 16 x and 16 y buckets
(bind::fan_out::BOUND_BUCKETS, PROBE_BOUNDS_AT, BLOCK_SET, STRADDLE_SET, fn bucket; PROBE_SETS 6 ->
7), and a run is drawn, through the region-copy route as before, only into the regions its
blocks reach, as consecutive ranges in table order. A triangle crossing w = 0 is bounded by its
part where w > 0: per axis its positive-w vertices' coordinates, plus infinity on each side where
an edge crosses w = 0 (the side is the sign of w_a*v_b - v_a*w_b; within 2^-16 or NaN, both
sides). A run whose bounds reach every bucket draws into every region, as before. The route,
its clip distances and the Equal-depth identity are unchanged. New counters:
WorkCounts::rate_map_run_region_draws, rate_map_runs_every_region,
rate_map_straddling_triangles. FAST-PATHS row 50 says so with its numbers.

Verified (blotch, d141fe9096..b277d4df9e on 69c5ab1de6):
- runtime_lane::rate_mapped_pieces, wide frame (23 flagged draws, 35 runs, 8983 run triangles,
  2074 regions), warm GPU: XTX fan-out 7.2 / wide 11.7 ms (9ec2b198f3: 6.1 / 20.3), runs 4.5 ms
  against 14.2; 780M 27.9 / 37.0 (28.9 / 43.0), runs 9.1 ms or less against 14.1. Runs drawn into
  12,241 regions against 72,590; 0 runs into every region, 0 straddling triangles.
- lavapipe: rate_mapped_depth_equal 0 red in all 10 route pairs; rate_mapped_fan_out 4/4 (1
  straddling triangle; 6 runs into 864 regions, each spanning the target); 135 fan_out, region,
  rate_map and probe unit tests; the probe's structural test checks the straddle add, the bounds
  Or, the two infinities and the 12 edge-side compares.
- Owed on development: 780M/XTX depth_equal and fan-out runs with cold creation per state,
  clippy in three configurations, rustdoc, the 2080 lane numbers, and the consumer's Iris sample.

SEMANTICS_VERSION 2099 -> 2100, RUNTIME_VERSION 2247 -> 2248.
2026-11-13 16:26:40 -08:00
Anees Iqbal dbcbc704c2 SEMANTICS 2099: forward a thread-memory load to the value its single dominating store wrote, once calls are inlined and again after SCCP
A kernel that keeps values in a private (thread) arena through pointers stored in a closure-like
struct, then read back after its stitched calls are inlined, kept every such slot in memory: on
NVIDIA the arena became local memory (4,304 B on the heaviest authored shape) and the kernel ran
6-10x slower than the same arithmetic in registers.

canon::forward now runs once link, byval, erase, inline and devirt are done, and again right
after the first SCCP and the constant-load folds, over the variant the function constants pick
(SCCP runs again only when forwarding changed the body). A load from a thread allocation becomes
the value its single dominating store wrote where type, offset and length match; allocations with
no read left are dropped; inttoptr(ptrtoint p) read back through such a slot becomes p. A load of
an aggregate that holds a pointer, and a load that would read a thread or threadgroup null
pointer (it exists only in memory), stay memory loads. Plain loads and stores only: volatile,
atomic and non-private address spaces are untouched.

Running forward before SCCP first walked every unspecialized body with all function-constant
variants (peak worker 469 MB, work 10.9 M -> 29.3 M units on the scan cases); forwarding over the
specialized body keeps them at the tip's level.

Verified (ftk2, dff96439f6 on 33de04117d):
- NVIDIA statistics: the heavy kernel's local memory 4,304 B -> 0 (registers 59 -> 64); its
  sibling stays 0 B. Module words: 28078 -> 14358, 15253 -> 11962, 8132 -> 6846.
- RTX 2080 (26970, runtime CB span, median of 21): the three heavy shapes 0.430/0.470/0.221 ->
  0.044/0.046/0.034 ms (6.5-10.3x); others within -1..+3%. RX 7900 XTX (26972): 0.106/0.144/0.068
  -> 0.019/0.020/0.014 ms (4.8-7.4x); one conv shape +8% (A/B 27033 pending), another -6%.
- Census (M3, 26969): 2369 cases, 48670 compiled, 1079 refused, 0 failed, 0 differences, 0
  regressions, 10362 artifacts moved; peak worker 228 MB, slowest compile 908 ms, wall 116 s.
- Suites (msi 26948/26949) pass but golden_hashes (578 cells, re-blessed on development); clippy
  all features, each alone, m2v_gpu and m2v_cpu_icd 0; rustdoc 0. canon/tests/forwarding.rs fails
  before and passes after.
- Pipeline state creation on the 2080, cold process: 19-25 ms tip, 21-36 ms with the change,
  almost all of it the driver.

SEMANTICS_VERSION 2098 -> 2099.
2026-11-13 15:53:27 -08:00
Anees Iqbal 0ee5fb1b9b RUNTIME 2247: an indirect command buffer's records lie in the runtime's own pages, so a device recovery keeps them
A device recovery's carry of an indirect command buffer whose records lay in pooled host-visible
memory moved them to new memory and reset every command (a lost device's mapped memory has
undefined contents), where Metal keeps a Shared buffer's records across its GPU's restart. On ANV
(i915), whose held host-pointer imports cost every submission, the runtime's own small buffers
never lay in imported pages, so every ICB took that path. The consumer's test (four senders
setting nil vertex and fragment buffers while the device recovers, Iris Xe) read back a suffix of
a command's sets as 0 in 10/10 runs, at pin 75 and with RUNTIME 2245 alike.

Now the records (Device::records_buffer, FreshPages::Always) and the slots past them lie in fresh
pages of their own at any length, whatever a held import costs, where the device imports host
pointers into the Shared class's best type. The carry imports the same pages again
(Contents::Kept): records and contents pointer as they were, the CPU's and the GPU's writes kept.
Such a buffer is parked and taken again as a pooled one is. Only a device without the import, or
a failed import, keeps the pooled placement and its reset, which the recovery notice counts.
docs/API.md's recovery section says so.

Cost: one held import per live ICB, about 0.35 us a submission on ANV i915 (submit_check.rs's
measured figure), by its pages on RADV; an import at creation 17-43 us where no parked one is
taken (fresh_pages.rs).

Verified (carryrace, 362d920e11 on acb4c6780d, msi lavapipe):
- icb_carry_race::a_recovery_keeps_the_commands_the_cpu_encoded (a compute command whole and 64
  render commands' four nil buffers, recover, read back, run): base + test (27027) prints Lost and
  fails (command 0 read [None x4] where [64, 80, 96, 112] was set); the fix (27028) prints Kept,
  80/80 with the ICB, executions, recovery, fresh-page, no-pointer-import and recycling tests.
- Owed: clippy in three configurations, rustdoc, the N-ICB submission cost, the consumer's Iris test.

RUNTIME_VERSION 2246 -> 2247.
2026-11-13 15:51:44 -08:00
Anees Iqbal 977c9da12f RUNTIME 2246: setTriangleFillMode: 2 (MTLTriangleFillModePoints, Apple-private) draws a triangle's vertices as points
Apple's GL renderer sends setTriangleFillMode:2 for glPolygonMode(GL_POINT) under its Intel and
Apple-silicon caps tables. The value is not in the public headers. Our TriangleFillMode had only
Fill and Lines, so the consumer's raw-value conversion failed and its host died. Measured on
Metal: an M3 Max and an Intel UHD 630 draw only a triangle's 3 vertex pixels (a Radeon Pro 5300M
fills it); our own probe on the M3 (m3-max-26811) draws 1-px points whether point_size is 4, 1 or
unwritten, culls them with CullMode Front, and draws them with Back.

Now TriangleFillMode::Points (2) exists. The generator (scripts/regen-metal-enums) takes a
PRIVATE line for it, with its evidence, and a PRIVATE_DOCS doc comment (metal_enum! accepts
variant attributes); generated.rs stays generated and `--check` passes. The runtime draws it as
VK_POLYGON_MODE_POINT. It needs fillModeNonSolid (refused otherwise:
Feature::TriangleFillPoints) and, on a portability-subset device, pointPolygons
(VkFeature::PointPolygons; MoltenVK withholds it, so it refuses Points). New degradation
TrianglePointSize ("triangle-point-size"): Vulkan sizes the points by the PointSize the vertex
function writes, where Metal draws 1 px. An ICB command still refuses set_triangle_fill_mode, as
before. New lane module runtime_lane::triangle_points.

Verified (fillpoints, 6b9927c402 on 25be73dddf):
- lavapipe lane 30/30: points light {(3,3),(3,12),(12,3)} (Metal's 3 vertex pixels); culled
  front none, back the same 3; fill 45 px (the M3 lit 45); lines 27; fill/lines unchanged.
- msi: clippy plain, m2v_gpu and m2v_cpu_icd 0; rustdoc 0; touched tests 102/102.
- Owed: the XTX leg (m3-max-26943).

ARTIFACT_FORMAT_VERSION 519 -> 520 (VkFeature appended to the codec), RUNTIME_VERSION 2245 -> 2246.
2026-11-13 15:26:44 -08:00
Anees Iqbal b741f93b9e SEMANTICS 2098 / RUNTIME 2244: a rate-mapped pass's region-by-region draws copy each region in the vertex function, scissored, so Equal depth matches the fanned-out route
Under RateMapRegionPolicy::FanOut a draw was drawn two ways: fanned out (a geometry stage's copy
of each triangle per region, window position a*x + b*w through one viewport), or region by region
(each region through its own Vulkan viewport). The two rounded a vertex's window position
differently, so a pass testing depth Equal against depth the other route stored failed along whole
surfaces: the consumer's black blotches on lit surfaces in Apple's Modern Rendering sample on the
RTX 3090. The depth-Equal repro left 44,666 of 89,483 pixels red on lavapipe whenever the prepass
and the Equal pass took different routes; 0 under Exact or on one route.

Now on a fanning device the region-by-region draws take a region-copy variant
(RegionFanOut::RegionCopies), with no geometry stage. Its vertex function computes region
RegionFirst + DrawIndex of the table, stores its position through the region's line and four clip
distances by the one emitter the fan-out stage's copies use (pipeline::link::fan_out::region_copy:
NoContraction arithmetic, Position and ClipDistance Invariant), and its draw index as
ViewportIndex. Each recording sets as many viewports as one multi-draw takes, every one the
fan-out's over the render area, with each region's scissor at its index (bind::fan_out::scissors),
so off-region triangles are scissored, not clipped. The settle keys the pipeline with the same
viewport count (fan_out::copy_viewports). The variant replaces the regions variant, so no pipeline
is added per state. A device without multiViewport, shaderOutputViewportIndex and
shaderDrawParameters keeps the per-region-viewport route (FAST-PATHS known gap). Exact is
untouched. New: bind::fan_out::scissors, WorkCounts::rate_map_region_copy_draws and
rate_map_region_copy_recordings, PushField::RegionFirst; cache codec variants (artifact format).

Verified (blotch, steelbrain/blotch 1fd68a45c0..16d5c2404f):
- lavapipe at 16d5c2404f: rate_mapped_depth_equal + rate_mapped_fan_out 4/4, 0 red in all 10
  depth-Equal lines (mixed pairs included), 0 pipelines made at the host step; clippy CPUICD,
  GPU and plain 0; rustdoc 0. Translator suite at 8ad673ffba 3562/3563, the one failure
  golden_hashes (re-blessed on development).
- 780M and XTX at 8ad673ffba (differs from the tip by the settle fix only): 0 red in all 10
  lines. E->E GPU cold/warm: 780M 4.99/4.97 ms against Exact 1.68/1.65; XTX 1.14 ms/650 us
  against 569/265 us. Creation (shader cache off): 780M 1.32 ms/state (Exact 0.92), XTX 1.30
  (Exact 0.68).
- Owed: the same numbers at development's tip without this change (the GS fan-out), the
  clip-distance probe, and the 780M/XTX runs at 16d5c2404f.

SEMANTICS_VERSION 2097 -> 2098, ARTIFACT_FORMAT_VERSION 518 -> 519, RUNTIME_VERSION 2243 -> 2244.
2026-11-13 14:52:26 -08:00
Anees Iqbal 20d04dbd5e RUNTIME 2242: an ICB's setters write through one batch, mostly without the lock; set_render_command and set_compute_command
An indirect command buffer's CPU setters, after RUNTIME 2238's dense table and one hold: every
setter write now goes through one per-command batch (one storage pointer, one count of the writes
made without the lock), written into in place rather than handing back a ~180-byte plan (which
made a first form slower than before). The written flag (SEMANTICS 2097) is set in the one write
helper, write_field, by the rule unchanged: every setter write sets it, a write of the reset
record clears it. A draw, a dispatch, a set barrier and a cleared barrier the edits' summary
already holds, like a buffer slot before, take no lock where the GPU may not have written the
buffer, checked against an atomic mirror of the summary set under the lock; a pipeline state the
command already names is set again with no lock and no CallHold (an atomic (id, serial, kind)
mirror per command; a recovery's carry forgets it, so the next set redoes every check). New
public calls IndirectCommandBuffer::set_render_command / set_compute_command (an index and a list
of sets, no handle and no Arc clone; index and kind refusals at place 0) and the handle's
set_each; borrowed RenderAt/ComputeAt views. docs/API.md says which setter writes take no lock;
the carry docs say a write made without the lock does not wait for a carry (as buffer slots'
did; a set racing a device recovery may write through the old mapping).

Verified (icbset, f403b6e922 on 33de04117d), ns a command, median, 16384 commands, msi lavapipe
(26658, two passes), development e93b3f192e -> tip: full render slot 142.6/147.6 -> 100.7/100.1;
compute slot 119.3/123.0 -> 77.5/77.5; three fields 77.1/78.8 -> 71.8/71.9; draw only 43.5/43.9 ->
34.0/34.0; set_render_command 94.7, set_compute_command 78.9. 780M (26754, 256 commands): full
slot 154.3/167.7 -> 111.0/117.0, compute 123.3/122.7 -> 93.1/87.8. lavapipe ICB set 154/154,
including a test of which way each write went and set_each/set_render_command against one setter
at a time; negative control (a whole-record read-modify-write in write_field) fails the
strengthened two-thread test (26658). 780M: the 6 ICB device tests and set_states pass. clippy
plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and rustdoc 0 (26682, 26756).

RUNTIME_VERSION 2241 -> 2242.
2026-11-13 14:24:31 -08:00
Anees Iqbal 67fb4a7902 SEMANTICS 2097 / RUNTIME 2239: an ICB's blit reset writes only the commands written since the last
An indirect command buffer's records live in Shared host memory by design (the host step reads
them on the CPU, and plain Metal lets the CPU write a Private ICB's commands), so a blit's reset
of a whole ICB was a vkCmdFillBuffer over every record across the link: on the consumer's Modern
Rendering sample (45k commands, 101 MB of records) 56.9 ms of GPU time a frame on an RTX 2080
over PCIe x4, against 0.26 ms for the same fill in device-local memory, while the sample writes
~1.3k commands a frame.

Each command now has a u32 written flag in an optional tail after the records (16 +
capacity*2248 + 4*i; CommandBuffer::initialize and decode unchanged). The lowered encode
operations and copy_command store 1 through the contained wide_at (no tail: the sink; a faulting
operation stores nothing); the CPU setters and edit mark it, and a CPU write of the reset record
(reset_with_range) clears it; a blit copy fills the destination's flags with 1. A blit reset is
one dispatch of the new owned kernel bind::icb_reset_module per run of commands, a workgroup a
command that zeroes a flagged record with 8-byte stores and clears its flag; the overflow clear
stays a fill. The carry copies the whole storage, flags included; a lost carry rewrites the header
and zeroes the flags.

Verified (radvcompile, at 273dbba28c on 045c6fedf9):
- 2080 (26425, 26442; 45k commands): old reset 56.8-56.9 ms in every shape; flagged reset 0
  written 0.256 ms, ~1.3k written 1.736 ms, all written 60.47 ms (+6.5%: 8 bytes is the widest
  store every record allows; recorded in blit_indirect.rs "What a reset costs"). A culling-shaped
  encode kernel (45k render commands, 3 operations each): 19.80 -> 20.11-20.16 ms.
- msi 26494: engine and interpreter round trips with flag asserts and the reset kernel's tests
  59/59, runtime unit tests 1536/1536; clippy workspace all features, each feature alone, runtime,
  --cfg m2v_gpu all 0; rustdoc -D warnings and the API reference check 0.
- RTX 5080 (26478, the change before the rebase): 281/282, both new device tests passing
  (a_reset_resets_what_each_writer_wrote_since_the_last on the host step;
  an_execution_on_the_gpu_alone_runs_what_a_reset_left); the one failure, a getter test's old fill
  count, fixed in this commit. Negative control (26505, the kernel's flag store removed): both new
  tests fail. A device rerun at the landing tip is queued.

SEMANTICS_VERSION 2096 -> 2097 (the lowered encode operations store the flag), RUNTIME_VERSION
2238 -> 2239.
2026-11-13 13:16:16 -08:00
Anees Iqbal a3214f16f7 RUNTIME 2237: a skipped inert dispatch still names what it binds, so its command buffer copies Managed buffers in
RUNTIME 2228 (3969e96010) records no Vulkan dispatch for a kernel with no loop that writes only its
own threads' and threadgroup memory, but compute::record returned at the top for such a pipeline,
before the dispatch's uses were made. Its bound buffers were never named by the batch, so a
Managed buffer the CPU wrote with didModifyRange kept its modified range for the next command
buffer that named it: the guest's timed kernel, which then paid a fill-queue submission and the
bytes over the link. Metal (and pin 69) copies it in with the command buffer that binds it. The
early return also skipped the detached/rebound check, holding resident buffers, the offset and
function-table checks, the stage-in reach check, fills and first work for what it binds, and the
table retain.

Now an inert dispatch plans and makes its uses as any dispatch, passes the detached-buffer check,
and names them (EncoderCore::name_uses: keys kept, host-page buffers held and named, resident ones
held; no hazard tracking and no write noted, as it runs nothing), retains its table, counts
dispatches_skipped_inert and records no vkCmdDispatch.

Found by gbreg from the consumer's Geekbench traces on the RTX 2080 (gbt pin 69 vs gbi
a2ac4433ca; the split run gbh, their tree on our pin-69 runtime, put the rise in our runtime):
solo import_image_rgba_to_rgb 0.228 -> 1.118 ms, color_look_up_tetrahedral 0.769 -> 2.651 ms.

Verified (gbreg, 5ac162c1ba on 84f68cc6d9):
- 2080 release harness examples/inert_uploads (26460; 330ca5a282 / a2ac4433ca / 84f68cc6d9 / fix,
  medians, two passes): batch shape (40 x 8 MiB Managed, CPU-written; A = 40 inert dispatches
  binding them, B = 40 dispatches reading 4 KiB of each): B 0.36 / 169.6 / 169.5 / 0.39-0.45 ms
  (the 335.5 MB copy-in back in A); frames shape (FT-like): frame wall 0.56 / 1.2-1.34 / 1.2 /
  0.17-0.20 ms, fill-queue submissions per frame 0 / 1 / 1 / 0. Inert dispatches alone: GPU 0.006
  ms at the fix as at a2ac4433ca (the skip's win holds); encode 0.9 us per inert dispatch.
- lavapipe inert_dispatch 5/5 (26452); negative control (fix reverted, tests kept) 4/5, the new
  detached test failing Completed vs Error(DetachedBacking) (26454).
- Owed on development: 2080 copy-in test runs, clippy in three configurations, rustdoc.

RUNTIME_VERSION 2236 -> 2237.
2026-11-13 12:58:22 -08:00