Commit Graph
9530 Commits
Author SHA1 Message Date
Anees Iqbal e9484b7d03 Replay dumps: a texture the cover rule holds covered is dumped with a whole-texture cover
A heap texture that another placement's texture wrote over after its last write was reported by
compare-dumps as a difference: the dump loop passed no cover for a texture (dumps.rs: "always `-`
for a texture"), so the bytes Metal leaves undefined there were compared. Each texture a listed
command buffer stores or binds is now dumped, when the dump reads it (after the wait that saw
the command buffer complete, the moment a buffer's ranges are taken), with the cover 0..N, N its
dump's length, where the cover rule holds any byte of it covered (Covers::covered), and `-`
otherwise. A texture's ranges in the rule are its bytes in its heap, which the dump's parts are
not laid out as, so a covered texture is covered whole. The compare then leaves its words out
as it leaves out a covered buffer word. dumps.rs and docs/REPLAY-STREAM.md section 10 say so.

Test: the_dump_compare_leaves_out_a_covered_texture_and_reports_one_outside_every_cover (no
device; Kept reads a texture part's first word from a per-texture word where it holds one). Of
three textures placed in a heap, #5 and #6 over each other and #7 apart, two dispatches of a
state that writes slot 0 write #5 then #6, which covers #5; the second play reads #5 and #7
otherwise. #5's cover is 0..32 and its differing word is counted covered; #7, covered by
nothing, is the one difference reported.

Verified at this commit: nothing yet; the lane's jobs follow.
2026-11-25 16:41:51 -08:00
Anees Iqbal f6b1adf204 Replay player: a layered pass plays as the runtime builds it, and its dump holds each slice
The player marked a pass whose renderTargetArrayLength is 2 or more as one the runtime's
descriptor does not hold (Unheld(renderTargetArrayLength)) and skipped its encoder, though
RenderPassDescriptor::render_target_array_length takes it: the runtime renders that many slices
from each attachment's slice, refuses an attachment with fewer slices (AttachmentPlace) and
answers a length past maxFramebufferLayers with Gap::RenderPass of ArrayLength. The player now
sets render_target_array_length from the recorded value (narrowed to u32 as the other counts
are) and lets the runtime decide: a gap is a skipped encoder counted by the gap, and a refusal
stays the play's error. The attachments already carry slice and resolveSlice into the
runtime's descriptor; no other field is dropped for a layered pass.

The dump's stores read a layered pass's attachment as its first slice alone. They now keep each
pass descriptor's renderTargetArrayLength from its m2v.setPass record and store that many slices
from the attachment's slice (or the resolve's), through the MTLStoreActionUnknown path too.
dumps.rs and docs/REPLAY-STREAM.md (sections 10's skipped encoders and the dump) say so.

Tests: a_layered_pass_plays_and_its_draw_renders_the_layer_it_selects (device cfg; a stream of
a 2D array of two slices, R32Uint, renderTargetArrayLength 2, cleared to 7, and rt6_layered's
triangle selecting layer 1: no encoder or draw skipped, the blit's check of both slices matches
7 then 0x101, and the dump of the command buffer holds both slices) and
a_layered_pass_s_dump_holds_each_slice_it_renders (no device; Kept: length 3 stores slices 1 to
3 of a Store attachment and 0 to 2 of an Unknown one, length 1 the slice alone).

Verified at this commit: nothing yet; the lane's lavapipe job and the quick check follow.
2026-11-25 16:41:37 -08:00
Anees Iqbal 6c43304e65 Tests: the poke guard stages its hold only where the busy work is seen complete behind the gate
ce87e6bc96's gate hung the guard on lavapipe: the quick check (job m3-max-74323) and a run alone
(m3-max-74325) each timed out in a wait at 60 s, while the RX 7900 XTX passed it (m3-max-74331:
"X held with 6 seen complete behind the gate, the busy work's last 6; 1 pokes"). A probe that
printed each step and the stall reports (m3-max-74338, steelbrain/pokeguard-diag e3e2cc5345,
never landed) showed why. The GPU had finished the busy work (the progress counter at 6). The
completion thread had retired busy1 (progress 4), poked once, and was still in that round, "its
step last entered reading 1 retirees' timestamps". Y waited staged for room that only the next
round gives. Lavapipe does not return that vkGetQueryPoolResults read (no WAIT flag) while its
queue waits on the test's gate batch, a semaphore only the test signals, so the round never
ended. The runtime missed no wake: a guest cannot submit a wait ahead of its signal (the README:
the submit thread holds such a wait, its command buffer Committed). The one such wait is the
test's own gate.

The hold is now staged where the device shows it can be: after the busy work opens, the test
gives the completion thread SEEN (5 s) to see the busy work's last value. Where it does, the
round that raised it has poked already, so the group and Y go and X is held. The test asserts as
before that nothing past the busy work was seen behind the gate, X's hold, and the one poke from
X's hold to L's handler. Where it does not, the test opens the gate at once and prints "the hold
not staged" with the completion side's stall report, and asserts neither the hold nor the poke.
Lavapipe can stage it too, where one round sees the whole busy work. There is no device-kind guard.

Test only; no product change. Verified at this commit: nothing yet. The quick check, the device
runs on the RX 7900 XTX, the Iris Xe and an RTX 3090, and the red control follow in the lane's
jobs.
2026-11-25 16:09:21 -08:00
Anees Iqbal df39c2eea4 Tests: the poke guard holds the group behind a gate of its own until X's hold is asserted
every_device_pokes_the_submit_thread_for_a_completion_that_leaves_room needed S, sized to about
100 ms from a measured run, to still be running when X was held, and retried with S's copies
doubled where the completion thread had seen S complete by then. On lavapipe in the quick
check's whole-suite run at b87236c3fc (job m3-max-74285, llvmpipe LLVM 23.1.1) S was seen
complete first in all 4 attempts and the test failed. Run alone at the same commit (job
m3-max-74322) it passed at its first attempt, with 1 poke; its two sizing runs read 4.7 ms and
16.7 ms for the same 8 copies a moment apart. The red is the host's timing, not the merged tree:
kkview's run_settled keeps each_device's steps and their order.

The test now submits a second gate (Busy:🆕 a batch on the device's one VkQueue that waits
for a timeline semaphore only the host signals) after the busy work and before the group goes,
which it does only once the busy work is seen complete. A semaphore wait holds every later
command in submission order, so S, A, L and Y cannot run, and no completion past the busy work
can come, until the test opens the gate after it has read the pokes and asserted X's hold. The
test now asserts what the retry read, that the completion thread has seen nothing past the busy
work's last value at that point, and asserts X's hold unconditionally. The retry loop and S's
100 ms aim go; S and L both take one sizing of about 10 ms. Every assertion stays: S, A and L
held in one group, sent member by member after the long run, Y then X held behind them, and one
poke from X's hold to L's handler.

The gate is made just before the busy work opens: its batch's fence follows the busy work, so
dropped by a failed check before that, it would wait forever for the closed busy gate.

The stack's siblings rely on L's GPU run, not on S's outlasting the host's calls, and no gate
fits them: every_device_signals_each_member_of_a_group_sent_apart reads A's value while L runs,
and every_device_settles_an_early_members_shared_writes_at_its_own_completion asks, where the
device holds a coherence state, for A's sight before L's GPU end. Both need L running on the GPU
while the host looks; the submit thread submits A's and L's batches under one hold of the queue
lock, so no batch goes between them, and a host-set VkEvent may not gate a pending command buffer
(VUID-vkSetEvent-event-09543). every_device_feeds_an_early_members_run_to_its_queue_as_the_last_retires
uses fills and no length. They are unchanged.

Test only; no product change. Verified at this commit: the classification runs above. Not yet
run at this commit: the quick check (lavapipe rt suite), the runtime device suite on the RX 7900
XTX, the Iris Xe and an RTX 3090, and the guard alone with Work::completed's wake_at test
reverted, which is expected to fail; their jobs follow.
2026-11-25 16:09:21 -08:00
Anees Iqbal c43f1a5447 Replay player: setSamplePositions:count: plays on a pass descriptor, and passes at other positions are counted
The runtime player refused setSamplePositions:count: on a render pass
descriptor ("not played on a render pass descriptor"), so every play of a
stream whose 2D renderer sets positions on its 4-sample pass stopped before
that pass.

It now plays the call as the runtime treats it: the runtime's descriptor has
no field for the positions and every multisample pass rasterizes at Vulkan's
standard sample locations, so nothing is set and nothing is refused. The pass
keeps the positions its last call set, and each render encoder the runtime
makes of a pass whose positions differ from Metal's defaults for the pass's
sample count (its attachments', or defaultRasterSampleCount with none) is
counted on a report line, with the first one's frame and call:
"passes at sample positions other than Metal's defaults N: rasterized at the
defaults, Vulkan's standard locations; the first at frame F, call C".

Metal's defaults are taken as Vulkan's standard locations at 1, 2 and 4
samples (the spec's Standard Sample Locations table; the runtime's floor row
standardSampleLocations and its known gap name them Metal's defaults at those
counts; the conformance rows sample-positions-default-4x/-2x). No other
count's defaults are held, so a set at any other count counts as differing;
an empty list (count 0) is the defaults.

Tests: rt_replay's sample_positions_play_and_a_pass_at_other_positions_is_counted
writes its own stream, two passes over a 4-sample target, one at the 4x
defaults and one at four others; it plays through with nothing skipped and
the line counts only the second (call 12). Without the fix the play stops
refused at call 5. new_runtime's
sample_positions_differ_from_metal_s_defaults_of_the_pass_s_count checks the
comparison (defaults, one coordinate off, reordered, fewer positions than
samples, Vulkan's 8x locations) and the line at zero, without a device.

Docs: docs/REPLAY-STREAM.md lists the call among the pass descriptor's
setters and says how the backend plays and counts it.
2026-11-25 15:48:21 -08:00
Anees Iqbal e5bac28d23 Runtime docs: a compressed copy at the clamped size into the inside of a larger level stays refused, and why
What: place()'s doc and the runtime README's refused list for copy_from_texture name the basis
for refusing, as Refusal::TextureRegion, a size of no whole blocks that stops at the source
level's edge and inside the destination's level (4 x 2 texels of a BC level of 4 x 2 into the
second block of a level of 8 x 4, the size Apple's page for the copy asks for). Three facts:
- Metal's validation layer stops it, "size.height(2) must be a multiple of
  MTLPixelFormatBC1_RGBA blockHeight(4)" (2 x 1: the width too), taking a size of no whole
  blocks only where both places reach their edges;
- plain Metal lands the source's block by no one rule: from level 9 (4 x 2) at the block named,
  level 8 (4,0) ("dm"); from level 10 (2 x 1) at level 8's first block, (0,0) ("md"), not the
  (4,0) the copy names;
- Vulkan's copies chapter still says "Copy regions for each image must be aligned to a multiple
  of the texel block extent in each dimension, except at the edges of the image, where region
  extents must match the edge of the image", while in Vulkan 1.4.366 only the source's extent
  has a valid usage of that (VUID-vkCmdCopyImage-srcImage-01728/-01729); the destination's
  dstImage-01732/-01733/-01734 were removed in 1.4.316 ("Remove common copy image VUs
  constraining extent with compressed destination images", internal issue 4113), leaving
  dstOffset-00150/-00151 and pRegions-07281/-07282.
The README's "Not built" sentence becomes a bullet of its own after the refused one. The probe's
header line on copies between levels no longer says 10to8 lands the block named: it lands it at
level 8's first block.

Why: the bug row's case left after the blockedge lane. Metal's answer for it is recorded, and it
is not well defined, so the refusal stays (main's ruling of the stop, 11-25) and its doc names
the basis instead of "no texel is there to copy".

Verified: Metal's answer is read from job m3-max-73696's log (an Apple M3 Max, macOS 27.0.1,
26A434): bc1/bc3, mp and pp, 9to8-clamp and 10to8-clamp, layer on (signal 6 at the call) and off
(status 4; levels fnv BC1 905021b8270b2f7d / e29c43c95a986a65, BC3 0e3db2fa9a018635 /
ba80003e40f740e5, each equal to its 4x4 form's). Vulkan's terms are from vkspec.txt 1.4.366 and
its ChangeLog.adoc. refusal_surface.py --check: unchanged. No code changed; the quick check runs
at this commit.
2026-11-25 15:47:58 -08:00
Anees Iqbal b87236c3fc Landing note: the submit-thread stack's cost and wall on the 780M and the XTX, as measured
An empty commit: published history is never amended, so the stack's measured cost is stated here,
on top of it. It changes no file.

The stack (each member of a group sent apart signals its own progress value; a completion wakes
the submit thread only when it can leave room; an early member feeds the expected run as the last
retires; enqueue and commit wake waits only where a thread waits), rebased onto development
efd7dbcd4d. Budget jobs: the harness's instruction rows and the draw and dispatch instruction
tests, before (development efd7dbcd4d) and after (da6afd1b74, whose product code equals this
tip's), alternated three times in one exclusive job per card. Each figure below is per timed run,
the three passes in order. Instructions are own_per_run: the runtime's threads and the harness's,
in user space.

Per dispatch 0.944 on both cards (780M 38434 -> 36275/36274/36274, XTX 38427 -> 36266/36267/36267)
and per draw 1.000 on both (12244 in both arms).

780M (RADV PHOENIX, job m3-max-74155), the rows that failed (b):
- burst_160: instructions up by 1.0218 (before 4334360/4342825/4356199, after
  4445226/4434268/4438013); wall before 624.5/607.8/610.0 us, after 578.8/572.8/584.0 us, wholly
  below; submissions before 17.59/16.78/16.87, after 13.23/14.43/13.26.
- burst_160_shared: instructions up by 1.0224 (before 4366162/4352586/4353147, after
  4443101/4470494/4450471); wall before 640.2/630.1/633.5 us, after 585.3/594.1/585.1 us, wholly
  below; submissions before 17.98/18.23/17.88, after 14.03/16.27/14.53.
- burst_2000: instructions up by 1.0226 (before 49203922/49011492/49099261, after
  50271148/50106146/50265990); wall before 7483.9/7469.9/7332.6 us, after 7013.3/6891.9/6948.3 us,
  wholly below; submissions before 241.69/250.09/239.58, after 218.75/216.88/214.50.
- burst_2000x5: instructions up by 1.0088 (before 98762327/98831256/98938899, after
  99773524/99728752/99642838); wall before 11853.0/11648.5/11613.5 us, after
  11766.1/11658.5/11857.6 us, the ranges overlap; submissions before 193.64/206.46/194.78, after
  185.68/182.57/186.84.

XTX (RADV NAVI31, job m3-max-74154):
- burst_160_shared, failed (b): instructions up by 1.0076 (before 4671450/4693624/4686014, after
  4707679/4713619/4737142); wall before 1097.2/1103.4/1096.2 us, after 1100.4/1097.8/1100.6 us,
  the ranges overlap; submissions before 13.88/13.72/13.76, after 13.76/13.81/13.63.
- burst_2000, failed (b): instructions up by 1.0084 (before 48405591/48482937/48645781, after
  48906000/48952717/48892406); wall before 9346.9/9465.9/9298.0 us, after 8986.1/8954.1/9068.0 us,
  wholly below; submissions before 391.11/411.76/393.94, after 312.56/302.02/321.07.
- burst_160, read under (c) (spread 5.70% in the after arm; ratio of means 1.0388): instructions
  before 4308890/4306596/4337184, after 4335127/4582028/4538356, the ranges overlap; wall before
  830.0/829.9/823.0 us, after 866.3/790.2/796.4 us, the ranges overlap; submissions before
  21.62/23.97/20.57, after 29.87/14.82/15.76.
- burst_2000x5, passed (b) at 1.0035: whole-process instructions before
  97575132/97961952/97592923, after 98067782/98145547/97956382; wall before
  17543.8/17768.5/17594.0 us, after 17033.4/16983.0/17281.6 us, wholly below; submissions before
  543.60/605.65/549.99, after 450.69/432.33/478.58.

(b) of the budget rule was not met; it did not decide, because the change moves the submission
count and a submission's kernel side is in neither user-space measure, so each failing row was
read with its wall, and no row's wall rose.

This is not a known gap, and the runtime's README gains no line for it.

Gates at the tip's tree (f38f8d527c, whose tree this commit keeps): quick check m3-max-74172
(signatures, clippy plain, m2v_gpu and m2v_cpu_icd, rustdoc, rt's whole suite on lavapipe 752/3,
the conformance replay on lavapipe); suites m3-max-74126 at 7224d73dd9 (validation, conformance,
doctests green; product red only on the golden table's bless due, development's, with no
translator change here); rt's device suite under the validation layer with the GPU-hazard tests
out, 755 passed and 3 skipped on each of: Iris (ANV) m3-max-74184, XTX (RADV) m3-max-74176,
Iris under --cfg m2v_shared_view m3-max-74175, RTX 3090 (NVIDIA) m3-max-74257; the control
m3-max-74158 on the RTX 3090, at da6afd1b74 (an early member's settle deferred to the group's
last, a scratch patch never committed), failed the settle test (A's handler read 0 invalidates
against 1 of 256 bytes) and the unpatched archive passed it in the same job.
2026-11-25 15:34:17 -08:00
Anees Iqbal 3cafd30596 Tests: the early member's settle test asks for A's early sight only where the device holds coherence state
every_device_settles_an_early_members_shared_writes_at_its_own_completion failed on lavapipe in
the quick check's whole-suite run (job m3-max-74149, msi-laptop, llvmpipe) with "A seen complete
before L's GPU end" after its four attempts. Lavapipe retires A together with L: its completion
thread's round does not see A's own value before L completes, as the stack's lane found for the
poke guard. Lavapipe's one memory type is host-coherent, so the device holds no coherence state
there, and the test's only checks are that no flush or invalidate is made and each handler
reads its fill. Neither depends on A being seen early.

A's sight before L's GPU end, and the retries that look for it, are now asked for only where the
device holds a coherence state. That covers every GPU through the refused device's view, and
every GPU under --cfg m2v_shared_view. There the invalidate counts at A's handler and at A's
status are exact only for a sight before L's end. On a device with no state the test asserts
zero calls at A's handler, at A's status and at L's handler. The pass line now prints whether A
was seen early.

On the Iris under the view (job m3-max-74153, at da6afd1b74) A's handler ran 7.68 ms and its
status was seen 7.40 ms before L's GPU end, with one invalidate of 256 bytes each time. The
control job with the settle deferred to the group's last is m3-max-74158.

Test only.
2026-11-25 15:34:17 -08:00
Anees Iqbal b9da46258e Tests: the poke guard and the early member's settle test print the attempt that asserted
every_device_pokes_the_submit_thread_for_a_completion_that_leaves_room asserts X's hold only on an
attempt where S was not seen complete first (1b4595dea9). An attempt where it was goes again, up
to four. The fourth fails, so a pass always has one attempt that asserted the hold. The failure
now says the hold was never observed. The pass line names the attempt that asserted it, so each
run shows the hold was checked and on which attempt.
every_device_settles_an_early_members_shared_writes_at_its_own_completion's line names its
attempt as well.

Test only.
2026-11-25 15:34:17 -08:00
Anees Iqbal cd6797fb47 Tests: an early member of a group sent apart has its Shared writes invalidated at its own completion
The stack moves a member of a group sent member by member to retire at its own progress value.
A-narrow's invalidate of the Shared memory a command buffer may write sits in that retirement
(command::retire, coherence::Coherence::settle), ahead of its status and its handlers. Until now
no test read the invalidates for such a member. tests/coherence.rs reads them for one command
buffer filled and finished alone. The stack's guards read progress values, runs and pokes.

every_device_settles_an_early_members_shared_writes_at_its_own_completion builds on those guards'
helpers (behind_busy, halves, halves_for, Arena). A fills one Shared buffer of the arena. L runs
copies sized to about 10 ms and then fills another. Both are held behind the busy work in one
group, which goes member by member. Where the device holds a coherence state, the test asserts
three things, each counted since the group was held:
- at A's completed handler, run while L still runs (its host time before L's GPU end), one
  invalidate of A's 256 bytes and no failed call;
- at A's status seen complete on the test thread, also before L's GPU end, the same;
- at L's handler, two invalidates over 512 bytes.
Each handler reads its own buffer's fill. Where the device holds no coherence state, it asserts
that no flush or invalidate was made at all. Each device runs the test as it reads its types:
the coherent lab cards and lavapipe make no calls, and under --cfg m2v_shared_view every GPU holds
the state. Under plain m2v_gpu it also runs through the refused device's view
(tests::cached_types_incoherent), so every GPU leg runs both forms. An attempt where A was seen
complete only after L's GPU end goes again with L's copies doubled, up to four attempts.

The test fails if the invalidate moves to the group's last or past the handlers. A control job
with the early members' settles deferred to the group's last retirement (a scratch patch, never
committed) shows that; its job id is in the lane's report.

Test only; no product change.
2026-11-25 15:34:17 -08:00
Anees Iqbal 541068fb7b Tests: the poke guard reads X's hold only where S was not seen complete first
every_device_pokes_the_submit_thread_for_a_completion_that_leaves_room asserted that X was held
behind the group and Y before it read whether the completion thread had already seen S complete.
The test's own retry, for an S that completes before X is held, came after that assertion and
never ran. On lavapipe in the quick check's whole-suite run (job m3-max-74125, homelab-gem10-1,
llvmpipe, nextest at its default parallelism and no LP_NUM_THREADS), the count read AHEAD + 5
against AHEAD + 4: X was submitted, not held, at the first attempt, 0.44 s into the test.

X gets room only once the group's last member is seen complete. Behind the group and Y, the
queue's in-flight list holds the group's entry until L's value retires. The expected run the
test set (1 s), halved by the busy work's three retirements, stays far above GROUP_RUN, so no
shorter run frees room. Any completion past the busy work raises Done::completed above
busy_last before the test reads it, so an attempt where X got room always reads `early`. The hold
is now asserted only where `early` is false. Where it is true, the attempt goes again with S's
copies doubled, as the test already did, and the final `assert!(!early)` still fails a fourth
such attempt. S is sized from a run measured under the suite's load, so it can run shorter than
its 100 ms aim once the load eases.

Test only; no product change. Verified: expected to pass again in the next quick check's lavapipe
whole-suite run (STEP lvp_rt), with the guard's red control unchanged (its poke count assertion
is untouched).
2026-11-25 15:34:17 -08:00
Anees Iqbal c4aded723b Tests: wake_at's guard opens its window before S's round can poke
The guard passed with wake_at reverted on lavapipe (job m3-max-72805): S's
round poked the submit thread before the window opened, while S's status still
read scheduled, its round stalled in the timestamp read behind the queue's
later work. A round raises what the completion thread has seen before it pokes,
so the test now reads that against the busy work's last value as the window
opens, and runs again with S's copies doubled where the completion thread had
seen S by then; S's copies are sized to about 100 ms.
2026-11-25 15:34:17 -08:00
Anees Iqbal 3668435cfb Runtime: a command buffer's enqueue and commit wake its waits only where a thread waits
Every commit called notify_all on the command buffer's condition variable, at
its enqueue and again at its commit: each a futex wake, a system call whether
or not a thread waits, about 1.2 us a commit in a consumer's profile. The
command buffer's state now counts the threads waiting on it, under the same
lock, and both notify only where one waits. A device test has a thread wait
for a command buffer not yet committed: the commit wakes it, and the wait
returns once the command buffer completed.
2026-11-25 15:34:17 -08:00
Anees Iqbal 6930e494d6 Tests: guards for the submit thread's wake at a group's last and the expected run's feed
Two device tests, each failing without its change:
- an early member of a group sent member by member leaves its queue's
  retirement count and expected run as they stood until the group's last
  retires: A's handler and L's see the count two apart and the run fed twice;
- while a queue holds a command buffer behind such a group and one more
  submission, the members ahead of the group's last complete without poking the
  submit thread, and the last's completion pokes it once (a count of pokes the
  device tests read).

The apart-group test's long copies and their sizing become helpers the new
test shares.
2026-11-25 15:34:17 -08:00
Anees Iqbal 7e945bc38b Runtime: a member that completes before its group's last feeds the expected run as the last retires
With each member of a group sent member by member signalling its own value,
a member retires early, and its GPU run fed its queue's expected run and its
retirement count at once. The submit thread's joins, its count of joins since
a retirement and its parting of groups then read runs the single signal never
showed them, at other points: on an RTX 3090 the per-member signal made 7.8-40%
more vkQueueSubmit2 calls per command buffer (jobs m3-max-72705, 72726).

A member that completes before its submission's last still retires, and its
handlers run, at once; only its run waits, kept in order on the completion
thread, and feeds the queue as the last retires, where it did with one signal.

On the RTX 3090 (job m3-max-72726, every arm at P0) it made 0.466 and 0.472
calls per command buffer with 6 shorts a long, 16 in flight, against the base
arms' 0.518 and 0.513 and the threshold form's 0.538 and 0.574: fewer than the
base, as a host that hears a member complete at its own end commits while the
group is still in flight, finds no room and joins a held group. On the
consumer's RX 7900 XTX guest run (job m3-max-72747) the w3 burst took 567.06 us
a buffer against the base arms' 575.21 and 570.52. The lavapipe test, clippy
in three configurations and rt's suite passed with it (job m3-max-72725).
2026-11-25 15:34:17 -08:00
Anees Iqbal e42fc0cc53 Runtime: a completion wakes the submit thread only when it can leave room
Since each member of a group sent member by member signals its own progress
value, every member retires in a round of its own, and each such round woke
the submit thread while its queue held work. A member's completion cannot leave
room: a queue's submission in flight is the group's, at its last value, and
room changes only as that completes.

The flag that said a queue holds work becomes the value whose completion can
leave room: the first submission in flight of each queue that holds, the lowest
of them; 0 while the thread passes, so a completion during the pass still wakes
it, and none while nothing is held. The completion thread wakes the thread for
a round that reached it, and for a round that fired events or found the device
lost, as before.

On an RTX 3090 (job m3-max-72705, every arm at P0, base, per-member signal,
this, this, per-member signal, base at 8 s), the submit thread's timeslices per
command buffer over the base fell from +47.6% to +16.4% (2 shorts a long, 16
in flight) and from +34.8% to +6.8% (6 shorts a long), and its CPU per command
buffer from +3.94% to +3.51% and from +8.55% to +0.78%, at rates within 0.2%.
The lavapipe test, clippy in three configurations and rt's suite passed with
it (job m3-max-72695).
2026-11-25 15:34:17 -08:00
Anees Iqbal 3f3dc7fd73 Runtime: each member of a group sent apart signals its own progress value
A held group whose summed expected run passes GROUP_RUN as it goes is sent member by member,
one vkQueueSubmit2 each, and only the last call signalled the progress semaphore. A member ahead
of a long one was then seen complete (its status, its completed handlers, waitUntilCompleted)
only at the group's end, late by the GPU runs of the members after it. Metal completes each
command buffer at its own end. On an RX 7900 XTX (RADV) a guest's compute work showed it: its
8-16 ms spans from GPU end to handlers matched its 8-16 ms GPU runs one for one, with submissions
equal to commits, so those groups went member by member.

Each part of such a group now signals its own value, the last part the group's, and each member
retires at its own part's. The calls, their submit infos and the room rule are unchanged: the
queue counts the group one submission in flight, at its last value. Uploads and copy-ins retire
at the group's value as before, and the held-start gap keys on the group's value. A group sent in
one call keeps its one signal.

Verified on lavapipe, job m3-max-72649: the new device test polls the progress semaphore while
a group of a fill A and a long copy L (about 10 ms) goes member by member. In three repeats it
read A's value 59-254 us after A's GPU end, and the group's last at L's end, 9.3-10.9 ms after.
With this commit's runtime files taken back, the counter went from the busy work's value to the
group's at L's end (9.6 ms) and the test fails. rt's suite on lavapipe: 714 passed, 3 skipped.
Clippy with -D warnings plain, under --cfg m2v_gpu and under --cfg m2v_cpu_icd: clean. On
lavapipe A's handler still begins after L's end: the round before it waits in
vkGetQueryPoolResults behind the queue's execution there (jobs m3-max-72643, m3-max-72616), so
the handler times are read on a card.
2026-11-25 15:34:17 -08:00
Anees Iqbal cb3d913139 Runtime tests: the view tests take the floor's choice over the view as their arm, on every device
What: tests::floor's a_device_with_no_cached_coherent_type_opens_where_the_floor_chooses_its_types
and tests::coherence's view test (renamed from every_gpu_read_as_the_refused_device_... to
every_device_opened_under_the_view_flushes_and_invalidates_the_shared_memory_work_reaches) share
one helper beside open_each_device, tests::command::on_device::each_device_under_the_view. For each
device of the cfg's kind it reads the buffer bits from a device made with no view, takes the
floor's choice (floor::choose) over the viewed memory properties, and makes the device through the
view: where the choice refuses, the make must refuse with exactly BelowFloor { missing } from that
choice, and one line names the device and the refusal; where it chooses, the device must open with
the chosen types and the test's body runs on it, settled and with its gauges checked at drop as
open_each_device does (its per-device steps are now run_settled, which both use). The floor test's
`if cfg!(m2v_cpu_icd)` guard is gone, and the coherence test's #[cfg(m2v_gpu)] with it: both run
under every device cfg. The doc comments state the structure: a device whose one host-visible,
host-cached buffer type also holds the parameter ring is refused under the view, with its refusal.

Why: round efd7dbcd4d-1125-1433, leg mac:rt (job m3-max-74110), KosmicKrisp 26.3.1 on the M3: both
tests failed with "below the runtime's floor: it lacks a memory type with DEVICE_LOCAL |
HOST_VISIBLE | HOST_COHERENT for buffers (the device offers buffers: type 0 with DEVICE_LOCAL |
HOST_VISIBLE | HOST_CACHED)". That device's one buffer type also holds the parameter ring, as
lavapipe's does, so the view leaves no ring type and the floor refuses it, as it should. The floor
test took the refusal arm by the device's kind; the coherence test had none.

Test-only; the runtime's behaviour is unchanged. docs/VALIDATION.md's m2v_shared_view note checked:
nothing in it is false, unchanged.

Verified: cargo fmt only; the quick check, the KosmicKrisp rt leg on the M3 and the Iris view leg
follow.
2026-11-25 15:31:35 -08:00
Anees Iqbal 5e8b3cbcd7 Runtime README: the attachment read over a buffer in place keeps its fact, not the forms once ruled
What: the known gap for a draw that reads its own target over a buffer in place keeps what is true
now (refused on every device as AttachmentRead; no play of the replay streams met it) and drops the
sentence naming the forms ruled for it should a stream meet it.

Why: a README says what is true now. That sentence's second form, unified image layouts with a
LINEAR feedback image, needs a unifiedImageLayouts query, which would be a twelfth form under
AGENTS.md rule 2 and is the owner's word alone. The forms stay on file in the planner's plan,
outside the tree.

Verified: docs only; no other file quotes the sentence (grep over *.md, *.rs, *.py, *.tsv).
The whole-workspace docs check runs with development's checks at this tip.
2026-11-25 15:30:53 -08:00
Anees Iqbal 75dfcedf48 Landing note: the host write into a stale heap texture, verified on every venue
What: no change. This notes the evidence for 358a78fcf3..ca3d489bcd, whose own message ends
"Verified so far" before the gates read. Published history is never amended.

Verified:
- The new test reads heap_moves as (at the host write, at the later GPU write) for three later
  writes: generateMipmaps, a blit into another region, a pass that loads the texture.
  - Base 358a78fcf3, lavapipe, job m3-max-74235: (0, 1) in all three, red.
  - Tip ca3d489bcd, lavapipe, job m3-max-74248: (1, 0) in all three, green; 18 of 18 alias,
    heap_alias and heap tests passed.
- The runtime's device suite at ca3d489bcd, from one m2v_gpu archive (m3-max-74252):
  XTX (RADV) m3-max-74254, Iris Xe (ANV) m3-max-74255, RTX 3090 (NVIDIA 620.70.06) m3-max-74256;
  751 of 751 passed on each, the new test (1, 0) in all three rounds, the region kept.
- Quick check m3-max-74249: signatures, clippy plain and under each device cfg, rustdoc, lavapipe's
  rt suite 748 of 748, the conformance replay with 0 ledger drift lines. Suites check m3-max-74251:
  product 3641 of 3641, golden matches, validation 1307 of 1307, conformance 1040 of 1040, doctests.
- No budget job: no harness row times uploads.

The texel loss itself was seen on no device. The base ran only on lavapipe, where the host-written
region read back intact after the move from undefined. The real cards ran only at the tip. The
heap_moves count, its place and its value, carries the proof.
2026-11-25 15:30:30 -08:00
Anees Iqbal ca3d489bcd Runtime: a host write into a stale heap texture moves it in its upload, so its next GPU write keeps the texels
What: Texture::replace_region into a heap texture that takes part in
crate::alias settles the alias state in the upload's own command buffer,
under the work lock, ahead of its copy (alias::host_write). A stale
texture moves from undefined in alias::record's barrier, after every
earlier command's writes, counted in heap_moves and barriers. Its
staleness clears and its texture links turn stale. That state change is
Placement::written, which alias::stage now shares: one write path. A
texture in no heap, or one that takes no part, pays one test and records
nothing. A linked texture that is not stale records no command. No state
is added beyond what the alias module holds.

Why: a host write marked nothing, so a texture that a write over its bytes
had left stale stayed stale through it. Its next GPU write (its mipmaps, a
blit into another region, a pass that loads it, a draw's or a dispatch's
write) then moved its whole image from undefined, and the texels the host
wrote were lost, where Metal keeps them. upload_region reaches no heap
texture (it has no named bytes; the test asserts the refusal), and no
other work.upload caller writes one.

Ordering, by reading submit.rs: three things hold the work lock: the
call's settle, a segment's staging (alias::stage in WorkState::step,
where its checks read the staleness and its writes store it), and the
close of the submission that takes the upload (take_uploads). The upload
is numbered N, the next commit. It runs ahead of every segment of the
first submission whose last leading command buffer has seq >= N, or of
the next submission after a flush.
1. X committed after the call (seq >= N): staged after the settle, and
   run after the upload. Its checks see the host write. Right.
2. X committed before the call and submitted before it, which includes
   every X the program waited for: staged before the settle, and run
   before the upload. The settle sees its stores. Right.
3. X committed before the call, not submitted when the call is made, and
   writing T or a resource over T's bytes:
   (a) staged before the settle, in a held group that a later commit
       joins or a flush sends: the upload runs ahead of X, X overwrites
       the host's texels, and T's next write misses its move;
   (b) staged after the settle, and submitted alone before the upload's
       submission: X runs first. The settle missed X's store, so where T
       was fresh its copy goes in with no move after X's write. X's store
       lands after the clear, so T's next write moves T;
   (c) staged after the settle, in the upload's submission or a later
       one: the upload runs ahead of X, X overwrites the texels, and T's
       next write moves it.
In 3a to 3c, X has not completed at the call. Apple's page for
replace(region:mipmapLevel:slice:withBytes:bytesPerRow:bytesPerImage:),
as fetched on 11-25 and relayed by main: "This method runs on the CPU
and immediately copies the pixel data into the texture. It doesn't
synchronize against any GPU memory operations to the texture. Ensure all
operations that write or render to the texture complete before reading
the texture's contents..." So order 3 is the program's race on a Mac too,
and owner rule 1 does not emulate it. The docs state it as the program's
race and say what the runtime does then. The other side, ordering the
upload after earlier commits, was ruled out: it changes the order of
every upload, or adds a second form for heap ones, and blocks the host on
queue room. When a Mac reuses a heap's bytes is unaudited.

Docs: the alias module's "A use that writes" paragraph,
Metrics::heap_moves, replace_region's doc, and the runtime README's heap
paragraph. No refusal or public item changed.

Verified so far: the new test fails at the base on lavapipe (job
m3-max-74235, msi-laptop, llvmpipe): heap_moves (host write, GPU write)
= (0, 1) for mipmaps, blit and load, against (1, 0) wanted. The tip's
lavapipe run, the gates and the device suites are reported to main as
they read.
2026-11-25 15:20:16 -08:00
Anees Iqbal 358a78fcf3 Runtime tests: a host write into a stale heap texture keeps its texels through the next GPU write
A heap texture that a write of a buffer over its bytes left stale stays
stale through a replace_region: the host write marks nothing in
crate::alias, so its next GPU write moves its whole image from undefined
and the texels the host wrote are lost, where Metal keeps them.

The test places T (64 x 64 RGBA8Unorm, two levels) and then B, a heap
buffer over its bytes. Each round fills B by a blit, writes a 16 x 16
region of T's first level by replace_region, then writes T on the GPU
elsewhere: its mipmaps, a blit from a buffer into another region of its
first level, and a pass that loads its first level. It asserts heap_moves
+1 at the host write and +0 at the GPU write, and reads back only the
region the host wrote. It also asserts that upload_region refuses a heap
texture (no named bytes), so replace_region is the one host write that
reaches one.

Expected to fail at the base: heap_moves +0 at the host write, +1 at the
GPU write. Verified by the lavapipe run reported with the fix.
2026-11-25 15:15:26 -08:00
Anees Iqbal a26b61b3b2 Census at efd7dbcd4d: the authored AIR 1.8 sampling case compiles on every profile
What: corpus/authored-compile.tsv gains case 884ad7d75a22's row (the AIR 1.8 sampling case of
f4f6fd32cf), compiled on all 9 profiles. No other row and no artifacts_at line moves: the
translator's inputs at efd7dbcd4d equal db3a88526b's.

Why: the pin at efd7dbcd4d records the census at its tip.

Verified: census job m3-max-74099 on the M3 at efd7dbcd4d: 2348 cases over 9 profiles, 21132
cells, the 9 new cells compiled, 0 failed, 1 difference (the new case), 0 regressions.
2026-11-25 14:42:35 -08:00
Anees Iqbal 9be3f46fb7 Golden at efd7dbcd4d: the AIR 1.8 sampling fixture's two rows
What: crates/metal2vulkan/tests/golden_hashes.tsv gains the rows of engine/air_1_8_sampling.air.ll
and engine/air_1_8_sampling.ll (function a18_sample_fs), the fixture the authored AIR 1.8 case
added (85a39d3ab1..f4f6fd32cf). No existing cell moves.

Why: the pin at efd7dbcd4d gets its bless at that tip. Development's suites read "bless due (stale
cells only, keys changed)" for these rows from f4f6fd32cf on (m3-max-74029, 74090, 74102).

Verified: bless job m3-max-74098 on the M3 at efd7dbcd4d. The inventory, golden and printout
blesses exit 0, and the patch is these two added rows (2850 bytes).
2026-11-25 14:42:35 -08:00
Anees Iqbal 09cf6d9a06 Runtime tests: m2v_shared_view's hook takes a device cfg, so the cfg alone means nothing
Device::new's hook for `--cfg m2v_shared_view` (device.rs) was gated on
`cfg(all(test, m2v_shared_view))`, but the `DeviceOptions::memory` field it sets and
`tests::cached_types_incoherent` exist only under a device cfg (`m2v_gpu` or `m2v_cpu_icd`).
`cargo test --cfg m2v_shared_view` with no device cfg therefore failed to compile, while
docs/VALIDATION.md says the cfg means nothing alone. The hook is now gated on
`cfg(all(test, m2v_shared_view, any(m2v_gpu, m2v_cpu_icd)))`. The `cfg!(m2v_shared_view)` reads
in tests/coherence.rs sit in its device-cfg'd `on_device` module and need nothing.

Verified: cargo fmt; a CPU job builds the runtime's tests under `--cfg m2v_shared_view` alone,
and clippy runs under `--cfg m2v_gpu --cfg m2v_shared_view` (the job named with this sha).
2026-11-25 14:34:24 -08:00
Anees Iqbal efd7dbcd4d AGENTS.md: rule 2's eleventh form, Shared memory's host coherence, with its known gap
The owner chose this form, Telegram 2963, verbatim: "Correction, a-narrow sorry". That answers
the planner's question whose A-narrow option named the eleventh form; it replaces 2961. This
commit lands with the form's code (the commits before it), so development never holds the form
without its rule.

AGENTS.md, rule 2 only: "for ten only" becomes "for eleven only", the list's final "and" moves
before the new entry, and the entry names the query (the host-coherent flag of the memory type
Shared takes), the second form (on the cached type without coherence, what is flushed before
the GPU reads it and what is flushed then invalidated before the host reads it), and its known
gap (no device the tests run on shows a missed range; the flush's cost grows with the Shared
bytes a submission reaches). The planner accepted the wording with two changes, both applied.
Nothing else in AGENTS.md changes.

crates/metal2vulkan-runtime/README.md, the known gaps of memory blocks: a submission's flush
names every Shared range its command buffers reach, written or not, merged, so its cost grows
with the Shared bytes a submission reaches, not with what its commands wrote.

The cost on devices whose Shared type is host-coherent, as measured at 890f6580ac against
development 8f74582eb3, three alternated passes, each job alone on its node: 74045, Radeon RX
7900 XTX: every row passes, +43.1 user-space instructions per command buffer on burst_2000;
74046, Radeon 780M: burst_2000 1.0062 (+152.1 per command buffer) and frame_5cb 1.0115, a loss
by the planner's reading rule; +2 instructions per draw, 0 per dispatch, on both. The form
lands on the owner's word with those figures before him.

Checks: cargo fmt. The prose matches the code (coherence.rs, submit.rs, texture.rs, fill.rs,
command.rs, complete.rs, event.rs). docs/REFUSALS.md and error/basis.rs are unchanged under
refusal_surface.py. The quick and suites checks run at the rebased tip.
2026-11-25 14:24:29 -08:00
Anees Iqbal 412bce0bd5 Runtime: a coherent device's command buffers carry one None pointer of coherence, boxed
The planner's form A after the XTX budget job 74002 read burst_2000 as a loss (+139 user-space
instructions a command buffer at 3363435164). A device whose Shared type is host-coherent now
moves 8 bytes of coherence state with each command buffer and each batch instead of 40 and 48,
and three further items are development's own code again.

What a coherent device's command buffer did that development's does not, before this commit
(at 3363435164), with its cost and what this commit does:
- command.rs:300 `Gpu::coherence: Option<coherence::Recorded>`, 40 bytes (atom 8, the Writes
  Vec 24, reach 8), inside `Building` too. With one compute encoder a command buffer moves it
  by value about 14 times: into its Arc at the make (command.rs:413), open_encoder's take into
  the encoder (command.rs:470, encoder.rs:476), the encoder's take at its end (encoder.rs:1053),
  close_encoder (command.rs:484), the commit's take (command.rs:690), `Pending { gpu }`
  (command.rs:719), `Work::commit` into its entry (submit.rs:1604), `group.finished`
  (submit.rs:1999), the completion's `Retiree { Item::Command { gpu } }` (complete.rs:340) and
  its pop, and `retire(gpu)` (command.rs:1782). That is about 2-4 instructions a move for 40 more
  bytes. NOW `Option<Box<Recorded>>` (command.rs:301), one pointer, `None`; the box is made at
  the make on a device that is not coherent (command.rs:410, `Coherence::recording`). It is made
  at the make, not at the first write: a lazy box would need each recording site to read the
  device's coherence through its core, or an atom kept outside the box, and the commit still
  finds a reach from kept buffers with no write.
- submit.rs:546 `Batch::flushes: Option<Flushes>`, 48 bytes (two Vecs), moved with each batch.
  NOW `Option<Box<Flushes>>` (submit.rs:548), one pointer, `None`, boxed at the batch's first
  reach or copy-in (submit.rs:1924, 2068).
- counters.rs:661 the five coherence counters sat after `submit_infos`, moving every later
  counter 40 bytes from its place in development, including the submit thread's
  `submit_call_nanos` and the lock-wait counters (a layout change, no instruction). NOW they
  follow every other counter (counters.rs:892), so every development counter keeps its offset.
- encoder.rs:1223 and render_encoder.rs:2466, the dispatch's and the draw's facts: two tests
  (the encoder's recording, then its coherence) where development tested nothing. NOW
  development's `facts.host` is tested first (encoder.rs:1225, render_encoder.rs:2468), so a
  kernel or draw that writes no memory the host reads takes that one test.
- command.rs:1806 the retire: one test of the `None`, then its drop glue at the destructure, a
  second test. NOW the field moves out once (command.rs:1813) and the one `if let` takes it, so
  a `None` is tested once; `Gpu::is_empty`'s body is `nothing_for_the_gpu` over the segments, so
  the retire reads them past that move.

Left on a coherent device, each development's code behind one test of a `None` pointer: the
make (command.rs:410), the commit (command.rs:671), each command site (blit.rs:250, 495, 623,
745, 902, 1118; render_encoder.rs:901, 1618, 2041; encoder.rs:880; and the facts sites above),
the segment join (submit.rs:1923), each copy-in (submit.rs:2067), the submission
(submit.rs:2713), the retire (command.rs:1813) and each completion wake with listeners
(complete.rs:766); about 2-3 instructions each. The 8-byte pointer in `Gpu` (and so in
`Building`) and in `Batch` moves with them. Not per command buffer: each event's `settled`
field and a staged span's memory and size.

On a device that is not coherent the calls and ranges are as before; each command buffer
allocates its box at its make, and each batch at its first reach or copy-in.

Verified: cargo fmt. Not built when committed; the build job and the device and budget jobs
that follow name it.
2026-11-25 14:24:29 -08:00
Anees Iqbal 300747079a Runtime: a coherent device's command buffers hold no coherence state, behind one test each
On a device whose Shared type is host-coherent, the per-command-buffer path is development's
own code behind one test of an Option; nothing is built for the absent state.

Built per command buffer before, on a coherent device:
- an empty `coherence::Writes` and an `Option<Arc<Ranges>>` of `None` in its `Gpu`, built at its
  creation, carried to its retirement and dropped there;
- at every command that names a Shared write (each blit, render pass attachments, a render
  encoder's Shared buffer store, a dispatch's or a draw's facts, `use_resource`), a read of the
  device's `nonCoherentAtomSize` through the device's core; in both `use_resource`s a range
  slot in the declaration's tuple, filled through `Option::and_then`, and a call that tested it
  and returned;
- in each submission group and empty batch, two empty lists (the ranges of the command buffers
  reached and those of the copy-ins), destructured at submission, the first dropped there;
- on the completion thread, a tuple of two tests at each wake that fires listeners;
- in a shared event's `signaledValue` and wait, development's code restructured: the lock
  taken and dropped before the counter's read, and a call that tested the device's Option.

Left on a coherent device:
- the `Gpu` holds one `Option<coherence::Recorded>`, `None`, from one test of the device's
  coherence at the command buffer's creation; each command site tests it once
  (`Building::coherence`, a field of the recording), each `use_resource` keeps development's
  tuple and tests it once after the access;
- the commit, each segment that joins a group and the retirement test it once; a batch holds
  one `Option<Flushes>`, `None`, tested once at submission; each copy-in tests the device's
  coherence once;
- the completion thread tests the device's coherence once per wake that fires listeners;
- `signaledValue` and the wait are development's code behind one test of the device's
  coherence (`let`-`else`, `match`); each event keeps an 8-byte `settled` field, 0 and never
  read;
- not per command buffer: a staged copy's span carries its allocation's memory and size, and
  `replace_region`, `upload_region` and `get_bytes` test the device's coherence once each; the
  zero source's make takes one flag.

A device whose type is not host-coherent records into `coherence::Recorded` what the two
fields held, and a batch builds its `Flushes` only where one of its command buffers or copy-ins
reaches Shared memory; the calls and their ranges are as before.

Test: the device test of each device's coherence state now asserts that a new command buffer
holds the state exactly where its device does.

Verified: cargo fmt. Not built when committed: no build runs on this host; the build job and
the device jobs that follow name it.
2026-11-25 14:24:29 -08:00
Anees Iqbal e6df09cddd Docs: under m2v_shared_view a card that offers imports only cached types refuses every import
What: VALIDATION.md's m2v_shared_view entry gains the planner's sentence: under the view a card
whose host-pointer and dma-buf queries offer only its cached types refuses every import; run it
with the import families filtered.

Why: on the RX 7900 XTX (RADV) the host-pointer query offers type 5 alone (0x20) and the dma-buf
query types 5 and 10 (0x420); the view leaves neither coherent, so import.rs's rules refuse
every import there: 17 tests of the view's suite failed on that alone (job m3-max-73943). The
planner's ruling keeps the view and import.rs unchanged and filters those tests in the leg's
command line.

Verified: docs only.
2026-11-25 14:24:29 -08:00
Anees Iqbal a6ec647350 Tests: the refused shape's refusal arm is the CPU device's, by a match guard
What: tests::floor's a_device_with_no_cached_coherent_type_opens_where_the_floor_chooses_its_types
takes the floor's refusal under the view only under m2v_cpu_icd (a match guard), so a GPU refused
under the view falls to the arm that fails with its refusal; the assert!(cfg!(m2v_cpu_icd)) is
gone.

Why: clippy job m3-max-73942 (--cfg m2v_gpu --cfg m2v_shared_view, e1907acf0f) failed with
clippy::assertions_on_constants, "this assertion has a constant value", and it holds under every
device cfg.

Verified: not yet run (cargo fmt only); clippy in the device cfgs follows.
2026-11-25 14:24:29 -08:00
Anees Iqbal 6c1eb0e77c Runtime tests: m2v_shared_view runs the device suite through the refused device's view
What: a test-only cfg, m2v_shared_view, declared in metal2vulkan-runtime's check-cfg list beside
m2v_gpu_hazards and added to docs/VALIDATION.md's cfg table. Under it, Device::open gives every
device the tests make with no memory view of its own the refused device's view through the
landed seam: options.memory.or(Some(crate::tests::cached_types_incoherent)), which takes
HOST_COHERENT from every host-visible, host-coherent, host-cached type. A test that sets its own
view keeps it. The existing device suite then runs, unchanged, with Shared in a cached type that
reads not coherent, so it runs Shared memory's flushes and invalidates on memory that is coherent
in fact, which Vulkan allows. tests::coherence's every-device test asserts, under the cfg, that
every device builds the coherence state, and prints the Shared type and the calls.

Why: the planner's condition for A-narrow's proof on lab cards, which have no cached type that is
not coherent: a test that sets the option, no second suite, no env var.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:29 -08:00
Anees Iqbal 9661df630a Tests: the refused device's view opens a GPU, with the coherence state
What: tests::floor's seam test becomes
a_device_with_no_cached_coherent_type_opens_where_the_floor_chooses_its_types. Through the
refused device's view (crate::tests::cached_types_incoherent) every device answers at its make as
floor::choose over the view does. Every GPU opens: Shared takes the first cached type, which the
view left not coherent, and the device holds the coherence state. A device the choice refuses is
refused with that refusal: lavapipe, whose one memory type holds the parameter ring too and is left
with no coherent type. A GPU refused under the view fails the test.

Why: with Shared's floor item host-visible and host-cached, the user's shape (no type both cached
and coherent) no longer refuses a GPU; this test is that fix seen on our cards.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:29 -08:00
Anees Iqbal 31ca7f6779 Runtime: Shared coherence only where the Shared type is not host-coherent, decided at the make
What: Device::new reads the HOST_COHERENT flag of the memory type floor::choose took for Shared
once, at the make (Coherence::of). Core::coherence is now an Option<Coherence>, built only where
that type lacks the flag. A device whose Shared type is coherent keeps no ranges and makes no
flush or invalidate: every site of the flush form asks the Option first (Building::atom now
answers Option<u64>), so a commit finds no Ranges, a retirement, a submission, a shared event's
signal seen, replace_region, upload_region, get_bytes and the zero source's make each make no
call, and the encoders name no write. flush and settle are now methods of Coherence, so only a
device that holds one can make them. The type rule stays sharedflush's: the first host-visible,
host-cached type, a coherent one first. Where the type is not coherent the form is unchanged.

The flush and invalidate on a coherent type are legal (vkspec 1.4.366, "Host Access to Device
Memory Objects"): "If the memory object was created with the VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
set, vkFlushMappedMemoryRanges and vkInvalidateMappedMemoryRanges are unnecessary and may have a
performance cost." The VkMappedMemoryRange VUIDs name no type flag: memory-00684, size-00685,
size-00686, offset-00687, size-01389 and size-01390 (offset and size at multiples of
nonCoherentAtomSize or the allocation's end, inside the mapped range). So the device suite can
run the form on memory that is coherent in fact, through the test-only memory view.

tests::coherence: every device holds a coherence state exactly where its Shared type is not
coherent, and its work's calls follow (zero calls where it holds none); every GPU read through
the refused device's view (crate::tests::cached_types_incoherent) holds it and makes sharedflush's
counted calls. README, the Metrics docs, floor::SHARED_MEMORY and MemoryClass::Shared say the
calls happen only where the type is not coherent; the known gaps say no lab device can show a
missed flush, only a device whose Shared type is cached and not coherent can.

Why: sharedflush's form, with its calls on every device, cost 1.038 to 1.047 of the runtime's
instructions on four harness rows on the 780M (m3-max-73790). This is A-narrow, offered to the
owner beside B: an eleventh form, so it does not land without his word.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:29 -08:00
Anees Iqbal 70821f0032 Runtime: a Managed synchronize names coherence's Range by its path
What: blit.rs names crate::coherence::Range by its path and drops the import, since the module
already imports std::ops::Range.

Why: build job m3-max-73781 (8178f7796a) failed with E0252, the name Range defined twice.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:29 -08:00
Anees Iqbal e13ed258d5 Runtime: Shared coherence's bookkeeping trimmed; a Managed buffer's device copy is its GPU reach
What:
- BufferObject::shared_range (and shared_span) answers None for a Managed buffer with a device
  copy. Its commands reach the copy, so neither a command buffer's reach at submission nor its
  writes at completion name the block of the buffer's bytes. Two calls touch that block: a
  copy-in (did_modify_range), whose submission flushes the bytes it reads
  (CopyIn::shared_ranges), and a synchronize (read_back), which now names the block's bytes
  itself (Range::of_block of the held block) as a write, so its command buffer's completion
  flushes and invalidates them. Each of the two flushes or invalidates its own bytes there,
  which is why the GPU reach can leave the block out.
- Writes holds a Vec, not a HashSet: no hashing, and no RandomState per command buffer. A range
  named again right after itself is held once, and the ranges are merged in place each time
  their count reaches a power of two from 64.
- merge() sorts and merges in place (Vec::dedup_by) in place of merged()'s second Vec.
- flush and settle build their VkMappedMemoryRange array on the stack for up to 8 ranges.
  settle builds it once for both calls and sums the bytes once.
- A submission of one command buffer and no copy-in flushes that command buffer's ranges,
  already merged at its commit, with no new Vec.
- README and module doc: the submission's reach leaves out a Managed buffer with a device copy.

Why: job m3-max-73772 (RX 7900 XTX, c030b1b4bd against 4fb7684a62, three alternated passes)
put the runtime's own instructions per timed run 4.7 to 6.7% over the before arm on the frame
and burst rows, about 1,300 to 1,600 instructions a command buffer, past the 1.03x gate. Job
m3-max-73773 (Iris Xe) put them about 1,650 to 1,700 a command buffer over. Most of that was
heap allocation and hashing per command buffer, and on a discrete GPU a Managed buffer's host
block counted as reached. Same form: every call is still made on every device, with no branch
on the type's flags.

Verified: not yet run (cargo fmt only). The alternated job is re-run on the 780M first, then
the XTX.
2026-11-25 14:24:28 -08:00
Anees Iqbal 1a57dc490e Tests: the coherence test's texture takes no index
What: tests::coherence makes its 4x4 texture with Device::new_texture_for_views, which takes no
index, in place of new_texture with no index.

Why: on lavapipe (job m3-max-73732, ef7f03df3f) new_texture refused a texture that shaders read
with no index (Refusal::TextureIndex), before the test reached its copies. The other assertions
of the test ran no further, so they are still unverified.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:28 -08:00
Anees Iqbal 28080d9ecc Runtime: a shared event's settle keeps in-flight command buffers from letting go meanwhile
What: Coherence::signal_seen now settles the written ranges of the command buffers in flight
while it holds the flight list's lock. A retiring command buffer calls Coherence::retired, which
takes the same lock and drops its entry, after its own settle and before it lets go of its blocks
or lowers the pool's in-flight count.

Why: signal_seen took strong references to the ranges, released the lock, then flushed and
invalidated. A command buffer that retired in that window gave its blocks back, so a call could
name memory the command buffer no longer held: an allocation the block-maker may free, or a
range another take now owns.

Verified: not yet run (cargo fmt only).
2026-11-25 14:24:28 -08:00
Anees Iqbal 7c187b52e7 Tests: the cached-type choice's last case lists a ring type
What: shared_storage_takes_a_cached_type_a_coherent_one_first's last case, a buffer that cannot
use the coherent cached type, gave choose() no device-local, host-visible, host-coherent type, so
choose() refused it for the missing ring type rather than answering the Shared index. The list now
has one (type 3), and the buffer's usable bits take types 0, 1 and 3.

Why: job m3-max-73726 (9589aa5b0c, lavapipe) failed the test with
Err([MemoryType { flags: DL | HV | HC, .. }]) against Ok(1).

Verified: not yet run (cargo fmt only); the next quick check runs it.
2026-11-25 14:24:28 -08:00
Anees Iqbal ac99e3f7d8 Runtime: Shared coherence's README, counters test and the named bytes' flush
What: the README's memory section gets "Shared memory's coherence": where each flush and
invalidate falls, what a command buffer may write, the atom widening, the counters, and the
consumer's contract (a range reached only through an address with no declaration is neither
flushed nor invalidated where the Shared type is not host-coherent; the consumer's own host
accesses are its own). The known gaps of memory blocks name three things on such a device: the
calls' time as its cost (unmeasured, since no lab device has such a type), a host write racing
the GPU's in an atom it writes (quoting Vulkan's invalidate-without-flush sentence and the
nonCoherentAtomSize definition), and a buffer reached only through a residency set. The floor's
memory table row for Shared becomes HOST_VISIBLE and HOST_CACHED, with a coherent type first.

Texture::upload_region now flushes the named bytes it copies, from the region's first byte to
the end of its last at the place's pitches (Transfer::extent, BufferObject::shared_span). The
first commit missed this GPU read of host-written Shared memory: it is part of no command buffer
and is not a copy-in.

New device test tests/coherence.rs, under the device cfgs. The zero source is flushed at its
make. A fill into a Shared buffer counts [2 flushes, 2 x atoms, 1 invalidate, atoms, 0
failures], and its bytes read back. A fill into a Private buffer makes no call. replace_region
flushes once and get_bytes flushes and invalidates once, and the texels round-trip.

The api_signatures table gets the five new Metrics fields (signatures.py --bless).
docs/REFUSALS.md regenerated with no change: the floor's Missing text holds no flag names.

Verified: not yet run (cargo fmt only). The quick check and device legs follow.
2026-11-25 14:24:28 -08:00
Anees Iqbal 2c4680acea Runtime: Shared storage takes a host-cached type, flushed and invalidated on every device
What: the floor's Shared item becomes host-visible and host-cached; Shared storage takes the
first such type a buffer can use, a host-coherent one first (floor::choose). A new module,
coherence, makes the flushes and invalidates Vulkan asks of a type without
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, on every device, never reading the type's flags:

- before each submission, a flush over the Shared memory its command buffers keep (buffers,
  textures over buffers, heap blocks) and the ranges its Managed copy-ins read;
- before the host can see GPU progress, a flush then an invalidate over what a command buffer
  may write: as it retires (before its status, waits and completed handlers), and over every
  command buffer in flight before a shared event's GPU-raised value reaches a listener,
  signaledValue or a wait. What it may write: blit destinations, written bindings of the
  function's interface, use_resource with a write, render attachments, the visibility buffer,
  synchronize targets, every used heap's Shared block, textures over Shared buffers in images
  of their own;
- the runtime's own accesses: replace_region's staging span flushed after the rows are
  written, get_bytes's span settled before it is read, the zero source flushed at its make.

Ranges are widened to nonCoherentAtomSize inside the whole-mapped pool blocks. Imports are
unchanged (their type is host-coherent; Vulkan maps none of them). Exported blocks and surfaces
take the Private type and have no host mapping (export.rs, surface.rs), so they are never
flushed. Metrics gains shared_flushes, shared_flushed_bytes, shared_invalidates,
shared_invalidated_bytes and shared_coherence_failures.

Why: a Meteor Lake device on Mesa's Intel driver with the i915 kernel driver lists
[DL|HV|HC, DL|HV|HCached] and has no host-visible, host-coherent, host-cached type, so the
floor refused it at device creation. The lab's lists all have an HV|HC|HCached type, which
choose() still takes first: their index is unchanged.

Verified: not yet run (cargo fmt only). Still to come in later commits: README, the generated
refusal surface and signatures table, a device test of the counters, and the device legs. The
flush's effect on that device is unaudited until the user boots it.
2026-11-25 14:24:28 -08:00
Anees Iqbal f4f6fd32cf Observations: the AIR 1.8 sampling case matches Metal on Intel's Iris Xe under ANV
corpus-vulkan (job m3-max-73981, venue intel-irisxe-rplp-anv: Intel Iris Xe Graphics (RPL-P),
Mesa 26.2.6) runs case 884ad7d75a22 through the runtime under the validation layer: Match, the
candidate's output 7d65bff73d82 equal to Metal's bytes on the M3 under macOS 27.0.1.
2026-11-25 13:37:09 -08:00
Anees Iqbal c718924d44 CI: qualify the AIR 1.8 sampling case on lavapipe with the other public cases
scripts/qualify-public-cases runs case 884ad7d75a22 against its committed Metal row. Run by hand
under the same operator environment (ci-lavapipe, job m3-max-73980 on lavapipe 23.1.1): Match,
candidate output 7d65bff73d82, Metal's bytes.
2026-11-25 13:37:09 -08:00
Anees Iqbal f97ad936de Observations: Metal qualifies the AIR 1.8 sampling case on the M3 under macOS 27.0.1
corpus-metal (job m3-max-73969, Apple M3 Max, macOS 27.0.1 26A434) qualifies case 884ad7d75a22:
its three executions agree, and the 4x4 target holds (x + 1, y + 1, 4y + x, 0.5) at every pixel,
the value the case's rationale derives (checked against the recorded bytes).
2026-11-25 13:37:09 -08:00
Anees Iqbal ad264bd34b Tests: air_1_8_sampling's golden printout, blessed with LLVM 21.1.8's llvm-as
bless_engine_goldens on the M3 (job m3-max-73966; its llvm-as is the pinned major, 21.1.8): the
new fixture's printout; no other printout moved.
2026-11-25 13:37:09 -08:00
Anees Iqbal 2d36b67c38 Cases: an AIR 1.8 fragment that samples plainly and by gradient through an argument sampler
The authored case over engine/air_1_8_sampling (case 884ad7d75a22, installed by
corpus-case-check --manifest --install in job m3-max-73936): a 4x4 rgba32_float target whose
pixels take their position over 4 as the coordinate, a texel center of the 4x4 rgba32_float
texture, so the nearest plain sample and the gradient sample (derivatives exactly 0.25, level 0)
read one texel, and the output (a + b) * (0.5, 0.5, 0.5, 0.25) is exact on every device. It runs
the AIR 1.8 forms an old library declares (the sample without a minimum level-of-detail clamp or
access operand, the buffer with a size and no address space, the render target with the
attachment alone) on Metal and on Vulkan.

Not yet qualified at this commit: the Metal run and the Vulkan candidate follow.
2026-11-25 13:37:09 -08:00
Anees Iqbal ddf99ea3e9 Fixtures: air_1_8_sampling's rows in the engine inventory, blessed on the M3
Blessed with bless_engine_inventory (job m3-max-73940 on the M3, which has every assembler): the
fixture's one entry, a18_sample_fs, compiles (ok) on all 15 profiles from both its typed .air.ll
and its .ll; no other row moved.
2026-11-25 13:37:09 -08:00
Anees Iqbal 787072ecab Fixtures: air_1_8_sampling's companions from scripts/regen-air-fixtures
The .ll (llvm-dis 21.1.8 of the AIR) and the typed .air.ll that xcrun metal wrote for the
fixture's source (Apple metal 32023.922, macOS SDK 27.2), and its TOOLCHAIN line. Generated by
job m3-max-73924 on the M3. The module is AIR 1.8 (triple air64_v18-apple-macosx10.11.0) and
declares air.sample_texture_2d.v4f32 with 7 parameters and air.sample_texture_2d_grad.v4f32 with
7, its buffer with air.buffer_size and no air.address_space, and air.render_target with the
attachment alone.
2026-11-25 13:37:09 -08:00
Anees Iqbal 85a39d3ab1 Fixtures: air_1_8_sampling, a fragment's sampling at AIR 1.8 (source only)
The owned MSL source of an AIR 1.8 fixture whose fragment samples through an argument sampler,
plainly and with a gradient, reads a constant buffer and writes one render target: the forms an
AIR 1.8 library declares before AIR 2.0 (the sample without a minimum level-of-detail clamp or
access operand, the buffer with a size and no address space, the render target with the
attachment alone). Its companions follow from scripts/regen-air-fixtures on the M3.
2026-11-25 13:37:09 -08:00
Anees Iqbal 3aea8c21ed Census at db3a88526b: the authored compile census is unchanged after the AIR 1.8 reader and the stencil rule
What: corpus/authored-compile.tsv's artifacts_at line names the product at db3a88526b
(e81e0423...). No case's row moves.

Why: the pin at db3a88526b records the census at its tip. legacybc's reader (c5cedb39b3) changes
what the AIR front end accepts, and stencilclass (db3a88526b) changes validation's candidate
executor.

Verified: census job m3-max-73999 on the M3 at db3a88526b: 2347 cases over 9 profiles, 21123 cells,
19539 compiles, 18829 compiled, 2294 refused, 0 failed, 0 differences, 0 regressions.
2026-11-25 13:31:33 -08:00
Anees Iqbal 404c36aa00 Golden at db3a88526b: the table's semantics line moves to 2304; no hash cell moves
What: crates/metal2vulkan/tests/golden_hashes.tsv's semantics line goes from 2303 to 2304, the
SEMANTICS_VERSION that legacybc's reader commit set (b6b940fd5f). Every golden hash cell is equal.

Why: the pin at db3a88526b gets its bless at that tip, so the golden test's class check reads the
SEMANTICS value of the last pin.

Verified: bless job m3-max-74000 on the M3 at db3a88526b. The inventory, golden and printout blesses
exit 0, and the bless patch is this one line (678 bytes).
2026-11-25 13:31:33 -08:00