Commit Graph
512 Commits
Author SHA1 Message Date
Anees Iqbal 3b2443c8fe RUNTIME 2275: the unshared hold's budget is 2 ms only while the unshared queue committed within 50 ms, else 16 ms
The unshared-isolation hold kept other queues' batches to about 2 ms of expected work ahead of an
unshared (compositor) queue on the same VkQueue at all times. On the 780M that stretched Super
Resolution's command buffers (reims gbo-780m A/B with isolation Off: SR 27.78 -> 24.78 s; 5772 holds).
Now the 2 ms budget applies only while an unshared queue on that VkQueue committed within the last
50 ms; otherwise the budget is 16 ms (the intolerable-wait line), so a quiet compositor's first
frame waits at most about 16 ms plus one batch.

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

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

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

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

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

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

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

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

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

RUNTIME_VERSION 2272: folded groups split at a partial failure.

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

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

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

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

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

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

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

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

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

RUNTIME_VERSION 2268: compute encoders fold into one VkCommandBuffer.

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

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

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

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

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

From steelbrain/nvscroll (81915c28de..3cdbfe9256, 11 commits). Verified on potluck at 3cdbfe9256:
clippy gpu (28377), cpu_icd and plain (28379) 0; rustdoc -D warnings 0; api_signatures and
api_surface 15/15; lavapipe 478/478 (copy form unchanged there). 5080 A/B nvscroll-ab-233300
(kind t). The tip's 5080 device test and lane (b5080 batch 28393) are pending; the 2080 and XTX
runs wait for um790.
2026-11-14 00:03:40 -08:00
Anees Iqbal 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 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 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 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 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 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 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 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 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 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 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 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 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 a0e7b75ad6 The copy-in ledger row states the measured cost of AtCommit
What: docs/FAST-PATHS.md's managed_copy_in row gives the copy-in bench's
medians on the RTX 3090 (eGPU) and the RX 7900 XTX: the commit call and the
wall time to completion of 32 MiB commits under both values.

Why: a ledger row states the cost of its accurate form.

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

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

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

Verified: jobs in the report (lint both cfgs, the translator's fast_paths, the
runtime suite on lavapipe, managed_copy_device and the lane test on the RTX
3090 and the RX 7900 XTX, and the copy-in bench there before and after).
2026-11-12 23:57:16 -08:00
Anees Iqbal 7b77851a95 Runtime attachment images start at zero where an unstored DontCare load stays DONT_CARE
What: Device::new_planned_texture, which makes the runtime's own images (the
scratch image of separate depth and stencil textures, stand-ins, backings,
colour twins), starts an image with color or depth/stencil attachment usage
that a clear writes at zero (Start::ZeroUnpatterned) on a device whose
unstored DontCare loads stay the driver's DONT_CARE
(clear_reach::UnstoredLoads::DontCare: UnstoredDontCarePolicy::Driver on a
driver without DriverFact::UnstoredClearNoSlower). Elsewhere it starts as its
memory lies, as before. FAST-PATHS' unstored DontCare row and API.md say so.

Why: such a load reads what the image holds (a depth or stencil test, a
blend, a fetch). A Private runtime image started as its memory lay, and a
recycled one may hold a released texture's texels, of another process of a
consumer whose processes share the device. Devices that clear such loads read
nothing of it, so they pay no clear.

Verified: tests::unwritten_parts on lavapipe and Iris Xe (jobs in the
report).
2026-11-12 23:41:01 -08:00
Anees Iqbal ab56a1c88e Half division and square root at 16 bits under the 16-bit float controls
Rule 1: where the module computes half in 16 bits under the 16-bit float
controls (QuantizeForm::Controlled), the device's native form of a half
division and square root is its 16-bit OpFDiv and Sqrt, so those are the
only form there; elsewhere the float instruction rounded to half stays.

- divide::native: a half quotient under the controls narrows its operands
  (exact, they are halves), scales a divisor past 2^14 by 2^-2 and a
  denormal one by 2^10 into Vulkan's range for the 16-bit OpFDiv
  ([2^-14, 2^14], 2.5 half ulp), divides at 16 bits and widens. The
  scaling is exact but where the quotient rounds to zero or overflows
  anyway.
- math::float_fn: a half sqrt under the controls is the 16-bit Sqrt
  between exact conversions (Vulkan: inherited from 1 / InverseSqrt).
- narrow::computes_in_16_bits counts 16-bit FDiv and Sqrt, so the entry
  declares the controls (denormals kept, IEEE zeros, infinities, NaNs).
- ops: float_ty and f16_splat, shared with f16_binary.
- NativeDivision and DeviceArithmetic state the 16-bit bounds; docs/API.md,
  docs/FAST-PATHS.md, the narrow and half_hold module docs follow.
