Commit Graph
4849 Commits
Author SHA1 Message Date
Anees Iqbal 6f29ec3f67 RUNTIME_VERSION 2151: GPU times from the host start at the first submission that carried the work
The commits before this one. On a device made with DeviceOptions::gpu_times_from_host, a command buffer's
GPUStartTime was its kernel end, the call of its LAST submission, so a command buffer whose batches went as several
submissions dropped its earlier work from its GPU window (a consumer's profile: 2-8 s of work reported as 0-240 ms,
kernel end to GPU start 0.00 ms). KernelTimes now records the first driver submission call that carried a batch of
the command buffer (its own vkQueueSubmit or its group's call); the host-clock start is that call where it came
before the kernel end, else the kernel end as before, raised to the queue's latest GPU end where later. A command
buffer of one submission answers as before; devices that write timestamps were already right. Docs: gpu_time.rs,
gpu_start_time, DeviceOptions::gpu_times_from_host, the GpuTimesFromHost cost text and its API.md entry. Also: the
queue-times test holds heads, kernel starts and ends, and returns each in commit order (grouped batches can return
from one call).

Verified (on the branch): runtime_lane::gpu_times::a_command_buffer_of_two_submissions_is_timed_from_its_first_work_to_its_last
(a fill, a wait for an event the host signals 200 ms after the commit, a fill; timestamps and host times): lavapipe
(m3-max-22756) fails before the fix with host times (start +0.376 ms after the signal, the kernel end) and passes
after (-199.8 ms); Radeon 780M (m3-max-22792) passes both ways. lavapipe gpu_time + kernel_end_device 16/16, lane
gpu_times 12/12 (22782), degradation catalogue 17/17 (22797); 780M lane gpu_times 12/12, runtime 16/16 (22811).
Lint (m3-max-22812): clippy every feature, m2v_gpu, m2v_cpu_icd, rustdoc, api tests.
2026-11-12 14:35:38 -08:00
Anees Iqbal 037bae0cd6 Test: queue times come in commit order, grouped batches returning from one call
queue_times_are_noted_in_the_order_of_a_queue_s_submissions_and_only_where_asked
held each command buffer's kernel start after the return of the one
before it. Batches that wait in a group for one kernel submission begin
and are held before the call that carries them all returns: on the 780M
(RADV, job 22793) the second and third of three back-to-back fills
returned from one call, the third's kernel start 66 us before it. The
test now holds heads, kernel starts and ends, and returns each in commit
order.

Verified: pending the 780M rerun.
2026-11-12 14:35:01 -08:00
Anees Iqbal 1b1ebfd055 GPU times from the host start at the first submission that carried the work
A command buffer whose work went as several submissions (a wait for an
event the host signals, an execution its host step records) answered,
on a device made with gpu_times_from_host or a driver whose timestamps
wait for every queue's, the call of its LAST submission (its
kernelEndTime) as its GPUStartTime: its window missed the work of its
earlier submissions. Metal's GPUStartTime and GPUEndTime span the whole
command buffer's GPU work. A consumer that answers GPU times from the
host read windows of 0 to 240 ms on an Iris Xe for command buffers whose
kernel start to end spanned 2 to 8 s, each GPU start at the kernel end.

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

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

