Commit Graph
925 Commits
Author SHA1 Message Date
Anees Iqbal 3a3c2fb3fd The encoder trail names each host-stepped draw's route, and the pipeline pool at a stall
For the 3090 hang, where a shadow pass's host step and a rate-mapped pass's fan-out ran in the
same second: the trail now counts, per host step, the route each draw took (plain, the fan-out
probe, fanned out, region by region) and the executions recorded in their GPU form, and its stall
line names the device's pipeline pool's makings waiting and under way, so a driver compile
running beside a hung batch shows. Default off.

Verified: encoder_trail::tests and tests::stall (the line names the pool) in the check job.
2026-11-12 21:41:04 -08:00
Anees Iqbal abacc1222e The encoder trail names what a host step drew: ranges read, draws, the largest, kept chunks
A stalled host-stepped render encoder's trail line named its states but not what its step
recorded from the records and range buffers the GPU wrote, which is where a wrong count would
come from. With the trail on, a host step now notes each range it read from a buffer (location and
length as the bytes held them, and the commands it ran), its draws, their vertices or indices
times instances summed, the draw of the most of those (primitive type, count, instances), and the
kept chunks it ran again, whose draws it did not read. Default off: nothing is read or formatted
with the trail off.

Verified: the trail unit test (encoder_trail::tests) covers the line's new part.
2026-11-12 21:41:04 -08:00
Anees Iqbal 7093ca7911 A new Private texture whose first use writes every texel first takes no zeros
What: a new zero-filled Private texture's first move is marked overwritable
(FirstMove::mark_overwritable). An encoder notes each such texture it writes
whole before any of its commands reads it, decided from its own description,
never a shader's (encoder::Overwrite, on its first part):
- a render pass that loads every aspect of it Clear (as the descriptor set
  it, before DontCare loads take clears) and stores it, rendering it itself
  (no stand-in, sample planes or separate depth and stencil scratch) over its
  whole extent, the image of one level and one layer
  (PassLayout::overwrites);
- a blit command whose box covers its whole extent in every aspect
  (BlitCommandEncoder::scrub).
At a batch's take (command_buffer/submit.rs, first_overwrites), an
overwrite counts where its part has no segment, only blit parts with no
segment that name nothing of the image come before it (any other encoder may
reach a texture through its resource ID, unnamed), and the part's own uses
read nothing of the image but its attachment's own reads (a pass) or
nothing at all (a blit). FirstMoves::take_holding then takes that move
without its zeros (unzeroed, undone if the submission is given back): the
layout move stays, and batches on other VkQueues wait for this batch as for
any first work. A part that runs nothing drops its overwrites (fail_part).
DontCare and Load first uses, and partial writes, keep the zeros. Counted:
WorkCounts::private_textures_overwritten_unfilled (new public field,
signatures re-blessed); the runtime README and docs/API.md say so.
tests::first_overwrite checks both paths (whole pass, depth pass, whole
copy, a recycled image's clear; DontCare, Load, a partial copy, a clear after
another pass) and first_overwrite_costs (ignored) prints OVERWRITE-COST,
for textures made together before the first commit (the first submission
takes every waiting first move, so only its own texture goes unzeroed) and
for textures each made just before its own command buffer (every one does).

Why: the zeros are for isolation only (main's plan for pin 64): a first use
that writes every texel before anything reads one never shows them, and
they cost the Iris Xe up to 0.22 ms a 2048² depth texture (job 24088).

Verified: before this replay onto development, at 9ab0b01426 (on a67e1e3d55):
the validation lanes touching first moves, recycling, clear reach, resolves,
blits and heaps on lavapipe (job 24205, 358 passed); on the Iris Xe (job
24218) tests::first_overwrite, memoryless_fresh and recycle (9 passed;
FIRST-OVERWRITE whole: 1 each) and OVERWRITE-COST zeroed against skipped:
made together, 8 RGBA8 1024² 2.136 against 2.100 ms median, 2 Depth32Float
2048² 1.693 against 1.487 ms, one texture a burst unzeroed. At this commit,
tests::first_overwrite and the runtime suite on lavapipe, clippy (plain and
m2v_gpu) and rustdoc, and the each-made-before cost on the Iris, reported
with this sha.
2026-11-12 21:32:27 -08:00
Anees Iqbal 5877117603 A device's recovery carries its rasterization rate maps
A rate map held its device as the generation handle it was made on. After
a recovery from the loss of the VkDevice, a render pass over a map made
before it met that handle in its descriptor's check (rate_mapped_pass.rs
check_descriptor: map.device().same(device)) and was refused,
NotImplemented(MadeBeforeRecovery), at every encoder, as Metal's map goes
on: a consumer's offscreen pass was refused every frame after a real
recovery on an RTX 3090, the pass's 938 textures carried.

A map holds no Vulkan object, so it now holds its device as a fence or a
depth/stencil state does (LineDevice): the recovery carries the handle, a
pass's and a copy's checks match its root handle by its line, and its
reads (the zero-layer notice, a reset's registry of command buffers to
encode again) take the generation it was carried to last. Its public
device() answers that generation's handle, owned, as the other such
objects' do (it answered a borrow). The recovery also carries the
device's note that a map of layers was released, which a later map of no
layers reads.

The device test a_rasterization_rate_map_goes_on_past_a_recovery encodes
a pass over a map made before a recovery, commits it and waits for it to
complete, copies the map's parameter data into a buffer of the next
generation and resets the map; an_objects_device_keeps_meaning_its_
generation_past_a_recovery takes the map's device among the others'. The
recovery notice's, the refusal's, the README's and docs/API.md's lists of
what a recovery carries name the maps.
2026-11-12 21:25:03 -08:00
Anees Iqbal 5eb107ac89 A new Private texture reads zero on every device: never the bytes its memory held
What: new_texture_image starts a Private texture zeroed (Start::Zero) on a
device that presents an Intel or AMD Mac, as it did on an Apple GPU presenting
one: its first move clears it, or copies zeros, or takes the driver's zeros
where the block is fresh. Only a Memoryless texture starts held.
private_textures_zero_filled counts each. WorkCounts::private_textures_unfilled
goes, as nothing counts it now.
- The recycled image a new texture takes (recycle.rs) and a recovery's remade
  texture (texture/carry.rs, Remake::Own through texture_as) go through the
  same making, so both read zero.
- Tests: mac_class (an Intel or AMD Mac's new texture reads zero, counted as
  zero-filled); the parent's recycle test.
- Lanes: fresh_contents and fresh_costs expect zeros there, counted.
- Docs: API.md's accepted difference, the runtime README, MacClass::IntelOrAmd,
  conformance's without_compression.
- api_signatures re-blessed (the field goes).

Why: Start::Held matched a Mac with an Intel or AMD GPU, where a new Private
texture can read a released texture's texels. On such a Mac those texels are
the same process's. A consumer that serves several processes from one device
showed one process another's pixels that way. The 780M read a released
texture's colour through a recycled image (m3-max-23995). After a forced
recovery on the RX 7900 XTX, a guest window read other windows' pixels. Zero is
what those Macs read where their memory held nothing, and Metal leaves the
contents undefined.

Verified: the lane run reported with this sha (the recycle test of the commit
before fails on lavapipe, the 780M and the XTX; this one passes).
2026-11-12 20:36:13 -08:00
Anees Iqbal b95bd50ae6 The encoder trail's API.md paragraph: the stall probe and the watchdog count as without it
Rewrapped after the rebase onto the watchdog (b6c52f1fa9); says the trail's line comes before
the stall probe and the watchdog, which count with the trail on as without.
2026-11-12 20:33:17 -08:00
Anees Iqbal efcb6851ce The encoder trail: name the encoder a stalled GPU stopped in, and the last one that completed
A GPU hang (a CTX SWITCH TIMEOUT on an RTX 3090) left the runtime with no way to say which
encoder never completed: encoders share batches and grouped submissions, and neither
METAL2VULKAN_LOG_PASSES nor METAL2VULKAN_QUEUE_TIMES logs anything at a stall.

METAL2VULKAN_ENCODER_TRAIL (env_vars.rs), or DeviceOptions::encoder_trail for one device, is a
default-off diagnostic (encoder_trail.rs):

- Each encoder, and each part of one a host step splits off, ends its batch (Batches::alone),
  and no batch waits in a group, so each goes in a vkQueueSubmit of its own that signals its
  queue's timeline. When work goes to the driver changes; what it computes does not.
