Commit Graph
1069 Commits
Author SHA1 Message Date
Anees Iqbal 3aa410e2ab A device refused for want of resources takes its least plan whatever the code: too many objects and host memory too
vkCreateDevice's answer where the device-specific resources a logical
device needs run out is VK_ERROR_TOO_MANY_OBJECTS (the Vulkan spec,
vkCreateDevice), and a driver short of host memory for the plan's
VkQueues may make a device of fewer: both now take the least plan, as
VK_ERROR_INITIALIZATION_FAILED (NVIDIA's channels) and
VK_ERROR_OUT_OF_DEVICE_MEMORY did. A device refused with both plans
is refused naming each attempt, as before.

Asked for by a device test on an RTX 2080 under parallel test load
(job m3-max-18589) that got OutOfMemory(Host) from
Device::system_default_with, where the least plan's three queues would
have fit: the 2080 held 10 devices of the plan's 18 VkQueues at once,
and 68 of the least plan's 3 (job m3-max-18774).

The pure test of made_within_resources takes each of the four codes.
2026-11-11 21:51:22 -08:00
Anees Iqbal 3cfcbe6304 FAST-PATHS: reflow the one-graphics-queue gap's new count line 2026-11-11 21:51:22 -08:00
Anees Iqbal 37db40177b Command queues take the VkQueue the fewest live queues hold; unshared ones an empty one under every verdict
A new command queue took the round robin's VkQueue by a creation counter (made modulo the
round robin), which never reuses a slot: a guest makes about 340 queues past NVIDIA's 14 in a
250 s walk, so live queues landed together while other VkQueues stood empty. An unshared
queue (a compositor's) got a VkQueue of its own only where the device shares (an Adaptive
verdict of Idles); under PerQueue, on MoltenVK, and on a device that answers GPU times from
the host (reims-vgpu's, Unchecked) it took the round robin's next, so app queues made later
landed on it every 14th make. Guest walks (reims's logs, read in place): unshared command
buffers behind another queue's batch 1062 in one 3090 walk (39 over 16 ms, longest 33.8 ms),
5 in the next on the same build; 511 on a 2080; 2048 on the M3 (437 over 16 ms).

Now, under every policy and verdict, a command queue takes, as it is made, the round robin's
VkQueue the fewest live command queues hold of those no unshared queue holds, the first in
turn from the counter among equals (queue_share.rs fewest_held, Device::take_round_robin):
one pass over the round robin's VkQueues' counts, atomics alone, at creation only; nothing
scans the command queues. Its claim is made before it reads the unshared count, as an
unshared queue's is made before it reads the live count, both sequentially consistent, so the
two never both succeed. An unshared queue takes one no command queue holds where one is free
(the existing unshared_order, now ungated), else the one the fewest hold.

Counts: WorkCounts::command_queues_live_most (the most command queues the program held at
once: what a walk needs to size the plan by) and unshared_queues_sharing_a_vk_queue (an
unshared queue that found no VkQueue free of other queues). queues_sharing_a_vk_queue keeps
its meaning, the queues made past the round robin's VkQueues; unshared queues now count among
them under every verdict, as they did where the device did not share. QueueLimits notes keep
theirs, an unshared queue's included.

Tests: tests::queue_share's pure churn shaped like a walk (354 made over 14 VkQueues, at most
12 live, an unshared one kept): no queue placed beside a live one while one stood empty and
the unshared one never shared, against a positive count by the old rule; device test
over_a_churn_queues_take_the_least_held_vk_queue_and_unshared_ones_an_empty_one under
Adaptive, PerQueue and untimed Adaptive. The helpers that share a VkQueue on purpose (beside,
the lane's queue_where) keep the queues they make until one lands there.

Docs: QueueSharingPolicy, new_command_queue_unshared, new_command_queue_for_presenting,
queue.rs and queue_share.rs module docs, docs/API.md, the runtime README, FAST-PATHS's queue
sharing row and its known gaps.

Not yet built or run: potluck jobs follow.
2026-11-11 21:51:22 -08:00
Anees Iqbal b649078d10 Docs: a buffer bound inside a no-copy buffer's import holds its keep-alive, or its deallocator
The release order RV 2073 brought, in the docs a consumer reads. A no-copy buffer made over part
of a live one's bytes, or over the same bytes as memory of another class, is bound inside the
live one's import (one live import of a page: VK_EXT_external_memory_host leaves a host allocation
imported twice into one device undefined) and holds it, so the live one's keep-alive is dropped
only once both are released and the import is freed. With a keep-alive its deallocator still runs
at its release, as Metal's; given none, the deallocator waits for the free, announced as
host-deallocator-delayed.

- API.md: the host-deallocator-delayed entry names the cause and its cost; section 10 (Heaps and
  memory) records the keep-alive's later drop as an accepted difference, with
  WorkCounts::host_releases_held_inside.
- HOWTO, "Unmapping host memory": the order for a buffer over part of another's bytes.
- The runtime README's no-copy paragraph and KeepAlive's doc name it.
2026-11-11 21:51:08 -08:00
Anees Iqbal 88af28874e Host RAM: an object's own import claims its RAM pages until noted; chunks mark in flight under the claims
The straddle copy (f083e9c806) and the held-back chunk (c55501db1b) each read only finished
state: an object's check read made chunk imports alone (chunks_hold_any), and a chunk's check
read noted object imports alone (the alias registry). So an object made while a chunk's import
was in flight, or a chunk imported while an object's own import was between its checks and its
note, imported the same pages twice. Both tests of 1d77522508 showed it on lavapipe, 3 runs of
3 each (m3-max-18881): imports_inside_live 1.

Each RAM the device uses now keeps the claims of objects' own imports in flight. An object's
making and a rebind claim their window's RAM pages (Device::claim_ram_pages) where no chunk binds
them, and hold the claim through their import until it is noted: where a chunk's import, made or
in flight, holds some of the pages, nothing is claimed and the object is a copy
(CopiedBecause::OverRamChunk, as for a made one). A chunk's import is marked in flight only under
the RAM's claims (RamOnDevice::chunk takes them before the chunk's lock, as a claim does, and
looks at the chunk again), and is held back where a claim meets its pages (held_back), as where a
noted import does. Whichever starts first, the other never imports the same page.

Docs: host_ram.rs's one-import bullet; the OverRamChunk cause, copied_over_live_imports and
docs/API.md's copied-host-pages entry say made or in flight.
2026-11-11 21:49:22 -08:00
Anees Iqbal 53501197a8 Host RAM: an object across two imported chunks is a copy, never a second import
A no-copy object whose pages cross the end of a guest RAM's chunk, the chunks on both sides
imported, is bound in neither: route_runs answers Runs, and the object took the gate's path
and imported its own pages, the same host addresses as the two live chunk imports
(VK_EXT_external_memory_host leaves that undefined; imports_inside_live counted it). The
consumer's walks hit it at boot on the 2080 and the 3090: a 2 MiB heap from 0x3f22000 into a
64 MiB chunk, 0xde000 bytes in the first chunk and 0x122000 in the next.

Such an object, and one over a live chunk's pages that no resolver routed, is now a copy of its
pages (CopiedBecause::OverRamChunk, counted in copied_over_live_imports, announced as
copied-host-pages, the gate not asked), at its making and at a heap's rebind. Chosen over:
- aligning chunk imports to objects: the chunks are imported ahead, before the objects over
  them exist, and objects lie anywhere;
- one import over both chunks: each chunk's import already binds objects when the straddling
  one comes, and swapping it would move every bound object;