Verified: pending lavapipe before and after, the 780M, lint.
2026-11-12 14:35:01 -08:00
Anees Iqbal d5a91164c8 Test: the two-submission command buffer's times, also with GPU times from the host; drop the making split
The lane test runs on the device as made and on one made with
gpu_times_from_host, whose GPU start is answered from the host's clock:
there a command buffer whose work goes as two submissions must start
before the host's signal its second waits for, as its first fill's work
ran then. The runtime test of a command buffer a pipeline's making
splits goes: on lavapipe its batches went as one submission at the
commit (kernel end 299.9 ms before the hold's end, job 22710), so it
tested no split.

Verified: pending the lavapipe run at this commit and the fix after it.
2026-11-12 14:35:00 -08:00
Anees Iqbal 672a406767 Test: a command buffer a pipeline's making splits is timed from its first work to its last
A command buffer whose draw's pipeline is still being made at its commit
(PipelineWaitPolicy::Exact, the pool's test hold dropped 300 ms after the
commit) goes as more than one submission: the fill before the pass at
once, the pass once its host step recorded it. Its GPU start must be the
fill's, before the hold went, and its end after it. Run with the merge
check as found and forced to hold, so its batches may wait in a group.

Verified: pending the lavapipe and 780M runs.
2026-11-12 14:35:00 -08:00
Anees Iqbal bef09b0369 Test: a command buffer of two submissions is timed from its first work to its last
A command buffer whose work goes as two submissions 200 ms apart (a fill,
a wait for a shared event the host signals 200 ms after the commit, a
fill) must answer Metal's GPUStartTime at its first fill, before the
signal, and its GPUEndTime at the second, after it. A guest profile on
an Iris Xe read GPU start..end spans of 0 to 240 ms for command buffers
whose kernel start..end spanned 2 to 8 s, the GPU start at the kernel
end.

Verified: pending the lavapipe and 780M runs.
2026-11-12 14:35:00 -08:00
Anees Iqbal 47d48eb4c1 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 14:34:43 -08:00
Anees Iqbal c86f4c2f9e RUNTIME_VERSION 2150: a texture turns no face after an execution of indirect commands in its command buffer
The three commits before this one. A pass that turns a texture's faces rewrites its heap elements; an execution of
an indirect command buffer earlier in the same command buffer records its commands at the commit or in a host step,
after the pass opened, and had bound no heap set when the turn was decided, so it read the face the pass turned to
(stale texels) though it runs before the pass. defer_execution (compute and render) now marks the command buffer's
heap use as executing later (HeapUse::executes_later), and the turn point asks HeapUse::may_bind (bound or later):
such a pass turns nothing (Unturned::Busy) and copies in, as after an earlier heap bind. HeapUse::bound is
unchanged. Docs: faces.rs. An encoding again hands no face-resolving work to another thread (audited: replays run
on the rebind's thread inside the faces-as-of context; the scheduler's later segments resolve nothing).

Verified (on the branch): attached_read_faces::an_execution_before_a_clearing_pass_reads_the_texels_from_before_it
(an execution reading the texture through an argument buffer, then a clearing pass) fails without the fix (the pass
turns; the execution reads 0x40 and 0) and passes with it (busy 1, swaps 0, 180 texels copied in; reads 0x50 and
0x20) on lavapipe (m3-max-22819) and M3 / MoltenVK (m3-max-22818); clippy plain, m2v_gpu, m2v_cpu_icd
(22820-22822).
2026-11-12 14:34:03 -08:00
Anees Iqbal 409c7f6ac2 Faces test: the face a turn would take holds the first read's 0x40, and nothing outside it
The execution test's comments said the other face holds 0x10 outside the
rectangle; the first read copies in only what its draw reads, so it holds no
texel of the texture there (lavapipe read 0, m3-max-22819). Comments only.
2026-11-12 14:33:27 -08:00
Anees Iqbal 644e670dd9 A texture turns no face after an execution of indirect commands in its command buffer
What: an encoder that leaves an execution of indirect commands to record later
(compute and render, defer_execution) notes it on its command buffer's heap
use (HeapUse::executes_later), and a pass's turn point takes that as bound
heaps (HeapUse::may_bind): the turn is refused (Unturned::Busy) and the pass
copies in, as where an earlier command bound a heap set. Docs: faces.rs
(When, Unturned::Busy, TurnPoint).

Why: a turn writes the texture's heap set elements again, so it is refused
where a command of the command buffer bound a heap set: such a command runs
before the turning pass and would read the new face through the texture's ID.
An execution's commands are recorded by the commit or a host step, after the
pass opened, so they bound no heap set yet when the turn was decided, and read
the face the pass turned to (stale texels) through an argument buffer naming
the texture. An encoder encoded again after a rebind leaves its execution to
record later as its first encoding did, so the turn its pass decided is
refused alike.

Verification: the previous commit's test, without and with this change, on
lavapipe and one device; results go with the hand-off.
2026-11-12 14:33:27 -08:00
Anees Iqbal c263c377ac Test: an execution before a clearing pass reads the texels from before it
What: attached_read_faces gains a third test. In one command buffer, a compute
encoder executes an indirect command buffer whose command (rt_heap_zero) reads
the texture through an argument buffer naming its resource ID, at a texel
inside the rectangle and one outside; then a pass clears the texture and reads
it. The faces were made earlier, so the texture's own face holds 0x50/0x20 and
the other face 0x40/0x10. The test asserts that the command reads 0x50 and
0x20 (Metal's answer: the texels from before the pass), that the pass turns
nothing (busy), and that the pass leaves its own texels.

Why: the commit records an execution's commands, so they bind the heap sets
after the pass opened. A turn there rewrites the texture's heap elements to
the face it turns to, and the command, which runs before the pass on the GPU,
reads that face's stale texels. The turn is refused only where a command of
the command buffer bound a heap set by then, which an execution's command has
not.

Verified: see the next commit, whose fix this test checks.
2026-11-12 14:33:27 -08:00
Anees Iqbal 1125fb62d2 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 14:09:13 -08:00
Anees Iqbal 2b49475f91 RUNTIME_VERSION 2149: a merged color's keep follows its copy in after an inline first instance
The two commits before this one. A render pass whose attachment a draw fetches through a scratch (the image over
host pages can't take STORAGE) and whose first instance records inline gets the stand-in's copy in only after that
first instance; the linear merge's keep was still recorded before the pass, so it snapshotted whatever the scratch
already held. From the second round on the scratch is the previous round's recycled image, so the merge dropped
every word the later instances wrote that matched those stale bytes: the fetching draws' output was lost (a
guest's Dock icons drawn as rims on MoltenVK). The keep is now recorded right after the copy in, at both places
that record it (keep_in_pass). Docs: render/inline_first.rs, linear_merge.rs.

Verified (on the branch): M3 / MoltenVK (m3-max-22709): the new fetch_composite case
a_loaded_srgb_composite_over_host_pages_through_a_scratch_keeps_every_draw (RGBA8Unorm_sRGB over host pages,
loaded, always through the scratch) fails without the fix (round 1: 3072 wrong pixels, 4 instances, 1 inline pass,
1 linear merge) and passes with it, with the other 3 cases; lavapipe (m3-max-22715) 4/4 (input attachments, route
unchanged); clippy plain, m2v_gpu, m2v_cpu_icd (22712-22714). The case relies on the recycled scratch keeping the
previous round's bytes, as MoltenVK's does.
2026-11-12 14:08:32 -08:00
Anees Iqbal 663c564484 A merged color's keep follows its copy in after an inline first instance
What: where a pass's first render pass instance records inline, a color over a
buffer's bytes rendered through a stand-in (a fetched texture's scratch) is
copied in right after that instance, as before; its linear merge's keep was
recorded before the pass. It is now recorded right after that copy
(LinearMerge::keep_in_pass), in both places that record the copies after the
inline instances (a pass recorded at its end, and one that records later), as
the keep after a pin already was. Docs: render/inline_first.rs and
linear_merge.rs's keep_in_pass.

Why: the keep taken before the copy in held whatever the stand-in's image held
then, and the merge after the pass writes only the words that differ from the
keep, so it dropped every word the later instances wrote that equalled it. On
MoltenVK the scratch was the previous round's image, recycled with that round's
pixels, so a pass that drew the same pixels again lost everything after its
first instance, a compositor's fetching draws among them. Nothing ties it to
MoltenVK: any device whose recycled or fresh scratch holds bytes equal to
what the later instances write loses them.

Found by ratemap (the candidate fix, unbuilt); applied here on development.

Verification: the previous commit's sRGB case, on the M3 (MoltenVK) without
and with this change, and on lavapipe; results go with the hand-off.
2026-11-12 14:07:55 -08:00
Anees Iqbal e5b8db79f6 Test: a loaded sRGB composite over host pages renders through a scratch and keeps every draw
What: fetch_composite gains a target format, and a case whose target is
RGBA8Unorm_sRGB over a no-copy buffer's host pages, loaded from what the CPU
wrote there. On a device that fetches through storage such a target always
renders through a scratch: the fetching draws read and write it through an
unsigned-integer view no texture's image is made mutable to. The pass's first
icon records inline into the target itself; the scratch arrives with the first
fetch, takes the target's texels after that instance, and the words the later
instances change are merged back into the pages (linear_merge.rs). Codes are
the device's own sRGB conversions, compared within one code. Where the target
is in place and the device fetches through storage, the case also asserts that
a linear merge ran, so it checks the scratch route rather than another. Each
round reports its inline passes and linear merges with the pixels.

Why: fix (1) made the RGBA16Float target over host pages fetch in place on
MoltenVK, so the existing case no longer reaches the scratch route, which lost
the fetching draws' output there (the second round kept the CPU's background
wherever an instance after the first drew). The sRGB target forces that route.
In the second round the scratch is the first round's image, recycled, still
holding that round's pixels, which is what the merge's keep read.

Verified: see the next commit, whose fix this test checks.
2026-11-12 14:07:54 -08:00
Anees Iqbal 66e521a807 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 14:05:00 -08:00
Anees Iqbal 4cf7196a0c RUNTIME_VERSION 2148: a logged pass turns its faces, and an encoding again meets the faces as its first encoding did
The five commits before this one. A render pass that logs its calls (while a host-page buffer is alive) was given
Unturned::Pass, and so did a pass after an earlier logged encoder: its attached reads copied in where they could
turn faces. Now a logging pass turns as it would unlogged. Each encoding again (command_buffer/reencode.rs: a
replay, and work recorded on the GPU alone) runs inside a context naming its command buffer and the encoder's
parts, so Faces::face() gives the face from before any turn a later part of the same command buffer made, and the
turning pass encoded again retakes its turn (Texture::retake_turn) with no copy in. Under METAL2VULKAN_LOG_SHADOWS
(default off) each shadowed texture gets one line at the first draw that binds it: its slot, whether the function
fetches, samples or writes it, and each sampler's filters. Docs: faces.rs, face_swap.rs, reencode.rs, work_counts,
API.md, env_vars.rs.

Verified (on the branch, at ca76fa2ebf): lavapipe (m3-max-22636) runtime attached_read|face|reencode|rebind 80/80,
validation 141/141, sync validation 25/25; Radeon 780M (m3-max-22667) runtime 80/80, lane 26/26, sync
logged_face_turns 1/1. New tests attached_read_faces::a_logged_pass_turns_and_its_encoding_again_meets_the_faces_as_first_met
and runtime_lane::logged_face_turns: the logged pass swaps with 0 texels copied in (180 before); a rebind encodes 2
encoders again, none refused, 0 copied in; pixels byte-equal to the copy route. With the context switched off the
lane fails (EncodedUseRebound). Lint (m3-max-22674): fmt, clippy default/gpucfg/cpuicd, rustdoc.
2026-11-12 14:04:15 -08:00
Anees Iqbal 8b58dcca6f Faces tests: the copy route's lane runs with no rebind
A rebind of its buffer is refused (EncodedUses), as the runtime holds a command buffer's pages
until it completes where a host step records part of it: that lane's pass's first copy in goes to
its batch's submission (shadow_standing.rs, GatedCopyIn). A throwaway probe on lavapipe showed the
turned lane's rebind made and the copy route's refused, with no shadow_texels_unskipped count
moved (a gated copy). The copy route's lane now runs the same command buffer with no rebind, and
the turned lane's bytes, through the encoding again, are compared with it. The passes' corners
from the pages stay; the earlier commit's reason for them was wrong.
2026-11-12 14:03:31 -08:00
Anees Iqbal 292071246c Faces tests: every lane pass takes its corners from the pages
The first run (gem10, lavapipe, job m3-max-22514) refused the rebind with EncodedUses in both new
tests: the turning pass was the first draw to read its corners from a buffer, and its pipeline
variant was still being made at the commit. Every pass of the lane now takes its corners from the
pages, so the variant is made before the command buffer behind the wait.
2026-11-12 14:03:31 -08:00
Anees Iqbal 490db00052 Re-encode: the encoder's last part read from the back
Clippy's double_ended_iterator_last on 14854f2473's lint job.
2026-11-12 14:03:31 -08:00
Anees Iqbal 834819bdb6 Shadow log: the first-draw line names its samplers (the format's argument was misnamed)
Caught by the lint job's build of 981a131409 (E0425); not yet built again.
2026-11-12 14:03:31 -08:00
Anees Iqbal 6014ad370d Faces: a logged pass turns, and an encoding again meets the faces as first met
While the device has a buffer over host pages, every render pass logs its calls for a rebind,
and a pass with a log, or with an earlier encoder of its command buffer keeping one, turned no
texture (Unturned::Pass): under a consumer that keeps host-page buffers alive, no attached read
ever took the turn and every one copied in.

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

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

Tests: the runtime's attached_read_faces gains a lane with a host-page buffer alive (a logged
pass turns; a blit and a turning pass behind a shared-event wait, encoded again by a rebind, read
the texels from before the turn), against the same lane beside an open command buffer (the copy
route); the validation crate's runtime_lane::logged_face_turns runs the same under the layer.
Not yet run: dispatched next.
2026-11-12 14:03:30 -08:00
Anees Iqbal 7926fa6e66 SEMANTICS_VERSION 2062: the predicated walk's size estimate charges what the walk emits
The commit before this one. The emulated-simdgroup variant (a dispatch whose threadgroup leaves a partial
simdgroup) took its size forecast from divergent::extra_words: 512 words per AIR block and 12 per operand use, about
15M words on a large kernel, so two kernels of a guest's path tracer (4.0M and 4.5M words emitted) were refused
LimitExceeded(SpirvWords) before emission, where Metal makes them. The estimate now charges each construct the walk
emits beyond the plain walk, from the structured tree (guards per segment, syncs and their guarded stores, reloads
of demoted uses, flag and vote words per walked loop, arm sequencing per walked branch); each constant names the
emitter code it bounds. Translation results change: modules that were refused now translate.

Verified (on the branch): nextest -p metal2vulkan --all-features (m3-max-22642) 3500/3501, the one failure
golden_hashes from SEMANTICS_VERSION 2061's pending re-bless (blessed since at pin 59; this commit changes no
emitted word); the shared test helpers assert estimate >= emitted on every Emulated-tier or walked module the
engine suites build; a_large_predicated_body_compiles_under_a_cap_it_fits (old forecast ~20x emitted). Lint
m3-max-22643. Release translation, amd-780m-radv profile (m3-max-22644): the two kernels' emulated variants at
1.64 s / 256.6 MiB and 1.99 s / 287.4 MiB, within 20 s / 500 MiB. Census over the 3,781 simd/quad/barrier rows
on vk12-floor (m3-max-22649) pending.
2026-11-12 13:57:58 -08:00
Anees Iqbal 2464994609 Predicated walk estimate: charge each construct the walk emits, from the structured tree
The size estimate of a kernel walked predicated (the emulated simdgroup tier, or a workgroup
synchronization in divergent control flow) charged 512 words per AIR block and 12 per operand
use. A large kernel's forecast was several times its emitted size, so its emulated-simdgroups
dispatch variant was refused LimitExceeded(SpirvWords) before emission although its module
fits the cap (4.04M words emitted against a forecast over 2^24).

