Commit Graph
1152 Commits
Author SHA1 Message Date
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 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 3976ecbeff blend16 lanes: an interlocked draw's notes come from the profile's MetalHalfStorageWrites
The blend16 lanes asserted that a draw through the pixel interlock
announces none of their notes. A float output's blend is converted to
half by the storage image's store: Metal's conversion (toward zero) where
the profile takes DriverDeviation::MetalHalfStorageWrites, else the
device's own, which the translator records as
PrecisionNote::DeviceColorConversion (lower/fragment/fetch.rs). The
RTX 2080 is not among that deviation's measured rows (the 3090 and the
5080 Laptop GPU are), so its float cases announced device-color-
conversion and four tests failed, though their texels were Metal's
(4096/4096).

interlocked_notes names what an interlocked draw announces from the
profile's own predicate: device-color-conversion for a float output
where the profile does not take the deviation, nothing else. The
assertion is now equality with that list, in blend16.rs and narrow.rs
(zero.rs and nans.rs share blend16's sweep).

Seen in pin 84's 2080 legs. Verification follows.
2026-11-13 23:38:36 -08:00
Anees Iqbal 6e8a946749 Lane: tests whose work makes a second command queue take one queue or the plan
On the RTX 2080 (NVIDIA, 16 graphics queues: a plan of 14 round-robin
VkQueues) four lane tests failed on metal2vulkan-queue-limits-reached,
which fails a run by design (runtime_case's Messages::sink): under the
lane's limits (one round-robin VkQueue) the program's second command
queue shared VkQueue 0 where the plan gives it one of its own. RADV's
one graphics queue leaves the plan as the limits do, so the XTX and the
780M said nothing.

- generic_pointers and sampler_tables made a queue per dispatch: each
  test now makes one queue per device and dispatches through it.
- depth_executions' frame commits on two queues on purpose: both tests
  that draw it make their device with the plan (at_plan).
- rate_mapped_passes' counted_draw makes a queue per draw: the two tests
  that call it more than once take fresh_with(at_plan), as the file's
  other multi-queue tests do.

Seen in pin 84's 2080 legs (archive e30c91de8a): generic_pointers_answer
_as_metal, a_frame_s_executions_at_a_fixed_stride_run_on_the_gpu,
a_sampler_table_read_at_a_dynamic_index_samples_as_metal and
a_viewport_over_part_of_the_screen_draws_only_the_regions_it_reaches.
Verification (build, the 2080 and lavapipe runs) follows.
2026-11-13 23:38:36 -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 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 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 da739e4aa5 The runtime-pin input test lists spirv/ir/intern.rs as not a runtime input
The test the_runtime_sources_are_the_committed_ones failed on development
(full validation suite, m3-max-27765 at d72dc03519): the runtime inputs
reach metal2vulkan/src/spirv/ir/intern.rs through bind/state.rs, which has
used its FxHasher since RUNTIME 2226 (54752dd4f7) to key kept bind shapes
and samplers, and the file is neither hashed nor listed.

The hash only narrows which kept shapes a draw compares field by field;
that comparison decides, so another hasher changes no run's answers. The
file goes on the not-runtime list with that reason instead of into the
pin's hash, which would re-pin on every translator interning change.

Test infrastructure only: no version bump.

Verified: the_runtime_sources_are_the_committed_ones on msi (m3-max-27822).
2026-11-13 19:28:32 -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 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 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 69c5ab1de6 Expect no shared-memory notice in the fill-mode tests that make no buffer
points_need_fill_mode_non_solid expected "not announced: [SharedInSystemMemory]"; on a discrete
device that notice comes only from a Shared buffer, and the test (like the two MoltenVK refusal
branches) makes only Shared textures, so on the RX 7900 XTX it failed on the expectation alone
(m3-max-26943, 4/5). The three now expect no notice. Test only.

Verified (fillpoints, d4db20618e): XTX (RADV NAVI31, 27021 build, 27032 run) 5/5, XTX_RUN=0:
Points light Metal's 3 vertex pixels, culled front none, back the same 3, fill 45 px, lines 27,
triangle-point-size announced once; fill-lines pixels unchanged.
2026-11-13 15:54:34 -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 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 33de04117d runtime_lane: an indirect dispatch's split is expected where the runtime splits it
Two runtime_lane indirect_dispatches tests (an_indirect_dispatch_reads_the_arguments_the_work_before_it_wrote,
an_unaligned_offset_reads_at_the_multiple_below) expected a SplitDispatch notice on every device. A
10x3 grid in 4x2 threadgroups runs on the kernel's partial-threadgroups variant where the device
compiles it (compute.rs partial_direct), as Metal runs the dispatch its arguments state with partial
threadgroups, so nothing splits; on the RTX 5080 both failed on the notice alone, their outputs
matching the direct dispatch's, at 045c6fedf9 (26552) as at e93b3f192e (26537).

ragged_splits(device) compiles the fixture's kernel through the public compile layer under
VariantKey::partial_threadgroups (the variant settle_partial asks for) and answers "split" where
that compile is refused, which is what makes the runtime keep the split; the kernel uses no
simdgroup function and binds plain buffers, so that key is the runtime's. The two tests expect
SplitDispatch where it holds; an_indirect_dispatch_runs_as_the_direct_dispatch_of_its_arguments
expects it where ragged_splits holds or maxComputeWorkGroupCount[1] < 65536, so its 65536-group case
still checks the split notice on the 5080 (limit 65535).

Verified (radvcompile, 1eb49b23b6 on e93b3f192e): clippy -p metal2vulkan-validation --all-targets
--all-features --cfg m2v_gpu = 0 and the gpucfg test build = 0 (26569); RTX 5080 runtime_lane::
indirect_dispatches 10/10 (26585). The predicate's "split" side has not run on a device yet (CI's
lavapipe device job runs it). Test only; no version bump.
2026-11-13 13:34:21 -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 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 791035345b SEMANTICS 2093 / RUNTIME 2227: a rate-mapped draw draws only its blocks that hold a flagged triangle region by region
For each flagged triangle, the fan-out probe's geometry stage also sets the bit of its block of
BLOCK_TRIANGLES (64) in a sixth set of 32 words (PROBE_BLOCKS 1024, PROBE_SETS 6; the last block
also takes every triangle past 65,536). A flagged draw in parts is drawn as its runs of flagged
blocks region by region: the first run cut to the first flagged triangle, the last to the last,
everything before, between and after the runs fanned out. Runs less than RUN_GAP (170 =
REGION_DRAW_WORK/3) apart are joined; a draw has at most MOST_RUNS (4) runs, the nearest joined
first. WorkCounts::rate_map_region_runs counts them. Exact is unchanged. FAST-PATHS row 50 edited
in place; api_surface gains BLOCK_TRIANGLES and PROBE_BLOCKS.

Why: on the pieces lane's wide frame, 23 flagged draws with 36 flagged triangles drew 106,519
triangles region by region (whole spans from first to last flagged triangle). Now 8983 in 35 runs,
and the frame splits into 2 pieces instead of 8.

Verified (ratemap, release, command-buffer GPU time on the wide frame, base aea1543936 vs the
change, order base/after/after/base on um790, jobs 25793 and 25796):
  780M (Mesa 26.2.6) warm 115.0/90.5 -> 61.2/57.7 ms (Exact 257.0); cold 178.2/176.4 -> 80.4/86.9
  RTX 2080 (620.70.06) warm 28.7/27.9 -> 16.6/18.7 ms (Exact 60.1); cold 59.1/56.1 -> 44.2/48.9
Pixels equal Exact's on lavapipe (25771, 3/3, incl. a second wide triangle far from the first;
asserts 6 flagged triangles, 52 triangles in 6 runs). Clippy workspace all targets/features clean
(25770); touched translator tests 297/297, runtime 16/16; unit tests for cuts, joins, the tail
block, a draw with no bits, and a 3000-draw property check. Not built: this rebased tip (clean
rebase; generators unchanged).