- Each encoder notes what it was: its kind, its command buffer's object ID, its place, a
  render pass's area, samples, attachments' formats and sizes, instances and rate map, its
  indirect command executions, and the label hash of each state it bound (the first 8 bytes
  of a SHA-256 of the state's label and its functions' names; no name, no shader text). A host
  step adds the states its indirect commands named, as the GPU and the CPU left the records.
- Once no work of the device advanced for 2 s with some pending, completion.rs's stall path
  logs one Info line (id name metal2vulkan-encoder-trail) for each VkQueue whose oldest batch
  is pending: that batch's encoders and the last batch the queue completed, with how long
  before; once a stall.
- A submission a host step makes and waits for itself (a rasterization-rate map's fan-out
  probe, a predicated loop's check run again) signals no timeline; once it ran 2 s, one line
  names it, the encoder whose step made it and the states its commands named.

Off, a device reads the switch once and notes nothing.

Verified on msi (lavapipe, --cfg m2v_cpu_icd), at the branch tip this commit's tree equals:
- tests::stall::the_encoder_trail_names_the_stuck_encoder_and_the_last_one_completed: a cb
  stuck on an event wait before two blit fills; the line names the stuck cb's encoder 0 (not
  its encoder 1) and the earlier completed cb's encoder 0:
  "VkQueue 0's oldest pending batch: Blit encoder 0 of command buffer 3, states []; the last
  batch it completed: Blit encoder 0 of command buffer 2, states [] (2.106823047s before)".
- tests::rate_mapped_fan_out::the_encoder_trail_fans_out_the_same_pixels: with the trail on,
  probes/flagged/fanned [1, 1, 6] as without, no texel differs from the encoder's own draws.
- The host-step families (rate_mapped_fan_out, rate_mapped_pieces,
  indirect_command_buffer_device, host_step_neutrals, ycbcr_in_place_loop) with
  METAL2VULKAN_ENCODER_TRAIL=1: 11 passed.
- encoder_trail's unit test (one state's hash pinned: a reader of the pipeline creation log
  computes it again); the runtime suite 1504 passed; api_ tests 16 passed; clippy all features
  and the runtime under m2v_gpu and m2v_cpu_icd; rustdoc of the runtime and metal2vulkan.

The runtime-sources pin moves (not re-pinned here).
2026-11-12 20:33:17 -08:00
Anees Iqbal d4ab197556 Metal's command-buffer watchdog: a front batch 20.2 s without its timeline advancing fails as Metal's timeout
reims's 3090 boot after an Xid 109 (CTX SWITCH TIMEOUT) had its graphics queue's batch never
complete while the copy engine ran on: the staging probe completed 23 times in under a
millisecond, so the stall rule found the GPU running and nothing failed. The probe stays; beside
it each queue's front batch now has its own clock (stall::Clock::front_held), which runs while
its waiter's waits run out with it pending and stops whenever its queue's timeline advances,
whatever the probe answers. Past stall::WATCHDOG (20.2 s, the x86 AMD Mac's measured bound and the
largest of Metal's) the front fails as Metal's timed-out command buffer (GpuHang, code 2, named
exactly: its queue is known, no inference), the rest in flight as GpuRecoveryVictim, and the
generation is marked stopped (Stop::Watchdog), parked and recovered from as a wedge; the notice
says the watchdog stopped it. Counted: WorkCounts::watchdog_timeouts (wedges_declared keeps the
unanswered probe's stops).

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

Tests (tests::stall): the stuck front with an answered probe fails at the hooks' 1 s bound, no
sooner, as GpuHang, parks the generation and runs the next command buffer; the answered leg
whose front advances within the hooks' 3 s fails nothing. Docs: stall.rs, revocation.rs,
docs/FAST-PATHS.md known gap, docs/API.md, the runtime README, WorkCounts, api_signatures.
2026-11-12 20:29:01 -08:00
Anees Iqbal c7362776d0 Let carried textures' and pipeline states' parts go at the lost generation's rest
What: a recovery's carried textures and pipeline states let go of their
parts on the lost generation once it comes to rest, as buffers already
did, so the lost VkDevice goes while they live.

- device/carry.rs: LetGo<T>, the let-go cell MadeOn was (MadeOn is now
  LetGo<Device>), and PartsCalls/CallHold, one guard generalised from the
  buffer's calls and HeldParts: a call outside command buffers' work counts
  itself, and a release at rest waits for the last call to end. Buffers
  use it unchanged in behaviour (Buffer::held_parts, LostBuffer,
  LostPlaced, LostHost).
- Pipeline states: StateShared.program and ProgramLink.program are LetGo
  cells. The carry hands the lost generation a LostProgram, which drops
  the state's program there in place at rest (its variants' objects,
  plans, makings and its Device). reached() skips programs let go of. The
  state keeps its own copy of its label, so label()'s borrow outlives the
  program. Holds: the public state methods that reach the program,
  program(), Debug, and the argument encoder's and indirect commands' set
  paths.
- Textures: TextureShared's per-generation parts (storage, moved,
  pending_move, usage_shadow(_making), faces, snapshot, kept_backings,
  render_shadow, facts, planes_in_place) move into Parts in a LetGo cell,
  read through Deref. The carry hands the lost generation a LostTexture.
  At rest it leaves the texture's slot in the lost generation's table and
  heap sets, hands the caller's range token to the parts on the next
  generation, and drops the parts in place. Parts with a handed-out VkImage
  (Texture::vk_image) stay until the texture goes. Texture::s() skips parts
  let go of. Holds: the public texture methods that reach parts, and
  vk_image; a view's hold holds its root texture too. slot_keeper names a
  texture buffer's generation by its texel views, not by the buffer's
  serving generation.
- WorkCounts::lost_programs_released and lost_textures_released, counted
  on the line.
- Public signatures: ComputePipelineState::device,
  RenderPipelineState::device, FunctionHandle::device and
  VisibleFunctionTable::device now answer an owned Device. The last two
  also borrowed from the state's program. Command-buffer paths use the
  crate-private borrowing generation(). api_signatures is blessed.
- Docs: the carry module docs (device, pipeline, texture), docs/API.md's
  recovery entry, the runtime README's recovery paragraph, vk_image's doc.
- Tests: the four recovery tests in 99dbc69666 also assert the counters.

Why: a carried texture kept its images on the lost generation, and a
carried state its program there, until the object went, so the lost
VkDevice lived as long as any of them. A long-lived program kept it for
good.

Verified: cargo check of the workspace, all targets and features, under
no cfg, m2v_gpu and m2v_cpu_icd, clean but for one validation call site
fixed here (jobs m3-max-23824, 23852). The lavapipe lane (the tests of
99dbc69666 before and after), the suite, lint and the 780M run follow.
2026-11-12 19:32:06 -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 64982ac827 A GPU that stops with no loss from the driver fails its work and is parked
On NVIDIA after an Xid 109 the device's queues stopped: no batch completed and
every completion wait answered VK_TIMEOUT, never VK_ERROR_DEVICE_LOST, so the
program's command buffers waited without end.

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

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

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

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

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

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

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

Verified (release, `--cfg m2v_gpu`, e55e6ebd01 before the rebase onto aacde9f2ad, which applied
cleanly): the runtime's `rate_mapped` tests pass on an Iris Xe and a Radeon 780M (Mesa 26.2.6) and
on lavapipe, the fan-out test counting one probe, one flagged draw and six fanned out with pixels
equal to the region-by-region draw's; the pieces lane's host-step frame takes 111 ms of the Iris
Xe's GPU fanned out against 514 ms under Exact, 125 ms against 462 ms on the 780M, the probe 1.1
ms and 0.5 ms. Clippy, rustdoc, the API reference check, the surface and signature tests and the
fast-paths tests pass; the golden table's changed cells are development's drift, re-blessed there.
2026-11-12 18:28:19 -08:00
Anees Iqbal 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 30ba489080 A recovery carries sampler states
What: a sampler state's device is a LineDevice the state's own carry links
(LineDevice::unkept, link_unkept). The recovery takes the generation's live
sampler states (Carry::sampler_state, Taken::samplers) and, first after the
handles, carries each (SamplerState::carry) where both generations compile
alike: its handle linked to the new generation's under its cache's lock, the
VkSamplers it kept forgotten, the state kept in the new generation's map of
live states (an equal request gets it) and placed in its heap sets and
sampler tables, then kept there for a later recovery. Its placement on the
lost generation is taken out at that generation's rest (LostPlacement).
SamplerState::vk_sampler takes the generation the bind writes for and makes
the sampler there, cached for the state's latest generation alone; for any
other generation it answers None, and the heap set, slot and argument-buffer
writes take the neutral sampler. The recovery's notice counts the states
carried (and any left, where the generations compile otherwise).
Docs: MadeBeforeRecovery, the device-recovered cost (degradation.rs and
API.md), the runtime README, device/carry.rs and sampler.rs. As main asked,
Device::recover_for_test's doc and line.rs's module doc now point at
device/carry.rs for the kinds carried instead of a stale list.