The charge is now a bound derived from what the walk emits beyond the plain walk:
- per AIR block (divergent::extra_words): the live load before a guarded block, one `if live`
  per guarded segment (synchronizations + 1), per synchronization its predicated form and the
  guarded store of its demoted result, one load per use a guarded segment may reload (counted
  with the demotions), and the walk's frame once;
- per statement of the structured tree (structurize::emit::construct_words, measured at the
  end of planning from the same view emission structurizes): the live-select stores of
  selector and pending writes, the flag stores of break and continue, the live store of a
  divergent return, the guard of a statement run as it is, the condition reload, literal
  comparisons and sequential or guarded arms of a walked branch, and a walked loop's flags,
  exit test and workgroup vote.
Each constant names the emitter code it bounds.

The shared test helpers (typed_module_with, compile_kept) now check that the estimate bounds
the emitted words of every module of the emulated tier or the predicated walk the engine tests
build, and a large predicated body (256 diamonds after a divergent simdgroup sum) compiles under
a cap of eight times its emitted words.
2026-11-12 13:57:21 -08:00
Anees Iqbal 86d01646ae Re-bless the golden tables at 05a719a9d2
34 golden-hash rows move: the heap-reading kernels (a4_heap_sample, a4_heap_textures, cfb_ts_copy_held and the
other rows whose float reads, samples, gathers or queries may meet a raw-texel heap texture) now carry
SpecKey::HeapRawTextures's specialization constant and one OpLogicalAnd per raw-arm site (SEMANTICS_VERSION 2061).
That change's own run (m3-max-22504) showed golden_hashes failing for exactly those rows. No engine golden,
printout or inventory row moves.

