Commit Graph
1268 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 3697a412e9 Name each batch submission that holds its thread 5 ms or longer, phase by phase
What: under METAL2VULKAN_QUEUE_TIMES (a default-off diagnostic that already notes queue head
and submit-return times), a batch submission that took 5 ms or longer from its start to its
vkQueueSubmit call logs one line (id name metal2vulkan-slow-submissions, through the device's
message sink, else stderr): its place in its command buffer, its VkQueue slot, the span split
into the prologue, the first work's take, the staging queue's flush (its waits for the staging
queue's lock and for one of that queue's command buffers counted apart) and the planning and
recording, then the call's own time. slow_submissions.rs holds the watch; submit.rs enters the
phases; device/staging.rs counts the two waits through a thread-local only while a watched
submission runs on the thread. Off, a submission reads one flag; no clock read, no line.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

RUNTIME_VERSION 2233 -> 2234 (the warm pass answers kept refusals).
2026-11-13 11:49:37 -08:00
Anees Iqbal 4383b55aed SEMANTICS 2096: ANV: a stage heavier than the largest measured to compile in host-sized memory is refused, or keeps the widest pin
ANV's compiler takes memory that grows faster than the stage it compiles, inside the process that
creates the pipeline, well below the 2^20-object bound the serialized stage already keeps under.
Measured on the Iris Xe of RPL-P (Mesa 26.2.6), compute modules created cold through
vkCreateComputePipelines, the resident set sampled every second (job m3-max-26147): entry weights
73,814, 75,886 and 99,109 were created in 45 s, 47 s and 132 s at peaks of 1.76, 2.24 and
3.65 GiB; a module of entry weight 532,213 passed 16 GiB at 358 s without finishing. Job
m3-max-26086: a module of entry weight 796,525, its heap raw-texture arms dead, passed 20 GiB in
under two minutes. Both under the old bound (786,432) would have been handed to the driver: one
pipeline creation that can take a host's memory.

- DriverWorkaround::CompilerMemoryGrowsWithStageSize, keyed on ANV whatever its GPU and release
  (device::derive), documented with those points.
- stage_bound: StageBounds holds both bounds (SERIALIZED_STAGE_WEIGHT 786,432;
  COMPILED_STAGE_WEIGHT 99,109, the largest measured to compile, no margin below it as nothing
  above it is measured to compile). emit keeps a module under every bound its profile's defects
  set, with the same widest-pin retry; a refusal (StageSize, DriverDefect) names the serialized
  stage's defect past 786,432 and the compiler's memory below it. The bound rises when a larger
  compile is measured within host-sized memory.
- The test hooks (compile_bitcode_bounded, compile_stage_bounded) take StageBounds.