Why: a sampler state kept its lost generation, so every bind of it after a
recovery was refused (MadeBeforeRecovery) where Metal's goes on; and the
argument buffers' listing of live states is line-wide, so a draw or
dispatch of the new VkDevice made the listed state's VkSampler on the lost
VkDevice and wrote it into a descriptor set of the new one, a handle of
another device, which Vulkan does not allow.

Verified: the lane that follows runs the test before and after on
lavapipe; REFUSALS.md regenerated (no change).
2026-11-12 17:38:31 -08:00
Anees Iqbal 56a8aa5283 did_modify_range: a commit takes the ranges of the buffers its command buffer uses, copied in on its queue
What: Modified::take_at_commit takes, at a commit, only the noted ranges of the buffers the
command buffer may use (CommandBuffer::may_use: its encoders' uses name the buffer or made it
resident, a command may reach memory no use names, its last encoder's end is still with the
lowering thread, or nothing owns the buffer's key); the rest stay noted, in their order, for a
commit that uses them (managed.rs's Noted). Their copies in, and every other upload into a
buffer the program may have read (Buffer::upload, copy_in_from), register as uploads
(FirstMoves::register_upload, FirstFill::reached_only): a batch takes one only where its
commands may reach the buffer, on a device with a fill queue or without one, never because it
takes every other fill; an internal submission takes it too, and a batch that needs no GPU work
leaves it waiting. FillTake::Owned carries the batch's reach for that. So the copy lands on the
user's queue, after the command buffers before it there, before the commands of the first that
uses it: Metal's shape. Docs: managed.rs, managed_copy.rs (the 'as on Metal' line now says what
holds: only two queues' unordered uses of the buffer race the copy), first_move.rs, API.md, the
runtime README and FAST-PATHS.md's managed row.

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

Tests: managed.rs's take rule (a_commit_takes_the_noted_ranges_of_the_buffers_its_command_buffer_uses)
and first_move.rs's (an_upload_goes_only_with_a_batch_that_reaches_its_buffer), on every device;
the parent's named rounds on two queues and on one, on the RTX 3090 before and after (job ids in
the report). RUNTIME_VERSION wants a bump at landing.
2026-11-12 17:18:01 -08:00
Anees Iqbal 6b79a77730 A recovery carries drawing and mesh pipeline states
What: a drawing state (a mesh one, and a twin of a color group, a single-sample or a factor-scaling
state among them) keeps a chain of programs per generation as a compute state does
(pipeline/carry.rs): its StateShared Deref reaches the program of the generation whose command
buffer's work the thread does, else the last; its ID, uniqueIdentifier, label and sampler numbers
stay. Each state is kept by its generation's carry registry (GraphicsState::kept at the end of a
render or mesh creation, with its color groups' twins); the recovery carries them after the compute
states (pipeline/render/carry.rs): its base variant, and its large-buffer form's, made again from
the pipelines its creation compiled or the live variants of them the new generation holds, no
translation; then, under the new generation's reach (NoticesFor::of_generation), its neutrals, its
predicted first draw's VkPipeline handed to the pool with nothing waiting for it
(make_at_creation(false)), and its depth stand-in copies. Its descriptors, keys, label and twins are
kept; its other variants, plans, settles and routings are made as its draws need them. A failed
making is counted and refused where bound (RemadeAfterRecoveryFailed) through
RenderPipelineState::bound_device, at set_render_pipeline_state (encoder, call checks, indirect
command buffer) and an argument encoder's render word; a tile state's bind now answers its kernel's
failed making the same way. A state is made again only where both generations compile alike
(compiles_alike, the profile fingerprint the memo carry checked already); else its making is refused
as failed. Docs: device/carry.rs, pipeline/carry.rs, MadeBeforeRecovery (render states no longer
listed refused) and RemadeAfterRecoveryFailed, the DeviceRecovered cost (degradation.rs and API.md,
equal), API.md's recovery entry, the runtime README; REFUSALS.md regenerated.

Why: drawing states made before a recovery were refused where bound after it; Metal's go on.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes), with the recovery's wall time for 0, 200 compute and 200 drawing states.
2026-11-12 17:13:53 -08:00
Anees Iqbal 98db2b33e6 A recovery carries compute and tile pipeline states
What: a compute state (and so a tile state's kernel) keeps a chain of programs, one per
generation (pipeline/carry.rs): the state object, its ID, uniqueIdentifier, label and sampler
numbers stay, and its Deref reaches the program of the generation whose command buffer's work the
thread does, else the last. Each state is kept by its generation's carry registry; the recovery,
after the textures, makes its program again on the new generation: the base variant's objects
from the pipeline its creation compiled (Variant::of with the compiled pipeline, or the live
variant the new memo already holds), no translation, and the VkPipeline its creation predicted
queued on the making pool with no wait (make_predicted with waited false). The lost generation's
memo of compiled functions and pipelines is carried first where both generations' profile
fingerprints match (PipelineMemo::carry_from), so later variants and creations translate nothing
again. A state whose making there fails stays the lost generation's, is counted by the notice and
refused where bound with the new RuntimeGap::RemadeAfterRecoveryFailed (compute encoder,
argument encoder and indirect command buffer checks, through ComputePipelineState::bound_device).
The notice says how many states were made again and how many failed. An indirect command
buffer's depth/stencil check now matches the state by its line too, as the encoders' do since the
regression fix. Docs: carry.rs, MadeBeforeRecovery, the new gap, the DeviceRecovered cost
(degradation.rs and docs/API.md, equal), the runtime README; REFUSALS.md, reach.tsv and the API
signature table regenerated.

Why: compute and tile states made before a recovery were refused where bound after it; Metal's
go on.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes), with the recovery's wall time for 0 and 200 live states.
2026-11-12 16:45:38 -08:00
Anees Iqbal 85847d3941 A binary archive and a dynamic library go on past their device's recovery
What: a binary archive and a dynamic library hold their device as a LineDevice
(device/carry.rs), as a fence or a library does: device() answers the generation handle of the
generation they were made on, else of the one a recovery carried them to last, and the lost
generation's handle goes at its rest. A creation's archive check matches an archive by its
device's line (its root handle), so a creation of any generation lists an archive made before a
recovery; each add makes its state on the generation that serves (Device::at_serving through the
root handle), its used artifacts taken afresh for each run. Docs: both modules, carry.rs,
MadeBeforeRecovery, the DeviceRecovered cost (degradation.rs and docs/API.md, equal), the runtime
README. REFUSALS.md regenerated: unchanged.

Why: an archive made before a recovery refused its adds there (its creation ran on the lost
generation) and every creation that listed it (MadeBeforeRecovery), and both kinds held the lost
VkDevice while they lived; Metal's go on.

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes).
2026-11-12 16:35:28 -08:00
Anees Iqbal fb41ed11d9 Name the simdgroup kernels' one-row flat dispatch in the split-dispatch notice's entry 2026-11-12 16:29:20 -08:00
Anees Iqbal 9b308145e9 A texture buffer goes on over its carried texels; the notice counts lost textures by storage mode
What: Texture::carry makes a texture buffer of new_texture again over its texels' buffer where the
recovery carried that buffer (texture_buffer_over, the runtime's own ID use), so a Shared one
reads the bytes the buffer carry kept; where the buffer was left it is made new as before.
Remade splits the textures whose contents were lost by storage mode (Shared, Managed, Private or
memoryless), and the recovery's notice says those three counts. carry.rs says how kept bytes are
read: Vulkan makes the content of external memory imported to a lost device undefined (vkspec
5.2.3), read as the hung work's writes possibly landing in part; once the lost import goes, the
pages are only our or the caller's memory. Docs: texture/carry.rs, carry.rs, the
DeviceRecovered cost (degradation.rs, docs/API.md, equal), the runtime README, and a known gap in
docs/FAST-PATHS.md: a recovery loses the contents of textures whose only copy is device memory
(new_texture of any storage mode), textures over carried pages keeping what their buffer keeps.

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

Verified: see the lane run reported with this sha (the test commit before it fails, this one
passes).
2026-11-12 16:27:36 -08:00
Anees Iqbal b564fb7a91 A recovery carries textures, their views and those over carried buffers
What: a device's recovery now carries the program's textures made by a call it can make
again (texture/carry.rs). That covers a texture of `Device::new_texture`, a texture over a
buffer the recovery carried (`Buffer::new_texture` and its kin), and a view of either.

- The call is made again on the new generation as the runtime's own texture, which takes no
  ID. That texture holds the program texture's parts there: `TextureShared::next`, with a
  `carried` flag.
- `Texture::s` picks the parts the work at hand reaches. Inside a command buffer's work it
  answers that generation's parts (`NoticesFor::generation`); elsewhere, those of the
  generation the texture was carried to last. The buffer carry picks its parts the same way.
- Every read of a per-generation field goes through it: `storage()` (the hub), facts, faces,
  usage shadows, storage forms, render shadows, snapshots, memoryless backings and planes in
  place.
- The texture object keeps its `ObjectId`, resource ID, label, parent and handles, and its
  purgeable state is copied across. Its ID's slot in the new generation's texture table and
  heap sets names its parts there (`heap_sets::place`), and leaving the slot walks every
  generation's parts.
- Each program texture is kept by its generation's carry registry as it is made
  (`Carry::texture`). The call that made it sets how to make it again (`Remake`) and carries
  it itself where the take came first (`Device::kept_texture`, `Carry::late_texture`).
- The carry runs inside a `NoticesFor::of_generation` scope for the new generation, so the
  buffer it remakes a texture over and a view's parent answer their parts there.
- Left refused, and counted by kind in the notice: a heap's texture or one over a heap's
  buffer, a texture over the caller's `VkImage`, a sparse or shareable texture, a texture over
  a buffer left, and their views.
- The notice adds ", and N textures whose contents were lost too (they read as new ones), M
  textures over the buffers carried and V texture views".

Known gap, documented in API.md, the README and device/carry.rs: a carried texture's images
on the lost generation, and so the lost `VkDevice`, stay until the texture goes. Letting them
go at the lost generation's rest needs a hold of the parts by each call outside command
buffers' work, as `Buffer::held_parts` does for buffers.

Why: render targets and display textures made before a recovery were refused
(`MadeBeforeRecovery`) where they met the new `VkDevice`, while Metal's go on.

Tests: device_recovery_carry's main test now leaves a `Shared` heap instead of a texture as the
object that keeps the lost `VkDevice`. Its held-parts test now expects the texture made by a
call that completed on the lost generation to be carried by its maker. Docs updated:
`MadeBeforeRecovery`, the device-recovered cost (degradation.rs and docs/API.md, kept equal),
the runtime README and the heap docs. docs/REFUSALS.md regenerated (`view` became `view_as`).

Verified: the lane run of the test commit before and this one after is reported with its sha.
2026-11-12 16:27:35 -08:00
Anees Iqbal b1d963289e The resident-set search is its loop alone, without 16 unrolled steps
Each resolve of a loaded pointer emitted 16 unrolled binary-search steps before the loop that
finished sets of more than 2^16 entries. RADV inlines every call of the search, so a module with
many loaded pointers paid the 16 steps at every site: on a curve-shading kernel with 1,065
searches, its creation on the 780M took 92.9 s and 8.4 GiB of compile memory.

The search now starts the loop from all N entries. A step halves the candidates whatever its
compare gives, so the trip count, ceil(log2 N), depends on N alone: every invocation that
searches one table takes the same branches, and a set below 2^16 entries does fewer entry loads
than the 16 steps did (they kept loading after one candidate was left). search_step is the loop's
step; search_rest is now bisect, from (0, N). SEARCH_STEPS is gone, SEARCH_WORDS charges one step
plus the loop, and the docs (roots.rs, API.md) and the tests that named the unrolled reach say
what is true now. The handle-table search keeps its own unrolled steps. Answers are unchanged.

Measured on the 780M (RADV PHOENIX), before (1125fb62d2) and after, one job (m3-max-23016), one
run each:

The curve-shading kernel's creation (pipeline cache off, RADV_DEBUG=shaderstats):
  time in the driver   92.9 s -> 62.6 s
  peak RSS             8,462 -> 5,846 MiB
  ACO instructions     1,741,690 -> 1,000,747
  spilled VGPRs        179,037 -> 105,970
  spilled SGPRs        95,824 -> 46,562

GPU time of a dispatch whose 262,144 threads each resolve 64 loaded pointers, over M buffers made
resident, every lane's address the same (uniform) or its own (divergent); median of 15 commits,
every thread's sum checked (0 wrong in every row):
  M        form       before      after
  16       uniform    5.56 ms     4.02 ms   -28%
  16       divergent  4.61 ms     4.03 ms   -13%
  1,024    uniform    5.58 ms     6.52 ms   +17%
  1,024    divergent  8.37 ms     7.84 ms    -6%
  66,048   uniform    7.86 ms     9.04 ms   +15%
  66,048   divergent  92.4 ms     95.8 ms    +4% (ranges overlap)
Uniform addresses over sets of 1,024 entries or more cost 15-17% more GPU time: the loop's exit
test and back branch at each step cost more there than the unrolled chain's extra steps.
2026-11-12 16:12:29 -08:00
Anees Iqbal a610b58b8a A replayed draw whose making outlasts the commit's bound leaves its pass to the host step
The last draw dropped for its making's time: a draw of an execution's replay at commit (render
commands the CPU writes) whose pipeline the replay began itself and that was still being made at
the command buffer's bound recorded nothing. Metal cannot encode a draw before its pipeline
exists, so every encoded draw runs.

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

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

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

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

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

Tests (device, rewritten): a draw, a replayed draw and a dispatch whose
makings are held past the bound each complete once the making lands,
drawn or written, nothing dropped, while another queue's command buffer
completes meanwhile and the held one is still not complete a second past
its bound.
2026-11-12 15:41:59 -08:00
Anees Iqbal 3c88a7df60 An address pool goes on past its device's recovery
What: `AddressPool` holds a root handle of its device (`Device::root`) and the device's
address space, instead of a handle of the generation it was reserved on. A buffer placed in
one of its slots after a recovery passes the same-device check (`Device::same` answers a root
and any generation of its line alike), and the pool's drop gives its span back to the address
space, which every generation shares, without reaching a generation.

Why: a consumer found that after a recovery every new buffer in a slot of a pool reserved
before it was refused (`MadeBeforeRecovery`), which refused all of its buffers under 16 KiB.
A pool holds no Vulkan object and no memory: it is a span of the line's address space
(`AddressSpace::reserve_pool`), and a buffer in a slot takes its own memory as any buffer
does, only its Metal address from the slot. Holding a generation handle also kept the lost
`VkDevice` alive while the pool lived.

Docs: the recovery lists in `MadeBeforeRecovery`, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README and device/carry.rs name address pools; the pool's own
docs say it goes on. docs/REFUSALS.md regenerated with no change.

Verified: the lane run of the test commit before and this one after is reported with its sha.
2026-11-12 15:33:06 -08:00
Anees Iqbal 62923811dc A library and its functions go on past their device's recovery
What: a library holds a root handle of its device (Device::root) rather than the generation
it was made on, and its functions take that handle, as a fence does. A library is the
compile layer's parsed library and a function the compile layer's function with its
constants, no Vulkan object; their sampler-ID holds are the line's resource IDs, which every
generation shares. So a pipeline made from them on any generation passes its device check
(same matches a root handle by its line), and they no longer keep the lost VkDevice alive.
Docs: library.rs, carry.rs, MadeBeforeRecovery (libraries leave the refused list), the
device-recovered cost (degradation.rs and docs/API.md), the runtime README. REFUSALS.md
regenerated: unchanged.

Why: after a recovery a pipeline made from a library or function made before it was refused
NotImplemented(MadeBeforeRecovery); Metal's library goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:11:30 -08:00
Anees Iqbal fb7eaa8cbc A depth/stencil state goes on past its device's recovery
What: a depth/stencil state holds a root handle of its device (Device::root) rather than
the generation it was made on, as a fence does. The state is its descriptor and the compile
layer's Vulkan depth/stencil state, no Vulkan object, so a render encoder of any generation
accepts it (check_device matches a root handle by its line), and it no longer keeps the lost
VkDevice alive. gpu_resource_id asks supports_family, which goes to the serving generation,
instead of the "now" form a root handle has no generation for. Docs: depth_stencil.rs,
carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs and docs/API.md),
the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a recovery a state made before it was refused NotImplemented(MadeBeforeRecovery)
at set_depth_stencil_state; Metal's state goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:11:29 -08:00
Anees Iqbal e05beb832d A fence goes on past its device's recovery
What: a fence holds a root handle of its device (Device::root) rather than the generation
it was made on. A fence has no Vulkan object, only the key the tracker orders on, so
update_fence and wait_for_fence of any generation's encoder now accept a fence made before
a recovery (check_device matches a root handle by its line); an update made on a lost
generation went with that generation's work, so a wait on the next one finds none, as for a
fence never updated there. The fence no longer keeps the lost VkDevice alive. Docs: fence.rs
module and item docs, carry.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a 780M gfx ring timeout and a recovery, a guest's waitForFence: calls were
refused NotImplemented(MadeBeforeRecovery) about 2,000 times; Metal's fence goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 15:02:41 -08:00
Anees Iqbal b10839e2b2 A recovery carries Private heaps with the buffers placed in them
What: a device's recovery now carries each live heap to the new VkDevice (Heap::carry,
called from Device::carry_to after the buffers, or by a heap's maker where the recovery
took the generation first). A Private heap's own buffer is made again in new memory placed
where the heap's textures can lie (place_heap_buffer), zeroed as a carried Private buffer
is, keeping its ObjectId, hazard key, Metal address and range, range token, label and
purgeable state; the heap is registered by its key there and kept in the new generation's
registry for a later recovery. Each live buffer placed in it gets a new link on the new
generation (Buffer::carry_placed) at the same offset of the carried bytes, with the same
ObjectId, address, label and a shared aliasable flag; its old link lets go of its live-list
entry and device handle at the lost generation's rest (LostPlaced). A placed buffer's drop
gives an automatic heap's range back only from the link carried to last, so a carried
buffer frees its range once. A buffer placed while the heap is being carried carries itself
under the heap's placed lock. The heap's textures made before stay the lost generation's
(no recovery carries a texture); the heap forgets them (keeping their numbering), so a
use_heap on the new generation never makes an old image resident. Shared heaps (their bytes
are pooled host-visible memory, never the runtime's own pages), no-copy heaps and sparse
heaps stay left, with their buffers.

The recovery notice now counts carried heaps ("N `Private` heaps (B bytes) with the M
buffers placed in them") and left heaps by kind, and splits the old "buffers over the
caller's or exportable memory" into "buffers over the caller's `VkBuffer`" and "buffers in
exportable memory" (Left::Caller / Left::Exported). Docs: carry.rs module docs, the
Buffer::carry docs, heap.rs, MadeBeforeRecovery, the device-recovered cost (degradation.rs
and docs/API.md), the runtime README. REFUSALS.md regenerated: unchanged.

Why: after a GPU recovery a guest's MTLHeap newBufferWithLength:options:offset: was refused
NotImplemented(MadeBeforeRecovery) and the guest got nil; Metal's heap goes on.

Verified: see the lane run reported with this sha (the test commit before it fails, this
one passes).
2026-11-12 14:59:22 -08:00
Anees Iqbal da3cea7633 A heap texture's chosen constexpr samplers are one sampler array, not a switch
A heap texture sampled through one of several constexpr samplers that a
sampler handle names at run time (a table of constexpr samplers read at a
computed index) was a switch-at-use with one arm per candidate: each arm
its own heap sampling and raw-texel emulation. On large kernels that
multiplies the sampling code by the candidate count.

Where every candidate is a constexpr sampler, their handles are
consecutive, each candidate's sampling is the same but for its sampler
and the state its raw emulation follows, the use is not tangled, and the
device indexes a sampler array non-uniformly
(shaderSampledImageArrayNonUniformIndexing, which heap textures already
need), the sampling is now one sampling through a set-0 array of the
candidates' samplers (ResourceKind::SamplerArray,
BindingSource::SamplerArray): element handle - first, NonUniform, its
immutable samplers each made as the heap sampler of that candidate alone
would be (DescriptorBinding::immutable_samplers, listed per stage in
StageInterface::sampler_arrays). A handle outside the array reads zero,
as the switch's null arm. The raw emulation reads the element's sampler
word from a constant table at the same index (heap_raw::State::Table),
through the runtime-word path. Elsewhere the switch stays.

The runtime bakes one sampler per element into the set layout, pushes
each element's own sampler where set 0 is pushed, and keys the set-0
shape on them.

Tests: the array form on every profile with the sampled heap (one
sampled image, L3), the switch kept for non-consecutive handles, each
element equal to the immutable sampler of the candidate sampled alone and
never written by the plan, and a device test (lavapipe under
m2v_cpu_icd) that each lane reads what its sampler alone reads and what
the address modes define.

Docs: API.md section 5, the sampler module doc, api_signatures,
api_surface, REFUSALS regenerated.
2026-11-12 14:55:47 -08:00
Anees Iqbal bcfec16960 A rate-mapped draw skips the regions its viewport and render area leave no pixel
Each draw of a rate-mapped pass was recorded once per region of the map's plan, even where the
region's scissor, cut to the pixels whose centres lie in the guest's viewport and to the render
area, held no pixel. Such a recording shades nothing (the scissor test discards every fragment),
and its vertex function repeats nothing observable (a plan of several regions refuses a vertex
function that writes memory), so it is now left out. Where the cut leaves no region a pixel, the
first region alone is still recorded through its empty scissor, so the vertex function runs as
Metal's does. A draw whose viewport covers part of the screen now records only the regions it
reaches; one over the whole screen records what it did.

The new lane test draws the case's fullscreen triangle over a 256-pixel map at the falling
quality with a viewport over the screen's left quarter: fewer regions than the whole screen's,
from an indirect buffer region by region, and the direct (batched) draw shades bit for bit the
same pixels, inside the left half of the physical columns.
2026-11-12 14:37:06 -08:00
Anees Iqbal 1b1ebfd055 GPU times from the host start at the first submission that carried the work
A command buffer whose work went as several submissions (a wait for an
event the host signals, an execution its host step records) answered,
on a device made with gpu_times_from_host or a driver whose timestamps
wait for every queue's, the call of its LAST submission (its
kernelEndTime) as its GPUStartTime: its window missed the work of its
earlier submissions. Metal's GPUStartTime and GPUEndTime span the whole
command buffer's GPU work. A consumer that answers GPU times from the
host read windows of 0 to 240 ms on an Iris Xe for command buffers whose
kernel start to end spanned 2 to 8 s, each GPU start at the kernel end.

