Commit Graph
5048 Commits
Author SHA1 Message Date
Anees Iqbal b620952743 tns_mm_left fixture: matmul2d with a cooperative left input, and its construction
The owned fixture tns_mm_left, built for macOS 27 (each run the header's _v2 form), computes
out = A * B + C over the descriptors macOS 27's gather matmul kernels use, 16 x 32 x 32 and
32 x 32 x 32 over one simdgroup, A a cooperative left input filled by coordinate, B transposed or
not in device memory, in threadgroup memory or as a cooperative right input, in float, half and
bfloat (36 variants), one M x 32 tile per threadgroup from blocks a buffer names. Its second
kernel, tns_init_left, reads what constructing a cooperative left input in a loop's body leaves
in its storage, as tns_init reads a destination's and a right input's. The run forms are the
gather kernels' own: run_cooperative_<t>_dv_<t>_f32_v2, run_cooperative_<t>_tg_<t>_f32_v2 and
run_cooperative_<t>_<t>_f32_v2.
2026-11-12 19:23:39 -08:00
Anees Iqbal 80a3cf4bb1 Metal observations: the 22 tns_coop_left cases on the M3 Max (macOS 27.0.1)
Every case qualified (m3-max-23724). Each reading is the measured model's: the left input of
m x k is m / 8 block rows of k / 8 block columns, coordinates (k, m), whichever the right input's
transpose; the 16 x 32 x 32 right input and destination follow the model of the shapes measured
before, with a 1 x 1 split; every element is valid and every element i sits at byte i * size.
2026-11-12 19:23:39 -08:00
Anees Iqbal ba6d54c611 Authored cases: where matmul2d places a cooperative left input's elements
Twenty-two cases over tns_coop_left, one per variant: the cooperative left input of 16 x 32 x 32
and 32 x 32 x 32 with the right input transposed or not, the right input (either transpose) and
the destination of 16 x 32 x 32, in float, half and bfloat over one simdgroup of 32 threads, as
the tns_coop_layout cases read them. Installed through corpus-case-check --install
(m3-max-23719).
2026-11-12 19:23:39 -08:00
Anees Iqbal 680ff9a563 tns_coop_left fixture: where matmul2d places a cooperative left input's elements
The owned fixture tns_coop_left measures, as tns_coop_layout does, where MetalPerformancePrimitives'
matmul2d places the elements of a cooperative left input (16 x 32 x 32 and 32 x 32 x 32, the right
input transposed or not) and of the 16 x 32 x 32 destination and right input, in float, half and
bfloat over one simdgroup: per thread the capacity, then one word per element (valid, byte offset
from element 0, coordinates). macOS 27's gather matmul kernels fill a cooperative left input of
those descriptors by offset from element 0, so a translation must place its elements as Metal
does, and no layout of a left input was measured before.
2026-11-12 19:23:38 -08:00
Anees Iqbal bab584d04b Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 19:01:04 -08:00
Anees Iqbal 8ce98916be warm test: expect_err, as clippy asks 2026-11-12 18:59:46 -08:00
Anees Iqbal cbe64ff91b warm: a failed creation is announced once per kind, naming the kind and nothing of the shader
What: a record whose creation fails on Device::warm is still counted and dropped, and the first
failure of each kind a device meets is now announced through its message sink (else stderr) as
the warning metal2vulkan-warm-record-failed, as the first unread record is. The kind
(warm::pass::failure_kind) is the runtime error's variant and, for a translator refusal, its
feature and what it needs, e.g. Compile(Unsupported{Lowering(Access); NotImplemented}); for an
input error, its class. Never a symbol, location or message, which can name the record's
shaders. Past 32 kinds a device counts later ones alone.

Why: pin 62's warm pass failed 124 of ms01's records and 90 of um870's and said nothing: the pass
counted them and dropped them, so the walk's summary line was the only trace, and naming the
class took a replay with a temporary print (all 124 on ms01 were
Unsupported{Lowering(Access); NotImplemented}, fixed by SEMANTICS_VERSION 2070). The next such
regression names its kind in the consumer's log.

Tests: a_failure_kind_names_nothing_of_the_shader (a refusal with a symbol and a function
location renders as its variant, feature and needs only), and the device test
a_failed_creation_is_announced_once_by_its_kind_and_the_pass_goes_on (two records Metal refuses
alike around a render record: 2 failed, 1 warmed, the warning heard once, naming the kind the
program's own creation meets and not the kernel's name). The runtime README and docs/HOWTO.md
say so.
2026-11-12 18:59:46 -08:00
Anees Iqbal f5603a00ef Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:55:45 -08:00
Anees Iqbal 62fb29e05e RUNTIME_VERSION 2179: a rate-mapped pass's pieces are timed on a device asked for host-clock GPU times
The two commits before this one. A rate-mapped pass's piece timer skipped every device whose command buffers answer
GPU times from the host clock (gpu_times_from_host), so on reims's RTX 3090 rate_map_pieces_timed stayed 0 and no piece
time was read where the rate-map hang happens. It now skips only a device whose driver's timestamps wait for every
queue (MoltenVK); the option, gpu_time, the degrade notice, the API catalogue and the work counts say so. The pieces
lane gains guest-scale lanes (384 commands of about 5.5M indices, about 120 pieces on the 3648x1734 map's 2074
regions, FanOut and Exact), compiled only under m2v_gpu_hazards and ignored by default; the lane docs and the fan-out
row's FAST-PATHS cost cell carry the RTX 3090's numbers, FanOut slower than Exact at 64 commands there.

Verified (on the branch): the runtime test a_device_answering_gpu_times_from_the_host_times_its_pieces on lavapipe
(m3-max-23718) and on the RTX 3090 ("pieces 12 timed 13"); the 3090 run m3-max-23744 (--exclusive, NVIDIA 620.70.06):
commit 64 commands 39.4 ms in 20 pieces (longest 2.64 ms), host step FanOut 98.4 ms (probe 14.0 ms) against Exact
54.4 ms, guest scale FanOut 174.3 ms (probe 74.4 ms, 384 fanned out) against Exact 332.3 ms in 117 pieces, all timed,
longest 2.67 ms; nothing wedged. Signatures and REFUSALS unchanged; land-tip clippy with m2v_gpu and the hazards cfg
queued (23787).
2026-11-12 18:54:59 -08:00
Anees Iqbal 0c6d7cc1c8 Pieces lane at a guest frame's scale, a GPU hazard; the RTX 3090's numbers
rate_mapped_pieces_guest_scale (FanOut) and _guest_scale_exact run the host
step's frame at six times the commands (384 commands, 5,508,648 indices,
about the 126 pieces a guest frame was recorded in on an RTX 3090), compiled
only under m2v_gpu_hazards and ignored by default.

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

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

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