Docs: stage_bound's module docs and FAST-PATHS' known-gaps entry state both bounds with the
measured points only (weights, never names), and restate the serialized bound's figures in
entry_weight's units: the faulting stage 1,603,989 (0.683 objects per unit, was 1,565,083 and
0.70 by a count 2.4% lower), the other 21 stages' ratios as counted by that count, which ran 1.9
to 2.7% below entry_weight on the five modules both counted; the shader-object figure likewise
1,603,989. Feature::StageSize's docs and its reach line cover the memory bound; REFUSALS.md
regenerated. api_signatures.tsv blessed with the new variant (the bless also moves
scheduler_slice_rescues to the script's own order).

For a consumer on ANV: a module of entry weight past 99,109 and up to 786,432 that was handed to
the driver is now refused (Unsupported, Feature::StageSize,
Needs::DriverDefect(CompilerMemoryGrowsWithStageSize)) unless its pinned plan fits. Other drivers
are unchanged.

Tests:
- engine_simd_lockstep::a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused covers
  both defects: for each, under a bound the emulated module passes the kernel is planned again
  pinned (exact at 32 lanes), under one its pinned module passes too it is refused naming that
  defect, and past both the serialized stage's defect is named; RADV emits under every bound.
- engine_simd_lockstep::a_kernel_past_the_stage_bound_gets_one_answer_through_either_path on the
  serialized bound through StageBounds.
- device::tests::profile::large_module_defects_are_keyed_on_anv includes the new workaround.

Verified, on msi, read from inside each job:
- m3-max-26184 (this change on 86d362e2aa): cargo fmt --check 0; clippy --workspace
  --all-targets --all-features -D warnings 0; clippy -p metal2vulkan --no-default-features 0;
  clippy with --cfg m2v_gpu (all features) 0; nextest over device::tests, engine_simd_lockstep,
  fast_paths and the refusal_surface, api_signatures, api_surface and feature_vocabulary
  binaries: 189 run, 189 passed.
- m3-max-26212: the stage-bound test with its output shown passed with no SKIPPED line; the
  negative control, the compiled bound's cap set past every module, fails it ("left: Emulated,
  right: Direct" for CompilerMemoryGrowsWithStageSize).

SEMANTICS_VERSION 2095 -> 2096: on ANV a module of entry weight above 99,109 (and up to 786,432) is now
refused or re-planned with the widest pin kept, where it was handed to the driver.
2026-11-13 11:45:50 -08:00
Anees Iqbal 523d32a10a A failed submission's and a failed recording's warning end in their id name
reims's sink writes a runtime message's text alone, without its id, so a metal2vulkan-submit-failed
or metal2vulkan-recording-failed line could not be found by id in qemu.log. submit_failure::warn
now appends " [<id name>]" to the text, as degrade notices end in theirs, for both warnings.
The device test asserts the submit-failed line ends in " [metal2vulkan-submit-failed]".
docs/API.md says so. Log text only: no version bump.

Verified: expected, by the check job dispatched at this commit (clippy plain and m2v_cpu_icd on the
runtime, the submit_failure unit tests, the lavapipe device test).
2026-11-13 11:19:29 -08:00
Anees Iqbal 19ead6a74a docs: the failed-submission and failed-recording warnings
API.md's diagnostics paragraph and CommandBufferError::Internal's doc name the two Warning lines
a device's sink now hears (metal2vulkan-submit-failed, metal2vulkan-recording-failed): which
submissions log one, what the line names, its bounds, and that a successful submission does none
of it. Checked against submit_failure.rs's constants and texts; rustdoc runs in the Linux job.
2026-11-13 11:16:16 -08:00
Anees Iqbal a2ac4433ca SEMANTICS 2094: One input, one answer: a compile past the stage bound is charged once, by either path
A kernel planned again past the stage bound (stage_bound::emit, WidestPin::Kept) ran plan_one a
second time: decode, specialization, lockstep order, lowering inputs and memory analysis, all
charged to the meter again. And Device::compile_function_from_entries charged nothing for an entry
a creation had already specialized (StageEntries handed out an uncharged copy). So one input got
two answers under one budget: compiled alone, a large kernel past the bound on the Iris Xe was
refused LimitExceeded(WorkUnits); compiled from a creation's entries, Unsupported(StageSize).

- stage_bound::emit analyzes the entry once (analyze_one, the part of plan_one before selection,
  kept as Analyzed) and only selects, emits and rolls again. What the dropped plan and module hold
  of the ledger is released, measured from before the selection.
- Meter::measured runs work and states what it charged (Spent: work units, its ledger peak above
  where it began, the bytes it still holds); Meter::spend charges that to another meter, work units
  first, then the peak, keeping the held bytes.
- StageEntries keeps each entry's, decode's and plain answer's Spent and charges it to every ask
  that finds them, so a found entry costs what making it cost. The object spares time, never
  budget: compile_function_from_entries charges what compile_function charges, unit for unit.

For a consumer: Spent, Meter::measured and Meter::spend are new public items of
metal2vulkan-air's budget module (api_signatures.tsv blessed); nothing was removed. A creation
that shares a StageEntries is now charged its found entries' work units against each compile's
budget, as a compile that shares nothing always was.

Tests:
- budget: spent_work_charges_another_meter_as_the_work_did (work, ledger and peak equal to the
  work itself; refused alike one unit under either cap).
- engine_simd_lockstep: a_kernel_past_the_stage_bound_gets_one_answer_through_either_path. The
  pressured kernel under a bound its emulated module passes (planned again, Direct) and under one
  its pinned module passes too (StageSize): alone, from entries that make the entry and from
  entries that find it, the same answer and the same work units W; at exactly W both paths answer
  the bound's way, at W - 1 both are refused WorkUnits; the negative control, a meter also charged
  one more plan of the entry (what the plan made again used to charge), is refused WorkUnits at W.
- library_entries_decode_once, stage_input_siblings: the work units through a shared decode or
  entry now equal the unshared compile's (they asserted fewer before); the decode counts still
  show the sharing.

Also in this commit: crates/metal2vulkan-air/tests/api_surface.txt gains the four rate-map items
b31ce16c85 made public and left out of it (canon::rate_map_data BOUNDARY_MASK, GRANULE_SHIFT,
shader_physical_to_screen_integer, shader_screen_to_physical_integer): the_table_matches_the_source
failed on development without them, the same four lines at d5620581d5 (job m3-max-26042).

Verified, on msi, read from inside each job:
- m3-max-25972 (21ff252584, this change on d5620581d5 before the surface lines): cargo clippy
  --workspace --all-targets --all-features -D warnings exit 0; cargo nextest -p metal2vulkan
  -p metal2vulkan-air -p metal2vulkan-runtime --all-features: 5,645 run, 5,643 passed, 2 failed:
  metal2vulkan-air::api_surface (the four rate-map lines above, failing alike at the base) and
  golden_hashes_match_the_table.
- m3-max-26018: golden_hashes_match_the_table lists 360 changed cells at this change and 360 at
  d5620581d5, the same cells line for line, 180 in each of the nvidia-rtx50-linux and
  nvidia-rtx5080-laptop columns: development's own pending re-bless, none of this change's.
- m3-max-26001: budget::tests::spent_work_charges_another_meter_as_the_work_did passed.

Not landed beside it: the handle-table search as a loop (memory::handles::define_lookup), measured
and dropped. On the RX 7900 XTX (RADV, release, shader cache off), a synthetic kernel of 1,408
heap handle loads: the loop cut cold creation from 224.6 ms to 129.4 ms and the driver's code from
24,512 instructions (118,512 bytes, 28 spilled SGPRs) to 15,441 (78,004 bytes, 11), but a kernel
of 64 handle loads a thread over 2^20 threads took 33 to 38% more GPU time (median of 20 runs,
two rounds: 0.604 and 0.625 ms against 0.829 and 0.832 at 65 resident textures; 0.666 and 0.644
against 0.883 and 0.866 at 4,097). Creation is paid once and cached; the GPU time on every
lookup-heavy dispatch. The unrolled search stays.

Correction to c53ea4164e's message: its "reproduced ... with a synthetic 360k-FMA chain" was wrong.
That chain faults on another ANV defect, through a pipeline and through a shader object alike
(job m3-max-25842), so it is no reproduction of the serialized-index wrap.

SEMANTICS_VERSION 2093 -> 2094: an input near the work budget past the stage bound now gets the
bound's answer where it was refused at the work cap, so cached LimitExceeded(WorkUnits) refusals
must be recomputed. Landed before its own check (m3-max-26047) reported.
2026-11-13 10:36:44 -08:00
Anees Iqbal 77788d5321 FAST-PATHS: the ANV shader-object compile of the stage-bound kernel, measured to 20 GiB
The known-gaps entry for the ANV stage bound said the kernel of entry weight 1,565,083, created as
a VK_EXT_shader_object compute shader, held more than 8 GiB within ten minutes: that was the cap
of the job that measured it, not the compile's end. Measured again with room (job m3-max-25881,
the Iris Xe of RPL-P, ANV Mesa 26.2.6, vkCreateShadersEXT alone in a process under a 20 GiB cap,
the child's VmHWM sampled every 60 s): 2.0 GiB at 60 s, 2.1 GiB from 120 s to 360 s, 5.3 GiB at
420 s, then past 20 GiB, where the job's cap stopped it at 435 s of wall time (434 s of CPU, one
core). It did not finish, so the shader-object route is no way around the bound on this driver,
and the refusal stays.

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

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

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

