Commit Graph
4801 Commits
Author SHA1 Message Date
Anees Iqbal 0bb4e9f42b Pipeline log: a refused kernel's compile takes a line naming its function
A compute state whose kernel's compile is refused, at its creation or at a
dispatch's variant, printed nothing under METAL2VULKAN_LOG_PIPELINES, and
the refusal itself (compile failed: LimitExceeded(SpirvWords)) names no
function, so a consumer's log could not say which kernel it was. The log
now prints, at both compile sites, a line with the kernel's function name,
the refusal, and the descriptor it was made from, as a made pipeline's
line names them. Diagnostics only: nothing else changes.
2026-11-12 13:18:48 -08:00
Anees Iqbal d782275fc5 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 13:18:23 -08:00
Anees Iqbal 358330659a SEMANTICS_VERSION 2061, ARTIFACT_FORMAT_VERSION 508, RUNTIME_VERSION 2142: heap raw arms behind a spec constant
The commit before this one. A heap float read, sample, gather or query that may meet a texture held by its raw
texels branches into the raw decode arm at every site; the arm's test is now ANDed with
SpecKey::HeapRawTextures(stage)'s HELD bit, a u32 specialization constant (default 3, every arm live) that the
compute and render plans fill from the command's heap members (heap_raw(shape, stage, reach), the value the notes
already read). Where it is 0 no handle the command names carries a raw form's class, so the arms are dead at
pipeline creation. Modules change (one OpLogicalAnd per site, about 5.6k words on the largest kernels), and the
stored specialization key carries the new constant.

Verified (on the branch):
- nextest -p metal2vulkan --all-features (m3-max-22504): 3499/3500; golden_hashes changes on the heap-reading rows
  (296 cells), re-blessed on development.
- clippy --all-features (m3-max-22498); clippy --cfg m2v_gpu and rustdoc -D warnings (m3-max-22505).
- The decode-note test checks the stage declares the constant (default 3) and the plan's key carries 0, 1 or 3 per
  bound set; it fails without the change.
- CLI translation, amd-780m-radv profile (m3-max-22496): the four largest guest kernels at 0.96-1.76 s and
  163-271 MiB translation alone, 6.9-14.1 s with spirv-val, within 20 s / 500 MiB.
Not run yet: create time on the XTX (m3-max-22515) and the lavapipe heap lanes (m3-max-22516).
2026-11-12 13:17:44 -08:00
Anees Iqbal 64d3fc4261 Heap raw arms: a spec constant drops them where no raw texture is held
A heap float read, sample, gather or query that may meet a texture held by
its raw texels (BGR10_XR, BGRA10_XR, R10Unorm_X6, RG10Unorm_X12, the bfloat
forms) branches on the handle's class index into the raw decode arm at every
site. On a large kernel those arms are most of the module RADV compiles, and
they are live even when the command's heap holds no such texture.

The test now also reads SpecKey::HeapRawTextures(stage)'s HELD bit, a
specialization constant (default 3, every arm live) that the compute and
render plans set from the command's heap members, the value its notes
already read. Where it is 0, no handle the command names carries a raw
form's class, so the gate is exact, and the arms are dead code at pipeline
creation.

Verified: the decode note test now also checks that the stage declares the
constant and that the plan's specialization key carries its value.
2026-11-12 13:04:45 -08:00
Anees Iqbal 53afacd2a2 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:58:08 -08:00
Anees Iqbal f30d2c42a2 IcbShared states its Send and Sync, so a handler that keeps its reports builds at the default limit
The validation crate's release build of its tests under --cfg m2v_cpu_icd stopped building on
development (155027095f, job m3-max-22422): runtime_lane/indirect_host_steps.rs's executed-commands
handler keeps the reports it is handed (Arc<Mutex<Vec<ExecutedCommands>>>), and proving its
capture Send and Sync walked from the reports down an indirect command buffer's fields past
rustc's default recursion limit of 128 (recursion_depth_exceeding_limit, an error under
-Dwarnings). A program's crate that writes such a handler meets the same walk.

IcbShared now implements Send and Sync by hand, as Deferred does, with a constant that makes the
compiler prove each of its fields Send and Sync, naming every field, so a field added fails the
build until it is proved too. The walk from a consumer's types ends at an indirect command buffer's
shared state. Chosen over #![recursion_limit = "256"] on the validation crate: that would hide the
walk from the lanes alone, while every program's crate keeps the default limit.