Verified: the new runtime test
a_device_answering_gpu_times_from_the_host_times_its_pieces passes on
lavapipe (12 pieces past the first, 13 timed) and on an RTX 3090 (NVIDIA
620.70.06, the same counts), built at the branch's earlier commit with the
same runtime source.
2026-11-12 18:54:27 -08:00
Anees Iqbal a65e891df9 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:53:23 -08:00
Anees Iqbal 760eeb6cca RUNTIME_VERSION 2178: an import several blit-read no-copy buffers lie in stays releasable
The commit before this one. A guest-RAM import that a second no-copy buffer over the same bytes lay in was held for
good, whatever the buffers' reads (read_apart_second_buffer): on reims's Valley walk on the RX 7900 XTX about 1,268 of
1,330 live dma-buf imports, each listed in every kernel submission (RADV lists every imported BO), about 0.57 ms of
each 0.835 ms vkQueueSubmit. Such an import now stays releasable while every read of each buffer in it is a blit's or
none (a holder over the whole view that nothing reads included), released once idle and imported again as the
one-buffer case is. A binding, an argument word, a resident use, a handed-out address, a heap's bytes or a rebound
buffer lying in it, a buffer bound inside its memory, or a range_of share keeps it held as before. The read-apart
gauge is split into host_imports_read_apart_inside, _shared_range, _heap and _rebound; host_imports_joined_releasable
counts the imports the new rule keeps releasable. host_residency's and WorkCounts' docs follow.