KernelTimes keeps the call of the first driver's submission that carried
a batch of the command buffer (the batch's own vkQueueSubmit, or its
group's), and the host-clock start is that call where it came before
the kernel end, else the kernel end as before, or the queue's latest GPU
end where later. A command buffer whose work went as one submission
answers as before. Devices that write timestamps already started at the
first batch's timestamp (lavapipe, job 22670: GPU start 173 ms before
the signal its second batch waited for).

Docs: gpu_time.rs (the host-clock bullet, rule 2), gpu_start_time,
DeviceOptions::gpu_times_from_host, the GpuTimesFromHost notice's cost
and its API.md entry.

Verified: pending lavapipe before and after, the 780M, lint.
2026-11-12 14:35:01 -08:00
Anees Iqbal 6014ad370d Faces: a logged pass turns, and an encoding again meets the faces as first met
While the device has a buffer over host pages, every render pass logs its calls for a rebind,
and a pass with a log, or with an earlier encoder of its command buffer keeping one, turned no
texture (Unturned::Pass): under a consumer that keeps host-page buffers alive, no attached read
ever took the turn and every one copied in.

A logged pass now turns as any other. A rebind's encoding again of the command buffer's encoders
meets the faces as their first encodings met them: the encoding again runs with a thread-local
context of the command buffer and the encoder's parts (with_faces_as_of); a texture a later pass
of the command buffer turned presents the face from before that turn to it (Faces::face), and
the turning pass encoded again takes its turn again (Texture::retake_turn: the shadow of the face
from before the turn held current, no copy in). Any other pass encoded again turns nothing.
TurnPoint drops logs_kept; SwapRecord keeps the face it turned from.