tests/consumer_auto_traits.rs gains a_handler_keeps_the_reports_it_is_handed_at_the_default_recursion_limit,
the handler written as the lane writes it, in a function of its own as the file's other checks are.
2026-11-12 12:57:17 -08:00
Anees Iqbal 4909701fa1 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:55:35 -08:00
Anees Iqbal 93d6d2df8f Tests: the inputs encoding drops region_viewports' default as it drops the other later inputs'
pipeline::compile::tests::the_inputs_encoding_is_the_earlier_derived_debug failed at the rebased
tip (job m3-max-22386): LoweringInputs' derived Debug now ends with region_viewports, which the
key's encoding hashes only where it is set, as it does the other inputs added after the first
three. The test strips its default too.
2026-11-12 12:54:43 -08:00
Anees Iqbal a640990233 Queue times: the device tests' switch compiles only with the device tests
Under plain clippy --all-targets the device tests are out, so the switch was dead code; it is now
gated like step_aside's device-test helpers. Found by the lint job on msi.
2026-11-12 12:54:42 -08:00
Anees Iqbal 0ab547b714 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:54:07 -08:00
Anees Iqbal 7b27d0b63e Re-derive the generated documents at the landing tip
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.

Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
2026-11-12 12:53:37 -08:00
Anees Iqbal d09897f9fb RUNTIME_VERSION 2141: a draw that reads its pass's color at its own pixels with no barrier takes the snapshot, writers included
The commits before this one let snapshot_wanted take own-pixel readers with or without a Metal barrier, so a
draw that reads the color it writes (a compositor's backdrop: mix(read, colour) into its own target) reads a
snapshot of the earlier draws (pixel interlock, drawn twice) instead of a copy of the target, on devices with
attachmentFeedbackLoopLayout, extendedDynamicState3ColorWriteMask and fragmentShaderPixelInterlock. A fallback
counts as a split reason only where the draw would otherwise split; a no-barrier reader that falls back reads
the copy as before. The Macs disagree on such a read (the M3 answers the texels from before the pass; the
5300M and the UHD 630 the earlier draws' writes): docs/API.md's accepted difference now covers writers and names
both answers: a private target's reader through small scissors keeps the M3's answer by the area rule, a
surface's reader gets the x86 Macs'. FAST-PATHS and attached_reads.rs say the same; the conformance pass-start
read rows with no barrier accept the drawn answer (DRAWN_WITHOUT_BARRIER).

Verified (Radeon 780M, RADV, gem10):
- GPU time per frame, a compositor's shape (6 passes over BGRA8 surfaces, a backdrop draw per pass, exclusive,
  m3-max-22298): 4.069 ms with the copy -> 3.406 ms with the snapshot; shadow copies 8 -> 2; with the write-mask
  feature withheld 4.074 ms (the copy route in the same binary).
- At 7d45829efd (m3-max-22455): validation in_place_reads, snapshot_reads and attachment_reads 23/23 (the surface
  no-barrier test Moved { snapshotted: 2, splits: 0, copies: 0 }, pixels drawn; the private one copies 2, the
  M3's answer); 31/31 runtime attached-read tests; conformance pass_start unit tests 7/7 and the replay of all 14
  pass-start-barrier rows exit 0, over-buffer-read differed and justified by the accepted difference.
Running: fmt, clippy default, --cfg m2v_gpu and --cfg m2v_cpu_icd, rustdoc (m3-max-22457, 22462).
2026-11-12 12:52:52 -08:00
Anees Iqbal fb286f3492 Attached-read standing test: a read with no barrier takes the snapshot where the device reads so
tests::attached_read_standing reads a texture over a Private buffer's plane, whose image aliases
the bytes; with the snapshot route taking own-pixel readers with no barrier, a device with the
route reads it through a snapshot and copies nothing in. The test holds each read to the route
its counts show, as it already did after the barrier, and checks the bytes either way; lavapipe,
with no snapshot route, still checks the copies' cuts.

Verified: it failed on the 780M at c67027e1a9 (job m3-max-22418) with Read all zeros where the
copy was expected; the rerun follows.
2026-11-12 12:52:10 -08:00
Anees Iqbal 9b629fac02 Attachment-read lane: no-barrier own-pixel reads over a buffer's bytes take the snapshot
With the snapshot route taking own-pixel readers with no barrier, a reader of a target over a
buffer's bytes on a device with the route reads through a snapshot and sees what the draws before
it wrote: A's red in an_own_pixel_read_without_a_barrier_reads_the_texels_from_before_the_pass, the
clear in a_draw_after_a_clear_with_no_barrier_reads_the_texels_from_before_the_pass (psb_read), and
the load in a_barrier_at_the_pass_start_costs_nothing_without_a_read_of_a_cleared_color, with or
without the pass-start barrier alike. Each test holds the answer to the route the counts show, and
allows the snapshot only for the target over a buffer; check() takes a snapshot with no barrier.

Verified: the three failed on the 780M at 9894244e5d (job m3-max-22401) with exactly these
answers (128 for A's red, (120, 200, 40, 255) for the reordered clear, one snapshot for the loaded
read); the rerun follows.
2026-11-12 12:52:10 -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 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