Verified: bless on the M3 at 05a719a9d2 (m3-max-22661): golden hashes blessed, engine goldens pass; merged check at
the same sha on msi (m3-max-22658): clippy every crate with --cfg m2v_gpu, api_signatures, api_surface,
fast_paths 43/43, rustdoc -D warnings.
2026-11-12 13:56:56 -08:00
Anees Iqbal 05a719a9d2 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:52:25 -08:00
Anees Iqbal 0c348e0f95 RUNTIME_VERSION 2147: a render target in place over host pages takes the storage usage without the feedback-loop usage
The three commits before this one. An image in place over host pages tried STORAGE only together with the
attachment feedback-loop usage, so on a device without VK_EXT_attachment_feedback_loop_layout (MoltenVK) a
framebuffer over host pages never got STORAGE, and every draw that reads its attachment through the pixel interlock
went through the fetch-through-scratch route. The in-place plans now try both usages, the feedback-loop usage alone,
then STORAGE alone, each only where the linear tiling has the usage's format features, the image still lies at the
texels' pitch, and (for STORAGE) the device's in-place check for shader writes passed. Devices with the feedback
loop keep their order. The scratch route's own loss on MoltenVK stays an open bug (the test's over-host-pages case
reproduces it where the scratch is taken).

Verified (on the branch): M3 / MoltenVK (m3-max-22641): fetch_composite's new over-host-pages case (RGBA16Float
RenderTarget|ShaderRead over a no-copy buffer, loaded, icon and fetch draws, two rounds): before, STORAGE false,
4 render pass instances, round 1 with 3072 wrong pixels (the fetch draws' output lost); after, STORAGE true, 1
instance, 0 wrong pixels in both rounds; in_place_storage shows STORAGE on RGBA8, BGRA8, RGBA16F and R8 in place.
lavapipe (m3-max-22639) 4/4 (it fetches through input attachments, route unchanged). Lint running (22645-22647).
2026-11-12 13:51:46 -08:00
Anees Iqbal ece1bf461d Test: the loaded composite writes its background before each round, and reports the route with the pixels
The second round loaded what the first left, which its fetches halved again: the
expected pixels are each round's over the background, so the CPU writes it before
each. The route check joins the pixel failures, so a run that takes the scratch
route shows its pixels too.
2026-11-12 13:51:08 -08:00
Anees Iqbal 7d9e8ce385 A render target in place over host pages takes the storage usage without the feedback loop usage
What: an image in place over host pages of a texture that renders tried the
storage usage only together with the feedback loop usage
(VK_EXT_attachment_feedback_loop_layout). It now tries, widest first, both
usages, the feedback loop usage alone, then the storage usage alone, each
where the device makes the image in place with it (its linear tiling has the
usage's format features, and the image lies at the texels' pitch in their
memory, as before), the storage usage still only where the device's check
passed for a shader's writes of its texels over the pages.

Why: MoltenVK has no feedback loop layout, so there a guest's framebuffer
surface over host pages (RGBA16Float, RenderTarget | ShaderRead) never took
STORAGE, and every pass that fetched it in the pixel interlock rendered
through a scratch image, where the fetching draws' output was lost: the
Dock's icons drawn as rims, the Finder sidebar's glyphs washed out (reims's
A/B on the M3: declaring ShaderWrite, which gives the image STORAGE, drew
both right). Devices with the feedback loop usage keep their order: both,
then the feedback loop usage alone, as before. The scratch route's own loss
stays a separate fix.

The in-place storage test now allows the storage usage without the feedback
loop usage; the docs of the in-place image, the storage form and
in_place::storable say a fetching draw reads the texture in place through it.

Verified: see the report's job ids (fetch_composite's over-host-pages case on
MoltenVK before and after, and on lavapipe).
2026-11-12 13:51:08 -08:00
Anees Iqbal 1663f1a5ff Test: a loaded composite of icons and fetches over a no-copy buffer's host pages
What: fetch_composite gains a third home for its target, a texture over a
no-copy buffer's host pages, loaded from what the CPU wrote there, as a
guest's framebuffer surface is (RGBA16Float, RenderTarget | ShaderRead).
Where the image lies in place, the device's check passed for a shader's
writes of its texels and the device fetches through storage, the test
asserts that the image took the storage usage, so the pass fetches the
target in place rather than through a scratch image; and, as for the other
homes, every pixel must be its draws' answer in draw order.