Tiles (B, steelbrain/ratemap-tiles c3d51ef25c) not landed: 2080 27.3 -> 23.8 ms but 780M
91.7 -> 568.2 ms (14.4M geometry invocations a frame at ~33 ns on RADV).

SEMANTICS 2092 -> 2093 (the linked fan-out geometry stage changes); RUNTIME 2226 -> 2227.
2026-11-13 09:20:43 -08:00
Anees Iqbal c50b66ab6e NVIDIA computes half on its 16-bit instructions under the float controls
DriverWorkaround::HalfConversionPairFolded (every NVIDIA_PROPRIETARY GPU)
made narrow::controlled_modes return None, so NVIDIA's profiles lost the
16-bit float controls altogether: quantize_form was Converted and
f16_arithmetic None, a half + - * was computed in f32 and "rounded" by an
FConvert pair the driver folds away, spirv::half_hold never ran, and a
half / and sqrt were f32. The workaround is the pair's alone: NVIDIA's
compiler folds an OpFConvert 32->16 and its widening back into the 32-bit
value; it reports RTE, DenormPreserve and SignedZeroInfNanPreserve for
Float16 (independence ALL), under which its 16-bit instructions and a
single conversion are Metal's by the Vulkan spec (owner rule 1: the
device's native form is the only form).

- narrow::half_controls(p): shaderFloat16 and every mode of
  controlled_modes, which no longer reads the workaround.
- narrow::quantize_form: Controlled (the decorated pair under the
  controls) only where the driver keeps the pair; NVIDIA stays Converted,
  so an f32 result rounded to half through a round trip is still the
  device's conversion, recorded NativeHalfConversion.
- What keyed on Controlled but is no round trip now keys on the controls
  (ArithPlan::controls, ModuleBuilder::half_controls): a half + - *
  (f16_arithmetic), / (divide::native), sqrt (math::float_fn), the half
  fma route (fma::half_route), spirv::half_hold, and in compile.rs the
  declaration of the modes and the widening/narrowing note. The modes are
  declared for a pair only where the pair is Controlled.
- Unchanged: blend's half_of, round, round_texel and the bit conversions
  follow the rounding form.

Docs: narrow.rs, half_hold.rs, divide/math/fma, the workaround's doc,
PrecisionNote::NativeHalfConversion, docs/API.md's
native-half-conversion entry and docs/HOWTO.md say NVIDIA computes under
the controls and keeps the native conversion for the round trip only.

Tests:
- tests::engine_native_half::nvidia_computes_half_on_16_bit_floats_under_the_float_controls:
  nvidia-rtx50-linux, nvidia-rtx5080-laptop and the 5080 laptop's
  description with an RTX 2080's (0x1E87) and an RTX 3090's (0x2204)
  device ID emit 16-bit OpFAdd/OpFMul for a half sum, product and chain,
  declare the three 16-bit modes, require their properties, record no
  NativeHalfConversion, pass L3, and round each operation on the
  interpreter; a half narrowed and widened alone stays the noted round
  trip. Negative control: the 2080 description without
  shaderRoundingModeRTEFloat16, and Pascal (no shaderFloat16), emit no
  16-bit instruction or mode and record the note.
- Existing tests that pinned NVIDIA's widening note or keyed on
  Controlled for the controls follow the split.