RUNTIME_VERSION 2230 -> 2231.
2026-11-13 10:34:23 -08:00
Anees Iqbal 671140cc3c Pipeline creation log: a compute line names its required subgroup size and why its simdgroups are emulated
METAL2VULKAN_LOG_PIPELINES's compute lines (the making line before the driver's call and the
made line after it) now also name:

- the subgroup size the VkPipeline is created to require: `subgroup size required 32`, or
  `subgroup size any` where it requires none (the ComputeStage's required_subgroup_size, the value
  the runtime hands VkPipelineShaderStageRequiredSubgroupSizeCreateInfo);
- why the kernel emulates its simdgroups, where the runtime can tell: `simdgroups emulated (widest
  pin)` where the translator's census holds simd.emulated.widest-pin (the emulation in place of
  the pin to the device's widest mode), `simdgroups emulated (variant)` where the dispatch's
  variant is the emulated-simdgroups one (VariantKey::emulated_simdgroups), else `simdgroups not
  emulated for the widest pin or a variant`. The last is worded so because the runtime does not
  see the translator's tier: the device's subgroup model and the lockstep order choose the
  emulated tier too, and telling them apart would need a translator change.

Why: to read off a creation's own line whether a slow driver compile (a kernel that took 49 s on
ANV) was the widest pin's emulation, without a counter. Default-off, diagnostics only; the
translator is unchanged (env_vars.rs's description of the variable is the one line there).
WIDEST_PIN_STRATEGY in pipeline/sources.rs is shared with the log rather than spelled twice.

Docs: docs/API.md's paragraph on the log and the variable's description in env_vars.rs.

Verified (job m3-max-25986, msi, 60327894c6): cargo clippy -p metal2vulkan -p metal2vulkan-runtime
--all-targets --all-features -D warnings, exit 0; under --cfg m2v_cpu_icd, clippy of the runtime
exit 0 and tests::opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes
on lavapipe passed, which now asserts both lines carry `], subgroup size ` and
`simdgroups not emulated for the widest pin or a variant` (vsh_round has no simdgroup
semantics), with the creation_log unit tests (6 run, 6 passed).
2026-11-13 10:23:51 -08:00
Anees Iqbal 3969e96010 RUNTIME 2228 / ARTIFACT_FORMAT 518: a dispatch of an inert kernel records no Vulkan dispatch
The translator records, from the final SPIR-V (ModuleStats::inert, spirv/verify/effects.rs),
whether a kernel can affect anything outside its invocation: inert means no loop, and no store,
atomic or image write to any storage class but Function, Private or Workgroup, in the entry or
anything it calls. Anything not classified counts as writing. A module with a loop is never
inert, since a kernel that never terminates is the one case where skipping would change the
outcome. The runtime's compute record path (compute::record, shared by direct, threads, indirect
and the host-encoded ICB path) records no vkCmdDispatch for an inert pipeline and counts it in
WorkCounts::dispatches_skipped_inert. The encoder's fences, events, barriers and the command
buffer's completion are unchanged, and a skipped dispatch's reads take no hazard tracking. Metal's
answer is the same: nothing an inert kernel does is observable, and counter sampling is a
RuntimeGap. GPU-encoded ICBs don't go through record and still dispatch. API.md documents it.

