Commit Graph
1348 Commits
Author SHA1 Message Date
Anees Iqbal ab139e4b6e RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line
writes for its own failures when it refuses a library or pipeline creation,
where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written).

- The CLI's bundle writer moves into the library as the hidden crate-root
  module metal2vulkan::repro (feature serde), shared by the binary and the
  runtime. A bundle's directory is named by its content
  (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed,
  so an identical failure is written once, across threads, processes and
  runs. The CLI's own bundles keep their files (input, profile.json, the
  descriptor files, repro.sh, repro-command.txt, failure.txt); only the
  directory's name changed, so a bundle written before still replays.
- The CLI takes --device FILE in place of --profile: the JSON of a
  DeviceDescription and DevicePolicy (ReproDevice), which builds the
  runtime's own compile device.
- The runtime hooks each creation where its refusal returns: a library of a
  metallib, a function's lookup, every compute and tile state
  (ComputePipelineState/TileState::create_adding: creations, added binary
  functions, archive adds) and every render state
  (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented
  and Compile refusals but a cancelled compile and a name the library lacks
  (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the
  library's bytes, device.json, the request as the CLI's options and
  descriptor files, and failure.txt with the call, the refusal and what the
  command does not replay. That list comes from a full destructuring of the
  compute, tile and render descriptors (and the stage functions): a new
  descriptor field fails to compile in repro.rs until it is replayed or
  listed.
- Bounded: at most 32 bundles and 256 MiB per process; past either nothing
  more is written and one line says so. Written on the refusing thread; the
  call returns the same refusal; a write failure is said once. Each bundle
  is named in one line through the device's message sink (id name
  metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde.
- Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later
  variant, driver VkPipeline makings, Metal-source libraries.

Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime
README's Errors section, the CLI help.

Tests: runtime CPU tests of the bounds (a tally with the seam's limits);
a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor:
one bundle with the expected parts and command, device.json rebuilding the
runtime's compile device by profile fingerprint and answering the same
refusal, none for a second identical refusal or a missing name, none
without a directory); CLI tests replaying library-written runtime bundles
(compute, and render with a vertex descriptor) through repro.sh to the same
FALLBACK, and --device compiling what --profile does.

Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli,
api_surface and api_signatures 25 passed; runtime repro tests 9 passed;
clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features
0. Lavapipe (m3-max-32978): repro_device writes one bundle that the
CLI replays to the same refusal; a second identical refusal writes
nothing.
2026-11-15 10:14:52 -08:00
Anees Iqbal 0b6f72ac29 RUNTIME 2362: Scheduler: a copy queue's command buffer keeps commit order behind a held batch
What: a head on a queue made for copies (Device::new_command_queue_for_copies) no longer
goes before an earlier-committed batch of another queue it conflicts with because that
batch gives way. The order's comparator (scheduler/mod.rs is_behind) treats a held batch
that gives way as one that keeps its place when the head's queue keeps commit order
(Standing::commit_order, from CommandBufferShared::keeps_commit_order: the queue's kind,
set by the copy queue's constructor). Such a head waits behind it in the scheduler when
tracker::ordered says the two conflict, whether the held batch waits for its pipelines'
making, a host step or its checks. Once the held batch is submitted, the tracker orders the
copy after it on the GPU: the copy engine's VkQueue waits for the other VkQueue's timeline,
or a barrier where they share one. There is no wait on the host. A copy that shares nothing
with the held batch still goes. Unchanged:
- plain queues keep the give-way exactly as before (order.rs, Held batches give way), so the
  Iris Xe compositor case is untouched;
- a held batch ON a copy queue stands to a later plain queue's commit as any held batch does
  (the rule is the head's);
- a batch held for an event value or a binary semaphore's signal the program has not given
  holds back no copy (Stops).

Why: the copy queue's documented promise is that a copy reading what another queue's
command buffer committed before it wrote waits for that command buffer on the GPU. A
command buffer of a blit and a new pipeline's first dispatch, held for the pipeline's
making, gave way to a copy committed right after it on the copy queue. The copy ran first
and read the bytes from before the blit: the consumer's copy queue on an RTX 2080, and a
plain second queue on MoltenVK, round 0 only, always the new pipeline's first dispatch. The
give-way rule (b46459080d) stays for plain queues, where real Macs disagree; the copy queue
is a runtime extension whose contract is ours.

Docs: order.rs (But not to a queue made for copies, No deadlock), the scheduler's Tracking
paragraph and is_behind, new_command_queue_for_copies (what holds exactly, the reverse
direction, and that on a device that answers None a plain queue used instead gives way, so a
caller orders such a copy with an event), the runtime README's copy-queue and pipeline-wait
passages, docs/API.md's pipeline-wait passage, pending_dispatch.rs,
WorkCounts::heads_held_for_earlier_commits, and the hold_sites module docs.

Verified: lavapipe before (the previous commit's copy-queue leg) and after, reported with
the tip.

Verified (lavapipe, the copy queue on the round robin VkQueue): at
87ab2111b0 (m3-max-32839) the copy-queue leg fails, reading the bytes
from before the blit; at 404352e262 (m3-max-32840) hold_sites,
dispatch_pending, pipeline_wait_order, held_step_order and copy_queue
16/16, clippy m2v_cpu_icd 0.
2026-11-15 09:19:49 -08:00
Anees Iqbal 5ba7afd9d4 RUNTIME 2360: Shader cache: no default directory makes a memory-only device, never a failed one
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere),
default_directory answered Err and CacheSetup::of turned it, and any failure to
open the default path, into Error::ShaderCache, so every device creation and
adoption failed. Metal never fails device creation over its shader cache, and
the default is the runtime's choice, not the caller's (owner rule 2).

- The Windows default is %LOCALAPPDATA%\metal2vulkan (the local application
  data folder, read from the environment; no new dependency). XDG_CACHE_HOME and
  USERPROFILE are no longer read there.
- default_directory takes its environment as a closure (CacheSetup::of_in), so
  a test feeds its own without touching the process's.
- Where the caller names no directory and the default does not exist or cannot
  be made or written, the device keeps its cache in memory alone: the Store has
  no directory, every lookup is absent, every write is refused with no
  filesystem call, the scans do nothing, and writers ask has_directory first so
  nothing is encoded for it (a translated function still is: its encoded length
  weighs it in the memo). The device says so once as it is made, as the existing
  degrade notice ShaderCacheEntryNotWritten naming why; each entry it does not
  write counts in write_failures. The driver's pipeline cache data is not read
  back, and the device checks' verdicts are not encoded.
- A directory the caller names that cannot be used is still Error::ShaderCache.
- Device::shader_cache_directory answers Option<&Path>: None for such a device.

Docs: the shader_cache module docs, ShaderCacheOptions::directory,
write_failures, Error::ShaderCache, the degradation's declaration and its
docs/API.md entry, the runtime README (Windows default, error table), HOWTO,
create.rs's list of environment variables. api_signatures re-blessed;
docs/REFUSALS.md regenerated (a refusal's site function renamed).

Tests: tests::shader_cache's default-directory and no-directory-store unit
tests (plain gate), and the lavapipe/GPU device test
shader_cache_no_directory: a device made with an empty environment and no
caller directory is made, has no directory, makes four render states with two
functions translated once, writes nothing, and its notice is heard once.

Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and
degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0;
m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and
in_place_check, including the no-directory device test.
2026-11-15 09:10:25 -08:00
Anees Iqbal 8ba1fd7d67 RUNTIME 2358: Host RAM copies: a repeated copy takes the plan kept of it, where its buffer, the device's figures and its imports are the plan's
A copy by dispatches spent most of its encode on work that depends only on its runs, its
buffer and the imports it reads through: cutting the runs into pieces, the chunks' ranges,
the pieces' places in the imports, the table and the dispatches. A consumer repeats the same
copy (a surface's same runs) every frame.

Such a copy's plan is now kept per RAM per device (RamCopies, which ChunkKeys becomes):
direction, runs' form, buffer key (object id, device generation, length), the runs, the
blit_at VkBuffer and byte, the device's figures (window, alignment, workgroups, array), the
span and total, the chunk ranges and joined ranges, the import serials in order with the
chunk-to-imports map, the table and the dispatches. The next copy with the same key (runs
compared element by element, no hash trusted) takes the table and dispatches where:
- blit_at gives the same VkBuffer and byte (a rebind or a new VkBuffer plans anew);
- the device's figures are the same;
- every chunk takes at once (copy_take Now for all; else the full path stages it);
- copy_imports gives the same imports, by serial number, in the same order, with the same
  map. RamChunk now carries a serial from a process-wide counter, never reused, so a chunk
  released, given back or imported again has a new one. Plans keep numbers, not Arcs.
Every step a copy takes each time still runs: blit_at, copy_wrote, the takes, copy_imports,
the upload, the binds, the uses and the counts. Where the plan does not hold, what it took
(blit, takes, imports) goes to the full path, which takes none twice: a chunk released
between the takes and the imports plans over the imports it got.

Bounds: 8 plans and 4 MiB per RAM per device, the one taken longest ago dropped first; a
plan over 4 MiB is not kept. Counter: WorkCounts::host_ram_copy_plans_reused.

stages() is split into takes() and Takes::staging() so both paths share the takes;
record_dispatches() is the dispatch tail both paths record through.

Tests: unit, the bounds; device (lavapipe): a repeated copy takes its plan and a run
changed, the other direction, another buffer offset, another buffer, a rebound no-copy
buffer each plan anew; a chunk let go of (idle, given back) makes the next copy plan anew
and the one after take the new plan; a new use of the RAM plans anew; a kept plan's copy
is ordered after a fill of its buffer and after a scatter into its pages in the same
command buffer.

The plan also holds the buffer's host pages weakly and compares them by
identity: lavapipe gave a rebound buffer's new VkBuffer the destroyed
one's handle value (m3-max-32579), so a handle match alone cannot see a
rebind. The plan names no VkBuffer; the binds take the live one on every
call. The pages copy's kernel is looked up only where a copy goes by
dispatches, as before. The layer bench says how many copies a kept plan
recorded.

Measured (release, msi lavapipe, m3-max-32581, before d0ef5e0145 and
after, one job, median us a call over 8100 single-page runs): layer in 1
chunk 373.9 -> 139.1, over 128 chunks 859.8 -> 323.4; at 0bae61504a
(m3-max-32615) 200 of 200 copies by a kept plan.

Verified at 0bae61504a (m3-max-32610): host_ram tests on lavapipe
103/103, clippy plain, m2v_gpu and m2v_cpu_icd 0, rustdoc 0. Negative
control (m3-max-32579): with the serial compare removed, the let-go test
fails (a reuse happened).
2026-11-15 08:30:44 -08:00
Anees Iqbal 135df83657 RUNTIME 2357: Textures over buffers: an image over a buffer's texels may take its whole placement; an unobserved buffer lies on the linear image alignment
Intel's driver for the UHD 630 on Windows (101.2145) rounds a small
linear image's VkMemoryRequirements size up to its 4096-byte alignment:
BGRA8 73x8 at a pitch of 320 has a 2560-byte subresource and a 4096-byte
image, 16x16 1024 -> 4096, RGBA16F 88x8 6144 -> 8192. The in-place check
(linear_plan::aliases) bounded the image's size by the buffer's VkBuffer
bytes from the texture's first, so a texture over a padding-unobserved
Private buffer of exactly its rows was a shadow, and a buffer placed on
256 bytes failed the image's 4096 start too.

The room an image over a buffer's texels may take is now the buffer's
own placement from its byte 0 (Buffer::memory_room: bytes no other
resource is placed in), in texture.rs's two aliasing checks and the
two-plane YCbCr check. A buffer whose maker declares its padding
unobserved is placed on the device's linear images' memory alignment
(Device::linear_image_alignment: one probe image's alignment, a 64x8
R8G8B8A8_UNORM linear image, kept for the device), its start and size
whole units of it; the recycler's BufferMaking keys on that alignment,
and a device recovery's carry places such a buffer so again. Where the
alignment is 256 or less (RADV, lavapipe, MoltenVK), every placement met
it already and nothing changes. Cost: at most alignment - 1 bytes more
for each such buffer on the UHD 630, plus the start's padding.

Still a shadow: an image the driver sizes past its alignment's rounding,
R8 4096x1 over 4096 bytes taking 16384 on the UHD 630 (FAST-PATHS known
gaps), and on that driver textures over buffers that do not declare
their padding unobserved where the image is larger than the placement or
starts off 4096.

Tests: padding_unobserved's a_texture_whose_rows_fill_an_unobserved_buffer_is_in_place
makes a 73x8 BGRA8Unorm texture at the device's own linear pitch over a
Private padding-unobserved buffer of its rows alone and asserts the
placement lies on the alignment, the texture is the image over the
buffer, and no shadow is counted.

Docs: BufferDescriptor::padding_unobserved, the runtime README entry,
FAST-PATHS known gaps.

Checks: on the UHD 630 (Windows, m3-max-32630, at the same diff before
its rebase), padding_unobserved's new test passed: 73x8 at a pitch of 320
over 2560 bytes, 4096 of room on 4096, an image over the buffer, 0
shadowed. At cb7660c625: clippy plain, m2v_gpu and rustdoc 0
(m3-max-32602); lavapipe touched set 153/153 and m2v_cpu_icd clippy 0
(m3-max-32603).
2026-11-15 08:28:49 -08:00
Anees Iqbal f4c9902c63 FAST-PATHS: the cold Shared making's range on this tree is 95-97 ms
The previous commit gave 92-97 ms; m3-max-32595's two runs of this tree
made the cold round in 97.0 and 94.6 ms.
2026-11-15 08:15:57 -08:00
Anees Iqbal 9ee682344f FAST-PATHS: the 16 KiB allocation's measured cost
A 16385-byte buffer's VkBuffer requires 32768 bytes where 16400 did, on
RADV PHOENIX and lavapipe (m3-max-32595, m3-max-32558). On the Radeon
780M, release, exclusive, the base (d2ee5bca5b) and this tree run twice
each in one job (m3-max-32595): 1000 buffers of 16 KiB + 1 to 4 MiB
required 763.3 MB against 754.8 MB and took one more 64 MiB block in
their second round; making them took the same time within the runs'
spread, Shared ones cleared on the host and Private ones' first fills
alike.
2026-11-15 08:15:57 -08:00
Anees Iqbal a1175662e7 RUNTIME 2355: Textures over buffers: a buffer of 16 KiB or more holds Metal's allocation, a heap's buffer its heap
A texture over a buffer whose texels run past the length was always a
copy: a shadow image or a staged texture buffer whose bytes past the
length lay in a tail of its own. Metal's texels there are the
allocation's: a buffer of 16 KiB or more holds its length rounded up to
16 KiB (allocatedSize), zero when made, and a heap's buffer reaches its
heap's end, whose bytes are the heap's.

Now a buffer the device makes in the Metal address space with a length
of 16 KiB or more takes that allocation (buffer.rs's metal_allocation):
its VkBuffer and placement are its length rounded up to 16 KiB, which
its first fill clears with the rest (Buffer::clear_first: the host's
clear of a Shared or Managed buffer, the device's fill of a Private
one), with no command of its own. A texture keeps in place the bytes the
buffer's memory holds for it (Buffer::texel_reach: the allocation, a
heap's buffer's heap to its end, a no-copy buffer's length), so such a
texture is made as one inside the length is: an image over the buffer's
memory where the device makes one, a texture buffer viewed in place. The
shader-visible ranges, robustness, copy reach (a blit past the length is
still refused) and exported sizes stay at the length. Heap, no-copy,
wrapped and exportable buffers, and every buffer under 16 KiB, take
their length; past what the memory holds a texture keeps its tail, as
before. The runtime has no buffer allocatedSize; a heap's size and a heap
texture's allocated_size are unchanged.

The tails conformance cases now lie in place: their comments say so,
and the texture buffer case drops its staged-texture-buffer allowance,
which no device can fire there any more (its view starts at 16384).

Tests: buffer_tail_device's last-texel case lies as over a buffer that
holds it inside its length, with no tail; a new case over a 20000-byte
buffer (64x128 packed, ending at 32768) reads zero in the padding as
made, lies as inside the length, lands a kernel's writes past the length
in the buffer's memory, takes no copy where it is an image over the
buffer, and refuses a blit past the length; the heap case lies in the
heap, its kernel writes landing in the heap's other buffer; a new case
over a heap's second buffer keeps its texels past the heap's end in a
tail; the no-copy and 4096-byte cases keep their tails.

Docs: buffer_texture.rs's Tails, linear_plan.rs's Length, docs/API.md's
accepted difference and StagedTextureBuffer entry, and a FAST-PATHS
cost-of-matching-Metal entry for the padding.

Checks: the jobs that compiled and ran this commit are named in the
lane's report.

Evidence (lane jobs): m3-max-32551 (msi): clippy runtime+conformance -D warnings 0; 2632/2632 runtime+conformance; fast_paths +
api_surface 34/34. m3-max-32578 (lavapipe) at the tip: touched 56/56 (buffer_tail_device incl. the allocation, heap and
heap-end cases, texture_placement_device, linear_plan, buffer_texture, degradation_catalogue); runtime+validation partition
1/4 1572/1572. VkMemoryRequirements on lavapipe for a 16385-byte buffer: 32768 (alignment 64). The padding is cleared by the
buffer's existing first fill (no new command). allocatedSize: no buffer API; heap sizes unchanged. The PHOENIX run, the
release creation bench and lavapipe partitions 2-4 follow in the lane. Conformance: buffer-tails cases now in place; the M3
venue's cost records for buffer-tails-* re-bless on development.

Lane commits: d2ee5bca5b (bench), a8f3796f59, ee54952340 (heap cases in a placement heap).
2026-11-15 08:14:12 -08:00
Anees Iqbal 0ca24685d7 RUNTIME 2351: Textures over buffers: Metal's allocation bound counts the last texel, a heap's size and a no-copy buffer's pages
A texture over a buffer whose texels run past the length was answered nil
where its rows' padding ended past the length rounded up to 16 KiB. The
M3 Max (macOS 27.0.1, the consumer's limits runs, every buffer kind and
length bisected) makes more:

- A 2D texture and a texture buffer count to their last texel, not the
  last row's padding: a 2D R32Uint 64x64 from 256, rows 512 apart, over
  20000 bytes is made with its last texel at 32768 (rows' end 33024); a
  texture buffer of 32768 R8Uint texels at a bytesPerRow of 36864 over
  20000 bytes is made. Arrays keep their rounded slices' end.
- A heap's buffer is bounded by the heap's size, counted from the
  buffer's start, whatever its length or place in the heap (4 MiB heap:
  made to 4194304, nil at 4194305).
- A no-copy buffer is bounded by its pages: its pointer's offset in its
  16 KiB page plus its length, rounded up to 16 KiB, from its start
  (16384 bytes starting 4096 short of a page's end: made to 32768).

BufferFacts now carries the buffer's allocation (own, a heap's size, a
no-copy buffer's page offset), filled from Buffer::heap, host_backing and
contents; BufferFacts::allocation_end gives the bound. Buffers under
16 KiB keep no bound (the M3 Max answers nil past 128 KiB there, the x86
Macs make every end measured), and an array whose last texel lies inside
the length is still made: no new refusal.

Such a texture stays a copy, as before at the old bounds: a 2D texture or
array is a shadow image whose copies in and back go through its tail
(texture/route.rs Route::Past -> TextureShadowReason::PastLength,
announced shadowed-texture), a texture buffer's functions view its tail
(into_texture_buffer, staged-texture-buffer). The texels past the length
live in the tail, zero when made; the caller's bytes past a no-copy buffer
and a heap's other bytes are never read or written.

Tests: tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does
(each kind's and form's M3 boundary, made at it and nil one past; the
made rows past the old bound fail before this change); device tests in
buffer_tail_device (a heap's buffer to its 64 KiB heap's size, a no-copy
buffer at page offset 12288 to 32768, a padded 2D texture to its last
texel): made, every path reads and writes right, the buffer's CPU write
inside the length is read through the texture, shadow copies counted,
no other memory touched, one row more Metal's nil. docs/API.md's
accepted difference, REFUSALS.md regenerated.

Evidence (lane jobs, msi): m3-max-32369: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0;
linear_plan|buffer_texture 34/34 incl. tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does (the
M3's boundaries per kind and form, made at E, nil at E+1). m3-max-32370 (lavapipe): 13/13 buffer_tail_device + allocation
tests incl. a heap's buffer to its heap's size, a no-copy buffer to its pages, a 2D texture whose last texel ends at the
allocation: every path (get_bytes, blit, kernel) reads as made, writes coherent with the buffer's bytes inside the length
(shadow copies counted: such textures are shadows / staged texture buffers through their tail), neighbours untouched, one
row more Nil(PastAllocation). Negative control and the PHOENIX run follow in the lane.

Lane commit: 263219d515.
2026-11-15 07:15:50 -08:00
Anees Iqbal f851c07e52 SEMANTICS 2123 / RUNTIME 2349: Texture buffers past maxTexelBufferElements bound through views of their parts
Metal makes texture buffers of up to 2^28 texels on every Mac; one texel
buffer view holds at most the device's maxTexelBufferElements (2^27 on ANV
and lavapipe, 2^26 on MoltenVK), and the binding of a wider one was refused
(BindError::TexelBufferTooLarge).

The consumer now states with a texture buffer's binding the views its texels
take (BoundTexture::Buffer::parts, bind::texel_buffer_parts: 1 within the
limit), which its shape carries. A slot whose function only reads, writes,
updates by an atomic or asks the width of the texture buffer, on a device that
indexes texel buffer arrays NonUniform, states RuntimeFact::TexelBufferParts;
where the shape binds more than one part there, the plan asks for the parts
variant (VariantKey::texel_buffer_parts). Under it the slot is an array of
the parts' texel buffers: texel i is texel i - k*P of part
k = min(i / P, parts - 1), P the device's limit rounded down to its texel
buffer offset alignment (bind::part_texels), and the width (parts - 1) * P
plus the last part's. texel_ranges writes one range per part at its array
element (DescriptorRange::element), and the runtime views each.

Each part is the device's own view in the format one view takes, so a read
converts its texel as the one view does: no precision note. A texture buffer
one view holds keeps one view, no variant and its key. The families row
TextureBufferWidth is exact where the parts reach 2^28.

Still refused (TexelBufferTooLarge): a slot read through a sampler or used beyond read/write/atomic/width; a device
without NonUniform indexing of that kind of texel buffer array; formats with several texels a block. Argument-buffer
texture buffers past the limit stay the heap neutral (unnamed-texture-unviewable). New: WorkCounts::texel_buffer_parts_bound,
RuntimeFact::TexelBufferParts (appended), bind::part_texels / texel_buffer_parts, BoundTexture::Buffer.parts,
TextureShape::Buffer.parts (serde default 1), VariantKey/LoweringInputs.texel_buffer_parts (hashed only when non-empty),
DescriptorRange.element. SEMANTICS_VERSION bumped: input once refused now translates.

Evidence (lane jobs, msi): m3-max-32343 at 628264de17: clippy --workspace --all-features --all-targets -D warnings 0;
41 metal2vulkan tests incl. golden_hashes_match_the_table (every fixture's SPIR-V unchanged on every profile: one part is
byte-identical), the binder test (an under-limit slot: no parts entry, empty variant, layout counts 1), the interpreter
parts test (robust and unrobust), api_surface / api_signatures / refusal_surface; families::states_follow_their_sources;
lavapipe texture_buffer_width_device (R32Uint limit+64 texels: both sides of the limit and the last texel read and written,
past the end reads 0 and writes dropped, texel_buffer_parts_bound +3) and buffer_tail_device. Without the fix the device
test fails at bind: TexelBufferTooLarge{elements 134217792, limit 134217728} (m3-max-32140). ANV (2^27) is down; the XTX
(2^29) never parts.

Lane commits: 9fbf7d3c14, 7f7f3ad95e, 9a745ffb3c, 740e9e43dd, 628264de17.
2026-11-15 07:10:59 -08:00
Anees Iqbal 45e6784e91 RUNTIME 2348: ICB records the GPU never wrote are read in place, not staged
On a device that places indirect command buffer records by first use (no
unified memory, a staging queue), a host access of records in device-local
memory was staged whenever a command buffer held them or the buffer was
Private: the records it read were copied down through the staging queue and
waited for, counted, and staged-indirect-records announced. That held even
where the GPU never wrote the records, though then the host's buffer holds
exactly what device-local memory does.

The XTX conformance replay of development a88823f8f4 failed on it:
blit-copy-indirect-command-buffer announced staged-indirect-records. Its
range-none leg copies no commands into a fresh destination (an empty copy
holds nothing and marks nothing written), then executes destination command 0.
The execution's hold placed the untouched records in device-local memory, and
the commit, which records the execution from the CPU's records because no GPU
route met the buffer, read them through host_access while its own command
buffer held them: staged. The cause dates from 5dd3668a4f (RUNTIME 2294,
placement by first use); the last green XTX replay (06fd49b221, 11-11)
predates it, and the case's recording did not change.

Now host_access serves an access that only reads (Reach::Reads) records the GPU
never wrote (State::written false) in place: not staged, not counted, nothing
announced. A write of such records is still staged, for its copy back alone:
it no longer copies the runs down first.

Why the two sides cannot differ while written is false:
- placement (place_on_device) fills the device-local storage with zeros and
  writes encode_header's header, which is what the host's storage holds as the
  buffer is made (write_header: CommandBuffer::initialize's header and reset
  records, flags cleared; the reset record is all zero,
  metal2vulkan's indirect_commands/tests/records.rs
  reset_clears_action_and_bindings_to_zero). A Shared buffer the CPU touches
  before any GPU use is placed on the host for good; a Private one is placed on
  the device at its first host access, before that access writes.
- every CPU write of the records goes through records_access with
  Reach::Writes or Reach::Overwrites (reset_command, batch, the CPU reset), and
  while the records lie in device-local memory that access is staged with
  back = true, whose drop copies the written runs (records and written flags)
  back into device-local memory: home.rs line 222,
  `copy_runs(self.icb.generation(), records, host, &self.runs, false)`.
- every GPU route that writes the records holds them with writes = true, which
  sets written (home.rs line 320, `state.written |= writes`): a blit's copy and
  reset, and a compute or render encoder's use_resource with WRITE.
The move path already relied on the same fact (a move of a buffer the GPU never
wrote copies no bytes).

The conformance case needs no declaration: the notice was the runtime staging
where it need not.

Also: the runtime-lane test private_indirect_records_follow_the_memory_model
expects two staged accesses (its two setters), its getter now reading in place;
the docs of home.rs, Degradation::StagedIndirectRecords (and its cost),
WorkCounts::icb_records_staged_accesses and docs/API.md's catalogue entry say
which accesses stage. No new Degradation kind, no new counter.

Verification: in the job reports that follow.

Evidence so far (lane jobs): msi m3-max-32246 at cfcdb29780: the conformance binary and the m2v_gpu archives built; the
lavapipe replay (conformance replay --cpu) matches known-gaps.tsv (LVP_REPLAY=0). gem10 m3-max-32248: clippy -D warnings
plain, m2v_gpu and m2v_cpu_icd on runtime + validation = 0. The XTX replay and the new device tests (with the control at
76a78ec60a) follow in the lane's um790 job.

Lane commits: 76a78ec60a (tests), cfcdb29780 (fix).
2026-11-15 06:58:33 -08:00
Anees Iqbal b7053280de RUNTIME 2346: 4:2:2 textures over IOSurface planes: an image of their texels, decoded from the pairs in place
A GBGR422 or BGRG422 texture made over a buffer's bytes (Buffer::new_texture_with_iosurface_plane,
a CoreVideo 2vuy or yuvs plane, over a Shared buffer or a no-copy buffer's host pages) had no
decoded twin: twins are attached only to textures whose image is their own for good, so every
dispatch or draw that read or sampled it was refused, with a "needs R8G8B8A8_UNORM SampledImage"
line naming a format every device samples.

Such a texture is now an R8G8B8A8_UNORM image of its texels, the converted shadow a two-plane
YCbCr texture over planes already is (ShadowSource::Converted, its conversion now an enum of the
planes' and the pairs'): its copy in, before the first command of a command buffer that reads it
and after a command wrote the bytes, is one dispatch of the new bind::chroma_convert_module that
reads the pairs where they lie, at any byte of their VkBuffer, through one storage-buffer binding,
and writes Metal's texels (ChromaDecode, exact) through the image's R32_UINT view. Copies, blits
and CPU calls keep moving the plane's bytes. Where the device converts the pairs' format with
Metal's reconstruction (MoltenVK), the copy in is that conversion instead: the plane's rows copied
into the pairs' image, sampled through the conversion (chroma_sample_module) into a scratch,
copied into the image; announced decoded-texel-precision at the copy in's planning. The set binds
the buffer's VkBuffer, so the planning makes it again after a rebind gave the buffer another one,
and each command buffer holds the set it took. The placement query answers OtherShape. A plane
the window cannot take (past maxStorageBufferRange, a last word past the buffer, rows that share
bytes, texels past the buffer; with the device's conversion, a first byte or rows off 4 bytes)
keeps the carrier, its reads refused; FAST-PATHS records it as a known gap.

Per frame, per texture (w x h texels): before, no read ran at all; the texture was an R8G8_UNORM
carrier of the plane, 2 bytes a texel. Now no byte is copied: one dispatch reads the w*h*2 bytes
of pairs in place and writes w*h*4 bytes of texels (1920x1080: 4147200 read, 8294400 written).
Memory: one R8G8B8A8_UNORM image, w*h*4 bytes (1920x1080: 8294400), in the carrier's place; with
the device's conversion also the pairs' image (w*h*2) and the scratch (w*h*4), and per copy in a
w*h*2 copy in and a w*h*4 copy out. Announced carried-decoded-twin (an existing kind) with that
cost. No new Degradation kind, no new WorkCounts field.

A carrier's binding without a twin is now refused NotImplemented(Format) naming the texture's
format (pvrtc::holds_for_copies), not a need of the twin's view format.

Public surface: metal2vulkan::bind::{chroma_convert_module, ChromaConvertModule} added
(api_signatures.tsv blessed, api_surface table); docs/REFUSALS.md regenerated (one more
binding_view site of Format).

Tests: the in-place kernel against ChromaDecode's decode under the interpreter (both orders, first
bytes off a word, odd sizes, rows apart); a carrier's binding refusal (binding_view unit test);
a device test of both formats over a Shared buffer and over host pages reading Metal's measured
bar values (an Apple M3 Max, macOS 27.0.1) and Metal's decode of a random frame written on the
CPU before the next command buffer, OtherShape from the placement query, and the device's
conversion counted and announced where it converts. Verification jobs follow in the lane report.

Evidence (lane jobs): msi m3-max-32240 at 94f603bf35, --cfg m2v_cpu_icd on llvmpipe: 130/130 touched tests, clippy -D warnings 0;
the device test fails without the fix (placement not OtherShape, the read's dispatch refused). PHOENIX gem10 m3-max-32260
(archive m3-max-32241): all 4 cases (GBGR422/BGRG422 over a Shared buffer and over host pages) "Metal's texels, exact"
for the M3's measured bars and a random CPU-written frame; ycbcr_device, ycbcr_refresh, twin_reads 7/7. MoltenVK (device form)
run on the M3 follows.

Lane commits: 735234d5f4, d59f44baa6, 94f603bf35.
2026-11-15 06:48:09 -08:00
Anees Iqbal ef64727c7a RUNTIME 2345: Host RAM: a first gather over bytes some use may write is staged in a part of its own, never through imports made or waited for on the encoding thread
stages() staged a gather over chunks the device's thread imports only where no use but a
copy's read may write its host bytes (RamOnDevice::written_over). That holds for the whole copy
as soon as one chunk it touches had a scatter recorded (copy_wrote, never cleared) or a buffer
over host pages lies over its bytes, so a first fill over a fresh RAM after any download into one
of its chunks took the imports' path: for_copy imported each chunk not imported yet on the
encoding thread (the ahead plan imports no range alone). A consumer's decoder waited 1.73 s
for 124 such imports on an RTX 3090 (each pins 64 MiB of fresh pages).

Such a gather is now staged as one over a chunk that takes no import is when written: in a part
of its own (Staging::after_the_gpu), its host step after the work before it in its command buffer
completed, on the steps' thread. Its encoder keeps no log (an encoding again through the imports
would start no part, so its parts would not be the first's). Docs: copy.rs, deferred.rs,
docs/HOWTO.md.

Tests: host_ram_copy_device::a_first_gather_over_chunks_a_scatter_wrote_waits_for_no_import (a
scatter then a gather in one encoder over two chunks not imported, the thread's imports held in
flight): the gather is staged, waits for no import, imports no range, reads the scatter's bytes;
two later fills of its pages (a later encoder, a later command buffer) land after its read.
Benches (ignored, release): host_ram_first_fill_spread_bench, host_ram_layer_encode_bench.

Evidence (lavapipe, msi): negative control m3-max-32190 (the test against the parent's copy.rs
fails: not staged, 600 ms waiting on two paused imports); with the fix all 92 host_ram tests pass
(32190); clippy cpuicd -D warnings clean and the extended test pass at the tip (32210). First-fill
bench after a 1-page download: before staged 0, 121 chunks imported on the encoding thread, call
1369 us (32174); after staged 1, 0 import waits, 0 chunks imported by the copy, call 328 us (32210).
The 3090 run follows.

Lane commits: e70fea0886, f50ee551c3, 9e74f43df1, ab6d8af756.
2026-11-15 06:43:15 -08:00
Anees Iqbal 43bb61c60e RUNTIME 2344: Runtime: a command queue on the copy engine, and buffer copies merged into runs
Device::new_command_queue_for_copies() answers a CommandQueue whose command
buffers submit to the device's copy engine (the staging queue's family of
transfers alone), or None where the device has none to give (MoltenVK,
lavapipe, RADV by default, a copy engine of one queue, an adopted device).
Its VkQueue is the copy engine's third queue where it has one, else the fill
queue's, whose submissions then take that QueueSlot's lock: NVIDIA's copy
engine has two queues, staging's and fill's, and staging must wait for no work
in flight. The slot is the last of the device's VkQueues, after presenting's;
its family stays out of image sharing (buffers already share it as the staging
queue's family, so no ownership transfer is recorded).

Its command buffers take blit encoders alone, and of their commands buffer
copies, fills and fences: other encoders and blit commands are refused
(Invalid, Problem::CopyQueue(CopyQueueProblem::Encoder | Command)), as is a
caller's VkBuffer not concurrent with the copy family (Buffer). A copy batch
takes buffers' fills alone from first work. Barriers on its VkQueue name the
copy family's reads (Barrier::record_reading), not the primary family's, which
a family of transfers alone may not name beside ALL_COMMANDS
(VUID-vkCmdPipelineBarrier-dstAccessMask-02816).

A blit encoder's consecutive copy_from_buffer_to_buffer calls between the same
two VkBuffers that its order needs no barrier between are recorded as one
vkCmdCopyBuffer of many regions (copy_run.rs), on every queue; counted as
WorkCounts::buffer_copies_merged. Batches on the copy slot are counted as
WorkCounts::copy_queue_batches.

Verified: not yet built (first build job follows).

Also in this landing:
- Copy queue: docs, and the device test's None answer checked against the device
- Copy queue: keep the copy queue's place alive while the families are counted

Evidence: lavapipe 425/425 (m3-max-32049), clippy m2v_cpu_icd and m2v_gpu -D warnings (32049, 32053); XTX m3-max-32073: default RADV answers None; RADV_PERFTEST=transfer_queue: 1 batch on the copy engine, 63 of 64 row copies merged, sync file signalled, bytes right, refusals typed, validation layer silent.
The derived API table and docs/REFUSALS.md were re-derived on the merged tree (winport's #[cfg(unix)] gates landed beside copyq).
2026-11-15 06:09:09 -08:00
Anees Iqbal a9dce911e7 Known gaps: drop the first commit's translation; held_step_order's numbers from a release build
9aadbdf281 rewrote the known gap from the test profile's numbers. A release build of the same
test on the same idle Radeon 780M (RADV PHOENIX, m3-max-31944, 2 processes x 3 runs) puts the first
commit of a host-step pass, which translates the variants its step draws with, at 4.5 and 5.4 ms,
and a later one at 0.11 to 0.19 ms; the unoptimized test build takes 23 to 25 ms and 1.0 to 1.3 ms
there. Nothing measured holds a guest's commit past a frame's 16 ms any more: the 406 and 10.5 ms
were the test build inside a suite that loaded the host's cores. So the known-gap row goes, and
CHANGELOG's known-failing line names only the teardown test. The test's COMMIT doc carries the
release and the test build's numbers.

Docs and a test comment only. Verified: the numbers are m3-max-31944's printouts.
2026-11-15 05:45:35 -08:00
Anees Iqbal 9aadbdf281 held_step_order: time Scheduled from the commit's return; hold the commit call to a frame
command_buffers_behind_a_waiting_step_read_scheduled failed 3 of 3 on the Radeon 780M (PHOENIX)
inside the whole device suite (m3-max-31782): the long command buffer's commit returned 405.95,
23.66 and 10.50 ms after its call, and the test bounded the call plus the scheduler's pass to
`Scheduled` by 10 ms together. Scheduled itself came 19.6, 1.6 and 2.3 ms after the commit
returned: the ordering the test is for held.

What holds the call (probes m3-max-31832 and m3-max-31876, gem10's 780M idle, step marks in the
commit path): no pipeline wait (commit_pipeline_wait_nanos 0) and no lowering; Recording,
Deferred::prepare of the host-step pass. Its first commit translates the variants the step draws
with on the program's thread (DeferredPass::settle: the step's buffer forms and the fan-out's,
the route's replay variant; record_on_gpu's decision and, once a device, the notice's rules past
its cause): 24.1 / 23.7 ms cold, 49.8 in an earlier run. A later commit finds them made: 1.0 ms
(2.4 in the earlier run), about 30 lookups of 5 to 35 us, no single repeated item. The suite on
the host's cores stretched the same work about tenfold. The translation cannot move earlier
(whether the pass is a host step and its route are decided at the commit) nor off the program's
thread (the device keeps only what the program's calls make, in its order).

So the test's one bound mixed two properties. Now:
- `Scheduled` is timed from the long commit's return, still within 10 ms (the long work ends
  100 ms or more after it);
- the commit call is asserted apart, by its own clock (WorkCounts::commit_nanos), within a frame's
  16 ms in one of the runs at least (the later runs are warm), the test's own work_counts()
  snapshot outside the timed span.

docs/FAST-PATHS.md's known gap is rewritten to what is measured (the first commit of a host-step
pass translates its step's variants, why it stays there), and CHANGELOG's known-failing line with
it.

Verified: see the lane's report (PHOENIX 5/5, negative control with a sleep in the commit path).
2026-11-15 05:36:51 -08:00
Anees Iqbal 7ba0cd9fe6 RUNTIME 2343: GPU times placed by a calibration still beyond 20 us are announced and counted
A calibration pair is read again while the smallest deviation so far
states more than 20 us (`gpu_time::SETTLED`), four readings at most
(`least_deviation`). Where the least of four still stated more (93 and
125 us on the RX 7900 XTX under full parallel suites: a reading's
deviation holds the time its thread spent off the CPU), the runtime
placed the command buffer's GPU times by it, inside the command
buffer's life, with up to that error, and said nothing. Owner rule 2:
a near-equivalent is recorded and announced.

`GpuClock::span` now answers `Placement::Loose { deviation }` where the
pair places both times inside the life and its deviation exceeds
`SETTLED` (a pair outside the life is still set aside as before).
`Placement::read` gives the notice for every placement the first read
of a command buffer's GPU times announces, counting a loose one:
- new kind `Degradation::LooselyCalibratedGpuTimes`,
  `loosely-calibrated-gpu-times`, class Precision, announced once per
  device at the read (the site `uncalibrated-gpu-times` uses), its
  reason stating the deviation; not `uncalibrated-gpu-times`, whose
  cost says the times are placed by the completion, where these are
  the pair's, the duration exact;
- new `WorkCounts::loosely_calibrated_gpu_times`: command buffers
  whose times a read found placed so, counted at the read that
  announces, so the count is nonzero exactly where the kind was
  announced.

Tests: `tests::gpu_time::a_pair_still_beyond_the_settled_deviation_is_
announced_once_and_counted` feeds `least_deviation` a fake source of
four readings above 20 us (Loose, the kind with the deviation in its
reason, each read counted, announced once) and settled ones (Iris
Xe's 165 then 7.6 us; 20 us exactly: Calibrated, nothing), and a loose
pair outside the life (Disagreed, the uncalibrated kind, not counted).
The lane's `gpu_times` expects the kind exactly where counted, and holds
the count nonzero exactly where `calibration_deviation_most` exceeds
the slack (no disagreement); `read_kinds` adds it where counted
(mesh_draws), `disagreeable_kinds` allows it (first_use); a site const
`LOOSE_GPU_TIMES` takes it. The conformance cases that read GPU times
(`command-buffer-facts`, `empty-command-buffers`) allow its notice:
the host's load decides it, and every value still compares exactly.

docs/API.md's catalogue lists the kind; api_signatures.tsv blessed.
2026-11-15 05:18:59 -08:00
Anees Iqbal d9236a8a11 Known gaps: a commit held past 16 ms on a Radeon 780M; a teardown wait past 16 ms on an RTX 2080
Two latency tests fail on some GPUs at the 0.2.0 release candidate, recorded where a user reads
open gaps (docs/FAST-PATHS.md, Known gaps) and in the 0.2.0 CHANGELOG entry, at the owner's call to
document them as failing and release:

- tests::held_step_order::command_buffers_behind_a_waiting_step_read_scheduled: on the Radeon 780M
  (Phoenix, m3-max-31782, exclusive) the long command buffer's commit returned 405.95 / 23.66 /
  10.50 ms after its call over the test's three runs (bound 10 ms); pin 97's XTX printout shows the
  same shape (315.68 -> 12.59 -> 17.11 ms). The ordering the test is for held in every run.
- tests::teardown_threads::a_running_queue_switch_check_leaves_the_device_to_the_program_s_thread:
  on an RTX 2080 (620.70.06) it failed 3 of 3 alone (m3-max-31777): the teardown waited 33.1 / 23.3
  / 19.8 ms for the check, 19.6 / 22.0 / 18.4 ms of it the check's objects' release; it passes on
  the RTX 3090, RX 7900 XTX and Radeon 780M. That host's driver calls on the 2080 ran several times
  slower than usual during the measurement (cause open).

Docs only.
2026-11-15 02:15:21 -08:00
Anees Iqbal ec0be064d0 RUNTIME 2342, SEMANTICS 2122: Texture buffers read through argument buffers sit in texel-buffer heap classes
A pipeline whose argument buffers hold texture buffers was refused with
ArgumentBufferTextures (NotImplemented, no location): the translator's heap layout
(lower/texture/slot.rs declare_heap) had no set-1 class for a texture_buffer member, so
SPIRV-Cross-shaped tier-2 argument buffers (descriptor sets as [[buffer(n)]] structs with
texture_buffer, texture2d and sampler members) could not be made, on any device.

- Set 1 gains texel-buffer heap classes: UNIFORM_TEXEL_BUFFER for read, formatless
  STORAGE_TEXEL_BUFFER for read_write and write. The class follows the facts' texture type.
- DescriptorCaps gains update_after_bind_uniform_texel_buffer and
  update_after_bind_storage_texel_buffer; where a device lacks them a typed needs_any_of names
  the missing features. Non-uniform texel-buffer indexing and the without-format read/write
  needs are checked as for images; link counts STORAGE_TEXEL_BUFFER with the images against
  the update-after-bind limits.
- New public bind::heap::HeapElement::TexelBuffer(vk::Format).
- The runtime writes each live texture buffer's texel view at its resource ID, with a neutral
  texel view at element 0; a gone texture buffer's Texels stay alive until its tickets clear.
  A texture buffer whose bytes cannot be viewed in place (staged, tail-viewed, offset off
  minTexelBufferOffsetAlignment, past maxTexelBufferElements, swizzled, or a non-direct format)
  reads the neutral and is announced through the existing UnnamedTextureUnviewable. No new
  Degradation kind.
- docs/REFUSALS.md and api_signatures.tsv regenerated.

Test: runtime_lane::argument_texel_buffers::a_texture_buffer_in_an_argument_buffer_is_read_in_both_stages
(an owned fixture in SPIRV-Cross's shape): vertex and fragment read a texture_buffer member of a
set-0 argument buffer, the fragment also samples a set-1 texture2d through the sampler beside it;
every pixel must equal texel[1] + texel[4]*tint + albedo.

Verified: lavapipe with the validation layer, m3-max-31658 at 6626eeaff3: pass. Control
m3-max-31636 (the fixture and test at the base, without the fix): fails with exactly the
ArgumentBufferTextures NotImplemented refusal.
2026-11-14 23:33:03 -08:00
Anees Iqbal 1b5a527f5e RUNTIME 2340: Scheduler: a host step at its gate whose batch's uses are known keeps its place
What: since a7e519150b (RUNTIME 2326) a batch held for its host step, once
the step took its gate, gave way to every later commit of another queue but
for one that writes what the step reads on the host (its executions' records
and ranges) or shares a fence with it. That rule was for a step whose uses
commit could not bound (a shadowed texture's copies, tile memory, a
visibility query, an inherited function table): its footprint is not known,
so keeping its place held every queue's tracked work. It also applied to a
bounded step, whose footprint names what its commands may reach, and there
it let a later commit that conflicts with those uses go first, against the
commit order the M3 keeps:

- runtime_lane::queue_order::a_copy_committed_while_a_write_waits_for_its_
  host_step_holds_it: queue B's copy of the buffer A's indirect commands
  write (made resident for writing) went before A's execution and read
  zeros;
- runtime_lane::steps_apart::another_queue_goes_on_while_a_host_step_records:
  a pass into A's target on another queue, committed after A's, began its
  host step while A's step still recorded.

Now the step's host reads are kept for giving way only where the batch's
footprint is not known (CommandBufferShared::footprint's None). A batch
whose uses are known keeps its place from its gate on, as before a7e519150b:
a later commit of another queue that conflicts with them waits behind it,
and one that shares nothing with it goes (the compositor's fill of
tests::held_step_order). The step whose uses are not known still gives way
but to writers of its host reads, so held_step_order's unknown-uses leg is
unchanged. Docs: the scheduler's and order.rs's rules, Held::gate_reads,
place_of, is_behind, WorkCounts::heads_held_for_earlier_commits and the
host-replayed-indirect-commands notice (degradation.rs, docs/API.md).

Bisect (lavapipe, the two tests alone): 06b5fe355e, a7e519150b's parent,
passes both (m3-max-31546); a7e519150b fails both with pin 97's messages
(m3-max-31547). This commit's proof (the two tests, held_step_order's three
legs, the catalogue, clippy) is in the lane's report.

Fixes pin 97 (eee64c8668) lavapipe and 780M failures queue_order::a_copy_committed_while_a_write_waits_for_its_host_step_holds_it
and steps_apart::another_queue_goes_on_while_a_host_step_records, both bisected to a7e519150b (RUNTIME 2326; parent
06b5fe355e passes, m3-max-31546/31547). RUNTIME 2326 was for the RTX 3090 89 ms rate-mapped pass, a step whose uses
were not known (it held every queue; a bounded footprint holds only what conflicts with it). That case keeps its give-way:
held_step_order visibility-query leg passes. Compiled in m3-max-31554 (msi: clippy; lavapipe both tests, queue_order,
held_step_order fill legs, degradation_catalogue, replayed_frames footprint-once).
2026-11-14 22:54:44 -08:00
Anees Iqbal 734e1cac02 RUNTIME 2339: Bind a slot read at its residual over a range its bind offsets share
What: bind::instantiate::shared_range gives a descriptor-form slot of a
Bounded window that its functions read at the residual one range for a run
of bind offsets of the bound buffer: the padded buffer from 0 where it fits
the view's maximum range (and 4 GiB), else the block of half that maximum
its window starts in, to the maximum past the block's start; its
SlotBindOffset residual the rest. A window of at most half the maximum never
straddles its block's range; a longer one, or one at or past the padded end,
keeps descriptor_range's range. planned_range takes it for every Bounded
storage view (no function reads one at its bind offset alone), and for a
uniform view where the new BindState::uniform_views_at_residual says the
consumer reads every uniform view at its residual: its keys all take their
residual forms. The runtime states it where pipeline::reads_views_at_bind
does not hold (every device today: no driver carries
DriverFact::ConstantOffsetUniformReadsPreloaded), through AtBindViews, at
each bind state that states the view base alignment (render, compute twice,
tile dispatch). Shapes, plans and keys are unchanged; the flag is not part
of the shape.

Why: a constant reference at a buffer index (constant float4 &) is a uniform
view of a 16-byte Bounded window, whose range started at the bind offset
with residual 0. Every offset-only rebind (a consumer's staged
setVertexBytes: setVertexBuffer at the next 256 bytes of an upload chunk)
then wrote another descriptor: rebind_into, push_set and the driver's
vkCmdPushDescriptorSet at every draw (reims-vgpu's Iris: +538 ns a draw
against a device pointer, +93 inside the push and +99 under record). The
range at the bind offset serves only keys reading the view at the bind
offset alone, which no device takes today: the shader already adds the
residual. Now such a draw keeps its set-0 writes (writes_kept) and pushes
only its residual, as a device pointer's draw does.

Metal and Vulkan: each read inside the window reads byte
lo + (bind - lo) + m = bind + m, the bytes it read before, through the same
instructions. A read outside the window, which Metal leaves undefined,
reads the buffer's bytes inside the range. The range starts at 0 or a block
multiple, a multiple of the base alignment
(VUID-VkWriteDescriptorSet-descriptorType-00327/00328), stays within the
view's maximum (00332/00333) and the padded allocation
(VUID-VkDescriptorBufferInfo-range-00342); a dynamic descriptor's offset is
its start as before (VUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971).

Verified: by the jobs that follow (unit tests of shared_range and
planned_range, the lavapipe runtime test
constants_moved_along_one_buffer_keep_their_set_zero, the release medians
of runtime_lane::constant_offsets before and after).

With (bench and tests): 78463d1e1d The moved-constant set-0 test counts every second draw again as taking every step in builds with debug assertions; 5e7d715629 The moved-constant set-0 test lists which of the second pass's draws were rebound; 99a3459dc6 The moved-constant set-0 test moves the vertex constant alone, as constant_offsets does; a9c4b07790 The moved-constant set-0 test names what the second pass's draws did where some were not moved; 5e938c75c5 The moved-constant set-0 test draws the bench's shape; a bounded storage window's dispatch test binds the shared range; 69e598a6b5 Drop the stale copy of the range-from-bind-offset test; round-trip the new BindState field; ea4602012c cof_device reads its float4 at the instance's element; cd6492fd41 constant_offsets also draws over chunks in host pages, under the consumer's policy; 4d6e17bb89 constant_offsets takes the AIR library trait into scope; 1221f53ce0 Time draws that rebind a constant reference by offset against a device pointer.

Compiled in m3-max-31548 (msi: clippy, lavapipe uniform_bind_offsets/draw_again/general_form/inline_continues/
kept_shadowed_draws 48/48). The set-0 test fails at the base (16 writes pushed, want 0; 31536). Release counts
(31392): set-0 pushes per constant draw 1.00 -> 0, push constants 0 -> 1.00. The new fixture's golden rows re-bless
on development.
2026-11-14 22:47:14 -08:00
Anees Iqbal 5fcd8be7de RUNTIME 2337: A pass's first draw that samples a color the pass clears reads its copy cleared to the clear, with no barrier too
A draw that samples a texture its own pass renders reads the texture's shadow, a copy taken
before the pass's load actions (texture/attached_reads.rs). In a pass that clears the color, a
first draw that sampled it with no barrier read the texels from before the pass at every pixel it
read: the M3 Max's answer, while both x86 Macs read the clear there (probe ownread: no draw
before it, so the load and the draws before it wrote only the clear). The copy was cleared to the
clear (Texture::cleared_copy, vkCmdClearColorImage) only after a memory barrier before the pass's
first draw.

The Macs disagree, so Metal's answer is either; the macOS guests are x86 ones, and a clear of the
copy costs less than a copy of the texture. RenderLowering's draw now takes the cleared copy for
every draw that samples a color the pass clears before any draw of the pass recorded, wherever
Texture::cleared_copy holds (a whole single-sampled 2D texture of one level and slice that one
color renders in place), with a barrier before it or none; the draw keeps nothing to draw again,
as after the barrier. A pass that loads the color, and every read outside cleared_copy, read as
before.

Tests: attachment_reads' no-barrier lane becomes a_first_draw_with_no_barrier_reads_its_pass_s_load,
Load and Clear over both target kinds, the texture of its own image taking the cleared copy
(attachment_read_clears) and reading the clear where the pass clears; check() counts a cleared
copy as taking no split's place with no barrier. framebuffer_fetch gains
a_first_fetch_after_a_clear_reads_the_clear (a fetch after a Clear reads the clear, not the texels
from before the pass). The conformance rows pass-start-barrier-*-sample with no barrier accept the
clear too, as the -read rows did. docs/API.md's accepted differences and attached_reads.rs's docs
say which Macs answer what.

Verification: the jobs that compile and run it are reported with this sha.

With: 645f1c3323 snapshot_reads' first test makes its readers' pipelines before the counted pass; af0a44cc6d The render lanes and inline-split tests read their fixtures where the test runner names the crate; 8b5cd6dfb4 attachment_reads' first-draw lane lets a target over a buffer's bytes take the cleared copy too (test-only).

The user's GitHub issue 17. Compiled in m3-max-31319 at 8b5cd6dfb4 (clippy x3; lavapipe lanes, the first-draw lane, the
fetch-after-clear lane, the 14 pass-start-barrier conformance rows exact and default; the negative fails).
2026-11-14 22:00:02 -08:00
Anees Iqbal 7b1725eb34 RUNTIME 2336: Lay no more of a predicated loop's copies than keep its waiting host steps within 16
On RADV, runtime_lane::predication::every_dispatch_form_runs_in_each_pass_past_the_copies ran
40-77 s alone and passed its 60 s wait for one command buffer under the suite. The cost is the
runtime's, not the test's breadth: each piece of work a host step records after the GPU's work
before it (an indirect dispatch of a kernel that observes its partition, an indirect command
buffer's execution inside a block) is its own batch, a round trip to the host (submit, wait for
the GPU, record, submit) in every run of a loop's laying, whether its copy's pass runs or skips.
A loop was laid down as 64 copies (16 inside another), bounded only by its commands
(LAID_BUDGET), so the test's inner DoWhile of 20 + 1 passes inside a DoWhile of two laid 1024
copies of its body: measured on lavapipe at the base (msi job m3-max-31287, a timing probe), its
command buffer's first run recorded 4097 host steps and made 8195 submissions (6145 and 12291 on
the device without device addresses, whose step form records six such pieces a pass), where its
21 passes ran 84 (126); the DoWhile of 100 passes 257 (385). That command buffer was 94% of the
test's 21,772 submissions, and each costs a GPU round trip, a few milliseconds on RADV.

copies_of now bounds a loop's copies by a second budget too: the work apart whose host step waits
for the GPU (Deferred::gpu_written) that its copies lay down, at most WAITED_BUDGET (16), counted
as LAID_BUDGET counts commands, from the first copy's, inner loops' copies included
(Predication::waited, Looping::waited_at). A loop of no such work keeps its 64 or 16 copies. A
loop that ends before its copies pays at most 16 round trips for the copies it skips, and one that
runs past them one more round trip, its check, per 16. The run-again path, unchanged, takes any
count of copies down to one.

Tests: every_dispatch_form_runs_in_each_pass and the failing test assert each loop's first run
records at most 16 host steps and the check (257 and 4097 at the base: the negative control);
the 100 passes no longer run again exactly once. docs/API.md and docs/RUNTIME-PORTING.md name the
new bound.

With abd0662e9f: the budget trades nothing for accuracy, so it has no FAST-PATHS row.
2026-11-14 21:39:26 -08:00
Anees Iqbal 5efe2f1d73 Test queue limits count the program's live command queue handles
The runtime tests' default queue limits count the queues the program holds, not live ones

The check that fails a test needing the queue plan counted live queues
(QueueShared). A command buffer holds its queue's QueueShared, and the
runtime's threads let a completed one go a moment after its wait
returns. So a test that let a queue go and then made two more could
fail or pass by timing.

The check now counts the command queues the program holds a handle of:
- each QueueLine counts, under cfg(test), the command buffers alive
  whose `commandQueue` it is;
- a queue the program made is held where its strong references
  outnumber those command buffers plus the caller's upgrade
  (QueueLine::held_by_the_program, Line::program_queues_held);
- a command buffer takes its count before its handle of the queue and
  drops it after, so a count in passing reads one fewer, never one
  more.

The product's count of live queues (WorkCounts::command_queues_live_most)
is unchanged.

The device test a_default_test_device_fails_where_its_work_needs_the_plan
now keeps a command buffer of a queue it let go before making the
third. The live-queue count panicked there; the held count does not.
The message reads "while the program holds 2 of its command queues".
docs/VALIDATION.md and TEST_QUEUE_LIMITS' doc say the same.

The command buffer's count among its queue's is a guard held for its drop: _counted

Clippy (-D warnings) refused 3d6e4e5957's field `counted`, never read:
the field exists for its Drop, which takes the command buffer's count
off its queue's. Named _counted, as a guard held for its drop.

The test limits' check runs where the program makes a queue, not where a recovery places one again

With the held count, a recovery's queue that took its place on the new
generation counted itself and the program's other queues. So
device_recovery's a_loss_holds_the_hang_s_queue_until_the_recovery and
work_held_unsubmitted_at_a_loss_fails_as_its_victims_in_queue_order (two
queues each) failed on lavapipe at 577d649100. The rest of the suite
passed: 2741 of 2743.

The check now runs in Device::command_queue, for a new round-robin or
unshared queue of the program's, before its place. A queue placed again
after a recovery was counted where it was made.

Verified: job 31249 at 1f69cb2e0c: clippy plain, --cfg m2v_gpu and
--cfg m2v_cpu_icd; queue_limits, queue_limits_device and device_recovery on
lavapipe three times (22/22 each); the runtime suite on lavapipe 2743/2743;
a negative control (the old live count) fails at the third queue. Test-only
(cfg(test)).
2026-11-14 21:02:38 -08:00
Anees Iqbal fdea9b585a RUNTIME 2333: On a device whose image uses miss buffer writes in one VkCommandBuffer, an end-recorded render pass joins after byte writes and splits only where its images meet them
A render encoder whose pass records at its end joins a group after byte writes, split before its pass where it meets them

On a device where DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer
holds (the RTX 3090), State::join_fold let a render encoder join no group
whose earlier encoders wrote bytes. Every render encoder after a compute or
blit write of any buffer then began a VkCommandBuffer of its own: a chain of
dispatch, draw and copy took 7 VkCommandBuffers where it took 1 elsewhere
(render_fold at pin 96). The defect is narrower: an image use after a
buffer write over the image's memory in one primary.

The join now stands on that device as on any other, and the split goes
before the pass where the pass uses such an image:
- Each draw a pass recorded at its end notes its uses apart, into its
  secondary (EncoderCore::record_aliased); where one uses an image whose
  memory meets the bytes noted written in the VkCommandBuffer (the group's
  FoldOrder::byte_writes and the encoder's own), the encoder owes a split
  (AliasWrites::noted_apart).
- The first command it then records into the VkCommandBuffer, a shadow's
  copy before a later draw or the steps and pass at its end, whose uses
  hold the attachments', goes in a new one where it owes one or its own
  uses meet the writes (AliasWrites::meets). An unordered encoder's shadow
  copy now takes the check too (EncoderCore::shadow_command).
- A pass whose first instance records inline still joins no group
  (Fold::admits): its draws record from the first on.

render_fold's counts go back to one VkCommandBuffer for the chain on every
device (no lane's pass uses an image over written bytes). heap_textures
gains the render analogue of the measured lane: a blit's copy into a
tracked heap's buffer, then a render encoder's draw reading the texture
over those bytes (recorded at its end), its pass loading and storing that
texture (at its end), and a draw reading it in a pass recorded inline,
each asserting every texel is the copy's, the join, and a split where the
fact holds for the two recorded at their end (none for the inline one).
The render functions are an owned fixture, examples/heap_draws.metal.

A texture reached through a heap made resident (useHeap:) is a read of
the heap's bytes, which meets no write; alias_split.rs says so.

Verified: cargo fmt; the fixture's regen check (metal-as round trip, LLVM
21 llvm-as). Clippy, the runtime and validation suites and the device runs
(the 3090 with a negative control, a non-splitting device) follow.

alias_split: a write after a draw noted apart, over its image, splits before the pass; use_heap guard lanes

The draw-time check of the narrowing (a render encoder whose pass records at
its end joins a group after byte writes) checked each draw recorded apart only
against the writes noted by the time of the draw. A command recorded into the
tail after that draw, but before the pass (a shadow's copy, or an emulated mesh
or tessellation dispatch writing guest bytes), adds writes the draw's images
were never checked against. The draw still runs after them, inside the pass
the encoder records at its end, in the same VkCommandBuffer: the defect the
split guards (DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer, the
RTX 3090).

AliasWrites now also notes the memory the images of the commands recorded apart
use (`apart`). That list is per encoder and bounded like the writes: at most 32
keys, each key's ranges joined into one, and past that every range meets.
note() sets the owed split where a new write meets one of those images. The
check is now order-free: every image a pass's draws use is checked against
every write recorded before the pass. begun() clears the writes and the debt
but keeps `apart`, since those draws still run after whatever the new
VkCommandBuffer records before the pass. The draw-time check and the write-time
check share one bounded range set (`Noted`). UseRange::image_bytes gives an
image's place as shares_memory takes it.

The draft's scope sentence about useHeap: was wrong (devlegs agrees). A texture
of a heap made resident is its own Used::Texture token. bind's used_uses lists
it for any function that reads a texture, and resident_uses_into gives it a
Texture::bound_use image use. Two heap_textures lanes now guard that path. In
each, a blit writes the heap buffer, then something reads the texture over
those bytes only through an argument buffer, with use_heap and no
setTexture:
- a draw of a pass recorded at its end (read_argument_fragment);
- a dispatch (read_argument_kernel).
Each asserts that every texel shows the write, that the encoder joined the
blit's group, and that the split count is > 0 exactly where the fact holds. The
lane enum is TextureUse now (it covers a dispatch), the function
blit_write_then_texture_use. The fixture heap_draws.metal gains the two
argument-buffer functions (regenerated with scripts/regen-air-fixtures).

Verified: cargo fmt; the fixture regen (metal-as round trip, LLVM 21 llvm-as).
The unit test a_write_after_a_draw_noted_apart_over_its_image_splits_the_next_command
fails without note()'s new check. Builds, clippy and the device runs (with a
negative control on the 3090) follow in jobs.

Verified: job 31175 at ceb7e56415: clippy -D warnings (runtime and
validation, all targets and features), the alias_split unit tests 6/6. Job
31177 on lavapipe (--cfg m2v_cpu_icd): 25/25 (the blit-write lanes,
a_buffer_write_shows_in_an_overlapping_texture, the 13 render_fold lanes
at the non-split counts). Job 31176 compiled the --cfg m2v_gpu archive.
The 3090 tip and negative control and the 780M (31189) and the 5080 entry
are pending.
2026-11-14 20:36:13 -08:00
Anees Iqbal 3625b90721 SEMANTICS 2121 / RUNTIME 2331: A kernel's unit-axes variant, taken once made, never waited for
A kernel's unit-axes variant: the translator and the binding plan

In a threadgroup of one thread along an axis (Metal's threads_per_threadgroup 1
there), every thread's thread_position_in_threadgroup on that axis is 0 and its
thread_position_in_grid is its threadgroup's position, partial threadgroups
included. A kernel whose emulated simdgroups are walked predicated only because
such a position steers a synchronization (a simdgroup sum in a loop whose trip
count reads gid.y, the shape of a depthwise convolution dispatched in 8x1x16
threadgroups) pays the predicated walk's live flags and votes for nothing.

- lower::simd::uniform tracks per-lane masks for vectors of up to 8 lanes, and
  takes the lanes of thread_position_in_threadgroup and thread_position_in_grid
  on the unit axes LoweringInputs::unit_axes names as uniform.
- A kernel walked predicated (divergent::barriers, workgroup::check) states
  RuntimeFact::UnitAxes { axes: 0, relief }: bit m-1 for each mask m of axes
  under which fewer of its synchronizing blocks stay divergent (one analysis
  for all three axes, then the six others only where that one relieves).
- VariantKey::unit_axes compiles the variant; its module states
  UnitAxes { axes, relief: 0 }.
- BindingPlan::unit_axes_variant offers the variant to a dispatch whose
  threadgroups have one thread along relieving axes, where the plan's own
  variant runs it; the variant's plan sends any other dispatch back
  (dispatch_variant, NeedsVariant).

SEMANTICS_VERSION 2121: a predicated kernel's artifact states a new fact.
No new Degradation kind.

Test: engine_simd_unit_axes (lavapipe's profile, CPU interpreter, 8/16/32
lanes): predicated without the variant, unpredicated with it, Metal's words
in both; the variant traps at two threads along y (Vulkan's barrier rule), unit
x relieves nothing, and a kernel steered by x is offered no variant for unit y.

The runtime takes a kernel's unit-axes variant once it is made, never waiting

A direct dispatch whose plan offers the unit-axes variant
(BindingPlan::unit_axes_variant) takes it only where its translation is
done and each of its regions' VkPipelines is made (pipeline/unit_axes.rs).
Otherwise it settles on its plain variant, which gives the same answers,
and the variant is begun: its translation as a piece on the pipeline pool,
kept by the state (piece_holds.rs), at the first such dispatch; its objects
and pipeline notices on the program's thread at the next (no piece announces
a notice), with its regions' makings handed to the pool as any dispatch's
are. Nothing waits for the translation or a making. A dispatch planned
meanwhile is kept neither in the state's latest plans nor in its encoder's
memo, so a later one asks again. A refused translation or a failed making is
remembered, the plain variant then running those dispatches; the state tracks
at most VARIANTS such variants at once, and they live among its VARIANTS
others.

The dispatch that begins it is recorded for a later process's warm pass,
which compiles the variant and makes its regions beside the plain variant's.

The one-row and emulated-simdgroups variants are still compiled on the
encoding thread when a dispatch first asks (ComputePipelineState::settle ->
variant -> Variant::compile); this path does not follow them.

WorkCounts: unit_axes_variants_begun, unit_axes_dispatches,
unit_axes_meanwhile. No new Degradation kind. docs/API.md section 3 and the
bind module's docs state the rule and the variant; api_signatures.tsv
blessed.

Test: tests::unit_axes (m2v_gpu / m2v_cpu_icd): a 16-thread threadgroup
kernel whose simdgroup sum sits in a loop steered by gid.y; 4x2x2 never begins
the variant; 8x1x2 begins it once, runs on the plain variant meanwhile, then
settles on it, Metal's words every time.

A unit-axes variant's objects are made under its state's lock of begun variants

Two dispatches of one state could both find a translated variant gone from
the begun set while the first made its objects, and the second begin its
translation again. The first now makes them under the lock, as variant()
compiles under the lock of the state's variants.

Public: RuntimeFact::UnitAxes { axes, relief }, VariantKey.unit_axes,
LoweringInputs.unit_axes, BindingPlan::unit_axes_variant; WorkCounts
unit_axes_variants_begun, unit_axes_dispatches, unit_axes_meanwhile. No new
Degradation kind.

Verified: job 31119 at 58f7ef3c21: workspace clippy under --cfg m2v_gpu,
metal2vulkan with no feature and each feature alone, rustdoc -D warnings.
Job 31118: metal2vulkan + runtime suites 5187/5188; the one failure is the
golden hash table (24 cells of rfs_async_copy_{1,2,4}, the expected
SEMANTICS change), re-blessed on development. Job 31098 at c7f44ff865: the
engine test tests::engine_simd_unit_axes and the runtime test
tests::unit_axes on lavapipe. Iris compile-only replay of a guest's records
(31117): one depthwise state takes the variant (driver estimate 2.47M ->
0.57M cycles, spills 179:340 -> 0); the GPU-time A/B is pending.
2026-11-14 20:23:55 -08:00
Anees Iqbal e7b9c5bfdc RUNTIME 2329: A GPU route's commands are drawn one draw per command in the replay variant, indexed
The GPU route of a rate-mapped pass's host step drew each command's corners
in its merged variant: a non-indexed draw of every index, which loses the
indexed draw's vertex reuse and looks its command up per vertex. On the
Iris Xe the wide frame's pieces took 74.2 ms against 48.0 ms when the host
read the records (job 30850).

Now the step reads back each command's VkDrawIndirectCommand and its index
entry (the device address of its first index and its index size,
bind::DRAW_INDEX_ENTRY_BYTES, now public), resolves the index address to
its Metal address through the resident set's ranges and the live table's,
and draws each command as the host draws a record it read: indexed where it
is, with its instances, base vertex and base instance, in the state's
replay variant (BufferForms::Replay), each draw pushing the command's own
slot tables at its PushHole::RootTableAddress holes (CommandTables). The
commit's settle begins the replay variants for the routed executions. The
corner cutting in the piece loop goes: an indexed routed draw is cut into
index ranges as any.

Tests: the pixel and depth test asserts indexed draws are recorded on a
routed frame; the count test runs three frames, the host step making no
pipeline on any and nothing made at all on the second and third.

Public: bind::DRAW_INDEX_ENTRY_BYTES (api_signatures, api_surface).

Verified: job 30942 at the branch tip: clippy for metal2vulkan and the
runtime, the runtime under --cfg m2v_cpu_icd, the runtime and validation
under --cfg m2v_gpu; the two route tests on lavapipe. Job 30922: lavapipe
suites 78/78, API tests 15/15, rustdoc -D warnings; a negative control
(the change reverted but its tests) fails the pixel test with 0 indexed
draws recorded. The Iris and 3090 GPU-time A/Bs are pending.
2026-11-14 19:20:14 -08:00
Anees Iqbal a7e519150b RUNTIME 2326: Scheduler: a host step held at its gate gives way but to writers of its reads
What: a batch held for its host step, once the step took its gate, kept its
place in the order across queues, so every later commit of any queue whose
footprint conflicted with it waited host-side until the GPU work before the
step completed and the step recorded. A step whose uses commit could not
bound (shadowed textures, tile memory, a visibility query, an inherited
function table) conflicts with every batch that makes a tracked use, so it
held every queue, the compositor's unshared queues included. On an RTX 3090
a rate-mapped pass executing a GPU-written indirect command buffer held every
queue's commits for the 89 ms pass before it in its command buffer.

Now such a batch gives way, as it already did before its gate (the x86 Macs
take a later commit of another queue first; the M3 keeps commit order), but
for a later commit that writes what the step reads on the host (its
executions' records and ranges), which the gate does not cover, or that
shares a fence with it. The batches after it on its line give way with it.
A step whose host reads are not known (staged gathers and scatters, indirect
dispatches, loop checks, predicated executions, indirect sparse updates)
keeps its place from its gate on, as before.

How: Held keeps the step's host reads as a footprint when the gate is taken
(CommandBufferShared::step_host_reads, step_reads without the bounded-uses
requirement; Footprint::of_uses); place_of answers GivesWay for it; the
order's comparison for a batch that gives way checks fences and, for such a
step, a later write of its reads. Order itself is unchanged. Docs: the
scheduler's and order.rs's rules, gate_of, WorkCounts, and the
host-replayed-indirect-commands notice (degradation.rs, docs/API.md).

Verified: tests::held_step_order on lavapipe, three legs (results in the
report): an unshared queue's fill while the pass waits at its gate, the pass
bounded and not, goes with no look held behind it; a reset of the records the
step reads still waits behind the pass's batch. Before this change the
unbounded leg's fill went 111.40 ms after its commit, 0.2 ms before the pass
(m3-max-30848 at cd77de72d8, 3 looks held).

Also in this landing: cd77de72d8 Test: an unshared queue's fill waits for no other queue's host step.

RUNTIME 2326: an unchanged artifact's later commits on other queues no longer wait behind a host step held at its gate.
Proof (m3-max-30854, lavapipe): held_step_order's unknown-uses leg 0.17 ms after commit, 0 looks held (base 111.40 ms,
3 held); a reset of the step's records still waits. Negative control m3-max-30866 (the old gate condition): that leg
fails, 125.03 ms, 4 looks held.
2026-11-14 18:35:15 -08:00
Anees Iqbal 58de9ba9a1 The runtime's own device tests take four VkQueues by default, not the plan's 18
What: in the runtime crate's test build, DeviceOptions::default() carries queue limits of a round
robin of two VkQueues and none for presenting (TEST_QUEUE_LIMITS), beside the staging and fill
queues: four on NVIDIA's families, where the queue plan takes 18. Outside the crate's own tests the
default is unchanged (None, the plan), and on RADV's and lavapipe's one graphics queue the limits
leave the plan as it is. DeviceOptions' Default is now written out (every field named) so that its
queue_limits can be the test default there; the API signature table is re-blessed for the derive
moving to an impl, which changes nothing for a consumer.

A test whose work needs more than the default gives on a device with queues to spare (the
program's third command queue, unshared or not; a presenting queue; reserved or extra queues; a
read of the queue sharing) panics where it asks for it, on every device, and makes its device with
`queue_limits: None`: the runtime lane's LANE_QUEUE_LIMITS rule, whose failure is the device's
metal2vulkan-queue-limits-reached and so is said only on a device with queues to spare. Here the
check reads no plan, so a lavapipe run finds every such test. least_queue_plan and many_devices
measure the plan and take it.

Why: NVIDIA's driver makes and destroys one device at a time across processes, and each VkQueue
adds to both. Measured on the RTX 3090 (620.70.06, a probe build that timed each phase of a
device's opening and teardown, m3-max-30672): alone, vkCreateDevice took 540-575 ms and
vkDestroyDevice 163 ms of a device test's 1.17 s (priming 129-142 ms, loader and instance 93 ms,
the runtime's own phases under 25 ms); at 12 threads 55 device tests took 66.9 s, 1.2 s each, no
less than one at a time, their vkCreateDevice a median of 8.1 s and vkDestroyDevice 2.8 s. On the
RTX 5080 Laptop GPU a device of 2 queues took 145 ms against 445 ms with 17
(DeviceOptions::queue_limits' measurement).

Verified: tests::queue_limits::the_tests_default_devices_take_four_of_nvidia_s_eighteen_queues
(no device: NVIDIA's families give 4 VkQueues under the default, 18 at the plan; fails without the
change, whose default is the plan) and
tests::queue_limits_device::a_default_test_device_fails_where_its_work_needs_the_plan (on the
device the cfg selects: the third command queue, an unshared one past it, a presenting queue, a
read of the queue sharing and a reserved queue each panic under the default, and a plan device
makes each).

Also in this landing (the lane's later commits):
- 1edf6b494a The runtime tests' default queue limits fail a test by its live command queues, not its made ones
- 9a2bfa7bc5 Tests that ask for reserved or extra queues take the queue plan
- b9e7cd775b Tests that keep more than two command queues live take the queue plan

Proof (m3-max-30836 at b9e7cd775b): clippy plain and cpuicd 0; the no-device tests 33/33
(the_tests_default_devices_take_four_of_nvidia_s_eighteen_queues: 4 of 18 placed); lavapipe runtime
suite 2732/2732. Negative control m3-max-30752 (default_queue_limits returns None): fails at the 4-of-18
assert. No RUNTIME bump: the product default is unchanged.
2026-11-14 18:24:24 -08:00
Anees Iqbal b585744208 Boxed draws: the constant's numbers count the three draws the patches frame still fanned out
GEOMETRY_TRIANGLE_WORK's doc (5983bb3e72) split the patches frame's boxed piece
time as if the 3 draws still fanned out held 3/64 of its triangles. By the
lane's layout they are its three largest commands (161,820 and twice 89,184
indices, boxes of 110, 99 and 72 regions), 112,356 of its 301,150 triangles; a
simulation of its patches, map and bucket rule boxes the same 61 at 180, into
14,816,646 vertex-regions against the 15,286,908 counted. With their fan-out
taken out, a boxed vertex-region cost 0.49 / 0.48 ns on the Iris Xe, 0.73 ns on
the Radeon 780M and 0.13 ns on the RTX 3090, so a fanned-out triangle's geometry
stage is worth 31 / 32, 29 and 72 of them, not 26, 25 and 49. The boxed draws
held about 84 vertex-regions a triangle and took about 2.5, 2.8 and 1.1 times
their fan-out, as those ratios predict (2.7, 2.9, 1.2).

The constant stays 24, below the least (29.4): a draw it boxes costs at most
about 0.82 of its fan-out on each of the three. The doc, docs/FAST-PATHS.md's
row and the two tests' docs carry the corrected numbers; tests::rate_mapped_boxed_rule
checks the boxed draws' own average (9285 indices, 27 regions a box), fanned out
at 24 and boxed at 180.

Verified: arithmetic from m3-max-30553/30686/30687's warm pieces; the rule test
and clippy in the job that follows this commit.
2026-11-14 18:02:57 -08:00
Anees Iqbal f40cc8595b RUNTIME 2325: A rate-mapped pass's host step decodes GPU-written records on the GPU (its GPU route)
A render pass over a rasterization-rate map that executes an indirect command buffer the GPU
may write goes to the host step. There the host read every record, decoded it and drew each
command through the probe and the fan-out routes. On the consumer's RTX 3090 that step took
44.7 ms of a 65.8 ms frame, reading 781 records a frame. The only rule its executions broke was
the rate map's.

At a host step that fans the pass's triangles out, an execution whose records the GPU may write,
and which takes its merged GPU form once the rate map's rule is passed over (the cause.rs
decision), now takes its GPU route (render/executions/gpu_route.rs):
- The step records the form's prework: the head, the preprocess and the two merge passes. It
  copies each command's first corner and the merged draw's two VkDrawIndirectCommands to the
  host, submits that with a fence and waits, as it does for its probe.
- The host reads those words and no record. Each command that draws becomes one direct draw of
  its corners in the state's merged variant, with the merged header pushed
  (RenderLowering::merged_header).
- The probe and the routes take those draws as they take commands the host read: probed, then
  fanned out, boxed, in parts or region by region. A long corner draw is cut into piece-sized
  ranges, as an indexed command is.
- The host reads the records as before where the total reaches MERGED_CHUNK corners, where the
  prefix does not rise to the total, or where the prework did not complete.

RenderExecution::record_gpu's prework moves into RenderExecution::prework, which both paths
share. The replay loop takes a GPU route's corners beside the records the host read (Replayed,
StepCommand). The new counters are WorkCounts::rate_map_gpu_routes and
rate_map_gpu_route_wait_nanos.

Tests:
- New, tests::rate_mapped_gpu_route. Eight commands of a buffer that inherits the encoder's
  pipeline state: grids, one in two instances, one without indices, and the large, medium and
  wide triangles the probe flags. Each command is nearer than the one before, under LessEqual
  depth and half-alpha blending. It asserts no record read, one route, one probe and three
  flagged draws, and that the colour and Depth32Float bytes equal the encoder's own draws.
- Changed, tests::host_step_rules. Its empty command, through the route, counts as
  nothing_to_probe.

Also in this landing (the lane's later commits):
- d2728b735e: the step's commands are one vector of reads or of corners (no per-command enum of 3.3 KB); clippy.
- 51afad9359: HostReplayedIndirectCommands' cost names the GPU route's second round trip (the notice's text changes).

RUNTIME 2325: an unchanged artifact's rate-mapped host step now decodes GPU-written records on the GPU, and the
notice's text changes. Negative controls (m3-max-30703): the plan.rs lifts reverted fail
a_merged_draw_s_variant_fans_out (NotImplemented(RasterizationRateMap)); the route turned off fails
rate_mapped_gpu_route's counts ([8, 0, 1, 3] against [0, 1, 1, 3]).
2026-11-14 17:40:26 -08:00
Anees Iqbal 5983bb3e72 RUNTIME 2324: Boxed draws: a fanned-out triangle's geometry stage is worth 24 vertex-regions, not 180
The boxing rule (RUNTIME 2318) took GEOMETRY_TRIANGLE_WORK = 180 from the pieces
lane's bands frame, whose 22-by-10-pixel triangles cost 132 ns each fanned out on
an Iris Xe: mostly their fragments, which every route shades, not the geometry
stage boxing saves. Its 61 boxes on the patches frame (2-pixel quads, about 18
regions a box) lost on every device measured, the pass's warm piece:
  Iris Xe (Mesa 26.2.6)    4.64 ms fanned, 9.21 / 9.06 ms boxed  (m3-max-30553)
  Radeon 780M (Mesa)       6.47 / 6.46 ms, 13.57 / 13.57 ms      (m3-max-30687)
  RTX 3090 (620.70.06)     2.80 / 2.77 ms, 3.01 / 3.00 ms        (m3-max-30686)
On that frame, whose fragments cost little, a fanned-out triangle cost 15.4,
21.5 and 9.3 ns, a boxed vertex-region 0.59, 0.87 and 0.19 ns: 26, 25 and 49
units. The constant is the least, 24.7, rounded down, so a draw it boxes costs
no more than its fan-out on each of the three; a lower constant only boxes
fewer draws than 180 did. The doc and docs/FAST-PATHS.md's row carry the numbers.

tests::rate_mapped_boxed_draws: the 120-by-40 strip across ten regions (50
units a triangle, the patches frame's boxes about 55) is now fanned out, and a
patch across four regions' corner is boxed in its place, so the test still
boxes a draw across region borders: counts [1, 0, 3, 4, 4]. At 180 the strip is
boxed and the counts fail. tests::rate_mapped_boxed_rule checks the rule on the
patches frame's average draw: 18 regions fanned out, 4 boxed. The lane's patches
frame no longer asserts that it boxes a draw.

RUNTIME 2324: an unchanged artifact's rate-mapped draw that boxed at 180 fans out at 24.
2026-11-14 17:37:51 -08:00
Anees Iqbal acd25fd445 RUNTIME 2323: NVIDIA's RTX 3090 image uses miss a buffer's write in the same VkCommandBuffer: such a use goes in a new one
runtime_lane::heap_textures::a_buffer_write_shows_in_an_overlapping_texture,
a_heap_texture_metal_compresses_keeps_the_driver_s_compression_by_default and
an_adopted_device_stating_host_image_copy_aliases_its_heap_textures failed on the RTX 3090
(NVIDIA 620.70.06) at pins 93b and 94 (m3-max-30259, 30260, 30491, 30492): a Shared heap's
64x64 RGBA8Unorm texture, a linear image in the heap's memory, read all 4096 texels as they were
after a copy into a buffer over the same bytes. The encoder trail (each encoder its own
submission) passed at the same archive (30469), and so did the trail half of 30552 at
c6a823ff13, whose folded half failed.

A scratch probe (not landed) ran the copy and the read four ways on the 3090 (m3-max-30571):
in two blit encoders (folded into one VkCommandBuffer) and in one blit encoder, a global
TRANSFER_WRITE -> TRANSFER_READ barrier between them, 4096 of 4096 texels left alone three times
each; in two VkCommandBuffers of one submission (an MTLFence keeping the encoders apart) or two
command buffers, none. 1024x1024 and 16x16 (a Tiled shadow read through buffers) left none in any
form. Vulkan defines the answer (a buffer and a linear GENERAL image over the same memory are
host-accessible aliases, ordered by a memory dependency), so it is the driver's defect, shown by
blit folding (RUNTIME 2293) and present before it in one blit encoder. NVIDIA's 615.71.09 on the
RTX 5080 Laptop GPU answered every form right (b5080 batch m3-max-30599), so it is not listed.

Now:
- DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer, one MEASURED row: NVIDIA on the
  RTX 3090, its measurement in the module docs, the reverse direction named unmeasured.
- On a device with it (DeviceShared::splits_at_aliases), an encoder notes the bytes its commands
  write into its current VkCommandBuffer (alias_split.rs, at most 32 keys apart, a key's
  writes joined), an encoder that joined a group starting from the group's FoldOrder byte
  writes. A command through command_observing whose uses name an image of a key whose noted
  bytes meet the image's place (UseRange::shares_memory) ends the VkCommandBuffer and goes on in
  a new one, its barrier first; a folded encoder so goes on in its own after the group's tail,
  which its part's submission orders after the group's first part, the measured fence form. A
  render encoder joins no group whose order wrote bytes there. Counted:
  WorkCounts::command_buffers_split_at_aliases. Elsewhere nothing is noted.
- heap_textures' alias round trip also copies and reads in one blit encoder, and the alias test
  asserts the split count is nonzero exactly where the fact holds.
- tests::alias_split (any host): the measured shape meets; a place apart, another key, a buffer
  read, a write through an image and a new VkCommandBuffer do not; a joining encoder meets the
  group's write; past 32 keys every image use meets; only the fact's devices split. And
  device::tests::driver_facts: the 3090 takes the row at every release, the 5080 Laptop and
  desktop do not.

No new Degradation kind or notice: the split is exact. RUNTIME 2323: on the 3090 an unchanged artifact's command buffer now splits where it did not.
Verification: the msi check job and one 3090 rerun, reported with the landing.
2026-11-14 17:36:04 -08:00
Anees Iqbal 7c223b02e4 RUNTIME 2320: A host step's notice names every GPU-form rule its pass breaks; rate-mapped steps that probe nothing are counted by why
What: where `commit` keeps a pass whose indirect commands the GPU may write from the GPU form,
and the `host-replayed-indirect-commands` notice of that first rule is to be announced
(`Device::announces_host_step`, a peek that counts nothing), the decision runs again passing over
each rule once named (`render/executions/cause.rs`'s `Passed`, `DeferredPass::rules_past`), and the
notice names every rule past the first that the pass breaks too, each judged as though the rules
before it were kept: the rate map's as though the pass had none. A rule the rest takes its answer
from (the commands' one primitive type, the pipeline state and its kind, the inherited state's
tessellation, vertex function and tile memory, the buffer's size, a refusal) is never passed over.
The commit path is unchanged where the notice was announced already: the first rule decides, as
before. Three WorkCounts fields count the rate-mapped passes a host step records without a probe:
`rate_map_steps_unfanned` (no fan-out: policy, features, memoryless attachment, shadowed texture),
`rate_map_steps_nothing_to_probe` (no command read) and `rate_map_steps_probing_none` (commands
read, no draw probed); with `rate_map_probes` they count every such pass once.

Why: the consumer's walk of a 3D renderer sees one notice, naming the rate map, so whether a GPU
form for rate-mapped passes would cover its pass (rules past the rate map) is unknown; and about
half a host step a frame there probes nothing, for no counted reason.

The notice's text changes (a RUNTIME bump at landing). API: three public WorkCounts fields
(api_signatures.tsv blessed); nothing removed.

Verified: tests::host_step_rules on lavapipe (an indexed triangle and an empty command of a
GPU-written buffer, executed in a rate-mapped pass: the rate map's notice names that rule alone;
with a visibility result mode set, the notice names the visibility rule, then the rate map past
it, which fails without this change; the counts: probed once each, the empty command's pass
probing none).

Also: host_step_rules: the buffer inherits the encoder's pipeline state; Degradation::HostReplayedIndirectCommands says its notice names the rules past the first.

Verified (lane icbgpu, msi m3-max-30616 at eec7881980, lavapipe): clippy -D warnings plain
and --cfg m2v_cpu_icd 0; 74/74 over host_step*, icb_*, indirect_command_buffer*,
notice_command_buffers, rate_map*, rate_mapped*, degradation*, trail_gpu_forms and
draw_shape_notices, the new host_step_rules among them; api-signatures --check clean.
Landed (main) at once: the hand negative control, gpucfg clippy and rustdoc run after.
RUNTIME 2320: the notice's text and what a run records change. WorkCounts gains
rate_map_steps_unfanned, rate_map_steps_nothing_to_probe, rate_map_steps_probing_none.
No Degradation kind.
2026-11-14 17:04:25 -08:00
Anees Iqbal 257bdd7d14 SEMANTICS 2117 / RUNTIME 2319: GPU-written ICB records naming released or reused state IDs run what a Mac runs
What: two changes to how an indirect command's record names a pipeline state the program
released.

1. A record's state word gains a bit, KERNEL_PIPELINE (layout::KERNEL_PIPELINE = 2,
   CommandRecord::kernel_pipeline, RecordView::kernel_pipeline). A kernel's pipeline setter writes
   it wherever the token names a state. A kernel's copy carries it with the pipeline word, and its
   "reports" test now reads RETAINED alone. A kernel's compute reset keeps the bit beside RETAINED.
   Metal's reset leaves the command executing with the pipeline it had (measured on the M3 Max and
   the M4: reported cleared, run by the next dispatch). For a kernel's write, that pipeline is the
   state the write resolved, so the retained pipeline keeps saying the kernel wrote it. The CPU's
   compute reset does the same. The CPU's pipeline setter clears the bit, and a record the CPU
   wrote never carries it. The replay's state-word check and decode accept the bit; either bit
   beside no pipeline is still malformed. Where the bit is set, the runtime's host step, getter and
   identifier ignore the state the CPU set and resolve the ID by its holder as the GPU last could
   write it.
   Case 4 (the CPU set x, x released, y took the ID, then a kernel writes the state) now runs y, as
   the M3 Max and the 5300M do; before, it ran x, announced. Case 5 (the kernel writes only the
   buffers) runs x unannounced, as every Mac does. The host step no longer guesses, so the
   "Unsure" announcement and may_name_another are gone.

2. The device keeps the program of each freed pipeline state ID's last holder (FreedPrograms):
   one per ID, dropped when any state takes the ID. Every live indirect command buffer of the
   device holds the store and the device holds it weakly, since a program holds its device. A
   buffer the GPU may write takes the store's programs at its first such write. Case 1 (x released
   before the write, its ID taken by no one) now runs x, as the M3 Max and the UHD 630 do; the
   Radeon Pro 5300M fails the command buffer instead. Where Macs disagree, the cheaper answer is
   taken: failing the CB would need a failure path decided mid-flight in a host step. Bound: one
   program per freed ID that no state retook, so at most the peak count of live
   supportIndirectCommandBuffers states plus placed IDs, kept only while an ICB of the device
   lives. Still announced (ReleasedCommandState, the command runs nothing): a state released while
   no ICB of the device lived, and one past the ID's last four holders.

SEMANTICS_VERSION 2117: kernels that set pipelines now write the state-word bit, so their SPIR-V
and golden hashes change (re-blessed on development). api_signatures blessed for the new field and
method. No new Degradation kind. RUNTIME_VERSION is left to the landing.

Tests: indirect_commands::tests::records (a_kernel_s_pipeline_is_told_from_the_cpu_s, plus the
random field round trip with the bit). The engine_indirect_commands expectations of kernel writes
carry the bit, and the kernel reset keeps it. Runtime: released_programs (the freed store's one
program and its release on take) and notice_command_buffers (a host-step Unrun now reached through
a kernel's write of a state released while no ICB lived). Validation runtime_lane:
indirect_host_steps (case 1 runs the template; the forced notice past four holders and while no
ICB lived; case 4 runs the flat template; case 5 runs the template unannounced) and
indirect_executions (the GPU-writable copy case no longer announces). Run on lavapipe in the
lane's msi job; the results go in the lane report.

Also: Pin the notice of a state released while no buffer of commands lived; Replay tests: the kernel's pipeline bit runs, an unknown bit faults.

Verified (lane relstate, msi m3-max-30537): clippy --cfg m2v_cpu_icd exit 0; runtime tests
24/24; validation tests 113/113 on lavapipe, the new released-state cases 1, 4 and 5 among
them. Landed (main) at once: the plain clippy and translator rerun (m3-max-30546) and the
hand negative control (m3-max-30555, steelbrain/relstate-nc) run after landing; the engine
golden hashes of kernels that set pipelines are re-blessed on development.
RUNTIME 2319: what a GPU-written record naming a released or reused state runs changes.
2026-11-14 16:21:41 -08:00
Anees Iqbal 8a374ba0e5 RUNTIME 2318: Rate-mapped draws whose triangles lie in few regions are boxed, not fanned out
At a host step under RateMapRegionPolicy::FanOut, a probed draw the probe flags nothing of
goes through the fan-out variant, and so does a flagged draw's fanned part. Its geometry
stage emits a copy of each triangle per region it touches. On the pieces lane that stage costs
a fanned-out triangle what 371 to 739 vertex invocations for one region cost. On an Iris Xe
that is 130.7 ns a triangle, against 0.352 ns an index-region through the region-copy variant.
On a 3D renderer's frame there (tm91-iris), about 68 of the 125 ms of rate-mapped pieces a
frame tracks the probed and fanned geometry, which is 383 fanned draws a frame.

Such a draw is now boxed when that holds no more work: drawn through its region-copy variant
into the boxes of the regions its triangles reach by the probe's bounds (fan_out::run_boxes of
Probed::reach, a part's from its own blocks), as a run is.
- The rule: rate_mapped_pass::boxes_cheaper, regions x (vertices + REGION_DRAW_WORK) <=
  GEOMETRY_TRIANGLE_WORK x triangles (a direct draw; a strip's triangles counted at
  vertices / 4).
- GEOMETRY_TRIANGLE_WORK = 180: about half the least that a fanned-out triangle cost against a
  vertex for one region on the four devices measured (Iris Xe 371-500x, Radeon 780M 739x,
  RX 7900 XTX 570x, RTX 3090 654x; the constant's doc has the numbers). The rule is
  device-independent, keyed to no app, map or shader.
- No new pass, variant or readback. fan_out_asked asks for the region-copy variant (settled at
  commit already) and the recording takes the boxes (RenderLowering::boxed_reach).
Pixels: the routes already share a pass and put a vertex at one window position. A pixel lies
in one region, whose copies keep the draw's order of instances and primitives in either route.
The bounds are widened as the probe's are, so a box holds every pixel a copy would cover: the
same pixels and depth wherever today's routes agree.
A boxed draw rides whole in its piece, as a fanned-out one does; its work is no more than its
fan-out's.
Counts: WorkCounts::rate_map_boxed_draws and rate_map_boxed_vertex_regions (CopyRoute::Boxed).
A boxed part is not a run, so rate_map_region_runs and rate_map_parted_region_triangles leave
it out.
Test: tests::rate_mapped_boxed_draws, 6 commands blended at half alpha:
- boxed: a 10-pixel patch, a 120x40 strip across region borders, a patch of two instances,
  and a patch without indices;
- fanned out: a whole-target grid and one wide quad.
It checks probes 1, flagged 0, fanned 2, boxed 4, region-copy draws 4, and boxed vertex work
under the whole table's. The pixels equal the encoder's bit for bit. Under Exact nothing is
boxed.

Also (2f82e025be): The pieces lane draws each command's own patch: rate_mapped_pieces_host_step_patches; (01d8344d2a): A command's settle at commit boxes no draw; the boxed test's counts keep their function's name.

Verified (lane ratemap3, msi m3-max-30513 at 01d8344d2a, llvmpipe): rate_map|fan_out
26/26, the new rate_mapped_boxed_draws among them (probes 1, flagged 0, fanned 2, boxed 4,
region-copy draws 4, boxed vertex work 10752 against the whole table's 997056; pixels equal
the unboxed execution; nothing boxed under Exact); rate_mapped_fan_out, region_boxes, pieces
and depth_equal unchanged. Landed (main) at once: clippy x3 (m3-max-30514), the Iris A/B
and the hand negative control run after landing.
RUNTIME 2318: what a run records and draws changes. No Degradation kind.

API: two WorkCounts fields added (rate_map_boxed_draws, rate_map_boxed_vertex_regions);
api_signatures.tsv blessed. A consumer building WorkCounts by struct literal must name them.
2026-11-14 16:05:31 -08:00
Anees Iqbal 497e1f4ec0 SEMANTICS 2116: NVIDIA's float denormals under the 16-bit float controls are the device's, noted
What: a new DriverWorkaround, FloatDenormalsKeptUnderHalfControls, with rows for NVIDIA's driver on
the RTX 3090 and the RTX 5080 Laptop GPU (the GPUs its MetalFloatDenormals rows name). In an entry
that declares the 16-bit float controls (narrow::controlled_modes) on such a profile, the float
operations the deviation covers record PrecisionNote::DeviceDenormals and the module requires no
VkProperty::MetalFloatDenormals. An entry that declares no float-controls mode keeps the
deviation, and so does every other driver.

Why: runtime_lane::driver_deviations::fused_pairs_answer_metals_nans_and_denormals failed on the
RTX 5080 Laptop GPU (615.71.09) and the RTX 3090 (620.70.06) at pin 93b. The same 33 of 4,096
words in each fixture kept a denormal where Metal answers zero (thread 0x11: 1e-20 * 1e-20 gives
0x116c2; thread 0x29: the smallest denormal times 2^30 gives 0x04000000). That held for the lone
product a * w as much as for the fused pairs, so the fused pairs are not the cause. The fixtures
compute half in 16 bits, so their entries declare RoundingModeRTE, DenormPreserve and
SignedZeroInfNanPreserve for 16 bits. The deviation's probes (nan_denormals,
nan_denormals_fast) declare no mode and flush on the same GPUs. Vulkan leaves 32-bit denormals to
the implementation when no 32-bit mode is declared (the NVIDIA profiles report independence ALL),
and NVIDIA states no shaderDenormFlushToZeroFloat32. So the device's answer stands (owner rule 1),
scoped and noted; nothing is flushed in the shader. RADV on the Radeon 780M (Phoenix and Hawk
Point, Mesa 26.2.6) declares the same modes there and passed the test at pin 93b, so it keeps the
deviation. MoltenVK states no shaderDenormPreserveFloat16, so its entries declare no 16-bit mode.

The device test now decides "Metal's" per kernel (requires_property), as the float_denormals tests
do, and asserts DeviceDenormals where the kernel does not require the property. The new unit test
float_denormals_under_the_half_controls_are_the_devices_where_its_driver_keeps_them checks the
5080 Laptop GPU, the 3090, the desktop RTX 5080 and the 780M against fmx_fma_precise,
fmx_fma_fast and nan_denormals. It fails without the rows.

Docs: the workaround's doc, the DEFECTS and MetalFloatDenormals table docs, the deviation and
property docs, PrecisionNote::DeviceDenormals, docs/API.md's device-denormals entry,
docs/FAST-PATHS.md's denormal row, the signature table. SEMANTICS_VERSION 2116: NVIDIA modules'
notes and requirements change. No new Degradation kind.

Landed (main) at once, before its check: the lane's check (clippy plain
and cpu_icd, the touched unit tests, the two denormal device tests on
lavapipe) and the NVIDIA device proof run after landing.
2026-11-14 15:44:20 -08:00
Anees Iqbal dd486250e3 RUNTIME 2317: A kept draw reading its pass's copy by the area rule takes its reader identity and query
What:
- render/draw_again.rs, rebound.rs: a kept reader drawn again or rebound
  takes its reader identity and occlusion query as every step takes them,
  whichever form it reads through (the copy taken before the pass among
  them), and records its drawing commands inside the query. A debug
  build checks each draw again's identities against the step's
  (Readers::taken).
- slow_submissions.rs, command_buffer/submit.rs: a batch held in the
  scheduler's group gets its slow line, timed from its submission to its
  hold, naming the group.
- Tests: kept_shadowed_draws counts a frame's begins as the command buffers
  it began (WorkCounts::command_buffers_begun), not the device's begin
  calls, which begin-ahead spares move; kernel_end_device's slow-line
  check expects a group held by the groups' ends.
docs/API.md and env_vars.rs describe the slow line.

Why: at pin 93b on the 780M (devlegs), kept_shadowed_draws' kept frame
recorded 3 queries where the apart frame recorded 4: a kept draw through
the pass's copy skipped its reader's query, so its coverage was never
learned. kernel_end_device's slow line was missing for a batch held in a
group.

How verified (lane keptquery): 780M (RADV PHOENIX) at 918d3319ea,
m3-max-30392: 86/87, all four kept_shadowed_draws pass with queries 4 in
both frames, 31 of 355 kept draws checked taking an identity, begins equal
to the command buffers begun; the one failure was its own new group check,
fixed in 68c8917098. Negative control at 400efe7932, m3-max-30393: 3 of 7
fail as at 93b (queries 3 vs 4; slow line absent). Lavapipe 87/87 and
clippy plain and cpu_icd at 918d3319ea (um790 m3-max-30313). The 3090 run
(m3-max-30394), lint (m3-max-30391) and the 780M kernel_end rerun at
68c8917098 run after landing.
RUNTIME 2317: a kept draw records a query and a slow line it did not.
2026-11-14 15:17:52 -08:00
Anees Iqbal 1858a2fb34 RUNTIME 2316: Rate-mapped passes count their region-copy and fanned-out vertex work by box size
What: new WorkCounts fields
- rate_map_whole_copy_vertex_regions, rate_map_own_copy_vertex_regions,
  rate_map_run_vertex_regions: vertices x regions drawn through the
  region-copy variant into the whole table, by the encoder's own draws,
  and by a host step's runs;
- rate_map_fanned_vertices, rate_map_fanned_box_vertex_regions: vertices
  fanned out through the geometry stage, and those times the regions of
  their probe-bounded boxes;
- rate_map_fanned_vertices_boxed_16, _64, _256: fanned-out vertices whose
  boxes hold at most that many regions.
render::fan_out::Probed::of also ORs every block's bounds (its reach).
FAST-PATHS' FanOut row, docs/API.md and rate_mapped_pass.rs list them.

Why: on Iris a whole-table region copy costs about 16x a geometry-stage
fan-out a triangle, and the consumer's 127 ms a frame of rate-mapped GPU
time cannot be split between the encoder's own whole-table draws, runs and
fanned draws from today's counts. A plain sum cannot say how much fanned
work lies in small boxes, which a cheaper route for few-region draws
would take.

How verified (lane ratemap3, msi m3-max-30401 at 7a17a61829): render::fan_out
unit tests 6/6; rate_map device tests on lavapipe 19/19, with exact counts
in a_host_step_fans_out_the_commands_the_probe_does_not_flag (encoder frame:
own == whole == (5 x 3072 + 9) x table regions; host step: no whole-table
work, fanned vertices exact; under Exact all zero); clippy -D warnings
plain, cpu_icd and gpu; api_signatures --check clean.
RUNTIME 2316: what a run records changes. No Degradation kind, no
behaviour change.
2026-11-14 15:16:31 -08:00
Anees Iqbal 057b794f5b SEMANTICS 2115 / RUNTIME 2315: rate-mapped region copies record a box of regions per multi-draw
What: a draw through its region-copy variant recorded its regions 16 at a time (the device's
viewports). Each recording set 16 scissors, pushed its first region and stored DrawIndex as
ViewportIndex. On a guest frame the host step made about 4.7k such recordings a frame (Iris and
RTX 3090), while the GPU sat idle waiting for the step.

The variant's four clip distances already keep each copy to its region's pixels, as a fanned-out
copy's are kept; the per-region scissor only culled. Now:
- The vertex function draws region first + (DrawIndex / c)*nx + DrawIndex mod c from a pushed
  box (PushField::RegionBox, renamed from RegionFirst, now [first, columns]).
- It stores 0 as ViewportIndex, the recording's one viewport, so it writes every output the base
  variant wrote.
- The recording sets one viewport and its box's union scissor.
- A direct draw records a box as many regions at a time as one vkCmdDrawMultiEXT takes
  (maxMultiDrawCount - 1), its rows in order. A run records one recording per box its bounds
  reach; any other draw records the whole table in one or a few.
- Indirect draws keep one region a recording, under that region's scissor.
- The variant still needs shaderOutputViewportIndex and shaderDrawParameters; it no longer
  needs multiViewport.

Exactness: a border between two regions of a recording holds no pixel centre and no sample at
Vulkan's standard sample locations (at least 1/16 px inside a pixel, up to 8 samples), while each
copy's clip distance there is zero up to rounding. A box is recorded one column (row) at a time:
- in a pass whose custom sample positions put a sample on a pixel's left (top) edge;
- on a device without standardSampleLocations;
- in a 16-sample pass.
See render/fan_out.rs, folds.

A box's recording and the recordings of each of its regions alone run one pipeline that writes
the same outputs. They differ only in their dynamic viewport and scissor values and the integer
region each draw selects (Vulkan's Invariance appendix, Rules 2 and 4). The agreement between the
encoder's region-copy vertex function and the host step's fan-out geometry stage stays the
existing FAST-PATHS known gap, checked by running: no new near-equivalent, no new accepted
difference.

SEMANTICS_VERSION 2115 (the variant's module and push layout); ARTIFACT_FORMAT_VERSION 523 (the
PushField tag); RUNTIME_VERSION 2315 (what a region-copy draw records). Docs: rate_mapped_pass.rs,
render/fan_out.rs, bind/fan_out.rs, the translator's region-copy plan and store, docs/API.md, and
the FAST-PATHS fan-out row and known gap. docs/REFUSALS.md regenerated unchanged; api_signatures
blessed. No new Degradation kind, no WorkCounts field.

Tests:
- render/fan_out/tests.rs: run boxes, box recordings, box scissors, the fold rule.
- tests::rate_mapped_region_boxes (device test): the same two passes drawn directly (boxes) and
  indirectly (one region a recording, its own scissor), additively blended into RGBA16Float with
  a ground plane, border-crossing slivers and off-screen and w-straddling triangles, then an
  Equal pass, compared bit for bit, with the recordings counted.

Verified (lane ratemap2):
- msi m3-max-30288 at 9240cc0ea6: clippy -D warnings, all targets and features, plain, cpu_icd
  and m2v_gpu, exit 0; rustdoc -D warnings exit 0; translator touched tests 226/226; runtime
  33/33; lavapipe 13/13.
  - rate_mapped_depth_equal: 0 failing pixels in every pairing under Exact and FanOut. Without
    the ViewportIndex store, FanOut's mixed-route pairings had 2853 of 89483 (m3-max-30235).
  - rate_mapped_region_boxes: direct 3 draws in 3 recordings against indirect 3 in 624, 0 texels
    differ, Equal-pass mismatches [0, 0].
- Negative control (each clip distance widened by one pixel): rate_mapped_region_boxes fails,
  25464 texels differ, Equal-pass mismatches [11019, 0].
- The Iris GPU-time A/B (ms01, m3-max-30315, exclusive) is running; the consumer's renderer run
  at the next pin is the workload proof (rate_map_piece_gpu_nanos a frame on Iris).

Landing note: docs/API.md merged by hand with RUNTIME 2314's probe-parts sentence (both rewrote one
paragraph), and rate_mapped_pass.rs's Fan-out now says the probe runs in parts (RUNTIME 2314).
2026-11-14 14:32:33 -08:00
Anees Iqbal 744dfd4d9d RUNTIME 2314: A host step's rate-map probe runs in parts, each on the GPU while the host records the next
A rate-mapped pass whose records the GPU may write is recorded by a host step that fans
its triangles out to the map's regions after a probe: every command's draw recorded once
more through the probe variant, submitted, and waited for before the routes are
recorded. The host recorded the whole probe with the GPU idle, then sat idle itself for
the probe's whole GPU time. On a 3D renderer's frame on an RTX 3090 (pin 91b) that wait
was 23-35% of host_step_nanos, 5-7 ms of a ~22 ms step, three steps a frame.

Now the probe is recorded in parts: at least 32 commands a part and at most 8 parts a
probe (DeferredPass::probe_parts). Each part is submitted with its own fence once
recorded, so the GPU runs it while the host records the next, and the host waits once,
for every fence, after the last part (CommandBuffer::submit_fenced / wait_fenced, the
halves of rerun::submit_waited, which the predicated loop's runs again keep using). A
part may hold commands of several executions; its draws take the flag words one
recording would give them (the index carried from part to part, each command's slot by
its place among its execution's commands that run), so the probe's words, the routes
and the pixels are the same in any parts. A probe that stops (a barrier, a draw that
writes memory) stops for the rest of its execution; a part recorded in more than one run
sends the execution region by region, as one recording did. Every part submitted is
waited for before the step goes on, a failed later recording's too.

Ordering: the parts go on the command buffer's own VkQueue, in order, and each part's
primary begins with the segment's full barrier (EncoderCore::segment), as the one
probe's did, so part k+1 follows part k and the pass follows the last; no semaphore and
no other queue's edge is added.

Cost: up to 7 more submissions and probe render pass instances a step (load and store in
GENERAL, no fragment). WorkCounts::rate_map_probe_parts counts the parts;
rate_map_probes stays one a step; rate_map_probe_gpu_nanos sums the parts' times;
rate_map_probe_wait_nanos is now the host's one wait after the last part.

Test: tests::rate_mapped_fan_out's a_host_step_probes_many_commands_in_parts: 72
commands (the eight's pattern nine times) probe in 3 parts with the same flagged,
fanned-out and parted draws, each 9 times the eight's, and the encoder's pixels; the
eight-command test asserts one part. The workload takes its command count.

New WorkCounts field: rate_map_probe_parts (api_signatures blessed). No new Degradation
kind. No RUNTIME_VERSION bump (main does it at landing).

Also in this landing: the icb_reads example's --rate-map and --wide-every W (the A/B shape);
the parts' recordings joined once, after the wait; and the split fenced wait reaching the
device's functions inside each exit-guard section (a predicated loop's run again on the loop
thread).

RUNTIME_VERSION moves: a host step's probe of an unchanged artifact is now recorded and
submitted in parts.

Verified (lane icbstep2, msi lavapipe):
- m3-max-30234 at c41586a13d: clippy -D warnings plain and cpu_icd (runtime, all targets, all
  features) exit 0; 63/63 for rate_map|rerun_arenas|indirect_command_buffer|icb_|host_step|
  fan_out, among them the ordering tests a_flagged_draw_s_parts_take_each_triangle_once_in_order,
  a_host_step_s_instances_follow_their_commit_in_the_program_s_order,
  a_recovery_s_carry_waits_for_a_write_without_the_lock and
  an_unshared_head_at_its_host_step_goes_before_work_whose_room_came_after_its_commit; the new
  a_host_step_probes_many_commands_in_parts reports probes [1,36,36,36], 3 parts and 5
  submissions, with the encoder's pixels.
- Negative control m3-max-30241 (one part a probe): the new test fails, "the probe's parts of
  32, 32 and 8 commands, left: 1 right: 3", with the same probe counts.
Expected, not yet measured: the 3090 release A/B (host_step_nanos and rate_map_probe_wait_nanos
a step) follows. The consumer's renderer run at the next pin is the workload proof.
2026-11-14 14:00:01 -08:00
Anees Iqbal 1a6fcf6ece A kernel's patch control-point input stays refused: pin it and say why
What: an ABI test, a_kernel_takes_no_control_point_input, decodes one synthetic module's
air.patch_control_point_input (its declared, never-defined fetch function and two fields) on a
post-tessellation vertex function and checks that the same input on a kernel is refused,
InvalidInput(Abi(UnknownKey)) at argument 0 and that key. docs/API.md's kernel [[stage_in]]
section states the refusal, Metal's answer, and the two forms through which a kernel does read
vertices by index.

Why: Metal refuses the shape too. `metal` (32023.922) writes no control-point input for a
kernel: every MSL spelling fails to compile ("invalid type 'patch_control_point<CP>' for input
declaration in a kernel function"). A kernel assembled by hand in the post-tessellation shape
(xcrun metal-as, metallib) gives a library and a function on an M3 Max under macOS 27.0.1, whose
reflection lists both fields as control-point stage-input attributes. Every compute pipeline of
it fails, "Internal compiler error.", under Constant, ThreadPositionInGridX (rates 1 and 2, a
region origin of 2), ThreadPositionInGridY and both indexed steps. Without a descriptor Metal
asks for one, and a vertex step function in a compute descriptor stops at a framework
assertion. As a check that the module was well formed, the same body as a [[patch(quad, 4)]]
vertex function makes its render pipeline and fetches patch p's point j as element 4p + j. As a
check of the host and the descriptors, an MSL kernel [[stage_in]] of the same attributes makes
a pipeline under every one of them. So the refusal stays where it is, at the pipeline compile.
The ABI has no error kind for a role outside its stage other than UnknownKey (its documentation
covers a role the stage does not accept), so the error kind is unchanged and REFUSALS.md does
not move.

Verified: the M3 probes ran as potluck jobs m3-max-30194, 30197, 30201 and 30203. The test,
clippy, and a negative control (the role allowed on a kernel, which fails the test) ran in one
msi job, named in the report.

Checks (msi m3-max-30227 at 70b57adf99): clippy -D warnings plain and cpu_icd exit 0; 74 touched
tests pass; negative control (the refusal made to accept) fails the new test, exit 100. No
RUNTIME bump: the refusal and its error are unchanged.
2026-11-14 13:56:59 -08:00
Anees Iqbal 22fa0997b1 RUNTIME 2312: A write-only argument-buffer use of a texture whose writes Metal drops names none of its image
What. A command that makes a texture resident whose writes Metal drops
(metal::format::writes_dropped: the 4:2:2 formats, the subsampled and packed
two-plane YCbCr ones) names no use of it where its binding plan's heap holds
it at no element (no WriteSource::HeapEntry of its token): every heap storage
array holds such a texture as its neutral (bind::heap's Fit::Dropped), and a
kernel that only writes it declares no sampled array, so its function reaches
none of the texture's image (binding.rs, resident_uses_into; the storage-only
test holds_write_shadow becomes heap_holds, by class access or any).

Why. A kernel that only wrote a YCBCR8_420_2P texture through an argument
buffer (useResource WRITE) named the texture's image as a written use. That
use matched the texture's converted shadow, so the command's shadow planning
made and recorded the planes' conversion (ShadowCopies::prepare ->
YCbCrConversion::make), and on a device that converts 4:2:0 itself (Iris Xe:
the consumer's pin 92 Iris leg, writes_through_argument_buffers_of_two_plane_
ycbcr_textures_are_the_slots) that first conversion announced
ycbcr-filter-not-exact though nothing read the texture: relayed in default
mode, fatal in strict mode. The write itself was dropped, as Metal drops it.
4:4:4 textures already named only their write shadow. Now such a command
converts nothing and announces nothing; a command whose function reads the
texture through the argument buffer (a sampled array holds it) converts it
and announces the device's conversion as before.

Test: runtime_lane::ycbcr_argument_writes::a_kernel_that_only_writes_a_held_
420_texture_converts_none_of_its_planes (lavapipe and GPU lanes): resident
WRITE and READ|WRITE, the write-only kernel records no conversion
(ycbcr_refreshes + ycbcr_whole_conversions), announces no
ycbcr-filter-not-exact and leaves the planes' bytes; a kernel reading it
through the argument buffer records one conversion and announces the notice
where the device converted the texture itself. lavapipe converts 4:2:0
through Metal's arithmetic, so there the conversion count is the check that
fails without the fix. docs/API.md's catalogue entry and ycbcr.rs's writes
bullet say so.

Verified (lane ycbcrnote, at 12dbbcc67e on fe38b678dc):
- msi lavapipe m3-max-30151: touched lane tests 173/173 and runtime cpu_icd
  tests 238/238; clippy -D warnings plain and cpu_icd exit 0. Negative control
  in the same job (binding.rs back to fe38b678dc): the new test fails at "the
  writing command converted the planes".
- RTX 5080 (b5080 entry ycbcrnote-held420-130832, prebuilt m2v_gpu archive):
  passes; device conversion true, write-only commands announce nothing, the
  reading command announces YCbCrFilterNotExact once.
- msi m3-max-30159: clippy -D warnings under m2v_gpu and rustdoc -D warnings
  exit 0.
Expected, not run: the consumer's Iris strict test passes.
RUNTIME_VERSION moves: the same artifact's write-only commands now record and
announce nothing where they converted and announced before.
2026-11-14 13:11:54 -08:00
Anees Iqbal dfda37628d RUNTIME 2311: ICB records lie in pooled memory where a held pointer import taxes every submission
What: DevicePolicy gains indirect_records (IndirectRecordsPolicy, a runtime
choice no profile carries). Under the default, Untaxed, an indirect command
buffer's records and overflow slots take fresh pages of the runtime's own
(a pointer import held for the buffer's life) only where the device's import
tax check has not found that a held pointer import costs every submission, or
has not answered; where it has (RADV, ANV on i915), they lie in pooled
host-visible memory as the runtime's other buffers do. Under Carried, which
exact_answers() selects, they lie in fresh pages wherever the device imports
host pointers, as before, so a recovery keeps them. A recovery of a taxed
device under the default loses pooled records and rewrites them as a new
buffer's (carry.rs's existing pooled path); the device-recovered notice
already counts such buffers ("N indirect command buffers, M of them whose
records were lost"), as on a device without pointer imports and for
device-local records on discrete GPUs. No new Degradation kind.

Why: on a Radeon 780M (RADV, Mesa 26.2.6, Linux 7.3.3) beside a guest game
whose ICB records were the process's only pointer imports (3 buffers, 19.6 MB),
the submission thread had 5 windows of 65-140 ms in 12 s in which every
amdgpu_cs_ioctl waited in mmu_interval_read_begin or returned EAGAIN (373 of
the run's 382 failed calls, retried at once by libdrm). RADV lists every
imported memory in every CS, amdgpu re-faults every userptr page each CS and
adds the CS fence to every listed BO, so a page migration of one of those
pages (kcompactd, khugepaged, and the runtime's own block making in direct
compaction) waits in amdgpu_hmm_invalidate_gfx for all the process's GPU work
in flight while every submission waits behind it. With no userptr BO listed,
compaction migrates pages without waiting on any fence.

Docs: the FAST-PATHS ledger row (default, switch, the recovery cost, the
measured chain), API.md's device-recovered text, HOWTO's residency section,
fresh_pages.rs, indirect_command_buffer.rs and carry.rs, the conformance
crate's Policy::Exact list. API: signatures blessed, api_surface row,
REFUSALS.md regenerated.

Tests: tests::icb_records_policy (Linux, cpu_icd/gpu): the import tax forced
Holds/Fails; under Untaxed+Holds the records lie in pooled memory, no fresh
pages made, a recovery moves them and its notice counts 1 lost; under
Untaxed+Fails and Carried+Holds in the runtime's own pages, kept, 0 lost. The
translator's fast_paths names the choice, checks it keys no profile and that
exact_answers() takes Carried. icb_carry_race's own-pages cases run on a
Carried device (device_recovery::carried_device), so they assert the carry of
own pages whatever the device's verdict.

RUNTIME_VERSION moves: where records lie and what a recovery keeps change on taxed devices.
New public items: metal2vulkan::device::IndirectRecordsPolicy { Untaxed, Carried } and
DevicePolicy::indirect_records.

Verified, msi m3-max-30127 at cba1ec585a (the fix plus a test-only fix: DevicePolicy is
non-exhaustive, so the tests set the field on a copy):
- clippy -D warnings --all-targets --all-features: metal2vulkan + runtime plain 0, runtime
  --cfg m2v_cpu_icd 0;
- translator tests 49/49 (fast_paths with the new choice, its no-profile key and exact_answers
  tests, api_surface, api_signatures);
- runtime under cpu_icd on llvmpipe 34/34: icb_records_policy, icb_carry_race, icb_records_home,
  indirect_command_buffer*, device_recovery_every_kind, device_recovery_carry.
ICB-RECORDS lines:
- Untaxed with the tax forced Holds: records not in own pages, 0 fresh-page buffers, the
  carry moved them, notice "1 of them whose records were lost";
- Untaxed with the tax forced Fails: own pages, 2 fresh-page buffers, kept;
- Carried with the tax forced Holds: own pages, 2, kept.
Workload proof owed: reims's traced loaded-desktop walk on the 780M (per-CS get_user_pages 0, no
-EAGAIN windows).
2026-11-14 12:49:09 -08:00
Anees Iqbal ce54ad8b25 RUNTIME 2310: an unshared commit on its way goes before another queue's batch whose room came after it
A scheduler pass that found another queue's batch's room let it go while an unshared queue's
commit there, taken in, waited only for the runtime: its host step (handed to the steps'
thread in the same pass), its submission checks, or a shared event's value whose signal was
already submitted and had not landed. Order::next refused the unshared head and sent the
other batch; the unshared command buffer then waited for that whole batch on the GPU. In
reims's traced walk ld91 (um870 Radeon 780M, guest compositor beside gameload) another queue's
batch went in while a compositor's command buffer so waited ahead of 33 of the 46 frames
answered more than a refresh late: 20 at its host step (e.g. take 1794684425.009: gameload
#19392 committed -3.0, submitted +2.6, inside WS #19398's commit +2.3 -> submit +2.8), 13
waiting for the landing of its other unshared queue's signal.

The rule (unshared_hold.rs, "Commits on their way"): each unshared commit carries its place
among those posted on its VkQueue (SlotShare::posted_unshared now answers it). Each look
collects the unshared heads on their way (on_its_way: binary semaphores ready, every event
value reached or reached by a submitted signal, held only for its host step with no pipeline
making pending, or for its checks) that wait behind no earlier commit (is_behind), and a
batch whose room came is held (behind_commits) while one posted before its noted count leads
its line so. The step's end, the checks or the landing wake the scheduler's thread, whose
next pass sends the unshared one first. Each look asks again: a head waiting for anything
else (a value nothing submitted reaches, a binary semaphore, a making, a decode, a rebind) or
behind an earlier commit (the held batch's own included) holds nothing, so neither waits for
the other. Other threads' passes leave such batches to the scheduler's thread
(first_for_the_thread widened to heads on their way), which they wake. Counted in the
existing WorkCounts::heads_held_for_unshared_commits (doc widened). No switch, no public item,
no Degradation kind. Docs: unshared_hold.rs, FAST-PATHS unshared-isolation row, API.md.

Tests: unshared_hold unit test of behind_commits with places on their way; queue_share_device
(lavapipe), each leg by the scheduler's pass and a committing thread's:
an_unshared_head_at_its_host_step_goes_before_work_whose_room_came_after_its_commit,
an_unshared_head_waiting_for_a_signal_to_land_goes_before_work_whose_room_came_after,
an_unshared_head_behind_an_earlier_commit_of_the_held_queue_holds_nothing,
an_unshared_head_waiting_for_a_value_nothing_submitted_reaches_holds_nothing.

RUNTIME_VERSION moves: what a run submits, and in what order, changes.

Verified (msi lavapipe):
- m3-max-30046 at 71c8bf7337 (the rule plus a test-only fix), runtime crate, --all-features
  --all-targets -D warnings:
  - clippy plain and --cfg m2v_cpu_icd: 0;
  - 103/103 tests: unshared_hold, queue_share, queue_share_device, scheduler,
    scheduler_held_wakes, scheduler_wakes, inbox, waiter_submits, commit_and_submit, hold_sites,
    dispatch_pending, queue_limits_device, stall.
- New tests, each run once through the scheduler's pass and once through a committing thread's:
  - at its host step: the other buffer began 0.168 / 0.199 ms after the unshared one;
  - waiting for a signal to land: 0.183 / 0.206 ms after;
  - behind an earlier commit: holds nothing;
  - waiting for an unreached value: holds nothing.
  The RV2303 tests still pass.
- Negative controls:
  - m3-max-30021, rule off: both "goes before" tests fail (the other buffer began 1.519 ms
    before the unshared one);
  - m3-max-30036, the two no-hold exclusions removed: both no-hold tests time out at 20 s.
- Test-only fix in this change: RV2303's committing-thread test held its scheduler thread with an
  application batch that now correctly waits behind the stepping unshared dispatch. Its holder is
  now a command buffer on another unshared queue, which nothing holds back.
2026-11-14 12:22:47 -08:00
Anees Iqbal e453efbf0a RUNTIME 2309: a texture whose rows are in place makes its shadow at the first reach of its image
A device-gap texture over a buffer (its image refused for a reason that leaves its rows in
place: format, pitch, placement, source, dma-buf) was a shadow made at new_texture: its
VkImage, memory and views, its notice and shadow-log line, and its slot in the texture table
and every heap set. A slot whose function only reads, writes or asks its size binds the rows
in place, so a texture only ever bound that way paid for a shadow no command used (reims's
gbs91 on the 780M: hundreds of such textures, 8 to 52 MB each).

Now such a texture (rows in place, no pending in-place verdict, not over a heap's buffer) is
made with its shadow left unmade (texture/lazy_shadow.rs): the storage accessor makes it at
the first reach, once, under a lock, with the making's notice, log line and counts, then
places its slot (its resource ID reads the neutral until then). Paths that must not make it
read the recipe instead (rows binding, placement and heap-set writes, CPU copies, blits on
the bytes, shape and plan questions, logging). The reaches that make it: a slot that binds
the image (before the command's copies are planned from its uses), use_resource, a pass's
attachment, an execution of commands inheriting the bindings, a view, its VkImage handed out.
An out-of-memory making fails the reaching call, as new_texture did.

WorkCounts::shadows_left_unmade and shadows_made_at_use count both halves; docs/API.md says
when the shadowed-texture notice is given.

Not in scope: two kinds still make their shadow at new_texture. A texture waiting on its pages'
in-place verdict may move in place. A texture over a heap's buffer is made resident by use_heap
through a path that checks the shadow.

RUNTIME_VERSION moves because the run's announcements change. The shadowed-texture notice and the
shadow-log line come at the making, and a texture only ever bound through its rows gives neither.
A resource-ID read of an unmade texture gets the neutral. No new Degradation kind. No FAST-PATHS
row: the copy work follows uses, not the shadow's existence (an unbound shadow was copied 0 times
per commit before and after), so no accuracy is traded. The saving is the making: the VkImage, its
memory, views and heap-set slots.

Test: tests::texel_rows_device::a_shadow_is_made_at_the_first_reach_of_its_image, on a copied
buffer, since over the pages lavapipe lays the rows in place. Three cases:
- a written-only texture: shadows_left_unmade +1, none made, shadowed_textures 0,
  shadow_copies 0, texels inverted in the pages;
- a rows write then a sample in one command buffer: made at the sample, copies > 0, pixels equal
  to a device-own texture's;
- use_resource: made at the call.
joined_residency's helper asserts shadows_bytes() where it asserted the shadow at new_texture.

Verified, msi m3-max-30024 at 088a73d3b7:
- clippy -D warnings, runtime crate, all targets and features: plain and --cfg m2v_cpu_icd exit 0;
- lavapipe 206/206: texel_rows, shadow*, read_twin*, joined_residency, padding/kept_padding,
  exported_*, first_host_texture, surface_shapes, attached_read*, copied_device, fresh_pages,
  texture::*;
- translator api_signatures, api_surface and fast_paths: 47/47;
- the negative control in the same job (lazy = false): the test fails at "Copy: left unmade",
  (0,0,1) against (1,0,0).
2026-11-14 12:15:15 -08:00
Anees Iqbal 41bac06524 RUNTIME 2308: no explicit DRM_FORMAT_MOD_LINEAR plane at a row pitch NVIDIA's shaders misread
On NVIDIA's proprietary driver, a DRM_FORMAT_MOD_LINEAR image with an explicit plane at a row
pitch that is no multiple of 32 bytes is made, and vkGetImageSubresourceLayout reports that pitch
back, but its shaders read the rows at another pitch. Measured case: 64 x 64 BGRA8Unorm at rows
272 bytes apart is read by a kernel at 256 and copied out by a blit at 272. Rows 288, 320, 384 and
1024 apart read right.

Measured on:
- the RTX 5080 Laptop GPU (615.71.09): the sweep over every multiple of 16 bytes to 1024;
- the RTX 3090 (620.70.06).
Both over host pages and over the device's own memory.

Vulkan makes the implementation validate an explicit plane layout and refuse one it cannot use
(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT), so no documented rule explains the
misread: it is a driver defect. It caused the 5080's wrong texels on development. A texture in
place over host pages, at rows padded 16 bytes past their texels, read other rows through the
pitched route; a read twin at rows 272 apart was one such texture.

The change:
- RuntimeDriverDefect::ExplicitPlanePitchMisread, on every NVIDIA GPU and release until a probe
  finds a clean one.
- Device::explicit_plane_pitch refuses such a plane at a row pitch that is no multiple of 32 where
  the device has the defect. It does so in both makers of an explicit plane: pitched_image (host
  allocations and the device's own memory) and explicit_plane_image (dma-bufs). The texture then
  takes its shadow (Refusal::Pitch; the shadowed-texture notice names the pitch), or texel rows
  for a slot that only reads.
- The bound is the measurement, not the driver's own linear alignment. The driver's own linear
  images lay rows at multiples of 128, and keying on that would shadow 288 and 320, which read
  right.
- A cfg(test) switch, DeviceShared::explicit_plane_pitch_misread_forced, stands in for the defect
  on a driver that reads such planes right (lavapipe).
- docs: a FAST-PATHS known gap (NVIDIA's pitch, with both measurements); api_signatures.tsv +1.
  REFUSALS.md is unchanged.

No new Degradation kind or WorkCounts field. RUNTIME_VERSION moves because in-place routes change
on NVIDIA, and the linear-alignment records are keyed on it.

Tests:
- textures_at_padded_rows_read_their_bytes: 64 x 64 BGRA8Unorm at 256, 272, 288, 320, 384 and
  1024, over host pages and the device's own memory, each read by a kernel and by a blit. No
  pitched image at 272 where the defect applies.
- The same test under the forced defect: on lavapipe, 272 moves off the pitched image and reads
  right, while 288 stays pitched.
- driver_defects lists the new defect.
- The padded-rows sweep tests, and the shadow log test's twin at padded rows.

Verified:
- msi m3-max-29913 at 7a64d31930:
  - clippy -D warnings, all targets and features: plain, --cfg m2v_gpu and --cfg m2v_cpu_icd all
    exit 0;
  - lavapipe read_twin_device, driver_defects, in_place_check and shadow_causes_device: 43/43;
  - api_signatures, api_surface and fast_paths: 47/47.
- Negative control (rule disabled): the forced test fails with pitched 1 at 272.
- RTX 5080 at 39d564abc4 (archive md5 dd1f3982, b5080 entry roip2-fixarch-5080-112137):
  read_twin_device 20/20. That includes the shadow log test that failed before: its twin at 272
  now takes the twin's shadow.
- The RTX 3090 run of the same archive (m3-max-29951) is queued; its result follows in the lane.
2026-11-14 11:29:56 -08:00
Anees Iqbal 8dd9d3af55 Refusals name what they saw: an unknown ABI key's string or shape, a stage-size refusal's weight and bound
- Every Abi(UnknownKey) that named no key now carries what the reader found: the unknown string
  (an argument's role or attribute, a visible function's key, a node's tag, a compile option, a
  signature kind, a module flag), cut at 64 bytes, or, where there is no string, the operand's
  shape in LLVM spelling. The detail is a crate-private field of InputError (`saw`), printed by
  Display and Debug; it lives there and not in Location because a Location field grew the
  translator's Error past clippy's result_large_err. No public item or refusal kind changes;
  REFUSALS.md regenerated unchanged.
- The ANV stage-size refusal (Feature::StageSize, DriverDefect) names the module's entry weight
  and the bound it passed in its symbol, which Display prints: "entry weight N, past the bound B".
  The bounds and the refusal are unchanged; the FAST-PATHS known-gap row says so.

Why: a consumer's log of a GL-on-Metal kernel refused as UnknownKey at an argument with key None
and of two kernels refused for stage size could say neither which key nor how far past the bound;
one rerun at the pin carrying this names both.

Translation output unchanged: no SEMANTICS or RUNTIME bump.

Verified (msi, m3-max-29879 at 2ddbda8ecf): clippy air + translator 0; metal2vulkan-air 567 passed
incl. abi::tests::an_unknown_key_names_what_it_read (a synthetic node per site, whole location,
seen detail and Display); metal2vulkan a_kernel_past_the_stage_bound_keeps_the_widest_pin_or_is_refused
(symbol and Display name weight and bound past each defect's bound), error::tests and engine_handles
compute tests 10 passed, llvm-as present (no SKIPPED).
2026-11-14 10:52:44 -08:00
Anees Iqbal 2960070096 SEMANTICS 2114 / RUNTIME 2307: write() through an argument buffer to a two-plane YCbCr texture stores or drops as the slot write does
An argument buffer's texture2d<float|half, write> of a two-plane YCbCr
texture died at dispatch (its storage heap member was refused). Metal
stores through a handle exactly what it stores through a slot (the M3
Max under macOS 27.0.1, measured by the consumer): nothing of
YCBCR8_420_2P, both planes of the unpacked 4:4:4 formats byte for byte
the slot's.

- bind::heap: a storage class holds a texture whose writes Metal drops
  (metal::format::writes_dropped) as its neutral (Fit::Dropped), and a
  4:4:4 texture whose writes Metal stores (ycbcr_writes_stored) through
  the R32G32B32A32_SFLOAT view of its write shadow; its table entry
  carries FLAG_YCBCR_WRITES (bit 15). A stage that reads the storage
  class (new RuntimeFact::HeapStorageReads, a PlanTimeCheck) refuses
  either texture it reaches there, Format / NotImplemented, as a slot
  that reads one is refused.
- memory::handles: the search carries the flag into handle bit 29
  (HANDLE_YCBCR_WRITES) under the stage's new SpecKey::HeapYCbCrWrites,
  a u32 constant the plan gives from the command's members (1 where a
  member it names is such a texture, usage writing). At 0 the carry
  mask, the element mask and the write's test are spec-constant
  folds, so a command naming no such texture runs the pipeline it ran
  before (the predicted bindings name none).
- lower::texture: a float/half 4-lane 2D heap write selects
  (rgb, 1.0) where the handle carries the flag: the mark the write-back
  kernel reads (nonzero), in place of any member conversion.
- runtime: the write shadow's image is MUTABLE_FORMAT with an
  R32G32B32A32_SFLOAT view where the device stores that format; the
  heap's float storage element is that view; a command making such a
  texture resident for writing names the shadow in its uses (its copies
  clear the marks and encode the marked texels into the planes), and
  the texture's own image only where it reads it too.

Tests: src/tests/engine_heap_ycbcr_writes.rs (interpreter run at the
constant's 0 and 1, plan values and one variant for every command
naming no shadowed texture, the storage-read refusal);
runtime_lane::ycbcr_argument_writes (500/503/507/523/527/542/545
through an argument buffer against the slot's bytes, and the pipeline
count). REFUSALS.md regenerated; api_signatures blessed: two new
variants of #[non_exhaustive] enums, nothing breaks for a consumer.

Metal (M3 Max, macOS 27.0.1, m3-max-29643): argument-buffer writes are byte-identical to slot writes
for 500/503/507/523/527.

Verified (msi lavapipe, --cfg m2v_cpu_icd): m3-max-29859 clippy translator/runtime/validation 0,
runtime 243/243, lavapipe lanes 75/75, translator 246/247 (a word bound the mark raised, fixed in
ce01da189e); m3-max-29865 at ce01da189e clippy 0, translator 4/4, lavapipe 2/2: argument-buffer
writes byte-equal to slot writes for all 7 formats (alpha-0 writes, so an unmarked write stores
nothing); pipelines 1 after RGBA8/RGBA16Float/500 commands, 2 after the first 503 and still 2
after a second.
2026-11-14 10:46:27 -08:00
Anees Iqbal 948b5e37fb RUNTIME 2306: a texture over a bit-24 buffer that no image lies over reads a shadow of its read twin, not of the copy
A no-copy buffer of Metal's private option bit 24 is a copy of its pages off macOS, beside a read
twin over the pages in place. A slot that only reads a texture over such a buffer binds the
texture's read twin, but only where the twin's texture lies in place over the twin's bytes. Where
it did not (RADV lays no DRM_FORMAT_MOD_LINEAR plane whose rows or first byte are off a multiple
of 256: a window server's 48x48 textures at rows of 192 bytes, its 128x128 ones at rows of 512
from 32 bytes in), the twin's texture was made as a shadow and dropped. The slot then bound the
program's texture, itself a shadow of the copy for the same reason, so its command buffer used the
copy and its commit compared the whole copy with the pages.

Workload reason (reims's appwalk17 desktop walks, numbers only): twin textures not in place
780M 362, RTX 3090 304, Iris Xe 1; copies compared 52,537 (2,897 MB), 43,384 (2,138 MB) and 331
(35 MB); the Iris compared in one walk step only, the one that made its one twin not in place.
Copies compared plus twin slot reads come to about the same total on all three (56,775, 52,277,
54,233): every such read that missed a twin read the copy.

Now the twin's texture is kept as a shadow of the twin's bytes where the program's texture is a
shadow too, and the slots that only read the texture bind it under the same proof as before. The
program's texture lists it beside its own shadow (shadow::texture_copies, held weakly), so draws,
rebound draws, dispatches and resident textures copy it in from the pages in place at its first
use in each command buffer, where they copied the texture's own shadow in from the copy (a shadow
of a copy of Shared memory never stands). Where the pages carry a log of their writes only the
changed rows move. The command buffer names the twin's and the shadow image's keys, never the
copy's, so its commit compares nothing. No store reaches the pages: the twin's one GPU access is
the copy in's read, the shadow is the runtime's own image no call returns, the slots only read it,
and a copy back would write the twin's key, which every encoder refuses.

Discrete devices take it too: their copy lies in system memory (MemoryClass::Shared), as the
pages do, so the shadow's copy in crossed the bus before and crosses it now; what goes is the
CPU's comparison. Cost: an image of the texture's size per such texture while it lives.

- WorkCounts::read_twin_texture_shadows (new field). No new Degradation kind.
- The shadow log's twin line says whether the twin's shadow serves the read slots.
- cfg(test) DeviceShared::linear_pitch_rule_forced: RADV's LINEAR plane rule at Device::unplaced.
- Tests (read_twin_device): the two shapes sampled by a draw and the 128x128 one read by a
  kernel through the twin's shadow (compares 0, a CPU write read next, a fill read back through
  the copy, pages kept); over logged pages the second command buffer copies nothing in and a told
  write moves its rows alone. The screen-sized texture lavapipe lays no image of now reads its
  twin's shadow too.
- Docs: read_twin.rs, shadow_log.rs, API.md and the FAST-PATHS row on bit-24 memory;
  api_signatures.tsv (+1).

Verified (msi lavapipe, m3-max-29778 at 69f0a567b1): clippy plain and --cfg m2v_cpu_icd 0;
read_twin_device, copied_device, copied:: units, texel_rows_device, dirty_pages_device and
waited_reads 73/73; api_signatures and fast_paths 35/35. With RADV's LINEAR rule forced (offset
and pitch multiples of 256): 48x48 at pitch 192 and 128x128 at pitch 512 offset 32 sampled by a
draw and read by a kernel: twin slot reads +1, compares 0, texels the pages', a CPU write read
in the next command buffer; a fill in the same command buffer reads back through the copy with
one compare, pages kept; over a dirty log an unchanged twin copies 0 bytes. Negative control
(serves cut back to in-place only): the 3 new tests fail, the commit compares the copy.
2026-11-14 10:22:01 -08:00