Commit Graph
2438 Commits
Author SHA1 Message Date
Anees Iqbal 4b37878cda RUNTIME 2265: staging queue grows its command-buffer ring to 128 rather than wait on the host past 8
A staging submission that found its queue's 8 command buffers all pending
waited on the host for the oldest, under the staging lock, on whichever
thread submitted: the scheduler's among them, inside a batch's submission
(flush_staging), which held every queue's submissions until the staging
queue ran. On a device whose staging queue is of compute work that can be
as long as the program's kernels run.

Now the staging queue makes another command buffer instead, up to 128
(MOST), and frees those past the 8 it keeps once the host saw their
submissions complete, at the next submission. Past 128 it waits as before.
The fill queue keeps its 8: its batches submit only after they found room.
The doc comment says why 128 and what it costs (ANV below Xe-HP: a 64 KiB
binding-table block per command buffer, 8 MiB at the cap).

Counted: WorkCounts::staging_buffers_grown (made past the 8) and
staging_buffer_waits (host waits for a command buffer to come free, either
queue), classified as submission work in the conformance cost table.

Tests: a unit test of the ring's choice (reuse the oldest complete, free
the other complete ones past 8, grow below the most, wait at it), and a
device test that holds 20 staging submissions on the GPU and checks every
round's command buffer is submitted meanwhile with no host wait, then that
the ring is back to 8 after one more round. The device test passes trivially
on a device without a staging queue (lavapipe).

RUNTIME_VERSION 2265: staging submissions no longer wait on the host for a
command buffer below 128 pending.

Verified (gbkern, at ffd3a51a79 on c796a88d6a): clippy x3, rustdoc, unit 29/29,
api_signatures/api_surface 15/15, lavapipe 4/4, RTX 5080 4/4 (20 staging
submissions held, 12 command buffers made past 8, 0 host waits, back to 8 after).
2026-11-14 00:22:06 -08:00
Anees Iqbal 161e8fe310 leading_snapshots: expect coverage only after a pass that measured both readers
On the RTX 5080 Laptop GPU (b5080 entry nvscroll-tip at 3cdbfe9256) the test failed in its
second pass: Took { leading: 2, by_coverage: 0 } where it expected the whole-plane reader to
split by coverage. Its first pass recorded the readers once the pool made their pipeline
(pipelines pooled 1), and such a recording measures nothing (render.rs: a measured reader
records inside its query only where its pipeline was made at the draw), so the second pass
had no count yet. The lane in the same entry shows coverage weighing the same readers
(host pages, full coverage: 7.47 of 8 readers a frame over half, split).

The test now runs three passes and expects the coverage form only in a pass after one whose
coverage queries counted both readers, and asserts that a device that leads and measures
weighed a pass so at least once.
2026-11-14 00:16:02 -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 3805039770 RUNTIME 2262: distinct textures sharing one resource key at bytes apart share no memory; private intra-doc links resolve on x86-64
Two members of the false-overlap class that RUNTIME 2257 closed for heap-placed images remained:

- A pass drawn in color groups refused a resolve target set in its first group's encoder
  (RuntimeGap::ColorAttachmentGroups) wherever a draw had read anything with the target's key:
  check_group_resolve compared ResourceKeys only. A heap-placed target, or one made over a
  buffer, apart from the bytes the draw read was refused although Metal runs it. First.read is
  now a per-key list of UseRanges (byte ranges joined where they touch), and the refusal stands
  only where the target's use shares memory with a noted read.
- A texture made over a buffer (Storage::Alias, Owner::Buffer) took the buffer's key with a WHOLE
  place, so attached_levels, cleared_copy and snapshot_color counted every texture over one
  buffer as the same image: a pass rendering one and sampling another at other bytes took the
  attached-read route, and after a load-ordering barrier before the first draw the sampled
  texture's copy read the attachment's clear (4096 of 4096 texels wrong). Owner::Buffer now
  carries the texels' ImagePlace (Texels::place, in Buffer::tracked's offsets) and Image::place()
  returns it.

True overlaps keep their routes: the tests' controls refuse a target over the read bytes, and a
texture over the attachment's own bytes still takes the attached read and reads the clear.

Also: CI's "Private intra-doc links" step (ceiling 0 for every crate) failed on x86-64 Linux
with 16 links whose targets exist only under some cfg (runtime 10, metal2vulkan 4, air 2); they
are plain code spans or paths that resolve under every cfg now. Doc comments only.

From steelbrain/falseov (9e7367e451..b77784c0b4). Verified on potluck:
- before the fix, lavapipe (msi): m3-max-28285 at 9e7367e451 failed 3/3 (both targets refused,
  apart read attached=1); m3-max-28297 with the fix reverted: the barrier case 4096/4096 texels
  wrong.
- after: lavapipe touched filter 175/175 (m3-max-28304); XTX RADV carried m2v_gpu archive 175/175
  (m3-max-28303; asserts aliases_buffer() and color_group_passes ran).
- clippy -D warnings plain (28314), m2v_gpu (28299), m2v_cpu_icd (28301): 0; rustdoc
  --document-private-items 0 for all six crates on x86-64 (28311), public cargo doc 0.
No new Degradation kind, WorkCounts field or refusal kind; docs/REFUSALS.md unchanged.
2026-11-13 23:13:37 -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 a397a8b366 RUNTIME 2260: a rate-mapped pass of one piece times its piece
The pieces' GPU times (WorkCounts::rate_map_piece_gpu_nanos) counted only
passes recorded in two or more pieces, so a frame's single-piece
rate-mapped passes were untimed: on the Iris guest frame only about half a
multi-piece pass a frame was timed, and the Offscreen time outside the
pieces could not be split from the counters.

PieceTimes::take now times any piece count above zero, and the executed
pass's recording takes it only for a rate-mapped pass (one of its
executions has a map), so a pass without a map still writes no
timestamps. Two timestamps a pass, where the device times pieces at all.

Test: rate_mapped_pieces' uncut execution now asserts its one piece timed
where PieceTimes::timed_on; verification follows on potluck.

Also: the pieces lane gains the wide frame without a map and each frame's host steps (e640147b9a),
and the pieces device test loads its fixture where the run's manifest lies, so it runs from a
carried archive (1c01beec35; it failed so on the 780M, m3-max-27994).

Why: on the Iris guest's rate-mapped sample (asp78-iris) about 93 ms a frame of the Offscreen
pass was untimed, because rate_map_piece_gpu_nanos timed only passes cut into two or more pieces;
the next Iris run splits the whole pass.

Verified at 1c01beec35: clippy plain exit 0 (m3-max-28152); lavapipe 6/6 rate_mapped device
tests, the uncut pass's one piece timed ("pieces 12 timed 13") (28151); release m2v_gpu archive
builds (28150). clippy under m2v_gpu and m2v_cpu_icd and rustdoc passed on the tip that carried
these same changes.
2026-11-13 21:47:07 -08:00
Anees Iqbal 1895fe40d6 RUNTIME 2259: a use's range stays 32 bytes: an image's place in its heap counts 64-byte granules
What: tracker::ImagePlace, which RUNTIME 2257 added to UseRange::Image so that
images placed apart in one heap (one tracker key) share no memory, held its
bytes as two u64s, growing UseRange from 24 to 40 bytes. It now holds two u32
counts of 64-byte granules (PLACE_GRANULE), rounded out (start down, end up),
so UseRange is 32 bytes; a place past what u32 granules count (256 GiB) is
WHOLE, the key's whole memory. Rounding out only adds bytes, so places whose
bytes meet still meet; two that share a granule alone are taken to meet, at
most a needless barrier or copy.