Why: on MoltenVK such a target's in-place image took the storage usage only
together with the feedback loop usage, which MoltenVK lacks, so every
fetching pass over a guest's framebuffer went through the scratch route,
where the fetching draws' output was lost (the Dock's icons drawn as rims).

Verified: see the next commit, whose fix this test checks.
2026-11-12 13:51:08 -08:00
Anees Iqbal 5ef4a9f432 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:50:38 -08:00
Anees Iqbal 6bf7e13e91 RUNTIME_VERSION 2146: a device whose held imports cost every submission keeps at most 64 releasable imports resident
The three commits before this one. On a device whose submission check found a per-import cost
(pointer_imports_tax_submissions: about 0.45 us a submission per held import on the 780M), at most RESIDENT_MOST = 64
releasable imports stay resident; past it the residency thread wakes at once rather than at its 500 ms tick and
releases the least recently read idle imports, paced. New counter WorkCounts::host_imports_released_over_most
(api_signatures row). HOWTO.md and HostMemory::with_dma_buf describe the cap.

Verified (on the branch): lavapipe (m3-max-22599) host_residency, pointer_residency, dma_buf_import_cycles,
host_ram_dma_buf 32/32; Radeon 780M (m3-max-22634) the same modules 31/31, with the new device test
past_the_most_resident_the_least_recently_read_import_is_released (most 2 over three buffers: exactly the least
recently read released, the others read with no re-import, the released one's next blit reads a file write after one
re-import). One release and re-import on the 780M: 37.5 us free + 153.6 us encode, ~0.19 ms. Lint green at the
pre-stack base 7f1e5d7151 (m3-max-22547); development's checks cover the tip.
2026-11-12 13:50:00 -08:00
Anees Iqbal c7f9c44530 Residency: the resident count's decrement takes try_update, fetch_update's new name
Found by the lint job (22525) on msi: fetch_update is deprecated on this toolchain.
2026-11-12 13:49:23 -08:00
Anees Iqbal cc694355b1 Residency: a device test of the release past the most, and the guide's and HostMemory's words for it
past_the_most_resident_the_least_recently_read_import_is_released: with the most held at two
(Device::keep_resident_host_imports), three dma-buf imports read in turn; one released past the
most, the least recently read; the other two read with no import again; the released one's next
blit imports it again and reads the file's writes made meanwhile. It prints the free's and the
import again's times. HOWTO.md and HostMemory::with_dma_buf say a device whose held imports cost
every submission keeps at most 64 resident.
2026-11-12 13:49:23 -08:00
Anees Iqbal 5a4746a7a5 Residency: a device whose held imports cost every submission keeps at most 64 releasable imports resident
A window keeps an import used every few seconds imported for good, so a guest that blits from many
buffers in turn kept 1,000 to 1,470 of them in RADV's global list, each in every kernel submission.
On a device whose import tax check holds, the residency thread now also releases those past
RESIDENT_MOST (64), the least recently used first, whatever their windows, woken as soon as one
more is imported past it. Counted: WorkCounts::host_imports_released_over_most.