The shadow log (METAL2VULKAN_LOG_SHADOWS) also names, once per shadowed texture, at the first
draw that binds it after its shadow was made: the slot, whether the function fetches, samples or
writes it, and each sampler's min, mag and mip filters (a sampler state's by Metal's names, a
constexpr sampler's as the layout bakes it).

Tests: the runtime's attached_read_faces gains a lane with a host-page buffer alive (a logged
pass turns; a blit and a turning pass behind a shared-event wait, encoded again by a rebind, read
the texels from before the turn), against the same lane beside an open command buffer (the copy
route); the validation crate's runtime_lane::logged_face_turns runs the same under the layer.
Not yet run: dispatched next.
2026-11-12 14:03:30 -08:00
Anees Iqbal f62966f4f0 did_modify_range's bytes are taken at the next commit, as Metal takes them
What: did_modify_range (and a CPU write through a texture over a buffer) notes the range on the
device (managed.rs Modified); every commit, at its start and before it returns, copies each
noted range of a buffer with a host copy on the CPU into staging buffers as the host copy holds
it then (Buffer::upload_now, CallerCopy::copy_in_now, managed_copy::stage_in), which the next
submission copies into the device copy before any of its commands. A range the staging buffers
find no memory for falls back to the copy from the host copy as the submission runs.