Verified (on the branch, debug test binary): 780M RADV (m3-max-23761) host_residency and host_import_counts 15/15, the
new test (a never-read holder plus a blit-read buffer: released, re-imported by a blit, released again, then a kernel
binding one and reading the other's address) included; the same binary with the old exposure fails it ("the second
buffer kept the import for good", held for good 1 against 0). Clippy all features and m2v_gpu, rustdoc (23710); api
signature tests 16, runtime suite 1502, lavapipe host import, residency and alias tests 39 (23713), one test-only
commit before the tip.
2026-11-12 18:52:43 -08:00
Anees Iqbal 5039015420 An import several no-copy buffers over the same bytes lie in stays releasable
A no-copy buffer made over exactly the bytes a live one covers lies in that
buffer's import (host_aliases.rs, "One memory, one import"). Until now its
making read the import apart (ReadApart::SecondBuffer), which keeps a
releasable import imported for good. Such a buffer reads the import the way
the first one does, through the import: its blits take the import's objects,
imported again where released, and any other read of it exposes the import
just as a read of the first buffer would. So the import now stays releasable
while every read of each buffer in it was a blit's, or there was none. A
buffer that is never read, made only to keep the bytes imported, keeps the
import no more than a buffer read only by blits does.

Why: on the RX 7900 XTX (RADV), a guest's 3D benchmark kept 1,000 to 1,330
dma-buf imports live. RADV lists every one of them in every kernel submission,
at 0.43 to 0.44 us each (docs/FAST-PATHS.md, known gaps). Of those imports,
1,262 were held for good, and every held one had a second buffer lying in it.
The consumer keeps a holder for each view of guest pages: a no-copy buffer
over the whole view that nothing reads, with the block's buffer lying in its
import. The frames named about 0.6 imports per command buffer, while the
scheduler thread spent 0.63 to 0.90 s of each second in vkQueueSubmit, at
0.835 ms per call. Our own blocks on that device are plain VRAM, which RADV
makes local and lists in no submission.

What still keeps such an import imported for good:
- a no-copy heap's own bytes lying in it: the heap's placed buffers'
  addresses are the heap's, handed out without any read of the import noted;
- a rebound buffer lying in it, as a rebind's own import is kept;
- a buffer bound inside its memory with a VkBuffer of its own;
- a buffer made to share its buffer's range (BufferDescriptor::range_of),
  which is handed that buffer's address.

Counters: the gauge host_imports_read_apart_second_buffer is split into
host_imports_read_apart_inside, _shared_range, _heap and _rebound. The new
host_imports_joined_releasable counts the buffers that came to lie in a
releasable import beside another and left it releasable; a walk shows the
path ran when it is non-zero. host_residency.rs ("Several buffers in one
import"), host_aliases.rs, the WorkCounts docs, docs/HOWTO.md and the API
signature table say so.

Test: tests::host_residency::an_import_two_buffers_lie_in_is_released_while_idle_and_read_right_again.
It makes a never-read holder and a second buffer over the same 4 pages of a
udmabuf-backed memfd. Joining keeps the import releasable (nothing held for
good, no read apart) and imports nothing new. Read by a blit, the import is
released. The file's writes made while it is released are read by the next
blit through the second buffer, imported again from the kept descriptors. It
is released again. Then a kernel binds the second buffer, makes the holder
resident (useResource:, as Metal reaches a no-copy buffer through an address
only once a command buffer used it) and loads the holder's Metal address from
set_bytes; the binding imports the import again for good. The words the kernel
reads through the address, and the words it writes through it, are checked
against the pages. The source is called once, and the import leaves the gauges
once its buffers go.
host_import_counts now expects a second buffer over the same bytes to read
nothing apart.

Verified (the runtime's debug test binary, --cfg m2v_gpu, not a release build):
- m3-max-23710 (msi-laptop): cargo clippy --workspace --all-targets
  --all-features -D warnings, the runtime's clippy under --cfg m2v_gpu, and
  the runtime's rustdoc with -D warnings: clean.
- m3-max-23713 (msi-laptop): the API signature tests, 16 passed; the
  runtime's suite, 1502 passed, 6 skipped; on lavapipe (--cfg m2v_cpu_icd)
  the host_import_counts, host_residency, pointer_residency and host_aliases
  tests, 39 passed.
- m3-max-23761 (Radeon 780M, RADV PHOENIX): the host_residency and
  host_import_counts device tests, 15 passed, the new test among them ("1
  chunks of two buffers released twice, imported again twice"). The negative
  control, the same binary with a joining buffer reading the import apart as
  before, fails the new test at "the second buffer kept the import for good"
  (held for good 1, expected 0).
The lint and suite jobs ran one commit before the test's last change (the
holder made resident before the kernel reads through its address), a
test-only change that the 780M run's binary carries.
2026-11-12 18:52:11 -08:00
Anees Iqbal 655c548536 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:51:40 -08:00
Anees Iqbal 508a70b5eb RUNTIME_VERSION 2177: a GPU that stops with no loss from the driver fails its work and is parked
The five commits before this one. On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and every
completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the program's command buffers waited without end.
The completion's waiters keep a device-wide stall clock (command_buffer/stall.rs) that runs while a wait ran out with
its front batch pending and stops whenever any queue's timeline advances. Past 10 s one waiter probes the staging
queue with an empty submission and for up to 2 s reads the probe, the stuck front's fence and its timeline; a loss
takes the failed wait's path, an answered probe or an advanced front fails nothing and restarts the clock, so a device
that still makes progress is never failed whatever its work's length. An unanswered probe marks the generation
stopped and lost (the oldest command buffer GpuHang, the rest GpuRecoveryVictim), the line recovers, and the
VkDevice is parked: never destroyed, none of its objects released, its queues never waited for, its teardown returning
before vkDeviceWaitIdle. New public query Device::is_parked(vk::Device) -> bool (no Metal counterpart); counters
stall_probes_sent, wedges_declared, longest_stall_nanos; the DeviceRecovered notice says the VkDevice stopped and was
parked. The queue-switch check's waits end for a parked device. FAST-PATHS known gaps: no probe without a staging
queue, the parked device's leak, NVIDIA's exit handler waiting on a parked device's work, Metal's own bounds.

Verified (on the branch, archive c010d899ff, validation layer 1.4.363 on, NVIDIA 620.70.06): um870 RTX 3090
(m3-max-23757) 5/5 and um790 RTX 2080 (23758) 5/5: an answered stall sends 2 probes that complete in 81-197 us and
fails nothing (longest stall 200 ms), a stopped one fails after 2.3 s with 1 probe, 1 wedge, 1 recovery, the device
made again in 512-549 ms and the next command buffer running; the managed-copy rounds 0 wrong on all three routes, the
layer's whole-pool vkResetQueryPool report (VUID-vkResetQueryPool-firstQuery-02741, the documented layer gap) claimed
through layer_claim::Watched. lavapipe 95/95 (23685, at 1f24262fad). Clippy default, m2v_gpu, m2v_cpu_icd, rustdoc
and the api tests at c010d899ff (23748).
2026-11-12 18:50:57 -08:00
Anees Iqbal c3a002b71c stall test: the stopped test drains the parked queue before the process exits
On NVIDIA (620.70.06; um870's RTX 3090 and um790's RTX 2080) the stopped
test passed and its process never exited: under gdb (job 23736) the test
reported ok in 21.5 s, and the main thread then spun in exit(), in an exit
handler of libEGL_nvidia that tears down every VkDevice left and waits for its
work. The parked VkDevice's batch waits for the event's semaphore, which the
test never signalled. The test now keeps the stopping generation's functions
and semaphore and signals the reserved counter on the parked VkDevice once it
has checked the recovery, so its queue drains. It prints when the stuck
command buffer failed and when the next one ran.

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

Verified: cargo fmt. The NVIDIA runs follow with this commit's archive.
2026-11-12 18:50:18 -08:00
Anees Iqbal a5b6d52e70 managed_copy_device rounds: claim the layer's silence through layer_claim::Watched
The did_modify_range rounds tests (two timed command buffers in flight, on one
queue or two) failed on the um790's RTX 2080 with the validation layer 1.4.363:
ten VUID-vkResetQueryPool-firstQuery-02741 reports, each 'can't be called on
VkQueryPool 0x660000000066 that is currently in use by VkCommandBuffer 0x...'
(job 23407). That is the layer's whole-pool check of a host query reset that
tests/query_reset_gap.rs and the validation crate's
candidate/runtime_case/query_reset_gap.rs document from the layer's source
(cc_query.cpp, PreCallValidateResetQueryPool: a query of the range neither
AVAILABLE nor UNKNOWN calls ValidateObjectNotInUse on the whole pool): a slot
whose last holding completed and was read is reset as another command buffer
takes it while other slots of the same pool are in flight. The runtime gives a
slot back only in the completion turn's read_stamps, after its command
buffer's work completed, or at commit where nothing was submitted
(Stamped::NoWork); so the report names another slot's holder.

These tests collected every error message themselves, so they failed on the
gap. They now ask for the layer and claim its silence through Watched, as the
other layer-claiming tests do: the gap passes on 1.4.363 only, where the
source was read, and fails marked for a re-read on any other release; where
the host has no layer the test says LAYER-ABSENT.

Verified: cargo fmt. The 2080 run follows with the wedge's archive.
2026-11-12 18:50:18 -08:00
Anees Iqbal f625fa2618 A stopped device's teardown waits for no check's wait
On the RTX 2080 the stall test's teardown hung after the generation stopped:
the old generation's queue-switch check thread looped in its waits (a slice at
a time, VK_TIMEOUT each) for a round whose batches sat behind the stuck one on
the parked device, and the teardown waited for that thread to end. Its two
wait loops, and a dma-buf binding's settle, now end as on a lost device once
release::parked answers for their VkDevice.

Verified: the 2080 run of tests::stall follows on this commit.
2026-11-12 18:50:18 -08:00
Anees Iqbal 779d1be52a stall: the timeline's read needs no first value: every look reads it
Clippy (all three ways) refused the unused initial value.
2026-11-12 18:50:18 -08:00
Anees Iqbal 64982ac827 A GPU that stops with no loss from the driver fails its work and is parked
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and
every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the
program's command buffers waited without end.

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

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

Tests (tests::stall, through the line's hooks: the clock's bound 200 ms, and
no probe seen answered): a command buffer waiting on its VkQueue for a reserved
event signal is pending; with the probe answered nothing fails and it
completes once the host signals; with none answered it fails as GpuHang, the
old VkDevice is parked, the new one is not, and a command buffer runs after.
Verification follows on this commit.
2026-11-12 18:50:18 -08:00
Anees Iqbal 63232a93ee Re-bless the authored compile census at 3af1ca2dc4
Its product fingerprint follows the runtime-sources pin and SEMANTICS_VERSION since the last re-bless (b0e379733d at
43d2308170). 2287 cases on 21 profile-legs (48,027 cells), 0 failed, 0 regressions, 27 differences: 11 new cases (the
nine tns_mm_v2 cases and two other authored cases committed since), 14 cells of two cases that now compile where they
were refused for private memory above FunctionStorageBytesPerThread (17,408 of 16,384 bytes) on rdna3, Iris Xe,
roadmap-2022 and RTX 50, and those two cases' vk12-floor cells now refused first for MaxPerStageDescriptorStorageBuffers
(9 of 4) instead. The rest of the file's changed lines are artifact hashes (7,271 moved).

Verified: corpus-triage --audit authored-compile --bless on the M3 at 3af1ca2dc4 (m3-max-23746, release, 107 s wall,
slowest compile 588 ms, parent peak 113 MiB), the private sources read in place through the index.
2026-11-12 18:44:39 -08:00
Anees Iqbal 3af1ca2dc4 Re-bless the golden tables at 6b5f4b19ed
The translator changes since the last bless move five golden-hash rows and the engine inventory: SEMANTICS_VERSION 2070
makes generic_pointers' generic_captured and generic_functor translate again on every profile (38 inventory cells,
Unsupported to ok); SEMANTICS_VERSION 2071 adds the tns_mm_v2 fixture (its inventory row, ok on all 19 profiles, its
golden rows and its engine printout, recorded under LLVM 21). The one commit between 6b5f4b19ed and this one's parent
(RUNTIME_VERSION 2176) changes only the runtime, so no table it covers moves.

Verified: bless on the M3 at 6b5f4b19ed (m3-max-23726): golden hashes blessed, engine goldens pass; merged check at the
same sha on msi (m3-max-23712): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface, fast_paths, the
engine and fixture-inventory tests (1553/1556, the three failing exactly the rows this commit blesses), the runtime's
exit_guard and compile_memory tests, rustdoc -D warnings.
2026-11-12 18:38:51 -08:00
Anees Iqbal 6c3eefa3ed Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:32:56 -08:00
Anees Iqbal e4057b4c42 RUNTIME_VERSION 2176: a recovery carries no-copy heaps and the textures placed in heaps
The three commits before this one. After a device recovery a heap over the caller's memory was left refused with the
buffers and textures placed in it, and every texture placed in a heap was left (reims's forced recovery on a 3090:
44 no-copy heaps and 929 heaps' textures; WindowServer's command buffers refused 3424 setFragmentTexture binds and the
desktop came back mostly black). A no-copy heap is now made again over the same pages, as a no-copy buffer is: its
identity kept, its placed buffers carried at their offsets with their bytes as they are (its own buffer's pages keep
what they were made of). Textures placed in any carried heap, Private or no-copy, are made again after the heaps
through the path that placed them, over the same range (sharing its makeAliasable flag), a texture buffer's buffer
with it; a Private heap's texture reads as a new one (counted by storage mode), a no-copy heap's reads the pages. The
heap keeps its texture numbering; a texture the recovery leaves is forgotten so no useHeap makes it resident. Textures
over a carried heap's buffer carry too. Left as before: Shared, sparse and detached no-copy heaps. Docs: heap.rs,
texture/carry.rs, device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md), the
runtime README, FAST-PATHS' known gap on lost texture contents (now naming Private heap textures).