- runtime_lane::native_maths::half_arithmetic_under_the_float_controls_answers_metals
  (device): a half sum, difference, product and product plus a third
  operand over 4096 threads equal Metal's per-operation half answers
  exactly where the module declares the controls; it prints how many
  words the f32 computation (the folded pairs' answer) differs at.
  half_rounding_answers_within_its_recorded_bound now expects the sum
  Metal's and the round trip noted on a driver that folds it.
2026-11-13 09:14:25 -08:00
Anees Iqbal 758ed9348b The fan-out probe counts each draw's flagged triangles
A flagged draw drawn in parts draws its triangles from the first the
probe flagged to the last region by region
(rate_map_parted_region_triangles), but nothing said how many of those
are flagged themselves: the probe kept only the first and the last.
That density decides whether drawing blocks of flagged triangles apart
would cut the region-by-region triangles.

The probe's geometry stage now adds one, for a flagged triangle, into
the word its PrimitiveId picks of a fifth set of PROBE_COUNT_WORDS after
the flag (PROBE_SETS = 5, PROBE_DRAW_WORDS = 1 + PROBE_SETS *
PROBE_COUNT_WORDS, the only place the word count is stated). The
runtime sums that set (Probed::flagged_triangles) and counts it at the
probe: WorkCounts::rate_map_flagged_triangles. The pieces lane prints
it beside the parted draws' region-by-region triangles and checks it
is non-zero exactly where draws were flagged, and no more than those
triangles.

Tests: the probe's link test counts two atomic adds (the copies', the
flagged count's); the probe words' unit test sums the fifth set; the
fan-out device test checks its four flagged triangles.

The probe's GPU time, verified on lavapipe (LP_NUM_THREADS=1, as CI)
by the fan-out device test (rate_mapped_fan_out::a_host_step_fans_out_
the_commands_the_probe_does_not_flag, one probe of 8 draws, 4 flagged),
release runtime binaries under --cfg m2v_cpu_icd at 44eda17f1d (before)
and this change on that base (after, 44665e1bce), taking turns on msi,
rate_map_probe_gpu_nanos:
before 20.63, 3.44, 2.43 ms; after 16.36, 2.60, 1.79 ms (the first
round of each cold). No growth past the noise: each round's after is
below its before.

Also, from the landed device-local replay scratch (RUNTIME 2220): its
resident root table now lies at a multiple of 32 bytes, which fixes the
internal refusal (RootTable::resident_fields, a moved resident set)
that the old scratch could meet where the upload alignment is 16
(RADV, lavapipe), read from the code, not observed; the compute replay's
scratch (gpu_execute.rs) is upload_aligned to 32 with its table at
slots * SLOT_TABLE_BYTES + PARAMS_BYTES, a multiple of 32, so it has
none.
2026-11-13 08:01:34 -08:00
Anees Iqbal dad0470c2e A flagged fan-out draw is drawn in parts: only its flagged range region by region
Under DevicePolicy's RateMapRegionPolicy::FanOut the probe flags a draw that has a triangle
crossing w = 0 or reaching more regions than the geometry stage's copies. The whole draw was then
recorded region by region, once per region of the map (2074 for a 61 by 34 map), however few of
its triangles were flagged.

The probe now also records each flagged draw's first and last flagged triangle. A flagged list of
triangles of one instance, whose pipeline reads no [[primitive_id]] and writes no memory (the
conditions under which a draw is already cut into index ranges), is drawn in up to three parts in
its place: the triangles before the first flagged one fanned out, those from it to the last
region by region, and those after fanned out. Each part is a range of the draw's vertices or
indices, so each triangle keeps its vertices, vertex_id and order. Parts of a 16-bit index list
begin at even triangles, so their ranges start 4-byte aligned as the draw does. Any other flagged
draw is drawn region by region whole, as before.

The probe words grow from 1 + 2*32 to 1 + 4*32 per draw (bind::fan_out::PROBE_DRAW_WORDS). For a
flagged triangle the probe raises one of 32 words to u32::MAX - PrimitiveId and one to
PrimitiveId + 1, picked by PrimitiveId as the counts are, so no single word takes every atomic.
The wide marks that choose the variant of four copies now come only from triangles the probe does
not flag, so the fanned-out parts can take that variant.

Also: WorkCounts::rate_map_probe_wait_nanos sums the host's wall time from each probe's
submission until it saw it complete, so a walk can split host_step_nanos into the probe's round
trip and the host's own recording. rate_map_parted_draws and rate_map_parted_region_triangles
count the draws in parts and their triangles drawn region by region.

An earlier attempt drew a flagged draw through a geometry stage of 32 invocations, each taking a
block of up to 16 regions, in 5 passes over the map. On the pieces lane's frame with wide
triangles it made no GPU gain on an RTX 2080 (41.0 against 42.9 ms warm). On a Radeon 780M (RADV)
it went from 182 to 1900 ms, with one piece of 1.1 s. That attempt is not in this change.

Tests: render::fan_out's unit tests check that the parts take each triangle once, in order, with
no flagged triangle in a fanned-out part, and that the probe's words decode to the first and last
flagged triangle. The link test checks the probe's two atomic raises. The runtime's
rate_mapped_fan_out test adds two commands that draw the grid with one triangle over half the
target, one indexed and one without indices, and a triangle across w = 0 over the whole target.
Under FanOut all four flagged draws are drawn in parts and the frame is compared pixel for pixel
with the encoder's region-by-region frame. The pieces lane's wide frame checks that every flagged
draw is drawn in parts.
2026-11-13 02:43:42 -08:00
Anees Iqbal 0eb9f73862 The pieces lane draws a frame with wide triangles among the grid's, fanned out and region by region
One triangle of every 8192 of the lane's grid becomes one 48 quads a side, about 1061 by 504
pixels over the 3648 by 1734 screen, which touches more regions than the fan-out's copies. The
probe flags every command whose indices reach one, about a third of the 64, as a guest's
rate-mapped frame on an RTX 3090 and a Radeon 780M had about a quarter of its probed draws
flagged (rate_map_flagged_draws 698.8/s against rate_map_fanned_draws 1972.9/s; 280.4/s against
788.7/s). rate_mapped_pieces_host_step_wide fans the frame out and rate_mapped_pieces_host_step_wide_exact
draws it region by region; the fanned-out frame asserts that the probe flagged a draw, and the
small frames that it flagged none.

Measurement only (ignored, run by name); no product change.
2026-11-13 02:43:41 -08:00
Anees Iqbal d50b8de95b The every-extension device lists VK_EXT_shader_float8; the opened chains re-blessed
ash_interop::tests::every_feature_has_a_source reads every VkFeature from a fake device that
lists every extension; it lacked VK_EXT_shader_float8, so ShaderFloat8 had no source (24812). The
RTX 50 profiles' 8 opened validation contexts now chain VkPhysicalDeviceShaderFloat8FeaturesEXT
(one member more each), blessed by bless_opened_chains on msi (24812).
2026-11-13 01:11:23 -08:00
Anees Iqbal 42a13d17a9 The validation context's extension structures count shaderFloat8's
Verified by the lint A job that follows (24785 failed on the stale length 44).
2026-11-13 01:11:23 -08:00
Anees Iqbal 10f2539a71 8-bit floats widen through the device's own type where it has one
Owner rule 1: where a device has a native 8-bit float type, its conversion is the only form.
VK_EXT_shader_float8's shaderFloat8 (the SPIR-V capability Float8EXT, SPV_EXT_float8) is now a
VkFeature the device enables and the profile reads (leaf.float8); the SPIR-V IR has
Type::Float8 { encoding } (OpTypeFloat 8 with its FPEncoding, from the regenerated grammar items),
and the interpreter reads OCP's E4M3 and E5M2.

The shared decode, narrow::fp8_to_f32, widens through the device's type where the layout names
one (Fp8Layout::on): each u32 lane bitcast to four 8-bit floats, the low byte's widened by
OpFConvert, so no 8-bit integer type is needed. f8e4m3fn and a tensor's e4m3 take Float8E4M3EXT,
f8e5m2 and a tensor's e5m2 Float8E5M2EXT; the IEEE-like f8e4m3 has no device encoding and keeps
the integer decode. Every site takes it: air.convert's 8-bit float sources, simdgroup-matrix fp8
cells, and matmul2d, whose expansion now widens each element by an air.convert of the tensor's
format (Fp8::TensorE4M3, Fp8::TensorE5M2: Metal's reading, qualified on the M3 Max, e4m3 with no
specials, e5m2's NaNs 0x7FC00000; never parsed from a name, built by Out::air_call). A device
without shaderFloat8 decodes with integers, as before.

Where a tensor's element widens natively the stage records PrecisionNote::NativeFloat8
(native-float8): the device's e4m3 reads 0x7F and 0xFF as NaN where Metal reads 480 and -480,
and an e5m2 NaN's bits are the device's. Validation classes it Unbounded; the conformance suite
lists it among the native notes; FAST-PATHS.md has its device-gap row and API.md its catalogue
entry. The other formats record none: Metal on Apple M3 does not compile them.

The refusal of a matmul2d of 8-bit floats on such a device (Entry::float8_products, the select
check) goes. REFUSALS.md and api_signatures.tsv regenerated.

Tests: matmul2d's fp8 fused sums on the RTX 50 profile (Float8EXT declared, the note recorded,
e4m3 NaN sums) beside MoltenVK, RADV and lavapipe (neither); air.convert widenings on the RTX 50
profile and lavapipe; simdgroup-matrix fp8 cells on the RTX 50 profile too. Not yet built here:
the build and these tests run next on the cluster.
2026-11-13 01:11:22 -08:00
Anees Iqbal a6bf288f2c Match the managed copy-in policy by equality in the tests
What: the named-rounds tests' readable() and the lane test's step-4 answers
test ManagedCopyInPolicy by equality instead of matching its variants.

Why: the enum is non_exhaustive, so a match outside its crate needs a
wildcard; the tests did not compile (E0004).

Verified: the jobs that follow.
2026-11-12 23:57:16 -08:00
Anees Iqbal 9f3dc79994 A Managed buffer's named range is copied in by the GPU as the submission runs, by default
What: DevicePolicy gains managed_copy_in (ManagedCopyInPolicy, a runtime
choice no profile carries). Under the default, AtSubmission, a commit that
takes a did_modify_range's range has the GPU copy it from the host copy (the
import of the caller's pages, or the runtime's own host-cached memory) into the
device copy as the submission runs (Buffer::upload), with no CPU copy and no
staging. Pages no import maps are still staged by the CPU at the commit. Under
AtCommit, which exact_answers() selects, the commit copies the range on the
CPU as the host copy holds it then (the RV2145 snapshot, Buffer::upload_now,
now upload_at_commit). Staging buffers of both directions are now Shared in
the default CPU cache mode, host-cached system memory, never the device-local
(BAR) memory a write-combined buffer prefers without unified memory, and of
power-of-two lengths (64 KiB at least), so a like-sized later copy takes a
buffer the recycler parked rather than new memory.

