Commit Graph
1046 Commits
Author SHA1 Message Date
Anees Iqbal 528379dad5 RUNTIME 2439: Merge on the host whole up to 1 MiB of rows; count host steps
On the Iris Xe (RPL-P, ANV) the split merge's own GPU work (two buffer
copies of the pieces beside the texels, three barriers and the kernel's
dispatch) cost about 0.6 ms a command buffer for the guest's 34x34
RGBA16Float target (m3-max-35898: draw minus clear 0.69 ms, against
0.10 ms when the merge went on the host whole), while the host step's
word loop costs about 0.30 ns a byte (4.97 ms for a 1920x1080 target's
16.6 MB, half its texels changed). So the split pays only past about
2 MB of rows.

A merge on the host whose cut rows hold at most HOST_WHOLE_BYTES (1 MiB,
half the break-even) now goes on the host whole again; larger ones
split. A merge none of whose rows' lines holds a byte beside its texels
still goes by its kernel alone, as on any device. The whole merge is
also the exact form for the unmeasured case (a CPU write to a texel the
commands left in a line whose other bytes they changed), so the known
gap now applies only where the kernel stores: past the bound, and where
no row's line holds a byte beside the texels. Both forms keep the
measured padding contract, so there is no switch and no FAST-PATHS row.

WorkCounts::shadow_host_steps counts the host steps that ran for
encoders' copies back spliced and merges on the host: against
command_buffers_submitted, the GPU-to-CPU round trips a command buffer
pays, for a walk to read before any deferral of them.

Tests:
- shadow_runs::merges_on_the_host_go_whole_up_to_the_bound_and_split_past_it:
  over pages 16 bytes into a page, a 512x512 BGRA8Unorm target (1 MiB
  of rows) compares every byte of its rows on the host, and a 512x513
  one each row's first and last lines alone; each one host step.
- shadow_write_lines: the contract test's draw merges now compare every
  byte of their rows; the cost test alternates its verdict arms round by
  round, so clock drift and order weigh on both alike (the 1080p gap
  35898 showed, equal in Clear and Draw, with the same work recorded in
  both arms by every count); a new test prints, for a render target
  whose rows end a texel short of a 4096-byte page (1023x256 and
  1023x1024 BGRA8Unorm), under the device's own check and default
  policy, over pages imported by pointer and as dma-bufs: every host-page
  class's renders and copies verdicts for those row ends and its memory
  flags, the form the texture takes with its notices, and the median per
  command buffer of a clear-and-store and of a draw.

Degradation kinds added: none.

Verified: msi m3-max-35933 at f763e15338 (same tree): CLIPPY=0, CLIPPY_GPU=0, API=0 (15/15), release archive built. PHOENIX, lavapipe and the Iris run follow on development.
2026-11-16 02:57:29 -08:00
Anees Iqbal 438fdd4eee RUNTIME 2438: Merge on the host only the lines beside a texture's texels
A shadow's merge in place into host pages, on a device whose stores
write back the lines they end in (the Iris Xe under ANV) or whose check
has not answered, went on the host whole: the host step compared and
stored every byte of the merge's rows. On the Iris that cost 12.7 ms a
merge for a 1920x1080 RGBA16Float draw (17.7 ms a command buffer
against 3.7 ms by the GPU kernel), and the guest's scene has about 73
such shadows.

The merge now splits as the splice of a copy back does:

- Its kernel stores the changed words of each row's bytes in the lines
  that hold the texture's texels alone (ShadowMergeStores::Words, never
  whole blocks).
- The host step merges only each row's bytes in the lines that also
  hold a byte of no row of the texture's: the bytes between the rows and
  around them (shadow_splice::beside_texels; at most a row's first and
  last line).
- Before the kernel the GPU copies those pieces' kept bytes into a
  region of the command buffer's arena, then their changed bytes over
  them in the kept part, so the kernel finds them unchanged and stores
  none of them; the host step compares the region's bytes with the
  changed part's.
- The host step compares 4-byte words and stores a changed word with one
  AtomicU32 store (the changed word where all four bytes differ, else
  the word as it holds it with those bytes changed, as the kernel's
  Words form does); bytes outside whole words go one by one.
- A merge none of whose rows' lines holds such a byte (rows that start
  and end on lines, as the 1920x1080 plane's 15360-byte rows do) goes by
  its kernel alone, with its fetch view and kept image where it has
  them. A merge not cut to its texels' rows stays on the host whole.

The measured contract is the padding: row_padding_writes found the M3
Max, the 5300M and the UHD 630 keeping CPU writes to the bytes between
and around a texture's rows under clears, stores and draws, and over
IOSurfaces under kernels. No probe measured a CPU write to a texel the
commands left inside a line whose other bytes they changed, while the
command buffer runs; the kernel now stores into such lines, so that
write may be put back on the Iris. FAST-PATHS's known gaps record it,
beside the measured contract.