Not yet built or tested: the device test and the checks follow.
2026-11-12 13:49:23 -08:00
Anees Iqbal 4b99c54b07 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:48:48 -08:00
Anees Iqbal bac66a5b11 RUNTIME_VERSION 2145: didModifyRange's bytes are taken at the next commit, as Metal takes them
The two commits before this one. On a device without unified memory a Managed buffer has two copies, and
did_modify_range's copy in read the host copy when the GPU ran it, so a CPU write made after the commit but before
the GPU reached the copy reached the earlier command buffer. Metal takes the bytes at the commit (measured on a
discrete Mac, 5300M, macOS 26.7.1: write A, didModifyRange, commit, write B while the GPU is busy -> the command
buffer reads A; a write after didModifyRange and before the commit is read). did_modify_range, and a CPU write
through a texture over a buffer, now note the range on the device; every commit copies each noted range on the CPU
into staging as the host copy holds it then, and the next submission copies the staging in. Where staging finds no
memory the range falls back to the copy at execution. Docs: managed.rs, managed_copy.rs, API.md, the runtime README
and FAST-PATHS's managed row.

Verified (on the branch): RTX 3090 (m3-max-22616): the new lane test
device_copies::a_did_modify_range_reaches_the_bytes_the_next_commit_finds (the oracle's five steps, over pages and
runtime-made) fails without the fix at step 4 (read B, wanted A) and passes with it; device_copies::a_*,
texture_blits::, first_use:: 38/38; managed_copy_device, kept_padding, device_memory_overflow, detached_contents
27/27. Lint and the full suites run on development.
2026-11-12 13:48:09 -08:00
Anees Iqbal f62966f4f0 did_modify_range's bytes are taken at the next commit, as Metal takes them
What: did_modify_range (and a CPU write through a texture over a buffer) notes the range on the
device (managed.rs Modified); every commit, at its start and before it returns, copies each
noted range of a buffer with a host copy on the CPU into staging buffers as the host copy holds
it then (Buffer::upload_now, CallerCopy::copy_in_now, managed_copy::stage_in), which the next
submission copies into the device copy before any of its commands. A range the staging buffers
find no memory for falls back to the copy from the host copy as the submission runs.

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

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