- a sparse binding of both chunks' memory: heaps place resources at any offset, and not every
  device binds sparse buffers.
A copy costs one copy of the object's pages per commit, the rare edge object alone (one per
chunk end an object crosses).

Test: a_heap_across_two_imported_chunks_is_a_copy_and_imports_nothing (the consumer's shape:
both chunks imported by a buffer each, then a 2 MiB heap from 0xde000 before the first chunk's
end): one copy, no pointer import, imports_inside_live 0, the gate not asked; a buffer placed
across the chunks' end reads the RAM's bytes and a fill through it reaches them.
2026-11-11 21:20:02 -08:00
Anees Iqbal ea4bbb5fa3 A guest RAM chunk waits while a live import of an object's own holds its pages
reims's pin 42 walks on the RTX 2080 counted imports_inside_live = 1 at boot, once in each of
two walks, in the second the device's thread imported its first chunks ahead (with a 2 MiB
pointer import and host_imports_kept_of_heap in the same second). A no-copy heap made over the
RAM's pages before use_host_ram (or with no run resolver) imports its own pages outside the
RAM's routing, and the thread's import of the chunk holding them then imported those pages a
second time, which VK_EXT_external_memory_host leaves undefined (issue 6).

Now RamOnDevice::chunk holds the chunk back while HostAliases::within finds a live import over
its span (RamOnDevice::held_back): no import, the device's thread marks it tried, an object
over it falls back to the paths of memory no RAM holds (its own import, inside the live
import, or a copy), and copy_take sends copies over it through the CPU. Once every such import
over the chunk went, the next object over it imports it. Counted:
WorkCounts::host_ram_chunks_held_back (api_signatures updated).

Docs: host_ram.rs's module doc no longer describes pointer chunks' runs imported alone (the
2073 fix made those dma-buf-only); it states the held-back chunk. host_aliases.rs,
churn_counts.rs's imports_inside_live and HOWTO's guest RAM paragraph say the same.

Test: host_ram_device::a_chunk_a_live_import_made_before_the_use_holds_waits_for_it_to_go
(a heap over the first chunk made before the use; the thread and a buffer's take hold the
chunk back, the buffer imports its own pages and reads the RAM's bytes, no import inside a
live one; once both went, the next buffer is bound in the chunk).
2026-11-11 21:20:02 -08:00
Anees Iqbal 85041aa633 dma-buf imports try only the system-memory types the host maps last
87b0acd6d5 tried every type the host does not map before every type it maps. On an Iris Xe
(ANV, Mesa 26.2.x, m3-max-18804) that moved Shared, WriteCombined and Managed imports of a
udmabuf and of a device-local dma-buf from type 2 (DEVICE_LOCAL|HOST_VISIBLE|COHERENT|CACHED,
the class's first) to type 0 (DEVICE_LOCAL alone). On a unified-memory GPU the host's flags on
a device-local type may choose how the GPU caches its accesses to the pages, so that move is
not shown to be harmless.

Now only the system-memory types the host maps (HOST_VISIBLE without DEVICE_LOCAL) go last;
device-local types keep their class's order. NVIDIA's udmabuf types (0: no flag, 4: host-visible
coherent cached system memory) still order 0 before 4, so the 3090's result stands. ANV's types
are all device-local, RADV's for a udmabuf all host-mapped system memory, lavapipe's one: the
class's order as before.

Unit test: dma_buf_imports_try_the_system_memory_types_the_host_maps_last (renamed), with an
ANV-like set (all device-local, unified) and a GTT-like set (all host-mapped system memory)
whose orders and forms stand. FAST-PATHS's NVIDIA dma-buf gap says the same.
2026-11-11 21:20:02 -08:00
Anees Iqbal c267e94e74 dma-buf imports try the types the host does not map first
NVIDIA's 620.70.06 lists a udmabuf of host pages as its type 0 (system memory, no property
flag) and its type 4 (host-visible, coherent and cached, the Shared class's first), refuses
every import as type 4 with ERROR_OUT_OF_DEVICE_MEMORY, and imports it as type 0. Measured on
an RTX 3090 (tests::export_after_dma_buf, raw vkAllocateMemory answers on fresh devices): once
it refused an import as type 4, it answers ERROR_OUT_OF_DEVICE_MEMORY to every allocation of
its device-local type 1 exportable as an opaque fd or a dma-buf (with the device-address flag
or without), at 12,441,600 bytes and at 64 MiB, for the device's life; plain and
device-address-only allocations are still made. After a successful import as type 0, every
chain is made. Whether the import was dedicated does not matter. The runtime's first Shared
dma-buf import tried type 4 first, so every later Private exportable buffer overflowed into
system memory (type 0, DeviceMemoryOverflow).

The runtime never maps a dma-buf import (the CPU reaches the pages through the caller's own
mapping), so a type the host does not map serves it as well. dma_buf_candidates now orders the
types the host does not map first, then those it maps, each in the class's order
(dma_buf_class_order, the order before), and dma_buf_attempts tries every form (dedicated to
nothing, then to the buffer) of the first group before any form of the second. On NVIDIA the
import ends as type 0, as before, without the refused attempt. A driver that lists only
host-mapped types for a dma-buf keeps the class's order.

Tests:
- memory::dma_buf_imports_try_the_types_the_host_does_not_map_first (unit): both orders, and the
  attempts' order, for NVIDIA's types and for a set whose listed types are all host-mapped.
- export_after_dma_buf::a_private_exportable_buffer_after_a_dma_buf_import_lies_in_device_local_memory
  (renamed): asserts each export lies in a DEVICE_LOCAL type with the control's flags and no
  overflow counted. It failed on the RTX 3090 before this change (type 0, one overflow each).
- export_after_dma_buf::the_driver_s_answers_after_each_kind_of_dma_buf_import: kept as the
  driver's evidence, printed and not asserted.
- export_after_dma_buf::the_type_each_class_s_dma_buf_import_takes_against_the_class_s_order:
  prints, per class, the type the runtime's import takes and the type the class's order took,
  for a udmabuf and for a dma-buf of the device's own device-local memory; asserts they agree
  where both orders are the same.
docs/FAST-PATHS.md's NVIDIA dma-buf gap records the driver's refusal and the order.
2026-11-11 21:20:02 -08:00
Anees Iqbal 9ec681c85c REFUSALS: regenerated for the pooled bound's moved refusal sites 2026-11-11 21:00:30 -08:00
Anees Iqbal f9999c588c HOWTO: a quiet commit leaves none of its work to be recorded after it
The quiet-commit definition, where a shadow made before its verdicts (or a pooled texture's
shadow of its linear cost) moves in place, named only the uncommitted command buffers, events
and textures bound by ID. The commit also takes the move only where every batch before it was
submitted, every encoder of it may run, and none of its work is left to record after the commit
(command_buffer/storage_form.rs takes_storage_forms; Device::storage_form_switch). Found on
lavapipe: a diagnostic run (m3-max-18654, scratch prints, never landed) showed four compute-only
commits declining the move, each with recorded segments, and a blit's commit taking it
(moved 1, freed 1, the next read copying nothing).
2026-11-11 20:59:50 -08:00
Anees Iqbal 8cb5400e78 Pooled bound: a texture over bytes another texture was made over takes the image at its pitch
A guest's window server makes dozens of textures over each of its large Private surfaces (other
formats of the same bytes, and a new texture each frame), and past the pooled bound each was a
shadow of its linear cost of its own (216 on a Radeon 780M at a login, 1022 in 13 s on an Iris Xe).
storage_over_buffer decided each texture alone: pooled_pitched_image answered LinearCost for any
tracked texture over a Private buffer past 48 KiB, so every texture over the same bytes made a
full image of its own, copied every texel in at its first use, copied in again after a write
through any other (which lets go of its standing) and copied back whole after a kernel's write.
The shadow log names the buffer's object, not the texture's, so one object's two lines 22 ms apart
are two textures over the same surface, a frame apart.

