Commit Graph
4787 Commits
Author SHA1 Message Date
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 3e620240f2 Snapshot reads with no barrier: docs, a surface lane test and the pass-start read rows
The snapshot route's docs, WorkCounts::reading_draws_snapshotted and the 780M timing that keeps
it: a compositor's frame of six backdrop readers over surfaces with no barrier took 3.41 ms of GPU
time through snapshots against 4.07 ms through copies (backdrop_costs, job m3-max-22298, base
e303b7adbb against e7641d633f; 4.074 ms with extendedDynamicState3ColorWriteMask withheld at the
tip, the copy). New lane test snapshot_reads::without_a_barrier_a_surfaces_readers_take_the_snapshot.
The conformance rows that read at their own pixels with no barrier
(pass-start-barrier-{private,over-buffer}-read) accept the clear, the answer a snapshot reads, under
docs/API.md's accepted difference DRAWN_WITHOUT_BARRIER (its entry follows in this branch).

Verified: not yet compiled; the 780M lane run follows.
2026-11-12 12:52:10 -08:00
Anees Iqbal 72c1dc128f Snapshot reads with no barrier: a draw reads its pass's texture through a snapshot where it can
Route (b), for timing: a draw that reads, at its own pixels, a texture its pass renders, and
writes the color it reads, now takes the snapshot route with no barrier before it too, in place
of the copy taken before the pass. It then reads what the draws before it wrote, the x86 Macs'
answer (docs/API.md's accepted differences), as with a barrier. Where the snapshot route does not
take the draw it reads the copy as before, and the fallback counts under no split reason
(Wanted::split_otherwise).

Verified: not yet; the 780M timing (backdrop_costs, base e303b7adbb against this) decides whether
it stays. Lane tests and docs for the no-barrier answer follow if it does.
2026-11-12 12:52:10 -08:00
Anees Iqbal a5254ead3a Cost lane: backdrop_costs, a window compositor's backdrop reads with no barrier
A release-mode measurement in runtime_lane::attachment_read_costs: one command buffer a frame of
a pass over each of six BGRA8Unorm surfaces (IOSurface planes over private buffers, five layers
loaded and a 3840x2400 framebuffer cleared), each a fill, a draw that reads the surface at its own
pixels with no barrier before it and writes what it read, and another fill. Printed per device
(default, and with extendedDynamicState3ColorWriteMask withheld): the median GPU time per frame
and the work counts per frame. It weighs the copy such a reader takes before its pass against a
snapshot of it.

Verified: not yet compiled; the 780M timing job builds and runs it.
2026-11-12 12:52:10 -08:00
Anees Iqbal 5b969352d5 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 12:47:08 -08:00
Anees Iqbal 82499c710a Test: the in-place check's notes test prints every settled verdict and note
The notes test settles the device's check, then printed only the notes of
shapes the check made no image of. It now prints every verdict
(IN-PLACE-VERDICT) and every note (IN-PLACE-NOTE), among them what the check
found changed where a verdict failed, so a device's report is read from a
settled check: a report printed before the check settles reads Pending for
every verdict. The assertions are unchanged.

Verified: built and run on gem10's 3090 (see the run's job).
2026-11-12 12:45:56 -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 000989b78e Host RAM copies: say why the validation layer's write-after-write between a gather's dispatches is no race
What: one comment where a word-wise host RAM copy binds its dispatches' sets. Each dispatch binds
the whole window it writes (a gather's binding 1) and writes only its pieces' words there.

Why: the validation layer's synchronization checks (SYNCVAL_SHADER_ACCESSES_HEURISTIC) count a
bound storage range as written whole, so two dispatches of one window read as a write-after-write.
No word is written twice: a copy whose runs name a destination byte twice goes to rounds of
regions (`twice`). ddsync3-xtx (m3-max-22331 at d9478fc91f, pipelines named): all 54
WRITE_AFTER_WRITE reports name "metal2vulkan: PagesCopy(Gather)", binding 1 of its pushed set.

Verified: comment only; cargo fmt.
2026-11-12 12:45:56 -08:00
Anees Iqbal 38ab829481 Re-bless the golden tables and engine printouts at 757a6f44d2
The 14 profile rows move: every profile's key now covers VK_EXT_multi_draw and multiDraw (SEMANTICS_VERSION
2060's region viewports); no translation hash moves. New rows and the printout for the owned fixture
overlapping_slots (SEMANTICS_VERSION 2059).

Verified: bless on the M3 at 757a6f44d2 (m3-max-22420): golden hashes, engine goldens, printouts and inventory
blessed; merged check at the same sha on msi (m3-max-22419): clippy every crate with --cfg m2v_gpu,
api_signatures, api_surface, fast_paths, rustdoc -D warnings.
2026-11-12 12:45:30 -08:00
Anees Iqbal 757a6f44d2 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 12:39:07 -08:00
Anees Iqbal b223f58b9f SEMANTICS_VERSION 2060, ARTIFACT_FORMAT_VERSION 507, RUNTIME_VERSION 2140: a rate-mapped pass draws its regions 16 at a time through VK_EXT_multi_draw
The commits before this one. Where the device enables multiDraw, multiViewport, shaderOutputViewportIndex and
shaderDrawParameters, a direct draw in a rate-mapped pass of a vertex+fragment pipeline whose vertex function
chooses no slice or viewport asks for the region variant (VariantKey::region_viewports, RuntimeFact::
RegionViewports: a new RuntimeFact, so ARTIFACT_FORMAT_VERSION), whose vertex stage stores DrawIndex as
ViewportIndex. Each batch of k regions (k = min(regions, maxViewports, maxMultiDrawCount - 1)) sets the device's
full batch of viewports and scissors, padded with empty scissors, and records one vkCmdDrawMulti[Indexed]EXT of
as many identical draws as regions. Mesh, tessellated, amplified and indirect draws keep the per-region route.
The route depends only on the pass having a map, so a mutable map's reset changes no pipeline. Also: a pass
left for its draws' pipelines takes its encoding again once they are made, so a map reset after the making is
spliced in instead of refused (rate-map-reset-unencoded); older than the route, made common by it.

Why: a rate-mapped pass recorded each draw once per region (Apple's rate-map sample: about 880k region draws a
host step on the Iris), which filled ANV's dynamic state pool (fixed in RUNTIME_VERSION 2138) and rendered that
sample at 0.9 presents a second on the Iris, against 7.7-10 without rate maps.

Verified (at 287e4d1517, the same code before its rebase onto 155027095f):
- CPU per frame, 3840x2160, quality [0.3,0.6,1.0,0.6,0.3], 256 guest draws of 2624 regions: lavapipe 134 ->
  31.77 ms (m3-max-22356); Iris Xe 187.00 -> 54.64 ms (m3-max-22368); Radeon 780M 140.04 -> 41.86 ms
  (m3-max-22369). Commands a frame 671,744 draws (+ as many viewport and scissor sets) -> 41,984 multi-draws.
- Iris dynamic state (imgleak's probe shape, 2 rounds, m3-max-22368): drm-total growth per heavy command buffer
  about 224 -> 115 MiB.
- Pixels: the batched draws' bytes equal the per-region draws' bytes, plain and indexed, 36 regions as 3
  multi-draws; rate-map lanes, rate_map tests, public_render_cases and depth_executions 90/90 plain and 80/80
  under sync validation on lavapipe (m3-max-22356); all 17 rate-map lanes, 3 depth_executions lanes and the
  pixel test on the Iris (m3-max-22368) and the 780M (m3-max-22369); the reset-after-making lane ran its
  pending path on lavapipe.
- Lint: fmt, rustdoc, clippy default, --cfg m2v_gpu and --cfg m2v_cpu_icd, metal2vulkan with no feature and
  each alone (m3-max-22357, 22370).
Running on the rebased tip: clippy and the translator suite (m3-max-22386), the lavapipe lanes (22387), fmt,
doc and gpucfg clippy (22388). Not measured: a translation census of the vertex variant (the translator tests
bound its added words at 40 or fewer).
2026-11-12 12:38:26 -08:00
Anees Iqbal f10321aad5 A pass left for its draws' pipelines takes its encoding again once they are made
A render pass whose draw's VkPipeline was still being made as it was encoded records as a segment
of its encoder once the pipeline is made (render/pending.rs). A rate map's reset after that
making finished, before the command buffer's commit or after it while the command buffer waited,
encoded the pass again from its log, and the splice refused it: the segment in its place was
neither one whose pipelines are still being made nor work recorded on the GPU alone. The pass
then drew by the map it took and the reset announced rate-map-reset-unencoded, where Metal's GPU
draws by the map as reset. The rate-mapped multi-draw route made this common: its vertex variant
is made at a pass's first draw, so the reset lanes failed by timing
(a_reset_shows_in_a_pass_not_yet_submitted and a_reset_shows_in_every_pass_not_yet_submitted on
lavapipe, jobs m3-max-22179 and m3-max-22244).

The splice now also takes the place of a render pass left for its draws' or tile dispatches'
pipelines alone and executing no render commands (Deferred::left_for_pipelines,
DeferredPass::left_for_pipelines), made since or not: the encoding again recorded those draws
where it found their pipelines made, or left a segment of its own where they were still being
made, and what the first recording took stays retained, as for a segment still being made.

Verified, before the fix: a diagnostic on lavapipe (job m3-max-22327) waited a second after the
draw and refused the splice in both cases ("keeps false gpu_alone false ... making false"),
shading the identity's 64 by 64 pixels with the notice; without the wait the pipeline was still
being made and the splice took it. The new lane
a_reset_shows_in_a_pass_whose_pipeline_was_made_after_its_draw waits for the making
(WorkCounts::variant_pipelines_made) and checks the half map's 33 by 33 pixels and no notice.
2026-11-12 12:37:47 -08:00
Anees Iqbal 2117d6af79 Lane: the batched-region test takes the physical size's u64s as they are
clippy::useless_conversion under --cfg m2v_gpu (job m3-max-22248): the physical size's width and
height are u64 already.
2026-11-12 12:37:47 -08:00
Anees Iqbal 8ae3ee4a26 Rate-mapped batches: route by the pass's having a map, each command the device's full batch
A pass's draws took the multi-draw route only over a map of layers that is not the identity, and
each batch's VkPipeline took as many viewports as the least of the regions' count and the
device's batch. A reset of a mutable map so changed the variant or the VkPipeline its pass's
encoding again draws with: a pass encoded over the identity, reset before its commit to half
quality and again after it to a quarter, was encoded again at the commit with a pipeline still
being made, which leaves work for a host step and so keeps no log, and the second reset could not
encode it again: it shaded the half map's 33 by 33 pixels where Metal shades the quarter's
32 by 32 (runtime_lane::rate_mapped_passes::a_reset_shows_in_every_pass_not_yet_submitted, on
lavapipe, job m3-max-22179).

Now the route follows the pass's having a map at all (draws_region_batches), and every batched
command sets the device's whole batch of viewports and scissors, past its regions its first
viewport through empty scissors (region_states), so the pipeline never follows the map's
contents. The pixels are the region by region route's as before: each draw's ViewportIndex is
its own index, and the padding entries are never indexed.

regions_vary goes: nothing else used it.
2026-11-12 12:37:47 -08:00
Anees Iqbal bc0e2281d5 Re-bless the opened enable chains for VK_EXT_multi_draw
The validation device now opens VK_EXT_multi_draw and its multiDraw feature where the profile
reports them, so each profile's chain gains one member and one extension.

Verified: bless_opened_chains on msi (job m3-max-22182); every row moves by one member and one
extension.
2026-11-12 12:37:47 -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 86c7692890 Region viewports: the variant's ViewportIndex selects no encoder viewport; the draw-again sites take the multi-draws
The region variant stored ViewportIndex through the contract's StageBuiltin::ViewportIndex,
which link reads as the vertex function selecting the encoder's viewports
(GraphicsState::writes_viewport_index): a rate-mapped pass's plan refuses such a pipeline
(RegionRefusal::ViewportArray). It is now a stage-IO object of its own (builtin_object), the
module still declaring ViewportIndex and needing shaderOutputViewportIndex; the tests check the
requirements and that the variant's pipeline selects none.

The kept-draw and rebound recording sites (render/draw_again.rs, draw_again/rebound.rs) take
the new Recording::multi field and record_draw_command's tuple.

Verified: the runtime errors are the ones m3-max-22173 reported; built in the next jobs.
2026-11-12 12:37:46 -08:00
Anees Iqbal 7bb1358224 Runtime: record a rate-mapped pass's regions several at a time through VK_EXT_multi_draw
Where the device enables multiDraw, multiViewport, shaderOutputViewportIndex and
shaderDrawParameters, a direct draw of one amplification in a rate-mapped pass whose map may
plan several regions (not the identity), of a vertex+fragment pipeline whose vertex function
chooses no slice or viewport and takes no compensation or band, asks for the region variant
(BindState::region_viewports). The binder keeps the request only for a vertex pipeline drawn
in one pass of no views, and the runtime follows the settled plan's VariantKey.

Each batch of k regions (k = min(regions, maxViewports, maxMultiDrawCount - 1); the spec's
"drawCount must be less than" maxMultiDrawCount) sets k viewports and scissors, the last
batch padded with its first viewport through empty scissors, and records one
vkCmdDrawMulti[Indexed]EXT of as many identical draws as regions; the VkPipeline takes k
viewports (FixedState::viewports). DrawIndex selects each region's viewport and scissor.

- recorder: vkCmdDrawMultiEXT / vkCmdDrawMultiIndexedEXT routed and counted (MultiDraws).
- device: MultiDraws loaded with the batch from VkPhysicalDeviceMultiDrawPropertiesEXT.
- render: DrawState::draws, region_states, Recording::multi; execution settles ask alike.
- lane rate_mapped_passes: a direct draw (batched) and the same draw from an indirect buffer
  (region by region) shade the same bytes over 36 regions, plain and indexed; the counts show
  each route ran. rate_map_costs counts multi-draws.
- binder: a mesh, tessellated or amplified draw keeps the plain variant.

Verified: not yet built; the next commits fix forward what the build reports.
2026-11-12 12:37:46 -08:00
Anees Iqbal 62568021fd Region viewports: name the three features in the refusal; bless the API table and REFUSALS.md
The refusal under LoweringInputs::region_viewports lists its features literally, so the
refusal surface names them (devices without shaderOutputViewportIndex, shaderDrawParameters
or multiViewport). api_signatures.tsv takes the new fields and variants; REFUSALS.md the new
sites.

Verified: signatures.py --bless and refusal_surface.py ran locally (source-only).
2026-11-12 12:37:46 -08:00
Anees Iqbal c2278b27c3 Region viewports: VK_EXT_multi_draw and a vertex variant that stores DrawIndex as ViewportIndex
A rate-mapped pass records each draw once per region of the map: 2624 recorded draws a
guest draw on a 3840x2160 screen at five quality steps an axis. This is the translator half
of drawing those regions several at a time, each one draw of a vkCmdDrawMulti[Indexed]EXT
whose index selects its viewport and scissor.

- Vocabulary: VkFeature::MultiDraw and VkExtension::ExtMultiDraw (never promoted), queried
  through ash_interop, enabled by the runtime's chain and mirrored in validation's.
- VariantKey::region_viewports / BindState and BindShape::region_viewports /
  LoweringInputs::region_viewports: a vertex function stores ViewportIndex as DrawIndex
  ("the zero-based index of the draw" of a vkCmdDrawMulti*EXT; dynamically uniform, so the
  same at every vertex of a primitive) and states RuntimeFact::RegionViewports. A fragment
  function behind it that reads [[viewport_array_index]] reads 0, as Metal's does behind a
  vertex function that writes none.
- Refused NotImplemented(RasterizationRateMap) under it: a function that writes its own
  viewport or slice index, a post-tessellation function, and one under amplification
  draws, viewport compensation, replay bindings or merged draws (the runtime draws those
  region by region). A device without shaderOutputViewportIndex, shaderDrawParameters or
  multiViewport names the three.
- StageBuiltin::DrawIndex.

Verified: not yet built; the next commits fix forward what the build reports.
2026-11-12 12:37:46 -08:00
Anees Iqbal e55d2255f6 Lane: the rate-map cost lane compiles its fixture's text in, to run off its builder 2026-11-12 12:37:46 -08:00
Anees Iqbal 6a1c275e1e Lane: what a rate-mapped pass costs to encode, a guest-like frame
rate_map_costs (ignored, report only): a one-layer map over a 3840 by 2160 screen
whose quality falls from 1 at the centre to 0.3 at the edges, 256 indexed draws of
small rectangles a frame (half encoded, half through an indirect command buffer),
against the same frame over no map. Prints the draws, viewports and scissors the
device recorded a frame, the draws a guest draw becomes, and the CPU per guest draw
and per recorded draw. Not yet run.
2026-11-12 12:37:46 -08:00
Anees Iqbal 118bdbf77b 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 12:30:02 -08:00
Anees Iqbal 7c3e52e14d A state's shape is compared with a kept one's stage tables first again
Reverts the reorder of 6ac366a168 in BindState::has_shape_beside_used; is_of's class-first
comparison and its answer for an empty argument sampler list stay.

Why: with every other field compared before the stage tables, a kept shape that only the tables
tell apart (the scene's materials cycling three texture sizes, RecentShapes::find's usual
miss) paid every other comparison first, FunctionTablesShape::of and is_of among them, before the
first slot's shape set it apart. Job m3-max-22316 (gem10, lavapipe, release, base cea84c33c9 against
6ac366a168): instructions a draw 36450 -> 36878 in the scene and 40176 -> 40595 in the rebinds
scene, both up.

Verified: the measurement against cea84c33c9 follows in the landing message.
2026-11-12 12:29:11 -08:00
Anees Iqbal bda3be1b65 A state's shape is compared with a kept one's other fields before its slots', and an empty argument sampler list at once
LiveBind::shape finds a reshaped state's shape among the shapes it took lately
(RecentShapes::find), comparing each with BindState::has_shape_beside_used, latest first. On
lavapipe, in a scene whose materials cycle three texture sizes, that comparison was 92% of
LiveBind::shape's instructions: the slots' shapes worked out as they are compared (a sampler
slot's BoundSampler::shape 18%), and ArgumentSamplersShape::is_of 15%, which filled a 64-entry
array of shapes before it compared the capacity class, also for a state with no argument
samplers (perf, job m3-max-22239).

- is_of compares the class first, and answers a list of no sampler at once: the shape of no
  sampler is the one with no shapes, as ArgumentSamplersShape::of(&[]) makes it.
- has_shape_beside_used compares every other field before the stage tables, so a kept shape
  another field tells apart (draws alternating a primitive type, which picks the viewport
  compensation and the band) is passed over before any slot's shape is worked out. The answer is
  the same conjunction of the same comparisons, none with a side effect.

tests/bind_shape_of.rs compares has_shape with shape() == over every pair of its states, an
empty argument sampler list among them.
2026-11-12 12:29:11 -08:00
Anees Iqbal 155027095f 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 12:26:29 -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 1a4da6c83c 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 12:21:01 -08:00
Anees Iqbal 3b6350ab69 Test: another queue's reader of a staged scatter waits for an event the scatter's command buffer signals
What: tests::host_ram_copy_device::a_first_scatter_over_chunks_the_thread_imports_is_in_its_pages_once_it_completes
read one of the scatter's pages from a command buffer of another queue ordered after the scatter
by commit order alone. It now waits for an MTLEvent the scatter's command buffer signals after the
scatter and its later encoder, the order Metal gives a program across queues. host_ram/copy.rs's
staged-scatter paragraph said every command in a later command buffer runs after the CPU's copy;
it now says a later one that runs after it does, and names the give-way window.

Why: since b46459080d (a batch held for its host step before its gate gives way to later commits
of other queues), the scatter's first batch, held for ScatterStage's step (which waits for no GPU
work, so takes no gate), and the drain's batch after it on its line give way: a later commit of
another queue that shares no fence with them goes first. Where the reader's commit reached the
scheduler while the stage's step still ran, the reader went first and read the page's bytes from
before the scatter: msi lavapipe, m3-max-22289 at 21342840fe, line 1929. The test last passed
before b46459080d (m3-max-22001 at 892b1ac1e8, whose tree lacks it); m3-max-22087 and 22141 did
not run it. Reading first is inside Metal's range: conformance probes/cross_queue_surface_order.m
saw x86 Macs take a later commit of another queue first for one tracked buffer, and run two
no-copy buffers over one allocation unordered on every Mac measured; so the test's leg asked
more than Metal does, and the product is unchanged.

Verified: see the job in the landing message (one run of host_ram_copy_device on lavapipe).
2026-11-12 12:18:12 -08:00
Anees Iqbal 8d87f8dd08 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 12:16:02 -08:00
Anees Iqbal def140193f SEMANTICS_VERSION 2059: arguments that function constants put on overlapping slots of one table are an invalid request
The commits before this one refuse a specialization whose present arguments of one table (buffers,
threadgroup memory, textures, samplers) take overlapping slots: canon::interface::entry() checks each
table's resolved ranges, skips arguments a constant removes, and binds no slot for a count of 0. The
refusal names the later argument, as Metal does (RequestError / DescriptorError::OverlappingArgument
{ param, index, count }). Metal on the M3 refuses such a specialization in
newFunctionWithName:constantValues: with "<kind> argument X has invalid location (<index,count>)",
measured for buffers, constant and argument buffers, visible and intersection function tables,
acceleration structures, textures, texture arrays, samplers and threadgroup memory; different tables
never conflict. Before, the translator went on and failed later (Lowering(Sampler) or
Lowering(Texture)), or translated a specialization Metal refuses.

Owned fixture engine/overlapping_slots (with its probe): dst at texture(1), src at texture(n); n=1 is
refused, n=0 samples as Metal does.

Verified:
- The M3 (m3-max-22104, 22106, 22107, 22112, 22255): Metal's wording per kind; the fixture's n=1 refused
  ("texture argument src has invalid location (<1,1>)"), n=0 writes 1 2 3 4.
- lavapipe, runtime_lane::overlapping_slots (m3-max-22257): n=1 refused with
  Compile(InvalidDescriptor(OverlappingArgument)), n=0 writes 1 2 3 4, the validation layer silent.
- macOS 27's 590 MPS functions, every constant 0 (release, m3-max-22163): 42 rows move to
  InvalidDescriptor(OverlappingArgument) (35 Lowering(Sampler), 2 Lowering(Texture), 5 that translated a
  specialization Metal refuses), no other row changes; with the batch-size constant 1 all 42 translate
  and pass spirv-val (m3-max-22170).
- The metal2vulkan suite (gem10, m3-max-22256): clippy clean; the failures are the golden tables' new
  rows, re-blessed on development.
2026-11-12 12:15:21 -08:00
Anees Iqbal 3fb2998d94 Tests: two textures on one slot are refused as Metal refuses them, and apart sample as Metal does
- tests::engine_function_constant_interface::two_textures_on_one_slot_are_an_invalid_request:
  on every committed profile, overlapping_slots with n = 0 compiles and passes L3, or needs the
  storage texture's format where the profile cannot write one without it. With n = 1 it is
  InvalidDescriptor(OverlappingArgument { param: 1, index: 1, count: 1 }), which names src.
- runtime_lane::overlapping_slots: under the validation layer on the device, the runtime refuses
  n = 1's compute pipeline state as Compile(InvalidDescriptor(OverlappingArgument)). With n = 0,
  4 threads sample 1 2 3 4 through the default sampler state and write 1 2 3 4, Metal's words.
2026-11-12 12:14:42 -08:00
Anees Iqbal 4afd6e0ae0 Fixture overlapping_slots: a sampled texture whose slot a function constant sets
An owned fixture with a write texture at texture(1) and a sampled texture at texture(n), where n is
function constant 0. It has the shape the MPS kernels state through the static initializer.
n = 1 puts both on slot 1. n = 0, which is also what an undefined n reads, keeps them apart, so
the suites that compile every public fixture without constants get a kernel; it samples a 4 by 1
texture at each texel's centre and writes the sample out.

- engine/overlapping_slots.metal, its .ll and .air.ll companions and TOOLCHAIN line (regenerated
  on the M3 Max, m3-max-22255).
- probes/overlapping_slots.m: on the M3 Max (macOS 27.0.1), n = 1 fails when Metal makes the
  function ("texture argument src has invalid location (<1,1>)"), and n = 0 writes 1 2 3 4 for
  texels 1 2 3 4.
2026-11-12 12:14:42 -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 86f7429489 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 12:14:08 -08:00
Anees Iqbal 7c25e335b1 RUNTIME_VERSION 2139: command buffers and encoders take Metal's label, and a lost device's notice names the hang by them
The commit before this one adds CommandBuffer::label/set_label and label/set_label on the blit, compute,
render and resource state encoders (MTLCommandBuffer.label, MTLCommandEncoder.label), each EndedEncoder
reporting its label (EndedEncoder is #[non_exhaustive]). The DeviceRecovered notice now names the hung
command buffer and its queue by label and lists its first 32 ended encoders by place, kind and label
(the places CommitFailure and the draw-dropped notices number), the kinds and places alone where nothing
is labelled. Why: an Iris boot's GpuHang (46 victims) left nothing to tell which work hung.

Verified (gem10, m3-max-22325): clippy -D warnings (default and --cfg m2v_cpu_icd), rustdoc -D warnings,
and lavapipe 11/11 for tests::labels (both render lowering policies) and all of tests::device_recovery,
the relayed-loss test asserting the whole labelled notice; signatures.py, metal-coverage and
conformance-coverage --check locally.
2026-11-12 12:13:24 -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 d9478fc91f 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 12:11:14 -08:00
Anees Iqbal 6e04ad33fc Test: a device that reports messages names a kernel's pipelines by its function, one that reports none names nothing
A device test of the pipeline names: with a message sink, the compute state's variant names its
pipelines "scale_and_offset" (the kernel); without one, it works out no name. A test-only
accessor reads the name off the state's creation variant.
2026-11-12 12:10:05 -08:00
Anees Iqbal 4c3767097c Pipeline naming: the naming function's comments say every pipeline is named 2026-11-12 12:10:05 -08:00
Anees Iqbal ad402b548e Every VkPipeline the runtime makes is named for the validation layer's messages
Where the instance reports messages (VK_EXT_debug_utils), each pipeline now carries a debug
name, which the layer prints after its handle. Until now only a raster-order pipeline was named,
so a synchronization report could not tell a program's kernel from one of the runtime's own.

- A program's pipelines are named by its Metal functions' names, in pipeline order, joined by
  " + ". Each variant's objects keep them (`VariantObjects::name_pipelines`), set where a
  compute variant is made (`pipeline/mod.rs`) and at each render variant's making
  (`RenderVariant::of`). A pipeline library is named the same, with its part in parentheses.
  An indirect-bindable replay pipeline takes its variant's names.
- The runtime's own pipelines are named "metal2vulkan: " and the kernel or step: each owned
  kernel by its module (for example "metal2vulkan: PagesCopy(Gather)"), the split, merge,
  resolve, copy and plane steps by their kind, the in-place check's draw, and the priming's
  kernels beside its pipeline.
- A raster-order pipeline keeps its name alone, since the validation crate's lanes match it whole
  (`raster_order_gap.rs`).
- A name is worked out only where the instance reports messages
  (`DeviceShared::name_pipeline` takes a closure), and nothing reads it: it is a diagnostic,
  and no translation or runtime path depends on it.

Why now: a sync-validation run on the XTX (SYNCVAL_SHADER_ACCESSES_HEURISTIC) reported 45
WRITE_AFTER_WRITE hazards. All were vkCmdDispatch after vkCmdDispatch, on one pipeline, at storage
binding 1 of a pushed set 0.

What the code points to, which the next run's names will confirm or not:
- The runtime's pushed kernels are RowsCopy, PagesCopy and the shadow copies and merges. Of
  those, the ones whose binding 1 is a written storage buffer are PagesCopy(Gather), RowsCopy
  and ShadowCopyBack.
- Only PagesCopy(Gather) records several dispatches in a row with one pipeline in one command:
  one per guest RAM chunk the runs touch (`host_ram/copy.rs`). Every one of them binds the same
  window of the destination buffer at binding 1.
- That path is taken only when no destination byte is written twice (`twice()`; a gather whose
  runs share a buffer byte takes regions instead), so those dispatches write disjoint words.
  The tracker orders the copy as one command over its whole span.
- The heuristic counts each dispatch as writing its whole bound range. So these would be
  reports of disjoint writes, not a missing barrier.
- Guest kernels push set 0 too, so a program's kernel in a concurrent compute encoder is not
  ruled out. That is what the names settle.

Docs: HOWTO section 8 says what the names are.
2026-11-12 12:10:05 -08:00
Anees Iqbal 75fd266463 Re-bless the golden tables and engine printouts at cea84c33c9
New rows and the printout for the owned fixture ipr_reads (RUNTIME_VERSION 2137's in-place reads): no
existing row moves.

Verified: bless on the M3 at cea84c33c9 (m3-max-22291): golden hashes, engine goldens, printouts and
inventory blessed, 99 lines added and none changed; merged check at the same sha on msi
(m3-max-22290): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface, fast_paths,
rustdoc -D warnings.
2026-11-12 12:09:36 -08:00
Anees Iqbal cea84c33c9 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 11:58:53 -08:00
Anees Iqbal 27b186ad8f RUNTIME_VERSION 2138: a command buffer that recorded much frees its pools' command buffers as it gives them back; heap uses hold texture retains weakly
The commits before this one:
- Spares: a command buffer whose recordings (its host steps' included) reach spares::RECORDED (16,384
  commands, about 0.6 MiB of ANV's dynamic state pool) frees every command buffer of each pool it gives
  back, on the device's free thread, and the pool rejoins the spares stocked with a secondary. Rate-mapped
  passes record each draw once per region; on ANV (Mesa 26.2.6, Iris Xe) each takes about 100 bytes of a
  device-wide 1 GiB dynamic state pool, and the spare pools kept those recordings. A guest's core (rate maps,
  ICB passes replayed at about 880k region draws a host step) held the whole pool: 2985 command buffers,
  1023.7 MiB, 9 of them 92-112 MiB, the one recording 97.5 MiB with OUT_OF_DEVICE_MEMORY; ANV then wrote
  SF_CLIP_VIEWPORT through a null state and QEMU took a SIGSEGV. Counted:
  WorkCounts::spare_command_buffers_freed_past_recorded. FAST-PATHS records the gap left: about 200 MiB a
  heavy guest command buffer with one draw per region, about five alive at once fill the pool.
- Heap uses: the heap's list holds Weak<Retain>; textures_from upgrades under its lock and builds the
  handles outside it, so a heap use never lets go of a texture handle on a runtime thread (the latent drop
  RUNTIME_VERSION 2128 left: a race between a program's last drop and the heap walk).
- Tests: the spares' fewest test begins a primary ahead in every spare before its small command buffer
  takes one, so its take no longer depends on a gate wait's timing. The opt-in Iris probe
  runtime_lane::rate_mapped_volume (m2v_gpu_hazards) prints each round's counts and DRM memory.

Verified:
- Iris Xe (ANV, Mesa 26.2.6), the probe (16 rounds x 2 heavy command buffers of about 811k region draws,
  2304 regions), DRM memory high-water: without the fix 731 -> 751 MiB (m3-max-22221), with it 522 -> 534
  MiB (m3-max-22260), spare_command_buffers_freed_past_recorded 222 then +190 a round. Neither reached 1
  GiB; the guest's repro is the consumer's.
- lavapipe: spares 23/23 (m3-max-22076); heap and residency modules 112/112 (m3-max-22065); spares 22/22
  with the fewest test (m3-max-22066). clippy default, --cfg m2v_gpu, --cfg m2v_cpu_icd and the hazards
  config, rustdoc (m3-max-22018, 22060, 22074, 22075, 22279).
2026-11-12 11:58:13 -08:00
Anees Iqbal 0aab84abe0 Test: the fewest test begins a primary ahead in every spare before its small command buffer takes one
small_command_buffers_leave_the_pools_holding_the_most_to_the_large_ones failed once under load
on msi (m3-max-21956, tests/spares.rs:940): its small command buffer took a large command
buffer's pool of 199 command buffers. A taker takes a spare holding a primary begun ahead first
(take_command_pool). A settled pool given back begins one only where no thread waited on its
command buffer's gate as it completed. The test's run() waits on each command buffer in turn,
so which spares held a begun primary depended on when each completed. Where only a large pool
held one, the small command buffer took it, as designed.

The test now begins a primary ahead in every spare (Spares::begin_ahead) before it takes its
snapshot, so the spares differ only in what they hold, which is what the test is about. The
runtime's rule is unchanged.

Checked: the spares tests on lavapipe (job id in the report).
2026-11-12 11:57:28 -08:00
Anees Iqbal 6feb4604c6 Heap textures reached through their retains: a heap use never lets go of a texture handle it took
Heap::textures_from upgraded every texture of the heap's list under its lock, then let go,
with the lock free, of each one that no program handle held (Texture::for_heap_use, RV 2128).
If the command buffer that held such a texture completed in between, that let-go was the
texture's last handle, and the texture's release ran inside the heap use: on the encoding
thread, or on the scheduler's steps thread in a host step's sync_heaps, outside any passing
hold (resource_ids.rs).

The heap's list now holds each texture's Retain weakly. Retain(Weak<TextureShared>) is made
with the texture (Arc::new_cyclic). textures_from upgrades the retains, which only the
program's handles hold, and reaches each texture through its retain (Texture::heap_use). A
texture no program handle holds is never taken. A retain that outlives its texture's last
program handle drops holding the texture weakly, so it never releases the texture.

Behaviour is otherwise unchanged: the same textures are made resident. Checked by the existing
heap-use tests (tests::heap_use_released, the residency and heap suites) on lavapipe. No
deterministic test exists for the race itself: it is a let-go between two threads that the
structure now rules out.
2026-11-12 11:57:28 -08:00
Anees Iqbal b3b930353d PROBE: its docs state what it measured on the Iris Xe, before and after RECORDED
The probe's docs said each round's heavy command buffers took pools no heavy one used. The
Iris runs show otherwise: without RECORDED's frees the spares were taken 4 a round after the
first (the heavy command buffers took the round before's pools, holding the most), and the
process's DRM memory reached 731 MiB in the first round and 751 MiB by the last; with them,
34 a round, 190 command buffers freed past their record a round, and 522 to 534 MiB. Neither
filled ANV's pool. The docs now say what the probe does and what it measured.

Verified: Iris Xe (Mesa 26.2.6) before m3-max-22221 (705c06813f), after m3-max-22260
(ad7c1e30c3, the tree of this branch before this commit's docs and the gap's wording).
2026-11-12 11:57:28 -08:00
Anees Iqbal c45c44c01f PROBE: each round reports the process's DRM memory, which holds what ANV's state pools grew to
ANV's block pools never shrink, so the DRM memory a round reports is the high-water mark of
what its command buffers held of the dynamic state pool at once, with their batches. A run
that does not crash still shows how near the pool's 1 GiB the recordings came, before and
after the spares free a pool's command buffers past RECORDED.

Verified: run on the Iris Xe as the before (705c06813f) and after (dynpool-after3) runs.
2026-11-12 11:57:28 -08:00
Anees Iqbal bf359931a6 Spares, FAST-PATHS: the dynamic-pool gap states what the guest's core measured
A scan of every ANV command buffer in the crashed guest's core found the 1 GiB dynamic state
pool held in full (1023.7 MiB over 2985 command buffers). Nine held 92 to 112 MiB each: the
crashing recording, and four earlier command buffers whose two passes (one vertex binding,
then four) each replayed an indirect command buffer over the rate map, two to a pool. So a
guest's command buffer of one draw per region holds 184 to 224 MiB, and about five alive at
once fill the pool. The gap says so as today's measure, not as a bound, since a route that
records fewer commands per region changes it.

Verified: docs only; the scan is m3-max-22188 (core read in place, streamed).
2026-11-12 11:57:28 -08:00
Anees Iqbal 55d000c08c PROBE: a map of 9 zones a side (Metal's most samples), executions sized to about 800,000 region draws a heavy pass
(cherry picked from commit dc8e23be64c5cf64ada3a06319335bade63a6571)
2026-11-12 11:57:28 -08:00