- Test: engine_half_hold's half_division_and_sqrt_are_16_bit_under_the_
  float_controls (Iris Xe and RADV: 16-bit FDiv x2 and Sqrt, none at 32,
  no exact narrowing, the exact answers on the interpreter, L3, the notes;
  lavapipe: the float forms, the same answers).

Verification: in the following potluck runs (FConvert count on hnq,
the half engine tests, spirv-val, clippy, the suite).
2026-11-12 23:20:51 -08:00
Anees Iqbal b8257d9c10 Runtime images whose parts no copy writes start at zero, never as their memory lies
What:
- Device::storage_over_buffer: a surface depth or stencil texture's
  shadow whose copies leave an aspect out starts ZeroUnpatterned in every
  storage mode (Metal reads 0 there); a tiled texture of more than one
  level starts Start::Zero, as a new texture of its storage mode does.
  Before, both went through new_image, which starts a Private image held.
- surface_depth.rs pass_image (the twin and an X32_Stencil8 view's
  private image) starts ZeroUnpatterned: no copy writes its stencil.
- Docs: storage_over_buffer's comment, surface_depth.rs module docs and
  FAST-PATHS.md's tiled later levels gap say what they now read.

Why: a Private image's memory may hold a released texture's texels, of
another process sharing the device (a recycled image). A kernel reads the
shadow's stencil through an X32_Stencil8 view, blits and samples read a
tiled texture's kept later levels, and a pass's DontCare stencil load the
driver leaves reads the twin's.

Verified: tests/unwritten_parts.rs (previous commit) fails without this
and passes with it; runs follow.
2026-11-12 23:06:41 -08:00
Anees Iqbal 41b5430f6a A completed command buffer's release posts the host imports it frees last to the free thread
On NVIDIA each vkFreeMemory holds the device's other vkQueueSubmits while it runs, and a
completed command buffer that let go of no-copy buffers' imports last freed them on the thread
that runs the next completed handlers, back to back and unpaced. Now, inside a completed command
buffer's release (free_thread::AtCompletion), an import whose free a deallocator or a keep-alive
waits for is posted to the device's free thread, which paces it as it paces a block's free; the
deallocator and keep-alive run there after the free, possibly after the command buffer's waiters
returned. The queue stays bounded at 64: a post that finds it full, the teardown begun or no
thread frees in place. An import nothing waits for is freed in place, before the waiters return,
as the caller may unmap its pages once they did. A program's own release still frees in the
release. No switch, nothing by vendor.

The paths: HostImport::drop (a pin's last hold at completion), and rebind's Retained, a command
buffer's hold of a releasable import's objects (Imported::let_go_at_completion). The posted
objects hold the device through holder handles (device/holds.rs), so the program's last drop on a
program thread waits for them, and the thread frees them unpaced once the holds stopped. Where the
program's last drop ran on a runtime thread, a posted import can hold the device's last share:
the teardown then runs on the free thread, which frees what is still queued in place of waiting
for itself and ends unjoined.

Counted: WorkCounts::host_import_frees_posted; memory_frees_paced counts their pacing.
docs/FAST-PATHS.md's known gap on NVIDIA's frees is updated, and the Deallocator doc names the
free thread.

Verified: tests::completion_import_frees (posted with a deallocator, in place with none, and the
teardown on the free thread), the runtime suite and lavapipe device tests in the check job, and
the 2080 bench before and after.
2026-11-12 23:03:45 -08:00
Anees Iqbal 158f9788b5 Half holding: the dot and mix bounds are NativeDot's and NativeMix's, a test, the docs
A half dot or mix already records NativeDot or NativeMix on every device,
so the DeviceArithmetic scan the previous commit added in compile.rs is
removed, and those two notes' docs (artifact.rs, docs/API.md's catalogue)
and docs/FAST-PATHS.md's device-gap row now state the 16-bit form and its
bound: a 16-bit dot of n lanes within (3n - 1) * 2^-11 * sum |a_i b_i| +
(3n - 1) * 2^-25 of Metal's chain (2n - 1 correctly rounded 16-bit
roundings beside Metal's n), a 16-bit mix within 2^-8 of its two terms plus
2^-22. narrow.rs's module docs, lower/arith's dot and mix comment, and
docs/ARCHITECTURE.md (the tidy stage and the spirv/ map) name the pass.