The bound weighed one texture over the bytes. A buffer now notes the runs of bytes textures were
made over (texture_spans.rs, at most 8 runs, joined where they meet), whether those textures
still live: a texture over bytes another texture was made over takes the DRM_FORMAT_MOD_LINEAR
image at Metal's pitch at any size, as over CPU-visible memory, and the first texture's shadow of
its linear cost moves to that image once another texture is made over its bytes, through the
existing pooled move (wait_to_move_in_place: at the next quiet commit, with no copy). Both forms
give Metal's answer; the textures alias the bytes as Metal's do. The bound has no FAST-PATHS row:
it chooses between two exact speeds (6717cac4ea). API.md, HOWTO and the LinearCost docs say so.

Verified: cargo fmt; builds and device runs follow as potluck jobs.
2026-11-11 20:59:46 -08:00
Anees Iqbal d277b155e2 Shadows of a tracked Private image stand across command buffers, stale inside a rectangle
What: a usage or attached-read shadow whose truth is a tracked Private or Memoryless image the
runtime made in memory of its own (not shareable, its VkImage never handed out) now stands
across command buffers, as a shadow of a Private buffer's bytes already did
(Backing::PrivateImage, StandingAcross::over_image). A standing also keeps the rectangle its
image is stale in when the command buffer ended with it current there alone, and the next
command buffer's gated copy in moves only those texels (Standings::standing,
GatedCopyIn::standing_copy). The first render pass instance of a pass now bounds its loaded
colors' writes by its draws' scissors as later instances did, so a draw that samples the
texture its pass renders leaves that texture's shadow stale inside the drawn rectangle alone.

Why: on the 780M a 2618x1024 texture read through such a shadow was copied in whole once per
frame although its texels changed only every 4th frame: 2,680,832 texels a frame, about
200-370 us of GPU time, for a draw beyond the texture's usage and for one that samples it in
the pass that renders it through a 64x64 scissor. An image truth never stood (stands_across
took bytes alone), and a one-instance pass's attachment writes were never bounded, so the
shadow lost the truth whole. The copy an attached read takes before any barrier stays: read in
place through the feedback loop it would race the pass's own writes, which Vulkan forbids
(attached_reads.rs now names it).

New WorkCounts fields: shadow_texels_first_copied_in_private_images,
shadow_texels_unskipped_stale_within.

Tests: unchanged_truth_copies now asserts that a frame that changed nothing moves no texel the
shadow holds (0 beyond usage, the scissor's 4096 for the small attached read); image_standing
checks the stale-rectangle copy's texels and counts, the let-go after another write, and the
mip chain (clear level 0, render level 1 sampling the whole texture, then level 2, then sample
every level) with and without a usage shadow, its passes apart and in one command buffer. Run on
lavapipe and RADV PHOENIX after this commit (job ids in the report to main).
2026-11-11 20:30:20 -08:00
Anees Iqbal b11e59ec86 Records carry a compute state's dispatches, and the warm pass makes their pipelines
A compute state whose descriptor requires no threadgroup size predicts no
VkPipeline at its creation: the local size and the threadgroup memory
lengths are the dispatch's own calls, so its creation's record made none of
its dispatches' pipelines on a later warm pass, and each was a cold driver
compile at the program's first dispatch of its shape (the 12.7.6 kernels'
case in FAST-PATHS).

Now, where the device hands records over, a compute state's direct dispatch
(dispatchThreadgroups: or dispatchThreads:) whose regions' pipelines were not
all made hands the hook one more record: the creation's descriptor, as its
own record holds it, and the dispatch (its threadgroup, a dispatchThreads:
grid reduced to one whole threadgroup and its ragged edge per axis, and the
encoder's threadgroup memory lengths). Each such dispatch once per state, at
most 16 a state (pipeline/dispatch_record.rs). A warm pass that creates such a
record's state then plans the dispatch as a creation's prediction plans its
first one (nothing bound but the default samplers), with the recorded
lengths, settles its variant as a dispatch does, and makes each region's
VkPipeline on the pass's thread, so their driver data lands in the records
under the names the program's dispatch of that shape asks for.
WarmStatistics::dispatch_pipelines_warmed counts them. Indirect dispatches,
dispatches of a threadgroup range and tile dispatches record nothing.

Records are immutable, one per dispatch shape, so a consumer keeps each once
and needs no rule for which supersedes which. The record format moves to 7:
a compute record's bytes now end in its dispatch list (count, then each
dispatch), so a format-6 record reads as none. The codec bounds the list at
16 dispatches and 31 lengths each, both when writing and when reading.

Tests: warm_record round-trips a compute record with a dispatchThreadgroups:
and a ragged dispatchThreads: carrying two threadgroup lengths, and bounds the
list (more than 16 is unwritable; bytes claiming 17, resealed, are no record;
16 read back). The device test
a_warm_pass_makes_the_pipelines_of_the_dispatches_its_records_name records a
state's creation and first dispatch, checks that the same dispatch again and a
grid of the same edge make and record nothing, warms both records on a
device over the same directory (dispatch_pipelines_warmed equals the regions
the recording dispatch made), and checks that the program's first dispatch
there hands each of its makings the driver cache the pass filled
(caches_shared) and translates nothing. A control device warmed with the
creation's record alone makes no dispatch pipeline and shares no cache.
Verification is in the report to main (potluck lint and lavapipe jobs).