WorkCounts::shadow_merge_bytes_on_host counts the bytes the host steps
compared. Buffer::own_pages_flags gives a buffer's memory type flags,
which the cost test prints for a buffer made as the host scratch is,
beside the host loop's time over plain heap memory and over that
memory (1920x1080, half the texels' red and blue changed).

Tests:
- tests::shadow_splice (pure): the pieces equal the rows' bytes in
  lines beside the texels, found byte by byte, over 9 shapes and 6 page
  phases (wrapping among them); the host loop stores the differing bytes
  alone at every alignment.
- tests::shadow_write_lines: each draw merge's host step compares 16
  bytes a row (the row's last texels, in its padding's line); the cost
  test's 1920x1080 draw no longer merges on the host.
- tests::shadow_runs: the rebind test of host merges puts its pages 16
  bytes into a page, so every row's first and last lines hold bytes
  beside its texels, and asserts the bytes compared (a line a row).

Degradation kinds added: none.

Also (65db6f5b40): the old device-local query, left with no callers, is gone; the probe prints
the scratch's memory flags by name.

Verified (fplend): msi m3-max-35872 at a5289d8132 (same tree as 65db6f5b40): clippy 0, clippy
--cfg m2v_gpu 0, api_signatures + api_surface 15/15, debug and release archives built; 35850:
tests::shadow_splice 5/5 (host pieces against a byte-by-byte answer over 9 shapes x 6 page
offsets; the CPU word loop at every alignment). PHOENIX, lavapipe, rustdoc and the Iris run follow.
2026-11-16 02:29:15 -08:00
Anees Iqbal 2824464479 Storage twin docs: NonWritable states read-only memory, nothing more
What: views::declare_twin, DriverWorkaround::PushReadsLengthenThreadPayload and docs/API.md
section 5 no longer say that the twin's NonWritable decoration lets ANV fold or merge its loads, or
that the twin without it read more than the uniform view. They keep the fact: the twin binds the
uniform view's own range of a constant buffer, which the dispatch only reads, so its views are
decorated NonWritable. The decoration and its test stay.

Why: a585a74686 gave that as the cause of the Iris regression between pins 825997e49c and
44505b3807. The evidence since says it is not:
- Iris A/B m3-max-35592 (ANV, Mesa 26.2.6, 5 rounds): dispatch_chain --binds params ran
  358.8 us a dispatch with and without the decoration.
- Iris walk m3-max-35628 at bd3c1a8c37 (the decoration in): the two regressed workloads did
  not move (19.72 -> 20.01 s and 28.53 -> 28.36 s GPU).
- ANV's own stats (INTEL_DEBUG=cs, m3-max-35722) for a kernel of ours that reads its constant
  blocks through helpers and a private struct: twin at key 1 without the decoration and with it
  compile alike (SIMD16, 722 instructions, 79 sends, no spills).
The regression's cause is under investigation separately: a scratch build without storage twins
(68e39640e9, walk m3-max-35702) brought the workload back, so the twins are involved, not their
decoration.

No behaviour change: doc comments and docs only, no version bump. The runtime-sources pin
re-pins at landing (views.rs and profile.rs are hashed).
2026-11-16 01:34:11 -08:00
Anees Iqbal 518d6d8443 RUNTIME 2432: Shadows: merge on the host over host pages on devices that write lines back
What: a shadow's merge in place into a no-copy buffer's host pages, on a device whose
check of those pages failed, or has not answered, the copies or the shader writes of
texels whose rows end inside a line (the same rule as the copy back's splice), now goes
on the host. Its keep and the copy of the texels the commands left go into two parts of
a Shared scratch (ScratchKind::ShadowHost; the fetch view is not used, so the changed
texels are always copied). The encoder records only that copy, and a host step of a
batch of its own (Deferred::ShadowSplice, now carrying HostWrite::Splice or ::Merge)
compares the parts eight bytes at a time and stores each byte that differs into the
pages with atomic byte stores. Such a texture joins no run of passes (render.rs), so
each pass merges as its encoder ends. Devices where both checks passed keep the
kernel merge.

Why: the Iris probe (m3-max-35510) showed the merge kernel's stores losing CPU writes
to padding bytes in the line that holds each row's last texels, as the copy back did.
A CPU store changes only the bytes it stores, so the bytes the commands left, and
every byte the CPU writes meanwhile, stay. Metal keeps those bytes
(conformance probe row_padding_writes.m).

Where the merge stays on the GPU (FAST-PATHS known gaps): merges recorded between a
pass's instances, before a tile dispatch, into a held command buffer, at a segment's
end, merges through a copy, and the runtime's own Shared memory.

New WorkCounts fields: shadow_merges_on_host, shadow_merge_host_nanos.

Tests: shadow_write_lines now asserts the Draw rounds (keep + merge) put back no byte
and go on the host under unanswered verdicts, and follow the measured verdicts in the
second test. A new test, costs_of_a_write_back_spliced_or_not, prints the median
command-buffer time of a copy back and a merge for 34x34 and 1920x1080 RGBA16Float,
with verdicts unanswered and passed.

Degradation kinds added: none.

Verified (fplend): msi m3-max-35675 at bdb1e2cbae clippy (runtime, all targets/features, -D warnings) 0,
touched unit tests 3/3, api_signatures + fast_paths 34/34; msi 35689 clippy --cfg m2v_gpu 0.
PHOENIX suites (35711), lavapipe, rustdoc and the Iris cost run follow.
2026-11-16 01:05:03 -08:00
Anees Iqbal 9ea0a9c1f6 RUNTIME 2431: Shadows: splice a copy back into host pages on devices that write lines back
What: a shadow's copy back (Step::Back) of a 2D texture's image, or of a texture
buffer's staging buffer, into a no-copy buffer's host pages is spliced where the
device's check of those pages (DmaBuf or Pointer) failed, or has not answered, the
copies or shader writes of texels whose rows end inside a line (Access::Copies or
Access::Writes of RowEnds::InLines, Failed or Pending). The GPU copies only the
columns that fill whole lines of memory (nonCoherentAtomSize): one region a slice
where its rows are a multiple of a line apart, else one a row. Each row's head and
tail columns go by the GPU into a line-aligned region of the command buffer's arena,
and a host step of a batch of its own (Deferred::ShadowSplice, after the work before
it completed) copies them into the pages a byte at a time, as the CPU's stores go.
The encoder notes the truth's writes after the step. A copy whose texels fill whole
lines alone copies back as before; a device where both verdicts passed copies back
as before. New count WorkCounts::shadow_copies_back_spliced.

Why: on the Iris Xe (ANV) a copy of texels into a buffer's rows writes back the
64-byte line holding each row's last texels whole, putting back older values over
the CPU's writes beside them. The lane's probe (m3-max-35510) lost 3,539 to 14,319
bytes a kind in 300 command buffers through a shadow's copy back and merge, where
Metal keeps every such byte (row_padding_writes.m). This breaks Metal's contract on
the guest's bytes; the merge is the next change.

Where the copy stays (docs/FAST-PATHS.md, known gaps): a copy back between a render
pass's instances or before its tile dispatch, into a held pass's command buffer, at
a segment's end recorded at a commit or a host step, of rotated, two-plane, tiled or
heap depth/stencil textures, and into the runtime's own memory.

Tests: tests::shadow_splice (the cut run as GPU and CPU over a map of host bytes:
every texel once, no GPU byte in a shared line, every shape of texel, width, pitch
and phase); tests::shadow_write_lines (the probe made a device test: the guest's
34x34 RGBA16Float target over dma-buf pages, buffer and plane forms, a clear's copies
back put back no byte the CPU wrote beside them and are spliced; and a copy back
spliced exactly as the device's measured verdicts say).

Degradation kinds added: none.

Verified (fplend): msi m3-max-35614 clippy 0, tests 0, signatures 0; 35623 clippy m2v_gpu 0;
lavapipe 35625 clippy m2v_cpu_icd 0, 216 passed, rustdoc 0; PHOENIX 35632 (um790) in-place +
shadow suites 287/287, shadow_write_lines 2/2: under the measured verdicts (Copies and Writes
Passed) 0 spliced; under HostPageTexturePolicy::Shadow (no check, verdicts Pending) every copy
back splices (+300 in 300 rounds, 0 bytes put back). The Iris run follows.
2026-11-16 00:46:56 -08:00
Anees Iqbal a585a74686 SEMANTICS 2134 / RUNTIME 2427: A uniform view's storage twin is decorated NonWritable
What: memory::views::declare_twin states the twin's binding unwritten
(ModuleBuilder::unwritten_buffer). The serializer then decorates the twin's variables NonWritable,
its word view and its uvec4 view, where its own walk finds no store reaching them. No store goes
through a twin: TwinMem's write, write_bits, write_unit and write_vec all refuse.

Why: on the Iris profile (DriverWorkaround::PushReadsLengthenThreadPayload, ANV, Mesa 26.2.6)
RUNTIME 2413 reads a kernel's constant slot through its storage twin where the slot's
RangeAtBindOffset holds. The twin was not decorated NonWritable, because serialize::non_writable
only takes the bindings the lowering states unwritten. ANV runs nir_opt_access
(anv_shader_compile.c), which marks a storage buffer's loads reorderable only where the variable
is NonWritable or the shader writes no buffer. A kernel that writes its output therefore kept
every twin load apart, wherever it stood: no CSE, no hoisting, no merging. The uniform view's
loads, a uniform buffer's, are always reorderable, and the driver folded them.

Metal's compiler leaves a constant buffer's repeated loads for its own backend to fold. One guest
depthwise convolution kernel loads its params.srcSize (<4 x i32>) four times in every iteration
of its tap loop and its dstSize about ten times, and every inlined sample reads its ndArrayParams
again. Read through the twin, each of those loads ran per thread. A benchmark's Iris walk rose
from 754 to 1120 us a dispatch on that workload between pins 825997e49c and 44505b3807, and
825997e49c rebuilt matched the old walk (771). dispatch_chain's bump_wide reads its constant
word once, so the 2413 A/B could not show this. --binds params now can.

Aliasing (why NonWritable states nothing the uniform view did not):
- storage_twins gives a twin only to a slot whose form is a uniform view by its own window. That
  is view_kind's uniform view: a Metal constant address-space slot that no store or atomic of the
  function reaches, with a Bounded window, never the per-stage storage-buffer fallback.
- bind::instantiate::bind_buffers writes the twin's descriptor with the uniform binding's own
  buffer and DescriptorRange, pushed once for both.
- So the twin's bytes are exactly the uniform view's, under the same rule that chose a uniform
  view before the twin existed (the base form, 825997e49c).
- A uniform buffer is read-only to the module, and nothing orders it with a write through another
  descriptor of the same dispatch. Metal's constant address space is read-only for the dispatch.
  A guest that binds one MTLBuffer range as both a constant and a written device slot got no
  ordering from the uniform view either; the decoration claims no more than that.
- The runtime binds a twin nowhere the uniform view is not bound. A slot bound to nothing binds
  both from the device's zero buffer (RUNTIME 2420), which no command writes.

Docs: views.rs (the module docs and declare_twin), ModuleBuilder::unwritten_buffer,
serialize/non_writable.rs, the workaround's profile doc, docs/API.md section 5.

Test: engine_access's
a_kernel_uniform_view_reads_its_storage_twin_at_its_bind_offset asserts that every variable bound
at the twin's binding is decorated NonWritable. It fails without the change, where no twin
variable is.

SEMANTICS_VERSION 2134: translation output changes on the Iris profile alone (the twin's
decoration). The golden hashes and the authored compile census re-bless on development. New
Degradation kinds: none.

Also: dispatch_chain gains --binds params and params-off (bench only), a kernel that reads its
constant block again in a loop: params reads it through the twin at its bind offset
(RangeAtBindOffset 1), params-off through the uniform view at its residual (the base form).

Verified (ftreg, msi m3-max-35578 at 00a41f052f): clippy -p metal2vulkan -p metal2vulkan-runtime
--all-targets --all-features -D warnings 0; twin/NonWritable tests 44/44; negative control
(views.rs before the change) fails engine_access's twin test with [(12, false)]. Release A/B
arms built (35573/35574/35576); the Iris A/B follows. RUNTIME 2427: the translation changed.
2026-11-16 00:20:20 -08:00
Anees Iqbal 59fc85ea83 SEMANTICS 2133 / RUNTIME 2425: OpenCL mode: a 1D image bound to a real 1D texture reads it, through a variant
An OpenCL-mode kernel declares each image1d_t / image1d_array_t slot as the 2D texture of
height 1 Apple's OpenCL binds (canon::opencl::entry, canon::opencl_1d). A real 1D or 1D array
texture is a VK_IMAGE_TYPE_1D image, which takes only 1D views (Table 18,
VUID-VkImageViewCreateInfo-subResourceRange-01021), and a 1D view cannot sit in the slot's
Dim 2D descriptor (VUID-vkCmdDispatch-viewType-07752). So the binder wrote the declared 2D
type's neutral (PlanDiagnostic::IncompatibleBinding) and every read answered zero, outside
both measured answers (Radeon Pro 5300M: the 1D values; UHD 630: layer 0 of the array).

Now a per-slot variant keyed by the bound texture's type:
- air: Entry::open_cl_1d_images records the texture indices of an OpenCL-mode kernel's 1D
  images; SpecRequest::open_cl_lines names those a 1D texture is bound for, whose parameter
  keeps its texture1d type (opencl::entry) and whose operations stay 1D (opencl_1d::expand
  skips a call whose texture operand is that parameter).
- The kernel states RuntimeFact::OpenClLineTexture { slot } (Mechanism::Variant) per 1D image,
  in the base and the variant alike; nothing else states it.
- The compute plan puts such a slot in VariantKey::open_cl_lines where the shape binds a
  Type1D (Type1DArray) texture at a 1D (array) image read by the kernel
  (bind::plan::slots::open_cl_line_variant). VariantKey::lowering_inputs carries it to
  LoweringInputs::open_cl_lines, the specialized-entry cache key and SpecRequest. The variant's
  interface states the slot Type1D / Type1DArray, so its plan binds the 1D view and states the
  same key. The answer is the 5300M's.

With the set empty (Apple's 2D bindings) canon, the SPIR-V and the VariantKey are as before;
the base artifact gains only the OpenClLineTexture facts. The reflection still states the 2D
types. No runtime source changes.

Tests: canon::tests::opencl::opencl_1d_images_bound_to_1d_textures_keep_their_1d_operations,
engine_opencl_mode::an_opencl_mode_kernel_reads_real_1d_textures_through_its_variant and
a_plain_2d_texture_slot_given_a_1d_texture_binds_the_neutral; the runtime's
opencl_mode_1d_images_read_real_1d_textures (the repro).

SEMANTICS_VERSION 2133. api_signatures blessed (5 records); REFUSALS unchanged; docs/API.md's
OpenCL images paragraph.

Also e1aba1ad67 (the repro test), 9f3b309b65 and 8f2677c0ae (compile fixes: an Idx import; every SpecRequest literal names open_cl_lines).

Verified in the lane at 8f2677c0ae: lavapipe (m3-max-35393) OpenCL-mode runtime tests 19/19, the
new opencl_mode_1d_images_read_real_1d_textures among them (it failed at e1aba1ad67, m3-max-35348:
[0,0,0,0] for [10,11,12,13]); the 2D height-1 read and write tests pass at both. air OpenCL tests
9/9 (m3-max-35386). Still running when landed: the translator's engine_opencl_mode and api tests,
clippy x3, rustdoc, executor parity (runtime_lane::executions, runtime_run), the probe comparing
the guest 2D path's SPIR-V, facts and plan at base and tip, the PHOENIX run.

RUNTIME 2425 because the runtime's variant choice moves (bind::plan::slots); no runtime source
changed. New Degradation kinds: none.
2026-11-15 23:13:43 -08:00
Anees Iqbal 662460fe5e RUNTIME 2424: Storage twins take 0 where their kernel reads any other word the binder writes for it
What: the runtime's uniform_residual_form sets every twin's RangeAtBindOffset to 0, as it does
beside a residual read, also where the twin's stage reads under the key another word the binder
writes for it (residual::reads_other_words, from the interface's PushPlacements): a field placed in
its push range or its ArgumentTable, but a slot's SlotBindOffset residual where the key sets its
RangeAtBindOffset, and the DispatchRegion words where the key leaves the stage's MultiRegion 0 on a
variant that does not run a flat grid (a flat grid's one region reads them whatever MultiRegion
says). A root table's or execution status's address, a replay's region record, a slot's guest
base, a texture's levels and every other placed field count wherever placed. keyed_regions passes
the variant's flat_grid; the render callers pass false (render stages have no twins).

Why: RUNTIME 2419 kept a twin's key wherever no other RangeAtBindOffset of the key was 0, so a
kernel with a twinned constant view that also reads a root table's address (a pointer through an
argument buffer, dispatch_chain --binds ptr), or a multi-region region (dispatchThreads' edge
regions and group-count splits, tile and partial-threadgroup plans), or a flat grid's region kept
reading the twin at its bind offset while its thread payload stays long: the 2419 mechanism (ANV,
Mesa 26.2.6, Iris Xe RPL-P: moved arm 154.0 us through the twin against 143.1 us through the
uniform view, job m3-max-34864), whose cost is the stage's push reads (job m3-max-34063).
dispatch_chain --binds 4 reads thread_position_in_grid but dispatches threadgroups with
MultiRegion 0, so its measured twin gain (102.1 against 142.8 us) is kept.

Runtime only: no translation output, plan or artifact moves (the executor and the execution
record's plan check compare plans and artifacts, which the runtime's region keys are not), and no
creation key. Only dispatch keys of a kernel with a twin and such a word move, on the Iris profile
alone.

Docs: residual.rs's module docs and functions, keyed_regions, the workaround's profile doc and
docs/API.md section 5.

Tests: general_form's a_twin_takes_0_where_its_stage_reads_another_word (the twin zeroed where its
kernel reads another word, kept where it reads none, another stage's word ignored) and
a_stage_reads_its_region_under_multi_region_and_every_other_word_it_places (reads_other_words'
cases: MultiRegion 0 and 1, a flat grid, a residual held or not, an unkeyed residual, a root
table's address, another stage's field).

Verified in the lane (m3-max-35286, msi, at def6a68f94; each step's own exit code): clippy
-p metal2vulkan-runtime --all-targets --all-features -D warnings 0; tests::general_form 6/6;
lavapipe runtime_lane::executions + candidate::engine::runtime_run 34/34 (executor parity).
Still running when landed: clippy m2v_gpu and m2v_cpu_icd, rustdoc, the Iris A/B (a twinned
constant view beside a root table address / multi-region region, --binds 4 as control).

New Degradation kinds: none.
2026-11-15 22:36:33 -08:00
Anees Iqbal 92a77c7025 RUNTIME 2421: Continued passes on a device that splits at aliases, where no buffer write meets their images
What: on a device whose driver has DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer
(NVIDIA's 620.70.06 on the RTX 3090), an inline pass's last instance may now stay open, and
the next render encoder may continue it, as on every other device. Before it continues,
EncoderCore::continue_pass checks the group's byte writes (FoldOrder::byte_writes, the
leader's summary or the group's order) against every image the continuing pass uses:
its draws' images (AliasWrites' images noted apart), its attachments, and the uses of the
copies and steps before its later instances (render/inline_splits.rs, waiting_uses), all
of which record into the tail after what the group wrote there. Where one meets, the pass
begins its own instance in its own VkCommandBuffer, the measured form, counted in
WorkCounts::command_buffers_split_at_aliases. Where none meets, it continues and takes
the group's writes as its own (AliasWrites::continues), so what it records into the tail
after its pass is checked as a joining encoder's is.

Why: continuation cut the glass-panel frame's GPU time 11-26% on the 780M and Iris but was
off on the 3090. The open instance itself never holds a buffer write: its draws touch only
attachments, and anything else that records into the tail ends it first. The tail before
it can hold one, though (the leader's earlier inline instances and what records between
them), so the check is what the fact needs.

Also: render_fold's Lane::continuing (622368ab37) goes, since its lanes continue on every
device now. A test-only DeviceShared::aliases_split_forced lets lavapipe take the 3090's path.
New tests: tests::alias_split's continues unit test; tests::alias_split_device's count case,
a copy out of a texture after a continuation, a later instance of one pass reading an
earlier one's buffer write, and a texture over another buffer of the same host pages
(the last two are byte cases for two possible gaps on the 3090).

Also e818e7b442: Continued passes: a pass's uses of bytes count in the alias check, as an aliasing texture's are.
What: AliasWrites notes the bytes of buffers that the commands noted apart use (bytes_apart).
AliasWrites::continues now refuses a continuation where those bytes, or a Bytes use among
the pass's other uses, meet the group's byte writes, besides its images.

Why: a texture whose linear image aliases a buffer's bytes (Storage::Alias) names them as
the buffer's bytes (Texture::image_use), not as an image range. The lavapipe run with the
split forced (m3-max-35002) showed a pass sampling such a texture over bytes the leader had
just written continuing anyway: (1, 1, 1, 2, 0) where (2, 1, 0, 3, 1) was expected. A
continuation is refused rather than guessed at: a draw that reads, through a buffer, bytes
the group wrote also begins its own instance on such a device.

Tests: the count case now reads the written bytes through a texture over a buffer and

And dae7c2cad8: alias_split_device: the counted and copy-after cases read a texture over a buffer alone.

Verified in the lane (m3-max-35085, msi, at dae7c2cad8): clippy -p metal2vulkan-runtime --all-targets
--all-features -D warnings exit 0; lavapipe (m2v_cpu_icd) alias_split and render_fold 36/36; the
count test forced: written read (2,1,0,3,1), quiet read (1,1,1,2,0), unforced (1,1,1,2,0), texels
right. Still running when landed: the 3090 correctness job (alias_split, render_fold; F1-F3 byte
cases), PHOENIX render suites, clippy m2v_gpu and m2v_cpu_icd, rustdoc, the 3090 glass A/B.

New Degradation kinds: none.
2026-11-15 21:33:46 -08:00
Anees Iqbal cceefacfa7 RUNTIME 2420: A storage twin's neutral shares the device's zero buffer: the plan says which buffer writes are read-only
What: a new public BindingPlan::read_only_buffer(&DescriptorWrite): true for a uniform buffer and
for a uniform view's storage twin (DescriptorView::UniformWithStorageTwin, PlannedBuffer::twin),
which no function stores through. The runtime asks it where it used to read the descriptor type
alone (binding::descriptor's neutral arm, make_neutrals, binds_own_zeros), and makes the device's
zero buffer a storage buffer too, so a twin bound to nothing binds it.

Why: on the Iris Xe RPL-P profile (DriverWorkaround::PushReadsLengthenThreadPayload) RUNTIME 2413
gave a kernel's constant slot a storage twin. Left unbound, the plan writes the twin from the
ZeroBuffer neutral at a STORAGE_BUFFER binding, which the runtime took for a writable binding: every
dispatch took a fresh 64 KiB upload region, a dedicated VkBuffer allocated and zeroed, held until its
command buffer completed. Round 5974320352's Iris leg:
neutral_zeros_shared::dispatches_share_the_devices_one_zero_buffer, 8 dispatches made 8 VkBuffers
and 16 made 16.

Translation output and plans are unchanged (no SEMANTICS bump); the API addition is blessed in
api_signatures.tsv, and docs/API.md section 5 says it.

Test: engine_access::an_unbound_constant_slot_s_storage_twin_is_a_read_only_write plans
buffer_end_byte_load_constant with nothing bound on intel-irisxe-rplp-anv (the twin's STORAGE_BUFFER
write read-only, the written slot's not) and, as the negative control, on four other profiles (no
twin; read-only exactly at uniform buffers). The device check is the neutral test itself on the
Iris, which fails at the base.

Also, test premises on the Iris profile (round 5974320352's iris:runtime reds):
- a20c0a26d8: the compute creation test counts the forms its profile makes (1 + keyed storage views
  since RUNTIME 2410) and holds the pool only where completion is bounded (under Exact the second
  form runs on the pool).
- 88b8d31a32: set 0 at offsets counts the pipeline binds (draws past offset 0 take the residual form)
  and the push after each where the driver forgets pushed descriptors after a pipeline bind.

Verified in the lane (msi): m3-max-35051 clippy -D warnings -p metal2vulkan -p metal2vulkan-runtime
--all-targets --all-features exit 0, translator tests 71/71 (api_signatures 3/3); m3-max-35053
lavapipe (cpuicd) deferred_calls, neutral_zeros_shared, set_zero_at_offsets, uniform_bind_offsets
43/43. Still to run: clippy gpucfg and cpuicd, rustdoc, ONE Iris run of the three tests.

New Degradation kinds: none.
2026-11-15 21:23:17 -08:00
Anees Iqbal da08882991 RUNTIME 2419: Storage twins keep their key only where no other view reads its residual
On ANV (Mesa 26.2.6, Iris Xe RPL-P) a kernel's uniform view with a storage twin read the twin at
its bind offset wherever its own key held, also beside a storage view bound past offset 0, which
keeps reading its pushed residual word. There the thread payload stays long, and the twin's
per-lane storage read cost more than the uniform view's block read at its residual:
dispatch_chain --binds moved ran in 153.96 us a dispatch against base's 143.14 (job
m3-max-34864, 7 interleaved rounds, medians; ref's branch-free storage module 154.01), while
--binds 4, fixed and tex gained 28 to 38 %.

The runtime's uniform_residual_form now sets every twin's RangeAtBindOffset to 0 too where
another RangeAtBindOffset constant of the key is 0 (uniform_residual_form_of): a storage view
bound past offset 0, a twin at an offset no alignment divides, or a uniform view of no twin. The
kernel then reads its uniform views at their residuals, as base does. Where every view holds its
key, nothing changes.

Runtime only: no translation output moves, and no creation key (a creation's prediction binds
nothing, so its storage views and twins all hold). Only dispatch keys of a kernel with a twin and
a view off its bind offset move, on the Iris profile alone.

Docs: residual.rs, keyed_regions, the workaround's profile doc and docs/API.md section 5.

Test: general_form's a_twin_keeps_its_key_only_where_no_other_view_reads_its_residual (fails
with the cut sabotaged, the negative control in the check job).

Verified in the lane at 6d68983cc6: release build of the runtime and its dispatch_chain (m3-max-34932,
BUILD=0). Still running when landed: clippy plain, m2v_gpu and m2v_cpu_icd, rustdoc, the touched
runtime tests and the negative control (34931, 34933), the runtime suite on lavapipe, and ONE Iris
A/B of the arms and native code (base bcd50aba9f / opt2 680fc8997e / cut 6d68983cc6).

New Degradation kinds: none. Fixes the opt2 (SEMANTICS 2132 / RUNTIME 2413) regression of the moved arm.
2026-11-15 20:39:53 -08:00
Anees Iqbal b63bfbfac7 RUNTIME 2417: A render target's lend takes copies' failures through memory of one type
On the Iris Xe walk, a game engine's renderer made 73 RGBA16Float render
targets with free rows' padding over a no-copy buffer's dma-buf pages, and
each was a shadow: their renders failed for rows that end inside a line,
and the dma-buf classes' copies' verdict they lend that padding by
(`in_place::lent_to_copies`) was not failed in the recorded check, while
fresh checks fail it. A class's rounds catch a copy's line write-back only
as often as the CPU's writes race it, so the verdict hangs on a race.

The lend's copies verdict (`in_place::copies_verdict`, through
`InPlaceChecks::decided` at every decision site) now takes another host
class's copies failure, its reads passed, where the class's own kept every
byte or was unchecked, but only where the check's pages of both lay in
memory of a type of the same VkMemoryPropertyFlags as the driver reports
them: a write-back measured through memory of other flags says nothing of
this memory. Each class's memory flags are noted by the check and kept in
its record (CHECK_VERSION 21, eight words more). A shadow that renders with
free padding over host pages names the copies verdict it took in its
shadowed-texture notice. The line-write-back reason and docs (FAST-PATHS
host-pages row and the Iris known gap, API.md section 1 and the catalogue,
the kind's rustdoc) say so.

Tests: the unit test of the rule on the exact shape (same memory in place,
coherent against cached apart in both directions a shadow, unknown memory,
reads not passed, own-memory classes, own failed or pending kept, the
record's memory words); and a device test over a no-copy dma-buf buffer
(tests::lent_dma_buf_targets) whose control notes the pointer class in
memory of other flags and keeps the shadow.

Also 6e1f7b369d: the lend's memory flags are compared and printed as raw bits (ash's
MemoryPropertyFlags has no Debug impl here; clippy's chunks_exact_to_as_chunks).

Verified in the lane (m3-max-34875, msi, at 6e1f7b369d): runtime clippy --all-targets --all-features
-D warnings plain and --cfg m2v_cpu_icd exit 0; tests::in_place, tests::degradation*,
tests::texture_placement 38/38. Still to run: the device test on the Iris, PHOENIX and lavapipe
in-place suites, a sabotaged-build negative control, clippy m2v_gpu, rustdoc.

New Degradation kinds: none. CHECK_VERSION 20 -> 21: every device runs one fresh in-place check.
2026-11-15 20:15:41 -08:00
Anees Iqbal 765997d91f SEMANTICS 2132 / RUNTIME 2413: Kernel constant buffers on the Iris: a uniform view and its storage twin
What: on a profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV on the Iris Xe of
RPL-P), a kernel's uniform view (a read-only constant buffer whose window fits maxUniformBufferRange)
also binds its range as a storage buffer, its storage twin (DescriptorView::UniformWithStorageTwin,
ResourceKind::StorageTwin, BindingSource::StorageTwin). Each load selects, on the slot's
RangeAtBindOffset key, the twin read at the bind offset alone (key 1: a bind at an offset the class
divides, inline bytes, or unbound) or the uniform view at its residual (key 0). Specialization folds
the selection. The binder writes the twin from the slot's own source with a second descriptor range
starting at the bind offset. A twin's kind sorts last, so link numbers put a stage's twins after its
other bindings (docs/API.md section 5). Render stages and every other profile are unchanged: no twin
is declared and translation output is the same.

Why: on the Iris (m3-max-34275, dispatch_chain, us a dispatch) reading a kernel's constant buffer
through a storage view at its bind offset measured binds 4 142.7 -> 102.1, fixed 143.2 -> 101.3, tex
119.6 -> 74.4; at a non-zero residual the storage view lost (moved 143.1 -> 154.0), so the uniform view
keeps the residual case. Creation makes the key and its general form together (RUNTIME 2410), so no
first-use making.

Also: the cache codec lists the new variants; the interpreter binds a twin with no buffer of its own
to its slot's buffer; the device-replay tests name the twin's symbol. Docs: API.md section 5, the
workaround, the DEFECTS row, residual.rs, views.rs.

Verified in the lane: m3-max-34780 (at 7a862493b8) clippy -D warnings, metal2vulkan, runtime and
validation, all targets and features; the metal2vulkan suite 3626 passed, 11 failed: golden_hashes
(re-blessed on development) and 10 fixed at fca91cb055. m3-max-34804 (at fca91cb055) clippy 0. Still
running when landed: nextest over the three crates (34804), the authored compile census on the Iris
profile base against tip (M3), the Iris device tests and dispatch_chain A/B (every arm against base,
the branch-free reference for the folding check).

API: adds DescriptorView::UniformWithStorageTwin, ResourceKind::StorageTwin, BindingSource::StorageTwin
and BufferForm::storage_twin (additive to the enums: a consumer matching them exhaustively must add the
arm; a consumer binding set 0 itself fills the twin as docs/API.md section 5 says).
2026-11-15 19:48:21 -08:00
Anees Iqbal 725d2913d7 RUNTIME 2412: Bind shapes tell buffer length classes apart only as far as the device's range limits do
What: a new public bind::BufferRanges (a device's maxUniformBufferRange and
maxStorageBufferRange, BufferRanges::of(limits)), carried on each StageTable (buffer_ranges,
serde default), which the runtime sets on every table it reads (argument_table's AtBindViews,
beside the view base alignment: stage_table_reading, refresh_reading and the in-part
refreshes, AtBindViews::holds, and the debug check of a kept table). A buffer's shape states its
length class rounded up to the greatest class that fits the same limits
(BufferRanges::length_class); a class past both stays its own. BoundBuffer::shape and same_shape
take the ranges; BoundKind::of_bound and instantiate::bound_buffer class the bound length under
the table's ranges, so the instantiation's kind check takes a binding exactly where its class is
the plan's. The default (both 0) tells every class apart, as before.

Why: a guest compositor's serial compute encoder of ~1,140 fix-up dispatches over buffers of
many sizes made a new bind shape at 46% of its dispatches and planned again at 69% (the
consumer's XTX walks). A plan reads a length class only through class_fits against those two
limits (storage_view_variant and large_view_candidates against maxUniformBufferRange,
psb_variant and range_variant against maxStorageBufferRange); otherwise it only stores the class
for the kind check. On an RX 7900 XTX both limits are 4294967295, so every buffer below 4 GiB
takes the same plan decisions, and the dispatch_chain bench's 44 length-class shapes were one
plan. The bench there (job m3-max-34605, interleaved) matched the walk's split exactly (made
46%, found 18%, kept 36%) at 7.1-7.6 us a dispatch, against 4.1-4.4 us for the same stream of
one shape.

Exact: under the device's own limits, every class_fits answer of the rounded class is the exact
class's, so every plan decision, variant key and specialization is the same; under any other
limits the rounded class still bounds the padded length from above (padded < 2^class), so no
plan reads a range past a limit (it may take only a longer buffer's form).

Digests, cache keys and stored records: none carries the class. BindShape keys only in-memory
memos (Variant::plans, a state's kept Planned entries, the dispatch memo, the render draw
shapes); artifact digests and region keys are functions of the variant key and specializations,
which this leaves equal; validation and executor states keep the default ranges, so their shapes
and plans are unchanged; no pipeline record or warm record holds a shape. The serde form of
StageTable gains a defaulted field. So no SEMANTICS bump, in my reading.

Tests: bind::plan::slots length_classes_are_told_apart_as_far_as_a_plan_reads_them (4 GiB
limits, 64 KiB/128 MiB both ways round, 16 KiB, and none: every length's class answers both
limits' class_fits as the exact class does, bounds its padded length, is exact under none, and
bound_buffer takes a binding for another length's kind exactly where the classes are one, only
where the exact classes answer both limits alike); bind_shape_of's has_shape states and
same_shape pairs over range limits; runtime grid_classes
lengths_the_device_tells_apart_nowhere_plan_once (outputs of four length classes under 16 KiB,
one shape, 23 of 24 dispatches planned as before; 20 without this), and
shapes_and_classes_in_turn_each_plan_once re-made from the constant's binding (inline bytes, a
buffer, a buffer with a per-bind stride), since its three length classes are now one shape.
API: signatures blessed, api_surface, docs/API.md.

Also: 674c995a42 (dispatch_chain --zero-classes and --stay: a guest's fix-up dispatches over buffers of
many sizes), ad406afa87 (clippy in the new test).

Verified in the lane (m3-max-34674, gem10, at ad406afa87): clippy -D warnings -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features; translator tests 21/21 (the new
length_classes test, bind_shape_of, the slots tests). Still running when landed: the XTX bench before
and after (release, interleaved), the lavapipe bench, the runtime suite under m2v_cpu_icd on lavapipe,
the negative control (AtBindViews ranges set back to the default fails the new runtime test), clippy
gpucfg and cpuicd, rustdoc.

API: adds bind::BufferRanges and StageTable::buffer_ranges (serde default); additive.
2026-11-15 19:20:06 -08:00
Anees Iqbal 66de1cabbc SEMANTICS 2131 / RUNTIME 2410: At-bind storage views: creation makes the offset-0 key and its general form
On a profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV on the Iris Xe of
RPL-P) a storage view bound at offset 0 reads at its bind offset alone (RangeAtBindOffset 1). Every
plan made before a bind (a render state's creation prediction, a compute state's predicted region,
a warm pass's replay of a recorded dispatch) bound nothing, and an unbound storage view took 0, so
the creation made the general form and the commonest command, every storage view at offset 0,
made a second pipeline at its first use; the warm records named the other form.

- bind::plan::slots::range_at_bind_offset: a storage view bound to nothing takes what a bind at
  offset 0 takes; a uniform view keeps 0. Elsewhere no storage view declares the key.
- Render creation (pipeline/predicted.rs): the predicted key keeps its storage views' constants
  (uniform_residual_form) and the creation makes that key and, where it differs, its general form,
  together (RenderVariant::make_at_creation: pooled and waited for within one bound under Bounded,
  joined under Exact). The pool-ahead making of the key is deleted; the creation log names the
  general form's line.
- Compute creation (pipeline/dispatch_making.rs): the predicted region and its residual form,
  made together the same way. A warm pass's dispatch replay makes each region's residual form too
  (pipeline/dispatch_record.rs).
- The executor tells offset 0 apart at every slot (views_told_apart), so its plan of a case on the
  row is the runtime's (runtime_lane::executions).
- Tests: per-row expectations where offset 0 is its own shape or the creation makes two
  (made_at_creation, pipeline_records' Makings, grid_classes, dispatch_work, warm, the kernel
  creation counts in uniform_bind_offsets); the draw-again general-form test now binds
  colored_vertex's positions at 16 and colors at 0, a key neither creation form matches; a new
  device test, storage_views_at_offset_0_make_nothing_at_their_first_use, counts that a draw and a
  dispatch of storage views at offset 0 make, pool and take nothing but the creation's pipeline;
  an ignored timing test, storage_creation_times, times such a state's creation cold, from the
  memo and from the directory.
- Docs: DriverWorkaround::PushReadsLengthenThreadPayload, the DEFECTS row, residual.rs,
  predicted.rs, dispatch_making.rs, dispatch_record.rs, the warm pass, docs/API.md.

Also: c1d0b47a10 (WorkCounts docs name both creation forms; the first-use test types its positions),
6377eafa09 (storage_creation_times prints each round).

Why: fix forward for RUNTIME 2398-2400. Round cc1d619c7a's Iris legs failed about 16 tests on the
pipeline the creation made not being the one first use takes (made_at_creation, pipeline_records,
warm, restart, ycbcr_textures, executions, grid_classes, dispatch_work).

Verified in the lane: m3-max-34579 (at 2e6fbef8f2) clippy -D warnings, metal2vulkan, runtime and
validation, all targets and features; bind::plan::slots tests 14/14. m3-max-34603 (at 6377eafa09)
clippy --cfg m2v_gpu of runtime and validation; validation candidate::engine + worker::compile 103/105:
the runtime-sources pin (re-pinned at landing) and
candidate::engine::guards::tests::no_venue_runs_a_guarded_target_under_robustness_1_alone
(guards/tests.rs:125, under investigation: present on development or not). Still running when landed: the
Iris suites (made_at_creation, pipeline_records, restart, ycbcr_textures, executions, dispatch_work,
grid_classes, warm, uniform_bind_offsets, draw_again) and the creation-time A/B, cold and warm.
2026-11-15 19:02:47 -08:00
Anees Iqbal 8d617591f8 RUNTIME 2409: In-place textures over dma-buf pages: the image bound in the buffer's own import
A texture in place over a no-copy buffer's dma-buf pages no longer always asks the pages'
source for a new dma-buf and a dedicated import of its own. Where the pages lie in one import
dedicated to nothing (no sparse buffer over several imports, no import the driver made
dedicated to the buffer), its DRM_FORMAT_MOD_LINEAR image whose plane lies at offset 0 at the
texels' pitches is bound in that import at the texels' offset, beside the buffer
(vkBindImageMemory's memoryOffset): no udmabuf, no import, no new GPU mapping. Every fact is
asked of the driver: the image requires no dedicated allocation (VUID-vkBindImageMemory-
image-01445), the format query takes dma-bufs for it outside one (not DEDICATED_ONLY), its
alignment divides the offset (-None-10735), its size fits the pages' placement (-None-10737)
and its memory types take the import's. An import dedicated to the buffer binds no image
(-memory-10926): DmaBufPages now notes that.

A new check class, PagesClass::DmaBufInImport (CHECK_VERSION 20), measures that image; the
check's textures of each dma-buf class take that class's image alone (a thread-local of the
class the check runs). texture/route.rs takes the new class where its verdicts take the
texture, else DmaBuf's; a shadow waits on DmaBuf's verdict while both pend. Where the making
refuses the image in the import, it falls back to today's image where DmaBuf's verdicts take
it. A pending move re-routes the same way. Binding in the import reads it apart: it is kept
imported for good, as an image in a pointer import's is. A rebind remakes such an image in the
new pages' import by the same order. RADV requires a dedicated allocation of every such image,
so its check leaves the new class unchecked and it never takes the route.

New WorkCounts field: dma_buf_images_in_import. No new Degradation kind.

The route-(b) device tests (parked images, plane offset, import cycles, a texture's residency)
fail the new class's verdicts first, so they keep measuring today's image on any device. A new
device test (tests/dma_buf_in_import.rs) counts the route and its negative control.

Also: 4c3cbe2f1d and 37d2a750ce (the probe, dma_buf_linear_bind: a linear and a modifier image for
dma-bufs bound in the pages' existing import, the dedicated answers, a re-import arm), 5a40c2ef7b
(docs: API.md, HOWTO.md, FAST-PATHS.md, host_residency.rs module docs).

Why: the owner asked how to remove the per-texture dma-buf. Probe answers (Mesa 26.2.6): RADV on
the Radeon 780M refuses LINEAR images for dma-bufs (NOT_SUPPORTED x15) and requires a dedicated
allocation of every DRM_FORMAT_MOD_LINEAR image (m3-max-34443), so there it never fires. ANV on the
Iris Xe takes both images outside a dedicated allocation, bound in the existing import byte-exact;
first use of an 84 MiB texture 1.37 -> 0.21 ms (m3-max-34453).

Verified in the lane (m3-max-34571, gem10, at 5d5dee7901): clippy -D warnings -p metal2vulkan-runtime
--all-targets --all-features, plain and m2v_cpu_icd. Still running when landed: the lavapipe
in-place and dma-buf suites with the new count test (m3-max-34593), clippy m2v_gpu, PHOENIX, and the
Iris count test with its negative control.

API: adds the field WorkCounts::dma_buf_images_in_import (additive; api_signatures blessed in the lane).
2026-11-15 18:55:56 -08:00
Anees Iqbal 3442c96054 RUNTIME 2402: Park an in-place dma-buf image with its import for the next texture over the same pages
A texture in place over a no-copy buffer's dma-buf pages made a new
DRM_FORMAT_MOD_LINEAR image and a dedicated import of a new udmabuf of its
pages each time, so the kernel pinned and mapped every page again and the
first submission waited for the page tables: on the Radeon 780M an 84 MiB
texture took 1.4 ms to make and its first command buffer 7.1 ms against
2.2 ms over the device's own memory, every frame for a guest that remakes
its texture over the same pages.

As such an image goes (its texture and every command buffer that used it
gone) it now parks, VkImage and import, under the HostImport of its pages,
keyed by its plan, its texels' address among the pages, pitches and memory
type (dma_buf/parked.rs). The next texture in place over the same pages
tries each plan in its usual order and takes a parked image of that plan at
its texels before asking the source. An image whose first move ran rests in
GENERAL on our queue family (spec 12.10, 7.7.6: ownership stays with the
acquiring family; 7.9: host writes are visible to later submissions), so
the taken one notes no move; one never moved notes the same acquire a new
image notes. Not parked: images whose VkImage was handed out, the in-place
check's, rebind or detach replacements, past 64 per device.

Parked images are released by the residency thread after IDLE (2 s), count
as one listed import each against RESIDENT_MOST (released in park order
among the releasable imports' groups), go on host_range_remapped over their
buffer's bytes, and go with the HostImport before its deallocators.

WorkCounts: dma_buf_images_parked, dma_buf_images_taken,
dma_buf_images_missed, dma_buf_images_parked_released (api_signatures
blessed). New device test tests/dma_buf_parked_images.rs.

Verified in the lane (m3-max-34434): clippy -D warnings of the runtime, all targets and features; on lavapipe
(m2v_cpu_icd) tests::dma_buf_parked_images (6 textures over one buffer: 4 images made, 6 parked, 2 taken with
no source call and the CPU's later bytes, equal to a fresh image's; released on host_range_remapped and with the
buffer), dma_buf_plane_offset and host_residency's releasable-import test. The PHOENIX bench follows.
2026-11-15 18:09:55 -08:00
Anees Iqbal 0427b71281 RUNTIME 2400: Uniform views keep their residual form where storage views read at their bind offsets
On the profile that takes DriverWorkaround::PushReadsLengthenThreadPayload (ANV, Mesa 26.2.6,
Iris Xe RPL-P) the runtime read every view at its bind offset, a uniform view's included. A
uniform view read so compiles there to a constant-cache block read (send.hdc_ro
oword_block_read:owords4, job m3-max-34232) in place of the untyped read the residual form takes,
which cost about 18 us a dispatch more than the push word it saved. Now the device reads its
uniform views at their residuals, as on every device without
DriverFact::ConstantOffsetUniformReadsPreloaded, and the plan keeps the storage views' key:
reads_views_at_bind is the fact's alone again, and the plans and dispatch regions take
uniform_residual_form (each uniform view's RangeAtBindOffset at 0, a storage view's as the plan
gives it), which is residual_form wherever no storage view declares the key. Runtime only: no
translation output moves.

Measured on the Iris (job m3-max-34275, dispatch_chain, 4480 groups of 256, 200 dispatches a
command buffer, 7 interleaved rounds, medians in us a dispatch; every run checked its words):

  arm                   base f4082938de   landed d3b1dbdbe0   this change
  binds 1, serial            120.15             55.90             55.84
  binds 1, raw-barrier        55.74             55.75             55.75
  binds 4                    142.71            161.78            142.77
  fixed                      143.19            161.77            143.17
  moved                      143.10            165.23            143.04
  tex                        119.63            128.29            119.40

The storage-only kernel stays at raw speed, and every other arm is within 0.25 us of base.

Tests: general_form's a_plans_key_zeroes_its_uniform_views_and_keeps_its_storage_views (the
uniform-only residual form keeps a storage view's constant, the residual form zeroes both);
pipeline's every_committed_driver_reads_its_uniform_views_at_their_residuals again; and
uniform_bind_offsets' two kernel creation tests now key the kernel's own pipeline where its
output, a storage view bound at offset 0, declares the key (keys_its_own), on the workaround's
profile as on a device with the fact. Docs: residual.rs, the workaround's doc, the bind state's
uniform_views_at_residual, and docs/API.md.

Also: the test suites follow the Iris Xe's new workaround (its profile fingerprint differs from the
UHD 770 RPL-S by it; the stage-bound test's reference profile). Verified in the lane: clippy for
metal2vulkan and the runtime, all targets and features (m3-max-34321); the Iris run of
uniform_bind_offsets and inline_continues follows from the lane.
2026-11-15 17:38:32 -08:00
Anees Iqbal 4a06ce915d SEMANTICS 2129, RUNTIME 2399: Heap storage reads by the formats' own read bits on a device without the feature
A compute pipeline that reads a read_write argument-buffer texture was refused
Unsupported{ArgumentBufferTextures, needs ShaderStorageImageReadWithoutFormat}
on a device without shaderStorageImageReadWithoutFormat (ANV on Gfx12.0, the
Iris Xe), so the guest's work waited on a nil pipeline. Vulkan 1.3 and
VK_KHR_format_feature_flags2 enable the SPIR-V capability
StorageImageReadWithoutFormat, and a read of a view without a format is then
valid wherever the view's format has STORAGE_READ_WITHOUT_FORMAT_BIT (spec
19.9.3, VUID-vkCmdDispatch-OpTypeImage-07028). The slot path already took
that route; the heap path checked the feature alone.

- declare_heap takes a storage (and storage texel buffer) read by the
  feature or by the formats' bits (DeviceProfile::storage_reads_by_format_bits),
  and on such a profile needs the read bit of the class's neutral, which a
  null handle reads.
- The binder keeps each storage view as before (writes unchanged). On such a
  profile, a member whose view's format lacks the read bit is held for its
  writes and flagged (new entry flag FLAG_STORAGE_UNREADABLE, bit 28: the
  texel-class field narrows to the 12 bits its indices use), and a storage
  read through its handle reads the null element, as a nil texture's read
  does. A member of one of Metal's read-write tier formats, whose read
  Metal's contract defines, is refused without the bit instead.
- handle_entry_flags takes the profile (the flag is the device's).

On the committed Iris profile every Metal read-write tier format has the
read bit; RGB10A2, BGR10A2, RG11B10Float, BGRA8 and the 16-bit packed
formats do not (Mesa's isl: no Gfx12.0 typed reads).

A read-write tier format whose view lacks the bit is not refused at the member (binding runs for
every shader-writable texture of the runtime's device-wide heap, so a refusal there dropped the
texture's writes on a profile such as roadmap-2022, job m3-max-34236): lower::texture::slot::
declare_heap refuses the function that reads a heap storage class where any tier format would be
held in that class through a view without the bit, naming each view's bit; the member is held for
its writes, flagged. Docs: API.md accepted difference, FAST-PATHS known gap and device-gap row,
REFUSALS.md.

Verified in the lane (m3-max-34272): clippy -D warnings for metal2vulkan, metal2vulkan-runtime and
metal2vulkan-validation, all targets and features; nextest over the heap, handle, storage, profile,
fast_paths, without_format, texel_class and tier tests plus api_signatures, refusal_surface and
api_surface: 317 passed. A synthetic Iris profile with RGBA16F's read bit cleared refuses the
reading kernel naming that format; the committed Iris compiles it. The lavapipe lane with the
feature withheld and the Iris run follow from the lane.
2026-11-15 17:26:02 -08:00
Anees Iqbal d3b1dbdbe0 SEMANTICS 2128, RUNTIME 2398: Buffer views read at their bind offset where a pushed word lengthens every thread's payload
On ANV (Mesa 26.2.6) on the Iris Xe RPL-P, a compute function that reads a client push word
gets a longer per-thread payload (the base workgroup id moves 17 registers further), and a
light kernel runs about 2.2 times as long: 120.2 us against 55.7 us a dispatch on the same
module with the push read removed (raw Vulkan chains, jobs m3-max-34063 and m3-max-34038).
The 780M (RADV) shows no such gap (m3-max-34031). The runtime's storage views read their
SlotBindOffset residual on every access, so every kernel paid it there.

A measured DriverWorkaround row, PushReadsLengthenThreadPayload, on that driver and GPU:

- the translator declares SpecKey::RangeAtBindOffset for storage views too on that profile
  (access plan's storage_at_bind; the pulled vertex fetch of a shared slot folds its residual
  under the same key), so a key at 1 reads no push word once the driver folds it;
- the binder sets a storage view's key only at bind offset 0, where the runtime tells offset 0
  apart at the slot (StageTable::zero_offset_views, class ZERO_OFFSET_CLASS), and only where
  instantiation's range starts there (starts_at_bind), so the bytes before a bind offset stay
  reachable through the range from the buffer's start at every other offset;
- the runtime keeps the zero-offset slots beside the uniform ones (AtBindViews), leaving out a
  slot once it is bound at another offset, and reads views at their bind offsets on that
  profile (reads_views_at_bind), the uniform views' existing form included.

Every other profile declares no new key and its modules are unchanged; its stage tables leave
zero_offset_views 0, so its shapes and plans are as before.

Also a FAST-PATHS known gap: on the Iris Xe, kernels over exportable or host-pointer-imported
memory run about 2.2x (125.53 and 122.95 us against 55.73, m3-max-33760), cause unobserved;
zero copy stays.

Tests: engine_access (a storage view's module at key 1 reads no SlotBindOffset, at key 0 it
does, answers on the interpreter; no key on the other profiles), the binder's offset-0 rule and
class, the committed profiles' form choice, and a runtime device test of a storage view at
offset 0 and past it.

Verified in the lane: touched tests in msi jobs 34174/34198 (engine_access, bind::, fast_paths,
api_signatures, the runtime pipeline and argument_table tests); lavapipe m2v_cpu_icd 21/21 (34190:
uniform_bind_offsets and the new storage test, answers at offset 0, past it and at 0 again); clippy
plain 0 (34198), m2v_cpu_icd and m2v_gpu 0 (34200); rustdoc 0 (34213). golden_hashes reads stale only
for intel-irisxe-rplp-anv (re-keyed: 1788 cells, fingerprint 6d95bb254f9f9d66 -> 2f820bef4bfb9669); no
cell under an unchanged key moved. The table is re-blessed on development.
2026-11-15 17:07:41 -08:00
Anees Iqbal 4ee4deb737 RUNTIME 2385: a heap's 4:2:2 texture, a shadow of the heap's bytes, keeps a decoded twin
A heap's GBGR422 or BGRG422 texture lies as a shadow of the heap's bytes in Metal's rows (its answer
is Metal's measured rows: 512 @ 16 for 16x16, 8192 @ 16 for 64x64), and heap_texture_at excluded
4:2:2 textures from the decoded twin RUNTIME 2382 gave other carried formats' shadows, so every
kernel read and sample of one was refused, NotImplemented(Format) (56 refusals on PHOENIX and on
lavapipe, m3-max-33636 / 33625), where Metal reads it and the device can decode it.

heap_texture_at drops the 4:2:2 exclusion: the shadow keeps the twin with_decoded_twin chooses for
the device, through the device's conversion of the pairs where it converts them (rule 1), else
Metal's decode, one whole-image pass recorded after each copy in that moves its rows, its kernel made
at first use. A 4:2:2 heap texture cannot lie apart from the heap's bytes (held_to_metal sends rows to
Shadow or refuses with HeapTextureMemory; Unaliased is for one-plane and two-plane formats only), so
every 4:2:2 heap texture over device memory now keeps a twin; one over the caller's host pages, and a
detached heap's stand-in, stay twinless and refuse reads. Docs: chroma_pairs.rs contract,
decoded_twin.rs, degradation.rs CarriedDecodedTwin (doc and cost: "moves the blocks or rows"),
docs/API.md; first_use's lines say "decode passes set at the making N, their kernels made at first
use"; the HEAPDECODE line names a missing twin "none".

Verified: PHOENIX m3-max-33671 (carried archive of the lane tip 4976a40be3): 5/5 (heap_carried_reads
with GBGR422 and BGRG422 16/64 Private/Shared under both heap answer policies, new_resources_wait_for_
no_gpu_work, a_carried_heap_texture_reads_its_bytes_with_no_commit, four_two_two_heap_textures_take_
metal_s_size_and_layout, a_texture_held_for_copies_a_kernel_s_handles_reach_is_announced_once): every
4:2:2 case shadowed, a use 1 copy and 1 decode, a second encoder 0 and 0; kernel reads, samples,
samples after a blit and a Shared replaceRegion, blit out and getBytes equal the texture outside a
heap; route: Metal's decode (RADV and lavapipe convert no 4:2:2 pairs; the device-pair route in a
heap shadow ran on no device). lavapipe msi 33635: the same 5. Control (test commit alone): PHOENIX
33636 and lavapipe 33625 fail with the 56 refusals. Clippy plain, m2v_gpu, m2v_cpu_icd and rustdoc 0
(33635); runtime lib tests in 33672.
2026-11-15 14:20:58 -08:00
Anees Iqbal df0e7ec05e RUNTIME 2384: a fence update keeps its encoder group; the group orders after it by the narrowest barrier
A guest compute benchmark's encoders each update one fence and wait for one (reims, 780M,
c471372f87: fence updates = waits = encoders in every workload; 63 encoders a command buffer in one
workload), and an encoder that updated a fence ended its fold group, so every encoder began its own
VkCommandBuffer: 47.5 a submission, encoders_folded 54 of 117591. The driver's per-call work grows
with every VkCommandBuffer, and on the Iris Xe a VkCommandBuffer boundary costs 18.25 us of GPU time
against 0.64 us for the least barrier between dispatches (m3-max-33589).

A fence update no longer ends its group. A later member's commands order after the update by a
barrier recorded per command at the narrowest width that covers it: source, the updating encoders'
writes in the stages the update covers (SHADER_STORAGE_WRITE in shader stages, TRANSFER_WRITE in
transfer stages, attachment writes in a pass); destination, what the command can reach of memory
no use names, in its own stages (SHADER_STORAGE_READ | SHADER_SAMPLED_READ | SHADER_STORAGE_WRITE,
TRANSFER_READ | TRANSFER_WRITE), plus its untracked uses' own reads (indirect-argument or uniform
reads only where an untracked use reads them); tracked resources keep the tracker's rule. Between
two compute encoders that is the least barrier, SHADER_WRITE to SHADER_READ | SHADER_WRITE. The
barrier precedes the member's commands whether or not it waits, since a wait anywhere in an encoder
covers all its commands, which enter the shared VkCommandBuffer as they come; independent encoders
that update fences no one in the group waits on so run one after another (accepted: the guest's
encoders all wait). Across command buffers and queues nothing changes: Metal evaluates a fence at
submission, a wait only orders after updates committed before it ("commit the command buffers with
the producing passes before those with the consuming passes", MTLFence), a waiter on another VkQueue
waits for the updater's batch end, and a group never crosses a batch, so no cycle can form.
WorkCounts gains fold_fence_barriers and six folds_refused_* counts (the reason a join was refused:
kind, tail, batch, state, parts, ends; one relaxed add on a refused join, nothing on a join). Tests
that ended a group by a fence update now end it by a change of dispatch type or an event.

Verified: PHOENIX (RADV 780M, release, interleaved, 600 command buffers of 24 encoders, m3-max-33626):
fenced chain 47 -> 1 VkCommandBuffer a submission, mean call 56-79 -> 18-20 us, GPU start median
142-173 -> 101-105 us, GPU time median 146.7 -> 87.8 us (either wait order); independent fence-updating
encoders 74.7 -> 88.0 us GPU (serialised, as accepted); unfenced control unchanged (49.2 us).
fold_fence_barriers 13800 = 600 x 23; no folds_refused_* moved. Long-call bench, small listed:
539 -> 371 us mean call. Lane tip 8ae906a4fd: clippy plain, m2v_gpu, m2v_cpu_icd 0 (33633); lavapipe
runtime suite 2829 passed at 143a0013f8 and tracker unit tests 85 (33621; 8ae906a4fd deletes only the
dead Summary::has_updates); PHOENIX encoder_fold, render_fold, spares, fences 71 passed (33626).
Iris before/after: m3-max-33627, pending.

Public surface: WorkCounts (for the lanes) gains fold_fence_barriers and folds_refused_*, blessed in
api_signatures.tsv; a struct literal of WorkCounts must name them, Default and readers are unaffected.
2026-11-15 14:13:04 -08:00
Anees Iqbal d62e1d2bd9 RUNTIME 2382: a heap's decoded-format texture on a shadow route keeps a decoded twin
Under DevicePolicy::exact_answers (HeapAnswerPolicy::Metal) a heap's PVRTC or ETC2 texture on RADV
PHOENIX misses Metal's answer (its BC1 carrier image takes 4096 B @ 4096, Metal answers 128 @ 128
or 2048 @ 128), so it lies in memory of its own as a shadow of the heap's bytes (MemoryShadow;
Shadow or Tiled where those serve). heap_texture_at gave a decoded twin only to the Direct,
HostTransfer, Linear and Hidden routes, so its sampled view fell to the carrier, which has no
sampled usage, and every kernel read and sample was refused, Unsupported(Format) (8 of 8 cases in
m3-max-33467), where Metal samples it and the device can decode it.

A heap's PVRTC, ETC2 or EAC texture on a shadow route (not over the caller's host pages, not
detached) now gets its decoded twin. ShadowCopy::record_gated records the shadow's decode
(ShadowCopies::decode) after a copy in that moved texels, and only then (record_moves answers
whether it moved any); the pass is set at making (Image::decode_after_copies_in) and its kernel is
made in ShadowCopies::prepare at first use, so no making compiles. WorkCounts::shadow_twin_decodes
counts the decodes. 4:2:2 heap shadows stay twinless; heaps over the caller's host pages stay the
documented copies-alone gap. Docs: decoded_twin.rs, pvrtc.rs, etc.rs, degradation.rs, docs/API.md,
docs/FAST-PATHS.md (heap shadows of decoded formats are no longer for copies alone). New device test
runtime_lane/heap_carried_reads.rs. Public surface: WorkCounts (for the lanes) gains
shadow_twin_decodes, blessed in api_signatures.tsv.

Verified: PHOENIX m3-max-33568 (carried binary of the lane tip d5bf9cac82): heap_carried_reads,
a_carried_heap_texture_reads_its_bytes_with_no_commit, pvrtc_texels_read_as_metal_s and
etc_texels_read_as_metal_s pass. Under HeapAnswerPolicy::Metal all 8 cases shadowed; a use takes 1
copy and 1 decode, a second encoder in the same command buffer 0 and 0; kernel reads, samples, blit
out and getBytes equal the texture outside a heap, and samples follow a blit and a replaceRegion.
Under HeapAnswerPolicy::Device: not shadowed, 0 copies, 0 decodes, equal. Without the fix
(33467 at the test commit) all 8 reads were refused. lavapipe (msi 33535): the 4 tests pass. Clippy
x3 running in 33569.
2026-11-15 13:46:15 -08:00
Anees Iqbal 5813fe6743 RUNTIME 2381: a render target whose copies lose its padding lies in place
On the Iris Xe (ANV), a render target over host pages whose rows end
inside a 64-byte line (nonCoherentAtomSize) failed the in-place check's
renders: the clear and store, and draws, write back the line holding a
row's last texels whole, so a CPU write to the padding in that line can
be lost. Such textures were shadowed (733 in reims's walk: RGB10A2
66x66@512 572, RGBA16F 55, R8 49, A8 49, BGRA8 3). But the shadow keeps
nothing more: its copy back writes the same lines, and on this device a
plain buffer copy, a copy of texels into a buffer's rows and a kernel's
stores all write back that line too (Iris probe, job m3-max-33417:
clear+store 15/15 rounds changed padding bytes, draw 15/15, product
shadow copy back 14/15, buffer copy 15/15, kernel stores 6/6; every
changed byte in the row's tail line, none past it; rows on lines 0).

The check gains an access, Copies: a blit copies a zero texture's texels
into the class's buffer's rows while the CPU writes beside them (every
shape but the 3840x2160 surface; no rounds over the runtime's own
memory). A texture that renders over host pages whose rows' padding is
free (not declared unobserved), whose renders failed for its row ends,
now takes the verdict of renders that let that padding change where the
class's Copies failed for those row ends too (pending while they are),
announced as Degradation::LineWriteBack (line-write-back, Precision).
Copies failures carry across classes as the other GPU writes do. The
check notes each class and access's rounds' time. CHECK_VERSION 19.

Docs: FAST-PATHS host-pages row and a known gap for the Iris line
write-back (nonCoherentAtomSize 64; buffer copies, texel copies, kernel
stores, passes); API.md section 1 and the catalogue entry; the in-place
lane's VERDICTS 98 -> 112 and a lane test with the kind's site.

Verified: msi m3-max-33510 at the lane tip 47b06c9f0d: clippy (runtime + translator, all features,
all targets) 0; runtime tests 29/29 (the decision, a_texture_that_renders_lends_its_free_padding_
where_the_copies_change_it_too, carry, degradation_catalogue, degradation_sites, texture_placement);
translator api_signatures, fast_paths, api_surface 34/34; --cfg m2v_gpu archive of runtime +
validation built (33511). Pending: negative control 33520, lavapipe 33512, the Iris proof.
2026-11-15 13:32:18 -08:00
Anees Iqbal 369835f951 RUNTIME 2380: the submitting thread's CPU time is read only where queue times are noted
RUNTIME 2379's WorkCounts::batch_submit_cpu_nanos and submit_long_call_cpu_nanos read
CLOCK_THREAD_CPUTIME_ID twice on every submission call on every driver. That clock is a system
call on Linux, not a vDSO read: 459 ns a read against the host clock's 19 ns (thread_clock_bench,
Ryzen 7 7840HS, Linux 7.3, fastest of 3 rounds of 1M reads, m3-max-33486), so 0.9 us a call always
on, against a whole NVIDIA submission call of ~12 us. The thread's CPU time is now read only where
the device notes queue times (METAL2VULKAN_QUEUE_TIMES, the existing default-off diagnostic); the
CPU fields read 0 elsewhere and their docs say so with the measured cost. The wall-time fields,
the long-call counts included, stay on. The long-call bench turns queue times on and gains its
unfenced arms (one VkCommandBuffer against 47); thread_clock_bench measures the reads.

Verified: msi m3-max-33490 at the lane tip 57e916e1c6: clippy (all features, runtime + translator)
0, clippy --cfg m2v_gpu 0, lavapipe kernel_end_device + submit_stalls 16/16 (the queue-times device
test checks the CPU time stays unread when not asked and is counted once asked).
2026-11-15 13:18:30 -08:00
Anees Iqbal 85a91d182c RUNTIME 2367: Queue plan: a device made with its least plan reserves what its plan reserves, no more
The 2080 round 9ce951f521-1115-0907 failed
reserved_queues::a_device_with_no_queue_to_spare_reports_the_reserved_queue_absent:
"11 asked, 11 reserved; no message", where queue_plan(families, u32::MAX)
spares 10 (NVIDIA's graphics family of 16 less the round robin's floor of
four and presenting's two). Asked for 11, the plan takes 4 + 2 + 10 plus the
staging and fill queues, 18 VkQueues; the driver refused that for want of
channels (um790's kernel log: "kchannelAllocMem_GM107: Could not create
Channel" 19 times at 10:01 and 13 at 10:02, while the 780 s run that ended
10:04:38 was at the test), and made_within_resources took least_queue_plan:
queue_plan_within(families, options.reserved_queues, {1, 0}), a round robin
of one and reserved min(15, 11) = 11. 11 is what only that path gives.

So a device short of resources gave the caller more reserved queues than the
same device given them, and skipped the reserved-queues-absent message,
though the least plan's notice and the runtime README say it keeps the
plan's reserved queues. least_queue_plan now reserves as many as the
device's own plan (within options.queue_limits) reserves; its round robin
of one always leaves room for them, so no fewer either.

Tests:
- queue_limits::the_least_plan_reserves_what_the_plan_reserves: every
  family shape, reservation (0 to u32::MAX), limit and cached flag; fails
  without the fix on NVIDIA's shape asked for 11 (11 against 10) and on a
  family of 24.
- reserved_queues::a_device_made_with_its_least_plan_reserves_what_its_plan_spares:
  the plan refused through refuse_next_devices(1), the device asked for
  spare + 1 takes its least plan (its notice heard, round robin 1) and
  reserves spare, reporting the rest absent; refused where the least plan
  takes no fewer (lavapipe, RADV).
- The test sink records each message's id name with its text, so the
  least plan's notice is matched by its code.

Docs: the degrade catalogue (docs/API.md), LeastQueuePlan's rustdoc and the
runtime README's "A driver short of resources" say the reserved count is the
plan's.

Also: queue_share_device's pinned test takes a stay the sharing rule
explains, as its siblings do (test only).

Verified (msi, m3-max-33039): clippy plain 0; lavapipe reserved_queues,
least_queue_plan, queue_limits and the pinned test 16/16. The 2080 run
follows on development.
2026-11-15 10:37:01 -08:00
Anees Iqbal 0b6f72ac29 RUNTIME 2362: Scheduler: a copy queue's command buffer keeps commit order behind a held batch
What: a head on a queue made for copies (Device::new_command_queue_for_copies) no longer
goes before an earlier-committed batch of another queue it conflicts with because that
batch gives way. The order's comparator (scheduler/mod.rs is_behind) treats a held batch
that gives way as one that keeps its place when the head's queue keeps commit order
(Standing::commit_order, from CommandBufferShared::keeps_commit_order: the queue's kind,
set by the copy queue's constructor). Such a head waits behind it in the scheduler when
tracker::ordered says the two conflict, whether the held batch waits for its pipelines'
making, a host step or its checks. Once the held batch is submitted, the tracker orders the
copy after it on the GPU: the copy engine's VkQueue waits for the other VkQueue's timeline,
or a barrier where they share one. There is no wait on the host. A copy that shares nothing
with the held batch still goes. Unchanged:
- plain queues keep the give-way exactly as before (order.rs, Held batches give way), so the
  Iris Xe compositor case is untouched;
- a held batch ON a copy queue stands to a later plain queue's commit as any held batch does
  (the rule is the head's);
- a batch held for an event value or a binary semaphore's signal the program has not given
  holds back no copy (Stops).

Why: the copy queue's documented promise is that a copy reading what another queue's
command buffer committed before it wrote waits for that command buffer on the GPU. A
command buffer of a blit and a new pipeline's first dispatch, held for the pipeline's
making, gave way to a copy committed right after it on the copy queue. The copy ran first
and read the bytes from before the blit: the consumer's copy queue on an RTX 2080, and a
plain second queue on MoltenVK, round 0 only, always the new pipeline's first dispatch. The
give-way rule (b46459080d) stays for plain queues, where real Macs disagree; the copy queue
is a runtime extension whose contract is ours.

Docs: order.rs (But not to a queue made for copies, No deadlock), the scheduler's Tracking
paragraph and is_behind, new_command_queue_for_copies (what holds exactly, the reverse
direction, and that on a device that answers None a plain queue used instead gives way, so a
caller orders such a copy with an event), the runtime README's copy-queue and pipeline-wait
passages, docs/API.md's pipeline-wait passage, pending_dispatch.rs,
WorkCounts::heads_held_for_earlier_commits, and the hold_sites module docs.

Verified: lavapipe before (the previous commit's copy-queue leg) and after, reported with
the tip.

Verified (lavapipe, the copy queue on the round robin VkQueue): at
87ab2111b0 (m3-max-32839) the copy-queue leg fails, reading the bytes
from before the blit; at 404352e262 (m3-max-32840) hold_sites,
dispatch_pending, pipeline_wait_order, held_step_order and copy_queue
16/16, clippy m2v_cpu_icd 0.
2026-11-15 09:19:49 -08:00
Anees Iqbal 5ba7afd9d4 RUNTIME 2360: Shader cache: no default directory makes a memory-only device, never a failed one
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere),
default_directory answered Err and CacheSetup::of turned it, and any failure to
open the default path, into Error::ShaderCache, so every device creation and
adoption failed. Metal never fails device creation over its shader cache, and
the default is the runtime's choice, not the caller's (owner rule 2).

- The Windows default is %LOCALAPPDATA%\metal2vulkan (the local application
  data folder, read from the environment; no new dependency). XDG_CACHE_HOME and
  USERPROFILE are no longer read there.
- default_directory takes its environment as a closure (CacheSetup::of_in), so
  a test feeds its own without touching the process's.
- Where the caller names no directory and the default does not exist or cannot
  be made or written, the device keeps its cache in memory alone: the Store has
  no directory, every lookup is absent, every write is refused with no
  filesystem call, the scans do nothing, and writers ask has_directory first so
  nothing is encoded for it (a translated function still is: its encoded length
  weighs it in the memo). The device says so once as it is made, as the existing
  degrade notice ShaderCacheEntryNotWritten naming why; each entry it does not
  write counts in write_failures. The driver's pipeline cache data is not read
  back, and the device checks' verdicts are not encoded.
- A directory the caller names that cannot be used is still Error::ShaderCache.
- Device::shader_cache_directory answers Option<&Path>: None for such a device.

Docs: the shader_cache module docs, ShaderCacheOptions::directory,
write_failures, Error::ShaderCache, the degradation's declaration and its
docs/API.md entry, the runtime README (Windows default, error table), HOWTO,
create.rs's list of environment variables. api_signatures re-blessed;
docs/REFUSALS.md regenerated (a refusal's site function renamed).

Tests: tests::shader_cache's default-directory and no-directory-store unit
tests (plain gate), and the lavapipe/GPU device test
shader_cache_no_directory: a device made with an empty environment and no
caller directory is made, has no directory, makes four render states with two
functions translated once, writes nothing, and its notice is heard once.

Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and
degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0;
m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and
in_place_check, including the no-directory device test.
2026-11-15 09:10:25 -08:00
Anees Iqbal a1175662e7 RUNTIME 2355: Textures over buffers: a buffer of 16 KiB or more holds Metal's allocation, a heap's buffer its heap
A texture over a buffer whose texels run past the length was always a
copy: a shadow image or a staged texture buffer whose bytes past the
length lay in a tail of its own. Metal's texels there are the
allocation's: a buffer of 16 KiB or more holds its length rounded up to
16 KiB (allocatedSize), zero when made, and a heap's buffer reaches its
heap's end, whose bytes are the heap's.

Now a buffer the device makes in the Metal address space with a length
of 16 KiB or more takes that allocation (buffer.rs's metal_allocation):
its VkBuffer and placement are its length rounded up to 16 KiB, which
its first fill clears with the rest (Buffer::clear_first: the host's
clear of a Shared or Managed buffer, the device's fill of a Private
one), with no command of its own. A texture keeps in place the bytes the
buffer's memory holds for it (Buffer::texel_reach: the allocation, a
heap's buffer's heap to its end, a no-copy buffer's length), so such a
texture is made as one inside the length is: an image over the buffer's
memory where the device makes one, a texture buffer viewed in place. The
shader-visible ranges, robustness, copy reach (a blit past the length is
still refused) and exported sizes stay at the length. Heap, no-copy,
wrapped and exportable buffers, and every buffer under 16 KiB, take
their length; past what the memory holds a texture keeps its tail, as
before. The runtime has no buffer allocatedSize; a heap's size and a heap
texture's allocated_size are unchanged.

The tails conformance cases now lie in place: their comments say so,
and the texture buffer case drops its staged-texture-buffer allowance,
which no device can fire there any more (its view starts at 16384).

Tests: buffer_tail_device's last-texel case lies as over a buffer that
holds it inside its length, with no tail; a new case over a 20000-byte
buffer (64x128 packed, ending at 32768) reads zero in the padding as
made, lies as inside the length, lands a kernel's writes past the length
in the buffer's memory, takes no copy where it is an image over the
buffer, and refuses a blit past the length; the heap case lies in the
heap, its kernel writes landing in the heap's other buffer; a new case
over a heap's second buffer keeps its texels past the heap's end in a
tail; the no-copy and 4096-byte cases keep their tails.

Docs: buffer_texture.rs's Tails, linear_plan.rs's Length, docs/API.md's
accepted difference and StagedTextureBuffer entry, and a FAST-PATHS
cost-of-matching-Metal entry for the padding.

Checks: the jobs that compiled and ran this commit are named in the
lane's report.

Evidence (lane jobs): m3-max-32551 (msi): clippy runtime+conformance -D warnings 0; 2632/2632 runtime+conformance; fast_paths +
api_surface 34/34. m3-max-32578 (lavapipe) at the tip: touched 56/56 (buffer_tail_device incl. the allocation, heap and
heap-end cases, texture_placement_device, linear_plan, buffer_texture, degradation_catalogue); runtime+validation partition
1/4 1572/1572. VkMemoryRequirements on lavapipe for a 16385-byte buffer: 32768 (alignment 64). The padding is cleared by the
buffer's existing first fill (no new command). allocatedSize: no buffer API; heap sizes unchanged. The PHOENIX run, the
release creation bench and lavapipe partitions 2-4 follow in the lane. Conformance: buffer-tails cases now in place; the M3
venue's cost records for buffer-tails-* re-bless on development.

Lane commits: d2ee5bca5b (bench), a8f3796f59, ee54952340 (heap cases in a placement heap).
2026-11-15 08:14:12 -08:00
Anees Iqbal 0ca24685d7 RUNTIME 2351: Textures over buffers: Metal's allocation bound counts the last texel, a heap's size and a no-copy buffer's pages
A texture over a buffer whose texels run past the length was answered nil
where its rows' padding ended past the length rounded up to 16 KiB. The
M3 Max (macOS 27.0.1, the consumer's limits runs, every buffer kind and
length bisected) makes more:

- A 2D texture and a texture buffer count to their last texel, not the
  last row's padding: a 2D R32Uint 64x64 from 256, rows 512 apart, over
  20000 bytes is made with its last texel at 32768 (rows' end 33024); a
  texture buffer of 32768 R8Uint texels at a bytesPerRow of 36864 over
  20000 bytes is made. Arrays keep their rounded slices' end.
- A heap's buffer is bounded by the heap's size, counted from the
  buffer's start, whatever its length or place in the heap (4 MiB heap:
  made to 4194304, nil at 4194305).
- A no-copy buffer is bounded by its pages: its pointer's offset in its
  16 KiB page plus its length, rounded up to 16 KiB, from its start
  (16384 bytes starting 4096 short of a page's end: made to 32768).

BufferFacts now carries the buffer's allocation (own, a heap's size, a
no-copy buffer's page offset), filled from Buffer::heap, host_backing and
contents; BufferFacts::allocation_end gives the bound. Buffers under
16 KiB keep no bound (the M3 Max answers nil past 128 KiB there, the x86
Macs make every end measured), and an array whose last texel lies inside
the length is still made: no new refusal.

Such a texture stays a copy, as before at the old bounds: a 2D texture or
array is a shadow image whose copies in and back go through its tail
(texture/route.rs Route::Past -> TextureShadowReason::PastLength,
announced shadowed-texture), a texture buffer's functions view its tail
(into_texture_buffer, staged-texture-buffer). The texels past the length
live in the tail, zero when made; the caller's bytes past a no-copy buffer
and a heap's other bytes are never read or written.

Tests: tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does
(each kind's and form's M3 boundary, made at it and nil one past; the
made rows past the old bound fail before this change); device tests in
buffer_tail_device (a heap's buffer to its 64 KiB heap's size, a no-copy
buffer at page offset 12288 to 32768, a padded 2D texture to its last
texel): made, every path reads and writes right, the buffer's CPU write
inside the length is read through the texture, shadow copies counted,
no other memory touched, one row more Metal's nil. docs/API.md's
accepted difference, REFUSALS.md regenerated.

Evidence (lane jobs, msi): m3-max-32369: clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings 0;
linear_plan|buffer_texture 34/34 incl. tests::linear_plan::a_texture_ends_where_metal_s_allocation_of_its_buffer_does (the
M3's boundaries per kind and form, made at E, nil at E+1). m3-max-32370 (lavapipe): 13/13 buffer_tail_device + allocation
tests incl. a heap's buffer to its heap's size, a no-copy buffer to its pages, a 2D texture whose last texel ends at the
allocation: every path (get_bytes, blit, kernel) reads as made, writes coherent with the buffer's bytes inside the length
(shadow copies counted: such textures are shadows / staged texture buffers through their tail), neighbours untouched, one
row more Nil(PastAllocation). Negative control and the PHOENIX run follow in the lane.

Lane commit: 263219d515.
2026-11-15 07:15:50 -08:00
Anees Iqbal f851c07e52 SEMANTICS 2123 / RUNTIME 2349: Texture buffers past maxTexelBufferElements bound through views of their parts
Metal makes texture buffers of up to 2^28 texels on every Mac; one texel
buffer view holds at most the device's maxTexelBufferElements (2^27 on ANV
and lavapipe, 2^26 on MoltenVK), and the binding of a wider one was refused
(BindError::TexelBufferTooLarge).

The consumer now states with a texture buffer's binding the views its texels
take (BoundTexture::Buffer::parts, bind::texel_buffer_parts: 1 within the
limit), which its shape carries. A slot whose function only reads, writes,
updates by an atomic or asks the width of the texture buffer, on a device that
indexes texel buffer arrays NonUniform, states RuntimeFact::TexelBufferParts;
where the shape binds more than one part there, the plan asks for the parts
variant (VariantKey::texel_buffer_parts). Under it the slot is an array of
the parts' texel buffers: texel i is texel i - k*P of part
k = min(i / P, parts - 1), P the device's limit rounded down to its texel
buffer offset alignment (bind::part_texels), and the width (parts - 1) * P
plus the last part's. texel_ranges writes one range per part at its array
element (DescriptorRange::element), and the runtime views each.

Each part is the device's own view in the format one view takes, so a read
converts its texel as the one view does: no precision note. A texture buffer
one view holds keeps one view, no variant and its key. The families row
TextureBufferWidth is exact where the parts reach 2^28.

Still refused (TexelBufferTooLarge): a slot read through a sampler or used beyond read/write/atomic/width; a device
without NonUniform indexing of that kind of texel buffer array; formats with several texels a block. Argument-buffer
texture buffers past the limit stay the heap neutral (unnamed-texture-unviewable). New: WorkCounts::texel_buffer_parts_bound,
RuntimeFact::TexelBufferParts (appended), bind::part_texels / texel_buffer_parts, BoundTexture::Buffer.parts,
TextureShape::Buffer.parts (serde default 1), VariantKey/LoweringInputs.texel_buffer_parts (hashed only when non-empty),
DescriptorRange.element. SEMANTICS_VERSION bumped: input once refused now translates.

Evidence (lane jobs, msi): m3-max-32343 at 628264de17: clippy --workspace --all-features --all-targets -D warnings 0;
41 metal2vulkan tests incl. golden_hashes_match_the_table (every fixture's SPIR-V unchanged on every profile: one part is
byte-identical), the binder test (an under-limit slot: no parts entry, empty variant, layout counts 1), the interpreter
parts test (robust and unrobust), api_surface / api_signatures / refusal_surface; families::states_follow_their_sources;
lavapipe texture_buffer_width_device (R32Uint limit+64 texels: both sides of the limit and the last texel read and written,
past the end reads 0 and writes dropped, texel_buffer_parts_bound +3) and buffer_tail_device. Without the fix the device
test fails at bind: TexelBufferTooLarge{elements 134217792, limit 134217728} (m3-max-32140). ANV (2^27) is down; the XTX
(2^29) never parts.

Lane commits: 9fbf7d3c14, 7f7f3ad95e, 9a745ffb3c, 740e9e43dd, 628264de17.
2026-11-15 07:10:59 -08:00
Anees Iqbal 45e6784e91 RUNTIME 2348: ICB records the GPU never wrote are read in place, not staged
On a device that places indirect command buffer records by first use (no
unified memory, a staging queue), a host access of records in device-local
memory was staged whenever a command buffer held them or the buffer was
Private: the records it read were copied down through the staging queue and
waited for, counted, and staged-indirect-records announced. That held even
where the GPU never wrote the records, though then the host's buffer holds
exactly what device-local memory does.

The XTX conformance replay of development a88823f8f4 failed on it:
blit-copy-indirect-command-buffer announced staged-indirect-records. Its
range-none leg copies no commands into a fresh destination (an empty copy
holds nothing and marks nothing written), then executes destination command 0.
The execution's hold placed the untouched records in device-local memory, and
the commit, which records the execution from the CPU's records because no GPU
route met the buffer, read them through host_access while its own command
buffer held them: staged. The cause dates from 5dd3668a4f (RUNTIME 2294,
placement by first use); the last green XTX replay (06fd49b221, 11-11)
predates it, and the case's recording did not change.

Now host_access serves an access that only reads (Reach::Reads) records the GPU
never wrote (State::written false) in place: not staged, not counted, nothing
announced. A write of such records is still staged, for its copy back alone:
it no longer copies the runs down first.

Why the two sides cannot differ while written is false:
- placement (place_on_device) fills the device-local storage with zeros and
  writes encode_header's header, which is what the host's storage holds as the
  buffer is made (write_header: CommandBuffer::initialize's header and reset
  records, flags cleared; the reset record is all zero,
  metal2vulkan's indirect_commands/tests/records.rs
  reset_clears_action_and_bindings_to_zero). A Shared buffer the CPU touches
  before any GPU use is placed on the host for good; a Private one is placed on
  the device at its first host access, before that access writes.
- every CPU write of the records goes through records_access with
  Reach::Writes or Reach::Overwrites (reset_command, batch, the CPU reset), and
  while the records lie in device-local memory that access is staged with
  back = true, whose drop copies the written runs (records and written flags)
  back into device-local memory: home.rs line 222,
  `copy_runs(self.icb.generation(), records, host, &self.runs, false)`.
- every GPU route that writes the records holds them with writes = true, which
  sets written (home.rs line 320, `state.written |= writes`): a blit's copy and
  reset, and a compute or render encoder's use_resource with WRITE.
The move path already relied on the same fact (a move of a buffer the GPU never
wrote copies no bytes).

The conformance case needs no declaration: the notice was the runtime staging
where it need not.

Also: the runtime-lane test private_indirect_records_follow_the_memory_model
expects two staged accesses (its two setters), its getter now reading in place;
the docs of home.rs, Degradation::StagedIndirectRecords (and its cost),
WorkCounts::icb_records_staged_accesses and docs/API.md's catalogue entry say
which accesses stage. No new Degradation kind, no new counter.

Verification: in the job reports that follow.

Evidence so far (lane jobs): msi m3-max-32246 at cfcdb29780: the conformance binary and the m2v_gpu archives built; the
lavapipe replay (conformance replay --cpu) matches known-gaps.tsv (LVP_REPLAY=0). gem10 m3-max-32248: clippy -D warnings
plain, m2v_gpu and m2v_cpu_icd on runtime + validation = 0. The XTX replay and the new device tests (with the control at
76a78ec60a) follow in the lane's um790 job.

Lane commits: 76a78ec60a (tests), cfcdb29780 (fix).
2026-11-15 06:58:33 -08:00
Anees Iqbal b7053280de RUNTIME 2346: 4:2:2 textures over IOSurface planes: an image of their texels, decoded from the pairs in place
A GBGR422 or BGRG422 texture made over a buffer's bytes (Buffer::new_texture_with_iosurface_plane,
a CoreVideo 2vuy or yuvs plane, over a Shared buffer or a no-copy buffer's host pages) had no
decoded twin: twins are attached only to textures whose image is their own for good, so every
dispatch or draw that read or sampled it was refused, with a "needs R8G8B8A8_UNORM SampledImage"
line naming a format every device samples.

Such a texture is now an R8G8B8A8_UNORM image of its texels, the converted shadow a two-plane
YCbCr texture over planes already is (ShadowSource::Converted, its conversion now an enum of the
planes' and the pairs'): its copy in, before the first command of a command buffer that reads it
and after a command wrote the bytes, is one dispatch of the new bind::chroma_convert_module that
reads the pairs where they lie, at any byte of their VkBuffer, through one storage-buffer binding,
and writes Metal's texels (ChromaDecode, exact) through the image's R32_UINT view. Copies, blits
and CPU calls keep moving the plane's bytes. Where the device converts the pairs' format with
Metal's reconstruction (MoltenVK), the copy in is that conversion instead: the plane's rows copied
into the pairs' image, sampled through the conversion (chroma_sample_module) into a scratch,
copied into the image; announced decoded-texel-precision at the copy in's planning. The set binds
the buffer's VkBuffer, so the planning makes it again after a rebind gave the buffer another one,
and each command buffer holds the set it took. The placement query answers OtherShape. A plane
the window cannot take (past maxStorageBufferRange, a last word past the buffer, rows that share
bytes, texels past the buffer; with the device's conversion, a first byte or rows off 4 bytes)
keeps the carrier, its reads refused; FAST-PATHS records it as a known gap.

Per frame, per texture (w x h texels): before, no read ran at all; the texture was an R8G8_UNORM
carrier of the plane, 2 bytes a texel. Now no byte is copied: one dispatch reads the w*h*2 bytes
of pairs in place and writes w*h*4 bytes of texels (1920x1080: 4147200 read, 8294400 written).
Memory: one R8G8B8A8_UNORM image, w*h*4 bytes (1920x1080: 8294400), in the carrier's place; with
the device's conversion also the pairs' image (w*h*2) and the scratch (w*h*4), and per copy in a
w*h*2 copy in and a w*h*4 copy out. Announced carried-decoded-twin (an existing kind) with that
cost. No new Degradation kind, no new WorkCounts field.

A carrier's binding without a twin is now refused NotImplemented(Format) naming the texture's
format (pvrtc::holds_for_copies), not a need of the twin's view format.

Public surface: metal2vulkan::bind::{chroma_convert_module, ChromaConvertModule} added
(api_signatures.tsv blessed, api_surface table); docs/REFUSALS.md regenerated (one more
binding_view site of Format).

Tests: the in-place kernel against ChromaDecode's decode under the interpreter (both orders, first
bytes off a word, odd sizes, rows apart); a carrier's binding refusal (binding_view unit test);
a device test of both formats over a Shared buffer and over host pages reading Metal's measured
bar values (an Apple M3 Max, macOS 27.0.1) and Metal's decode of a random frame written on the
CPU before the next command buffer, OtherShape from the placement query, and the device's
conversion counted and announced where it converts. Verification jobs follow in the lane report.

Evidence (lane jobs): msi m3-max-32240 at 94f603bf35, --cfg m2v_cpu_icd on llvmpipe: 130/130 touched tests, clippy -D warnings 0;
the device test fails without the fix (placement not OtherShape, the read's dispatch refused). PHOENIX gem10 m3-max-32260
(archive m3-max-32241): all 4 cases (GBGR422/BGRG422 over a Shared buffer and over host pages) "Metal's texels, exact"
for the M3's measured bars and a random CPU-written frame; ycbcr_device, ycbcr_refresh, twin_reads 7/7. MoltenVK (device form)
run on the M3 follows.

Lane commits: 735234d5f4, d59f44baa6, 94f603bf35.
2026-11-15 06:48:09 -08:00
Anees Iqbal 7ba0cd9fe6 RUNTIME 2343: GPU times placed by a calibration still beyond 20 us are announced and counted
A calibration pair is read again while the smallest deviation so far
states more than 20 us (`gpu_time::SETTLED`), four readings at most
(`least_deviation`). Where the least of four still stated more (93 and
125 us on the RX 7900 XTX under full parallel suites: a reading's
deviation holds the time its thread spent off the CPU), the runtime
placed the command buffer's GPU times by it, inside the command
buffer's life, with up to that error, and said nothing. Owner rule 2:
a near-equivalent is recorded and announced.

`GpuClock::span` now answers `Placement::Loose { deviation }` where the
pair places both times inside the life and its deviation exceeds
`SETTLED` (a pair outside the life is still set aside as before).
`Placement::read` gives the notice for every placement the first read
of a command buffer's GPU times announces, counting a loose one:
- new kind `Degradation::LooselyCalibratedGpuTimes`,
  `loosely-calibrated-gpu-times`, class Precision, announced once per
  device at the read (the site `uncalibrated-gpu-times` uses), its
  reason stating the deviation; not `uncalibrated-gpu-times`, whose
  cost says the times are placed by the completion, where these are
  the pair's, the duration exact;
- new `WorkCounts::loosely_calibrated_gpu_times`: command buffers
  whose times a read found placed so, counted at the read that
  announces, so the count is nonzero exactly where the kind was
  announced.

Tests: `tests::gpu_time::a_pair_still_beyond_the_settled_deviation_is_
announced_once_and_counted` feeds `least_deviation` a fake source of
four readings above 20 us (Loose, the kind with the deviation in its
reason, each read counted, announced once) and settled ones (Iris
Xe's 165 then 7.6 us; 20 us exactly: Calibrated, nothing), and a loose
pair outside the life (Disagreed, the uncalibrated kind, not counted).
The lane's `gpu_times` expects the kind exactly where counted, and holds
the count nonzero exactly where `calibration_deviation_most` exceeds
the slack (no disagreement); `read_kinds` adds it where counted
(mesh_draws), `disagreeable_kinds` allows it (first_use); a site const
`LOOSE_GPU_TIMES` takes it. The conformance cases that read GPU times
(`command-buffer-facts`, `empty-command-buffers`) allow its notice:
the host's load decides it, and every value still compares exactly.

docs/API.md's catalogue lists the kind; api_signatures.tsv blessed.
2026-11-15 05:18:59 -08:00
Anees Iqbal ec0be064d0 RUNTIME 2342, SEMANTICS 2122: Texture buffers read through argument buffers sit in texel-buffer heap classes
A pipeline whose argument buffers hold texture buffers was refused with
ArgumentBufferTextures (NotImplemented, no location): the translator's heap layout
(lower/texture/slot.rs declare_heap) had no set-1 class for a texture_buffer member, so
SPIRV-Cross-shaped tier-2 argument buffers (descriptor sets as [[buffer(n)]] structs with
texture_buffer, texture2d and sampler members) could not be made, on any device.

- Set 1 gains texel-buffer heap classes: UNIFORM_TEXEL_BUFFER for read, formatless
  STORAGE_TEXEL_BUFFER for read_write and write. The class follows the facts' texture type.
- DescriptorCaps gains update_after_bind_uniform_texel_buffer and
  update_after_bind_storage_texel_buffer; where a device lacks them a typed needs_any_of names
  the missing features. Non-uniform texel-buffer indexing and the without-format read/write
  needs are checked as for images; link counts STORAGE_TEXEL_BUFFER with the images against
  the update-after-bind limits.
- New public bind::heap::HeapElement::TexelBuffer(vk::Format).
- The runtime writes each live texture buffer's texel view at its resource ID, with a neutral
  texel view at element 0; a gone texture buffer's Texels stay alive until its tickets clear.
  A texture buffer whose bytes cannot be viewed in place (staged, tail-viewed, offset off
  minTexelBufferOffsetAlignment, past maxTexelBufferElements, swizzled, or a non-direct format)
  reads the neutral and is announced through the existing UnnamedTextureUnviewable. No new
  Degradation kind.
- docs/REFUSALS.md and api_signatures.tsv regenerated.

Test: runtime_lane::argument_texel_buffers::a_texture_buffer_in_an_argument_buffer_is_read_in_both_stages
(an owned fixture in SPIRV-Cross's shape): vertex and fragment read a texture_buffer member of a
set-0 argument buffer, the fragment also samples a set-1 texture2d through the sampler beside it;
every pixel must equal texel[1] + texel[4]*tint + albedo.

Verified: lavapipe with the validation layer, m3-max-31658 at 6626eeaff3: pass. Control
m3-max-31636 (the fixture and test at the base, without the fix): fails with exactly the
ArgumentBufferTextures NotImplemented refusal.
2026-11-14 23:33:03 -08:00
Anees Iqbal 1b5a527f5e RUNTIME 2340: Scheduler: a host step at its gate whose batch's uses are known keeps its place
What: since a7e519150b (RUNTIME 2326) a batch held for its host step, once
the step took its gate, gave way to every later commit of another queue but
for one that writes what the step reads on the host (its executions' records
and ranges) or shares a fence with it. That rule was for a step whose uses
commit could not bound (a shadowed texture's copies, tile memory, a
visibility query, an inherited function table): its footprint is not known,
so keeping its place held every queue's tracked work. It also applied to a
bounded step, whose footprint names what its commands may reach, and there
it let a later commit that conflicts with those uses go first, against the
commit order the M3 keeps:

- runtime_lane::queue_order::a_copy_committed_while_a_write_waits_for_its_
  host_step_holds_it: queue B's copy of the buffer A's indirect commands
  write (made resident for writing) went before A's execution and read
  zeros;
- runtime_lane::steps_apart::another_queue_goes_on_while_a_host_step_records:
  a pass into A's target on another queue, committed after A's, began its
  host step while A's step still recorded.

Now the step's host reads are kept for giving way only where the batch's
footprint is not known (CommandBufferShared::footprint's None). A batch
whose uses are known keeps its place from its gate on, as before a7e519150b:
a later commit of another queue that conflicts with them waits behind it,
and one that shares nothing with it goes (the compositor's fill of
tests::held_step_order). The step whose uses are not known still gives way
but to writers of its host reads, so held_step_order's unknown-uses leg is
unchanged. Docs: the scheduler's and order.rs's rules, Held::gate_reads,
place_of, is_behind, WorkCounts::heads_held_for_earlier_commits and the
host-replayed-indirect-commands notice (degradation.rs, docs/API.md).

Bisect (lavapipe, the two tests alone): 06b5fe355e, a7e519150b's parent,
passes both (m3-max-31546); a7e519150b fails both with pin 97's messages
(m3-max-31547). This commit's proof (the two tests, held_step_order's three
legs, the catalogue, clippy) is in the lane's report.

Fixes pin 97 (eee64c8668) lavapipe and 780M failures queue_order::a_copy_committed_while_a_write_waits_for_its_host_step_holds_it
and steps_apart::another_queue_goes_on_while_a_host_step_records, both bisected to a7e519150b (RUNTIME 2326; parent
06b5fe355e passes, m3-max-31546/31547). RUNTIME 2326 was for the RTX 3090 89 ms rate-mapped pass, a step whose uses
were not known (it held every queue; a bounded footprint holds only what conflicts with it). That case keeps its give-way:
held_step_order visibility-query leg passes. Compiled in m3-max-31554 (msi: clippy; lavapipe both tests, queue_order,
held_step_order fill legs, degradation_catalogue, replayed_frames footprint-once).
2026-11-14 22:54:44 -08:00
Anees Iqbal 734e1cac02 RUNTIME 2339: Bind a slot read at its residual over a range its bind offsets share
What: bind::instantiate::shared_range gives a descriptor-form slot of a
Bounded window that its functions read at the residual one range for a run
of bind offsets of the bound buffer: the padded buffer from 0 where it fits
the view's maximum range (and 4 GiB), else the block of half that maximum
its window starts in, to the maximum past the block's start; its
SlotBindOffset residual the rest. A window of at most half the maximum never
straddles its block's range; a longer one, or one at or past the padded end,
keeps descriptor_range's range. planned_range takes it for every Bounded
storage view (no function reads one at its bind offset alone), and for a
uniform view where the new BindState::uniform_views_at_residual says the
consumer reads every uniform view at its residual: its keys all take their
residual forms. The runtime states it where pipeline::reads_views_at_bind
does not hold (every device today: no driver carries
DriverFact::ConstantOffsetUniformReadsPreloaded), through AtBindViews, at
each bind state that states the view base alignment (render, compute twice,
tile dispatch). Shapes, plans and keys are unchanged; the flag is not part
of the shape.

Why: a constant reference at a buffer index (constant float4 &) is a uniform
view of a 16-byte Bounded window, whose range started at the bind offset
with residual 0. Every offset-only rebind (a consumer's staged
setVertexBytes: setVertexBuffer at the next 256 bytes of an upload chunk)
then wrote another descriptor: rebind_into, push_set and the driver's
vkCmdPushDescriptorSet at every draw (reims-vgpu's Iris: +538 ns a draw
against a device pointer, +93 inside the push and +99 under record). The
range at the bind offset serves only keys reading the view at the bind
offset alone, which no device takes today: the shader already adds the
residual. Now such a draw keeps its set-0 writes (writes_kept) and pushes
only its residual, as a device pointer's draw does.

Metal and Vulkan: each read inside the window reads byte
lo + (bind - lo) + m = bind + m, the bytes it read before, through the same
instructions. A read outside the window, which Metal leaves undefined,
reads the buffer's bytes inside the range. The range starts at 0 or a block
multiple, a multiple of the base alignment
(VUID-VkWriteDescriptorSet-descriptorType-00327/00328), stays within the
view's maximum (00332/00333) and the padded allocation
(VUID-VkDescriptorBufferInfo-range-00342); a dynamic descriptor's offset is
its start as before (VUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971).

Verified: by the jobs that follow (unit tests of shared_range and
planned_range, the lavapipe runtime test
constants_moved_along_one_buffer_keep_their_set_zero, the release medians
of runtime_lane::constant_offsets before and after).

With (bench and tests): 78463d1e1d The moved-constant set-0 test counts every second draw again as taking every step in builds with debug assertions; 5e7d715629 The moved-constant set-0 test lists which of the second pass's draws were rebound; 99a3459dc6 The moved-constant set-0 test moves the vertex constant alone, as constant_offsets does; a9c4b07790 The moved-constant set-0 test names what the second pass's draws did where some were not moved; 5e938c75c5 The moved-constant set-0 test draws the bench's shape; a bounded storage window's dispatch test binds the shared range; 69e598a6b5 Drop the stale copy of the range-from-bind-offset test; round-trip the new BindState field; ea4602012c cof_device reads its float4 at the instance's element; cd6492fd41 constant_offsets also draws over chunks in host pages, under the consumer's policy; 4d6e17bb89 constant_offsets takes the AIR library trait into scope; 1221f53ce0 Time draws that rebind a constant reference by offset against a device pointer.

Compiled in m3-max-31548 (msi: clippy, lavapipe uniform_bind_offsets/draw_again/general_form/inline_continues/
kept_shadowed_draws 48/48). The set-0 test fails at the base (16 writes pushed, want 0; 31536). Release counts
(31392): set-0 pushes per constant draw 1.00 -> 0, push constants 0 -> 1.00. The new fixture's golden rows re-bless
on development.
2026-11-14 22:47:14 -08:00
Anees Iqbal 5fcd8be7de RUNTIME 2337: A pass's first draw that samples a color the pass clears reads its copy cleared to the clear, with no barrier too
A draw that samples a texture its own pass renders reads the texture's shadow, a copy taken
before the pass's load actions (texture/attached_reads.rs). In a pass that clears the color, a
first draw that sampled it with no barrier read the texels from before the pass at every pixel it
read: the M3 Max's answer, while both x86 Macs read the clear there (probe ownread: no draw
before it, so the load and the draws before it wrote only the clear). The copy was cleared to the
clear (Texture::cleared_copy, vkCmdClearColorImage) only after a memory barrier before the pass's
first draw.

The Macs disagree, so Metal's answer is either; the macOS guests are x86 ones, and a clear of the
copy costs less than a copy of the texture. RenderLowering's draw now takes the cleared copy for
every draw that samples a color the pass clears before any draw of the pass recorded, wherever
Texture::cleared_copy holds (a whole single-sampled 2D texture of one level and slice that one
color renders in place), with a barrier before it or none; the draw keeps nothing to draw again,
as after the barrier. A pass that loads the color, and every read outside cleared_copy, read as
before.

Tests: attachment_reads' no-barrier lane becomes a_first_draw_with_no_barrier_reads_its_pass_s_load,
Load and Clear over both target kinds, the texture of its own image taking the cleared copy
(attachment_read_clears) and reading the clear where the pass clears; check() counts a cleared
copy as taking no split's place with no barrier. framebuffer_fetch gains
a_first_fetch_after_a_clear_reads_the_clear (a fetch after a Clear reads the clear, not the texels
from before the pass). The conformance rows pass-start-barrier-*-sample with no barrier accept the
clear too, as the -read rows did. docs/API.md's accepted differences and attached_reads.rs's docs
say which Macs answer what.

Verification: the jobs that compile and run it are reported with this sha.

With: 645f1c3323 snapshot_reads' first test makes its readers' pipelines before the counted pass; af0a44cc6d The render lanes and inline-split tests read their fixtures where the test runner names the crate; 8b5cd6dfb4 attachment_reads' first-draw lane lets a target over a buffer's bytes take the cleared copy too (test-only).

The user's GitHub issue 17. Compiled in m3-max-31319 at 8b5cd6dfb4 (clippy x3; lavapipe lanes, the first-draw lane, the
fetch-after-clear lane, the 14 pass-start-barrier conformance rows exact and default; the negative fails).
2026-11-14 22:00:02 -08:00
Anees Iqbal 7b1725eb34 RUNTIME 2336: Lay no more of a predicated loop's copies than keep its waiting host steps within 16
On RADV, runtime_lane::predication::every_dispatch_form_runs_in_each_pass_past_the_copies ran
40-77 s alone and passed its 60 s wait for one command buffer under the suite. The cost is the
runtime's, not the test's breadth: each piece of work a host step records after the GPU's work
before it (an indirect dispatch of a kernel that observes its partition, an indirect command
buffer's execution inside a block) is its own batch, a round trip to the host (submit, wait for
the GPU, record, submit) in every run of a loop's laying, whether its copy's pass runs or skips.
A loop was laid down as 64 copies (16 inside another), bounded only by its commands
(LAID_BUDGET), so the test's inner DoWhile of 20 + 1 passes inside a DoWhile of two laid 1024
copies of its body: measured on lavapipe at the base (msi job m3-max-31287, a timing probe), its
command buffer's first run recorded 4097 host steps and made 8195 submissions (6145 and 12291 on
the device without device addresses, whose step form records six such pieces a pass), where its
21 passes ran 84 (126); the DoWhile of 100 passes 257 (385). That command buffer was 94% of the
test's 21,772 submissions, and each costs a GPU round trip, a few milliseconds on RADV.

copies_of now bounds a loop's copies by a second budget too: the work apart whose host step waits
for the GPU (Deferred::gpu_written) that its copies lay down, at most WAITED_BUDGET (16), counted
as LAID_BUDGET counts commands, from the first copy's, inner loops' copies included
(Predication::waited, Looping::waited_at). A loop of no such work keeps its 64 or 16 copies. A
loop that ends before its copies pays at most 16 round trips for the copies it skips, and one that
runs past them one more round trip, its check, per 16. The run-again path, unchanged, takes any
count of copies down to one.

Tests: every_dispatch_form_runs_in_each_pass and the failing test assert each loop's first run
records at most 16 host steps and the check (257 and 4097 at the base: the negative control);
the 100 passes no longer run again exactly once. docs/API.md and docs/RUNTIME-PORTING.md name the
new bound.

With abd0662e9f: the budget trades nothing for accuracy, so it has no FAST-PATHS row.
2026-11-14 21:39:26 -08:00
Anees Iqbal fdea9b585a RUNTIME 2333: On a device whose image uses miss buffer writes in one VkCommandBuffer, an end-recorded render pass joins after byte writes and splits only where its images meet them
A render encoder whose pass records at its end joins a group after byte writes, split before its pass where it meets them

On a device where DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer
holds (the RTX 3090), State::join_fold let a render encoder join no group
whose earlier encoders wrote bytes. Every render encoder after a compute or
blit write of any buffer then began a VkCommandBuffer of its own: a chain of
dispatch, draw and copy took 7 VkCommandBuffers where it took 1 elsewhere
(render_fold at pin 96). The defect is narrower: an image use after a
buffer write over the image's memory in one primary.

The join now stands on that device as on any other, and the split goes
before the pass where the pass uses such an image:
- Each draw a pass recorded at its end notes its uses apart, into its
  secondary (EncoderCore::record_aliased); where one uses an image whose
  memory meets the bytes noted written in the VkCommandBuffer (the group's
  FoldOrder::byte_writes and the encoder's own), the encoder owes a split
  (AliasWrites::noted_apart).
- The first command it then records into the VkCommandBuffer, a shadow's
  copy before a later draw or the steps and pass at its end, whose uses
  hold the attachments', goes in a new one where it owes one or its own
  uses meet the writes (AliasWrites::meets). An unordered encoder's shadow
  copy now takes the check too (EncoderCore::shadow_command).
- A pass whose first instance records inline still joins no group
  (Fold::admits): its draws record from the first on.

render_fold's counts go back to one VkCommandBuffer for the chain on every
device (no lane's pass uses an image over written bytes). heap_textures
gains the render analogue of the measured lane: a blit's copy into a
tracked heap's buffer, then a render encoder's draw reading the texture
over those bytes (recorded at its end), its pass loading and storing that
texture (at its end), and a draw reading it in a pass recorded inline,
each asserting every texel is the copy's, the join, and a split where the
fact holds for the two recorded at their end (none for the inline one).
The render functions are an owned fixture, examples/heap_draws.metal.

A texture reached through a heap made resident (useHeap:) is a read of
the heap's bytes, which meets no write; alias_split.rs says so.

Verified: cargo fmt; the fixture's regen check (metal-as round trip, LLVM
21 llvm-as). Clippy, the runtime and validation suites and the device runs
(the 3090 with a negative control, a non-splitting device) follow.

alias_split: a write after a draw noted apart, over its image, splits before the pass; use_heap guard lanes

The draw-time check of the narrowing (a render encoder whose pass records at
its end joins a group after byte writes) checked each draw recorded apart only
against the writes noted by the time of the draw. A command recorded into the
tail after that draw, but before the pass (a shadow's copy, or an emulated mesh
or tessellation dispatch writing guest bytes), adds writes the draw's images
were never checked against. The draw still runs after them, inside the pass
the encoder records at its end, in the same VkCommandBuffer: the defect the
split guards (DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer, the
RTX 3090).

AliasWrites now also notes the memory the images of the commands recorded apart
use (`apart`). That list is per encoder and bounded like the writes: at most 32
keys, each key's ranges joined into one, and past that every range meets.
note() sets the owed split where a new write meets one of those images. The
check is now order-free: every image a pass's draws use is checked against
every write recorded before the pass. begun() clears the writes and the debt
but keeps `apart`, since those draws still run after whatever the new
VkCommandBuffer records before the pass. The draw-time check and the write-time
check share one bounded range set (`Noted`). UseRange::image_bytes gives an
image's place as shares_memory takes it.

The draft's scope sentence about useHeap: was wrong (devlegs agrees). A texture
of a heap made resident is its own Used::Texture token. bind's used_uses lists
it for any function that reads a texture, and resident_uses_into gives it a
Texture::bound_use image use. Two heap_textures lanes now guard that path. In
each, a blit writes the heap buffer, then something reads the texture over
those bytes only through an argument buffer, with use_heap and no
setTexture:
- a draw of a pass recorded at its end (read_argument_fragment);
- a dispatch (read_argument_kernel).
Each asserts that every texel shows the write, that the encoder joined the
blit's group, and that the split count is > 0 exactly where the fact holds. The
lane enum is TextureUse now (it covers a dispatch), the function
blit_write_then_texture_use. The fixture heap_draws.metal gains the two
argument-buffer functions (regenerated with scripts/regen-air-fixtures).

Verified: cargo fmt; the fixture regen (metal-as round trip, LLVM 21 llvm-as).
The unit test a_write_after_a_draw_noted_apart_over_its_image_splits_the_next_command
fails without note()'s new check. Builds, clippy and the device runs (with a
negative control on the 3090) follow in jobs.

Verified: job 31175 at ceb7e56415: clippy -D warnings (runtime and
validation, all targets and features), the alias_split unit tests 6/6. Job
31177 on lavapipe (--cfg m2v_cpu_icd): 25/25 (the blit-write lanes,
a_buffer_write_shows_in_an_overlapping_texture, the 13 render_fold lanes
at the non-split counts). Job 31176 compiled the --cfg m2v_gpu archive.
The 3090 tip and negative control and the 780M (31189) and the 5080 entry
are pending.
2026-11-14 20:36:13 -08:00
Anees Iqbal 3625b90721 SEMANTICS 2121 / RUNTIME 2331: A kernel's unit-axes variant, taken once made, never waited for
A kernel's unit-axes variant: the translator and the binding plan

In a threadgroup of one thread along an axis (Metal's threads_per_threadgroup 1
there), every thread's thread_position_in_threadgroup on that axis is 0 and its
thread_position_in_grid is its threadgroup's position, partial threadgroups
included. A kernel whose emulated simdgroups are walked predicated only because
such a position steers a synchronization (a simdgroup sum in a loop whose trip
count reads gid.y, the shape of a depthwise convolution dispatched in 8x1x16
threadgroups) pays the predicated walk's live flags and votes for nothing.

- lower::simd::uniform tracks per-lane masks for vectors of up to 8 lanes, and
  takes the lanes of thread_position_in_threadgroup and thread_position_in_grid
  on the unit axes LoweringInputs::unit_axes names as uniform.
- A kernel walked predicated (divergent::barriers, workgroup::check) states
  RuntimeFact::UnitAxes { axes: 0, relief }: bit m-1 for each mask m of axes
  under which fewer of its synchronizing blocks stay divergent (one analysis
  for all three axes, then the six others only where that one relieves).
- VariantKey::unit_axes compiles the variant; its module states
  UnitAxes { axes, relief: 0 }.
- BindingPlan::unit_axes_variant offers the variant to a dispatch whose
  threadgroups have one thread along relieving axes, where the plan's own
  variant runs it; the variant's plan sends any other dispatch back
  (dispatch_variant, NeedsVariant).

SEMANTICS_VERSION 2121: a predicated kernel's artifact states a new fact.
No new Degradation kind.

Test: engine_simd_unit_axes (lavapipe's profile, CPU interpreter, 8/16/32
lanes): predicated without the variant, unpredicated with it, Metal's words
in both; the variant traps at two threads along y (Vulkan's barrier rule), unit
x relieves nothing, and a kernel steered by x is offered no variant for unit y.

The runtime takes a kernel's unit-axes variant once it is made, never waiting

A direct dispatch whose plan offers the unit-axes variant
(BindingPlan::unit_axes_variant) takes it only where its translation is
done and each of its regions' VkPipelines is made (pipeline/unit_axes.rs).
Otherwise it settles on its plain variant, which gives the same answers,
and the variant is begun: its translation as a piece on the pipeline pool,
kept by the state (piece_holds.rs), at the first such dispatch; its objects
and pipeline notices on the program's thread at the next (no piece announces
a notice), with its regions' makings handed to the pool as any dispatch's
are. Nothing waits for the translation or a making. A dispatch planned
meanwhile is kept neither in the state's latest plans nor in its encoder's
memo, so a later one asks again. A refused translation or a failed making is
remembered, the plain variant then running those dispatches; the state tracks
at most VARIANTS such variants at once, and they live among its VARIANTS
others.

The dispatch that begins it is recorded for a later process's warm pass,
which compiles the variant and makes its regions beside the plain variant's.

The one-row and emulated-simdgroups variants are still compiled on the
encoding thread when a dispatch first asks (ComputePipelineState::settle ->
variant -> Variant::compile); this path does not follow them.

WorkCounts: unit_axes_variants_begun, unit_axes_dispatches,
unit_axes_meanwhile. No new Degradation kind. docs/API.md section 3 and the
bind module's docs state the rule and the variant; api_signatures.tsv
blessed.

Test: tests::unit_axes (m2v_gpu / m2v_cpu_icd): a 16-thread threadgroup
kernel whose simdgroup sum sits in a loop steered by gid.y; 4x2x2 never begins
the variant; 8x1x2 begins it once, runs on the plain variant meanwhile, then
settles on it, Metal's words every time.

A unit-axes variant's objects are made under its state's lock of begun variants

Two dispatches of one state could both find a translated variant gone from
the begun set while the first made its objects, and the second begin its
translation again. The first now makes them under the lock, as variant()
compiles under the lock of the state's variants.

Public: RuntimeFact::UnitAxes { axes, relief }, VariantKey.unit_axes,
LoweringInputs.unit_axes, BindingPlan::unit_axes_variant; WorkCounts
unit_axes_variants_begun, unit_axes_dispatches, unit_axes_meanwhile. No new
Degradation kind.

Verified: job 31119 at 58f7ef3c21: workspace clippy under --cfg m2v_gpu,
metal2vulkan with no feature and each feature alone, rustdoc -D warnings.
Job 31118: metal2vulkan + runtime suites 5187/5188; the one failure is the
golden hash table (24 cells of rfs_async_copy_{1,2,4}, the expected
SEMANTICS change), re-blessed on development. Job 31098 at c7f44ff865: the
engine test tests::engine_simd_unit_axes and the runtime test
tests::unit_axes on lavapipe. Iris compile-only replay of a guest's records
(31117): one depthwise state takes the variant (driver estimate 2.47M ->
0.57M cycles, spills 179:340 -> 0); the GPU-time A/B is pending.
2026-11-14 20:23:55 -08:00
Anees Iqbal e7b9c5bfdc RUNTIME 2329: A GPU route's commands are drawn one draw per command in the replay variant, indexed
The GPU route of a rate-mapped pass's host step drew each command's corners
in its merged variant: a non-indexed draw of every index, which loses the
indexed draw's vertex reuse and looks its command up per vertex. On the
Iris Xe the wide frame's pieces took 74.2 ms against 48.0 ms when the host
read the records (job 30850).

Now the step reads back each command's VkDrawIndirectCommand and its index
entry (the device address of its first index and its index size,
bind::DRAW_INDEX_ENTRY_BYTES, now public), resolves the index address to
its Metal address through the resident set's ranges and the live table's,
and draws each command as the host draws a record it read: indexed where it
is, with its instances, base vertex and base instance, in the state's
replay variant (BufferForms::Replay), each draw pushing the command's own
slot tables at its PushHole::RootTableAddress holes (CommandTables). The
commit's settle begins the replay variants for the routed executions. The
corner cutting in the piece loop goes: an indexed routed draw is cut into
index ranges as any.

Tests: the pixel and depth test asserts indexed draws are recorded on a
routed frame; the count test runs three frames, the host step making no
pipeline on any and nothing made at all on the second and third.

Public: bind::DRAW_INDEX_ENTRY_BYTES (api_signatures, api_surface).

Verified: job 30942 at the branch tip: clippy for metal2vulkan and the
runtime, the runtime under --cfg m2v_cpu_icd, the runtime and validation
under --cfg m2v_gpu; the two route tests on lavapipe. Job 30922: lavapipe
suites 78/78, API tests 15/15, rustdoc -D warnings; a negative control
(the change reverted but its tests) fails the pixel test with 0 indexed
draws recorded. The Iris and 3090 GPU-time A/Bs are pending.
2026-11-14 19:20:14 -08:00
Anees Iqbal a7e519150b RUNTIME 2326: Scheduler: a host step held at its gate gives way but to writers of its reads
What: a batch held for its host step, once the step took its gate, kept its
place in the order across queues, so every later commit of any queue whose
footprint conflicted with it waited host-side until the GPU work before the
step completed and the step recorded. A step whose uses commit could not
bound (shadowed textures, tile memory, a visibility query, an inherited
function table) conflicts with every batch that makes a tracked use, so it
held every queue, the compositor's unshared queues included. On an RTX 3090
a rate-mapped pass executing a GPU-written indirect command buffer held every
queue's commits for the 89 ms pass before it in its command buffer.

Now such a batch gives way, as it already did before its gate (the x86 Macs
take a later commit of another queue first; the M3 keeps commit order), but
for a later commit that writes what the step reads on the host (its
executions' records and ranges), which the gate does not cover, or that
shares a fence with it. The batches after it on its line give way with it.
A step whose host reads are not known (staged gathers and scatters, indirect
dispatches, loop checks, predicated executions, indirect sparse updates)
keeps its place from its gate on, as before.

How: Held keeps the step's host reads as a footprint when the gate is taken
(CommandBufferShared::step_host_reads, step_reads without the bounded-uses
requirement; Footprint::of_uses); place_of answers GivesWay for it; the
order's comparison for a batch that gives way checks fences and, for such a
step, a later write of its reads. Order itself is unchanged. Docs: the
scheduler's and order.rs's rules, gate_of, WorkCounts, and the
host-replayed-indirect-commands notice (degradation.rs, docs/API.md).

Verified: tests::held_step_order on lavapipe, three legs (results in the
report): an unshared queue's fill while the pass waits at its gate, the pass
bounded and not, goes with no look held behind it; a reset of the records the
step reads still waits behind the pass's batch. Before this change the
unbounded leg's fill went 111.40 ms after its commit, 0.2 ms before the pass
(m3-max-30848 at cd77de72d8, 3 looks held).

Also in this landing: cd77de72d8 Test: an unshared queue's fill waits for no other queue's host step.

RUNTIME 2326: an unchanged artifact's later commits on other queues no longer wait behind a host step held at its gate.
Proof (m3-max-30854, lavapipe): held_step_order's unknown-uses leg 0.17 ms after commit, 0 looks held (base 111.40 ms,
3 held); a reset of the step's records still waits. Negative control m3-max-30866 (the old gate condition): that leg
fails, 125.03 ms, 4 looks held.
2026-11-14 18:35:15 -08:00
Anees Iqbal f40cc8595b RUNTIME 2325: A rate-mapped pass's host step decodes GPU-written records on the GPU (its GPU route)
A render pass over a rasterization-rate map that executes an indirect command buffer the GPU
may write goes to the host step. There the host read every record, decoded it and drew each
command through the probe and the fan-out routes. On the consumer's RTX 3090 that step took
44.7 ms of a 65.8 ms frame, reading 781 records a frame. The only rule its executions broke was
the rate map's.

At a host step that fans the pass's triangles out, an execution whose records the GPU may write,
and which takes its merged GPU form once the rate map's rule is passed over (the cause.rs
decision), now takes its GPU route (render/executions/gpu_route.rs):
- The step records the form's prework: the head, the preprocess and the two merge passes. It
  copies each command's first corner and the merged draw's two VkDrawIndirectCommands to the
  host, submits that with a fence and waits, as it does for its probe.
- The host reads those words and no record. Each command that draws becomes one direct draw of
  its corners in the state's merged variant, with the merged header pushed
  (RenderLowering::merged_header).
- The probe and the routes take those draws as they take commands the host read: probed, then
  fanned out, boxed, in parts or region by region. A long corner draw is cut into piece-sized
  ranges, as an indexed command is.
- The host reads the records as before where the total reaches MERGED_CHUNK corners, where the
  prefix does not rise to the total, or where the prework did not complete.

RenderExecution::record_gpu's prework moves into RenderExecution::prework, which both paths
share. The replay loop takes a GPU route's corners beside the records the host read (Replayed,
StepCommand). The new counters are WorkCounts::rate_map_gpu_routes and
rate_map_gpu_route_wait_nanos.

Tests:
- New, tests::rate_mapped_gpu_route. Eight commands of a buffer that inherits the encoder's
  pipeline state: grids, one in two instances, one without indices, and the large, medium and
  wide triangles the probe flags. Each command is nearer than the one before, under LessEqual
  depth and half-alpha blending. It asserts no record read, one route, one probe and three
  flagged draws, and that the colour and Depth32Float bytes equal the encoder's own draws.
- Changed, tests::host_step_rules. Its empty command, through the route, counts as
  nothing_to_probe.

Also in this landing (the lane's later commits):
- d2728b735e: the step's commands are one vector of reads or of corners (no per-command enum of 3.3 KB); clippy.
- 51afad9359: HostReplayedIndirectCommands' cost names the GPU route's second round trip (the notice's text changes).

RUNTIME 2325: an unchanged artifact's rate-mapped host step now decodes GPU-written records on the GPU, and the
notice's text changes. Negative controls (m3-max-30703): the plan.rs lifts reverted fail
a_merged_draw_s_variant_fans_out (NotImplemented(RasterizationRateMap)); the route turned off fails
rate_mapped_gpu_route's counts ([8, 0, 1, 3] against [0, 1, 1, 3]).
2026-11-14 17:40:26 -08:00
Anees Iqbal acd25fd445 RUNTIME 2323: NVIDIA's RTX 3090 image uses miss a buffer's write in the same VkCommandBuffer: such a use goes in a new one
runtime_lane::heap_textures::a_buffer_write_shows_in_an_overlapping_texture,
a_heap_texture_metal_compresses_keeps_the_driver_s_compression_by_default and
an_adopted_device_stating_host_image_copy_aliases_its_heap_textures failed on the RTX 3090
(NVIDIA 620.70.06) at pins 93b and 94 (m3-max-30259, 30260, 30491, 30492): a Shared heap's
64x64 RGBA8Unorm texture, a linear image in the heap's memory, read all 4096 texels as they were
after a copy into a buffer over the same bytes. The encoder trail (each encoder its own
submission) passed at the same archive (30469), and so did the trail half of 30552 at
c6a823ff13, whose folded half failed.

A scratch probe (not landed) ran the copy and the read four ways on the 3090 (m3-max-30571):
in two blit encoders (folded into one VkCommandBuffer) and in one blit encoder, a global
TRANSFER_WRITE -> TRANSFER_READ barrier between them, 4096 of 4096 texels left alone three times
each; in two VkCommandBuffers of one submission (an MTLFence keeping the encoders apart) or two
command buffers, none. 1024x1024 and 16x16 (a Tiled shadow read through buffers) left none in any
form. Vulkan defines the answer (a buffer and a linear GENERAL image over the same memory are
host-accessible aliases, ordered by a memory dependency), so it is the driver's defect, shown by
blit folding (RUNTIME 2293) and present before it in one blit encoder. NVIDIA's 615.71.09 on the
RTX 5080 Laptop GPU answered every form right (b5080 batch m3-max-30599), so it is not listed.

Now:
- DriverFact::ImageUsesMissBufferWritesInOneCommandBuffer, one MEASURED row: NVIDIA on the
  RTX 3090, its measurement in the module docs, the reverse direction named unmeasured.
- On a device with it (DeviceShared::splits_at_aliases), an encoder notes the bytes its commands
  write into its current VkCommandBuffer (alias_split.rs, at most 32 keys apart, a key's
  writes joined), an encoder that joined a group starting from the group's FoldOrder byte
  writes. A command through command_observing whose uses name an image of a key whose noted
  bytes meet the image's place (UseRange::shares_memory) ends the VkCommandBuffer and goes on in
  a new one, its barrier first; a folded encoder so goes on in its own after the group's tail,
  which its part's submission orders after the group's first part, the measured fence form. A
  render encoder joins no group whose order wrote bytes there. Counted:
  WorkCounts::command_buffers_split_at_aliases. Elsewhere nothing is noted.
- heap_textures' alias round trip also copies and reads in one blit encoder, and the alias test
  asserts the split count is nonzero exactly where the fact holds.
- tests::alias_split (any host): the measured shape meets; a place apart, another key, a buffer
  read, a write through an image and a new VkCommandBuffer do not; a joining encoder meets the
  group's write; past 32 keys every image use meets; only the fact's devices split. And
  device::tests::driver_facts: the 3090 takes the row at every release, the 5080 Laptop and
  desktop do not.

No new Degradation kind or notice: the split is exact. RUNTIME 2323: on the 3090 an unchanged artifact's command buffer now splits where it did not.
Verification: the msi check job and one 3090 rerun, reported with the landing.
2026-11-14 17:36:04 -08:00
Anees Iqbal 7c223b02e4 RUNTIME 2320: A host step's notice names every GPU-form rule its pass breaks; rate-mapped steps that probe nothing are counted by why
What: where `commit` keeps a pass whose indirect commands the GPU may write from the GPU form,
and the `host-replayed-indirect-commands` notice of that first rule is to be announced
(`Device::announces_host_step`, a peek that counts nothing), the decision runs again passing over
each rule once named (`render/executions/cause.rs`'s `Passed`, `DeferredPass::rules_past`), and the
notice names every rule past the first that the pass breaks too, each judged as though the rules
before it were kept: the rate map's as though the pass had none. A rule the rest takes its answer
from (the commands' one primitive type, the pipeline state and its kind, the inherited state's
tessellation, vertex function and tile memory, the buffer's size, a refusal) is never passed over.
The commit path is unchanged where the notice was announced already: the first rule decides, as
before. Three WorkCounts fields count the rate-mapped passes a host step records without a probe:
`rate_map_steps_unfanned` (no fan-out: policy, features, memoryless attachment, shadowed texture),
`rate_map_steps_nothing_to_probe` (no command read) and `rate_map_steps_probing_none` (commands
read, no draw probed); with `rate_map_probes` they count every such pass once.

Why: the consumer's walk of a 3D renderer sees one notice, naming the rate map, so whether a GPU
form for rate-mapped passes would cover its pass (rules past the rate map) is unknown; and about
half a host step a frame there probes nothing, for no counted reason.

The notice's text changes (a RUNTIME bump at landing). API: three public WorkCounts fields
(api_signatures.tsv blessed); nothing removed.

Verified: tests::host_step_rules on lavapipe (an indexed triangle and an empty command of a
GPU-written buffer, executed in a rate-mapped pass: the rate map's notice names that rule alone;
with a visibility result mode set, the notice names the visibility rule, then the rate map past
it, which fails without this change; the counts: probed once each, the empty command's pass
probing none).

Also: host_step_rules: the buffer inherits the encoder's pipeline state; Degradation::HostReplayedIndirectCommands says its notice names the rules past the first.

Verified (lane icbgpu, msi m3-max-30616 at eec7881980, lavapipe): clippy -D warnings plain
and --cfg m2v_cpu_icd 0; 74/74 over host_step*, icb_*, indirect_command_buffer*,
notice_command_buffers, rate_map*, rate_mapped*, degradation*, trail_gpu_forms and
draw_shape_notices, the new host_step_rules among them; api-signatures --check clean.
Landed (main) at once: the hand negative control, gpucfg clippy and rustdoc run after.
RUNTIME 2320: the notice's text and what a run records change. WorkCounts gains
rate_map_steps_unfanned, rate_map_steps_nothing_to_probe, rate_map_steps_probing_none.
No Degradation kind.
2026-11-14 17:04:25 -08:00
Anees Iqbal 257bdd7d14 SEMANTICS 2117 / RUNTIME 2319: GPU-written ICB records naming released or reused state IDs run what a Mac runs
What: two changes to how an indirect command's record names a pipeline state the program
released.

1. A record's state word gains a bit, KERNEL_PIPELINE (layout::KERNEL_PIPELINE = 2,
   CommandRecord::kernel_pipeline, RecordView::kernel_pipeline). A kernel's pipeline setter writes
   it wherever the token names a state. A kernel's copy carries it with the pipeline word, and its
   "reports" test now reads RETAINED alone. A kernel's compute reset keeps the bit beside RETAINED.
   Metal's reset leaves the command executing with the pipeline it had (measured on the M3 Max and
   the M4: reported cleared, run by the next dispatch). For a kernel's write, that pipeline is the
   state the write resolved, so the retained pipeline keeps saying the kernel wrote it. The CPU's
   compute reset does the same. The CPU's pipeline setter clears the bit, and a record the CPU
   wrote never carries it. The replay's state-word check and decode accept the bit; either bit
   beside no pipeline is still malformed. Where the bit is set, the runtime's host step, getter and
   identifier ignore the state the CPU set and resolve the ID by its holder as the GPU last could
   write it.
   Case 4 (the CPU set x, x released, y took the ID, then a kernel writes the state) now runs y, as
   the M3 Max and the 5300M do; before, it ran x, announced. Case 5 (the kernel writes only the
   buffers) runs x unannounced, as every Mac does. The host step no longer guesses, so the
   "Unsure" announcement and may_name_another are gone.

2. The device keeps the program of each freed pipeline state ID's last holder (FreedPrograms):
   one per ID, dropped when any state takes the ID. Every live indirect command buffer of the
   device holds the store and the device holds it weakly, since a program holds its device. A
   buffer the GPU may write takes the store's programs at its first such write. Case 1 (x released
   before the write, its ID taken by no one) now runs x, as the M3 Max and the UHD 630 do; the
   Radeon Pro 5300M fails the command buffer instead. Where Macs disagree, the cheaper answer is
   taken: failing the CB would need a failure path decided mid-flight in a host step. Bound: one
   program per freed ID that no state retook, so at most the peak count of live
   supportIndirectCommandBuffers states plus placed IDs, kept only while an ICB of the device
   lives. Still announced (ReleasedCommandState, the command runs nothing): a state released while
   no ICB of the device lived, and one past the ID's last four holders.

SEMANTICS_VERSION 2117: kernels that set pipelines now write the state-word bit, so their SPIR-V
and golden hashes change (re-blessed on development). api_signatures blessed for the new field and
method. No new Degradation kind. RUNTIME_VERSION is left to the landing.

Tests: indirect_commands::tests::records (a_kernel_s_pipeline_is_told_from_the_cpu_s, plus the
random field round trip with the bit). The engine_indirect_commands expectations of kernel writes
carry the bit, and the kernel reset keeps it. Runtime: released_programs (the freed store's one
program and its release on take) and notice_command_buffers (a host-step Unrun now reached through
a kernel's write of a state released while no ICB lived). Validation runtime_lane:
indirect_host_steps (case 1 runs the template; the forced notice past four holders and while no
ICB lived; case 4 runs the flat template; case 5 runs the template unannounced) and
indirect_executions (the GPU-writable copy case no longer announces). Run on lavapipe in the
lane's msi job; the results go in the lane report.

Also: Pin the notice of a state released while no buffer of commands lived; Replay tests: the kernel's pipeline bit runs, an unknown bit faults.

Verified (lane relstate, msi m3-max-30537): clippy --cfg m2v_cpu_icd exit 0; runtime tests
24/24; validation tests 113/113 on lavapipe, the new released-state cases 1, 4 and 5 among
them. Landed (main) at once: the plain clippy and translator rerun (m3-max-30546) and the
hand negative control (m3-max-30555, steelbrain/relstate-nc) run after landing; the engine
golden hashes of kernels that set pipelines are re-blessed on development.
RUNTIME 2319: what a GPU-written record naming a released or reused state runs changes.
2026-11-14 16:21:41 -08:00
Anees Iqbal 8a374ba0e5 RUNTIME 2318: Rate-mapped draws whose triangles lie in few regions are boxed, not fanned out
At a host step under RateMapRegionPolicy::FanOut, a probed draw the probe flags nothing of
goes through the fan-out variant, and so does a flagged draw's fanned part. Its geometry
stage emits a copy of each triangle per region it touches. On the pieces lane that stage costs
a fanned-out triangle what 371 to 739 vertex invocations for one region cost. On an Iris Xe
that is 130.7 ns a triangle, against 0.352 ns an index-region through the region-copy variant.
On a 3D renderer's frame there (tm91-iris), about 68 of the 125 ms of rate-mapped pieces a
frame tracks the probed and fanned geometry, which is 383 fanned draws a frame.

Such a draw is now boxed when that holds no more work: drawn through its region-copy variant
into the boxes of the regions its triangles reach by the probe's bounds (fan_out::run_boxes of
Probed::reach, a part's from its own blocks), as a run is.
- The rule: rate_mapped_pass::boxes_cheaper, regions x (vertices + REGION_DRAW_WORK) <=
  GEOMETRY_TRIANGLE_WORK x triangles (a direct draw; a strip's triangles counted at
  vertices / 4).
- GEOMETRY_TRIANGLE_WORK = 180: about half the least that a fanned-out triangle cost against a
  vertex for one region on the four devices measured (Iris Xe 371-500x, Radeon 780M 739x,
  RX 7900 XTX 570x, RTX 3090 654x; the constant's doc has the numbers). The rule is
  device-independent, keyed to no app, map or shader.
- No new pass, variant or readback. fan_out_asked asks for the region-copy variant (settled at
  commit already) and the recording takes the boxes (RenderLowering::boxed_reach).
Pixels: the routes already share a pass and put a vertex at one window position. A pixel lies
in one region, whose copies keep the draw's order of instances and primitives in either route.
The bounds are widened as the probe's are, so a box holds every pixel a copy would cover: the
same pixels and depth wherever today's routes agree.
A boxed draw rides whole in its piece, as a fanned-out one does; its work is no more than its
fan-out's.
Counts: WorkCounts::rate_map_boxed_draws and rate_map_boxed_vertex_regions (CopyRoute::Boxed).
A boxed part is not a run, so rate_map_region_runs and rate_map_parted_region_triangles leave
it out.
Test: tests::rate_mapped_boxed_draws, 6 commands blended at half alpha:
- boxed: a 10-pixel patch, a 120x40 strip across region borders, a patch of two instances,
  and a patch without indices;
- fanned out: a whole-target grid and one wide quad.
It checks probes 1, flagged 0, fanned 2, boxed 4, region-copy draws 4, and boxed vertex work
under the whole table's. The pixels equal the encoder's bit for bit. Under Exact nothing is
boxed.

Also (2f82e025be): The pieces lane draws each command's own patch: rate_mapped_pieces_host_step_patches; (01d8344d2a): A command's settle at commit boxes no draw; the boxed test's counts keep their function's name.

Verified (lane ratemap3, msi m3-max-30513 at 01d8344d2a, llvmpipe): rate_map|fan_out
26/26, the new rate_mapped_boxed_draws among them (probes 1, flagged 0, fanned 2, boxed 4,
region-copy draws 4, boxed vertex work 10752 against the whole table's 997056; pixels equal
the unboxed execution; nothing boxed under Exact); rate_mapped_fan_out, region_boxes, pieces
and depth_equal unchanged. Landed (main) at once: clippy x3 (m3-max-30514), the Iris A/B
and the hand negative control run after landing.
RUNTIME 2318: what a run records and draws changes. No Degradation kind.

API: two WorkCounts fields added (rate_map_boxed_draws, rate_map_boxed_vertex_regions);
api_signatures.tsv blessed. A consumer building WorkCounts by struct literal must name them.
2026-11-14 16:05:31 -08:00
Anees Iqbal 497e1f4ec0 SEMANTICS 2116: NVIDIA's float denormals under the 16-bit float controls are the device's, noted
What: a new DriverWorkaround, FloatDenormalsKeptUnderHalfControls, with rows for NVIDIA's driver on
the RTX 3090 and the RTX 5080 Laptop GPU (the GPUs its MetalFloatDenormals rows name). In an entry
that declares the 16-bit float controls (narrow::controlled_modes) on such a profile, the float
operations the deviation covers record PrecisionNote::DeviceDenormals and the module requires no
VkProperty::MetalFloatDenormals. An entry that declares no float-controls mode keeps the
deviation, and so does every other driver.

Why: runtime_lane::driver_deviations::fused_pairs_answer_metals_nans_and_denormals failed on the
RTX 5080 Laptop GPU (615.71.09) and the RTX 3090 (620.70.06) at pin 93b. The same 33 of 4,096
words in each fixture kept a denormal where Metal answers zero (thread 0x11: 1e-20 * 1e-20 gives
0x116c2; thread 0x29: the smallest denormal times 2^30 gives 0x04000000). That held for the lone
product a * w as much as for the fused pairs, so the fused pairs are not the cause. The fixtures
compute half in 16 bits, so their entries declare RoundingModeRTE, DenormPreserve and
SignedZeroInfNanPreserve for 16 bits. The deviation's probes (nan_denormals,
nan_denormals_fast) declare no mode and flush on the same GPUs. Vulkan leaves 32-bit denormals to
the implementation when no 32-bit mode is declared (the NVIDIA profiles report independence ALL),
and NVIDIA states no shaderDenormFlushToZeroFloat32. So the device's answer stands (owner rule 1),
scoped and noted; nothing is flushed in the shader. RADV on the Radeon 780M (Phoenix and Hawk
Point, Mesa 26.2.6) declares the same modes there and passed the test at pin 93b, so it keeps the
deviation. MoltenVK states no shaderDenormPreserveFloat16, so its entries declare no 16-bit mode.

The device test now decides "Metal's" per kernel (requires_property), as the float_denormals tests
do, and asserts DeviceDenormals where the kernel does not require the property. The new unit test
float_denormals_under_the_half_controls_are_the_devices_where_its_driver_keeps_them checks the
5080 Laptop GPU, the 3090, the desktop RTX 5080 and the 780M against fmx_fma_precise,
fmx_fma_fast and nan_denormals. It fails without the rows.

Docs: the workaround's doc, the DEFECTS and MetalFloatDenormals table docs, the deviation and
property docs, PrecisionNote::DeviceDenormals, docs/API.md's device-denormals entry,
docs/FAST-PATHS.md's denormal row, the signature table. SEMANTICS_VERSION 2116: NVIDIA modules'
notes and requirements change. No new Degradation kind.

Landed (main) at once, before its check: the lane's check (clippy plain
and cpu_icd, the touched unit tests, the two denormal device tests on
lavapipe) and the NVIDIA device proof run after landing.
2026-11-14 15:44:20 -08:00
Anees Iqbal dd486250e3 RUNTIME 2317: A kept draw reading its pass's copy by the area rule takes its reader identity and query
What:
- render/draw_again.rs, rebound.rs: a kept reader drawn again or rebound
  takes its reader identity and occlusion query as every step takes them,
  whichever form it reads through (the copy taken before the pass among
  them), and records its drawing commands inside the query. A debug
  build checks each draw again's identities against the step's
  (Readers::taken).
- slow_submissions.rs, command_buffer/submit.rs: a batch held in the
  scheduler's group gets its slow line, timed from its submission to its
  hold, naming the group.
- Tests: kept_shadowed_draws counts a frame's begins as the command buffers
  it began (WorkCounts::command_buffers_begun), not the device's begin
  calls, which begin-ahead spares move; kernel_end_device's slow-line
  check expects a group held by the groups' ends.
docs/API.md and env_vars.rs describe the slow line.

Why: at pin 93b on the 780M (devlegs), kept_shadowed_draws' kept frame
recorded 3 queries where the apart frame recorded 4: a kept draw through
the pass's copy skipped its reader's query, so its coverage was never
learned. kernel_end_device's slow line was missing for a batch held in a
group.

How verified (lane keptquery): 780M (RADV PHOENIX) at 918d3319ea,
m3-max-30392: 86/87, all four kept_shadowed_draws pass with queries 4 in
both frames, 31 of 355 kept draws checked taking an identity, begins equal
to the command buffers begun; the one failure was its own new group check,
fixed in 68c8917098. Negative control at 400efe7932, m3-max-30393: 3 of 7
fail as at 93b (queries 3 vs 4; slow line absent). Lavapipe 87/87 and
clippy plain and cpu_icd at 918d3319ea (um790 m3-max-30313). The 3090 run
(m3-max-30394), lint (m3-max-30391) and the 780M kernel_end rerun at
68c8917098 run after landing.
RUNTIME 2317: a kept draw records a query and a slow line it did not.
2026-11-14 15:17:52 -08:00