Why: the copy in read the host copy (the caller's pages through their import, or the runtime's
own host copy) when the GPU ran it, so a CPU write made after the commit, before the GPU reached
the command buffer, was what the command buffer read. Metal on a Radeon Pro 5300M (macOS
26.7.1, reims's oracle) takes the bytes at the commit after didModifyRange: a write before the
commit (after the call, or with the command buffer encoded before it) is read, one made 30 ms
after the commit while the GPU spun is not. Capturing at the call would be wrong (steps 2 and
3 read the later write there). An RX 7900 XTX computed frame 0 of a benchmark on frame 1's
input this way.

Docs: managed.rs and managed_copy.rs state the rule and its cost (a CPU copy of the range's
bytes at the commit); API.md, the runtime README and FAST-PATHS.md's managed row follow.
managed_bytes_copied_in counts a caller copy's copies alone, as before.

Verified: the lane test of the parent commit on an RTX 3090 (job ids in the report).
2026-11-12 13:47:32 -08:00
Anees Iqbal a7ba65dd66 synchronize_texture copies a Managed texture's bytes over a two-copy buffer out
What: on a device without unified memory, BlitCommandEncoder::synchronize_texture
now copies a Managed texture's bytes over a buffer from the buffer's device copy to
its host copy (the caller's pages, or the runtime's own host copy), as
synchronize_resource of the texture already did. A level that lies in the image
alone (a tiled texture's past its first) copies nothing; a texture of an image
alone still records nothing, its CPU access reading its image. The copy is shared
code: synchronize_resource's buffer and texture arms now call synchronize_bytes and
synchronize_texels.

Why: synchronize_texture recorded nothing on every device, its doc saying Managed
memory behaves as shared memory. Without unified memory a Managed buffer is two
copies (managed.rs, managed_copy.rs), and a texture over one serves get_bytes, and
the buffer its contents, from the host copy (buffer_texture.rs Texels::read). So a
program that synchronized with synchronizeTexture:slice:level: read the CPU copy as
of its last didModifyRange: stale texels. Found reading the read-back paths for a
benchmark that fails validation on an RX 7900 XTX.

Docs: the stale doc is replaced; API.md and FAST-PATHS.md name synchronize_texture
beside synchronize_resource for the copy out; the managed counters' docs count it.

Verified: the lane test runtime_lane::device_copies::
a_synchronize_texture_copies_the_texels_out (a blit into rows of a Managed texture
over pages and over a runtime-made Managed buffer, then synchronize_texture: the
contents and get_bytes hold the rows; the copy out counted for the pages with two
copies) is run on a discrete NVIDIA GPU with this change and once without the
runtime fix (negative control); job ids in the report.
2026-11-12 13:27:01 -08:00
Anees Iqbal df9ae6b02d Snapshot reads with no barrier: API.md's accepted difference covers writers
docs/API.md's accepted difference for a draw that reads its own pass's color at its own pixels
with no barrier now covers a draw that writes the color too: it reads what the draws before it
wrote where the runtime takes no copy for it (in place, or through a snapshot where the device
takes that route and the snapshot costs no more than the copy: a surface's reader always, a
private texture's by the area rule), else the copy, the M3 Max's texels. Its lead-in is the slug
the pass-start-barrier read rows name. FAST-PATHS.md's row and texture/attached_reads.rs say the
same, each naming both answers.

Verified: docs only; the conformance unit test that the slug exists runs in the 780M job.
2026-11-12 12:52:10 -08:00
Anees Iqbal 090930eebf Queue times: a default-off diagnostic notes when a command buffer became its queue's head and when its submission returned
What: with METAL2VULKAN_QUEUE_TIMES set, each command buffer notes two host times beside its kernel
times (gpu_time::KernelTimes), read through two hidden runtime-extension methods:
- CommandBuffer::queue_head_time: its first batch became the first of its queue's batches the
  scheduler had not taken. Noted as the scheduler takes it in onto an empty line, or as the batch
  before it on its line is taken for submission (Order::next, in the scheduler's passes and a
  committing thread's).
- CommandBuffer::submit_returned_time: the vkQueueSubmit that carried its last batch returned
  (submit.rs for a batch submitted now, group.rs for a group's members). kernelEndTime is that
  call's start, so the two bracket the driver's time in the call.
Unset, nothing is noted and no line is looked up: a relaxed load of the device's flag (read once
from the environment into gpu_time::Timing) per take and per submission.

Why: walkprof5 (m3-max-22376) put commit -> submission start at 37.0 ms p50, while kernel start to
kernel end was 0.008 ms, which does not bracket the vkQueueSubmit cost (the call starts at the
kernel end). The consumer's trace needs to split commit -> submission into time behind the
queue's earlier work and time held at its head, and to see each call's own length.

Docs: env_vars.rs's registry entry and accessor, docs/API.md's diagnostics paragraph, the
validation artifact note's list of variables the runtime reads; api_signatures.tsv blessed (two
hidden methods).

Tests: tests::kernel_end_device::queue_times_are_noted_in_the_order_of_a_queue_s_submissions_and_only_where_asked
(three command buffers on one queue, committed back to back): unasked, both read 0; asked
(Timing::note_queue_times, test-only), head <= kernel start <= kernel end <= returned for each,
heads in commit order, and each submission returned before the next one's kernel start.
2026-11-12 12:45:56 -08:00
Anees Iqbal 8274894e15 API.md: a rate-mapped pass draws several regions in one multi-draw where the device allows it
The accepted difference "A rate-mapped pass draws region by region" now says where the device
enables multiDraw, multiViewport, shaderOutputViewportIndex and shaderDrawParameters, a direct
draw of a vertex pipeline records up to the least of maxViewports and one below
maxMultiDrawCount regions in one vkCmdDrawMulti[Indexed]EXT, its vertex variant storing
ViewportIndex as DrawIndex, with the same pixels.

Docs only; the behaviour landed in the previous commits.
2026-11-12 12:37:46 -08:00
Anees Iqbal 3591461c0b Memory log: each copy of a no-copy object's host pages says its caller's pointer and length as it is made and as it goes
An Iris boot lost its VkDevice to one float written into an ANV batch buffer right after the
boot's one copied no-copy buffer was made. A copy's merge back writes exactly the bytes the GPU
changed into the caller's pages, one 4-byte store for one changed float, so a caller mapping
unmapped under a live no-copy buffer and reused for a batch mapping would show that symptom. The
memory log (METAL2VULKAN_LOG_MEMORY) placed only device addresses, so it could not test that.

With the log on, the copied registry (copied.rs) now says one line as each copy is made and one
as it goes: its number, the caller's pointer and length with the range's end, and the copy's
host address and end, the two ranges the runtime's comparisons write on the CPU. The going line
is said after the registry's lock is let go, as the consumer's sink takes it. Off, nothing is
formatted: the registry holds no log.

Verified: fmt only here; the new tests::memory line test, clippy and rustdoc run on a CPU node
next.
2026-11-12 12:25:38 -08:00
Anees Iqbal 182e21e83c Arguments that function constants put on overlapping slots of one table are an invalid request
Function constants can set an argument's slot ([[texture(c)]]; the frontend states the index as a
global the static initializer computes). Values that put two present arguments of one argument
table on overlapping slots make a specialization Metal refuses when it makes the function: "<kind>
argument X has invalid location (<index,count>)", naming the later argument. Measured on an M3 Max
(macOS 27.0.1) for:
- buffers, a constant buffer and an argument buffer;
- a visible and an intersection function table, and an acceleration structure;
- textures, and a texture array overlapping a range;
- samplers;
- threadgroup memory.
Arguments of two tables at one index (a buffer and a texture at 0) are made.

The translation took such a set as valid and went on. Where a write texture and a sampled one met
on slot 0, the slot plan gave the slot the write access and the sample was refused as
Unsupported(Lowering(Sampler)), NotImplemented: a gap that is not ours. Where the two arguments'
uses agreed, one resource stood for both, a pipeline Metal never makes.

The specialized entry now refuses it (canon::interface, beside the duplicate color output check),
as RequestError::OverlappingArgument { param, index, count } and
DescriptorError::OverlappingArgument. Only present arguments count (MPS keeps gated pairs on one
index), and a count of 0 binds no slot. past_table and the new check share one table map.

API.md, the runtime's new_function_with_name_constant_values doc (the runtime checks constants
when a pipeline compiles the function) and the specialization planner's doc say so. The
signatures table is re-blessed; REFUSALS.md is unchanged (this is a refusal Metal makes).

Verified: the canon test covers each table and the non-overlapping cases. The MPS census A/B
(590 rows, every constant 0, release CLI on msi, base 9c2635b430) moves 42 rows to
InvalidDescriptor(OverlappingArgument): the 35 Lowering(Sampler) rows, 2 Lowering(Texture) rows,
and 5 rows that translated a specialization Metal refuses. No other row changes. With constant 125
(the batch size that puts the sampled texture after the written one) set to 1, all 42 translate
and pass spirv-val.
2026-11-12 12:14:41 -08:00
Anees Iqbal 0a4f4e87f2 Labels: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
A lost VkDevice's recovery notice named its hang only as "a command buffer (of queue `Q`)",
so an Iris boot's GpuHang (46 victims) left nothing to tell which work hung. The runtime had
no label for a command buffer or an encoder at all.

CommandBuffer::label/set_label (MTLCommandBuffer.label) and label/set_label on the blit,
compute, render and resource state encoders (MTLCommandEncoder.label) now keep what the
program sets. A command buffer has one encoder open at a time, so the open encoder's label
lives on the command buffer's state, and the encoder's record takes it as it ends: each
EndedEncoder reports its label, in its place, a render encoder that ends on the lowering
thread included. The recovery names its culprit from the command buffer's state as it fails
the pending batches: its label and its queue's, then its first 32 ended encoders' places,
kinds and labels, counting the rest, e.g. "command buffer `busy` of queue `relayed` (its 1
encoder: 0 blit `copies`) failed as the hang (`GpuHang`)".