Docs: the runtime README, HOWTO and FAST-PATHS ("Made again before the
program asks") describe the dispatch records; api_signatures gains the
WarmStatistics field.
2026-11-11 19:10:38 -08:00
Anees Iqbal 0307da09ba Docs: the fill queue's numbers with the tip's runs on the RTX 3090, RTX 2080 and RX 7900 XTX
At the tip the RTX 3090's 1 MiB frame alone took 0.93 times as long through
the fill queue (18358), against 1.04 in the two runs before (17900, 18199),
and the RTX 2080's 64 MiB one 1.04 times (18309, against 1.00 in 18167): the
trade sentence names both, and the swept size from which the fill queue was
within 1% alone in every run is 256 MiB, not 64 MiB. The tip's runs, whose
two devices both copy at the batch's start under 1 MiB, put them 0.31 to
1.85 times apart there (RTX 2080 18309, RTX 3090 18358, RX 7900 XTX 18310);
64 MiB beside the kernels at the batch's start took up to 49.4 ms, and the
other queue's share moved -11 to +8 points on the RTX 3090 and RTX 2080.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 3a349c2419 Docs: the fill queue's numbers from the sweeps, with the bench's spread under 1 MiB
The ledger bullet and staging.rs's fill-queue docs take the ranges of all
the runs: 1 MiB beside another queue's kernels 1.80-1.84 against
3.53-3.60 ms on the RTX 3090 and RTX 2080 (18199, 18167, 18309), 64 MiB
35.9-37.8 against 40.6-48.9 ms, and on the RTX 5080 Laptop GPU 3.31-3.39
against 5.90-5.92 ms (18316, 18108). Under 1 MiB the fill queue's frames
took 0.51-2.03 times the batch's start's, but at the tip, where both of
the bench's devices copy at the batch's start under 1 MiB, the same bench
put them 0.31-1.39 times apart (18309): the sub-1 MiB differences are not
past the bench's spread, which the docs now say instead of a 2.0x loss.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 700b0fec07 FAST-PATHS: the fill queue's 1 MiB least trades 0.06 ms alone on the RTX 3090 for the halved frame beside other work
At 1 MiB alone the RTX 3090's frame took 1.04 times as long through the fill
queue (jobs 17900 and 18199), and beside another queue's kernels half as
long; the swept size from which it is within 1% alone on all three NVIDIA
GPUs is 64 MiB. The owner's coordinator kept 1 MiB; the bullet says the trade.

Verified: cargo fmt.
2026-11-11 19:08:58 -08:00
Anees Iqbal 421799152d Fill queue: a batch's fills go there only where they write 1 MiB or more
The fill queue's own submission and the batch's wait for it cost small
copies more than the copy engine saves them. The sweep of
managed_copies_bench (a Managed buffer's copy in each frame, the fill queue
against the batch's start, p50) placed the crossover:

- RTX 2080 (18167): 128 KiB 1.04x alone and 1.11x beside another queue's
  kernels; 256 KiB 2.03x alone (0.94 against 0.46 ms), 1.09x beside;
  512 KiB 1.31x alone; from 1 MiB up 0.98-1.00x alone and 0.51-0.91x
  beside (1 MiB 1.81 against 3.57 ms).
- RTX 3090 (18199): faster or within 4% everywhere; 1 MiB alone 1.04x
  (reproduced, 17900), beside 0.51x (1.80 against 3.53 ms).
- RTX 5080 Laptop GPU (18108, before the sweep): 64 KiB 1.44x alone and
  1.06x beside; from 1 MiB up 0.93-0.99x alone and 0.56-0.96x beside.

So FILL_QUEUE_LEAST is 1 MiB, the smallest swept size from which the fill
queue is no slower beside the kernels on any of the three and at most 1.04
times as long alone: Taken::take_fills takes the batch's fills only where
they write that many bytes in all (copies and zeros), and fewer stay at the
batch's start, as on a device without a fill queue. Decided from bytes, not
from the device.

The fill-queue test gains a last command buffer whose fills (a new Managed
buffer's zeros and its copy in, under half the least each) make no
fill-queue submission and read back exactly. The ledger's costs of
matching Metal gain the fill queue's bullet; the staging, create, bench and
README docs say the least and the measured numbers (the create.rs 82% came
from the raw example and is gone).

Verified: cargo fmt; device runs, lavapipe and lint follow.
2026-11-11 19:08:58 -08:00
Anees Iqbal 0e53ff56d5 Docs: the fill queue, where a batch's fills run, and what waits for it
device/staging.rs documents the fill queue: why (a copy through the graphics family runs on the
engine the kernels run on; the 3090 and 5080 numbers so far), why not the staging queue, what it
waits for, what waits for it (with the spec's semaphore and sharing text), what it holds, and what
stays where it was. first_move.rs and managed_copy.rs say where a batch's fills go. Queue counts:
the plan takes 18 queues on NVIDIA now, so the measured 17- and 2-queue devices are named by their
queues, and the least plan keeps the fill queue as it keeps the staging queue.
2026-11-11 19:08:57 -08:00
Anees Iqbal b3a9bda684 Docs: copied-host-pages names pages a live import holds some of; listed runs alone described where they stay
API.md's copied-host-pages entry gains the over-a-live-import cause
(copied_over_live_imports, announced once per device as the others are).
HOWTO's listed-plan paragraph described its runs alone "as above", text
the previous commit removed: it now says what a listed RAM's run import is
(a dma-buf), what it costs, how it orders, and that MoltenVK and ANV import
the chunk instead.
2026-11-11 19:01:50 -08:00
Anees Iqbal d76f7f7ee7 One page, one import: no run of a guest RAM chunk imported alone by its pointer
An object over a chunk not imported yet, and a copy over one, was bound in
an import of its own run alone, made by the run's host pointer while the
device's thread imported the whole chunk by its pointer: two live imports
of the same host addresses, the run's freed while the chunk's lived.
VK_EXT_external_memory_host leaves the same host allocation imported twice
undefined (issue 6). Runs are now imported alone only on a listed plan,
whose chunks and runs are dma-bufs of the RAM's source, and a run's import
never falls back to its pointer. Elsewhere every object and copy over a
chunk lies in its one import, made or waited for, as on MoltenVK and ANV.
The price is a making that waits for a chunk the window has not reached.

imports_inside_live now counts every import made over host addresses a
live import holds: a no-copy object's own import over another's (heaps
included) or over a live chunk import at the same addresses, and a
chunk's import over a live no-copy import, on the making and rebind
paths. A new evidence counter, imports_over_ram_chunk_pages, counts a
view's own import whose guest RAM pages a live chunk import holds at the
RAM's addresses. host_ab prints both and buffers_bound_in_import.

Not yet verified: built and tested next on lavapipe.
2026-11-11 19:01:50 -08:00
Anees Iqbal 269d7066c4 FAST-PATHS: what is built around a cold making's driver time, and the compute kernels' case
The known gap on the cold making of a 200,000-word compositing module ended "Nothing is built
around it", which was not true. It now names what is:

- the driver records across boots (`shader_cache/driver.rs`), named by the driver's identity, so a
  driver update, another device or a removed content directory makes every making cold again, and
  no machine's records serve another's;
- pipeline records and `Device::warm`, which remake a previous process's creations on a thread of
  their own below every other making, and what they do not cover today (a compute state that
  states no required threadgroup size predicts nothing, so its dispatches' pipelines are made at
  their first dispatch);
- `PipelineWaitPolicy::Bounded` at creation and at commit, and dispatches that hand their making
  to the pool;
- the consumer's creation of guest states on a compile thread off the guest's command path.

It adds the compute case: a convolution kernel's 12 variants at a macOS 12.7.6 login, one SIMD8
program each of 6,222 to 8,925 instructions with 70 to 221 spills, and the host-load
sensitivity that made the same login's makings 2 to 13 times slower than alone.

Measured on the Iris Xe (Mesa 26.2.6), the dumped modules made by a scratch harness with
the logged specialization, one module of its own per making, the driver's disk cache off:
- the 23,108-word variant alone 0.27 to 0.34 s (jobs 18284, 18292); 11 at once 0.31 to 0.53 s
  each, 0.50 to 0.53 s for all (18293); device robustness on or off alike (18292);
- the 138,047-word fragment module alone 2.03 to 2.42 s, two at once 2.42 to 2.53 s each, four
  at once 2.69 to 3.33 s each (18284);
- under 20 and 30 busy threads on the 20-CPU host, that fragment making 6.27 and 7.94 s, and 11
  kernel makings at once under 20 busy threads 0.78 to 1.44 s each (18293);
- the program counts from INTEL_DEBUG=cs (18226).
The login's own numbers (4.87 s; 1.5 to 4.2 s, 10 or 11 at once; the guest's 1 to 197 command
buffers a second during the making) are the consumer's cold-login log at the 12.7.6 capture; the
3.1 ms warm making is the consumer's warm boot.

Docs only.
2026-11-11 18:36:17 -08:00
Anees Iqbal e97d5da60c Docs: HelperBranchDropsSimdgroupStores also covers a call in no branch that SPIRV-Cross writes in one
The catalogue entry and the variant's rustdoc name the new case: a ?: arm, the right side of a && or ||, or a selection's arm, where the call's value is read once (spirv::helper_branches).
2026-11-11 18:13:09 -08:00
Anees Iqbal 5175cca5b4 Pipeline creation log: a compute line names its kernel's descriptor, and the dump writes compute modules
A compute pipeline's line in METAL2VULKAN_LOG_PIPELINES named the kernel's function, its SPIR-V
hash and length, its specialization constants and notes, but not what the kernel was made from:
a cold boot's slow compute creations could not be made again off the device, because the
function's Metal constant values were nowhere in the log, and METAL2VULKAN_DUMP_PIPELINES wrote
render modules only.

The compute line now ends with `; descriptor: ` and the same naming a render state's first line
gives each function (its name, the SHA-256 of its bitcode, the constant values by index and by
name with their types and bytes), from one helper both share (`render::logged_function`). With
the dump directory set, the line's module is written there as `<hash>.spv` (`dump_modules`, the
render dump's writer, now over any modules), and a failed write is named in the line as a render
line names it. Nothing is kept or measured while the variables are unset: the descriptor's text
is made only where the log is on (`compute_kernel`).

The creation log's module doc also names the record words the split prints since the record
naming change (`record's cache shared`, `found in cache`, `compiled`).

Test: `opencl_data::the_pipeline_creation_log_names_a_compute_pipeline_and_its_notes` now runs
its child with the dump directory set, and asserts the line's descriptor (the kernel's name,
`air`, `constants {`), no dump failure, and a SPIR-V module (its magic) at the hash the line
names. It and the creation_log unit tests, and lint, run on this commit as jobs after it is made
(the report names them); a failure is fixed forward.
2026-11-11 17:57:53 -08:00
Anees Iqbal a58070d630 Docs: a cold making of the 200,000-word compositing fragment module is the driver's own cost
Records, as a known gap, what is left of the Iris Xe's cold login
creations after the records stopped naming attachment formats: the one
compile of the compositing fragment module (203,016 words, macOS
26.7.2) that every state over another format then finds in its record.

Measured with a scratch harness making the module's fragment shader
library cold, the driver's disk cache off:
- ANV, Iris Xe, Mesa 26.2.6: 3.3 to 3.7 s at load ~16 (m3-max-17871);
  its program is 29,101 SIMD8 instructions, 34 spills, 10,585 non-SSA
  registers.
- RADV, Radeon 780M: 1.3 to 3.0 s (m3-max-17958, -18098).
- RTX 3090, 620.70.06: 4.5 to 7.4 s (m3-max-17957, -18097).

Why no translator change: spirv-opt -O (186,314 words) and -O with
frozen specialization constants (180,402) leave ANV's NIR within 0.2%
(27,347 to 27,393 instructions) and its program within 9 instructions,
and their creations are no faster than the original's within the
run's noise (m3-max-18022, -18034, -18127). Holding half values in 16
bits across moves, phis and selects (a scratch pass on the -O module)
makes it 29,719 instructions with 103 spills. So the words the
translator emits do not drive ANV's time; the shader's own work does
(NIR: 4,163 fmul, 2,868 fadd, 1,689 ffma, 1,835 csel, ~290 samples,
30 loops).

VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT: ANV builds the same
program in the same time and the 3090 the same time; RADV takes 0.9
to 1.0 s (m3-max-18098), at a draw cost not measured. Nothing is
built around it. Doc only.
2026-11-11 17:57:53 -08:00
Anees Iqbal d729b77438 FAST-PATHS: on NVIDIA each vkFreeMemory holds the device's other submissions, measured
The known gap the frees' pacing answers in part: tests::import_free_hold_bench on an RTX 3090
(NVIDIA 620.70.06, quiet host, two runs) put a fill's commit to completion at 0.13-0.14 ms beside
no free, 0.46-0.54 ms beside runs of 512 KiB pointer or dma-buf imports freed one after another
(each free 0.26-0.39 ms), 2.6-2.9 ms beside 64 MiB imports (2.2-2.4 ms each), 1.2-1.6 ms beside
512 KiB plain host-visible allocations (1.1-1.2 ms) and 70-79 ms beside 64 MiB ones (28-30 ms);
paced, 0.10-0.32 ms beside every kind. An RTX 2080 on a loaded host showed pacing lower the median
beside every kind too. What stays open: a program's own release of a no-copy buffer frees its
import there (Metal's contract), unpaced, as does a completed command buffer's handler that frees
the imports its blits held last; one free still holds a submission that meets it.
2026-11-11 17:54:27 -08:00
Anees Iqbal 515367b8f2 FAST-PATHS: the XTX's submission times beside surfaces over dma-bufs
submit_per_surface on the RX 7900 XTX, three runs at the tip: 128 surfaces list
256 dma-bufs (108 to 109 us in the ioctl) while in use and 128 after their idle
window (59 to 70 us). Text only.
2026-11-11 17:14:21 -08:00
Anees Iqbal e2c31d54e4 FAST-PATHS: what RADV lists in each submission, and what a texture in place over a dma-buf keeps
The idle-release bullet says a texture in place over a no-copy buffer leaves
the buffer's import to the release (its blit reads the buffer as any blit), with
the 780M lane's counts (submit_per_surface, three runs: 128 surfaces list 256
dma-bufs while in use, 128 after the idle window). A known-gap entry records the
per-entry cost the raw probe measured on the 780M and the XTX (0.43 to 0.44 us
per dma-buf import per kernel submission), what Vulkan offers that does not
change it (memory priority, no device address, no pageable extension listed),
that separate submission calls list every import again, and that each in-place
texture's own image import stays listed for its life (RADV requires a dedicated
allocation of such an image).
2026-11-11 17:14:21 -08:00
Anees Iqbal 2abe74f6f1 Docs: say what an in-place dma-buf texture lists now, without the history
The host_residency module doc and HOWTO section 6 told what a guest surface
listed before the in-place texture stopped pinning its buffer's import; docs
say what is true now. Text only.
2026-11-11 17:14:20 -08:00
Anees Iqbal 9b2ef7c237 A texture in place over a dma-buf import leaves the buffer's import releasable
RADV lists every imported VkDeviceMemory in every kernel submission, about
0.43 us each on the Radeon 780M and the RX 7900 XTX (a from-scratch Vulkan
probe, Mesa 26.2.6, Linux 7.3.3: 64, 256 and 512 dma-bufs held cost 31.5,
111 and 229 us an empty vkQueueSubmit against 7.2 with none). A consumer's
guest surface is a no-copy buffer over its pages and a texture in place over
the buffer: on RADV the texture is a DRM_FORMAT_MOD_LINEAR image in a
dedicated import of a dma-buf of its own pages, and making it read the
buffer's import apart (ReadApart::Texture), which kept the buffer's import
for good. So each surface listed two imports in every kernel submission for
its whole life.

The image asks the buffer's source for its own pages and binds none of the
buffer's memory, so its making now reads the buffer's dma-buf pages as a
blit does (HostImport::blit_pages: imported again where released, left
releasable), and the in-place watch a rebind reads takes the texels' offset
from the buffer's place in its host pages (Buffer::offset_in_host_pages),
not from their import. The buffer's import is then released after its idle
window like any blit-only one; the texture's image keeps its own import.
Pointer-imported pages, shadows and texel views still read the import apart:
they bind or read the buffer's memory.

Test: tests/host_residency.rs
a_texture_in_place_over_a_dma_buf_import_leaves_it_releasable: the buffer
under an in-place texture is released (its chunks leave
dma_buf_memories_live, the image's import stays), the texture reads the
CPU's writes made meanwhile without importing anything, and the buffer's
next blit imports it again. Without the change the release never comes.
Docs: host_residency.rs, HostMemory::with_dma_buf, HOWTO.md.
2026-11-11 17:14:20 -08:00
Anees Iqbal 5a1e043784 A driver cache record names its pass without the attachments' formats
A render making's record of the driver's data, and the libraries of its
pre-rasterization and fragment shader parts, were named by the pass
shape whole, formats included. A program that makes one state against
passes that differ only in a colour attachment's format (RGBA8Unorm,
RGBA16Float, BGRA8Unorm) so got one VkPipelineCache per format, and the
driver compiled the same fragment module once in each: on the Iris Xe
(ANV, Mesa 26.2.6) 3.3 to 3.7 s per compile for one large module, three
times over at a cold start.

No stage's conversion reads an attachment's format through the pass: a
format the translation reads is in the stage's own words and constants,
which name the part's record too. So a part's record now names the pass
by PassShape::without_formats (which attachments it has, its samples,
fetch inputs, unread inputs, storage attachments, view mask and
locations), and the depth bias is left out of it as before. The library
names the runtime keys its own library objects by keep the formats (the
libraries are made against VkRenderPasses, which must be compatible);
only the driver cache record is shared. A driver that does key a stage
by format keys that entry apart in the one cache: a compile, never a
wrong pipeline.

The record-naming version (shader_cache/driver.rs VERSION) goes to 3.
METAL2VULKAN_LOG_PIPELINES now says, per library, whether its record
was loaded, missed or its cache shared with an earlier making, and
whether the driver found it in that cache or compiled it (from
VK_EXT_pipeline_creation_feedback).

Measured before the change (a harness making the module's fragment
library against three passes on the Iris Xe, MESA_SHADER_CACHE_DISABLE):
a cache per format, 3.5 s, 3.7 s, 3.3 s; one shared cache, 3.5 s then
0.0 ms and 0.0 ms, the second and third APPLICATION_PIPELINE_CACHE_HIT.

Tests: record_pass_formats (a pass's record name drops formats, keeps
presence, samples, fetch inputs and view mask);
driver_pipeline_compile::creations_over_colour_formats_take_the_first_s_records
(two makings over BGRA8Unorm and RGBA16Float share the first's record,
caches_shared grows by the makings, one fragment library compiled,
while a constant that changes the module keeps its own record);
creation_log's text test.
2026-11-11 17:03:23 -08:00
Anees Iqbal 9c766f63d0 Docs: an RTX 3090 saturates logicOp's out-of-range integer outputs too
The logic-operation lane on an RTX 3090 (driver 620.70.06, job
m3-max-17707, at bdb59d55de): every out-of-range integer channel
(RGBA8Uint, RGBA8Sint, R16Uint, RG16Sint under xor and and) stores Metal's
saturated code through Vulkan's logicOp and through the fragment
function's operation, as on lavapipe. The FAST-PATHS known-gap row and
the private_state docs name both measured devices. No note: the spec
leaves the value undefined, and neither device differs from Metal.
2026-11-11 15:44:59 -08:00
Anees Iqbal e393b10cb7 Half + - * on the device's 16-bit arithmetic take the AIR's own contraction
A half fadd, fsub or fmul on the device's 16-bit arithmetic (ArithStrategy::F16:
MoltenVK, measured, and the float-controls profiles) was always kept apart: a
sum or difference decorated NoContraction and a product as Fma(a, b, -0.0)
decorated NoContraction, whatever the AIR's flags allowed. That holds Metal's
exact half bits at the cost of every fusion the flags allow (AGENTS.md rule 1:
the device's native arithmetic). It now decides as float does (contraction()):
an operation whose flags carry both contract and reassoc is undecorated, its
product a plain OpFMul, and the device's compiler groups and fuses it; any
other keeps today's form.

Notes mirror float's: note_rewrites already records FastMathRewrites where a
neighbour can be rewritten. On MoltenVK, Metal's fast compile folds an
undecorated 16-bit operation's conversions away and answers the float result
unrounded (the MetalHalfArithmetic measurement), so there a fast operation
records FastMathRewrites, whose doc (and docs/API.md's catalogue entry and the
FAST-PATHS device-gap row) now says so, and requires no MetalHalfArithmetic,
which the kept form still requires.

On an owned proxy (hnq_half_layer_composite) on the Iris Xe, the step-1
prototype of this form cut the SIMD8 cycle estimate from 58584 to 33092.

Tests: f16_binary's rounded-result and one-instruction tests under both
contractions; half_arithmetic_on_the_device_takes_the_airs_contraction
compiles fast, contract-only and flagless half + - * on every profile that
computes them in 16 bits and checks the instruction, its decoration, the note,
the requirement and the interpreted answers.
2026-11-11 15:37:33 -08:00
Anees Iqbal 256867fc33 Docs: copied host buffers' gem10 cost figures cover the run at the read-back tip too
The 256 MiB bench at the two-pass comparison's tip (gem10, job 17674, load 6-7) took
5.9-6.1 ms each way where nothing changed, 26.1-26.4 ms in and 26.7-27.3 ms back where
every byte changed, and 25.9-27.5 ms (47.4 without masked stores) for the GPU's rewrite of
every float, the snapshot 15.4-15.8, 146-152, 206-215 and 280-289 ms beside it: the ranges
in FAST-PATHS and copied.rs's module docs now cover both runs. And a module-doc line past
100 columns is wrapped.
2026-11-11 15:32:27 -08:00
Anees Iqbal edbd81a4df Docs: a copied host buffer's device base, its host blocks and its reads back on the staging queue
FAST-PATHS' base bullet gives the host's uncached reads of a device base (9-16 us a block
awake, 170-206 us idle on the RTX 5080 Laptop GPU's host), the blocks kept on the host, the
read back of 32 blocks or more on the staging queue with the crossover bench's figures on
the 5080 and the RX 7900 XTX, the GPU's wake from power-down a copy may wait for, and the
first and later merges back of a 256 MiB copy both sides wrote whole. Its cost bullet gives
the quiet gem10 run's figures (job 17408), and its kernel bullet the 5080's pass figures
(job 17417). HOWTO and API.md name copied_base_host_blocks and
copied_base_blocks_read_back.

Earlier commits 4af4a8665b and 7a93903404 carried doc edits with their code (the split's
sentence in API.md and HOWTO, copied.rs's cost bullet).
2026-11-11 15:32:27 -08:00
Anees Iqbal 9a14d3f38a Docs: FAST-PATHS states what a missed tag undoes at a completion, and the merge's byte both sides wrote
The merge back compares each block the GPU changed with the pages' own bytes where
their tag agrees, so a CPU write in such a block that the tag missed (at most 2^-64
a block a comparison) is undone where the GPU did not change its byte. A byte the CPU
writes while the merge runs keeps the CPU's or the GPU's.
2026-11-11 15:32:24 -08:00
Anees Iqbal d2f862c193 Copied host buffers: a split comparison's threads take their runs with the runs' lock let go
The pull loop's while-let held the lock of the runs' iterator through each run's work,
so the threads took their runs one after another. The lock is now let go before the
work, as a let statement drops its temporaries.
2026-11-11 15:32:23 -08:00
Anees Iqbal fbbf6322a1 Runtime tests: the 256 MiB copied bench prints the bytes copied in and merged back, and their rate 2026-11-11 15:32:22 -08:00
Anees Iqbal 8ddde3eec8 Docs: where a copied buffer's base lies, as copied_base_type decides it (a heap of 1 GiB or more) 2026-11-11 15:32:21 -08:00
Anees Iqbal 755656ccd8 Docs: a copied host buffer's base is made at its first writer, tagged per 1 KiB, its bytes in VRAM where a resizable BAR has room
HOWTO's copied-buffer section and API.md's copied-host-pages notice say what a copied
buffer holds beyond its copy and which WorkCounts count it.
2026-11-11 15:32:18 -08:00
Anees Iqbal cb8f4a0988 A compute state's required size past its kernel's own maximum is refused
A compute creation whose descriptor requires a threadgroup size of more threads than its
kernel's own [[max_total_threads_per_threadgroup(n)]] is now refused,
RequiredThreadsProblem::OverKernelMax, as Metal's first compile of the kernel refuses it. The
runtime made such a state and answered the kernel's maximum.

Measured on the M3 Max under macOS 27.0.1, compute_pipeline_limits.m with a salt
(m3-max-17580), each case a first compile and the same again in its salt:
required-128-attribute-64 is refused both times, code 3, "requested required threads per
threadgroup 128,1,1 but 'count64' expects max threads per threadgroup 64";
required-32-attribute-64 is made answering 32. After a compile of the kernel with no size,
Metal makes the 128 state and answers 64. The runtime answers as the first compile, every time,
as it already does for the other history-dependent answers (docs/API.md, accepted differences).

How: the check runs after the compile (additions::check_kernel_maximum, called from
of_kernel), not in the translator's compile: the required size is no part of the compiled
pipeline's key, so a pipeline of the kernel found in the memo, an archive or the disk cache
would skip a check there. It reads the kernel's maximum through a new public accessor,
CompiledFunction::max_total_threads_attribute. A tile function's own maximum beside a
required size is unmeasured and not checked.

Also: the probe header records the salted answers and the descriptor-validation stops of
m3-max-17549; docs/API.md's accepted difference and the additions.rs module docs name the
refusal; docs/REFUSALS.md regenerated; api_signatures.tsv blessed (two additions: the variant
and the accessor).

Test: runtime_lane::compute_threadgroups::
a_required_size_past_the_kernels_own_maximum_is_refused_every_time refuses 128x1x1 and 16x8x1
beside 64 before and after a state of the kernel is made (the second finds the pipeline
compiled), makes 32x1x1 (32) and 8x8x1 (64), and makes 128x1x1 for the kernel without a
maximum.

Verified: nothing yet; the lavapipe run of the test and the lint follow.
2026-11-11 15:17:08 -08:00
Anees Iqbal 1396cad799 NativeLogicOperation: Vulkan's logicOp on a signed normalized format's own codes is recorded
Post-merge evidence m3-max-17539 (msi, lavapipe lane at 0103821834) failed
the_logic_operation_over_a_signed_channel_s_lowest_code: Vulkan's logicOp
over an RGBA8Snorm channel holding 0x80 stored the operation of the raw
code (xor of 0xe0 gives 0x60, equivalence 0x9f) where Metal reads 0x80 as
0x81 and stores 0x61 and 0x9e, through a pipeline that recorded no note.
The Vulkan specification's logical operations take "the color attachment's
R, G, B or A component value", the stored code itself, so this is the
device's native form (rule 1): it stays, and is recorded.

lower::fragment::logic::vulkan_differs replaces widens as the test
note_vulkan_codes applies: a 10-bit unorm format, or any signed normalized
one. Docs: PrecisionNote and Degradation docs, API.md catalogue, the
FAST-PATHS known-gap row (now also citing the spec's "undefined" for
integer outputs past the channel's range, which lavapipe saturates as
Metal does, so no note), private_state and logic module docs, the
conformance replay bullet.

The unwritten-channel half of the item (masked channels, and no-op, which
draws unwritten, keep 0x80 where Metal stores 0x81, in both lavapipe forms)
is the existing snorm-minimum-kept notice: Metal's pass writes each tile
back through its values. The lane now accepts a kept lowest code only
where the device announced snorm-minimum-kept, and the integer test fails
any non-Metal answer that comes through no NativeLogicOperation pipeline.

Tests: the translator unit test
vulkan_s_operation_differs_on_10_bit_and_signed_codes_alone, the engine
test's lavapipe assertions (RGBA8Snorm and R16Snorm xor noted). Evidence
jobs follow on lavapipe (both forms) and the translator suite.
2026-11-11 15:06:23 -08:00
Anees Iqbal 569ac877dc copied-host-pages is announced once per cause, not once per kind
A consumer acts on a refused import, a failed one and a move apart, and rule 2
says each degradation is announced; the kind-level once let a gate's refusal
silence a later failed import on the same device. Device::degrade_copied_pages
keys copied-host-pages by its CopiedBecause cause (and a buffer lying in
another's live copy as a reason of its own) with a bit per reason in the
device's Announced record. Device::degrade keeps its rule for every other
kind; both share degrade_where (lowering refusal, replay, announce_each,
placement), so only this kind's record changes.

Test: copies_of_two_causes_on_one_device_are_each_announced, a refused copy
then a failed one (fail_next_host_imports) both heard with their reasons, a
second refused copy not. docs/API.md states the rule and the entry.
2026-11-11 15:00:04 -08:00
Anees Iqbal aba4034dca Runtime: a program's exit handler reaches no destroyed thread-local
exit destroys the exiting thread's thread-locals before it runs the exit handlers (macOS, the
GNU C library), and LocalKey::with on a destroyed one panics, which in a handler aborts the
process. The exits lane case an_exit_handler_s_common_calls_answer_as_on_any_thread aborted
there on both: "cannot access a Thread Local Storage value during or after destruction" in
calls_at_exit on the M3, and on lavapipe at warm::pass::warming from PipelineMemo::compute,
in the handler's new_compute_pipeline_state.

Every runtime thread-local whose type needs dropping that a program's call reaches is now read
with try_with, with what the thread does once it can keep nothing:
- the making budget's turn (pipeline/budget.rs): program_turn takes none there, holds_turn is
  false, and a turn's give-back and lend read the note with try_with;
- the driver facts' expectation (driver_facts.rs): expecting runs the call alone, its messages
  relayed;
- the creation log's split (pipeline/creation_log.rs): none noted;
- the warm pass (warm/pass.rs): none;
- a relayed compile's held sink messages (device/compiles.rs): the call alone, its messages
  delivered as raised;
- a lowering's refusal (render/deferral.rs): lowering::refusing is false there, so a notice of
  a kind the device refuses while lowering is announced, as anywhere else;
- the debug-build checks of kept resident uses (binding.rs) and of slot rebinds (the
  translator's bind/graphics.rs): skipped.

dirty_pages, shards, resource_ids and contexts already read theirs with try_with; the rest hold
Copy values with no destructor. docs/API.md's accepted differences under "Process exit" say what
an exit handler's calls keep no state for.
2026-11-11 14:55:15 -08:00
Anees Iqbal 93281ffc68 PrecisionNote::NativeLogicOperation: Vulkan's logicOp on a 10-bit format's own codes is recorded
Metal's private logic operation into RGB10A2Unorm and BGR10A2Unorm widens each channel's codes to
16 bits, operates and narrows back (probe logic_operation, M3 Max). A device with Vulkan's
logicOp draws with Vulkan's operation, the device's native form (rule 1), which works on the
10-bit codes themselves and can store another code (lavapipe's xor: green 938 where Metal's rule
gives 937). docs/FAST-PATHS.md's known-gap row ended "No note records it".

DeviceColorConversion could not carry it: every device that has logicOp (lavapipe, RADV, ANV,
NVIDIA) already records that note for any float write into a unorm attachment, so it would
neither tell this difference apart nor be absent where the fragment function computes Metal's
rule. So a new note, NativeLogicOperation (degrade code native-logic-operation, a native note):
the render pipeline's fragment stage records it exactly where Vulkan's logicOp operates on an
attachment whose codes Metal widens (lower::fragment::logic_widens, structural on the channels'
write rules: the 10-bit unorm formats), that a first output writes (GraphicsState::color_outputs)
with a channel its write mask keeps. The runtime announces it through the stage's notes, as every
note. The fragment function's operation records none.

Docs: FAST-PATHS's known-gap row names the note; API.md's catalogue gains the entry; the
conformance suite's NATIVE_NOTES and the validation comparison's allowance (unbounded) class it;
api_signatures.tsv re-blessed. REFUSALS unchanged (refusal_surface.py --check passes).

Tests: engine_private_render_state's logic test asserts the note on lavapipe's Vulkan xor into
RGB10A2Unorm and BGR10A2Unorm, and its absence for RGBA8Unorm, RGBA8Snorm, R16Unorm and
RGBA16Float, under copy, with an empty write mask, at an attachment no output writes, on MoltenVK
(the function's operation) and on lavapipe without logicOp; logic::tests the widened formats; the
lane runtime_lane::logic_ops asserts the note on each draw it counts as the 10-bit codes' own and
that the device announced native-logic-operation exactly where it has logicOp.

Verified: cargo fmt; scripts/api-signatures --bless; refusal_surface.py --check. Builds and
tests follow as potluck jobs.
2026-11-11 14:34:30 -08:00
Anees Iqbal 397c0f5d99 A late pass sends an unshared queue's command buffer before held work it lets go
Under UnsharedIsolationPolicy::Bounded, another queue's batch on an unshared
queue's VkQueue is held until its room comes, keeping its place in the order.
A pass that came only after the room came (the scheduler's thread, or a
waiting thread's pass, run late by a loaded host) found that batch and the
unshared queue's command buffer ready together and sent them in commit order:
the whole held batch, about 30 ms in the pin 39 round's 5080 runtime leg, went
ahead of the unshared one, which the hold exists to keep from waiting.

Order::next now takes `first`: the heads it puts first are asked before the
others, each still behind any earlier batch it conflicts with that keeps its
place (is_behind), so tracked order across queues stays commit order. Both
passes (the thread's and a committing or waiting thread's) put first an
unshared queue's head on a VkQueue that holds other queues' work back for it
(CommandBufferShared::goes_ahead_of_held_work); under Off, and for every other
queue, the order is unchanged.

Tests: a_late_pass_sends_an_unshared_queue_s_command_buffer_before_work_let_go_with_it
(the device test from the commit before, which fails without this), and
a_head_put_first_goes_before_the_ready_heads_committed_before_it (Order alone).
2026-11-11 14:31:06 -08:00
Anees Iqbal 72834578f0 Docs: the dma-buf stall's runs with the form and type order on the RTX 5080 Laptop GPU
docs/FAST-PATHS.md's NVIDIA dma-buf stall bullet adds the result of the form and type order with a
kind's first imports one at a time on 615.71.09: 6 of 6 four- and eight-thread probe runs ended on
the RTX 5080 Laptop GPU, in 8 to 9 s each (potluck m3-max-17361, three runs of each probe, at
branch steelbrain/nv5080fails-serialform, which carries this branch's code on the earlier base).
Before it, with the type order alone, both probes stalled in their first run (m3-max-17118); with
every import serialized and the type order alone, 2 of 4 runs failed (m3-max-17296).

The stall stays open for a kind's first imports, which still try a refused form or type.
2026-11-11 14:24:49 -08:00
Anees Iqbal c6371eebfe dma-buf: an import tries first the form and type its kind last imported as
On the RTX 5080 Laptop GPU (NVIDIA 615.71.09) the four- and eight-thread leak probes still
stalled with the type order alone. A failed import there can spin inside vkAllocateMemory while
holding the driver's lock. With every failed import printed (potluck m3-max-17206, a scratch
commit that also tried no host-visible type), 4346 of the probe's 6000 imports failed first: type
0, dedicated to nothing, ERROR_OUT_OF_DEVICE_MEMORY, for udmabufs of scattered pages from 16 KiB
to 63 MiB. Each then succeeded dedicated to its buffer. The type order cannot remove these,
because they are a refusal of the form, not of the type. Locking every import alone did not stop
the stall either: 2 of 4 runs still stalled, every import failing twice before it succeeded
(m3-max-17296).

The order extends from type to form and type. Each kind remembers the form (dedicated to its
buffer or not) and the type its last import succeeded as (Memory::dma_buf_imported_as), and
tries that pair first. Every other pair is still tried after it, in today's order. worked_first is
generic over what it orders. On 615.71.09 a no-copy buffer's imports then go dedicated first and
no longer fail in steady state. On 620.70.06 the pair is (dedicated to nothing, type 0), as
before. The import's third value now says whether the memory is dedicated to its buffer, made so
now or because an earlier import of its kind found that form
(WorkCounts::dma_buf_buffer_imports_dedicated counts the same imports). The dedicated-allocation
info is renamed so that it no longer shadows the attempt's form.

docs/FAST-PATHS.md records 615.71.09's refusal of the form, the order, the first-import lock, and
the stall's runs on 615.71.09.

Test: memory::a_dma_buf_import_tries_the_form_and_type_its_kind_last_imported_as_first covers
the pairs: a buffer's attempts with the dedicated form put first, and with the undedicated form
put first; a shared import, which has no dedicated form; and the type cases as before.

Verified at this change's sources (branch steelbrain/nv5080fails-serialform, which carries the
same code on the earlier base):
- CPU: 31 of 31 tests pass (potluck m3-max-17327).
- RTX 2080: 31 of 31 touched tests pass (m3-max-17331), including host_ram_dma_buf x12 and
  no_pointer_import x2, which cover the dedicated retry. The probes ran in 28.8 s (four threads),
  56.8 s (eight threads) and 16.8 s (one thread).
- RTX 3090: 31 of 31 pass (m3-max-17358). The probes ran in 41.7 s, 69.2 s and 18.0 s.
2026-11-11 14:24:48 -08:00
Anees Iqbal a334ecbef2 FAST-PATHS: the 10-bit gap as the lane measured it on lavapipe
Job m3-max-17323: under lavapipe's logicOp the lane's xor and equivalence draws into
RGB10A2Unorm (blended and not) store exactly the per-channel texel, 4 draws, where Metal's
rule widens the codes to 16 bits.
2026-11-11 14:18:20 -08:00
Anees Iqbal 9873d6cfed Logic operation: RGB10A2Unorm and BGR10A2Unorm on 16-bit codes, as Metal's
The probe (job m3-max-17294 on the M3 Max) confirms Metal's rule for the 10-bit unorm formats at
all 12,800 texels of its formats and masks cases: each stored code widened to 16 bits
(round(d * 65535 / max)), the operation on it and the output's 16-bit code, the result narrowed
back to the channel's code. The fragment function's operation now computes it as a 16-bit
channel's (logic::channels answers 16 for a 10-bit or 2-bit unorm channel), the device's write
narrowing the result, so these formats are no longer refused under the function's operation.

Vulkan's logicOp, which a device that has it draws with, operates on the 10-bit codes
themselves: recorded as a known gap in FAST-PATHS. The lane now checks Metal's rule for
RGB10A2Unorm and counts apart the draws that store exactly the per-channel rule's texel under
Vulkan's operation. Translator tests: RGB10A2Unorm compiles under the function's operation on
MoltenVK and on lavapipe without logicOp; B5G6R5Unorm is refused there.

Not yet built or run.
2026-11-11 14:18:20 -08:00