The ledger gets its row (the bound: a CPU write after the commit, before the
GPU runs the command buffer, may be read), and managed.rs, managed_copy.rs,
API.md's accepted difference, the runtime README, FAST-PATHS' costs bullet and
the conformance crate's Policy::Exact say so. tests::fast_paths names the
choice and checks it keys no profile and that exact_answers() takes AtCommit.
The named-rounds race tests take the policy: by default each round reads, in
each byte, its own byte or one the CPU wrote to its buffer after its commit
(0xee, a later round's), never an earlier round's; under AtCommit only its
own; three AtCommit tests join the three default ones. The lane test's step 4
reads either oracle's answer by default and the 5300M's under AtCommit
(exact_answers_take_a_did_modify_range_at_the_commit).

Why: a compute benchmark's commits spent most of their time in this copy on a
discrete GPU (a CPU memcpy into write-combined staging in BAR across an eGPU
link, fresh 32 MiB chunks each time). The oracles differ on the bytes after
the commit (5300M A,B,B,A,B; UHD 630 A,B,B,B,B), so the cheaper answer is the
default and the snapshot stays behind the switch (AGENTS.md rule 1).

Verified: jobs in the report (lint both cfgs, the translator's fast_paths, the
runtime suite on lavapipe, managed_copy_device and the lane test on the RTX
3090 and the RX 7900 XTX, and the copy-in bench there before and after).
2026-11-12 23:57:16 -08:00
Anees Iqbal 62dfb5cec3 String literals whose line continuations were lost join their lines again
A run of spaces inside a string literal, where a line once ended in `\`, printed the next line's
indentation into the text. Swept every .rs file's string literals (non-raw) once for a run of
four or more spaces between two non-space characters, and for literals whose line ends without a
continuation; the latter were all intended multi-line text (LLVM IR, SQL, data tables, usage).

Restored (each run became ` \` and the next line's indentation, 28 runs):
- product messages: render_state.rs (SampleDepthClamp's text), degradation.rs
  (YCbCrFilterNotExact's text), two_planes.rs (a blit's why-not), device/create.rs (the dropped
  instance layers' line);
- tests and suites: render_sibling_work.rs, shadow_standing_device.rs, image_standing.rs (2),
  conformance texture_views.rs (2) and rate_map_sweeps.rs (3), validation plan_resources.rs and
  parallel_encodes.rs (2);
- conformance times.rs: a wrapped line after an explicit `\n`, its two-space indent kept;
- engine_refused_families.rs: one space in an LLVM IR line's `ptr addrspace(1)`.

The degradation texts change in whitespace alone; docs/API.md's catalogue names the kinds, not
these texts, and still matches. Left as written: aligned columns and indentation after `\n`
(kernel_textures.rs, renders.rs, argument_buffers.rs, degradation_catalogue.rs, the
conformance stability, verdict and cost reports, the tab table of dma_buf_leak_probe.rs, usage
texts). cargo fmt.
2026-11-12 23:16:47 -08:00
Anees Iqbal c72bbdb125 A new buffer's zeros are one fill on every device, unified memory too
What: `FirstFill::zeros` set a new buffer's word-aligned zeros with one
`vkCmdFillBuffer` only on a device without unified memory; a device that
shares the host's memory copied the device's zeros instead. It now fills on
every device (copies stay for a range whose ends are not multiples of 4).
The first-use lane's `a_new_private_buffer_reads_zero_through_its_first_fill`
asserts exactly one fill (`WorkCounts::new_buffer_zero_fills`) on every
device; it asserted none on unified memory. The docs of `zeros`,
`first_move.rs`, `word_fill.rs` and `new_buffer_zero_fills` say so.

Why: the copy read the zeros as well as it wrote the range, which costs on
unified memory too. Measured on one blit zeroing 17,899,520 bytes, GPU time
by timestamps, median of 20 (a diagnostic branch, not committed):
- Radeon 780M (RADV, Mesa 26.2.6): fill 0.532 ms, copies 0.748 ms; the
  command buffer's wall time 1.556 vs 1.900 ms.
- Iris Xe (ANV, Mesa 26.2.6): fill 0.517 ms, copies 0.527 ms; wall time
  0.948 vs 1.070 ms.
The discrete numbers already in the doc (RX 7900 XTX) are unchanged.

Verified (at the same change on bfcd63c5e2): the first-use lane on the Iris
Xe and the 780M (11 passed each, "its zeros 1 fills" on both); clippy over
the workspace, all targets and features, green. Not FAST-PATHS material: no
accuracy is traded.
2026-11-12 23:09:52 -08:00
Anees Iqbal 9689f5934b matmul2d of 8-bit floats: refused where the device has its own 8-bit float type
Owner rule 1: where a device has a native 8-bit float type, its conversion is the only
form. VK_EXT_shader_float8 (whose shaderFloat8, the SPIR-V capability Float8EXT, Vulkan
requires of every device that lists it) is the vocabulary's ExtShaderFloat8, enabled where
the device lists it. The matmul2d expansion records whether a lowered run reads 8-bit float
elements (Entry::float8_products, from the run's operand types), and selection refuses such
an entry, Unsupported{Tensors, NotImplemented}, where the extension is enabled: the
conversion through the device's type is not built yet. Elsewhere the integer decode stays
the form. Of the committed profiles, nvidia-rtx50-linux and nvidia-rtx5080-laptop list it;
their 8 opened validation contexts each enable it (opened_chains.txt blessed). REFUSALS.md
and api_signatures.tsv regenerated.

Verified on msi (m3-max-24411, m3-max-24435): 261 of 261 touched tests (matmul2d, tensor
ops, the device vocabulary and enables, requirements, the codec, ash interop, the signature
table) pass, among them fp8_products_are_refused_where_the_device_has_its_own_8_bit_floats
(both RTX 50 profiles refuse e4m3 and e5m2; RADV and lavapipe translate and validate) and
the fused-sum tests on MoltenVK, RADV and lavapipe.
2026-11-12 22:57:49 -08:00
Anees Iqbal 47ee9f4806 Fan a rate-mapped draw out through four copies where its triangles reach at most four regions
A host step's fanned-out draw went through one geometry-stage variant that
declares the output of the most copies (up to 16) for every triangle, though
most draws' triangles touch only a few regions. The declared output size is
what the 780M's geometry stage pays for.

- The translator: RegionFanOut::DrawFew, the draw variant whose loop emits
  at most FEW_COPIES (4) copies and whose geometry stage declares 3 x 4
  output vertices; its codec name and compile-key word (" region_fan_out
  few"); the link and engine tests cover the three modes.
- The probe: each draw's words grow to 1 + 2 x PROBE_COUNT_WORDS (65): its
  flag, the 32 count lanes, and 32 wide lanes, where a triangle whose
  widened pair count exceeds FEW_COPIES stores 1 (picked by PrimitiveId
  mod 32, as the counts are). The host reduces them to (flag, copies, wide).
- The runtime: a fanned-out draw no triangle of which is wide draws
  through DrawFew, else through Draw; commit's settle begins the three
  variants (probe, few, most). Counted:
  WorkCounts::rate_map_fanned_few_draws.
- The pieces lane prints the count. The runtime test's 8 commands add one
  whose triangle covers four tiles a side (more regions than four, no more
  than the most copies), drawn through the most copies, and assert the
  other 6 fanned-out draws took four; the pixels are still the encoder's
  region-by-region draws'.
- docs/FAST-PATHS.md: the fan-out row names the variant and its count, and
  its cost cell carries the numbers below. bind/fan_out.rs: FEW_COPIES's
  numbers.

Verified, release binaries, runtime_lane::rate_mapped_pieces and
tests::rate_mapped_fan_out, the command buffer's GPU time, cold then warm:
- Radeon 780M (Mesa 26.2.6), m3-max-24369, this change plus a scratch
  switch (never landed) drawing every fanned draw through the most copies,
  interleaved in one job: 4 copies 40.2/29.7 and 43.9/30.8 ms; the most
  copies 61.9/36.8 and 62.7/34.5 ms. Warm about 5.4 ms (15%) less.
  64 of 64 draws of four copies.
- Iris Xe (Mesa 26.2.6), m3-max-24317: 47.7 ms cold, 40.0 ms warm (40.5
  warm through the most copies in an earlier run); 64 of 64 of four copies.
- RTX 3090 (NVIDIA 620.70.06), m3-max-24316: 28.6 ms cold, 6.1 ms warm
  (6.2 ms before); 64 of 64 of four copies.
- tests::rate_mapped_fan_out on all three: 3 passed, 6 drawn of few
  copies, the fan-out's pipelines 3 ready plus waited, 0 made at the step.
The Iris and 3090 runs are of the same change at base 9c30ffd263; the
780M's at bfcd63c5e2. Clippy (translator, runtime, validation,
conformance, --cfg m2v_gpu and m2v_gpu_hazards, all features) and the
translator's fan_out and api_surface tests: m3-max-24351, at bfcd63c5e2,
0 messages, 20 passed. signatures.py --check passes; REFUSALS.md
unchanged.
2026-11-12 22:28:15 -08:00
Anees Iqbal 8bc2e7e1ac Keep the content directory's large records as content-defined chunks, each shared run once
NVIDIA's pipeline cache data (620.70.06, an RTX 3090) held one 1,851,552-byte section, the same
bytes, in 3,565 of um790's records: its 11,853 NVIDIA records were 8,061 MB. A read-only measure
of that node's 42,860 records (cut as below, averages of 16, 32 and 64 KiB) stores them in 296 MB
at 32 KiB (NVIDIA's in 180 MB, 2.2%); 64 KiB keeps each shared run's end chunks apart (634 MB),
16 KiB doubles the files a read opens for 1.3x the bytes.

shader_cache/chunks.rs (new), store.rs, driver.rs:
- A content record of 256 KiB or more is cut by a gear rolling hash (FastCDC's normalized cut,
  8 KiB to 128 KiB around 32 KiB): boundaries from the bytes alone, nothing of any driver's
  format read. Each chunk is kept once at <root>/chunks/<2 hex>/<SHA-256>, outside <root>/v1, so
  a build whose scans know nothing of chunks never removes one. The record's file is a manifest
  (M2VCHNK1, length, count, each chunk's SHA-256 and length, its own SHA-256); a read joins the
  chunks and the record's decoder checks it end to end as before (a driver record's checksum, a
  library's content hash). A missing or short chunk is a miss; the next write brings it back,
  and a chunk whose bytes are not its digest's is written again. Smaller records stay whole.
- Crash-safe: every chunk (temporary + rename) before the manifest's rename. An advisory lock
  (std File::lock, <root>/chunks/lock): writers hold it shared from their first chunk look to
  their manifest's rename; the cleanup takes it exclusively with try_lock and removes only
  chunks no manifest names. Neither waits: a writer that meets a cleanup writes its record
  whole.
- Bounded cleanup, in the scans the store makes already: the sweep at device creation where no
  cleanup ran yet or the chunks grew past 110% of what the last kept, and after a cap scan that
  freed chunks. It reads each content record's first 8 bytes (a manifest whole) and lists the
  chunks once. The chunks count against the cap; a removed manifest frees the chunks only it
  named.
- Upgrade: driver::VERSION 3 -> 4, its frame's magic M2VPPLC -> M2VPPL4 (an older build names
  and frames otherwise, never misreads one). The old records are removed by
  Store::sweep -> Chunks::due (no state yet) -> Chunks::cleanup -> Chunks::manifests, which
  removes each content record whose magic is in driver::RETIRED. Each family pays one cold
  making after the upgrade. The validation lanes read the new magic.
- Linux reads: every chunk opened first and posix_fadvise(WILLNEED) on each, so cold chunks
  are read together.

Tests (tests::shader_cache_chunks, 8): round trip and the 256 KiB bound; a shared 1.5 MiB run
kept once (the second record wrote 95,310 of 1,580,864 bytes); no manifest when its chunks
cannot be written; a missing or damaged chunk; the sweep removing a synthetic v3 tree (four
M2VPPLC records, one of 2 MiB), unnamed chunks and a dead writer's temporary; a writer's
shared lock putting the cleanup off; a cleanup's lock making a writer write whole; the cap
evicting the older record with its own chunks.

Verified on msi (m3-max-24179, at this tree's code): clippy -D warnings all features, rustdoc,
shader_cache tests 44 passed, the runtime suite 1512 passed.

Load time, release mode on um790 (NVMe), a store load with a SHA-256 decode in both
(m3-max-24178; the SHA-256 of 1.85 MB alone is 0.80 ms), median of 20 cold (every file dropped
from the page cache) and 200 warm:
- 1.7 MB, 40 chunks (NVIDIA p90): cold 1.56 ms whole, 1.47 ms chunked; warm 0.77 / 0.95 ms.
- 2.5 MB, 67 chunks (worst): cold 2.07 / 2.62 ms (+0.55 ms; one of 20 at 12.1 ms); warm
  1.12 / 1.44 ms (+0.32 ms).
- 20 families sharing the section, all cold, in turn: per family median 0.86 ms whole,
  1.13 ms chunked (first 0.94 / 1.65 ms); whole's slowest 138.6 ms, chunked's 1.18 ms.
A family's later makings on the device use its live cache and read nothing.
2026-11-12 21:10:10 -08:00
Anees Iqbal 9e19371285 Pieces lane: default pipeline waits, the commit's time, the fan-out's makings taken
The lane's device ran under exact_answers(), whose PipelineWaitPolicy::Exact
made every pipeline a commit settles on the program's thread: with the
fan-out's begun at commit, the cold frame's commit took 86.9 ms on an RTX
3090 and 69.8 ms on an Iris Xe, a cost a consumer's device, under the
default Bounded waits, hands to the pool. The lane's device now makes them
under the default waits, as a consumer's does. Its line adds the program's
time in commit (the host's clock) and the fan-out's makings the commit
began that the step found made or waited for
(WorkCounts::rate_map_fan_out_pipelines_ready, _waited).

The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry
the three GPUs' numbers with the fan-out's pipelines begun at commit and
the copy loop (m3-max-24007 RTX 3090, 24008 Iris Xe, 24009 Radeon 780M),
command buffer GPU time FanOut against Exact, cold then warm:
- Iris Xe: 47.3 and 40.6 ms against 514.3 and 496.8 ms; commit 2.1 ms.
- Radeon 780M: 42.3 and 29.4 ms against 299.3 and 232.6 ms; commit 1.8 ms.
- RTX 3090: 44.2 and 7.5 ms against 71.2 and 65.5 ms, the step waiting for
  the fan-out's makings in the cold frame; commit 7.4 ms.
2026-11-12 21:02:13 -08:00
Anees Iqbal 7cafb7c6c8 Lanes that asked whether a new Private texture was left unfilled ask whether it is zero-filled
What: compressed_decode (a new Private BC texture reads zero blocks too, counted
as zero-filled, no BCFRESH-UNFILLED), depth_denormals, fresh_writes and
parallel_encodes now take fresh_contents::zero_filled in place of unfilled. The
texture module's and heap_tiled's docs say what a new Private texture reads now.

Why: the commit before retired private_textures_unfilled and the helpers that read
it; the validation crate did not build under --cfg m2v_gpu (job m3-max-24030).

Verified: the lint and lane runs reported with this sha.
2026-11-12 20:36:13 -08:00
Anees Iqbal 5eb107ac89 A new Private texture reads zero on every device: never the bytes its memory held
What: new_texture_image starts a Private texture zeroed (Start::Zero) on a
device that presents an Intel or AMD Mac, as it did on an Apple GPU presenting
one: its first move clears it, or copies zeros, or takes the driver's zeros
where the block is fresh. Only a Memoryless texture starts held.
private_textures_zero_filled counts each. WorkCounts::private_textures_unfilled
goes, as nothing counts it now.
- The recycled image a new texture takes (recycle.rs) and a recovery's remade
  texture (texture/carry.rs, Remake::Own through texture_as) go through the
  same making, so both read zero.
- Tests: mac_class (an Intel or AMD Mac's new texture reads zero, counted as
  zero-filled); the parent's recycle test.
- Lanes: fresh_contents and fresh_costs expect zeros there, counted.
- Docs: API.md's accepted difference, the runtime README, MacClass::IntelOrAmd,
  conformance's without_compression.
- api_signatures re-blessed (the field goes).

Why: Start::Held matched a Mac with an Intel or AMD GPU, where a new Private
texture can read a released texture's texels. On such a Mac those texels are
the same process's. A consumer that serves several processes from one device
showed one process another's pixels that way. The 780M read a released
texture's colour through a recycled image (m3-max-23995). After a forced
recovery on the RX 7900 XTX, a guest window read other windows' pixels. Zero is
what those Macs read where their memory held nothing, and Metal leaves the
contents undefined.

Verified: the lane run reported with this sha (the recycle test of the commit
before fails on lavapipe, the 780M and the XTX; this one passes).
2026-11-12 20:36:13 -08:00
Anees Iqbal efcb6851ce The encoder trail: name the encoder a stalled GPU stopped in, and the last one that completed
A GPU hang (a CTX SWITCH TIMEOUT on an RTX 3090) left the runtime with no way to say which
encoder never completed: encoders share batches and grouped submissions, and neither
METAL2VULKAN_LOG_PASSES nor METAL2VULKAN_QUEUE_TIMES logs anything at a stall.

METAL2VULKAN_ENCODER_TRAIL (env_vars.rs), or DeviceOptions::encoder_trail for one device, is a
default-off diagnostic (encoder_trail.rs):

- Each encoder, and each part of one a host step splits off, ends its batch (Batches::alone),
  and no batch waits in a group, so each goes in a vkQueueSubmit of its own that signals its
  queue's timeline. When work goes to the driver changes; what it computes does not.
- Each encoder notes what it was: its kind, its command buffer's object ID, its place, a
  render pass's area, samples, attachments' formats and sizes, instances and rate map, its
  indirect command executions, and the label hash of each state it bound (the first 8 bytes
  of a SHA-256 of the state's label and its functions' names; no name, no shader text). A host
  step adds the states its indirect commands named, as the GPU and the CPU left the records.
- Once no work of the device advanced for 2 s with some pending, completion.rs's stall path
  logs one Info line (id name metal2vulkan-encoder-trail) for each VkQueue whose oldest batch
  is pending: that batch's encoders and the last batch the queue completed, with how long
  before; once a stall.
- A submission a host step makes and waits for itself (a rasterization-rate map's fan-out
  probe, a predicated loop's check run again) signals no timeline; once it ran 2 s, one line
  names it, the encoder whose step made it and the states its commands named.

Off, a device reads the switch once and notes nothing.

Verified on msi (lavapipe, --cfg m2v_cpu_icd), at the branch tip this commit's tree equals:
- tests::stall::the_encoder_trail_names_the_stuck_encoder_and_the_last_one_completed: a cb
  stuck on an event wait before two blit fills; the line names the stuck cb's encoder 0 (not
  its encoder 1) and the earlier completed cb's encoder 0:
  "VkQueue 0's oldest pending batch: Blit encoder 0 of command buffer 3, states []; the last
  batch it completed: Blit encoder 0 of command buffer 2, states [] (2.106823047s before)".
- tests::rate_mapped_fan_out::the_encoder_trail_fans_out_the_same_pixels: with the trail on,
  probes/flagged/fanned [1, 1, 6] as without, no texel differs from the encoder's own draws.
- The host-step families (rate_mapped_fan_out, rate_mapped_pieces,
  indirect_command_buffer_device, host_step_neutrals, ycbcr_in_place_loop) with
  METAL2VULKAN_ENCODER_TRAIL=1: 11 passed.
- encoder_trail's unit test (one state's hash pinned: a reader of the pipeline creation log
  computes it again); the runtime suite 1504 passed; api_ tests 16 passed; clippy all features
  and the runtime under m2v_gpu and m2v_cpu_icd; rustdoc of the runtime and metal2vulkan.

The runtime-sources pin moves (not re-pinned here).
2026-11-12 20:33:17 -08:00
Anees Iqbal 4906f145e3 Pieces lane: each frame cold, then warm; the fan-out row's cold and warm costs
The lane's one frame mixed two costs at the host step: the GPU work, and on
the first frame of a state the driver making the fan-out's probe and draw
pipelines inside the step (82.1 of the RTX 3090's 88.6 ms cold fanned-out
window). The frame now runs twice on the same device, cold, then warm,
each printed and checked, and the line adds the host step's time
(WorkCounts::host_step_nanos), the pipelines it made
(host_step_pipelines_made) and the time creating render pipelines
(render_pipeline_create_nanos).

The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry
the three GPUs' cold and warm numbers after the probe spread, from one run
each (m3-max-23899 RTX 3090, 23900 Iris Xe, 23901 Radeon 780M), command
buffer GPU time FanOut against Exact:
- Iris Xe: 110.4 ms cold, 40.3 ms warm, against 514.6 and 499.1 ms.
- Radeon 780M: 84.3 and 34.7 ms against 299.5 and 231.7 ms.
- RTX 3090: 88.6 and 6.0 ms against 61.9 and 63.0 ms.
The guest-scale fanned-out figure, measured before the spread, is dropped;
its region-by-region one stands.
2026-11-12 19:41:07 -08:00
Anees Iqbal c7362776d0 Let carried textures' and pipeline states' parts go at the lost generation's rest
What: a recovery's carried textures and pipeline states let go of their
parts on the lost generation once it comes to rest, as buffers already
did, so the lost VkDevice goes while they live.

- device/carry.rs: LetGo<T>, the let-go cell MadeOn was (MadeOn is now
  LetGo<Device>), and PartsCalls/CallHold, one guard generalised from the
  buffer's calls and HeldParts: a call outside command buffers' work counts
  itself, and a release at rest waits for the last call to end. Buffers
  use it unchanged in behaviour (Buffer::held_parts, LostBuffer,
  LostPlaced, LostHost).
- Pipeline states: StateShared.program and ProgramLink.program are LetGo
  cells. The carry hands the lost generation a LostProgram, which drops
  the state's program there in place at rest (its variants' objects,
  plans, makings and its Device). reached() skips programs let go of. The
  state keeps its own copy of its label, so label()'s borrow outlives the
  program. Holds: the public state methods that reach the program,
  program(), Debug, and the argument encoder's and indirect commands' set
  paths.
- Textures: TextureShared's per-generation parts (storage, moved,
  pending_move, usage_shadow(_making), faces, snapshot, kept_backings,
  render_shadow, facts, planes_in_place) move into Parts in a LetGo cell,
  read through Deref. The carry hands the lost generation a LostTexture.
  At rest it leaves the texture's slot in the lost generation's table and
  heap sets, hands the caller's range token to the parts on the next
  generation, and drops the parts in place. Parts with a handed-out VkImage
  (Texture::vk_image) stay until the texture goes. Texture::s() skips parts
  let go of. Holds: the public texture methods that reach parts, and
  vk_image; a view's hold holds its root texture too. slot_keeper names a
  texture buffer's generation by its texel views, not by the buffer's
  serving generation.
- WorkCounts::lost_programs_released and lost_textures_released, counted
  on the line.
- Public signatures: ComputePipelineState::device,
  RenderPipelineState::device, FunctionHandle::device and
  VisibleFunctionTable::device now answer an owned Device. The last two
  also borrowed from the state's program. Command-buffer paths use the
  crate-private borrowing generation(). api_signatures is blessed.
- Docs: the carry module docs (device, pipeline, texture), docs/API.md's
  recovery entry, the runtime README's recovery paragraph, vk_image's doc.
- Tests: the four recovery tests in 99dbc69666 also assert the counters.

Why: a carried texture kept its images on the lost generation, and a
carried state its program there, until the object went, so the lost
VkDevice lived as long as any of them. A long-lived program kept it for
good.

Verified: cargo check of the workspace, all targets and features, under
no cfg, m2v_gpu and m2v_cpu_icd, clean but for one validation call site
fixed here (jobs m3-max-23824, 23852). The lavapipe lane (the tests of
99dbc69666 before and after), the suite, lint and the 780M run follow.
2026-11-12 19:32:06 -08:00
Anees Iqbal 15e5d84f74 candidate batch help: wrapped 2026-11-12 19:23:40 -08:00
Anees Iqbal d7c915aa99 Batch out directories carry the validation crate's fingerprint
What: BatchBuild, the record (build.json) a corpus-metal, corpus-vulkan or corpus-moltenvk
batch's out directory keeps of its runs' build, gains `validation`, this crate's source
fingerprint (worker::device::VALIDATION_FINGERPRINT). A batch resumes an out directory only of
its own build, so a build that changed only this crate's sources claims none of an earlier
one's, and is_this_build (batch-report's and batch-install's this_build) answers no for it. A
record from before the field reads it empty, which is no build's.

Why: the record held the executor ABI, the product fingerprint (which leaves this crate out),
SEMANTICS_VERSION and ORACLE_ABI. A fix in the oracle alone, such as the fuel transform's AIR
2.9 atomics (87e88c0706), moved none of them, so a batch resumed in an out directory of the
build before it would have skipped as done every Metal qualification metal-opt refused there.
ORACLE_ABI stays where it was: no committed Metal row is of a case the old oracle could
qualify and the new one answers differently.

Tests: an_out_directory_resumes_only_its_own_build claims a fresh directory and checks the
record holds this build's fingerprint, refuses a directory whose record differs only in it (an
oracle-only change, finished runs and all) and one from before the field, and answers
is_this_build no for both.
2026-11-12 19:23:40 -08:00
Anees Iqbal 0c6d7cc1c8 Pieces lane at a guest frame's scale, a GPU hazard; the RTX 3090's numbers
rate_mapped_pieces_guest_scale (FanOut) and _guest_scale_exact run the host
step's frame at six times the commands (384 commands, 5,508,648 indices,
about the 126 pieces a guest frame was recorded in on an RTX 3090), compiled
only under m2v_gpu_hazards and ignored by default.

Measured once on an RTX 3090 (NVIDIA 620.70.06), um870, each test its own
process: at 64 commands Exact 54.4 ms in 20 pieces (longest 2.63 ms),
FanOut 98.4 ms with a 14.0 ms probe; at guest scale Exact 332.3 ms in 117
pieces (longest 2.67 ms, mean 2.00 ms), FanOut 174.3 ms with a 74.4 ms
probe. The numbers go in the lane's docs and the fan-out row's cost cell
in docs/FAST-PATHS.md, where FanOut is slower than Exact at the small size
on that device.

Verified: clippy with --cfg m2v_gpu --cfg m2v_gpu_hazards over the runtime,
the translator and validation, 0 messages; the five lanes passed on the RTX
3090 (job m3-max-23744), built from the same lane source.
2026-11-12 18:54:28 -08:00
Anees Iqbal 41337099f5 Time a rate-mapped pass's pieces on a device asked for host-clock GPU times
A device made with DeviceOptions::gpu_times_from_host wrote no timestamps
at all, so a pass recorded in pieces read no piece time there
(rate_map_pieces_timed 0): a guest frame on an RTX 3090 cut into 126
pieces gave no hint which piece or draw was long. The option only spares
command buffers' own two timestamps; the piece timer and the host step's
probe now write theirs on such a device. They still skip where the driver's
timestamps wait for every queue's (FromHost::Driver, MoltenVK), since there
a timestamp would serialize the device's queues.

The option's docs, the gpu_time module's, the degrade notice's, the API
catalogue's and the work counts' say so.

Verified: the new runtime test
a_device_answering_gpu_times_from_the_host_times_its_pieces passes on
lavapipe (12 pieces past the first, 13 timed) and on an RTX 3090 (NVIDIA
620.70.06, the same counts), built at the branch's earlier commit with the
same runtime source.
2026-11-12 18:54:27 -08:00
Anees Iqbal b817cd5037 Pieces lane: frames at both region policies, the commit frame over a named range
The lane now runs the host-step frame under `RateMapRegionPolicy::FanOut` (checked for its probe
and fanned-out draws) and under `Exact` (`rate_mapped_pieces_host_step_exact`, checked for pieces
and ranges), and prints the probes, the flagged and fanned-out draws and the probe's GPU time.

Its commit frame executed over a range read from a buffer, which `commit` declines where the CPU
alone writes the records ("an execution of the pass whose records the CPU alone writes reads its
range from a buffer"), so a host step recorded it and fanned it out: it now names its range in the
call, which `commit` records.

Verified: at e55e6ebd01 the host-step frames passed on an Iris Xe and a Radeon 780M (Mesa 26.2.6)
and the commit frame failed as described (one probe, 64 draws fanned out); the commit frame's fix
is checked on both devices at this commit.
2026-11-12 18:28:20 -08:00
Anees Iqbal 87e88c0706 oracle_fuel: the status atomics take the form of the module's AIR version
What: the fuel transform reads the module's !air.version and, from AIR 2.9 on, declares and
calls the status load, add and or with the mem_flags i32 between the scope and the volatile flag
(0, no flags, as a relaxed atomic passes): `i32 (i32 addrspace(1)*, i32, i32, i32, i1)` for the
load. A module that states AIR 2.8 or earlier, or no version, keeps the form it had.

Why: Apple's compiler for macOS 27 writes AIR 2.9, whose atomic intrinsics take that operand,
and metal-opt refuses the AIR 2.8 form in a module that states AIR 2.9. So no macOS 27 case whose
entry reaches a loop could be qualified on Metal: every case of the tns_mm_v2 fixture (the Tensors
work, landing next) failed with "invalid AIR function air.atomic.global.load.i32 (i32 (i32
addrspace(1)*, i32, i32, i1))" (m3-max-23501).

Verified, one run each:
- oracle_fuel's tests, 80 of 80, among them the new
  the_status_atomics_take_the_form_of_the_modules_air_version (no version, 2.8 and 2.9: the
  declarations' forms, and every call's operand count equal to its declaration's)
  (m3-max-23527, the same patch on the Tensors branch).
- The nine tns_mm_v2 cases on the M3 Max (macOS 27.0.1): refused by metal-opt before
  (m3-max-23501), all qualified after (m3-max-23519).
- fmt, clippy (all features, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc over the Tensors
  branch that carries this patch (m3-max-23553).
2026-11-12 18:20:12 -08:00
Anees Iqbal 2b8b56617d An object a recovery carries answers the caller's own device handle
What: the public device() of every object whose borrow reached a handle a
recovery lets go of answers an owned Device, a clone of the generation
handle it read: Buffer, Texture, Heap, IndirectCommandBuffer, Event, Fence,
SamplerState, Library, Function, DepthStencilState, AddressPool,
DynamicLibrary, BinaryArchive and SharedTextureHandle (whose device is its
texture's). The runtime's own reads keep a borrow through a crate-private
generation() on the types they read it of (Buffer, Texture, Heap,
IndirectCommandBuffer, SamplerState, Function, BinaryArchive): 301 call
sites, so no hot path pays a clone. Each changed item's doc says the handle
is the caller's and keeps its generation, VkDevice included, while held,
past a recovery that carries the object on; MadeOn's doc states that no
borrow of it reaches the program. The validation lane's four callers that
passed the borrow on take a reference of the handle. Signature table
re-blessed (14 rows).

Why: these accessors answered a borrow into device/carry.rs's MadeOn (a
Buffer's or Event's parts, or a LineDevice's GenerationLink), whose
let_go drops that Device at the lost generation's rest while the object
lives. Safe code that held the borrow across a recovery and that rest read
a dropped Device. Metal's device property answers a retained device. The
other objects' device() (queues, command buffers, argument encoders, rate
maps, pipeline states and their function tables) answer a borrow of a
handle the object owns for its life, which no recovery lets go of.

Verified: the lane that follows runs tests::device_recovery_handles before
(it fails: one live VkDevice while the borrow is held) and after the fix;
a workspace check of the accessor change was clean under the plain cfg and
found the four validation callers under m2v_gpu and m2v_cpu_icd (job
m3-max-23584 on a probe commit).
2026-11-12 18:11:56 -08:00
Anees Iqbal cff8ee6e45 Pieces lane: a host-step frame beside the commit one
The rate-mapped pieces lane records its frame at commit only, from the CPU's records. A guest's
frame on NVIDIA records its rate-mapped pass at the host step, its records ones the GPU may
write. The lane now runs the frame twice: as before, and with a blit encoder that resets a
command past the range before the pass, so the host step records it. Each RATE-MAP-PIECES line
names where the pass was recorded.

Not yet run: built and run on the RTX 3090 next.
2026-11-12 17:40:20 -08:00
Anees Iqbal c4376d1042 canon::generic: a struct's generic pointers read through its address another thread object holds
What: canon::generic's cells (canon/generic/cells.rs) follow thread pointers through thread
memory. A slot of an alloca into which only the address of one alloca at one offset is stored
(a null among them or not), that no other write, copy, atomic or load at another offset or width
meets, of an alloca whose address no use but an access and address arithmetic takes, is
followed: a thread pointer loaded from it places what it addresses, and storing that address into
it is no escape. Places also derive through casts between the thread and the generic space, so
an object reached through a generic `this` is a cell too. The slots followed and the places they
lead to are found together, in rounds; a slot followed once and not after is never followed
again, and past the rounds' bound none is.

Why: macOS 27's MPS matmul and quantized matmul kernels keep their array_refs' generic pointers in
a thread struct and read them through a lambda that captures the struct by reference: the
lambda's object holds the struct's address, and its call operator, inlined, loads that address
and then the struct's fields. The fields' loads were from no place a cell knew, and the struct
was open because its address was stored into the lambda's object, so each was
GenericPointer(Memory).

The owned fixture generic_pointers gains generic_captured (a lambda capturing a `refs` by
reference, its call operator taking its object as a thread pointer) and generic_functor (a
functor holding `&r`, its out-of-line call operator taking the functor as a generic pointer), and
its Metal probe the same kernels. docs/FAST-PATHS.md's generic pointer gap says so.

Verified, one run each:
- Before, at development with the fixture: engine_generic_pointers refuses generic_captured
  with GenericPointer(Memory) (m3-max-23363).
- The M3 Max (macOS 27.0.1) answers both new kernels as generic_slots: 100+t, 201+t, 1 for t<4
  then 4, and t (m3-max-23383).
- engine_generic_pointers and the metal2vulkan-air suite pass, 561 tests (m3-max-23381).
- The metal2vulkan and metal2vulkan-air suites (m3-max-23401): 4060 of 4063 pass; the three
  that fail are the golden tables, which development re-blesses: golden_hashes, the engine
  inventory's two new rows (generic_captured and generic_functor, ok in every cell), and the
  engine printout of generic_pointers.ll (tests/air_input/generic_pointers.txt, recorded under
  LLVM 21).
- runtime_lane::generic_pointers on lavapipe, both tests, the five struct kernels among them
  (m3-max-23413).
- fmt, clippy with all features and rustdoc (m3-max-23436, the same patch on development
  6772e9aa8e); clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd at this tree (m3-max-23451).
- macOS 27's 590 MPS functions that name addrspace(8), release, RDNA3 profile (m3-max-23256
  before, m3-max-23382 after): GenericPointer(Memory) 47 -> 6. Of the 41 rows that move, 36 now
  stop at Tensors (a cooperative left input), 4 at Tensors (fp8 matmul2d) and 1 at a linked
  function the command line cannot supply; no other row's outcome changes (155 translate at
  both). Slowest 0.68 s, largest 189 MiB. The 6 left pass the struct's address to a visible
  function the pipeline links (the gap's documented case).
2026-11-12 17:28:54 -08:00