Why: every use of every command copies and compares a UseRange
(EncoderUses::note's map, command_uses_into, the kept uses). The XTX's
per-draw bench (walk_costs, exclusive, tip/before alternating, m3-max-27858)
put the no-barrier draw path about 1.2 us a draw (8-12%) above the build
before RUNTIME 2257, the barriers shape unchanged. This change narrows the
range back toward its old size. Whether it recovers the cost is the XTX
confirm's question; the commit claims only the size.

Verified: tests::tracker 76/76 including a_use_range_stays_32_bytes, clippy plain exit 0, lavapipe
heap_placed_reads, heap_placed_targets, attached_levels, color_groups and tracker 82/82
(m3-max-28099). On the XTX (m3-max-28098, exclusive, release walk_costs, tip/before/compact
twice and once under perf) the timings were bimodal in every build (frames at ~185 or 250-285 us),
wider than the 8% effect, so they settle nothing; the encoding thread's cycles:u profile puts the
tip's extra samples in RenderLowering::draw_rebound (51 against 18 before) and
State::shadows_to_carry (23 against <6), both copying and walking uses, and the compact build at
17 and 9: one perf run a build, evidence rather than proof.
2026-11-13 21:44:18 -08:00
Anees Iqbal 12fa641450 Tests: a surface plane over declared padding follows its placement answer where the driver refuses the pitch
What: tests::padding_unobserved's surface plane leg asks
Buffer::texture_placement_with_iosurface_plane before making each texture. A
declared plane is the DRM_FORMAT_MOD_LINEAR image at the pitch exactly where the
query answers NotHostPages; elsewhere it must be a shadow the device refused
(Shadow(Refused(_))), never one of the check's verdicts. Undeclared, a shadow as
before. The answer is printed.

Why: the leg skipped only devices that make no modifier images, so it assumed
every other driver takes a DRM_FORMAT_MOD_LINEAR plane with rows 416 bytes
apart. RADV refuses it: on the XTX and the 780M (pin 82 legs at 86ecc71b54) the
notice reads "the driver refuses a DRM_FORMAT_MOD_LINEAR image for the
runtime's own memory with rows 416 bytes apart
(ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT)", and its own linear image
lays the rows 512 apart, so the texture is a shadow, the device's honest
answer, and the leg failed (false, 0) against (true, 1).

Verified: XTX, 780M and lavapipe runs of the leg (jobs in the lane's report).
2026-11-13 21:29:42 -08:00
Anees Iqbal 9ebd6abe52 Tests: a texture that renders over padded Private rows is a shadow only where no check of renders passed
What: tests::merge_scratch's two_ways_merges_take_few_scratches runs on the
shadow policy's device (blit_holds::shadow_device), so its texture over a
Private buffer of padded rows is a shadow, the test's subject, on every device.
runtime_lane::in_place_textures' pooled_pitched_costs expects its undeclared
caches to be shadows exactly where Buffer::texture_placement answers Shadow,
and prints that count. Its edit (rendered_descriptor, the answer per cache)
went into 3677205866 with the rest of that file; the previous commit's
message wrongly says it is in this one. merge_scratch's module doc says the
padded Private target is in place where the check of renders passed.

Why: both still assumed such a texture is a shadow "on every device". Since
ed8b9a137b, linear_plan::holding's renders_kept puts it in place where the
device's policy takes images in place and its check of renders over its pooled
memory passed (Device::ordered_renders_kept, Between::Kept), as on the XTX: pin
82's legs (86ecc71b54) failed "the texture is a shadow" and "undeclared:
shadows" there alone; the 780M passed both.

Verified: XTX, 780M and lavapipe runs of both tests (jobs in the lane's
report).
2026-11-13 21:29:42 -08:00
Anees Iqbal 4df1dd5575 Tests: an attached read with no barrier follows the device's snapshot path
What: tests::pass_end_tiles' read over host pages expects a read through a
snapshot (WorkCounts::reading_draws_snapshotted) where
shadow_standing_device::reads_through_snapshots (now pub(super)) says the device
reads the texture so, else through the copy, as before. runtime_lane::
in_place_textures' attached-move test counts each pass's read through a copy
or a snapshot (exactly one) and checks the pages by the path counted: through
a copy every texel is the CPU's red; through a snapshot the fill's block holds
the fill's DRAWN_RED and the rest the CPU's. It is in the validation crate,
which sees the public counts alone. Only the pooled_pitched_costs edit
(rendered_descriptor) is the next commit's.

Why: on the XTX and the 780M (pin 82 legs at 86ecc71b54), a draw reading its
own attachment over a buffer's bytes takes the snapshot at any area
(render/snapshot.rs, over_bytes), so no copy moves (read_copies 0, and "0
reads through copies"). With no barrier, the snapshot reader reads what the
draws before it wrote: the accepted difference render/snapshot.rs states (an
AMD Radeon Pro 5300M and an Intel UHD Graphics 630 read so, probe ownread.m,
where an M3 Max reads the texels from before the pass), so the fill's block
was 128, not the paint ("the pages are not all red"). The tests took their
expectations from the copy path alone. Same class as 4d95375fe2.

Verified: XTX, 780M and lavapipe runs of both tests (jobs in the lane's
report).
2026-11-13 21:29:42 -08:00
Anees Iqbal 9ee2fd6bd2 Tests: separate depth and stencil's unstored pass clears to zero, so a clear is told from a released stencil
What: tests::unwritten_parts' separate depth and stencil leg gave both of its
passes the stencil clear value MARK (0xA5), the DontCare/DontCare pass too.
That pass now clears to 0 where its load is not Clear, and the leg runs on a
device of each UnstoredDontCarePolicy (Driver, then Cleared).

Why: with the clear value equal to the mark, the test could not tell a
released texture's stencil from Metal's clear. A device that clears an unstored
DontCare load (clear_reach::UnstoredLoads::Cleared: UnstoredDontCarePolicy::
Cleared, or DriverFact::UnstoredClearNoSlower, the Radeon 780M's) loads the
scratch image's stencil as its Clear to the attachment's clear value, Metal's
answer, which was MARK: every pixel passed the Equal test and the leg reported
"the released texture's mark" on the 780M (pin 82 legs at 86ecc71b54). No
released byte was read. Running both policies takes the Cleared form on every
device, lavapipe and the XTX included, where the default takes the zero start
(7b77851a95).

Verified: the Cleared leg with the old clear value fails on lavapipe and passes
with 0; lavapipe, XTX and 780M runs of the leg (jobs in the lane's report).
2026-11-13 21:29:42 -08:00
Anees Iqbal 7a691f6a52 SEMANTICS_VERSION 2107: a kernel's static threadgroup memory length is reported rounded up to 16 bytes, as Metal reports it
ComputePipelineState::static_threadgroup_memory_length answered the plain sum of a kernel's
static threadgroup variables (with typed threadgroup objects or the arena, no [[threadgroup(n)]]
regions). Metal rounds it up to a multiple of 16 bytes, its threadgroup memory's granularity:
`threadgroup uint a[256]; threadgroup uint b;` answers 1040 on the M3 Max (macOS 27.0.1), where
the runtime answered 1028 (reims's measurement; their compute-state test pins the difference).
The length a kernel with regions reports was already the 16-byte-aligned offset of the first
region. Only the reported answer changes: the planner counts the kernel's own bytes in each
dispatch's total as before.

Test: engine_simd_emulated::the_static_length_is_rounded_up_to_16_bytes_as_metal_reports_it (an
arena of 257 words answers 1040).

Verified (msi, m3-max-28025): the metal2vulkan suite passes; with the fix reverse-applied the new
test fails.
2026-11-13 21:05:39 -08:00
Anees Iqbal 804d8df68a RUNTIME 2258: a device's command-count shards are built on the heap, so a device is made on a 256 KiB stack
A program that made a device on a thread of 512 KiB of stack or less overflowed it on any driver
(reims's window render thread: "thread ... has overflowed its stack", confirmed on the Iris at
m3-max-27854; the SIGSEGV in assemble of x4route's second device). Line::new's
`counts: Arc::default()` built work_counts::Counters on the making thread's stack and moved it to
the heap: 172,928 bytes, 166,400 of them CommandTallies' inline arrays of 65 shards of 1,280 bytes.

Shards now hold a Box<[Shard<T>]> collected shard by shard, each written straight to the heap
(Counters 6,784 bytes); the shards' pointer lies on a 128-byte line of its own that nothing writes
once the device is made, so the one extra load a count takes stays a cache hit beside the shard's
own load and store. The adders' API is unchanged.

Test: tests::small_stack_device makes a device of its own options on a std::thread with a 256 KiB
stack, fills a buffer, reads it back and drops the device on that thread.

Verified: lavapipe m3-max-27859, the test passes with the fix and with the fix reverse-applied in
the same job overflows its stack (SIGABRT); device creation needs more than 1 MiB and at most 2 MiB
of stack before, more than 192 KiB and at most 256 KiB after (lavapipe debug, RUST_MIN_STACK
sweeps 27833, 27851); RTX 2080 on um790 m3-max-27937: small_stack_device, recorder_shards and
command_counts pass; clippy plain, gpucfg and cpuicd and rustdoc exit 0 (27875-27877); the plain
runtime suite 1538 passed (27876).
2026-11-13 20:25:04 -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 4d95375fe2 Tests: a layer pass's backdrop read moves no copy where the device reads it through a snapshot
a_layer_pass_reading_its_own_target_copies_in_its_read_alone_after_the_first took its counts
from lavapipe alone (m3-max-20039), where the read with no barrier reads the copy taken before
the pass and moves its 18x6 texels each frame. On a device that takes the snapshot path (the
XTX and the 780M: the snapshot draws' features, a fetch in the pixel interlock, and feedback loop
usage on the plane's shadow image), a read over a buffer's bytes takes the snapshot at any area
(render/snapshot.rs, over_bytes), so no copy moves and the test failed "moved 0 vs 108" on both
AMD GPUs (m3-max-27687, 27688, 27795).

The expectation now follows the runtime's own predicate for the device and the texture
(reads_through_snapshots: color_write_masks, through_storage, the image's feedback loop usage):
from the second command buffer on the read is counted through a snapshot exactly where the
predicate says so, and its copy moves 18x6 texels where it reads the copy, none where it takes
the snapshot. The line printed per frame names the device, the predicate and the count.

Verified: XTX (RADV NAVI31) m3-max-27883 passes, one snapshot read a frame and the copies in
skipped against the standing from frame 1; lavapipe m3-max-27900 passes, 108 texels a frame.
2026-11-13 20:13:22 -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 6ba577a89e RUNTIME 2253: the device recovery's announced cost states an indirect command buffer's records as docs/API.md does
RUNTIME 2247 (0ee5fb1b9b) moved an indirect command buffer's records into the runtime's own pages.
A recovery now keeps them, except on a device that imports no host pointer or where their import
failed. That commit rewrote docs/API.md's device-recovered entry to say so, but the kind's announced
cost in degradation.rs still said the records outside the runtime's own pages reset. The catalogue
test degradation_catalogue::a_runtime_kind_s_entry_states_the_cost_it_announces holds the entry to
the cost word for word. It has failed on development since then (msi plain runtime suite,
m3-max-27744): "they part at ... records o[utside the runtime's own pages] / [n a device that imports
no host pointer]"). The cost now uses the entry's words. Only the announced text changes; no
Degradation kind is added or removed.

Verified (syncfile, 55da7d6c9a): the parting text read from 27744's log. The runtime suite at the
landing tip follows on development.

RUNTIME_VERSION 2252 -> 2253.
2026-11-13 19:01:29 -08:00
Anees Iqbal 761bc21c29 RUNTIME 2252: overlapping YCbCr planes convert with the device's own conversion, a row at a time
YCbCrSampler::of took the device's sampler Y'CbCr conversion only for planes whose rows of codes do
not overlap: one buffer-image region per plane cannot state a pitch below the row
(VUID-VkBufferImageCopy-bufferRowLength-09101). RUNTIME 2251 made two-plane YCbCr textures over
rows of codes that overlap. On the RX 7900 XTX, where RADV converts G8_B8R8_2PLANE_420_UNORM
itself, the overlapping 66x64 texture went through Metal's fixed-point conversion. The same codes
laid apart went through the device's, so the lane's twin check failed (m3-max-27506: "read() is
the twin's, bit for bit"). Where the device has a native form, that is the only form (owner rule
1), so the layout must not choose Metal's arithmetic.

Such planes now copy into the conversion's image one region per row, each from its own first byte,
and convert on the device like any other. One region per plane remains where a plane's rows are at
least as long as its texels. Chroma rows that overlap (a 4:4:4 format over a 4:2:0 surface's rows)
took the same fallback before and now convert on the device too. The lane test asserts that the
device converts the overlapping texture and its twin alike, prints which form ran, and checks the
twin against the model or the device's bound.

Verified (planerows, 6c16371805 on 8e41d50f94):
- XTX (m3-max-27589, archive built on msi and carried): 6/6, LANE_XTX_EXIT=0. "YCBCR84202P 66x64
  over rows of 64 bytes: converted by the device true", within 0/2048 of Vulkan's conversion for
  the texture, the twin and the read after replace_region. The 10-bit shape is not converted by
  the device on RADV.
- lavapipe (27572): 8/8.
- clippy plain 0 (27592), m2v_gpu 0 (27590), m2v_cpu_icd 0 (27591); rustdoc 0 (27592).

RUNTIME_VERSION 2251 -> 2252.
2026-11-13 18:15:49 -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 8b09e7c51d RUNTIME 2250: a render-target barrier inside the pass keeps the encoder's kept draws
In the consumer's Launchpad walk on the RX 7900 XTX (lp75-xtx, pin 75), 293 of about 446 draws a
present took every step (about 21.6 us each against 7.6 us for a rebound draw), and RUNTIME 2240's
reader keeping never fired (reading_draws_snapshotted_again 0): a memoryBarrierWithScope
(RenderTargets, fragment -> fragment) came before nearly every snapshot reader (~80 a present
against 77 readers), and every barrier forgot every kept draw, the last one and those set aside.

The barrier changes no state the command buffer holds (pipeline, sets, push constants and dynamic
states survive vkCmdPipelineBarrier; a draw again records into the same command buffer). Now an
RT-only barrier recorded inside the current instance (render_target::between_draws), or one that
records nothing, keeps the kept draws, except those that read the pass's colours other than
through their own snapshots (through copies, at levels apart from the attached ones, or through
memory that shares an attachment: Kept::reads_colors, applied to the draws set aside and to the
last direct draw's kept draw), whose every step would change after it; where a use cannot be
told, the draw is let go. A barrier that splits the pass (its colours put apart there) and every
other scope still forget. New: WorkCounts::kept_draws_kept_across_barrier.

Also: runtime_lane::walk_costs, a release lane bench of the walk's draw mix (3 encoders a command
buffer, each [A, B, RT barrier, snapshot reader, A, B], indexed draws with their own scissors and
moved offsets over host pages, a fence wait and update), with and without barriers, and
walk_reader_forms over the owned fixture wlk_readers.metal (a reader whose texel decides a branch,
split and copied or fetched).

Verified (perdraw6, 2ebea446ac on 69c5ab1de6, msi lavapipe, debug):
- 149 touched runtime and lane tests at d407b50c87 (27245); kept_across_calls and draw_again 31/31
  at 2ebea446ac (27279), including the debug cross-check (every second draw takes every step and
  compares).
- Negative control (the reads_colors forget removed, 27279): the new
  a_barrier_inside_the_pass_lets_go_the_last_draw_s_kept_reader_of_its_colors fails (the debug
  check: a draw again changed its encoder's instance).
- tests::draw_again's in-pass barrier line now expects kept_across_barrier == 1 (its command,
  state-command and pixel equalities with every step unchanged). Clippy plain 0 (27250).
- Owed: the XTX walk_costs before/after, clippy m2v_gpu and m2v_cpu_icd, rustdoc.

RUNTIME_VERSION 2249 -> 2250.
2026-11-13 16:59:01 -08:00
Anees Iqbal 262d3df12b Build the region ranges from explicit Range literals (clippy single_range_in_vec_init)
8c89e236d0 (SEMANTICS 2100 / RUNTIME 2248) wrote `vec![0..scissors.len() as u32]` in render.rs
and `[0..15]` in render/fan_out/tests.rs, which clippy's single_range_in_vec_init rejects in every
configuration (carryrace's jobs 27210, 27213, 27214, exit 101). Both are now explicit
std::ops::Range literals; the values are unchanged. No behavior change.
2026-11-13 16:39:27 -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 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 71e088b900 RUNTIME 2245: an ICB setter's write under the lock reads the records' bytes under it
RUNTIME 2242 (20d04dbd5e) made an indirect command buffer's setter read the records' storage
pointer once, when its batch is made, and edit_locked wrote through that pointer after taking
the `pipelines` lock. A setter that waited on the lock while a device recovery carried the buffer
then wrote into the lost generation's memory, which the recovery had already released (records
lost, every command reset), and recorded its state in the carried table: the write was lost and
the table and record disagreed, or the process faulted. Before 2242 the edit read the bytes
under the lock.

Now edit_locked reads the records' bytes after it takes the lock. A test-only hook
(hold_next_set, under test with m2v_gpu or m2v_cpu_icd) holds a set after its batch is made.

Verified (carryrace, c7ea201189 on 522a8245e2, msi lavapipe llvmpipe):
- tests::icb_carry_race::a_locked_set_held_across_a_recovery_lands_on_the_recovered_records:
  a first dispatch (locked) held across recover_for_test lands on the recovered records
  (locked/unlocked writes moved by 1/0), answers its threads and runs once its state and
  buffers are set. ICB + recovery suites 26930 TESTS=0 (48 passed); wider with executions 26942
  ICB_SUITE=0 (55 passed).
- Negative control (26931, the batch's pointer put back): the new test dies with SIGSEGV
  (NEG_TESTS=100); the recovery's notice says the records were lost (every command reset).
- The unlocked setters' race with a recovery's release (use-after-free) is not fixed here; it
  follows.

RUNTIME_VERSION 2244 -> 2245.
2026-11-13 15:17:25 -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 5bf7ae2eae RUNTIME 2243: a committing command buffer counts as uncommitted until the scheduler holds its batches
The consumer's Iris walk at pin 73 (appwalk10 w-iris-26) failed one guest command buffer during
login with the runtime's own invariant "a batch's end recorded where the batch does not end"
(command_buffer/submit.rs), read as VK_ERROR_UNKNOWN (-13): the first tagged sighting of the -13
seen untagged three times on the 3090 and the 780M since pin 59.

Cause: a texture's face turn (texture/faces.rs turn_face) and a storage-form switch need the
device's Uncommitted count at 1 and the scheduler holding nothing. Both held for a command buffer
B in commit_now between slot.committed() and scheduler.commit(), where B's end is folded into its
last command buffer (face_swaps.any() false). Interleaving: B encodes an attached-read pass that
copies into the texture's other face G; B commits and folds its end; before B reaches the
scheduler, A opens a pass that turns the texture F -> G; at B's submission record_face_fixes finds
A's record and pushes a back copy G -> F after B's folded command buffer, so work.last() is not the
folded one and the command buffer fails. The same back copy would also have written stale texels
over B's rendering in F.

Now a committing command buffer stays in the Uncommitted count until scheduler.commit holds its
batches (Slot::handed; held.open still drops at committed(), so slot_wait is unchanged): no turn
or storage-form switch lands between the fold and the submission. Only turn_face and
storage_form_switch read the count, and both refuse rather than wait (Unturned::Busy and the
copy-in path; no switch), so nothing waits on it.

Verified (batchend, 42e70c6642 on 33de04117d), lavapipe on msi: new device tests holding B at a
new trace point Point::Committing while A's pass opens. Negative control (the tip without the fix,
26731): the folded test panics on the invariant (submit.rs:1145), the apart test finds B's pixels
clobbered (4096 bytes differ). Tip (26755): 6/6, finale folded 1 / apart 1 as built, Moved {swaps
0, busy 2, fixes 0}, B's pixels right at every step. Turns still happen: the existing
a_texture_s_faces_take_turns_for_its_attached_reads shows swaps 1 in each of its turn cases, the
same at base and tip. clippy --cfg m2v_cpu_icd (26758), --cfg m2v_gpu (26726), plain (26693) and
rustdoc (26725) 0. The command_buffer/submission/queue/storage_form/attached-read suites on
lavapipe (26759) and the XTX leg follow on development.

RUNTIME_VERSION 2242 -> 2243.
2026-11-13 14:26:06 -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 a308b1b409 RUNTIME 2241: kept draws survive fence updates and waits and resource and heap uses; the calls that let them go are counted
On the consumer's XTX Launchpad walk ~40 inline render encoders a present end keeping nothing
though none of their draws was counted unkept (keepdraws' read of lp72-xtx): every logged call
but a direct draw, a bind, a pipeline state set and a render state set forgets the encoder's kept
draws (render/replay.rs log -> forget_again), and the guest orders its heaps between encoders
with fences (updateFence after the last draw, useResource(s)/useHeap(s) before).

A kept draw, and those set aside, now survives:
- update_fence: it records nothing;
- wait_for_fence where the encoder used no shadowed texture (a wait over a shadowed texture marks
  it written, so later commands take its copy again: that wait still forgets);
- use_resource(s) / use_heap(s), but a memoryless use (which fails the command buffer): a use
  that changes the residency gives it a new generation, which Under holds, so the next draw takes
  every step; a repeat use changes nothing.
Every other logged call still forgets. New WorkCounts: kept_draws_kept_across_{fence,use},
kept_draws_let_go_{fence,use,barrier,store_action,visibility,other} (the kept draw a logged call
let go, by kind), encoders_last_draw_empty.

Verified (keepdraws, 77437d3277 on adaccf2367): lavapipe debug 64/64 over kept_across_calls,
draw_again, carried_draws, snapshot_reader, deferred_calls (26714); the new
tests::kept_across_calls 2/2 (draws after updateFence, waitForFence, a new useResource, the same
use twice, a new useHeap, the same heaps, updateFence, against the same calls plus a forgetting
call: pixels and commands equal; kept across fence 3 and use 5, drawn again 3, unlike_kept_under 2
for the two residency-changing uses; a barrier test let_go_barrier 1, encoders_last_draw_empty 1).
Negative control (26721: a draw again recording its Vulkan draw twice) fails the pixel test (48
vs 36 a channel). clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and runtime rustdoc 0 (26715).
An XTX run follows on development.

RUNTIME_VERSION 2240 -> 2241.
2026-11-13 14:22:58 -08:00
Anees Iqbal e3ee3d7f5e RUNTIME 2240: a draw that reads its own color through snapshots is kept: drawn again, rebound and carried
On the consumer's XTX Launchpad walk ~59% of render encoders end keeping nothing though they would
fit the next encoder (WorkCounts::encoders_none_kept_next_fits, RUNTIME 2229), and ~75 draws a
present read their own color attachment through a snapshot (render/snapshot.rs), a draw that kept
nothing and so took every step each time.

A direct draw that reads through snapshots (not in place), pins nothing, and otherwise meets every
plain-draw condition (records into its instance as it stood, a pipeline made ahead, one push, one
Vulkan draw, whole draw state, its only push hole SnapshotPhase, no write but its snapshots' uses)
now keeps a Kept with a reader part (slots, feedback colors, the phase hole, the pipeline's own
write masks, its layout). A draw again records exactly what the first did, the snapshot draw
(masks 0, phase 1) then the drawing draw (own masks, phase 0), with their barriers and query,
re-deriving only what changes with no call (the reader's ordinal, its learned coverage and the
area/coverage decision, peeked first; if it would no longer take the snapshot the draw takes every
step). A rebind re-derives the reader decision through side-effect-free cores of the functions
every step runs (in_place_wanted, snapshot_wanted, area/coverage, snapshot_holds, snapshot_apart),
binding::rebind_into rewrites a changed slot's SnapshotTexels source, and record_rebound records
the two recordings with their pairs. A carried reader's snapshot conditions are checked at its
rebind beside carried_stale (WorkCounts::draws_carry_stopped_snapshot), begin_carried passes its
feedback to inline_begin, and a carried draw retains its pipeline objects into its encoder.
Set-aside kept readers are exempt from a reader's forget of its colors' readers: their reads go
through their own pair, whose first barrier orders every earlier color write. In-place readers,
pinning readers and readers recording into a new instance stay unkept. New WorkCounts:
reading_draws_snapshotted_again, draws_rebind_stopped_snapshot, draws_carry_stopped_snapshot.
A lane bench (runtime_lane reader_costs) measures the CPU per draw of encoders ending in a reader.

Expected reach (keepdraws' read of the consumer's lp72-xtx counters): readers never sit in an
unsplit inline pass, so this reaches the ~22 fitting encoders a present that are not inline.

Verified (keepdraws): clippy plain / --cfg m2v_gpu / --cfg m2v_cpu_icd and rustdoc 0 at adaccf2367;
lavapipe 43/43 (no snapshot path there: pixels only); XTX and 780M debug at e4961c98ee 91/92, the
one miss (a carried draw's later draw again) fixed by 8e219f8bad. XTX/780M reruns at the tip,
negative control and the release bench are queued and follow on development.

RUNTIME_VERSION 2239 -> 2240.
2026-11-13 14:21:20 -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 ed9b745d20 RUNTIME 2238: an ICB's per-command pipeline states in a dense table, and one hold a pipeline set
An indirect command buffer's CPU setters cost ~290 ns a command in the runtime alone on lavapipe
(the consumer's icb_slots_cost at pin 72: 16384 render commands of 5 fields; a Mac does ~5 ns),
the largest frames CallHold's drop, the setters' edit, and a BTreeMap<u32, CommandState> insert per
command. Two cuts:
- The per-command state is a dense table: a u32 a command indexing a small table of distinct
  CommandStates, each counted by the commands that name it (set_states.rs); a set checks the last
  state it set, then a map. A recovery's carry walks the distinct states. An entry goes when its
  count reaches 0, so nothing is held past what the map held.
- A render or compute pipeline set took 4 CallHolds (the setter's, program(),
  can_encode_indirect_commands(), indirect_command_writes()), 8 mutex takes; it now takes one, and
  a set of a state the table already names reads no program at all.
Also: icb_encode_bench gains a full render slot (pipeline + 2 vertex + fragment + draw) and a
compute slot (pipeline + 2 kernel buffers + dispatch) a command.

Verified (icbset, msi lavapipe release, one A/B job m3-max-26475, binaries alternated, two passes,
host load ~20 so passes drift; median ns a command at 16384 commands): full render slot base
232.7/291.6 -> dense 215.7/253.9 -> + one hold 135.2/185.8 (-42%/-36%); compute slot 212.0/263.4 ->
196.8/217.6 -> 116.6/151.5 (-45%/-42%). ICB, released-program, write-route, recovery and kept tests
on lavapipe running (26484) at the branch tip. The batched setter (set_each) and the unlocked
action/pipeline setters follow after the ICB reset's dirty flags land.

RUNTIME_VERSION 2237 -> 2238.
2026-11-13 13:03:06 -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
Anees Iqbal 574d199d67 RUNTIME 2236: a managed synchronize decides its copy as it is encoded and records it in place
RUNTIME 2231 split the guest's encoder at each synchronize of a Managed buffer into its own
deferred segment (Deferred::SyncOut): every command buffer holding one paid an extra continuation
VkCommandBuffer and a segment VkCommandBuffer, its batch could no longer fold its end (an extra
VkSubmitInfo), and the copy was decided at submission. On the consumer's 2080 Geekbench walk that
showed as ~1 extra no-dispatch command buffer per synchronize.

Now the copy is decided at encode, from the kept writes of other command buffers plus this command
buffer's own writes before the synchronize, and recorded in place with only the written regions;
an unwritten synchronize records nothing. The copy is whole where an earlier segment is unknown,
the command buffer writes memory no use names, or the buffer was handed out. At submission,
settle_syncs_out adds a top-up command buffer just before the part holding the copy, covering only
writes from other command buffers noted after the encode, between two all-stage barriers
(WorkCounts::managed_synchronizes_topped_up, new). The SyncOut segment is gone (deferred.rs is
back to its 041038a914 form); may_fold folds again.

Verified (mansync, 4e3e22f4d6 on 8a81350e13; 2080 release, one run each, 26257), per command
buffer, 041038a914 / 8a81350e13 / fix:
- all (40 written): VkSubmitInfos 1/2/1, VkCBs 2/4.1/2, GPU 95.61/95.66/95.62 ms
- mixed (30 written, 10 CPU did_modify_range): VkSubmitInfos 2/3/2, VkCBs 3/5/3, copied
  176/132/132 MB, GPU 95.4/71.6/71.6 ms
- none (40 unwritten): VkCBs 1/3/1, GPU 95.05/0.014/0.007 ms
- small (import shape: 1 MiB fill + 2 unwritten 335,872 B no-copy synchronizes): VkCBs 2/4/2,
  commit-to-completion 0.519/0.111/0.116 ms (keeps ~4.5x)
vkQueueSubmit calls equal in every row; topped_up 0 in every fix row. Tests on the 2080 (26258):
managed_copy_device, detached_contents, kept_padding, device_memory_overflow 41/41, with two new
steps (a write committed before but encoded after the synchronize: topped up 1 and every byte read
back; a write committed after: nothing copied, the next synchronize copies exactly that range).
clippy plain 26228, --cfg m2v_gpu 26227, --cfg m2v_cpu_icd 26229 all 0; rustdoc 26230 = 0.

RUNTIME_VERSION 2235 -> 2236.
2026-11-13 12:24:45 -08:00
Anees Iqbal 7c96f44705 RUNTIME 2235: link a compute pipeline from its function, never read or keep its artifact
A compute or tile pipeline state's creation that found its function in the shader cache directory
also read, checked and decoded the pipeline's own artifact (68 KB on the 16,348-word ccb_conv_array
kernel: read, XXH64, scan, decode ~11 us plus its file read), and a creation that translated
encoded and wrote both. A compute pipeline is its one function relocated, with the layout and
interface its link derives from that function, so the link translates nothing and costs less
than the artifact (5.9 us on the same kernel).

Sources::kernel now takes the memo's live variant, else a binary archive's pipeline, else links it
from the compiled function (compile_compute_pipeline / compile_tile_pipeline), and keeps it in the
memo weighed by the new translator fn ComputePipeline::footprint. The directory keeps no compute
pipeline (EntryKind::ComputePipeline stays for binary archives). ShaderCache's compute pipeline
load/store, Looked::ComputePipeline and ShaderCacheStatistics' compute_pipeline_hits/misses
(always 0 now) are removed. The new public fn changes SOURCE_DIGEST, so cache directories start
fresh. RUNTIME_VERSION 2234 -> 2235: a run's pipelines now come from another path.

Also: compute_create_bench times "function decoded + pipeline linked" (test only).

Verified (warmskip, at 222d95ea69 on 18060aa638's base): clippy plain 26268, --cfg m2v_gpu 26269,
--cfg m2v_cpu_icd 26271 all 0; rustdoc -D warnings 26270 = 0; touched tests on lavapipe 26262
158/158 (runtime suite + validation lane cache, binary_archives, pipeline_records). Lavapipe A/B
release (msi 26316, legs B A B A, host busy so ~30% above quiet), creation medians before ->
after: CONV memo-1 settled 88.4/88.2 -> 74.0/72.4 us; CONV after a warm pass 194.8/177.8 ->
136.3/137.8 us; SMALL memo-1 32.4/32.0 -> 19.8/26.9 us; CONV warm same device 18.7/18.9 ->
18.8/19.4 (memo, unchanged). XTX before/after pending (26300).
2026-11-13 12:17:35 -08:00
Anees Iqbal 18060aa638 RUNTIME 2234: warm: a refusal for good is kept, and a later pass answers its record at once
A warm pass made every record's creation again at every boot, refusals
included: on the Iris Xe under ANV six Cycles kernels past the stage bound
its driver compiles intact (Unsupported{StageSize}) cost 1.4-2.4 s of
warm-thread work a boot, one record 1397 ms before its refusal. Nothing kept
the refusal: it is decided in the translation, after the shader cache's
lookup missed, and only translations are stored.

Now a warm creation's failure that is a fact of the record on this device
(a typed refusal, Error::Unsupported, or a translator outcome the translator
states permanent for its input; never a missing input, a deadline, a
cancellation, a failed host allocation, out of memory or a lost device) is
kept in the build's directory, named by the record's bytes and the driver's
identity (vendor, device, driver version, pipelineCacheUUID) under the
profile fingerprint and RUNTIME_VERSION (shader_cache/warm_refusals.rs). A
later pass looks the record up there before reading it and answers it as
failed of the same kind at once, counted in the new
WarmStatistics::records_failed_before and announced as before. The
program's own creation still translates and meets the refusal itself.

Tests: warm::a_refusal_for_good_answers_a_later_pass_at_once (a 256 KiB
private array every device refuses: a later device over the directory
answers it with no stage decoded and no lookup; an Invalid failure is made
again by each pass), pass::only_a_refusal_for_good_is_kept,
shader_cache::a_warm_refusal_is_found_by_its_own_driver_only,
warm_refusals' frame test.

Why: on the Iris (ANV, pin 71) every boot's warm pass retried 6 records refused StageSize /
DriverDefect, 1.4-2.4 s of warm-thread work a boot (one record 1397 ms). Verified (warmskip, msi,
lavapipe, at cedc049cf1 on 86d362e2aa): warm and shader_cache tests 73/73 (26206); negative control
with the lookup disabled fails, records_failed_before 0 (26215); clippy plain 26209, m2v_gpu 26224,
m2v_cpu_icd 26216, rustdoc -D warnings 26225, all 0.

RUNTIME_VERSION 2233 -> 2234 (the warm pass answers kept refusals).
2026-11-13 11:49:37 -08:00
Anees Iqbal a18db89220 RUNTIME 2233: spare command pools trimmed in rounds behind a re-record of the kept barriers (ANV heap growth)
On ANV (TrimmedCommandBufferFailsResubmission) the free thread frees a spare pool's command
buffers without trimming it, and Mesa's common command pool keeps every freed one for that pool's
later allocations; only a trim or the pool's destruction destroys it. Each pool kept as many
command buffers as it ever held at once, for the device's life, summed over every pool and
invisible to HELD: a guest's compute load on the Iris Xe grew the process heap to gigabytes under
vkAllocateCommandBuffers (consumer ledger: growth, then a panic, after Geekbench's Fluid pass).

- A pool counts the command buffers freed from it untrimmed, less those made from it since. Once
  the spares hold UNTRIMMED (4096), a trim round is due: as the scheduler next submits a batch,
  while its group holds no batch, State::trim_round marks every kept barrier command buffer to be
  recorded again before a batch takes it (KeptBarriers::invalidate; a begin clears what it names),
  then trims the spare pools holding the most until TRIMMED_AT_ONCE (1024) at least are destroyed.
  Where frees are trimmed at once, pools hold none untrimmed and nothing changes.
- A taker takes a spare holding command buffers before an empty one.
- Counted: WorkCounts::spare_command_pool_trim_rounds, spare_command_buffers_trimmed_in_rounds.
- spares.rs docs carry the measured effect, its walk figures scoped to their profiles.

Verified (perdraw5):
- Iris Xe (ANV) 25876, tests::spares_compute_in_flight, base -> with rounds: heap 410 -> 2936 MiB
  vs 416 -> 534 MiB; anonymous 434 -> 2965 vs 439 -> 743 MiB; shed 129,361 vs 71,086; 17 trim
  rounds destroying 64,714 command buffers. A negative control without the invalidate (e6e83e1e4b)
  lost the device at round 2.
- Iris 26157, the kept test: the round destroyed 1214 (pool (3, 1214) -> (3, 0)), 0 of 59 command
  buffers failed, 0 recoveries. Negative control 8db880af0a (no invalidate): the same round, then
  1 of 59 failed and 1 device recovery: FAIL.
- msi 26150 at 9315937cbc: pure spares and kept-barriers tests 25/25, clippy, --cfg m2v_gpu,
  rustdoc -D warnings, API signature/surface 15/15. msi 26162 at the rebased 2aef11f27d (on
  86d362e2aa): the same lint green, lavapipe debug spares/kept_barriers/scheduler_held_wakes/
  scheduler_wakes/unshared_hold 48/48.
- 780M walk: no churn (0 alloc/s, 0 frees, 0 trims).
Not shown: the fluid shape stayed flat on base and fix alike, so it doesn't reproduce the guest's
per-pass growth; the consumer's Iris Fluid pass is the proof.

RUNTIME_VERSION 2232 -> 2233.
2026-11-13 11:34:22 -08:00
Anees Iqbal c7d652ca5e RUNTIME 2232: the scheduler loses no wake for a batch held behind an unshared queue or a kept group
A guest's commitAndWaitUntilSubmitted could stay unanswered until the next commit (reims, XTX
RADV at pin 71, 2 of 77 runs under load: "A was never submitted"; the GPU idle; the scheduler
asleep with the batch held for 10 s; an empty commit on another queue released it at once).

Cause (reims's finding, /tmp/xqtest/m2v-finding.md): on a host whose one graphics VkQueue an
unshared queue also holds (RADV, ANV; WindowServer's queues are unshared), batch A behind H was
held by held_for_unshared() while H was in the Flight. QueueSlot::completed publishes `completed`
(fetch_max) before waits.completed takes H out of the Flight. When H completed between those two
steps, the hold read a stale Flight and gated on completed + 1, which nothing meets.

Fix:
- Unshared hold: QueueWaits::hold_ahead reads the published completed value under the waits lock;
  Flight::ahead(ran, completed) counts batches at or below it as gone; Room::Hold { after, through }
  carries the oldest still in flight; await_unshared_room gates on `through`, fences, and reads
  again (completed >= through wakes it at once). No reorder of QueueSlot::completed.
- Kept group (submit_ready, Group::keeps read before gate_on): sets the gate, fences, then reads
  again (Group::pending_through), the protocol gate_heads and check_heads use.
- A WAIT_SLICE that ends with a batch held makes a pass, as the module docs promise, counted in
  WorkCounts::scheduler_slice_rescues (0 wherever every wake comes). api_signatures and host_ab
  updated.

Verified (perdraw5, msi 26135, lavapipe, at 3bd14c83ac on a2ac4433ca): clippy all features and
--cfg m2v_gpu, rustdoc -D warnings, api_signatures/api_surface green; 36/36 of scheduler_held_wakes,
scheduler_wakes, completion_wakes, scheduler, unshared_hold. tests::scheduler_held_wakes forces
each interleaving with test-only hold points (completion::trace, cfg(test) + device cfgs; `Leave`
sits between QueueSlot::completed's fetch_max and waits.completed):
- unshared: H held at Leave while the next is committed; it goes with 0 slice rescues.
- kept group: both completions published between keeps and the gate; it goes in that pass, 0.
- lost wake: completion wakes dropped; the held group goes at the next slice (1 rescue, 99 ms).
Negative controls each fail only their own test: old gate (unshared held until the slice at
101 ms, and with development's code until the next commit, reims's symptom); kept recheck
removed (102.9 ms, 1 rescue); a slice making no pass (never completed within 5 s).

RUNTIME_VERSION 2231 -> 2232.
2026-11-13 11:22:48 -08:00
Anees Iqbal 523d32a10a A failed submission's and a failed recording's warning end in their id name
reims's sink writes a runtime message's text alone, without its id, so a metal2vulkan-submit-failed
or metal2vulkan-recording-failed line could not be found by id in qemu.log. submit_failure::warn
now appends " [<id name>]" to the text, as degrade notices end in theirs, for both warnings.
The device test asserts the submit-failed line ends in " [metal2vulkan-submit-failed]".
docs/API.md says so. Log text only: no version bump.

Verified: expected, by the check job dispatched at this commit (clippy plain and m2v_cpu_icd on the
runtime, the submit_failure unit tests, the lavapipe device test).
2026-11-13 11:19:29 -08:00
Anees Iqbal 34e3407522 RUNTIME: a failed submission's resource summary reads apart from its list
The lavapipe line read "0 keys of the runtime's own: buffer #1 ...", as if the stated
resources were the runtime's own. The summary now ends "and N keys of the runtime's own not
stated", and the stated resources follow after "; stated: ". The unit test's expected text
follows; run in the next Linux job.
2026-11-13 11:16:16 -08:00
Anees Iqbal 19ead6a74a docs: the failed-submission and failed-recording warnings
API.md's diagnostics paragraph and CommandBufferError::Internal's doc name the two Warning lines
a device's sink now hears (metal2vulkan-submit-failed, metal2vulkan-recording-failed): which
submissions log one, what the line names, its bounds, and that a successful submission does none
of it. Checked against submit_failure.rs's constants and texts; rustdoc runs in the Linux job.
2026-11-13 11:16:16 -08:00
Anees Iqbal 234ea4de4e RUNTIME: a failed submission's line names memory flags itself
ash is built without its debug feature here, so vk::MemoryPropertyFlags has no
Debug: the line names each flag (and any bit without a name by its value).
Verified by the build job that failed on it (m3-max-26103) and the new unit
test memory_flags_are_named_and_an_unnamed_bit_is_given_by_its_value.
2026-11-13 11:16:16 -08:00
Anees Iqbal cc9b00f0c8 RUNTIME: a failed vkQueueSubmit logs one bounded line naming what it held
Twice on an RTX 3090 a command buffer failed with VkResult -13 and nothing said
what its submission held. Every vkQueueSubmit of the runtime's that fails now
logs one warning (id name metal2vulkan-submit-failed) through the device's sink,
else on stderr: the VkResult, the VkQueue and what submitted; each VkSubmitInfo's
waits, VkCommandBuffers and signals, each semaphore by its role with its value
and the timeline's value read after the failure (flagged where a signal is not
above it, VUID-VkSubmitInfo-pSignalSemaphores-03242, or a value lies past the
least maxTimelineSemaphoreValueDifference, -03243/-03244); each VkCommandBuffer
by its role (an encoder's, barriers, kept barriers submitted again, first work,
end); the Metal command buffers by id and label; and the resources their
encoders name, as what owns their memory, with size, storage mode, memory type
and flags, no-copy import kind and whether it is released now, detached or
gone, and age in the device's submissions since it was made. Bounded: 8 infos,
8 waits and 8 signals each, 32 VkCommandBuffers, 8 command buffers, 32
resources, each list counting the rest.

Nothing is read on the success path: the line is built only in each call's
error branch, and it reads under its submitter's locks without waiting for any
lock another thread may hold (try_lock), but the two resource registries a
batch's submission already locks.

A recording that fails also fails its command buffer with a raw VkResult
(VK_ERROR_UNKNOWN for the runtime's own error, which the command buffer's
error drops): recording_error now logs that error (id name
metal2vulkan-recording-failed), so a raw -13 says which of the two it was.

Tests: tests/submit_failure.rs (an info's lists read back from its chain; the
line's words, flags and bounds), tests/submit_failure_device.rs (a blit's batch
failed by the test hook as VK_ERROR_UNKNOWN: one warning naming the result, the
label, the encoder, the queue's timeline and the buffer with its age).
2026-11-13 11:16:16 -08:00
Anees Iqbal 2434f48cc2 kept_shadowed_draws: expect in-place reads where the device reads in place, a queue per frame
The test failed on both the RX 7900 XTX and lavapipe, with or without the narrow forget.

On the XTX it failed at "the reads through copies" (4, not 8). Its four draws of the second
target's texels read a color their draws write nothing of, at their own pixels. A device that
enabled attachmentFeedbackLoopLayout and fetches no color through input attachments reads that
color in place (render/snapshot.rs's in place), with no copy, and such a draw keeps nothing. The
test expected the copy on every device. The expectation now follows the device's read path,
decided from the device itself (the feature it enabled and framebuffer_fetch::through_inputs of
its profile), not its name:
- In place: 4 reads through copies and 4 in place (WorkCounts::reading_draws_in_place, now
  counted with the copies). 4 draws unkept_shadowed in each frame. In the kept frame, 2 draws
  again (1 with debug assertions), 1 rebound (0), and 1 stopped.
- Through copies: as before.

On lavapipe it failed at "the apart frame's keeps": 1 draw rebound, not 0. Both frames ran on one
queue. The first frame's last draw, kept, was carried along the queue into the second frame's
render encoder (render/carried.rs), and the second frame's first draw rebound it. Each frame now
runs on a queue of its own.

The pixel checks are unchanged.
2026-11-13 11:10:43 -08:00
Anees Iqbal d38b5c4ef6 RUNTIME 2231: a managed synchronize copies out only the bytes the GPU wrote
On a device without unified memory, synchronizeResource: copied the whole Managed buffer (or a
texture's whole span over one) to its host copy every time. The runtime now keeps the GPU's
writes for each buffer that has been synchronized once (managed_sync.rs: GpuWrites, SyncCopy,
SyncOut), stamped in the scheduler's submission order across all queues. The copy-out is its own
segment (Deferred::SyncOut), decided when its batch is submitted, so it covers the writes of
earlier batches, of earlier encoders in its batch and of its own encoder, including a write
encoded after the synchronize but committed before it. Completion of the command buffer holding
the copy drops only the writes noted before the copy. It copies nothing when the GPU wrote
nothing since the last copy, and still copies the whole buffer where the writes cannot be known:
an untracked buffer; one whose VkBuffer was handed out or whose memory is exported; a buffer's
first synchronize; any batch since the last copy, not yet complete, that may write memory no use
names (State::writes_unnamed); and a synchronize recorded in place (a predicated loop's laying, or
no VkCommandBuffer could be made). Every barrier is still recorded. Pages no import maps copy back
only the regions copied. Textures over buffers take the same path (an image range counts as the
whole buffer). Touches command_buffer/submit.rs (record_syncs_out after record_scrubs) and
command_buffer/mod.rs (the footprint loop skips SyncOut segments), encoder.rs, tracker.rs,
deferred.rs, device/mod.rs. New WorkCounts: managed_synchronizes_unwritten,
managed_synchronizes_whole, managed_bytes_unwritten_skipped. FAST-PATHS managed bullet, API.md
managed section and the runtime README updated. No speed-for-accuracy choice.

Why: on the RTX 2080 the guest's Background Blur spent 0.90 s of GPU time copying out 3.5 GB
over 800 synchronizes (~176 MB a command buffer, the 2080's x4 link), whole resources each time.

Verified (mansync; step codes read inside the jobs):
- clippy --all-targets --all-features -D warnings, workspace: plain 25924, m2v_cpu_icd 25927,
  m2v_gpu 25928, all 0; rustdoc -D warnings 25935 = 0 (at b72228629c).
- RTX 2080 (um790) at ac0887e7f5, 25942: 41/41 (managed_copy_device, detached_contents,
  kept_padding, device_memory_overflow; hazard tests excluded). Counts (copied, skipped,
  unwritten, whole), both Import and Pages: first synchronize (1048576, 0, 0, 1); after no write
  (0, 1048576, 1, 0); after a fill in an earlier command buffer (16382, 1032194, 0, 0). Every
  byte checked after each step, including a write committed before the synchronize's command
  buffer but encoded after it, and a CPU write named by didModifyRange.
- Negative control (throwaway e1542d94c4, 26010): imports copy whole and pages drop kept writes;
  both legs fail.
- Release, 2080, examples/managed_sync_out (40 no-copy Managed buffers of 4,399,104 B, 176 MB
  synchronized a command buffer), median GPU ms over 20, base 010888b011 vs tip (25985):
  40/40 written 95.62 -> 95.58; 4/40 written 95.10 -> 9.57; 0/40 written 95.05 -> 0.014.
Not measured: Background Blur itself (the counters say how much of its 0.90 s goes); lavapipe
(unified memory, the copy-out legs return early).

RUNTIME_VERSION 2230 -> 2231.
2026-11-13 10:34:23 -08:00