tests::engine_half_hold: a kernel of half min, max, clamp, dot, mix, a
loop-carried half and a thread array of half; on the Iris Xe and RADV
profiles it narrows no exact half, its four input roundings are its only
narrowings and its result's its only widening, its dot, mix and bounds are
16-bit instructions, no float variable stays 32-bit, it answers 33.25 on
the interpreter, passes L3 and records NativeDot and NativeMix; on lavapipe
(Converted) nothing is held and it answers the same.

Verification: not yet run (the build and tests follow).
2026-11-12 22:47:26 -08:00
Anees Iqbal 47ee9f4806 Fan a rate-mapped draw out through four copies where its triangles reach at most four regions
A host step's fanned-out draw went through one geometry-stage variant that
declares the output of the most copies (up to 16) for every triangle, though
most draws' triangles touch only a few regions. The declared output size is
what the 780M's geometry stage pays for.

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

Verified, release binaries, runtime_lane::rate_mapped_pieces and
tests::rate_mapped_fan_out, the command buffer's GPU time, cold then warm:
- Radeon 780M (Mesa 26.2.6), m3-max-24369, this change plus a scratch
  switch (never landed) drawing every fanned draw through the most copies,
  interleaved in one job: 4 copies 40.2/29.7 and 43.9/30.8 ms; the most
  copies 61.9/36.8 and 62.7/34.5 ms. Warm about 5.4 ms (15%) less.
  64 of 64 draws of four copies.
- Iris Xe (Mesa 26.2.6), m3-max-24317: 47.7 ms cold, 40.0 ms warm (40.5
  warm through the most copies in an earlier run); 64 of 64 of four copies.
- RTX 3090 (NVIDIA 620.70.06), m3-max-24316: 28.6 ms cold, 6.1 ms warm
  (6.2 ms before); 64 of 64 of four copies.
- tests::rate_mapped_fan_out on all three: 3 passed, 6 drawn of few
  copies, the fan-out's pipelines 3 ready plus waited, 0 made at the step.