Verified: the lane test of the parent commit on an RTX 3090 (job ids in the report).
2026-11-12 13:47:32 -08:00
Anees Iqbal f7b5429a8a Lane test: did_modify_range's bytes against the commit, the oracle's five steps
What: runtime_lane::device_copies::a_did_modify_range_reaches_the_bytes_the_next_commit_finds
runs the five steps reims measured on a Radeon Pro 5300M (two copies) and a UHD 630 (one),
macOS 26.7.1, for a Managed buffer over pages and one the runtime made, each behind busy work
on the GPU: CPU writes of a range, did_modify_range, and a command buffer copying the range
out, encoded and committed in each step's order. Two copies: A, B, B, A, B (a write after the
commit is not read); one copy: A, B, B, B, B.

Why: a benchmark computing each frame on the next frame's input on an RX 7900 XTX; the runtime
copied a did_modify_range's range in from the host copy as the GPU ran the copy, so a CPU write
after the commit reached the command buffer (step 4 reads B with two copies).

Verified: run on an RTX 3090 against the fix's parent (expected to fail at step 4) and with
the fix (job ids in the report).
2026-11-12 13:47:31 -08:00
Anees Iqbal b95cdd8ffc Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:47:20 -08:00
Anees Iqbal b55eeedec3 RUNTIME_VERSION 2144: on a listed plan an object over a guest-RAM chunk not imported takes its own path and asks for no chunk
The three commits before this one. On a listed plan (held imports cost every submission: RADV, and ANV where they
do), an object over a chunk whose import is not made no longer imports its run alone and marks the chunk asked
(which had the device's thread import the whole chunk, pinning every page of it); bind_in_chunk returns None and
the object takes its own path, as over memory no RAM holds. It binds inside a chunk only where the chunk's import
is made (by a copy that needed it). AHEAD plans are unchanged. So attaching run resolvers to every no-copy object
changes no residency, and objects over chunks the copies imported leave the BO list. Removed with the path: the
object's run-again binding, Placement::over_ram_run, the residency import-again arm for runs and the counter
run_bound_buffers_made (api_signatures re-blessed).

Verified (on the branch, at e030317153):
- lint m3-max-22593: clippy every feature, --cfg m2v_gpu, --cfg m2v_cpu_icd, rustdoc, api tests.
- lavapipe m3-max-22602: host_ram_dma_buf, host_ram_device, host_ram_copy_device, device_recovery_no_copy,
  import_overlap_hazard, host_residency, dma_buf_import_cycles 77/77.
- Radeon 780M m3-max-22625: host_ram_dma_buf, host_ram_device, host_ram_copy_device 60/60, with
  where_each_listed_import_costs_a_submission_the_ram_is_long_chunks_released_once_idle asserting that the first
  object over an unimported chunk takes its own import with no chunk imported or asked a second later, and that after
  a copy imports the chunk the next object binds in it (chunk_bound_buffers_made +1, InHostRam).
2026-11-12 13:46:39 -08:00
Anees Iqbal f69a094752 Listed-plan tests import a chunk themselves before binding objects in it
On a listed plan an object over a chunk not imported now takes its own
import and asks for no chunk, so five host_ram_dma_buf tests that relied
on the first object importing its chunk failed on lavapipe (job 22517:
chunks imported 0, Copied instead of InHostRam, the tile test's holders
never imported). A test hook, Device::import_host_ram_chunk, imports the
chunk at an address as an object's import used to (RamOnDevice::chunk,
By::Object); the five tests call it before the objects they expect bound
in the chunk.

