Commit Graph
5900 Commits
Author SHA1 Message Date
Anees Iqbal 30331a477f kept_textured: the spun copies wait for the spin through a fence
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::kept_textured::a_kept_heap_draw_reads_what_an_earlier_command_buffer_wrote
failed on 1024 reports (512 copies, two cases): "vkCmdCopyBufferToImage(): READ_AFTER_WRITE
hazard detected. vkCmdCopyBufferToImage reads VkBuffer ..., which was previously written by
vkCmdDispatch", copy regions from offset 64, 64 bytes each.

spun_copies encodes the spin's dispatches, which store their count in the source buffer's
first word (bytes 0..4), and then copies the texels from bytes 64 on. Its premise ("so the
copies follow the spin") was Metal's whole-resource tracking of the buffer. The runtime orders
a tracked buffer by the bytes, as its README's "Hazards" says:

  The runtime orders a tracked buffer by the bytes a command reaches: those its translation
  proves a shader reads or writes, else from the bound offset to the buffer's end. Vulkan's
  synchronization validation takes a shader's buffer as accessed over its whole descriptor,
  which spans those bytes widened to 16-byte granules from the device's offset alignment, so
  it reports hazards between commands whose bytes are apart, as it does between untracked
  uses Metal leaves to the program; no order of either changes a result.

So on the runtime the copies did not follow the spin, and the test lost the delay it was built
on (the frame's kept draws waiting for an earlier command buffer's late writes). The layer
reported the copies' reads against the dispatch's whole descriptor.

The spin's encoder now updates a fence and the copies' blit encoder waits for it: an order
Metal keeps too (redundantly, beside its tracking), and one the runtime records as a barrier
from the spin's compute stages (fence.rs, the tracker). The copies follow the spin on both,
and the layer sees that barrier. Spin::encode takes the fence to update; Spin::new's timing
runs pass none.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the reports
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal f67343b44e address_maps: the alpha-code rounds note their dispatches' apart writes
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::address_maps::every_alpha_code_of_a_texture_whose_alpha_reads_one_reads_one
failed on 65280 reports (255 pairs a round, 256 rounds) of one record-time hazard:
"vkCmdDispatch(): WRITE_AFTER_WRITE hazard detected. Shader stage VK_SHADER_STAGE_COMPUTE_BIT
writes to VkBuffer ..., which was previously written by another vkCmdDispatch command", binding
0 of rrp_sw_read_f.

Each round's 256 dispatches write o[0], a float4: 16 bytes each, CODE_STRIDE (256) bytes
apart, in one tracked buffer. The runtime binds the slot over the buffer and orders a tracked
buffer by the bytes the translation proves a shader writes (runtime README, "Hazards"). The
layer takes the whole descriptor as written. Writes that share no byte make no data race
(Vulkan's Memory Model appendix), so no order of them changes a byte, and the claim the test
stated (layer_reported_nothing_at_all) was wider than what the runtime promises.

Each round now notes its 256 writes (NotedWrites, one per round: the rounds write the same
bytes again, after the previous round's wait) and states
layer_reported_nothing_but_apart_writes, which lets a write after write between noted writes
pass only where no two of them share a byte.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the reports
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal b815e51395 Hazard parser: read a transfer command's access as the layer words it at recording
Under METAL2VULKAN_LANE_VALIDATION=sync on lavapipe,
runtime_lane::memoryless_uses::memoryless_compute_and_blit_uses_fail_as_metal_s failed in
its "unused" case on one write after write the layer reported as the fill was recorded:

  vkCmdFillBuffer(): WRITE_AFTER_WRITE hazard detected. vkCmdFillBuffer writes to dstBuffer
  VkBuffer 0x700000000070, which was previously written by vkCmdDispatch.

The fill writes mark 3 (bytes 12..16) and store_const the mark at 8 (bytes 8..12). The test
notes both, so the report is of the apart form its claim already lets pass (8 of the run's 9
reports passed so). The lane's hazard parser (parity::sequences::hazards::parse) wanted
"VkBuffer " right after "writes to " and returned None for the parameter name ("dstBuffer")
that the layer puts before the memory in a transfer command's record-time wording. The runtime
now records the blit encoder after the compute encoder in one VkCommandBuffer, so the layer
reports the pair as recorded and no longer in the submission form the parser read.

parse() now skips one word between the verb and "VkBuffer "/"VkImage ". parity::sequences'
lane reads the layer's hazards through the same parser, so it gains the record-time transfer
wording too.

Tests: the_lane_reads_the_layers_hazards parses the exact record-time fill wording above and
a read of a "srcImage VkImage"; apart_writes' a_fill_and_a_dispatch_apart_pass_either_way_round
judges the record-time fill wording apart. Both fail without the parser change.

Before: m3-max-32985 (msi, lavapipe, sync, at 3945a91289) failed the test with the message
above. The proof run of this tip is in its landing report.
2026-11-15 10:22:18 -08:00
Anees Iqbal f452591afc 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-15 10:15:32 -08:00
Anees Iqbal ab139e4b6e RUNTIME 2366: Runtime FALLBACK repro bundle at a creation refusal (default-off diagnostic)
What: metal2vulkan-runtime writes the FALLBACK repro bundle the command line
writes for its own failures when it refuses a library or pipeline creation,
where METAL2VULKAN_REPRO_DIR names a directory (unset, nothing is written).

- The CLI's bundle writer moves into the library as the hidden crate-root
  module metal2vulkan::repro (feature serde), shared by the binary and the
  runtime. A bundle's directory is named by its content
  (metal2vulkan-repro-<16 hex>), written under a temporary name and renamed,
  so an identical failure is written once, across threads, processes and
  runs. The CLI's own bundles keep their files (input, profile.json, the
  descriptor files, repro.sh, repro-command.txt, failure.txt); only the
  directory's name changed, so a bundle written before still replays.
- The CLI takes --device FILE in place of --profile: the JSON of a
  DeviceDescription and DevicePolicy (ReproDevice), which builds the
  runtime's own compile device.
- The runtime hooks each creation where its refusal returns: a library of a
  metallib, a function's lookup, every compute and tile state
  (ComputePipelineState/TileState::create_adding: creations, added binary
  functions, archive adds) and every render state
  (GraphicsState::create_reflecting). It bundles Unsupported, NotImplemented
  and Compile refusals but a cancelled compile and a name the library lacks
  (Metal's own nil); never Invalid/Nil/MetalError. The bundle holds the
  library's bytes, device.json, the request as the CLI's options and
  descriptor files, and failure.txt with the call, the refusal and what the
  command does not replay. That list comes from a full destructuring of the
  compute, tile and render descriptors (and the stage functions): a new
  descriptor field fails to compile in repro.rs until it is replayed or
  listed.
- Bounded: at most 32 bundles and 256 MiB per process; past either nothing
  more is written and one line says so. Written on the refusing thread; the
  call returns the same refusal; a write failure is said once. Each bundle
  is named in one line through the device's message sink (id name
  metal2vulkan-repro). The runtime's metal2vulkan dependency gains serde.
- Not bundled: mesh states (no CLI mesh path), a dispatch's or draw's later
  variant, driver VkPipeline makings, Metal-source libraries.

Docs: env_vars registry, README CLI, docs/HOWTO.md section 4, the runtime
README's Errors section, the CLI help.

Tests: runtime CPU tests of the bounds (a tally with the seam's limits);
a lavapipe/GPU device test (ob3_stage_input with no stage-input descriptor:
one bundle with the expected parts and command, device.json rebuilding the
runtime's compile device by profile fingerprint and answering the same
refusal, none for a second identical refusal or a missing name, none
without a directory); CLI tests replaying library-written runtime bundles
(compute, and render with a vertex descriptor) through repro.sh to the same
FALLBACK, and --device compiling what --profile does.

Verified at ae56b195e9 (msi, m3-max-32986): metal2vulkan cli,
api_surface and api_signatures 25 passed; runtime repro tests 9 passed;
clippy -p metal2vulkan -p metal2vulkan-runtime all targets, all features
0. Lavapipe (m3-max-32978): repro_device writes one bundle that the
CLI replays to the same refusal; a second identical refusal writes
nothing.
2026-11-15 10:14:52 -08:00
Anees Iqbal 2cdfa840b5 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-15 10:13:55 -08:00
Anees Iqbal 1d2dbcbfc5 RUNTIME 2365: Compute: an encoder's dispatch takes the device's sampler states only where it needs them
Every compute encoder dispatch that settled (no memo entry held) listed
every live sampler state of the device (argument_samplers_at: a lock,
an Arc clone of each, and their drop), though its kept bind state
already listed them at the count of their slots' changes that held, and
a variant with no set-1 arrays binds none of them. In the consumer's
profile of its GL fix-index encoder that listing was 4.7% of
dispatch_threads, beside the states' drop.

A compute encoder's dispatch now takes them as a draw does
(sampler::ArgumentSamplers): only where the kept listing is not of
every live state at the count that holds (then compared state by state,
as before), where the variant has set-1 arrays (fitted and written to
the heap, as before), where a notice names a state of pixel coordinates,
or where a parked memo entry of such a variant goes on in the next
encoder (restamp). SettledDispatch::argument_samplers is None where
none were taken; a heap dispatch without them is an internal error,
not a silent empty listing. The memo's count of slot changes is the
taken states' where it took them, else the one the kept listing holds
at.

WorkCounts::argument_samplers_taken now counts compute dispatches'
takes too (its doc says so); no new field, no new Degradation kind.

Verified: not yet built; the next job builds and tests it.

Verified (msi, lavapipe, m3-max-32979 at 421c3c4d65): clippy plain 0;
compute, dispatch, grid, region widths, partial threadgroups, flat
simdgroups, sampler, argument and heap trimmed tests 163/163, including
compute_sampler_listing (argument_samplers_taken moves only after a state
is made or goes; every dispatch's words are Metal's).
2026-11-15 10:13:12 -08:00
Anees Iqbal 3945a91289 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-15 10:07:22 -08:00
Anees Iqbal 0ffe55a639 RUNTIME 2364: Encoders: a command's runs of one resource's bytes past what the order keeps are ordered as one use, exactly as their uses
A host RAM copy names each chunk it touches by up to 16 ranges (MOST_RANGES), 2049 uses for
a layer over 128 chunks, and the encoder's order paid for each: note 45 us, touch_reaching
27 us and wait_first 11 us of a 200 us call on msi, and the next command took the copy in
for another 150 us (inside_uses, merge's sort and finds, admit's finds). Probes m3-max-32845
and m3-max-32862, branch steelbrain/dl2-probe3 (not landed).

EncoderCore::track now orders a command by EncoderUses::order_joined. A run of more than
ENTRIES_PER_KEY consecutive tracked uses of one key's bytes, each past the one before, of a
key the command names nowhere else and the part holds no entry of (in its order, after the
part's first command is taken in, nor in its tracked uses), is compared, waited and taken
in as one use, its hull with the reads and writes of all: admit collapses the run's entries
into exactly that entry, and the comparison meets no entry of the key either way. The part
notes it as note leaves it from no entries: the hull of its first 9 + 8m uses, then each
after. So every barrier, the order and the encoder's summary are the same as order makes of
the uses; anything else goes through order unchanged. note_dirty, shadows.wrote, skips, the
twin check, owed.pay and the fold's order keep the command's own uses; inside_uses, admit and
note are unchanged. touch_reaching skips a use whose key and naming the use before it had
(its insert and name are idempotent; its per-position cache is kept for every use).

Tests: tracker, runs_of_one_key_joined_order_exactly_as_their_uses (600 generated encoders,
ordered and not, keys holding none to more than 8 entries before runs, runs off by an empty
range, a range not past the one before, an untracked use, a key named twice; per-command
barriers, summaries and the cross-queue plan of a following encoder equal; more than 300
commands joined); device, copies_over_a_long_scatter_s_pages_and_gaps_in_its_encoder_keep_
their_order and a_long_scatter_reports_each_run_to_the_ram_s_log_and_no_page_between_them.

Verified: m3-max-32906 (msi) clippy plain, m2v_gpu, m2v_cpu_icd 0,
rustdoc 0; m3-max-32926 the whole runtime crate on lavapipe 2806/2806;
runs_of_one_key_joined_order_exactly_as_their_uses: 600 generated
encoders, order and order_joined equal on every barrier, summary and the
next encoder's plan; sync_coverage 7/7 (m3-max-32907). Release medians
(m3-max-32909, msi loaded, interleaved), 128 chunks: the fill after the
copy 194.8/194.1 -> 27.9/26.5 us, the copy after a fill 459.0/442.1 ->
275.9/259.8 us.
2026-11-15 10:06:41 -08:00
Anees Iqbal 291635393a 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-15 10:05:37 -08:00
Anees Iqbal ac0229e5d7 RUNTIME 2363: Compute: a direct dispatch takes what another grid of its class planned
A compute pipeline state kept what its latest direct dispatches planned
(Planned: the variant, its plan and its regions' made VkPipelines) keyed
by the exact dispatch, so a guest's fix-up stream of dispatchThreads:
calls of a thread per element, one width after another, planned every
dispatch again: settle_direct, settle_flat and Variant::plan's LRU hash
and compare of the bind shape two or three times, a new Planned whose
regions' pipelines were looked up again, and plans of other shapes
pushed out of the four kept, so the shape was made again too. In the
consumer's profile of its GL fix-index encoder on an RX 7900 XTX that
was plan_now 17.8% of dispatch_threads, region lookups about 6%, and
BindState::shape 5.3% beside position_of_shape 2.3%.

A grid's class (pipeline::GridClass) is its dispatch form, its
threadgroup size, and whether it is a whole number of threadgroups and
one row in threadgroups of one row: what settle_direct chooses its
branch by (flat_direct and partial_direct now read those from the
class). Where every region a plan plans has the call's threadgroup size
(a flat variant's one region, a partial-threadgroups variant's
threadgroups, a whole grid's chunks), every variant key the branch makes
is a function of the plan and that local size, and the grid's size
reaches it only through the device's limits. So a Planned of the bound
form on a flat or partial-threadgroups variant, or of a whole grid,
serves the other grids of its class, after its plan names its very
variant for the new grid (BindingPlan::dispatch_variant, which checks
the grid against those limits each time); otherwise the dispatch plans
as any and meets the same refusal. A ragged grid's exact split keeps
the exact key. The call's own grid is what record instantiates; the
dispatch memo and the kept commands (Instantiated) keep their dispatch,
since their commands are the grid's.

New count: WorkCounts::dispatches_planned_across_grids, those of
dispatches_planned_as_before of another grid of the class.

Verified: not yet built; the next job builds and tests it.

Verified (msi, lavapipe, m3-max-32955 at ccfcc384b3): clippy plain 0;
api_signatures and api_surface 15/15; compute, dispatch, grid, region
widths, partial threadgroups and flat simdgroups 90/90; grid_classes reads
every dispatch back against Metal's answer and counts 20 cross-grid plans
a kernel; an over-limit grid of a planned class is refused as before.
Negative controls: reuse with the check skipped fails both tests.
2026-11-15 10:04:56 -08:00
Anees Iqbal 59932b32ba dma_buf_imports: is_multiple_of in the shared source's alignment check
Clippy (--cfg m2v_gpu and --cfg m2v_cpu_icd, -D warnings) refused the manual
modulo in Memfd::shared_source (clippy::manual_is_multiple_of), red in
m3-max-32936 for development b1c6b40570. Same check, its method form.

Verified: cargo fmt; clippy of metal2vulkan-validation in all three
configurations in the msi job that follows.
2026-11-15 09:59:10 -08:00
Anees Iqbal b1c6b40570 submit_per_import: held buffers as pieces of one shared dma-buf file
A third held-for-good kind: the n buffers' source answers each request with
a piece of one udmabuf of their whole memfd (DmaBufRequest::shared_files, as
a consumer's group of views is), so the device imports the file once and
binds each buffer at its piece (Memfd::shared_source). Against the own
dma-buf rows it shows whether a shared file costs RADV's submissions one
listed entry, whatever its pieces; the lines now print the pieces joined and
the shared files live, the evidence the join path ran.

Verified: cargo fmt; run on gem10's PHOENIX in the probe job that follows.
2026-11-15 09:49:50 -08:00
Anees Iqbal 1db2624115 submit_per_import: a phase of imports held for good
The dma-buf phases held at most 64 imports live (136 for 1000): their
buffers are read by blits alone, so the residency released those past the
most it keeps on a device whose held imports cost every submission. A
guest's imports are bound and stay (the HawkPoint Launchpad walk held 363
buffer dma-bufs and 163 image ones). Each kind now runs again with every
buffer's Metal address read (Buffer::gpu_address), which keeps each import
held for good, so a phase holds all n live and its line gives the per-entry
cost at the walk's counts.

Verified: cargo fmt; run on gem10's PHOENIX in the probe job that follows.
2026-11-15 09:36:16 -08:00
Anees Iqbal 5aad56bc82 submit_per_import: print each VkSubmitInfo's time in vkQueueSubmit
The SUBMIT-PER-IMPORT lines now carry the VkSubmitInfos a phase submitted and
WorkCounts::batch_submit_nanos over them: the driver's time per submission
beside the kernelStart-to-kernelEnd percentiles, so a phase's per-import cost
reads in the same unit as a walk's WorkCounts (perdraw8: the HawkPoint walk's
scheduler spent 390 us per VkSubmitInfo in RADV's vkQueueSubmit).

Verified: cargo fmt; built and run in the gem10 PHOENIX probe job.
2026-11-15 09:29:26 -08:00
Anees Iqbal e4daf97233 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-15 09:20:33 -08:00
Anees Iqbal 0b6f72ac29 RUNTIME 2362: Scheduler: a copy queue's command buffer keeps commit order behind a held batch
What: a head on a queue made for copies (Device::new_command_queue_for_copies) no longer
goes before an earlier-committed batch of another queue it conflicts with because that
batch gives way. The order's comparator (scheduler/mod.rs is_behind) treats a held batch
that gives way as one that keeps its place when the head's queue keeps commit order
(Standing::commit_order, from CommandBufferShared::keeps_commit_order: the queue's kind,
set by the copy queue's constructor). Such a head waits behind it in the scheduler when
tracker::ordered says the two conflict, whether the held batch waits for its pipelines'
making, a host step or its checks. Once the held batch is submitted, the tracker orders the
copy after it on the GPU: the copy engine's VkQueue waits for the other VkQueue's timeline,
or a barrier where they share one. There is no wait on the host. A copy that shares nothing
with the held batch still goes. Unchanged:
- plain queues keep the give-way exactly as before (order.rs, Held batches give way), so the
  Iris Xe compositor case is untouched;
- a held batch ON a copy queue stands to a later plain queue's commit as any held batch does
  (the rule is the head's);
- a batch held for an event value or a binary semaphore's signal the program has not given
  holds back no copy (Stops).

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

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

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

Verified (lavapipe, the copy queue on the round robin VkQueue): at
87ab2111b0 (m3-max-32839) the copy-queue leg fails, reading the bytes
from before the blit; at 404352e262 (m3-max-32840) hold_sites,
dispatch_pending, pipeline_wait_order, held_step_order and copy_queue
16/16, clippy m2v_cpu_icd 0.
2026-11-15 09:19:49 -08:00
Anees Iqbal 177ff2240b 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-15 09:16:59 -08:00
Anees Iqbal f10e9d8c90 RUNTIME 2361: Host RAM copies: a repeated copy's call finds its kept plan as it merges the runs given, and makes no vector of them
On a repeated copy by a kept plan, a third of the encode was the call's own work on its
runs before the plan was even looked up: runs.to_vec, merged into a second vector, boxed,
in_words, then compared with the plan's at the recording (probe m3-max-32752, msi: 66.8 of
97.1 us at 1 chunk, 51.2 of 233.0 at 128 chunks).

The four calls (copy_from_host_ram, copy_to_host_ram, copy_runs_from_host_ram,
copy_runs_to_host_ram) now give HostRamCall::new their runs as given (Given: laid one after
another from an offset, or each at its own byte). It looks for a plan of the same direction,
form and buffer key (RamCopies::kept_for) and compares the given runs with the plan's while
it merges them (merges_to): each run checked as merged checks it, joined as merged joins
it, each joined run compared with the plan's next, a run laid past u64 refused as
one_after_another refuses it. Merged runs, checked and in_words are functions of the given
runs alone, and a plan exists only for checked runs copied by words, so a match is exact.
On a match the call shares the plan's runs (HostRamCall.runs and KeptPlan.runs are now
Arc<[Run]>) and names the plan (HostRamCall::kept); else it builds its runs as before, and
a plan kept of it shares them instead of cloning them.

The recording takes a named plan only while the RAM keeps that very plan
(RamCopies::keeps, by Arc identity): one the LRU bound or anything else let go of before
the copy records (an encoding again at a rebind, say) takes the copy to the full path
over the call's shared runs. A call that named none looks one up as before. Every dynamic
check of record_kept is unchanged.

Second, takes() no longer joins every chunk's ranges for copy_take: copy_take's signature
is unchanged in its types (device, importer, slot, ranges: &[Range<u64>]) but ranges are
now the chunk's ranges as touched_ranges gives them, and copy_take joins them
(copy::alone_ranges) itself, only past its made() check, where it reads them. Same
answers: the joined ranges were read only on that branch. (probe: 9.2 us a call at 1
chunk, whose ~4100 ranges were joined though the chunk was made; 40.3 at 128.)
chunk(), take(), took() and after_take are untouched.

Tests: unit, runs_merged_as_they_are_compared_match_the_kept_runs_exactly_as_merged_gives_them
(random runs of both forms with joins, empty and off-word runs, runs laid past u64,
against their merge, one run more, the last fewer, the merge of the runs less their last,
each run changed); device, the repeated-copy test gains runs at their own bytes, and
a_named_plan_the_ram_let_go_of_before_the_recording_is_not_taken (eight copies' plans
push the named one out, a rebind encodes the encoder again: no reuse, the bytes right).

Verified at 96e281ba59 (msi, m3-max-32802): host_ram tests on lavapipe
106/106, clippy plain, m2v_gpu and m2v_cpu_icd 0, rustdoc 0; the named
plan let go of before recording is not taken (negative control fails).
Release medians (m3-max-32803, lavapipe, interleaved, 200 of 200 copies
by a kept plan): layer in 1 chunk 99.1/94.0 -> 59.7/58.1 us, over 128
chunks 248.9/282.6 -> 176.9/197.0 us.
2026-11-15 09:16:17 -08:00
Anees Iqbal 9dd5e78f60 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-15 09:11:16 -08:00
Anees Iqbal 5ba7afd9d4 RUNTIME 2360: Shader cache: no default directory makes a memory-only device, never a failed one
With no caller directory and no home (USERPROFILE on Windows, HOME elsewhere),
default_directory answered Err and CacheSetup::of turned it, and any failure to
open the default path, into Error::ShaderCache, so every device creation and
adoption failed. Metal never fails device creation over its shader cache, and
the default is the runtime's choice, not the caller's (owner rule 2).

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

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

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

Verified (msi): m3-max-32796 clippy plain 0, 67/67 shader_cache and
degradation tests, api_signatures 0, clippy x86_64-pc-windows-gnullvm 0;
m3-max-32797 (lavapipe) clippy m2v_cpu_icd 0, 61/61 shader_cache and
in_place_check, including the no-directory device test.
2026-11-15 09:10:25 -08:00
Anees Iqbal 9ce951f521 store_out_device: the stencil store test keeps three queues live, so it takes the queue plan
Its three faulting passes each take a queue of their own, and the earlier
queues stay live to the test's end, past the runtime tests' default limit
of two (lavapipe, job m3-max-32737: the device's panic names the limit).
plan_device, as the resolve tests use.
2026-11-15 08:57:17 -08:00
Anees Iqbal d3702a9758 Device tests: a Stencil8 attachment stores, resolves and faults as Metal's
A Stencil8 texture on a device without S8_UINT is held in a combined
depth/stencil image; these tests run the shapes the consumer's tests died
at on Intel's UHD 630 under Windows, and a plain draw into such a target.

- store_out_device: a Stencil8 texture at the start of a placement no-copy
  heap of bit 24 stored at Store (descriptor's and encoder's) faults its
  command buffer; at DontCare and a late CustomSampleDepthStore it
  completes. A 4-sample Stencil8 attachment resolving into it at
  MultisampleResolve (descriptor's and encoder's) and
  StoreAndMultisampleResolve faults; attached unresolved it completes. The
  pages keep their bytes. Each prints the format its image is held in.
- stencil_target: a Stencil8 target cleared to 0x5a, drawn into over its
  left half with a Replace of reference 0xa5, and stored reads 0xa5 and
  0x5a by halves through a copy; a later pass that loads and stores it
  keeps every byte, so the hidden depth aspect's DONT_CARE disturbs no
  stencil byte. Prints the image's format.

Verified: compiled and run in the jobs named in the lane's report (the
UHD 630 under Windows and lavapipe).
2026-11-15 08:57:17 -08:00
Anees Iqbal c119a60d91 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-15 08:47:00 -08:00
Anees Iqbal 4781b54e6e RUNTIME 2359: image_plan: a depth-only or stencil-only texture held combined is an attachment of its image
A Stencil8 texture on a device without S8_UINT (Intel's UHD 630 under its
Windows driver 101.2145, and the roadmap-2022, vk12-floor and
lunarg-desktop-baseline-2023 profiles) is held in D32_SFLOAT_S8_UINT or
D24_UNORM_S8_UINT (FormatEmulation::StencilInCombined), which the format
table admits for DepthStencilAttachment and documents as exact. plan_held
kept the attachment mapping only where its format was the direct one
(S8_UINT), so the image took no DEPTH_STENCIL_ATTACHMENT usage, RenderTarget
went unavailable, and the render pass refused the texture as needing
D32_SFLOAT_S8_UINT as a depth/stencil attachment, which the device has.
The consumer's store and resolve of a Stencil8 attachment died there.

The attachment filter now also admits the combined-aspect emulations
(DepthInCombined, StencilInCombined); the RenderTarget branch compares the
image's format with the attachment mapping's rather than the direct
format, and a memoryless plan takes the mapping's format. Colour formats
and direct depth/stencil formats plan as before (their attachment format
is the direct one). render_target.rs already renders such an attachment:
the hidden depth aspect is DONT_CARE both ways.

Test: tests/image_plan.rs
a_depth_or_stencil_format_held_combined_is_an_attachment_of_its_combined_image
feeds the planner the UHD 630's formats (no S8_UINT, no D16_UNORM_S8_UINT;
the combined formats render, sample and copy optimally, with no BLIT_DST
and no linear features) over the uhd770 profile: Stencil8 and Depth32Float
without D32_SFLOAT, 1 and 4 samples and memoryless, are D32_SFLOAT_S8_UINT
depth/stencil attachments with nothing unavailable.

Verified (m3-max-32701, msi): clippy plain 0; the runtime unit suite
1593 passed; with image_plan.rs restored to its parent, the new test
fails (Stencil8 planned D32_SFLOAT_S8_UINT with TRANSFER_SRC|TRANSFER_DST
only, RenderTarget unavailable).
2026-11-15 08:46:20 -08:00
Anees Iqbal 771dd124e8 tests: the replay modules' extended products are all 32-bit
the_replay_modules_test_overflow_by_a_products_high_word counted every
OpUMulExtended (8 in the flat dispatch, 11 in the preprocess). Since
the builder makes each 64-bit extended product from four 32-bit ones,
the five u64 products count four each: 23 and 26, every one 32-bit.
The test now counts them by width and wants no 64-bit form, so a
64-bit OpUMulExtended coming back into either module fails it.

Found red by the msi run of the metal2vulkan suite at 71ec267314
(job m3-max-32642: 3617 passed, this one failed with 26 where it
wanted 11 on the preprocess). Verified by the follow-up job named in
the report.
2026-11-15 08:44:50 -08:00
Anees Iqbal 29d0f9263e fresh_pages: a cleared long buffer's cleared bytes are its 16 KiB allocation
Step 2 (a1175662e7) gives a runtime buffer of 16 KiB or more Metal's allocation,
its length rounded up to 16 KiB, and the host clears all of it so that a texture
over the buffer reads zero past the length. Two fresh_pages expectations still
counted the length rounded to 16: the recycled buffer in
a_long_buffer_made_right_after_a_filled_one_reads_zero (red on lavapipe, partition
2: 33570816 cleared, 33558544 expected) and the cleared class in
a_long_new_buffer_reads_zero_with_nothing_written (the RADV leg, where no class
takes fresh pages). Both now expect the length rounded up to METAL_PAGE.

Test-only: the runtime-sources pin skips tests, so it is unchanged.
2026-11-15 08:42:56 -08:00
Anees Iqbal 1ba1330549 SPIR-V builder: a 64-bit extended product from four 32-bit ones
Every 64-bit OpUMulExtended and OpSMulExtended the builder would emit
is now built from four 32-bit OpUMulExtended of the operands' halves,
summed in 64-bit adds and shifts; signed, the high word subtracts
each operand where the other is negative. The struct result is the
same, so every caller (mul_hi, the flat indirect-dispatch derivation's
checked multiply, the replay preprocess) keeps its shape.

Why: Intel's Windows driver 101.2145 on the UHD Graphics 630 answers
garbage high words for both 64-bit forms, different from run to run,
while its 32-bit forms and its 64-bit UDiv and UMod are exact
(measured by the runtime's host_step_reads device test in job
m3-max-32600). The flat indirect-dispatch derivation's overflow check
read those garbage high words as overflow, zeroed the command and
reported ReplayFaults::GROUP_COUNT, so indirect dispatches and ICB
executions ran nothing on that device. The leaf is unconditional:
both forms are exact everywhere, and a per-driver key would leave
any missed construction site broken.

SEMANTICS_VERSION 2123 -> 2124: modules with a 64-bit mul_hi or a
flat dispatch derivation change their words.

Verified: the CPU interpreter test
sixty_four_bit_extended_products_are_exact_from_halves (both signs,
scalar and two-lane vectors, 121 operand pairs including 0, 1, -1,
i64::MIN, i64::MAX and u64::MAX, against i128/u128 products, and only
four 32-bit MulExtended in the module) is dispatched with this
commit; the device run on the mini follows.
2026-11-15 08:31:57 -08:00
Anees Iqbal 509a9c4c4e tests: a kernel's 64-bit multiply (low word) beside its mul_hi forms
The wide-math device test also stores `mul i64 x, y` for large
operands, to show whether the 64-bit OpIMul is exact on the device
whose 64-bit OpUMulExtended and OpSMulExtended high words are wrong.
Not yet run; the next mini run measures it.
2026-11-15 08:31:57 -08:00
Anees Iqbal 3500934fa6 tests: signed 64-bit and 32-bit mul_hi beside the unsigned 64-bit one
On the UHD 630 (m3-max-32592) the unsigned 64-bit mul_hi answers garbage high
words while 64-bit division and remainder are exact, and the flat dispatch
reports ReplayFaults::GROUP_COUNT. The fix's encoding depends on which widths
and signs the driver multiplies right; this measures them.

Verified: m3-max-32592 (UHD 630).
2026-11-15 08:31:57 -08:00
Anees Iqbal 9185644506 tests: a kernel's 64-bit mul_hi, division and remainder; the flat path's execution report
The device-pointer run passed on the UHD 630 (m3-max-32574): the translated
kernel's own loads and stores by device address work there. The flat path's
derivation (bind::replay flat_dispatch) computes in 64 bits through
OpUMulExtended, OpUDiv and OpUMod; this checks those in a translated kernel
and prints the flat dispatch's execution report (a GROUP_COUNT replay fault
would say the derivation found the grid too large).

Verified: not yet run.
2026-11-15 08:31:57 -08:00
Anees Iqbal d2a9880b4e tests: a translated kernel's load and store through a device pointer
On the UHD 630 (Windows, 101.2145) the indirect dispatch on the flat path, from
Shared, Private and unimported memory alike, and the GPU replay of copied
commands run nothing, while the host step with no device addresses
(shaderInt64 withheld) runs. This separates the translated kernel's own reads
and writes by device address (direct dispatches) from the indirect machinery.

Verified: m3-max-32562 (UHD 630) ran the earlier five: 4 failed, the host step passed.
2026-11-15 08:31:57 -08:00
Anees Iqbal 8e8af60ade tests: host_step_reads reports the WorkCounts fields it has
Verified: the Windows build of 91b38cc731 named own_pages as no WorkCounts field.
2026-11-15 08:31:57 -08:00
Anees Iqbal 4853b4ba5c tests: the GPU's reads of indirect arguments on each path, with and without pointer imports
The consumer's correction: their failing indirect dispatch takes the GPU (flat)
path, not the host step. The test now runs the dispatch from a Shared buffer the
CPU wrote on the default device and on one that imports no host pointer
(VK_EXT_external_memory_host withheld), from a Private buffer a blit filled, and
through the host step; each prints its page-buffer and import counts.

Verified: not yet run.
2026-11-15 08:31:57 -08:00
Anees Iqbal 6189c27fe9 tests: a host step's indirect dispatch and copied-command execution write their outputs
A device test of what a host step reads: an indirect dispatch on a device
without device addresses (shaderInt64 withheld) runs the arguments the CPU
wrote and those a blit copied before it; the same dispatch on the device as
made; and an execution of a dispatch a blit copied into the executed buffer.
Each prints the notices and the host steps recorded. Reproduces the consumer's
Windows report (UHD 630: host-step dispatches and executions run nothing).

Verified: not yet run (first build on the Windows mini).
2026-11-15 08:31:57 -08:00
Anees Iqbal fd921926d9 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-15 08:31:29 -08:00
Anees Iqbal 8ba1fd7d67 RUNTIME 2358: Host RAM copies: a repeated copy takes the plan kept of it, where its buffer, the device's figures and its imports are the plan's
A copy by dispatches spent most of its encode on work that depends only on its runs, its
buffer and the imports it reads through: cutting the runs into pieces, the chunks' ranges,
the pieces' places in the imports, the table and the dispatches. A consumer repeats the same
copy (a surface's same runs) every frame.

Such a copy's plan is now kept per RAM per device (RamCopies, which ChunkKeys becomes):
direction, runs' form, buffer key (object id, device generation, length), the runs, the
blit_at VkBuffer and byte, the device's figures (window, alignment, workgroups, array), the
span and total, the chunk ranges and joined ranges, the import serials in order with the
chunk-to-imports map, the table and the dispatches. The next copy with the same key (runs
compared element by element, no hash trusted) takes the table and dispatches where:
- blit_at gives the same VkBuffer and byte (a rebind or a new VkBuffer plans anew);
- the device's figures are the same;
- every chunk takes at once (copy_take Now for all; else the full path stages it);
- copy_imports gives the same imports, by serial number, in the same order, with the same
  map. RamChunk now carries a serial from a process-wide counter, never reused, so a chunk
  released, given back or imported again has a new one. Plans keep numbers, not Arcs.
Every step a copy takes each time still runs: blit_at, copy_wrote, the takes, copy_imports,
the upload, the binds, the uses and the counts. Where the plan does not hold, what it took
(blit, takes, imports) goes to the full path, which takes none twice: a chunk released
between the takes and the imports plans over the imports it got.

Bounds: 8 plans and 4 MiB per RAM per device, the one taken longest ago dropped first; a
plan over 4 MiB is not kept. Counter: WorkCounts::host_ram_copy_plans_reused.

stages() is split into takes() and Takes::staging() so both paths share the takes;
record_dispatches() is the dispatch tail both paths record through.

Tests: unit, the bounds; device (lavapipe): a repeated copy takes its plan and a run
changed, the other direction, another buffer offset, another buffer, a rebound no-copy
buffer each plan anew; a chunk let go of (idle, given back) makes the next copy plan anew
and the one after take the new plan; a new use of the RAM plans anew; a kept plan's copy
is ordered after a fill of its buffer and after a scatter into its pages in the same
command buffer.

The plan also holds the buffer's host pages weakly and compares them by
identity: lavapipe gave a rebound buffer's new VkBuffer the destroyed
one's handle value (m3-max-32579), so a handle match alone cannot see a
rebind. The plan names no VkBuffer; the binds take the live one on every
call. The pages copy's kernel is looked up only where a copy goes by
dispatches, as before. The layer bench says how many copies a kept plan
recorded.

Measured (release, msi lavapipe, m3-max-32581, before d0ef5e0145 and
after, one job, median us a call over 8100 single-page runs): layer in 1
chunk 373.9 -> 139.1, over 128 chunks 859.8 -> 323.4; at 0bae61504a
(m3-max-32615) 200 of 200 copies by a kept plan.

Verified at 0bae61504a (m3-max-32610): host_ram tests on lavapipe
103/103, clippy plain, m2v_gpu and m2v_cpu_icd 0, rustdoc 0. Negative
control (m3-max-32579): with the serial compare removed, the let-go test
fails (a reuse happened).
2026-11-15 08:30:44 -08:00
Anees Iqbal 18cc0cd056 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-15 08:29:48 -08:00
Anees Iqbal 135df83657 RUNTIME 2357: Textures over buffers: an image over a buffer's texels may take its whole placement; an unobserved buffer lies on the linear image alignment
Intel's driver for the UHD 630 on Windows (101.2145) rounds a small
linear image's VkMemoryRequirements size up to its 4096-byte alignment:
BGRA8 73x8 at a pitch of 320 has a 2560-byte subresource and a 4096-byte
image, 16x16 1024 -> 4096, RGBA16F 88x8 6144 -> 8192. The in-place check
(linear_plan::aliases) bounded the image's size by the buffer's VkBuffer
bytes from the texture's first, so a texture over a padding-unobserved
Private buffer of exactly its rows was a shadow, and a buffer placed on
256 bytes failed the image's 4096 start too.

The room an image over a buffer's texels may take is now the buffer's
own placement from its byte 0 (Buffer::memory_room: bytes no other
resource is placed in), in texture.rs's two aliasing checks and the
two-plane YCbCr check. A buffer whose maker declares its padding
unobserved is placed on the device's linear images' memory alignment
(Device::linear_image_alignment: one probe image's alignment, a 64x8
R8G8B8A8_UNORM linear image, kept for the device), its start and size
whole units of it; the recycler's BufferMaking keys on that alignment,
and a device recovery's carry places such a buffer so again. Where the
alignment is 256 or less (RADV, lavapipe, MoltenVK), every placement met
it already and nothing changes. Cost: at most alignment - 1 bytes more
for each such buffer on the UHD 630, plus the start's padding.

Still a shadow: an image the driver sizes past its alignment's rounding,
R8 4096x1 over 4096 bytes taking 16384 on the UHD 630 (FAST-PATHS known
gaps), and on that driver textures over buffers that do not declare
their padding unobserved where the image is larger than the placement or
starts off 4096.

Tests: padding_unobserved's a_texture_whose_rows_fill_an_unobserved_buffer_is_in_place
makes a 73x8 BGRA8Unorm texture at the device's own linear pitch over a
Private padding-unobserved buffer of its rows alone and asserts the
placement lies on the alignment, the texture is the image over the
buffer, and no shadow is counted.

Docs: BufferDescriptor::padding_unobserved, the runtime README entry,
FAST-PATHS known gaps.

Checks: on the UHD 630 (Windows, m3-max-32630, at the same diff before
its rebase), padding_unobserved's new test passed: 73x8 at a pitch of 320
over 2560 bytes, 4096 of room on 4096, an image over the buffer, 0
shadowed. At cb7660c625: clippy plain, m2v_gpu and rustdoc 0
(m3-max-32602); lavapipe touched set 153/153 and m2v_cpu_icd clippy 0
(m3-max-32603).
2026-11-15 08:28:49 -08:00
Anees Iqbal d0b5b196c9 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-15 08:26:57 -08:00
Anees Iqbal 2a64c23a05 RUNTIME 2356: host_ram: an object that waited for the thread's import of a chunk marks it taken after the thread
What: RamOnDevice::chunk cleared a chunk's `untaken` mark for an object's call
before it looked at the chunk's state. An object that found the device's thread
importing the chunk (Import::Making, By::Ahead) cleared it, then waited; the
thread, ending its import, set Made and then marked the chunk untaken under the
chunk's lock, after the object's clear. The object then took the chunk, which
stayed marked untaken. A give-back near the allocation limit skipped it while
the object's buffer held it, but freed it once that buffer went, setting `tried`,
so the thread never imported it ahead again and the next object over it
imported it itself.

How: the object clears the mark in the Import::Made arm, once it holds the
chunk, under the same lock the thread marks it under, so the clear comes after
the thread's mark whether the object found the chunk made or waited for it.

Test: at_the_margin takes when its first object takes the RAM's first chunk
(Opens::Made, as before, or Opens::InFlight: the thread's import held in flight
by making_pause, the object's call past taking_pause and still blocked on it).
a_chunk_an_object_waited_for_the_thread_s_import_of_is_not_given_back drops
that object, brings the device within the margin with an object past the
thread's chunks, and asserts AHEAD-1 chunks went back and 2 stay live (the first
chunk and the new object's); with the mark left set, AHEAD go back and 1 stays.
Verified on lavapipe: m3-max-32606 ran the 99 host_ram tests and clippy
(m2v_cpu_icd); m3-max-32614 ran clippy plain and with m2v_gpu. In the
same job, the host_ram.rs hunk reversed (negative control) fails the new
test: 4 chunks given back, 1 live.
2026-11-15 08:26:08 -08:00
Anees Iqbal f4c9902c63 FAST-PATHS: the cold Shared making's range on this tree is 95-97 ms
The previous commit gave 92-97 ms; m3-max-32595's two runs of this tree
made the cold round in 97.0 and 94.6 ms.
2026-11-15 08:15:57 -08:00
Anees Iqbal 9ee682344f FAST-PATHS: the 16 KiB allocation's measured cost
A 16385-byte buffer's VkBuffer requires 32768 bytes where 16400 did, on
RADV PHOENIX and lavapipe (m3-max-32595, m3-max-32558). On the Radeon
780M, release, exclusive, the base (d2ee5bca5b) and this tree run twice
each in one job (m3-max-32595): 1000 buffers of 16 KiB + 1 to 4 MiB
required 763.3 MB against 754.8 MB and took one more 64 MiB block in
their second round; making them took the same time within the runs'
spread, Shared ones cleared on the host and Private ones' first fills
alike.
2026-11-15 08:15:57 -08:00
Anees Iqbal ab779daf66 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-15 08:14:54 -08:00
Anees Iqbal a1175662e7 RUNTIME 2355: Textures over buffers: a buffer of 16 KiB or more holds Metal's allocation, a heap's buffer its heap
A texture over a buffer whose texels run past the length was always a
copy: a shadow image or a staged texture buffer whose bytes past the
length lay in a tail of its own. Metal's texels there are the
allocation's: a buffer of 16 KiB or more holds its length rounded up to
16 KiB (allocatedSize), zero when made, and a heap's buffer reaches its
heap's end, whose bytes are the heap's.

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

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

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

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

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

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

Lane commits: d2ee5bca5b (bench), a8f3796f59, ee54952340 (heap cases in a placement heap).
2026-11-15 08:14:12 -08:00
Anees Iqbal b3113687a8 heap_textures: the untracked lane prints each heap's splits at aliases
The untracked lane (a kernel's write of an untracked heap's buffer, bound
or through the address its argument buffer holds with the buffer resident,
then a read of a texture over the same bytes in one encoder) asserted only
that the run as a whole split some command buffer at aliases where the
driver fact holds and a texture lay in place. On the RTX 3090 at
25119268da both forms split 1 command buffer over the Shared and the
Private heap, each texture in place, so the counts did not say which heap's
read split, nor that the resident write splits where the bound one does.

Each HEAPTEX untracked line now prints the command buffers split at aliases
while its heap ran (from before its texture was made to after its compute
command buffer completed). Test-only; nothing asserted changes.

Verified: cargo fmt. The lavapipe build and run follow.
2026-11-15 08:04:10 -08:00
Anees Iqbal d0ef5e0145 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-15 07:57:53 -08:00
Anees Iqbal 7ede7adacf RUNTIME 2354: Host RAM copies: a copy finds each run's chunk by arithmetic, marks its pages in one bitmap vector and keeps its ranges as they are where they need no joining
A copy's encode cost grew with the chunks its runs touch: a binary search over the
chunks for each run that left the last run's chunk, a bitmap allocated for each chunk
touched, its runs read into a vector and copied into another, and each chunk's ranges
cloned, sorted and merged again before joining, though touched_ranges already gives
them sorted and apart.

- ChunkSpans (host_ram.rs): the chunks' spans and each RAM range's first chunk; of()
  finds an address's chunk as the range's first plus the chunks before it, the span
  span_of finds. pieces() takes it and still tries the last piece's chunk first.
- touched_ranges keeps every touched chunk's bitmap in one vector, reads the pages
  back with MarkedRuns (lazily, runs across words as one) and builds each chunk's
  ranges once, with as much room as its pieces.
- joined takes a chunk's ranges as touched_ranges gives them and borrows them where
  there are no more than the bound; chunk_ranges sorts and merges before it.

Same ranges, same overlap answer, same uses as before (the touched_ranges
equivalence test is unchanged). New unit tests: a chunk found by arithmetic is the
span that holds the address; MarkedRuns reads the runs the bits one by one give.

Evidence (lane jobs, msi lavapipe): m3-max-32538 at the lane tip: clippy plain / m2v_gpu / m2v_cpu_icd -D warnings 0;
host_ram 98/98; rustdoc 0. m3-max-32486: a_chunk_found_by_arithmetic_is_the_span_that_holds_the_address and
marked_runs_are_the_runs_of_the_bits_one_by_one; the touched_ranges equivalence test unchanged. Release medians, one job
m3-max-32485, 8100 single-page runs: 1 chunk 309.6 -> 298.9 us, 128 chunks 811.7 -> 733.4 us.

Lane commit: b13c097e6d.
2026-11-15 07:57:10 -08:00
Anees Iqbal 584da21fad 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-15 07:55:56 -08:00
Anees Iqbal 487a1253f2 host_ram: RamSource::wakes compiles only with its one caller, the device tests
Plain clippy of the runtime's lib test failed on development (a4ea017d9e): the
accessor was cfg(test), but its only caller, tests/host_ram_copy_device.rs,
compiles only under m2v_gpu or m2v_cpu_icd, so it was dead code there. It now
takes the caller's cfg, as step_aside.rs's device-test hooks do.
RamOnDevice::wakes stays cfg(test): the host_ram unit tests call it.
2026-11-15 07:55:10 -08:00