set_label and label are no calls in EncoderCall's numbering. The API table, the Metal and
conformance coverage maps, docs/API.md's DeviceRecovered entry and the runtime README say so.
The table's WorkCounts::spare_command_buffers_freed_past_recorded line moves to where the
script sorts it.

Verified: fmt only on this machine; tests::labels (both lowering policies) and
tests::device_recovery's relayed-loss test, which asserts the named notice, run on lavapipe next.
2026-11-12 12:12:54 -08:00
Anees Iqbal 99146ff67f In-place reads: the lane test and docs name the devices whose passes fetch no color
A pass on a device with rasterization-order color attachment access (lavapipe) or without the
pixel interlock (the RX 550) fetches its colors as input attachments, and in place, like the
snapshot, takes no such pass (its subpass would name the color in two layouts). The lane test
asserts the read in place only where the device's passes fetch no color, and API.md, FAST-PATHS.md
and render/snapshot.rs say which devices keep the copy.

Verified: lavapipe lane job m3-max-22227 (msi) at e83d75fe83: 33 of 34 attachment-read, snapshot
and in-place tests passed, debug and under METAL2VULKAN_LANE_VALIDATION=sync; the one failure was
this expectation (lavapipe fetches through inputs: copies 1, in place 0).
2026-11-12 11:55:21 -08:00
Anees Iqbal 7284147b43 A draw that reads its own color at its own pixels and writes none of it reads in place
A draw whose fragment function reads, at its own pixels alone, a texture its own render pass
instance renders as a color, and whose pipeline writes no channel of that color, now reads the
attachment in place, with a memory barrier before it or without: no copy, snapshot or split.
The color is in the feedback loop layout for its instance, the pipeline is made with
VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT, and the slot binds the texture in that
layout. A by-region barrier before the draw (color writes to fragment shader reads) orders the
earlier draws' and the load's writes before its reads (Vulkan 8.10.5), and a by-region execution
barrier after it (fragment shader to color output) orders its reads before later draws' writes.
Its own writes go to other colors, so no fragment of the draw races another over the texels it
reads. It reuses the snapshot route's checks (pass shape, view format, pins, one image) and its
binding (render/snapshot.rs, in place), on a device that enabled attachmentFeedbackLoopLayout.

Why: the real Macs disagree on such a read without a barrier (probe ownread.m: the M3 Max
answers the texels from before the pass at every pixel; the 5300M answers the earlier draws'
writes at 98.6% of pixels and at all after a barrier; the UHD 630 at all but 0.01%). Under the
owner's rule for such disagreements we take the cheapest form, the x86 Macs' answer, recorded as
an accepted difference in docs/API.md. A compositor's backdrop reads paid a copy of the whole
target per draw before.

texture/attached_reads.rs now gives a color's image feedback loop usage wherever the device
enabled attachmentFeedbackLoopLayout, not only where it has the snapshot route's write-mask
command. New WorkCounts::reading_draws_in_place (api_signatures.tsv row). The draw-key and
graphics-key carry a feedback_loop bit for the pipeline flag.

render.rs (the draw's snapshot plumbing) is touched at: the draw's snapshot request, the phase
hole, the counts, the snapshot views, the pair base and phases, Recording::record (the barrier
after), and settle_draw's snapshot checks.

Lane test runtime_lane::in_place_reads with an owned fixture ipr_reads.metal (regenerated with
scripts/regen-air-fixtures). The golden tables and the compile census are re-blessed on
development.

Verified: not yet compiled; potluck build, lint and lavapipe lane jobs follow.
2026-11-12 11:55:21 -08:00
Anees Iqbal 47ca9278c8 Pages beside live dma-buf imports import their own dma-bufs, not a copy
A no-copy buffer or heap (made or rebound) whose pages a live import of another holds some of
was always a copy of them (CopiedBecause::OverImport), for VK_EXT_external_memory_host's
undefined second import of a host pointer (its issue 6). On RADV every no-copy object's pages
are udmabuf dma-bufs, which that clause does not cover, so since the one-import rule landed a
consumer's 780M walk made 2715 such copies (copied_over_live_imports, 292 MB copied in).

Now, where every live import that holds some of the pages is of dma-bufs, the pages come with a
source of dma-bufs the device imports, and the device's barriers order blits through two
imports of the same pages (no RuntimeDriverDefect::AliasedImportBlitsUnordered, which ANV and
MoltenVK have), the object imports its own dma-bufs from the source, never its pointer
(Device::imports_beside). Two dma-bufs of the same pages are two aliases of external memory
(Vulkan 1.4, 12.11 Memory Aliasing: consistent for buffers, uses separated by a memory
dependency); the tracker orders every use by the host bytes it touches across keys with global
memory barriers, as for a guest RAM's run imported beside its chunk. A pointer import on either
side keeps the copy. A failed import there falls back to the copy, announced with the failure.
HostAliases::within now names the live imports that meet the pages (Within::Meets(Vec)).
Counted: ObjectChurn::dma_buf_imports_beside_live (imports_inside_live stays the count of
pages imported twice where that is undefined).

Tests: tests::dma_buf_beside (device, Linux): a buffer over part of a live import's pages and a
buffer rebound onto pages two live imports hold some of, as made and without pointer imports:
beside dma-bufs where the first import is of dma-bufs, else a copy; the GPU reads the CPU's
bytes, CPU writes between encode and commit reach the command, GPU writes reach the pages and
the other buffer, and in imports a fill through one and a copy through the other in one encoder
are ordered either way. The host_aliases unit test checks Meets names the import met. The
validation lane's dma-buf joined-import test takes the third outcome. Checks: to run.
2026-11-12 11:11:08 -08:00
Anees Iqbal 3a619009b7 Run one-row threadgroups of a row-lockstep kernel on a variant without its simdgroup barriers
What: a kernel whose only simdgroup semantics are lockstep simdgroup barriers that order pairs
meeting only where a simdgroup spans two rows (RowLockstep) kept them, their cross-lane class
and, on a device with tangled 32-lane subgroups, its pinned subgroup size, even for a dispatch
of one-row threadgroups, where no such pair meets. On the Iris Xe that pin makes ANV compile a
register-heavy kernel at SIMD32, which spills and takes seconds where SIMD8 takes 0.3 s.

- Address facts: a place among the threadgroup's linear threads (thread_index_in_threadgroup,
  and under rows thread_position_in_threadgroup's x, never the grid's) with its low five bits
  cleared (`& -32`) or shifted out (`>> k`, k >= 5) is one value per simdgroup (AddrFacts::
  aligned, in fixed). The lattice walk skips such terms like uniform ones, and its spread now
  holds two facts, the finest lattice and the whole bounded difference, either clearing a pair.