The Iris and 3090 runs are of the same change at base 9c30ffd263; the
780M's at bfcd63c5e2. Clippy (translator, runtime, validation,
conformance, --cfg m2v_gpu and m2v_gpu_hazards, all features) and the
translator's fan_out and api_surface tests: m3-max-24351, at bfcd63c5e2,
0 messages, 20 passed. signatures.py --check passes; REFUSALS.md
unchanged.
2026-11-12 22:28:15 -08:00
Anees Iqbal 9e19371285 Pieces lane: default pipeline waits, the commit's time, the fan-out's makings taken
The lane's device ran under exact_answers(), whose PipelineWaitPolicy::Exact
made every pipeline a commit settles on the program's thread: with the
fan-out's begun at commit, the cold frame's commit took 86.9 ms on an RTX
3090 and 69.8 ms on an Iris Xe, a cost a consumer's device, under the
default Bounded waits, hands to the pool. The lane's device now makes them
under the default waits, as a consumer's does. Its line adds the program's
time in commit (the host's clock) and the fan-out's makings the commit
began that the step found made or waited for
(WorkCounts::rate_map_fan_out_pipelines_ready, _waited).

The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry
the three GPUs' numbers with the fan-out's pipelines begun at commit and
the copy loop (m3-max-24007 RTX 3090, 24008 Iris Xe, 24009 Radeon 780M),
command buffer GPU time FanOut against Exact, cold then warm:
- Iris Xe: 47.3 and 40.6 ms against 514.3 and 496.8 ms; commit 2.1 ms.
- Radeon 780M: 42.3 and 29.4 ms against 299.3 and 232.6 ms; commit 1.8 ms.
- RTX 3090: 44.2 and 7.5 ms against 71.2 and 65.5 ms, the step waiting for
  the fan-out's makings in the cold frame; commit 7.4 ms.
2026-11-12 21:02:13 -08:00
Anees Iqbal d4ab197556 Metal's command-buffer watchdog: a front batch 20.2 s without its timeline advancing fails as Metal's timeout
reims's 3090 boot after an Xid 109 (CTX SWITCH TIMEOUT) had its graphics queue's batch never
complete while the copy engine ran on: the staging probe completed 23 times in under a
millisecond, so the stall rule found the GPU running and nothing failed. The probe stays; beside
it each queue's front batch now has its own clock (stall::Clock::front_held), which runs while
its waiter's waits run out with it pending and stops whenever its queue's timeline advances,
whatever the probe answers. Past stall::WATCHDOG (20.2 s, the x86 AMD Mac's measured bound and the
largest of Metal's) the front fails as Metal's timed-out command buffer (GpuHang, code 2, named
exactly: its queue is known, no inference), the rest in flight as GpuRecoveryVictim, and the
generation is marked stopped (Stop::Watchdog), parked and recovered from as a wedge; the notice
says the watchdog stopped it. Counted: WorkCounts::watchdog_timeouts (wedges_declared keeps the
unanswered probe's stops).

Measured on the M3 Max (macOS 27.0.1, a Swift probe): a command buffer waiting for an event no one
signalled, shared or plain, failed with MTLCommandBufferErrorTimeout ('Caused GPU Timeout Error
(00000002:kIOGPUCommandBufferCallbackErrorTimeout)') 5.00 s after its commit, nothing of it run;
two such on one queue revoked it (the next fill failed AccessRevoked 0.24 ms after its commit,
a new queue ran). So the clock counts event waits, as Metal's does, and the watchdog's GpuHang
counts against its queue as any timeout (revocation.rs says so; the count is QueueCommon's and
carries over a recovery, as Metal's queue keeps it).

Tests (tests::stall): the stuck front with an answered probe fails at the hooks' 1 s bound, no
sooner, as GpuHang, parks the generation and runs the next command buffer; the answered leg
whose front advances within the hooks' 3 s fails nothing. Docs: stall.rs, revocation.rs,
docs/FAST-PATHS.md known gap, docs/API.md, the runtime README, WorkCounts, api_signatures.
2026-11-12 20:29:01 -08:00
Anees Iqbal 4906f145e3 Pieces lane: each frame cold, then warm; the fan-out row's cold and warm costs
The lane's one frame mixed two costs at the host step: the GPU work, and on
the first frame of a state the driver making the fan-out's probe and draw
pipelines inside the step (82.1 of the RTX 3090's 88.6 ms cold fanned-out
window). The frame now runs twice on the same device, cold, then warm,
each printed and checked, and the line adds the host step's time
(WorkCounts::host_step_nanos), the pipelines it made
(host_step_pipelines_made) and the time creating render pipelines
(render_pipeline_create_nanos).

The lane's docs and the fan-out row's cost cell in docs/FAST-PATHS.md carry
the three GPUs' cold and warm numbers after the probe spread, from one run
each (m3-max-23899 RTX 3090, 23900 Iris Xe, 23901 Radeon 780M), command
buffer GPU time FanOut against Exact:
- Iris Xe: 110.4 ms cold, 40.3 ms warm, against 514.6 and 499.1 ms.
- Radeon 780M: 84.3 and 34.7 ms against 299.5 and 231.7 ms.
- RTX 3090: 88.6 and 6.0 ms against 61.9 and 63.0 ms.
The guest-scale fanned-out figure, measured before the spread, is dropped;
its region-by-region one stands.
2026-11-12 19:41:07 -08:00
Anees Iqbal 0c6d7cc1c8 Pieces lane at a guest frame's scale, a GPU hazard; the RTX 3090's numbers
rate_mapped_pieces_guest_scale (FanOut) and _guest_scale_exact run the host
step's frame at six times the commands (384 commands, 5,508,648 indices,
about the 126 pieces a guest frame was recorded in on an RTX 3090), compiled
only under m2v_gpu_hazards and ignored by default.

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

Verified: clippy with --cfg m2v_gpu --cfg m2v_gpu_hazards over the runtime,
the translator and validation, 0 messages; the five lanes passed on the RTX
3090 (job m3-max-23744), built from the same lane source.
2026-11-12 18:54:28 -08:00
Anees Iqbal c3a002b71c stall test: the stopped test drains the parked queue before the process exits
On NVIDIA (620.70.06; um870's RTX 3090 and um790's RTX 2080) the stopped
test passed and its process never exited: under gdb (job 23736) the test
reported ok in 21.5 s, and the main thread then spun in exit(), in an exit
handler of libEGL_nvidia that tears down every VkDevice left and waits for its
work. The parked VkDevice's batch waits for the event's semaphore, which the
test never signalled. The test now keeps the stopping generation's functions
and semaphore and signals the reserved counter on the parked VkDevice once it
has checked the recovery, so its queue drains. It prints when the stuck
command buffer failed and when the next one ran.

docs/FAST-PATHS.md's known gap and stall.rs's module docs say a driver may
wait for a parked VkDevice's work at the process's exit (NVIDIA's did, for
that stand-in wait); a GPU that truly stopped is not measured there.

Verified: cargo fmt. The NVIDIA runs follow with this commit's archive.
2026-11-12 18:50:18 -08:00
Anees Iqbal 64982ac827 A GPU that stops with no loss from the driver fails its work and is parked
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and
every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the
program's command buffers waited without end.

The completion's waiters now keep a device-wide stall clock
(command_buffer/stall.rs): it runs while a wait ran out with its front batch
pending and stops whenever any queue's timeline advances. Past 10 s one waiter
probes the staging queue (NVIDIA's copy engine) with a submission of nothing
that waits for nothing, and for up to 2 s reads the probe's answer and the
stuck front's fence (a wait of no time) and timeline
(vkGetSemaphoreCounterValue); a loss either read answers takes the failed
wait's path at once. One informational message, metal2vulkan-stall-probe,
names the stall, the probe's answer and each read's last VkResult. A probe
answered, or a front that advanced, fails nothing and restarts the clock, so a
device that still makes progress is never failed whatever its work's length.
A probe unanswered in 2 s stops the generation: Device::mark_wedged marks it
stopped and lost, the wait fails as a lost device's (the oldest command buffer
as GpuHang, the rest GpuRecoveryVictim), and the line recovers; the
DeviceRecovered notice says the VkDevice stopped and was parked.

Parked: release.rs's door leaves every object of a parked VkDevice, the device
itself included; DeviceShared::queues_idle waits for none of its queues, and
its teardown returns before vkDeviceWaitIdle, keeping the instance. New public
query Device::is_parked(vk::Device) -> bool (no Metal counterpart), for a
consumer that holds the stopped generation's handles. Counters:
WorkCounts::stall_probes_sent, wedges_declared, longest_stall_nanos. A device
without a staging queue sends no probe (FAST-PATHS known gap, with the leak and
Metal's bounds: about 5 s on the M3 Max, 20.2 s and 16.1 s on x86 Macs' AMD and
Intel GPUs).

Tests (tests::stall, through the line's hooks: the clock's bound 200 ms, and
no probe seen answered): a command buffer waiting on its VkQueue for a reserved
event signal is pending; with the probe answered nothing fails and it
completes once the host signals; with none answered it fails as GpuHang, the
old VkDevice is parked, the new one is not, and a command buffer runs after.
Verification follows on this commit.
2026-11-12 18:50:18 -08:00
Anees Iqbal a52c30aff2 A recovery carries no-copy heaps and the textures placed in heaps
What: a heap over the caller's memory (new_heap_with_bytes_no_copy) is
carried as a no-copy buffer is: its own buffer made again over the same
pages (Buffer::carry_no_copy, now for a heap's own buffer too, kept among
no program resources; its pages keep what they were made of, a heap's own
included), its identity kept, the buffers placed in it carried at their
offsets (Buffer::carry_placed), their bytes as they are. The textures
placed in a carried heap, Private or no-copy, are made again there after
the heaps (Remake::Heap, Device::heap_texture_again): as the runtime's own
texture over the same range of the heap's bytes, through the making that
placed them (a texture buffer's buffer carried with carry_placed), sharing
the range's makeAliasable flag (HeapPlace::aliasable is an Arc), the range
handed to the newest image (HeapPlace::again, hand_range_to), so it is
given back once. A Private heap's texture reads as a new one, a no-copy
heap's reads the pages. The heap keeps its textures numbered as they were
(no forget_held); one the recovery leaves is forgotten (Numbered::forget,
Heap::forget_texture). A texture over a carried heap buffer is made again
over it, as over any carried buffer. Heap::carry answers what its bytes'
carry did with their contents and None where it was carried already, so
the notice counts no-copy heaps apart (", and N no-copy heaps with the M
buffers placed in them, over the same pages") and textures placed in
no-copy heaps apart ("N textures placed in the no-copy heaps carried"),
a Private heap's textures by storage mode. Docs: heap.rs, texture/carry.rs,
device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs,
API.md), the runtime README, and FAST-PATHS's known gap on lost texture
contents, which now names a Private heap's textures.

Why: reims's forced recoveries (3090 m3-max-23482, XTX m3-max-23547) left
44 no-copy heaps and 929 heaps' textures refused: 3424 refused texture
binds in one compositor's command buffers, 82 placements in those heaps
refused, the desktop mostly black after. Metal keeps a heap and what is
placed in it. The owner's call: a Private heap's textures are carried with
their contents lost, as new_texture's are.

Verified: a check of the runtime's lib and tests under plain and
m2v_cpu_icd was clean (m3-max-23688, on a probe commit of this change);
the lane that follows runs the tests.
2026-11-12 18:31:39 -08:00
Anees Iqbal 257b77bc21 Fan a host step's rate-mapped draws out to the regions in one draw
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.

At a host step, where the default `RateMapRegionPolicy::FanOut` holds and the device enables
`geometryShader`, `shaderClipDistance` and `vertexPipelineStoresAndAtomics`, the pass is now
probed first: each execution's commands, read once, are replayed in probe mode into a segment of
their own (one middle render pass per instance, the fan-out variant's geometry stage writing a
flag and a copy count per command and emitting nothing), submitted and waited for. A command
whose flag is clear (no triangle crosses w = 0 or touches more regions than the copies) is drawn
once through the fan-out variant over the whole target, its geometry stage emitting a copy per
region it touches; a flagged command, and every command after a barrier, after a draw that writes
memory or at a mesh or patch draw, is drawn region by region as before. A fan-out variant the
compile refuses falls back to region by region at the settle.

`RateMapRegionPolicy::Exact` (`DevicePolicy::exact_answers()`) keeps every draw region by
region. The FAST-PATHS row, the API.md bullet and a known gap (the encoder's own draws and the
draws commit records stay region by region) describe it; `WorkCounts` counts the probes, the
flagged and fanned-out draws and the probes' GPU time. `CommandBuffer::submit_waited` is the
loop check's waited submission, shared with the probe.

Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto aacde9f2ad, which applied
cleanly): the runtime's `rate_mapped` tests pass on an Iris Xe and a Radeon 780M (Mesa 26.2.6) and
on lavapipe, the fan-out test counting one probe, one flagged draw and six fanned out with pixels
equal to the region-by-region draw's; the pieces lane's host-step frame takes 111 ms of the Iris
Xe's GPU fanned out against 514 ms under Exact, 125 ms against 462 ms on the 780M, the probe 1.1
ms and 0.5 ms. Clippy, rustdoc, the API reference check, the surface and signature tests and the
fast-paths tests pass; the golden table's changed cells are development's drift, re-blessed there.
2026-11-12 18:28:19 -08:00
Anees Iqbal c4376d1042 canon::generic: a struct's generic pointers read through its address another thread object holds
What: canon::generic's cells (canon/generic/cells.rs) follow thread pointers through thread
memory. A slot of an alloca into which only the address of one alloca at one offset is stored
(a null among them or not), that no other write, copy, atomic or load at another offset or width
meets, of an alloca whose address no use but an access and address arithmetic takes, is
followed: a thread pointer loaded from it places what it addresses, and storing that address into
it is no escape. Places also derive through casts between the thread and the generic space, so
an object reached through a generic `this` is a cell too. The slots followed and the places they
lead to are found together, in rounds; a slot followed once and not after is never followed
again, and past the rounds' bound none is.

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

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

Verified, one run each:
- Before, at development with the fixture: engine_generic_pointers refuses generic_captured
  with GenericPointer(Memory) (m3-max-23363).
- The M3 Max (macOS 27.0.1) answers both new kernels as generic_slots: 100+t, 201+t, 1 for t<4
  then 4, and t (m3-max-23383).
- engine_generic_pointers and the metal2vulkan-air suite pass, 561 tests (m3-max-23381).
- The metal2vulkan and metal2vulkan-air suites (m3-max-23401): 4060 of 4063 pass; the three
  that fail are the golden tables, which development re-blesses: golden_hashes, the engine
  inventory's two new rows (generic_captured and generic_functor, ok in every cell), and the
  engine printout of generic_pointers.ll (tests/air_input/generic_pointers.txt, recorded under
  LLVM 21).
- runtime_lane::generic_pointers on lavapipe, both tests, the five struct kernels among them
  (m3-max-23413).
- fmt, clippy with all features and rustdoc (m3-max-23436, the same patch on development
  6772e9aa8e); clippy under --cfg m2v_gpu and --cfg m2v_cpu_icd at this tree (m3-max-23451).
- macOS 27's 590 MPS functions that name addrspace(8), release, RDNA3 profile (m3-max-23256
  before, m3-max-23382 after): GenericPointer(Memory) 47 -> 6. Of the 41 rows that move, 36 now
  stop at Tensors (a cooperative left input), 4 at Tensors (fp8 matmul2d) and 1 at a linked
  function the command line cannot supply; no other row's outcome changes (155 translate at
  both). Slowest 0.68 s, largest 189 MiB. The 6 left pass the struct's address to a visible
  function the pipeline links (the gap's documented case).
2026-11-12 17:28:54 -08:00
Anees Iqbal 56a8aa5283 did_modify_range: a commit takes the ranges of the buffers its command buffer uses, copied in on its queue
What: Modified::take_at_commit takes, at a commit, only the noted ranges of the buffers the
command buffer may use (CommandBuffer::may_use: its encoders' uses name the buffer or made it
resident, a command may reach memory no use names, its last encoder's end is still with the
lowering thread, or nothing owns the buffer's key); the rest stay noted, in their order, for a
commit that uses them (managed.rs's Noted). Their copies in, and every other upload into a
buffer the program may have read (Buffer::upload, copy_in_from), register as uploads
(FirstMoves::register_upload, FirstFill::reached_only): a batch takes one only where its
commands may reach the buffer, on a device with a fill queue or without one, never because it
takes every other fill; an internal submission takes it too, and a batch that needs no GPU work
leaves it waiting. FillTake::Owned carries the batch's reach for that. So the copy lands on the
user's queue, after the command buffers before it there, before the commands of the first that
uses it: Metal's shape. Docs: managed.rs, managed_copy.rs (the 'as on Metal' line now says what
holds: only two queues' unordered uses of the buffer race the copy), first_move.rs, API.md, the
runtime README and FAST-PATHS.md's managed row.

Why: any queue's commit took every noted range, and any queue's next submission took its copy in
(before f62966f4f0 the call registered it, with the same take), so a range a thread named after
committing a command buffer that reads the buffer could land, on another queue's submission,
before that command buffer ran: on an RTX 3090 round 0 of a buffer read round 2's bytes, a silent
wrong result on every discrete GPU.

Tests: managed.rs's take rule (a_commit_takes_the_noted_ranges_of_the_buffers_its_command_buffer_uses)
and first_move.rs's (an_upload_goes_only_with_a_batch_that_reaches_its_buffer), on every device;
the parent's named rounds on two queues and on one, on the RTX 3090 before and after (job ids in
the report). RUNTIME_VERSION wants a bump at landing.
2026-11-12 17:18:01 -08:00
Anees Iqbal 9b308145e9 A texture buffer goes on over its carried texels; the notice counts lost textures by storage mode
What: Texture::carry makes a texture buffer of new_texture again over its texels' buffer where the
recovery carried that buffer (texture_buffer_over, the runtime's own ID use), so a Shared one
reads the bytes the buffer carry kept; where the buffer was left it is made new as before.
Remade splits the textures whose contents were lost by storage mode (Shared, Managed, Private or
memoryless), and the recovery's notice says those three counts. carry.rs says how kept bytes are
read: Vulkan makes the content of external memory imported to a lost device undefined (vkspec
5.2.3), read as the hung work's writes possibly landing in part; once the lost import goes, the
pages are only our or the caller's memory. Docs: texture/carry.rs, carry.rs, the
DeviceRecovered cost (degradation.rs, docs/API.md, equal), the runtime README, and a known gap in
docs/FAST-PATHS.md: a recovery loses the contents of textures whose only copy is device memory
(new_texture of any storage mode), textures over carried pages keeping what their buffer keeps.

Why: the consumer asked for Shared textures' contents kept across a reset. A texture of
new_texture of any storage mode has no copy outside its image in the lost VkDevice's memory, so
keeping it would need a CPU copy at a cost to every frame; decided against for now, and recorded
as the known gap. Textures over carried pages already keep their bytes; texture buffers did not.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes).
2026-11-12 16:27:36 -08:00
Anees Iqbal f5d97f8e95 Cut a rate-mapped execution's big draws into ranges of their indices
A piece bound by command count, or by whole commands, still lets one command
hold unbounded work: the sample's largest executed command draws 161,820
indices, times its 2,074 regions about 2.5 times the old piece work in one
draw. Where an executed command's draw in a rate-mapped pass would alone hold
more than the piece work, it is now drawn as consecutive ranges of its indices,
each a draw of its own that a piece may begin before. That draws what Metal's
one draw does only for an indexed list (points, lines, triangles: Metal never
restarts a list) cut at primitive ends, of one instance, whose pipeline reads no
[[primitive_id]] and writes no memory; every command of the sample is such a
draw. Ranges are sized by the most region draws a draw of the execution made so
far (the most a plan holds before any), an even count of primitives so 16-bit
ranges keep 4-byte offsets. Any other draw rides whole: FAST-PATHS' known gaps
now name them, with the encoder's own draws, as able to pass amdgpu's job
timeout and NVIDIA's context-switch timeout.

PIECE_WORK halves to 2^26, so a piece of cut draws holds under 2^27: about
56 ms of Iris Xe at a trivial vertex function, 35x under 2 s.

WorkCounts::rate_map_index_ranges counts the ranges past the first; the
signature table gains it and the four piece counters. A runtime device test
draws eight commands of a twice-drawn blended triangle grid through 32-bit and
offset 16-bit indices over a falling map, and checks the execution cut under a
small piece work against the uncut execution and the encoder's own draws, byte
for byte, with pieces and ranges counted.

Unverified at this commit: the compile check and device runs are next.
2026-11-12 16:03:38 -08:00
Anees Iqbal a610b58b8a A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render
commands the CPU writes) whose pipeline the replay began itself and that was still being made at
the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline
exists, so every encoded draw runs.

Now the replay at commit stops there, keeps the making on the command buffer
(CommandBuffer::leave_unmade), and the pass takes it into the makings its host step waits for
(DeferredPass::left_for_makings): the commit leaves the pass to the host step with its
pipelines pending, as it already did for a pass whose settled makings were still being made, and
the step records it from the records as they stand then once the making lands. A replay inside
a host step waits for its making until made, on the step's thread. record_on_gpu declines to
the host step the same way. The commit still returns at its bound at most.

Removed: DrawDroppedStillMaking, WorkCounts::draws_dropped_still_making,
CommandBuffer::drop_late_draw, RenderLowering::drop_late_replayed_draw, the execution's encoder
place that only named the dropped draw, and the open-gap text in FAST-PATHS row 43, API.md (the
bullet and the catalogue entry), the runtime README and the PipelineWaitPolicy docs
(api_signatures.tsv -2). The IndirectCommandCheck and executed-commands docs name the new case
in which an execution read at commit is read and checked again in its host step.

The gap's test flips: a_replayed_draw_whose_pipeline_is_still_being_made_at_its_bound_renders_once_made
(commit returns after the bound and before the 10 s watchdog; the command buffer is not complete
a second past its bound while another queue completes; once the hold goes it completes with the
rectangle drawn and nothing dropped). Checked by the lint and lavapipe jobs reported with it.
2026-11-12 16:01:25 -08:00
Anees Iqbal b4eaf4caa7 Keep the replayed draw's test as the open gap's, and name the gap by the replay's own wait
The lavapipe run (m3-max-23046) showed a draw of a commit-time replay of
CPU-written records dropped at the bound: the replay waits for that
making itself, which the settle did not leave to the host step. That is
the open gap this change keeps; its test asserts the drop, and the docs
name the gap by the replay's own wait.
2026-11-12 15:41:59 -08:00
Anees Iqbal 91dbc91bbc Hold a command buffer for its draws' and dispatches' makings instead of dropping them
A dispatch whose pipeline was still being made 4.5 s after its command
buffer's commit recorded nothing, and so did such a draw. Metal makes a
state's pipelines inside its creation, so every draw and dispatch it
encodes runs: a dropped dispatch leaves wrong results (a guest's path
tracer dropped 45 dispatches behind a 116 s compile on the RX 7900 XTX),
and a dropped draw leaves content drawn once (a cached shadow map, a
glyph atlas) without it. The owner's rule: no switch may break Metal's
contract, so the dropping form is removed, not kept behind a switch.

A batch's host step now waits for every making its segments record,
past the bound too (Segment::steps_after_pipelines; the scheduler's
StepWaits loses its `until`, and Segment::holds goes): the batch stays
in its queue's line on the scheduler's thread, which no call waits for,
and records the draws and dispatches once made. Held batches still give
way to other queues' later commits that share no fence. `commit` waits
for no making but a pass that executes render commands the CPU writes,
until its bound, and leaves that pass to the host step past it. The
pending dispatch, tile dispatch and pending draw recordings wait until
made. DispatchDroppedStillMaking, its counter and catalogue entry, and
CommandBuffer::drop_late_dispatch are removed.

One drop remains, an open gap named in FAST-PATHS and the notice: a draw
of an execution's replay whose pipeline the replay itself began making,
of a key the commit's settle did not foresee, still being made at the
bound (DrawDroppedStillMaking, now that case alone). That case is the
next change.

Tests (device, rewritten): a draw, a replayed draw and a dispatch whose
makings are held past the bound each complete once the making lands,
drawn or written, nothing dropped, while another queue's command buffer
completes meanwhile and the held one is still not complete a second past
its bound.
2026-11-12 15:41:59 -08:00
Anees Iqbal bcfec16960 A rate-mapped draw skips the regions its viewport and render area leave no pixel
Each draw of a rate-mapped pass was recorded once per region of the map's plan, even where the
region's scissor, cut to the pixels whose centres lie in the guest's viewport and to the render
area, held no pixel. Such a recording shades nothing (the scissor test discards every fragment),
and its vertex function repeats nothing observable (a plan of several regions refuses a vertex
function that writes memory), so it is now left out. Where the cut leaves no region a pixel, the
first region alone is still recorded through its empty scissor, so the vertex function runs as
Metal's does. A draw whose viewport covers part of the screen now records only the regions it
reaches; one over the whole screen records what it did.

The new lane test draws the case's fullscreen triangle over a 256-pixel map at the falling
quality with a viewport over the screen's left quarter: fewer regions than the whole screen's,
from an indirect buffer region by region, and the direct (batched) draw shades bit for bit the
same pixels, inside the left half of the physical columns.
2026-11-12 14:37:06 -08:00