Verified: pending the lavapipe run of the touched modules.
2026-11-12 13:45:59 -08:00
Anees Iqbal 2ddc2f810e Guest RAM: drop the import the run-again binding alone used
Found by the lint job (22518) on msi: Pages was imported for Device::ram_run_in_chunk and
ram_run_alone_again, which 5b396edb5a removed.
2026-11-12 13:45:59 -08:00
Anees Iqbal 27cd4bccc0 Guest RAM: on a listed plan an object over a chunk not imported takes its own path and asks for no chunk
On a device whose plan is listed (each held import costing every submission and the RAM's
chunks its dma-bufs: RADV, ANV where the import tax holds), an object over a chunk whose import
was not made was bound in an import of its own run and asked the device's thread for the chunk,
which faulted in and imported the whole chunk: udmabuf allocates every page of it and keeps them
after the import is freed, so attaching runs to every no-copy object would make the guest RAM
under every object resident chunk by chunk (12.3 GiB of a 16 GiB guest on the 780M before the
listed plan). Now such an object is bound in the chunk only where its import is made, and
otherwise takes its own path, as over memory no RAM holds: no run import, no ask. Chunks are
imported for the copies over them, and the objects over them after that lie in them. Plans that
import ahead (NVIDIA, host-pointer chunks) are unchanged.

Removed with the object path: RunAgain, Routed::run_again, Placement::over_ram_run, the
residency's AgainFrom::RamRun with Device::ram_run_in_chunk and ram_run_alone_again, and
WorkCounts::run_bound_buffers_made (an object is never bound in a run import now; copies keep
their ranges alone and run_imports_live). Docs: host_ram.rs, host_residency.rs, copy.rs,
HostMemory::with_runs, driver_defects.rs, WorkCounts, HOWTO.md; the API signatures table
re-blessed.

Tests: the listed tests now import their chunks by copies; the first object over a chunk not
imported, with a source of its own pages as a consumer's come, takes its own import, no chunk
imported and none asked of the RAM's source, and the objects over a chunk a copy imported lie in
it. The other host RAM tests lose their run-bound terms (0 on every plan they run).
2026-11-12 13:45:59 -08:00
Anees Iqbal ccefca132d Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:28:21 -08:00
Anees Iqbal d57a597cd1 RUNTIME_VERSION 2143: synchronizeTexture copies a Managed texture's bytes over a two-copy buffer out
The commit before this one. On a device without unified memory a Managed texture over a Managed buffer has two
copies; the GPU writes the device copy, getBytes and the buffer's contents read the host copy, and
synchronizeTexture:slice:level: recorded nothing, so a program that synced with it and then read saw the region as
of its last didModifyRange. It now copies the texture's span out as synchronizeResource does (shared
synchronize_bytes / synchronize_texels in blit.rs).

Verified (on the branch): RTX 3090 (m3-max-22550): runtime_lane::device_copies::a_synchronize_texture_copies_the_texels_out
fails without the fix (copy-outs expected 1, got 0) and passes with it, with the other device_copies::a_* tests,
texture_blits:: and buffer_texture_blits:: (27 passed). Lint and the full suites run on development.
2026-11-12 13:27:42 -08:00
Anees Iqbal a7ba65dd66 synchronize_texture copies a Managed texture's bytes over a two-copy buffer out
What: on a device without unified memory, BlitCommandEncoder::synchronize_texture
now copies a Managed texture's bytes over a buffer from the buffer's device copy to
its host copy (the caller's pages, or the runtime's own host copy), as
synchronize_resource of the texture already did. A level that lies in the image
alone (a tiled texture's past its first) copies nothing; a texture of an image
alone still records nothing, its CPU access reading its image. The copy is shared
code: synchronize_resource's buffer and texture arms now call synchronize_bytes and
synchronize_texels.

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

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

Verified: the lane test runtime_lane::device_copies::
a_synchronize_texture_copies_the_texels_out (a blit into rows of a Managed texture
over pages and over a runtime-made Managed buffer, then synchronize_texture: the
contents and get_bytes hold the rows; the copy out counted for the pages with two
copies) is run on a discrete NVIDIA GPU with this change and once without the
runtime fix (negative control); job ids in the report.
2026-11-12 13:27:01 -08:00
Anees Iqbal 95efe8405b Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:25:53 -08:00
Anees Iqbal 0bb4e9f42b Pipeline log: a refused kernel's compile takes a line naming its function
A compute state whose kernel's compile is refused, at its creation or at a
dispatch's variant, printed nothing under METAL2VULKAN_LOG_PIPELINES, and
the refusal itself (compile failed: LimitExceeded(SpirvWords)) names no
function, so a consumer's log could not say which kernel it was. The log
now prints, at both compile sites, a line with the kernel's function name,
the refusal, and the descriptor it was made from, as a made pipeline's
line names them. Diagnostics only: nothing else changes.
2026-11-12 13:18:48 -08:00
Anees Iqbal d782275fc5 Re-pin the runtime sources at the landing tip
The landed packet changed a runtime-sources input, so the committed digest no

longer described the sources and `the_runtime_sources_are_the_committed_ones`

would fail. Recomputed over the same inputs and committed by land-pkt.sh.
2026-11-12 13:18:23 -08:00