Why: on the RTX 2080 (gbt-2080, m3-max-25739, pin 69) the guest's upload_uchar_buffer kernel is
empty (`ret void`, its one buffer argument unused) and is dispatched as 1-thread threadgroups:
3,661 command buffers of it alone, 6,853 dispatches, 11.7 s of GPU time over the walk (p50
0.11 ms, p90 1.0 ms, max 111 ms a dispatch).

Verified (ftconv, at 80a7769421 on 80ff4aafa7, step codes read inside the jobs):
- 25890 engine_inert (4 profiles x 7 kernels incl. the codec round trip): NEXTEST=0, 1/1.
- 25912 lavapipe --cfg m2v_cpu_icd runtime inert_dispatch: NEXTEST=0, 3/3. Counter: empty
  direct/threads/indirect +3, workgroup-store-only +1, loop and device-store +0 (fills write
  1..=N); a fence and an event around a skipped dispatch still order a later read of an earlier
  write.
- 25913 clippy --workspace --all-targets --all-features -D warnings (plain): CLIPPY=0.
Not yet run at landing: clippy under m2v_gpu and m2v_cpu_icd, rustdoc -D warnings (dispatched by
ftconv), the 2080 before/after run and a walk with the counter.

ARTIFACT_FORMAT_VERSION 517 -> 518 (the artifact codec carries inert); RUNTIME_VERSION
2227 -> 2228.
2026-11-13 09:58:44 -08:00
Anees Iqbal b36335e5ba FAST-PATHS: the ANV stage bound's refusal follows what the driver compiles
The known-gaps entry for DriverWorkaround::SerializedStageWrapsLargeModules now says the
refusal reflects what the driver can compile, not only the 20-bit serialization defect. On the
Iris Xe of RPL-P (ANV, Mesa 26.2.6), the consumer kernel of entry weight 1,565,083, created as a
VK_EXT_shader_object compute shader (which skips the precompiled round trip; no NIR
deserialization was reached), still held more than 8 GiB within ten minutes and did not finish
(job 25810, killed at its cap).

Measured alongside (radvcompile, ms01, counts only): 23% of that kernel's weight is dead under
its specialization; two emitted search routines inlined at every call make 31% of the live
weight; the Emulated simdgroup form costs at most about 5%. Neither shrinking nor splitting
brings such a stage within what ANV compiles in practical time and memory, so no class fix is
built. Docs only, no version bump.
2026-11-13 09:32:58 -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 c53ea4164e SEMANTICS 2091: on ANV, a stage past the serialized-object bound keeps the widest pin or is refused
Mesa's common pipeline runtime (vk_pipeline.c) serializes every compute stage into a precompiled
shader and reads it back before compiling it. nir_serialize names each object by a 20-bit index
(MAX_OBJECT_IDS 1<<20) checked only by an assert, so a release build wraps past 2^20 objects and
the driver faults inside vkCreateComputePipelines. On Intel Iris this took a consumer's host
process down on a large compute kernel (its translated stage: idx_table_len 1,096,128).

DriverWorkaround::SerializedStageWrapsLargeModules (keyed on ANV) bounds the stage's weight at
SERIALIZED_STAGE_WEIGHT = 786,432 instructions, every call counted as its callee's body. A module
over the bound is never handed to the driver: a kernel that emulated its simdgroups only in place
of the widest mode's pin compiles pinned to 32 lanes again (lower::simd::WidestPin::Kept), and any
other is refused as Unsupported::driver_defect(Feature::StageSize, ..), where Metal compiles it.
The gap is recorded in docs/FAST-PATHS.md's known gaps; REFUSALS regenerated, reach.tsv marks
StageSize rare, api_signatures carries the two new variants.