Verified (on the branch, lavapipe): the no-copy heap test fails before the fix ("left refused: ... 1 no-copy heaps, 1
heaps' textures", m3-max-23705) and device_recovery passes 32/32 at the tip (23715): after the recovery the heap's
buffer keeps its address, the buffer and both textures read the pages' bytes, a GPU fill reaches the pages and the
texture over the buffer, and a new buffer and texture placed after it read the pages; the Private heap test's texture
is carried with lost contents and made resident by useHeap; the touched tests (heap, no_copy, aliasable, numbered,
placed) 167/167 one process each. Clippy plain, m2v_gpu, m2v_cpu_icd and rustdoc at 6f41668b95 (23706..23708).
REFUSALS and the signature table unchanged.
2026-11-12 18:32:14 -08:00
Anees Iqbal abf7dc879d Match the exportable carry test to the notice's texture counts
What: tests::device_recovery_exportable looks for " 1 textures over the
buffers carried,": the notice now goes on to count the textures placed in
the no-copy heaps carried after that count.

Why: the heap carry's notice change broke the test's match (lane
m3-max-23705: "1 textures over the buffers carried, 0 textures placed in
the no-copy heaps carried").

Verified: the lane that follows.
2026-11-12 18:31:39 -08:00
Anees Iqbal a52c30aff2 A recovery carries no-copy heaps and the textures placed in heaps
What: a heap over the caller's memory (new_heap_with_bytes_no_copy) is
carried as a no-copy buffer is: its own buffer made again over the same
pages (Buffer::carry_no_copy, now for a heap's own buffer too, kept among
no program resources; its pages keep what they were made of, a heap's own
included), its identity kept, the buffers placed in it carried at their
offsets (Buffer::carry_placed), their bytes as they are. The textures
placed in a carried heap, Private or no-copy, are made again there after
the heaps (Remake::Heap, Device::heap_texture_again): as the runtime's own
texture over the same range of the heap's bytes, through the making that
placed them (a texture buffer's buffer carried with carry_placed), sharing
the range's makeAliasable flag (HeapPlace::aliasable is an Arc), the range
handed to the newest image (HeapPlace::again, hand_range_to), so it is
given back once. A Private heap's texture reads as a new one, a no-copy
heap's reads the pages. The heap keeps its textures numbered as they were
(no forget_held); one the recovery leaves is forgotten (Numbered::forget,
Heap::forget_texture). A texture over a carried heap buffer is made again
over it, as over any carried buffer. Heap::carry answers what its bytes'
carry did with their contents and None where it was carried already, so
the notice counts no-copy heaps apart (", and N no-copy heaps with the M
buffers placed in them, over the same pages") and textures placed in
no-copy heaps apart ("N textures placed in the no-copy heaps carried"),
a Private heap's textures by storage mode. Docs: heap.rs, texture/carry.rs,
device/carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs,
API.md), the runtime README, and FAST-PATHS's known gap on lost texture
contents, which now names a Private heap's textures.

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

Verified: a check of the runtime's lib and tests under plain and
m2v_cpu_icd was clean (m3-max-23688, on a probe commit of this change);
the lane that follows runs the tests.
2026-11-12 18:31:39 -08:00
Anees Iqbal 16d01e402b Test that a recovery carries a no-copy heap with its buffer and texture
What: tests/device_recovery_no_copy_heap.rs makes a placement heap over a
private mapping (new_heap_with_bytes_no_copy) with a buffer at offset 0 and
an RGBA8Unorm texture placed after it, the pages' bytes set by the host
under each, then recovers: the notice counts one no-copy heap carried with
its buffer and one texture placed in the no-copy heaps carried, and leaves
no heap's buffer or texture refused; the heap, the buffer and the texture
are the new generation's, the buffer keeps its address, both read the
pages' bytes, a GPU fill of the buffer reaches the pages, and a buffer and
a texture placed in the heap after the recovery read the pages' bytes
there. The no-copy test file's helpers it reuses are pub(super).

Why: a recovery leaves a heap over the caller's memory and what is placed
in it the lost generation's, refused at their next use; reims's forced
recovery on a 3090 left 44 such heaps and 929 heaps' textures, and 46
placements in them answered nil after it. Metal keeps a heap and what is
placed in it.

Verified: the lane that follows runs it before and after the fix.
2026-11-12 18:31:39 -08:00
Anees Iqbal 6b5f4b19ed Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:29:30 -08:00
Anees Iqbal a6913f1065 SEMANTICS_VERSION 2072, ARTIFACT_FORMAT_VERSION 512, RUNTIME_VERSION 2175: a host step fans its rate-mapped draws out to the regions in one draw
The two commits before this one. A rate-mapped pass drew every draw once per region of the map's plan (2074 regions on
a 3648 by 1734 screen), so a guest frame's command buffer took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon
780M's. At a host step, under the default RateMapRegionPolicy::FanOut and where the device enables geometryShader,
shaderClipDistance and vertexPipelineStoresAndAtomics, the pass is probed first (the fan-out variant's geometry stage
writes a flag and a copy count per command and emits nothing); a command whose flag is clear is drawn once through the
fan-out variant over the whole target, a copy per region it touches; a flagged command, every command after a barrier,
after a memory-writing draw or at a mesh or patch draw is drawn region by region as before, and a refused fan-out
variant falls back to region by region. RateMapRegionPolicy::Exact (DevicePolicy::exact_answers()) keeps every draw
region by region. FAST-PATHS row and known gap (the encoder's own draws and the draws commit records stay region by
region), API.md bullet, WorkCounts for probes, flagged and fanned-out draws and probe GPU time. The pieces lane runs
both policies, its commit frame over a named range.

Verified (on the branch, release, --cfg m2v_gpu): the runtime's rate_mapped tests pass on the 780M (m3-max-23637), the
Iris Xe and lavapipe (at e55e6ebd01, the same code but the lane), the fan-out test counting one probe, one flagged draw
and six fanned out with pixels equal to the region-by-region draws; the pieces lane's host-step frame 87 ms fanned out
against 300 ms Exact on the 780M (23637; commit 284 ms in 20 pieces), 111 ms against 514 ms on the Iris (probe 1.1
ms). Clippy with --cfg m2v_gpu over translator, runtime and validation (23638), rustdoc, the API reference check, the
surface, signature and fast-paths tests.
2026-11-12 18:28:51 -08:00
Anees Iqbal b817cd5037 Pieces lane: frames at both region policies, the commit frame over a named range
The lane now runs the host-step frame under `RateMapRegionPolicy::FanOut` (checked for its probe
and fanned-out draws) and under `Exact` (`rate_mapped_pieces_host_step_exact`, checked for pieces
and ranges), and prints the probes, the flagged and fanned-out draws and the probe's GPU time.

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

Verified: at e55e6ebd01 the host-step frames passed on an Iris Xe and a Radeon 780M (Mesa 26.2.6)
and the commit frame failed as described (one probe, 64 draws fanned out); the commit frame's fix
is checked on both devices at this commit.
2026-11-12 18:28:20 -08:00
Anees Iqbal 257b77bc21 Fan a host step's rate-mapped draws out to the regions in one draw
A rate-mapped pass drew every draw once per region of the map's plan: an executed command's
triangles ran their vertex function 2074 times on a 3648 by 1734 screen's plan, and the command
buffer of a guest frame's shape took 514 ms of an Iris Xe's GPU and 462 ms of a Radeon 780M's.

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

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

Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto aacde9f2ad, which applied
cleanly): the runtime's `rate_mapped` tests pass on an Iris Xe and a Radeon 780M (Mesa 26.2.6) and
on lavapipe, the fan-out test counting one probe, one flagged draw and six fanned out with pixels
equal to the region-by-region draw's; the pieces lane's host-step frame takes 111 ms of the Iris
Xe's GPU fanned out against 514 ms under Exact, 125 ms against 462 ms on the 780M, the probe 1.1
ms and 0.5 ms. Clippy, rustdoc, the API reference check, the surface and signature tests and the
fast-paths tests pass; the golden table's changed cells are development's drift, re-blessed there.
2026-11-12 18:28:19 -08:00
Anees Iqbal cb2d3f77b2 SEMANTICS_VERSION 2071: a matmul2d run of the _v2 form without scale factors or static extents is the earlier form's run
The five commits before this one. macOS 27's MSL 4.1 headers spell matmul2d's runs in a _v2 form whose tensor operands
carry a scale type, block sizes and static extents; every such run was refused ("a matmul2d run of the single-thread
or v2 form"), among them the 12 MPS rows of the macOS 27 census. Run::of_call now takes a _v2 run whose operands have
scale type __tensor_ops_datatype_invalid (0), block sizes 0 and both static extents dynamic_extent (-1) as the earlier
form's run; scale factors and a static extent are refused with their own messages, the single-thread form alone as
before. New owned fixture tns_mm_v2 (tns_mm_float built for macOS 27, variants 10-15 a transposed B as a cooperative
right input and in threadgroup memory), nine authored cases over it (float, half, bfloat x B in device memory, as a
cooperative right input, in threadgroup memory) and their Metal rows on the M3 Max (macOS 27.0.1). The _v2 helpers
are crate-private; the API tables are unchanged.

Verified (on the branch): the engine v2 tests refuse before the change and engine_matmul2d, tensor_ops and matmul2d
pass 30/30 after (m3-max-23486); on Metal the three B placements give identical bytes within each element type, equal
to tns_mm_float's nt-right-device case on the same Mac (23519); lavapipe candidate 18/18 Match over the 9 cases and
both legs at the stacked tree (23671); translator suites 4070/4074 at 57b4ac923c, the 4 re-bless items only (the
inventory's new fixture, 38 golden cells of SEMANTICS_VERSION 2070's two kernels, part_5_of_8's same cells plus the
new row, ok on all 19 profiles, and the new printout, recorded under LLVM 21 on development); validation 1387/1387;
fmt, clippy all features, m2v_gpu, m2v_cpu_icd and rustdoc (23553, 23555). A release census of the 12 MPS rows (RDNA3,
23502, before SEMANTICS_VERSION 2069): all 12 now stop at LinkedFunction (a pipeline input the command line cannot
supply), the matmul2d expansion passing on every row; not re-run at this tip. The venues have no rows yet for the nine
new cases.
2026-11-12 18:22:08 -08:00
Anees Iqbal c7110e2c6c tensor_ops: the _v2 argument helpers are the crate's own
NO_SCALE, DYNAMIC_EXTENT and RunForm::v2_tensor_args serve only the matmul2d lowering in this
crate, so they are pub(crate) and the public API (api_surface, api_signatures) stays as it was
(both tables failed on the public items, m3-max-23554).
2026-11-12 18:21:40 -08:00
Anees Iqbal a53a644db4 Metal observations: the nine tns_mm_v2 cases on the M3 Max (macOS 27.0.1)
corpus-metal at cf48013638 (m3-max-23519), three runs each. Each element type's three cases
(B in device memory, as a cooperative right input, in threadgroup memory) answer the same
bytes, and those are the bytes tns_mm_float's nt-right-device case of that type answers on the
same Mac: Metal's _v2 runs compute what its earlier runs do.
2026-11-12 18:21:40 -08:00
Anees Iqbal 19b7bc198c Authored cases: matmul2d's float sums through tns_mm_v2's _v2 runs
Nine cases, tns_mm_float's three nt-right-device cases (float, half, bfloat) on tns_mm_v2, each
with B in device memory, as a cooperative right input (variants 10 to 12) and in threadgroup
memory (13 to 15): the same buffers and tiles, so each answers the same sums. Installed through
corpus-case-check --install (m3-max-23490).
2026-11-12 18:21:39 -08:00
Anees Iqbal b6bc78412d matmul2d: a _v2 run without scale factors or static extents is the earlier form's run
A _v2 run passes, after each tensor operand's descriptor type, its scale type
(__tensor_ops_datatype_invalid without tensor_plane_scales), the scale factors' two block sizes
(0 without) and the tensor's two static extents (get_static_extent, dynamic_extent passed as
the int -1 for a dynamic one). With no scale factors and only dynamic extents the operand is the
earlier form's: the descriptor object and descriptor type are the same, so Run::of_call takes it
as that run. A scale or a static extent stays refused, each by name, and so does the
single-thread form, now named alone.
2026-11-12 18:21:39 -08:00
Anees Iqbal d749f63850 tns_mm_v2 fixture: tns_mm_float built for macOS 27, its runs in the _v2 form
The header spells every matmul2d run in its _v2 form for a deployment target of 27.0: after
each tensor operand's descriptor type come its scale type, its scale factors' two block sizes
and its two static extents. tns_mm_v2 is tns_mm_float compiled for macOS 27 (MSL 4.1), with
variants 10 to 15 adding a transposed B as a cooperative right input and in threadgroup memory,
the forms macOS 27's quantized matmul kernels run. engine_matmul2d's fused-sum test runs it on
the three profiles against the same reference.
2026-11-12 18:21:39 -08:00
Anees Iqbal 87e88c0706 oracle_fuel: the status atomics take the form of the module's AIR version
What: the fuel transform reads the module's !air.version and, from AIR 2.9 on, declares and
calls the status load, add and or with the mem_flags i32 between the scope and the volatile flag
(0, no flags, as a relaxed atomic passes): `i32 (i32 addrspace(1)*, i32, i32, i32, i1)` for the
load. A module that states AIR 2.8 or earlier, or no version, keeps the form it had.

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

Verified, one run each:
- oracle_fuel's tests, 80 of 80, among them the new
  the_status_atomics_take_the_form_of_the_modules_air_version (no version, 2.8 and 2.9: the
  declarations' forms, and every call's operand count equal to its declaration's)
  (m3-max-23527, the same patch on the Tensors branch).
- The nine tns_mm_v2 cases on the M3 Max (macOS 27.0.1): refused by metal-opt before
  (m3-max-23501), all qualified after (m3-max-23519).
- fmt, clippy (all features, --cfg m2v_gpu, --cfg m2v_cpu_icd) and rustdoc over the Tensors
  branch that carries this patch (m3-max-23553).
2026-11-12 18:20:12 -08:00
Anees Iqbal 9c68983869 SEMANTICS_VERSION 2070: a GEP over a base not reached yet is not reached either
The commit before this one. Since the alignment lattice (SEMANTICS_VERSION 2069), the provenance GEP fact over a base
not yet reached (PtrFact::BOTTOM) took its indices' alignment, so it differed from BOTTOM in `align` alone, with no
roots, range or shape; every check that skips an unreached operand compares the whole fact with BOTTOM (the store
pass, the load transfer, the zero fills), so a pointer with no roots passed as reached. generic_pointers'
generic_captured and generic_functor (SEMANTICS_VERSION 2068) were refused at lowering on every profile on the merged
tree (Lowering(Access) at the store of &local[0] into refs.b; DereferenceLoadedPointer without int64 or a device
address), where they translated before the lattice. The GEP now returns BOTTOM for a BOTTOM base, after the
displacement walk refuses what it cannot size, as before the lattice.

Verified (on the branch): at development aacde9f2ad engine_generic_pointers fails (lavapipe generic_captured:
Lowering(Access), block 0, instruction 15) and the inventory refuses both rows on every profile (m3-max-23579); at the
fix engine_generic_pointers, the 8 public_fixtures_engine parts, engine_access (SEMANTICS_VERSION 2069's placement test
included), engine_copy and memory 141/142 (23616), the one the engine inventory part whose only difference is the two
rows now ok in all 19 cells (re-blessed on development); runtime_lane::generic_pointers 2/2 on lavapipe, the M3's words
(23639); golden_hashes lists the same cells with and without the fix (23640). fmt, clippy all features, rustdoc
(23646).
2026-11-12 18:16:10 -08:00
Anees Iqbal 4bcc5b752b provenance: a GEP over a base not reached yet is not reached either
Since the alignment lattice (786bae34a5), a GEP's fact over an unreached base (PtrFact::BOTTOM)
took the indices' alignment, min(cap, gep_twos), and so differed from BOTTOM in align alone
while its roots, range and shape were empty. Every check that skips an operand not reached
compares with BOTTOM whole (the store pass, the load transfer, the zero fills), so such a
pointer passed for reached with no roots. generic_pointers' generic_captured and
generic_functor, whose lambda and functor objects hold thread pointers, stopped translating on
every profile (Unsupported{Lowering(Access); NotImplemented}, and DereferenceLoadedPointer on
the profiles without int64 or a device address), where they translated at 88e6e2bce2. The GEP
now returns BOTTOM for a BOTTOM base, after the displacement walk refuses what it cannot size,
as it did before the lattice.
2026-11-12 18:15:43 -08:00
Anees Iqbal 182a32bba7 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:13:07 -08:00
Anees Iqbal 0f400463bf Say the device handle is owned, as Metal's device answers a retained one
What: the 14 device() accessors that answer an owned handle say so in
their docs, after Metal's retained device; the rest of each doc stands.

Why: the docs should name the change a caller sees (an owned Device where
a borrow was).

Verified: docs only; the lane and lint that follow build them.
2026-11-12 18:11:56 -08:00
Anees Iqbal 2b8b56617d An object a recovery carries answers the caller's own device handle
What: the public device() of every object whose borrow reached a handle a
recovery lets go of answers an owned Device, a clone of the generation
handle it read: Buffer, Texture, Heap, IndirectCommandBuffer, Event, Fence,
SamplerState, Library, Function, DepthStencilState, AddressPool,
DynamicLibrary, BinaryArchive and SharedTextureHandle (whose device is its
texture's). The runtime's own reads keep a borrow through a crate-private
generation() on the types they read it of (Buffer, Texture, Heap,
IndirectCommandBuffer, SamplerState, Function, BinaryArchive): 301 call
sites, so no hot path pays a clone. Each changed item's doc says the handle
is the caller's and keeps its generation, VkDevice included, while held,
past a recovery that carries the object on; MadeOn's doc states that no
borrow of it reaches the program. The validation lane's four callers that
passed the borrow on take a reference of the handle. Signature table
re-blessed (14 rows).

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

Verified: the lane that follows runs tests::device_recovery_handles before
(it fails: one live VkDevice while the borrow is held) and after the fix;
a workspace check of the accessor change was clean under the plain cfg and
found the four validation callers under m2v_gpu and m2v_cpu_icd (job
m3-max-23584 on a probe commit).
2026-11-12 18:11:56 -08:00
Anees Iqbal e71c688a26 Test that a device handle an object answered outlives a recovery's rest
What: tests/device_recovery_handles.rs holds the device a fence, a
sampler state, a Private buffer and an event answer, each made before a
recovery, across that recovery and the lost generation's rest, then uses
it: the lost VkDevice lives while the handle is held (two live VkDevices),
the handle names a generation that serves no more and its new_buffer goes
to the one serving, and the lost VkDevice goes once the handle is let go.

Why: each answers a borrow of the object's own handle of its generation
(device/carry.rs's MadeOn, through LineDevice for a fence and a sampler
state), which the recovery lets go of at the lost generation's rest while
the object lives: safe code holding the borrow across the rest reads a
dropped Device. The test fails before the fix at its first check (one
live VkDevice: the borrow keeps nothing), before it touches the borrow.

Verified: the lane that follows runs it before and after the fix.
2026-11-12 18:11:55 -08:00
Anees Iqbal 96f5c16298 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 18:04:18 -08:00
Anees Iqbal 3c98c7f6ee RUNTIME_VERSION 2174: a recovery carries Private exportable buffers over their own memory
The three commits before this one. After a device recovery a Private buffer in exportable memory was left refused
(MadeBeforeRecovery), failing, for example, a video session's frames over device caches that VA-API decodes into. The
recovery now exports the lost block's payload once from the lost VkDevice (vkGetMemoryFdKHR, which the spec lets a
lost device answer), keeps that descriptor on the block, and the new VkDevice imports a clone of it once for every
buffer carried from the block, as memory of the block's own type and size (dedicated where the lost block was a
dma-buf's dedicated allocation), binding each buffer at its offset. The buffer is not cleared: another API's import may
reach the same memory, so it keeps whatever the memory holds (the documented exception to the Private-reads-zero
rule). Its exports, and a texture image over it, answer the kept descriptor's clone, so textures over it carry as
over any carried buffer. Left refused: Shared and Managed exportable buffers (their contents pointer is the lost
mapping) and an opaque descriptor's dedicated allocation, a new left kind in the notice (Left::DedicatedOpaqueFd:
Vulkan does not define VUID-VkMemoryDedicatedAllocateInfo-buffer-01879's identical buffer across devices). Docs:
exported_memory.rs, carry.rs, buffer.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md),
error.rs, the runtime README.

Verified (on the branch): lavapipe m3-max-23522, the test fails before the fix (the notice left "2 buffers in
exportable memory, 1 textures over the buffers left"); at the test fix 0dda2df1ff device_recovery 30/30 on lavapipe
(23574) and on the 780M RADV (23583), OpaqueFd and DmaBuf both carried with the export after the recovery matching the
one before (64 MiB, offset 0, same memory type, same inode); the touched tests one process each 208/208 (lavapipe,
23522) and the export, dma_buf and handed tests 88/88 on the 780M (23552). Clippy plain, m2v_gpu, m2v_cpu_icd and
rustdoc at a8d9a42934 (23523..23525). REFUSALS unchanged.
2026-11-12 18:03:22 -08:00
Anees Iqbal f39f31edb9 Check the exportable carry by what the notice leaves, not a buffer count
What: the exportable carry test checks that the recovery's notice leaves no
buffer in exportable memory (nor in a dedicated opaque-fd allocation)
refused and counts its texture among those over carried buffers, in place
of counting one buffer carried with its contents; the export after the
recovery still checks the buffer's memory.

Why: the buffers carried with their contents counted two on lavapipe and
the 780M (lanes m3-max-23522, m3-max-23552): another buffer the test made
(a read buffer let go of, as far as the test can tell) was among them, so
the count is not the test's to fix.

Verified: the lane that follows.
2026-11-12 18:02:50 -08:00
Anees Iqbal e6124818d9 A recovery carries Private exportable buffers over their own memory
What: Buffer::carry takes a Private buffer in exportable memory (no host
copy) to the new generation over its block's payload imported again
(Device::buffer_in_carried_export, memory::place_carried_export): the lost
block is exported once from the lost VkDevice (memory::carried_payload,
vkGetMemoryFdKHR, which the spec lets a lost device answer) and that
descriptor is kept on the block (Block::payload); the new VkDevice imports
a clone of it (Handed) once for every buffer carried from the block, as
memory of the block's own type and allocation size with the device-address
flag of the device's blocks, dedicated to the buffer where the lost block
was a dma-buf's dedicated allocation, and binds each buffer at its offset.
The buffer is not cleared: another API's import (VA-API) reaches the same
memory and may be writing it, so it keeps whatever the memory holds, counted
among the buffers carried with their contents. Its exports after the
recovery answer a clone of the kept descriptor, and so does the dma-buf a
texture's image over it imports (ExportedTexels::payload), so textures over
it carry as over any carried buffer. Left refused: Shared and Managed
exportable buffers (their contents pointer is the lost mapping), and an
opaque descriptor's dedicated allocation, a new kind in the notice
(Left::DedicatedOpaqueFd: VUID-VkMemoryDedicatedAllocateInfo-buffer-01879
names a buffer identical to the payload's, which Vulkan does not define
across devices). Docs: exported_memory.rs, device/carry.rs, buffer.rs,
MadeBeforeRecovery, the device-recovered cost (degradation.rs, API.md) and
the runtime README, with the exception to the Private-reads-zero rule.

Why: reims's NV12/P010 device caches are Private exportable buffers
(STORAGE_PRIVATE in surface_cache.rs and vaapi.rs, read-only check) that
VA-API decodes into; a recovery left them refused, failing a video
session's frames, where Metal keeps the buffer.

Verified: the lane that follows runs the test before and after on lavapipe;
REFUSALS.md regenerated (no change).
2026-11-12 18:02:50 -08:00
Anees Iqbal 60b41a14a1 Test that a recovery carries a Private exportable buffer over its own memory
What: device_recovery_exportable::a_recovery_carries_a_private_exportable_buffer_over_its_own_memory
makes, for each handle type the device exports (an opaque descriptor, a
dma-buf), a Private exportable buffer with an RGBA8Unorm texture over it,
fills it and reads the fill back through the texture, exports it, and
recovers the device. It checks that the notice counts the buffer among
those carried with their contents and the texture among those over carried
buffers, that an export after the recovery answers the same allocation
size, offset, memory type and file (inode) as before, and that a fill on
the new VkDevice reads back through the texture.

Why: a recovery leaves every exportable buffer refused (Left::Exported,
MadeBeforeRecovery), where Metal keeps the buffer; a consumer's video
decode writes such buffers through another API's import of their memory.

Verified: runs in the lane with the fix that follows.
2026-11-12 18:02:50 -08:00