- Lockstep::rows holds where, under row facts, no conflicting pair wants more than a
  threadgroup barrier: threadgroup barriers stand where the whole threadgroup runs together,
  order every pair a simdgroup barrier would and need no subgroup size, so a one-row pipeline
  keeps them and drops only the simdgroup barriers (the argument is in Lockstep::rows' doc).
- VariantKey::one_row / LoweringInputs::one_row: the lockstep pass inserts only the threadgroup
  barriers where rows holds; the kernel states RuntimeFact::OneRow (Mechanism::Variant). The
  binder asks a dispatch whose every region is one row of a RowLockstep kernel for it
  (dispatch_variant), the planned pipeline still runs such a dispatch, and the variant's plan
  sends a dispatch with a taller region back (NeedsVariant). The runtime settles on it through
  dispatch_variant and prepares it beside the base where a one-thread dispatch asks for it.

Tests: engine_simd_emulated's a_one_row_dispatch_drops_the_lockstep_simdgroup_barriers on the
Iris profile (a tile whose halves meet only across rows plus a workgroup-uniform pair): the own
pipeline keeps its simdgroup and threadgroup lockstep barriers, CrossLane(BASIC), Direct and
RowLockstep, and leaves the expected words at 144 x 2 (the shared lane's included); the one-row
variant has one threadgroup lockstep barrier, no simdgroup one, (None, NoSubgroup), no subgroup
requirement and OneRow, and leaves the expected words at 128 x 1 and 48 x 1 at 8, 16 and 32
lanes; the binder sends 128 and 48 to the variant and 144 x 2 to the base, whose plan refuses
the variant 144 x 2; the kernel with a simdgroup sum keeps Direct and its own pipeline for 32,
128 and 144 x 2. a_row_of_a_lockstep_only_kernel_takes_one_compile now expects the one-row
variant for one-row threadgroups of the row kernel, and the pinned pipeline for whole ones of
the others. The mechanism table, the inputs-encoding test and api_signatures take the new items.
2026-11-12 11:02:40 -08:00
Anees Iqbal b46459080d A batch held for its pipelines' making gives way to later commits of other queues
What: the scheduler's order across queues (scheduler/order.rs) no longer keeps the place of a
batch held unsubmitted for a host step that has not taken its gate: its pipelines being made, or a
step that reads nothing the GPU writes (`place_of`: `Place::GivesWay`). A later commit of another
queue that conflicts with it on a resource goes first, and the held batch is submitted after it,
so the tracker orders the two that way (submission order). The batches after it on its line give
way with it. What still holds a head back behind such a batch is a fence the two share
(`tracker::fenced`: one updates a fence the other waits for or updates, or a batch whose uses are
not known yet against one that names a fence), so no batch is moved after a fence update it waits
for. Unchanged: same-queue order, event and binary-semaphore waits (a batch waiting for the
program still keeps no place), batches held for their submission checks or for a host step whose
gate was taken (they keep their place: a later write going first would land after the step read),
and the order among submitted batches.

Why: on an Intel Iris Xe a guest process's cold compute pipeline took about 3 s to make; its
command buffer kept its place, and the other processes' heads that conflicted with it (the window
server's frames among them, over a surface they shared) waited behind it: the guest's display
froze for 3.1 s. Metal's order across queues is the order the GPU takes the command buffers, not
commit order: probes/cross_queue_surface_order.m's same-buffer control (one tracked buffer,
written by queue A's long compute, then read or written by queue B's later commit) ran B before A
once in three on a Radeon Pro 5300M and on a UHD 630 (macOS 26.7.1; m3-max-21850, m3-max-21851),
and in commit order on an M3 Max (macOS 27.0.1). Where real Macs differ, the cheapest form inside
them is taken; no switch, as matching the x86 Macs trades no accuracy. (The previous commit's
message miscounted the no-copy buffer case: unordered in 10 of 12 runs, 6 of 6 on the M3, 3 of 3
on the 5300M, 1 of 3 on the 630.)

Docs: order.rs's contract (**Tracked order across queues is the order the batches go**, **Held
batches give way**, **No deadlock**), the scheduler's tracking and gate docs,
WorkCounts::heads_held_for_earlier_commits, pending_dispatch.rs, docs/API.md's and the runtime
README's pipeline-wait passages.

Tests: tests::scheduler a_later_commit_goes_before_a_batch_held_for_its_making and
a_batch_held_for_its_making_holds_back_a_commit_sharing_a_fence (the order's model; its existing
a_later_commit_that_conflicts_waits_behind_a_batch_held_for_its_step is the kept-place control);
tests::hold_sites a_head_that_shares_a_buffer_with_a_batch_held_for_its_making_goes_first (was
..._waits_behind_it: the fill completes while the dispatch is held, and the dispatch's words land
over it), a_head_that_waits_for_a_fence_a_batch_held_for_its_making_updates_waits_behind_it (the
fence control), and the host-alias leg, which passes again.
2026-11-12 10:29:05 -08:00
Anees Iqbal ed8b9a137b A texture that renders over padded rows in ordered memory is in place where the device's check of renders passed
linear_plan::holding refused every texture that renders over rows with
bytes between them, ordered memory too (a Private buffer, a Managed one's
own copy on a discrete GPU), since Vulkan lets a render pass's load and
store read and write back any byte of the attachment's subresource. So
each such render target was a shadow (BytesBetweenRows): 32 Managed
textures at rows of 152 in 256 on reims's XTX walk.

Now holding takes renders_kept: Device::ordered_renders_kept answers it
where the device's policy takes images in place and its check of renders
over its pooled memory (PagesClass::Pooled, Access::Renders, the texels'
row ends) passed. That check renders into a linear image over padded
rows, through its moves into the layouts a render takes, a pass that
clears and stores it and a draw over its last column, while the CPU
writes the bytes beside its texels, and passes only where every byte but
a texel keeps what was last written: the owner's per-driver check, the
same that takes images in place over host pages and pooled memory. In
ordered memory no other agent writes those bytes meanwhile. The texture
is then the device's linear image made PREINITIALIZED (Between::Kept),
as one that only reads; a pending verdict starts the check, and a
texture made meanwhile is a shadow. The pooled move path asks the same.

Docs: the shadowed-texture notice (API.md), HOWTO, the degradation's
declaration and linear_texture_bytes_per_row's doc say so.

Verified: cargo fmt; unit test linear_plan::ordered_writes_let_a_
texture_that_renders_nothing_hold_its_rows_padding covers renders_kept
(kept in ordered memory, refused outside it and over shared rows);
device runs of tests::ordered_renders follow.
2026-11-12 08:57:13 -08:00
Anees Iqbal 7cd885ea5b runtime_lane::render_merged_attributes: stage_in states' executions run on the GPU alone
The lane test of executions whose inherited state's vertex function reads [[stage_in]]
attributes now states the GPU form, against the host step's pixels (a barrier the CPU set and
cleared), for a kernel-written ICB of triangle draws and indexed draws (merged) and triangle
strips (one draw per command), each command binding its own positions and per-instance marks at
its own offsets, first/base vertex and base instance:

- pulled_attributes_of_executed_draws_fetch_their_commands_elements: strides 10 and 6, which the
  shader fetches anyway (merged draws read the command's vertex and instance, not the merged
  draw's corner indices);
- fixed_function_layouts_of_executed_draws_are_pulled: strides 8 and 4, marks at step rates 1
  and 2, no vertex buffer bound at the encoder;
- a_layout_of_a_stride_set_per_bind_keeps_the_host_step: a dynamic-stride position layout the
  commands bind at their own stride takes the host step, whose notice names the rule.

The fixture gains ima_strips (a triangle strip writer). docs/API.md states the attribute rule in
the indirect command buffer section and in the GPU form's list; api_signatures.tsv and
api_surface.rs list draw_replay_vertex_layouts.
2026-11-12 08:37:43 -08:00