The bound's basis: 22 stages measured at 0.14-0.99 serialized objects per weight unit; 786,432 is
3/4 of 2^20 at the worst measured ratio of about 1.

Verified: the crash reproduced live on ms01's Iris (job 25723) with both the consumer kernel and a
synthetic 360k-FMA chain; test
a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused; checks job 25736 (msi): clippy
on the workspace, rustdoc, the full metal2vulkan suite, green. Not yet verified: the consumer's
Iris run at the next pin.

SEMANTICS_VERSION 2090 -> 2091: translator output and refusals change on ANV.
2026-11-13 09:05:44 -08:00
Anees Iqbal b31ce16c85 The uint2 rasterization-rate map overloads compile to Metal's decoder
A fragment shader's map_screen_to_physical_coordinates and
map_physical_to_screen_coordinates with uint2 arguments were refused
(Unsupported{RasterizationRateMap, NotImplemented} at the lowering of
Fragment::MapCoordinates). Canon now expands them beside the float2
overloads, reusing the float2 decoder:

- screen to physical: the float2 decoder at the pixel's centre (c + 1/2),
  converted to uint saturating (a NaN to 0), the conversion the float2
  index path already uses;
- physical to screen: the bits of the float (0 - offset) * reciprocal of
  the entry of granule c >> 5 on the axis's to-screen table; the
  coordinate's value within the granule is not read.

Both are Metal's answers as our probe rate_map_integer_overloads measured
them on an Apple M3 Max under macOS 27.0.1: 20,114 coordinates over four
maps (one of two layers), at each map's layers and two past them, every
one equal to these formulas. The arithmetic is float and the device's own
(owner rule 1); where a device's denormals differ from Metal's flushed
ones the existing PrecisionNote::DeviceDenormals reading applies, as for
the float2 decoder. The boundary byte of a table entry is compared on its
low seven bits, as Metal's decoder does (the probe's maps hit an entry
with the high bit set).

The decoder's Rust models gain shader_screen_to_physical_integer and
shader_physical_to_screen_integer. Lowering's MapCoordinates arm is now an
invariant error: canon compiles every overload before lowering.

Tests:
- bind::rate_map::apple_tests::metals_integer_answers: 1,561 of the M3's
  answers (apple_integer_vectors.txt: Metal's answers to our probe on our
  maps, no Apple binary) against the Rust models, each map's bytes
  checked by sha-256;
- tests::engine_rate_map::integer: the fixture rate_map_integer (kernel
  and fragment) compiles on every tested profile, robust and not, passes
  L3 with no RasterizationRateMap note; the interpreter's answers equal
  the decoder's arithmetic at every layer and two past, and Metal's on a
  map's own layers; and the translated kernel's answers equal the M3's
  recorded ones at all 587 recorded points of the maps' own layers, bit
  for bit;
- the fixture's four expectation rows go from the refusal to ok on all
  profiles; integer_rasterization_rate_maps_are_refused is removed.

docs/REFUSALS.md regenerated: the fragment select site leaves the
RasterizationRateMap sites.
2026-11-13 08:31:52 -08:00
Anees Iqbal 76f5b1b53f SEMANTICS_VERSION 2088: a loop's AIR unroll request reaches its OpLoopMerge
The two commits before this one carry a loop's llvm.loop unroll metadata from the AIR latch to
its SPIR-V OpLoopMerge: unroll.full and unroll.enable ask Unroll (clang's enable: fully where the
trip count is known, partly otherwise, SPIR-V's "to the degree possible"), unroll.count N asks
PartialCount N (SPIRV_VERSION 1.5 has it, held by a const assertion), unroll.disable asks
DontUnroll, and a count of 0 or no request asks nothing. Metal's compiler honours the same
requests; until now every OpLoopMerge carried None. It changes no answer, so it is not a
speed-for-accuracy choice. Translator output changes (SEMANTICS). docs/REFUSALS.md follows a
renamed site (structure_loops).

Verified by imgleak's runs: engine_loop_unrolling, one test per form (5/5 at ba2b803e57, 25358);
negative control with e7ea80f1bb's lower/view.rs, so no request is read: the four form tests fail
(unroll_count [[0]] where [[256, 4]] is expected), the no-request test passes (25376). Before the
rebase, clippy -p metal2vulkan all targets and features clean and 585/586 touched tests, the one
failure golden_hashes on kernel_threadgroup_float_bbox_atomics (unroll(disable)) and
engine/hnq_half_layer_composite (#pragma unroll), re-blessed at the next pin (25343).
Cold creation (driver caches off) and GPU time of the SR conv kernel 199ed, read in place on
um790, base b4a3e4e91c -> nuw e7ea80f1bb -> unroll (25521-25523): RTX 2080 creation 0.076 ->
0.083 -> 0.448 s, GPU 119.8 -> 120.3 -> 6.46 ms a dispatch (binary 23936 -> 106368 B); RX 7900
XTX 0.021 -> 0.116 -> 0.044 s, 12.7 -> 0.72 -> 0.71 ms; Radeon 780M 0.019 -> 0.043 -> 0.042 s,
over 6 s -> 6.08 -> 6.04 ms. On the 2080 the hint costs 0.37 s of cold creation once and saves
113 ms a dispatch; on the AMD devices it keeps nuw's creation and cuts code 15404 -> 12448 B.
Authored fixtures on all three: creation within run-to-run noise.
2026-11-13 08:09:54 -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 47fb2942e5 FAST-PATHS: on NVIDIA a no-copy object across two imported guest RAM chunks is a copy
What: a known-gaps entry for the copied-host-pages copy of a no-copy object
whose pages cross the end of a guest RAM's chunk with both chunks imported
(CopiedBecause::OverRamChunk). The consumer's boot makes one on the RTX 2080
and the RTX 3090: a 2 MiB Shared heap 0xde000 bytes before a 64 MiB chunk's
end. It names why only NVIDIA meets it and why no in-place form exists there.

Why only NVIDIA: the plan, not alignment. NVIDIA's held pointer imports cost
a submission nothing, so its plan is Plan::AHEAD: the device's thread imports
the RAM's chunks by pointer before the objects over them exist, and a
straddling object finds both imported. RADV and ANV take the listed plan
(the consumer's RAM has a dma-buf source and each held import costs every
submission there): a chunk is imported only for a copy over it, and an object
over chunks no copy imported takes its own import.

Routes judged:
- Sparse binding over both chunks' imports: VUID-VkSparseMemoryBind-memory-01096
  needs a memory type the sparse buffer takes; on the RTX 2080 (620.70.06)
  that is type 1 alone (device-local, 64 KiB alignment), every usage, with the
  host handle type or without, where host pointers import as types 3 and 4
  (system memory). The intersection is empty.
- A plain buffer binds one memory, its whole size inside it
  (VUID-vkBindBufferMemory-buffer-07459, -None-10741).
- Chunk ends that follow objects: each chunk is imported before the objects
  over it and binds others by the time a straddling one comes; no cut or
  extension puts the object in one memory without a page imported twice.
- An own import beside the chunks: of the pointer, a second import of the
  same pages (VK_EXT_external_memory_host issue 6); of dma-bufs, an alias of
  a pointer import Vulkan does not define (the beside route exists only for
  dma-bufs beside dma-bufs on the listed plan).
- The Managed route's GPU copy in (003dc10fee) rests on Managed's explicit
  synchronization; a Shared copy's coherence is the three-way merge at every
  commit and completion, which a GPU form would run over the host pages at
  each batch's start and end.

Verified on the RTX 2080 (620.70.06, um790, potluck m3-max-25500, at
65ca5fc387): tests::sparse_host_pages printed the types above ("the
intersection is empty: no bind"); host_ram_device's
a_heap_across_two_imported_chunks_is_a_copy_and_imports_nothing passed, its
copied-host-pages notice naming the chunk cause. Docs only; no code changed.
2026-11-13 07:59:51 -08:00
Anees Iqbal ac9a1ceb68 A GPU form's draw replay scratch lies in device-local memory
An execution of render commands recorded in its GPU form wrote its whole
scratch into the command buffer's upload arena, which on a discrete GPU
is system memory. The preprocess wrote its slot tables, arguments and
index entries there, the two merge passes' serial loops read and wrote
the prefix and block sums there many times a command, and every draw
read its slot tables and arguments there, all across the bus.

The scratch is now a buffer of the runtime's own in Private memory
(Device::scratch_buffer), held by the segment's encoder until the
command buffer completes. The host still writes the head alone (the
parameters, the resident root table and its set, the extents, the
encoder's buffers and a merged replay's header) into an upload region,
and a copy carries it into the scratch between barriers before the
range's copy and the preprocess. The command buffer's first submission
still points the table in that region at the resident set as it lies
then, before the copy runs. The table lies at a multiple of an entry in
the scratch (the buffer takes 32 more bytes and the scratch starts
where that holds), as RootTable::resident_fields needs of a table and
its set.

The translator is unchanged: the kernels still address every section
from the resident table's address, so the scratch stays one buffer.
The preprocess writes every byte the merge passes, the draws and the
trail read (every command's arguments, zero where it draws nothing; a
merged replay's index entries, prefix, block sums and draws), so the
unzeroed buffer needs no clear.

With the encoder trail on, the GPU copies the words the trail's line
reads (GpuForm::sections: the range copied, the merged draws, the first
2^20 commands' arguments and their index entries) into an upload region
at the scratch's offsets once the passes that write them ended, and
the line reads that copy. Off, nothing is copied.

WorkCounts::gpu_form_device_local_bytes counts the scratch bytes the
device placed in device-local memory (checked on the buffer's pages),
and the trail GPU-form tests assert it is non-zero where a GPU form was
recorded, with their texts unchanged.
2026-11-13 03:59:02 -08:00
Anees Iqbal 4489ebcaca The widest mode's calibration: two points of 56 words without a search 2026-11-13 03:45:33 -08:00
Anees Iqbal a9b4f8adae A pressured kernel takes the Emulated tier in place of the widest mode's pin
On a device whose compiler picks a kernel's SIMD width between a minSubgroupSize below 32 and a
maxSubgroupSize of 32 (ANV), the Direct tier's required subgroup size of 32 with full subgroups
compiles the kernel in the widest mode, where each lane's value takes four times the registers
of the narrowest one. A kernel with many live values spills there, and its driver compile grows
to seconds and past them; one real kernel never finished compiling on an Iris Xe.

The kernel stage now takes the Emulated tier (each simdgroup 32 consecutive threads, its
operations and lockstep barriers through workgroup memory and barriers, no required size) when
the device has those facts, the inlined entry holds more than 256 instructions, and an estimated
peak of live 32-bit words passes 36. Both tiers are exact; it is not a speed-for-accuracy choice.

- lower/simd/pressure.rs: the estimate. Live intervals in layout order (a value stays live across
  both arms of a branch, as on a SIMT device), a phi's incoming value used at the end of its
  predecessor, a value read in a loop held to the loop's end; widths are the lowered ones (a wide
  pointer from a pointer load or inttoptr is 8 words, and its resident-set search holds 14 more
  where it is made). Linear in the body, metered.
- lower/simd/mod.rs: widest_pin, WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS, the census entry
  simd.emulated.widest-pin, and the calibration table in the module docs.
- workgroup::check is atomic: divergent::plan returns its demotions, which join `cross` only
  once nothing refuses, so a kernel the Emulated tier refuses keeps its Direct tier.
- Runtime: WorkCounts::widest_pin_kernels_emulated counts such translations.
- docs/API.md section 3 states the rule and the calibration.

Calibration: an authored kernel (S steps, K live float accumulators, a lockstep pair in divergent
flow each step, P = 1 the accesses through a loaded pointer) on an Iris Xe (RPL-P, ANV),
vkCreateComputePipelines and GPU time, both tiers, one run each. At 34 estimated words or fewer
the two compile alike and the pin runs as fast or faster; from 40 the pinned compile took 1.6 to
24 times the emulated one and its GPU time 1.5 to 25 times (P1 K48 S32: 25.8 s vs 1.3 s compile,
1.985 vs 0.081 ms GPU). Answers were the same bits on both tiers in every run. The estimate took
5.2 ms of a 3.41 s release translation (225 MB peak RSS) of a 162,914-instruction kernel.

Test: engine_simd_lockstep's a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode
(the Iris profile: unpadded, below the floor and a low-pressure chain stay Direct, a fan of
live values takes Emulated with the census entry; the RTX 5080 laptop and RDNA3 profiles and a
kernel the Emulated tier refuses stay Direct).
2026-11-13 03:45:33 -08:00
Anees Iqbal 082fd229aa The fan-out row states the frame with wide triangles, drawn in parts
docs/FAST-PATHS.md row 50 gains the pieces lane's frame with wide triangles
(rate_mapped_pieces_host_step_wide), warm, at ed46f36fba's change (built at its pre-rebase commit
22b6697ba0) against the lane-only commit (8bd88bf0ac's pre-rebase 8da477a56c), each one run:

- RTX 2080 (NVIDIA 620.70.06): 30.9 ms in parts, 39.6 ms with flagged draws region by region
  whole, 68.5 ms under Exact.
- Radeon 780M (Mesa 26.2.6): 223, 373 and 566 ms, on a machine running other jobs.

23 of the 64 draws are flagged; 106,519 of their triangles lie between the first and the last
flagged one and are drawn region by region.
2026-11-13 02:43:42 -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 2d98657ca8 A Managed buffer's pages that a guest RAM's chunk imports hold are copied in by the GPU from them
What: a Managed no-copy buffer on a device without unified memory can have
a host copy that is its pages alone, because its own import would map pages
a live import holds or the device refused it. Where a guest RAM's chunk
imports hold all of those pages, it now keeps the pieces of those imports
(host_ram.rs RamOnDevice::pieces_of, ChunkPiece). The caller's resolver is
still asked once: its answer is kept for the pieces.
- Its copies in (as it is made, at a rebind, and each range
  did_modify_range names under AtSubmission) are GPU copies from those
  imports' VkBuffers, one per piece. They are held as a host copy
  (Keeps::HostCopy): nothing is staged, no bound applies, no submission is
  made. AtCommit still stages a named range on the CPU at the commit.
- New public WorkCounts, so a pass can tell the paths apart:
  - managed_bytes_staged_in, the bytes the CPU staged for copies in;
  - managed_bytes_copied_in_from_ram;
  - managed_pages_alone_refused, managed_pages_alone_over_imports and
    managed_pages_alone_unwritable, why a host copy is its pages alone;
  - managed_pages_in_ram_chunks.
- Tests: tests/host_ram_managed.rs, a buffer across a chunk's end with
  both chunks imported, under both policies. It checks the counts (pages
  alone over imports, held by the chunks, nothing imported, gate unasked),
  the bytes the GPU reads as the buffer is made and after a named CPU
  write across the end, and which path copied them.
- Docs: managed_copy.rs, managed.rs, buffer.rs, HostMemory::with_runs,
  docs/API.md, and FAST-PATHS row 51. Signatures blessed.

Why: such pages were staged by the CPU at every commit that took a named
range. That is a CPU copy and staging memory, on the commit's thread, for
bytes the device already maps through the chunk imports. Zero copy first.

Verified: not run at this commit. The 2080 equality tests and the bench
(before at the bench commit, after here) and lint follow on the rebased
branch.
2026-11-13 01:56:44 -08:00
Anees Iqbal 3b3739ce45 The idle sweep hands glibc's free heap back, not only a large making
glibc keeps what the process's threads free as free heap, its pages resident, until
malloc_trim hands it back, and only a large pipeline making's return called it. The memory
log of one Iris Xe cold boot at pin 66 (reims's 24852) shows the cost: 1.4 GiB of glibc's 4.0
GiB of arenas free at its end, after 3 trims in all, all from large makings.

Now each device's idle sweep thread also looks at glibc's heap every 5 s (HEAP_EVERY), whether
or not a sweep is due, and trims once the heap holds more than the floor (FREE_FLOOR, 256 MiB)
free above the least free a look read since the last trim, at two looks in a row
(idle_sweep::HeapLook). The least-free rule, not the bytes free alone, because glibc still
counts a trimmed chunk free: a plain fordblks rule would trim again at every look. A trim
counts in WorkCounts::heap_trims, as a large making's does. compile_memory gains heap_bytes()
and trim(), which return_free_heap now uses. Only on Linux with glibc; elsewhere the thread
makes no look and waits as before.

Docs: idle_sweep.rs and compile_memory.rs module docs, WorkCounts::heap_trims, the memory
log's paragraph in docs/API.md.

Tests: tests::idle_heap_look (the look's rule: trimmed at the second look, not again for what
a trim left, again for what was freed after it); tests::idle_heap_trim (device test, m2v_gpu
or m2v_cpu_icd, Linux gnu): 768 MiB of written 64 KiB chunks, all but one in 16 and the last
freed, then idle; the device's thread trims and the resident set falls by 512 MiB or more. The
lavapipe run and its negative control (no heap look: the test must fail) follow this commit.
2026-11-13 01:51: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 72562e193a The pre-import placement's docs, and its test compares refusals too
What: Buffer::texture_placement, TexturePlacement::InPlace, InPlaceRefusal and route.rs say
what the query answers before it makes images and what host_pages_texture_placement answers
before the buffer; docs/API.md, docs/HOWTO.md and the runtime README name the new query. The
test compares both calls' results, refusals included (a plane past the buffer's length is
refused as PastBuffer by both, not answered PastLength), and asks rows of 8 bytes too.

Why: lavapipe m3-max-24732: every shape both queries decide answered alike (CheckFailed by
pointer, Unchecked over dma-bufs, InPlace elsewhere), but the past-length shape is a refusal
of both calls, which the test unwrapped.

Verified: pending the lavapipe run.
2026-11-13 00:43:10 -08:00
Anees Iqbal 1ace4b5c46 The pre-import placement test counts the asking thread's images; signatures and refusals
What: tests/host_pages_placement.rs reads ObjectChurn::vk_images_made_this_thread (the
WorkCounts field it named does not exist); api_signatures.tsv blessed for
Device::host_pages_texture_placement and Problem::HostPagesBacking; docs/REFUSALS.md
regenerated.

Why: the test did not compile (m3-max-24729); the public surface changed.

Verified: pending the lavapipe run.
2026-11-13 00:43:10 -08:00