Commit Graph
1223 Commits
Author SHA1 Message Date
Anees Iqbal df985fbacb Check a draw again against its every step by digests: the check allocates nothing
In builds with debug assertions every second draw again (and rebound draw) takes every step and
checks it against what the draw again would have done. The check boxed itself (Again::Check's
Box<Checked>) and cloned what it compared: the drawn areas and coverage, the pass's reads and the
instance's gathered uses (HeldReads, HeldGathered: copied lists), the noted uses, the pass's
input and extended sets, and of a rebound draw its commands, set-0 writes, offsets, push bytes,
vertex buffers, uses and resident keys. Those allocations count in the frame lanes' draw
allocations, which CI runs with debug assertions: runtime_lane::frame_costs'
a_frame_s_draws_and_pass_ends_allocate_within_their_bounds measured 22.30 allocations a draw on
the M3 (bound 20) once draws rebind.

Each part is now compared by a digest of its Debug form, streamed into a hasher through a
fmt::Write adapter (draw_again::digest), which copies nothing. The encoder's held state is taken
only for a plain draw again (Expected::Plain; a rebound draw's check compares what it worked out,
Expected::Rebound). Checked is no longer boxed: the draw path hands draw_again an
Option<Checked> on its stack, which kept_again takes as before. pass_start_reads::held and
shadows::gathered lend their lists rather than copy them; binding::Info and NotedApart print
their Vulkan values raw (ash's types print nothing without its debug feature). Release builds
are unchanged. No bound changed.

Measured on the M3 Max (MoltenVK 1.4.2), with debug assertions: that lane's draws make 18.21
allocations a draw (was 22.30; bound 20); a pass end 15.67, a pass open 5.00. Negative control:
with binding::rebind_into's image descriptors left as they were (the rebind's texture path
broken), tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
fails with "a draw rebound worked out other set-0 writes than its every step".

Verified there, --cfg m2v_gpu, on a tree that also held the next commit's change: the runtime's
whole suite, 1545 of 1546 (the one failure, tests::scheduler_wakes::
commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns); the validation crate's runtime
lanes listed in the last commit, 288 of 288. Clippy over the workspace, plain and
--cfg m2v_gpu; release builds check clean.

(cherry picked from commit 1b8e52fe2f58f01df507d4f9b345dcb901c16ca2)
(cherry picked from commit 838786566146858e00b579ebc78240353fa87061)
2026-11-03 05:51:20 -08:00
Anees Iqbal 6980b529dd Count draws again and rebound draws as they record, into per-thread shards
A render encoder's draws again and rebound draws added their counts to the device's only at the
encoder's next call that forgot the kept draw, or at its end (draw_again::Counted), so that no
draw took a shared atomic add: draws_as_before, draws_rebound, commands_noted_as_before,
draws_pushing_set_zero, provoking_last_pipeline_draws, the stage tables they read in part and the
state commands and set-0 writes they recorded. A reader of WorkCounts between draws saw none of
them.

Those counts, and the other counts the draw paths add per draw (stage_tables_read and
_in_part, draw_states_recorded, set_zero_writes_pushed), now live in per-thread shards:
shards.rs holds the recorder's shard scheme, moved out of recorder/thunks.rs, and a generic
Sharded<T> of 16 shards on 128-byte lines; each thread adds into its own shard (threads past 16
share them in turn) and WorkCounts sums them. A draw counts as it records: one thread-local
lookup, and atomic adds on a line no other thread writes. The deferral and forget_again's flush
are gone; the WorkCounts docs no longer say the counts wait for a call.

Checks: tests::draw_again::draws_again_and_rebound_count_as_they_record reads draws_as_before and
draws_rebound before each draw, with no call between but the binds a rebound draw takes; under
the deferral every read is 0. tests::recorder_shards::a_sharded_count_is_every_thread_s_additions
sums 19 threads' additions over the 16 shards.

Cost, M3 Max, release host_ab encode, one session, per draw (instructions retired and cycles
over 23 passes of 10000 and of 30000 draws), before -> after:
- draw_static (draws again): 2018 instr, 450 cycles, 0.110 us -> 2042, 639, 0.115 us;
- draw_offset (rebound draws): 12452 instr, 2376 cycles, 0.554 us -> 12357, 2442, 0.563 us.
The same within the runs' spread: a draw's adds land on its thread's own line.

Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that
also held the next two commits' changes: the runtime's whole suite, 1545 of 1546 passed (the one
failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, passed 10 of 10 reruns);
the validation crate's runtime lanes (frame_costs, render, draw_*, hazards, sync_coverage,
shadows, attachments, executions, degrade_notices), 288 of 288. Clippy over the workspace, plain
and --cfg m2v_gpu; the runtime's Rustdoc.

(cherry picked from commit c26838fdd2abe5bcaa5e3ecb2ed9477721b017dc)
(cherry picked from commit 643246f591c39b40c0d7d00f68f8768457673bdf)
2026-11-03 05:51:20 -08:00
Anees Iqbal 85c6c786d0 List the rebound draw's kept recording among the modules that keep device functions
A kept draw's recording (rebound::KeptRecording) holds its index bind (draw_source::IndexBind),
which keeps the device's sized index bind command where the device has it. The exit guard's
tests::exit_guard::only_the_listed_modules_keep_the_device_s_functions lists every module that
keeps a copy of the device's functions with why it may, and failed on the unlisted
render/draw_again/rebound.rs. It is listed: the recording is held by its encoder's bind state (a
spare one by the device's, which the teardown ends) and recorded again only by the encoder that
kept it.

Verified on the M3 Max (MoltenVK 1.4.2), --cfg m2v_gpu, with debug assertions, on a tree that
also held the next commits' changes: the runtime's whole suite, 1545 of 1546 passed, this test
among them (the one failure, tests::scheduler_wakes::commits_with_idle_gaps_lose_no_wake, 69
wakings over 68 sleeps, passed 10 of 10 reruns on the same tree).

(cherry picked from commit 921cfd22688850e5392ee455dec82c27cdeb1234)
(cherry picked from commit 383e74af1eaf0aceb4e600d5502f6a408c9c1517)
2026-11-03 05:51:19 -08:00
Anees Iqbal 3a8b56ecc7 Take every step of a draw after a sampler state is made or goes: its kept draw read the listing
Every step of a render draw lists the device's live sampler states again where their slots
changed since its bind state listed them (LiveBind::listed_at,
Device::sampler_slots_changed). The listing goes into the bind state and so may change its
shape. A draw again, and a draw rebound, took the kept draw's bind state as it was: after a
sampler state was made or dropped between two draws, they skipped the listing and the
reshape that every step would make.

The kept draw's Under now holds the count of the sampler IDs' slots' changes. A draw under
another count is not the kept draw again and takes every step. The count is one Acquire load
a draw, with no read-modify-write.

Check: runtime_lane::draw_work::draws_take_the_device_s_sampler_states_only_where_they_changed
(draws rebound after set_vertex_bytes: a state made before column 3's draw, gone before column
6's). With the bind tail and without this, the M3 counted [0, 0, 1, 0, 1, 0]: the listing came
one draw late, at the debug check's draw that takes every step. The test expects
[0, 1, 0, 0, 1, 0].

(cherry picked from commit d8bf1bcf383b7e746916d8f0dbbf769e0a60d4ae)
(cherry picked from commit 1a2b148ba4145da26a456ea52b6fc249b14aaeb4)
2026-11-03 05:51:19 -08:00
Anees Iqbal 50b41ecc54 Draw the kept draw again rebound after texture and sampler binds too: rewrite those slots alone
A vertex or fragment texture or sampler bind forgot the encoder's kept draw, so a draw after one
took every step: the compositor shape (a buffer and a texture bound before each draw) never
reached the bind tail.

Now:
- Texture and sampler binds keep the kept draw (log_keeping), as buffer binds do; the next draw
  compares the tables' stamps.
- BindingPlan::rebind_draw_slots_into (was rebind_draw_buffers_into) takes buffer, texture and
  sampler slots. A texture or sampler slot decides none of the commands. It answers Ok(false)
  for a texture buffer's texel range and a YCbCr texture's planes.
- binding::rebind_into writes a changed texture's or sampler's image descriptor as bind_into
  does (image_descriptor, through the encoder's memo, its samplers kept for retaining). It
  answers Ok(false) for a changed texel buffer, YCbCr image or argument sampler.
- The draw rebound brings in texture and sampler slots and stops where every step would differ:
  - a memoryless texture its functions use (the full path fails the command buffer there);
  - runtime samplers' address modes other than the kept draw's;
  - a changed shape (a sampler of other addressing, which the pipeline's specialization
    reads, takes every step);
  - a plan that samples or writes a color attachment's texture;
  - an extended-range shadow.
  It retains the new samplers and notes whether its uses read an image (Kept::reads_images).
- Docs: rebound.rs, WorkCounts::draws_rebound, docs/API.md, api_signatures.tsv.

Check: tests::draw_again::draws_after_texture_and_sampler_changes_rebind_what_every_step_binds
(tob_sample). It covers another texture each draw, another sampler of the same shape, both,
and samplers of other addressing. It checks rebound counts (0 for the last), commands, state
commands, noted uses and pixels against every step, with the debug cross-check on every second
hit. It fails without the change (0 rebounds). The buffer test's slot-of-another-class case is
now more slots than a draw rebound takes (samplers 0 to 8). Passes on the M3 (MoltenVK) with
the draw_again tests; clippy clean, plain and with --cfg m2v_gpu.

(cherry picked from commit ecf97956b214836a1309affe539aff8454239e97)
(cherry picked from commit 8472edf4c0ae174c3dab7bc667cecfa6874aa942)
2026-11-03 05:51:19 -08:00
Anees Iqbal 01f40bb3f4 Hold a render encoder's current instance in its lowering's box: a pass open makes no box of it
1aaf95c79f boxed the current instance (1656 bytes) so that the encoder's moves at its pass end
carried a pointer. That made one more allocation at every pass open, on every device:
runtime_lane::frame_costs::a_frame_s_pass_opens_allocate_within_their_bound measured 6.00 a
pass open on the M3 (bound 5.5) and 5.00 on NVIDIA (bound 4.5).

The instance now sits unboxed in the RenderLowering, which is already boxed once where it is
built. end_pass lists the pass's instances in the earlier instances' vector, the current one
pushed last, in place of a vector of boxes; a split still boxes the new instance it hands back
(Next::New) and unboxes it into its place. OPEN_ALLOCATIONS' doc says where the instance lives.

Not done: keeping the emptied instance box in the draw room. end_pass moves the first instance's
pieces, earlier steps, shape, positions and kept commands out to the pass's steps, so keeping
its box would need placeholder moves or a change to how long the steps live.

Verified: builds (cargo check, all features); the frame_costs lane runs next on MoltenVK.
(cherry picked from commit e4fb5fcd47c4a3bd97e1ef9a021d3c466291ac19)
(cherry picked from commit 15c0626814a8e8e75c30c105c1a69f7f8dd3ea0e)
2026-11-03 05:51:19 -08:00
Anees Iqbal d6302220bf Count recorded commands in per-thread shards: threads that record at once write apart
The recorder counted each command with one relaxed fetch_add into a single array per device
slot, so every thread recording at once wrote the same cache lines. On the 5080 a draw drawn
again (a Vulkan draw alone) cost 0.060 us of thread CPU on one thread and 0.232 us on eight.

Each slot now keeps 16 shards of its counts, each aligned to 128 bytes. A thread takes the next
shard at its first count (a thread-local, one fetch_add per thread, not per command) and keeps
it; threads past 16 share them in turn. WorkCounts::commands_recorded reads the sums, so the
counts mean what they meant.

Measured on the 5080 laptop (host_ab threads, 10000 draws, 32 timed passes, one round, under
the GPU locks, SCHED_OTHER), landed tip vs the bind tail plus this (a static draw takes no part
of the tail):
- draw_static, one shared state, thread CPU us/draw at 1/2/4/8 threads:
  0.060/0.092/0.149/0.232 -> 0.065/0.062/0.059/0.065; Mdraws/s 16.9/21.1/25.8/30.9 ->
  14.1/30.8/49.7/87.8.
- draw_static, a state per thread: 0.061/0.099/0.126/0.202 -> 0.058/0.062/0.059/0.062;
  Mdraws/s 16.2/19.9/31.0/35.1 -> 18.7/32.6/59.8/94.6.

Check: tests::recorder_shards::threads_count_into_shards_of_their_own (as many threads as
shards each count apart, and the next shares the first's): passes under nextest. clippy clean.

(cherry picked from commit 43ac1c48e746d592055aa5e0606cf79e8ebaedd7)
(cherry picked from commit ada254765fb0a09294b03a1ad17428a111c8192b)
2026-11-03 05:51:18 -08:00
Anees Iqbal e3f2c95dfe Draw the kept draw again rebound: after buffer, offset or bytes binds, rewrite those slots alone
A render encoder's kept draw (render/draw_again.rs) drawn again after calls that bound other
buffers, offsets or inline bytes at vertex or fragment buffer slots now rebinds only those slots
(render/draw_again/rebound.rs, WorkCounts::draws_rebound), where it took every step of a draw.

- Translator: BindingPlan::rebind_draw_buffers_into(state, slots, commands) writes again, over
  the same draw's commands of a state of the same shape, only what the buffer slots decide: their
  descriptor ranges at their places, the SlotBindOffset, SlotGuestBase and pulled-stride push
  fields that read them, and their vertex buffers' offsets. Ok(false) for a device-address slot,
  an argument or root table, a per-bind stride's vertex binding, a mesh, patch or de-indexed draw,
  or a uniform view a written slot may alias. docs/API.md says so; api_signatures gains it and
  WorkCounts::draws_rebound.
- Runtime: buffer and bytes binds keep the kept draw (log_keeping); the draw compares its tables'
  stamps with the kept draw's. On a difference, the tables' changes since (argument_table::
  changed_since: buffer slots alone, at most 8) are brought into the kept bind state
  (refresh_changed), and the draw goes on only where its shape stays, its variant and plan then
  the bind state's kept settle (LiveBind::settles_kept). It rewrites the commands
  (rebind_draw_buffers_into), set 0's writes and dynamic offsets (binding::rebind_into), push
  bytes and vertex buffers, and its uses whole (command_uses_into), and takes the checks a draw
  takes of them: a pulled attribute's reach, the stages' function tables, the attachments' reads;
  it stops at a pass whose fragments wrote memory, a shadowed texture among its uses, a barrier
  its fragments need after earlier geometry writes, or a detached buffer. It records with set 0
  as any draw finds or writes it (EncoderCore::set_zero_of), its uses noted as any draw notes
  them, through the kept draw's recording parts against what its command buffer holds; a notice
  met at each occurrence forgets it once recorded, as every step does. The kept parts (set-0
  writes that hold no keeper, dynamic states, the rest of its recording) live in the bind state's
  storage (LiveBind::kept), filled at the keep alone: a draw that takes every step pays one
  KeptStorage::keep and nothing per recording.
- Checked in builds with debug assertions: the first rebound draw of a kept draw and every second
  after it take every step instead, which must keep the draw, with the same commands, set-0
  writes, dynamic offsets, push bytes, vertex buffers and uses.

Tests: tests::draw_again::draws_after_buffer_changes_rebind_what_every_step_binds (MoltenVK, M3):
draws after offset and bytes changes rebind (draws_rebound == the draws again but those the check
takes), with the same commands of every kind, state commands, noted uses and pixels as the same
draws each taking every step, every draw at its own offset and color; a sampler bind between them
takes every step. Negative control: the translator not rewriting a changed slot's range fails it
at the cross-check ("other commands"). metal2vulkan's tests::engine_graphics_binder rebind test:
1360 rebinds over stage-io plans equal a full instantiate, and its negative control fails.

host_ab encode, release, 10k draws per command buffer, us/draw, offset case (one
set_vertex_buffer_offset before each draw), measured on this change before its last revision
(which moved the kept parts' fill from every full draw's recording to the keep and dropped three
Arc clones a keep; its own numbers come with the next landing):
  Apple M3 Max, MoltenVK 1.4.2, three interleaved rounds (median / mean of round p50s / max p90):
    lock fix 1.561 / 1.550 / 1.591  ->  0.550 / 0.548 / 0.592
  RTX 5080 Laptop GPU, thread CPU per draw, host_ab threads workload, one thread:
    lock fix 2.006 (shared PSO), 2.001 (own)  ->  0.541, 0.585; on 8 threads 10.3 Mdraws/s (was 2.9)
The unchanged draw (static) holds: 0.044 -> 0.046 on the M3.

(cherry picked from commit 2ee3520ff104094afde523e2eebf7bc8a9a9626d)
(cherry picked from commit d00975ea7da92da4886a29f1ebda6397f64202b1)
2026-11-03 05:51:18 -08:00
Anees Iqbal 658e5ced81 host_ab: the compositor stand-in, passes of 300 draws each binding its own buffer and texture
The encode workload's `draw_compositor` variant draws as a window server's frame draws: render
passes of 300 draws (the first clearing the target, the rest loading it), before each draw another
vertex buffer and offset and another fragment texture bound (as `draw_bind`), and every run of 10
draws drawn by the next of three pipeline states reused every frame: the two textured states
(`quad_vertex` + `textured_fragment`, without and with blending) and a solid one
(`quad_vertex` + `icb_draw_fragment`, blending, which reads no texture), the Scene's new `solid`.
It stands in for the shape a guest compositor's main command buffer takes during a window drag:
a few hundred draws a pass whose buffers and textures change between draws, its pipelines the same
across frames. Per draw: the encoding thread's wall time and the process's CPU time, as every
encode variant.

Verified: the example builds (release) on the M3 and runs its variants; its numbers come with the
commits that measure against it.

(cherry picked from commit 89cd071b0d416127c483900ccbbcabee04dc6fa0)
(cherry picked from commit f4d394f7d12a12f937e455f52ec6b5f3ce7b53f0)
2026-11-03 05:51:18 -08:00
Anees Iqbal 9ec100ba7c conformance cost: RACY holds 38 rows with linked_pipelines_shared beside commits_taken_in
Two commits each added one row to the racy-count table from bases that held 36 (the shared
linked pipelines' linked_pipelines_shared, and the taken-in wait's commits_taken_in); the
cherry-pick kept one length, so the array's stated length was 37 for 38 rows and the
conformance crate did not compile. Verified: clippy -p metal2vulkan-conformance --all-targets
--all-features -D warnings clean.

(cherry picked from commit 357a76f214273dd25e3caa905336fce7b7548135)
2026-11-03 04:54:41 -08:00
Anees Iqbal 14a73185a2 Pin the runtime sources after the empty fresh log's skipped lock and the warm budget's docs
(cherry picked from commit 0222da037d4a9883995cf96dd7645081ad3f00ab)
2026-11-03 04:54:41 -08:00
Anees Iqbal d07650b362 Warm passes: judge the byte budget on every device, and say what pipeline_bytes counts
What: tests::warm::a_byte_budget_stops_the_pass no longer skips its 1-byte leg when the pass
counted no driver bytes. That leg runs over a directory of its own, which holds none of the
records' driver data, so it now asserts that the pass wrote records' data (driver_saves > 0),
counted it (pipeline_bytes > 0), and stopped after the first record, on every device. A new test,
a_pass_over_its_records_own_directory_counts_only_what_it_writes, warms records over the directory
whose creations made them and asserts that the pass counts driver bytes exactly where its makings
wrote data. Where it wrote none, it asserts that a 1-byte budget stopped nothing.
WarmStatistics::pipeline_bytes, Device::warm, the runtime README and docs/HOWTO.md now say that a
making whose data the directory holds already adds nothing. Over that directory the budget binds
only where a making writes new data.

Why: the consumer read pipeline_bytes 0 on every boot of the RTX 5080, though the warm pass made
248 pipelines, and asked whether the counter is broken there (a making's keep on a thread
without the pass, or a path that never keeps). Measured with a scratch diagnostic at 1bb0b87a5a,
not committed:
- RTX 5080, a fresh directory: 23,800 bytes counted, 3 records' data written.
- The 5080 over the records' own directory: 0 bytes, 0 written, 2 unchanged, 2 found.
- M3 Max on MoltenVK 1.4.2: 13,362 bytes and 3 found respectively.
So keep() runs on the pass's thread and counts on NVIDIA too, and the consumer's 0 is the true
value. Their records come from the boot before, over the same directory, whose creations wrote
every making's data. The old test's skip branch could have hidden a broken counter; now a pass
that writes data and counts none fails.

Verified: tests::warm on the M3 (MoltenVK 1.4.2), 6 passed. The 1-byte pass over a fresh
directory counted 8,003 bytes with 1 record's data written; the pass over its own directory
counted 0 bytes, wrote 0 and found 3. cargo clippy -p metal2vulkan-runtime --all-targets
--all-features -D warnings with --cfg m2v_gpu; public rustdoc clean. The RTX 5080 run is in the
hand-over.

(cherry picked from commit 83cc2dbe6fb610c6ad59a741a7170812611cf703)
(cherry picked from commit 1d43003372f23275ceb7fcc463a34abedbeff9a7)
2026-11-03 04:54:41 -08:00
Anees Iqbal 376d835a4f Take no lock of a command buffer's fresh-texture log at a commit that logged nothing
What: FreshLog keeps a flag, set where FreshLog::add pushes an event. FreshUnwritten::commit
returns before it takes the log's lock where the flag is clear, as it already did where no
texture is noted. A commit that logged something takes the log as before.

Why: host_ab percall's commit rows failed on gate/stack11: commit_one_dispatch 5 allocations
a call (held to 4) and commit_no_copy_dispatch 10 (held to 9). e3b963bdc0 measured 4 and 9 on
9f56956ef3, before the pattern reads moved to the commit (95d7bdf6dc). Since then, while any
noted texture is live in the process, every commit locks its command buffer's FreshLog mutex,
in these rows for the first time: their dispatches bind only buffers and log nothing. On macOS
a std Mutex makes its pthread mutex at its first lock, one allocation (Rust 1.98.1 on the M3:
4 allocations for the first locks of 4 new mutexes, 0 for the second locks). The trace put
that allocation in FreshUnwritten::commit, the fifth of the commit's sites. The other four
(Predication::end_unit, close_tail, the BatchSync list, gate::Hold::new) are the ones the rows
were measured with.

Verified:
- host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2), on 4f0a1043b1
  with this branch's two commits before this one, the gate made to print: commit_one_dispatch
  4 and commit_no_copy_dispatch 9 allocations a call (stack11 with those two commits: 5 and
  10). No row of the gate fails in that run: end_render 24, end_compute 7, end_blit 7,
  heap_texture_256 17.25, the draws 0.0390625, dispatch 8.13.
- The traced commit_one_dispatch lists Predication::end_unit, close_tail, the BatchSync list
  and gate::Hold::new, the four a trace of 9f56956ef3 lists, and no FreshUnwritten::commit.
- tests::fresh_unwritten (8), tests::tracker and tests::heap pass under --cfg m2v_gpu on the M3
  Max (93 of 93).
- cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, plain and
  under --cfg m2v_gpu: clean.
The rows already hold the counts this restores, so the gate itself is the check: it fails
without this change. No answer, announcement or submission changes (a log with no events gave
the record nothing), so RUNTIME_VERSION stays; the runtime sources' pin moves with
fresh_unwritten.rs.

(cherry picked from commit b878f5b569662b4fcf45c23ef84e619e5e212ea6)
(cherry picked from commit 6c70d5b7e01a874aa2cfde501b024cea394209d4)
2026-11-03 04:54:40 -08:00
Anees Iqbal a977bbbe45 Pin the runtime sources after shared linked pipelines and the small encoder parts' stack order
(cherry picked from commit 873c932fa849d07da1d3d9186412d8044042c39c)
2026-11-03 04:54:40 -08:00
Anees Iqbal e6f3c91973 Bump RUNTIME_VERSION to 1750: render variants of one link share its linked pipeline
A run of an unchanged artifact and plan on a device that links pipelines from libraries now takes
the device's linked VkPipeline for a render variant whose four libraries and pipeline layout equal
one already linked (a content-keyed map; WorkCounts::linked_pipelines_shared), where it linked a
duplicate before; teardown drains the links before the libraries. Elsewhere nothing changes. Encoder
ends order a small part's resources on the stack and a heap texture asks whether a shadow fits only
where its images do not, which changes allocations alone. 1750 is 1749 (commits taken in) plus one.

(cherry picked from commit 2d9d5868bce2b1ddc1b46bf15d0901f320e6ffd3)
2026-11-03 04:54:40 -08:00
Anees Iqbal 7c142e9a12 events: hold the post-commit scheduled-signal claim's command buffer behind an event
a_scheduled_signal_sets_its_value_as_the_command_buffer_is_scheduled encoded a scheduled signal
right after committing a 64-byte fill and expected Ok(()); a call after the command buffer
completed is refused (ScheduledSignalAfterCompletion, claimed just below), so where the fill
completed before the call the claim failed. That happened once in stack13's lane under -j 6
load (10/10 alone). The command buffer now waits for an event the host signals only after the
call, so the call always lands between its commit and its completion; the claims are unchanged.

(cherry picked from commit d6771add4d5d8c009352d51543ca897f69fe94fd)
2026-11-03 04:54:40 -08:00
Anees Iqbal e70d81dc6c made_at_creation: the second state of one link takes the first state's linked pipeline
What: runtime_lane::made_at_creation::states_of_one_fragment_and_pass_share_its_fragment_library
now expects the second state (its attachment blending with factors one and zero, which makes no
library: the four parts and the layout are the first state's) to link nothing and make no
pipeline, and to take the first state's linked pipeline (WorkCounts::linked_pipelines_shared + 1),
where it linked a pipeline of its own from the same four libraries before.

Why: 22b2fd234e shares a linked VkPipeline between render variants of the same link; this lane
held the old re-link. It is the shape the change is for: a state of its own whose whole key is
the first state's.

Verified: on the RTX 5080 (msi, no VM, under the GPU lock) the lane passed on d3e66f9415 and
failed on 22b2fd234e with (0, 0, 0, 0) where it held (0, 1, 1, 0); the run of this commit is in
the hand-over.

(cherry picked from commit 9026d6e92c99425950099fd2387178d6021a03b1)
(cherry picked from commit ac134c2420fe1151064ddba8221f032bafe38dc8)
2026-11-03 04:54:40 -08:00
Anees Iqbal 29550063fe Share one linked VkPipeline between render variants of the same link
What: where the device links its render pipelines from graphics pipeline libraries, the linked
VkPipeline is now the device's, held in a content-keyed map (pipeline/libraries.rs) beside the
four part libraries and found by exactly what its linking takes: the four parts' names and the
pipeline layout it is linked with. A variant claims the link on the creating or drawing thread as
it claims its libraries; the first caller links it (Library::made, as a library is made), and every
later variant of the same link takes it with no driver call. The link holds its libraries and its
layout share while it lives (Vulkan may read a pipeline's creation's objects as long as the
pipeline lives); each variant's RawPipeline and each kept pipeline hold the link, and only the map
destroys it, at a program's settle once nothing holds it or at the device's teardown, before the
libraries. A pipeline made whole (no libraries, MoltenVK) is unchanged: the variant's own.

New count WorkCounts::linked_pipelines_shared; a shared link counts in neither pipelines_linked
nor variant_pipelines_made. The conformance cost half reports it as a FOUND count, never gated,
in the translation region. api_signatures.tsv gains the field.

Why: the consumer measured a client creating about 8,500 render states at login, each with a
linked pipeline of its own. States alive together of one compiled pipeline already share their
variant and its pipelines (memo.rs), and a released one's come back from kept.rs; but states that
are compiled pipelines of their own whose stages come out as the same words linked the same
pipeline again, each its own. Now a repeated link costs a lookup.

Test: tests::linked_pipelines_shared makes 16 siblings of one pair that differ only in
maxFragmentCallStackDepth (each a compiled pipeline and variant of its own; the fixture's fragment
function recurses through no visible function, so the words are the first state's), draws with
each and checks every pixel, and where the device links from libraries asserts the siblings
linked nothing, made no library and no variant pipeline, and took at least 16 shared links. A
descriptor differing only in a buffer's mutability is not such a sibling: it is the same compiled
pipeline, whose live variant it shares whole.

Verified: on MoltenVK 1.4.2 (M3 Max), which makes its pipelines whole, the new test and the
touched suites (driver_pipeline_compile, render_sibling_work, kept, warm_record,
uniform_bind_offsets, the libraries unit tests): all passed; the siblings there made 16 variant
pipelines, 0 shared, so the siblings are variants of their own. cargo clippy -p
metal2vulkan-runtime --all-targets --all-features -D warnings with --cfg m2v_gpu; public rustdoc
clean, no new private intra-doc link diagnostic; the conformance cost tests (37 passed). The run on
a device that links from libraries is in the hand-over.

(cherry picked from commit 22b2fd234eb66bf71ebc2c6e6639c0488ff5149a)
(cherry picked from commit a49b1f7d832c1beeae1e511a8f57b00b2e1640fd)
2026-11-03 04:54:40 -08:00
Anees Iqbal 2bf4e3b4cb Ask whether a shadow fits a heap texture only where its images do not, and hold it to 17.25
What: held_to_metal takes the question whether a shadow of the heap's bytes fits the image's
planes as a closure (shadowable), asked only of a single-sample texture its images do not hold:
past Metal's answer, or 4:2:2. HeapTextureShape loses its shadowable field. Device::heap_plan
passes `|| shadowable(plan, metal.size)`. host_ab percall's heap_texture_256 row comes down to
the measured 17.25 allocations a call from 20.25.

Why: shadowable answers from heap_planes, which lays out the texture's planes (copy_units'
list, heap_plane_layout's planes) and its copy regions (a BufferImageCopy list) only to compare
the bytes they span. f7d857ec55 moved the question from an else-if, where it was asked only
when needed, into the shape every heap texture builds, so each heap texture made those three
vectors and dropped them unread wherever its image lies in the heap: 3 of the 20.25. The other
+1 against the row's birth (18.25 at 5c9d347c2f) is not one: storage_view_formats' allocation
left this path since, so the call is now one under its birth count. c01e79adc1 raised the row to
20.25 with no cause found.

Test: tests::heap::a_heap_texture_is_held_to_metal_s_answer_by_its_image_or_by_a_shadow passes
the question as a counting closure: it is never asked where the images fit, nor of a texture
whose image lies apart; it is asked of each shape past Metal's answer, and the answers are as
before (Images, Shadow, Nothing, multisample and 4:2:2).

Verified:
- host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2), on 4f0a1043b1
  (gate/stack11) with this change and the one before it, the gate made to print:
  heap_texture_256 17.25 allocations a call (stack11: 20.25), its one image, one binding and no
  memory allocation unchanged. The trace of its allocations no longer lists heap_plane_layout,
  heap_planes or the copy_units under shadowable.
- The heap test and tests::tracker pass (65 of 65).
- cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, plain and
  under --cfg m2v_gpu: clean.
The route and the answers do not change (shadowable is the same function, asked where its answer
is read), so RUNTIME_VERSION stays; the runtime sources' pin moves with texture/heap.rs.

(cherry picked from commit aa872b37bf4d42c691fe76e9cde65d1a311cb99b)
(cherry picked from commit f95548afff73fb7b3f29e7b8c04c0c50adaa4971)
2026-11-03 04:54:40 -08:00
Anees Iqbal 7e0d848a0c Order a small encoder part's resources on the stack at its end, and hold the end rows to 7 and 24
What: EncoderUses::finish_parts orders each part's resources by key through by_key. Up to 16
resources (ORDERED_INLINE) are sorted in an array on the stack, more in a vector of their own
as before. The summary is unchanged: resources in key order, each one's uses in the order
recorded. host_ab percall's HELD rows come down to the measured counts: end_compute and end_blit
8 -> 7, end_render 25 -> 24.

Why: a5a8ddf96f replaced the stable sort of a part's flattened uses, which allocates nothing for
a short slice, with a sort of the resources' keys, each once, through two vectors: the tracked
map collected, and the order. 1aaf95c79f dropped the first. The second was one allocation at
every encoder's end, the +1 c01e79adc1 raised end_compute and end_blit to 8 for with no cause
found. At 44d97aaa5e, before both, the traced end_compute made 7 allocations and none of them
in finish_parts' ordering. The keys are still sorted once each, so the cost a5a8ddf96f removed
stays removed.

Test: tests::tracker::a_summary_lists_its_uses_by_resource_each_in_recorded_order runs its
shape over 6 resources (ordered on the stack) and over 40 (past ORDERED_INLINE, in a vector),
four ranges each used in no order.

Verified:
- host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2), on 4f0a1043b1
  (gate/stack11) with this change and the gate made to print: end_compute 7, end_blit 7,
  end_render 24 allocations a call. stack11 itself measured 8, 8 and 25 in the same build
  setup. The draw rows stay at 0.0390625 and dispatch at 8.13.
- tests::tracker passes (65 of 65 with the heap test below it in the same run).
- cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings, plain and
  under --cfg m2v_gpu: clean.
No answer, announcement or submission changes, so RUNTIME_VERSION stays; the runtime sources'
pin moves with tracker.rs.

(cherry picked from commit 47c17ea4b3901b1287d4e739c7b545ea6708bf78)
(cherry picked from commit 8014946d93f038907b43a0715ef9c568839da9ab)
2026-11-03 04:54:40 -08:00
Anees Iqbal 3d282e9a8d Pin the runtime sources after passes count the commits they take in
(cherry picked from commit 35431da6e694fb6e70edf2e2f132b78654deb13d)
2026-11-03 04:25:32 -08:00
Anees Iqbal ce57c7dce4 Bump RUNTIME_VERSION to 1749: passes count the commits they take into the order
A run of an unchanged artifact and plan now also records WorkCounts::commits_taken_in, the commits
a pass took into the scheduler's order, whichever thread made it, added as the pass ends after its
submissions and groups. Nothing it submits or answers changes. 1749 is 1748 (shadow carries,
withheld holds) plus one.

(cherry picked from commit 968ab4aa38649203cf483b020e576441f32ccef6)
2026-11-03 04:25:32 -08:00
Anees Iqbal 25cb4367d8 Bless the API signatures for WorkCounts::commits_taken_in
scripts/api-signatures/signatures.py --bless on this tree: one signature
added, the new WorkCounts field. Nothing else moved.

(cherry picked from commit 9d121883145b5c63b7afce7561e0903375d88490)
(cherry picked from commit 6cdc6575b6435f44dac9cdc755bdc4e6d3b82035)
2026-11-03 04:25:31 -08:00
Anees Iqbal 706855acfe grouped_submissions: wait for the commits taken in, not for a sleep
taken_in read WorkCounts::scheduler_sleeps after the last commit returned
and waited for it to move. Where the scheduler's thread had taken the commit
in and gone to sleep before that read, nothing moved it again: since idle
sleeps are untimed, an idle thread sleeps until woken. The behind-running-
work scenario commits each command buffer onto an otherwise idle order, so
a_command_buffer_with_a_submission_handler_and_check_is_held_behind_
running_work and the_exact_completion_keeps_no_group_behind_running_work
hung there and failed after 60 s on a loaded M3 ("the scheduler's thread
never slept"). The sleep read raced the commit; the runtime did not.

A new count: WorkCounts::commits_taken_in. It counts the commits a pass
took into the scheduler's order (the scheduler thread's, a waiting
thread's or a committing thread's), each as its pass ends, after the
submissions and groups it made. It is released then, and acquired as the
counts are read. Passes take commits in hand-off order, so once it
reaches commits_handed_off read after a commit returned, a pass has taken
that commit in and ended. That holds whether the pass ran before the read
or after, and whatever the thread does next. taken_in now waits for that.
It keeps its contract: every command buffer committed before the call is
in the order, and the counts read after it hold what that pass submitted
and kept. No sleep is involved.

The conformance cost lists classify the count as submission work and as
racy: a pass can end after its command buffer completed and the case read
the counts. A runtime change: RUNTIME_VERSION and the pin are left to the
lane.

(cherry picked from commit 0a0a7c1ff805af54ef7c7a1be786b513ef0b7c14)
(cherry picked from commit f2ec35ad576b115ad53442eb9ad05cb3ae514c18)
2026-11-03 04:25:31 -08:00
Anees Iqbal 5553cb59bd Pin the runtime sources after shadow carries dropped where batches split and holds withheld behind waiting writers
(cherry picked from commit 01cd44dbdca5df118bf7e066b8a24c27d2f46482)
2026-11-03 04:25:31 -08:00
Anees Iqbal b564a9a26e Bump RUNTIME_VERSION to 1748: shadow carries dropped where batches split, and holds withheld behind waiting writers
A shadowed texture's carry across one command buffer's encoders now lasts while they stay in one
batch, dropped where its batches split (a wait, a host step, a resource state encoder, or a signal
pending for the next encoder) and never at another command buffer's encoder end; and a command
buffer that waits for an event or a semaphore and wrote logged host pages keeps every log of a
shadow its writes meet from taking or giving a hold until it completes
(WorkCounts::dirty_holds_withheld). Both change which copies a run of an unchanged artifact
submits. 1748 is the lane's 1747 (residency joined where read, sampler prunes) plus one.

(cherry picked from commit fe5d8c1b51dc29e5f9ff577e8f41be3b23b11f35)
2026-11-03 04:25:31 -08:00
Anees Iqbal 5c1b97e7e3 Keep a logged shadow from holding while a command buffer that waits and wrote its pages runs
What: a command buffer that waits for an event or a semaphore, and whose commands write logged
host pages (HostMemory::with_dirty_pages), now keeps its writes in the device's dirty shadows
(dirty_pages.rs, WaitingWrites) from its commit until it completes. While they are kept, no
log of a shadow they meet (the shadow's truth or the shadow) takes a hold or gives one. That
covers a log made after the commit too: a shadow's log is made at its first gated copy in.
Each hold left untaken is counted in the new WorkCounts::dirty_holds_withheld. A command buffer
whose writes went unnoted (nothing collected them as it encoded), or that wrote past WRITES,
counts as writing everything. Its completion lets the writes go, after it reports them again.
committed() now reports the host writes at its end (the order against the stamps is
unchanged), and the commit site passes `unnoted`.

Why: such a command buffer may run after work committed after it. Its writes reach the log at
its commit, before that later work's stamps. A later commit whose end leaves the shadow's image
holding the truth takes a hold as of its own stamp, and a copy in behind that hold then skips
pages the waiting writer fills after the image was copied. The first design kept the waiting
writer on each ShadowLog it met at the commit. It withheld nothing in the test below ("holds
withheld 0"), because the log did not exist yet at that commit: the first copy in came later.
So the writes are kept by the device, and each log asks them when it would hold.

Test: runtime_lane::cross_queue_shadows::
a_write_of_logged_pages_after_an_event_wait_reaches_a_copy_in_behind_a_later_hold, over one
anonymous guest page with a dirty log. Y (queue 2) waits for an event, fills row 3, then spins
(150 dispatches of about 10 ms). X (queue 1, committed after Y) reads the texture and signals
the event; its end holds the texture whole. Z (queue 1, after X) reads it. The test asserts
the copies in were gated, X's hold was withheld, X's read holds the initial bytes and Z's read
holds Y's fill.

Verified on the M3 Max (MoltenVK 1.4.2, macOS 27.0.1) under --cfg m2v_gpu:
- Without this change (the test alone, on the landing's first commit), the test failed: Z's
  read lacked the fill (32 bytes of row 3 held the old texels), the gated copies in reading
  [2 gated, 1 whole, 1 skipped, 512 bytes whole, 256 copied].
- With it, 93 of 93 passed: runtime_lane::cross_queue_shadows, parallel_encodes and
  device_copies, and the runtime's tests::shadow, batches, fresh_unwritten, dirty_pages and
  copied_log. This test read [2, 2, 0, 512, 512] and "holds withheld 2".
- cargo clippy -p metal2vulkan-runtime -p metal2vulkan-validation --all-targets --all-features
  -D warnings, plain and under --cfg m2v_gpu: clean.
- metal2vulkan's api_signatures test passes with the new field's row.

(cherry picked from commit 5ef157a072f943ddcd71bb315cd4c1cb03f6097e)
(cherry picked from commit be09b8f937d221213a31230917680f1c848c4d7d)
2026-11-03 04:25:30 -08:00
Anees Iqbal d7e2436acb Drop a shadowed texture's carry where the command buffer's batches split, never on another's end
What: a command buffer's ShadowCarry (an earlier encoder left the shadow's image holding the
truth, so a later one takes no copy in) now lasts while its encoders stay in one batch.
State::shadows_to_carry clears it where the encoder opening next starts another batch:
- the batches split since the last ended encoder, at a wait, a host step or a resource state
  encoder (State::carry_batches, set at end_encoder);
- or the current batch signals (Batches::signals_pending), so the next encoder starts the next.
ShadowCopies::touched and shadow::Touched are gone, with every field initialiser, Entry::met,
Carried::touched, ShadowCarry::queue and ShadowCarry::on. Another command buffer's encoder
ending in between, of this queue or another, drops nothing.

Why: the consumer's ruling. A later encoder that sees a CPU write made after its command
buffer's commit is a correctness bug on every device. On the GPU nothing runs between two
encoders of one batch but the command buffer's own commands. A queue's batches go in commit
order, and another queue's batch that conflicts with this one's uses of the texture runs
wholly before or after it: each copy in is a tracked write of the image. So the counted ends
dropped carries that held, and the later encoder then copied in at its own run, a CPU write made
after the commit among it. Another queue's work comes between only where the batches split.
There the carry used to survive a signal, and the encoder after it read the image as the
earlier encoder left it, missing another queue's write that ran in between.

shadow.rs's Copy in rule now records what Metal does with a CPU write made once the command
buffer's own signal was seen, measured by the new probe
metal2vulkan-conformance/probes/cpu_write_after_a_signal.m. On the M3 Max (macOS 27.0.1),
three runs of each case, every run alike:
- the read after the signal took the write, in the encoder after it (out2 64 of 64 NEW) and
  in a later dispatch of that encoder (64 of 64);
- with no signal, a write while the command buffer ran reached no later encoder (64 of 64 OLD);
- a write before the commit reached both reads.
The GPU does not see a CPU store to a word while a kernel runs. Metal ended a spin waiting for
one ("Caused GPU Hang Error"), and also one dispatch of about 1.5 s, so the probe and the tests
spin in 150 dispatches of about 10 ms each, the cap timed first.

Tests:
- tests::batches::a_signal_is_pending_until_the_encoder_after_it_starts_a_batch (new).
- tests::shadow::a_carried_surface_is_dropped_by_anything_that_lets_another_writer_in: another
  command buffer's encoder ending between, or while the encoder was open, now keeps the carry.
  only_another_queue_s_encoder_drops_a_carried_surface is gone with Touched.
- runtime_lane::cross_queue_shadows (new), on the device the cfg selects:
  - a_cpu_write_while_a_command_buffer_runs_reaches_none_of_its_encoders: X of queue 1 reads,
    spins and reads; Y of queue 2 reads between X's reads; the CPU writes while X spins (X
    Scheduled). Both of X's reads hold the bytes as of the commit, the second through the
    carry (64 texels carried).
  - an_encoder_after_a_signal_reads_what_another_queue_wrote_after_it: Y of queue 2 waits for
    an event and fills a row; X of queue 1 reads, signals, reads. The second read holds the fill.
  - a_cpu_write_once_a_signal_was_seen_reaches_the_reads_after_it: the probe's two signal
    shapes through the runtime. The read after the signal holds the CPU's write.

Verified on the M3 Max (MoltenVK 1.4.2) under --cfg m2v_gpu, on f7abac8bbb plus the per-draw
log fix: those three, parallel_encodes, and the runtime's tests::shadow, tests::batches and
tests::fresh_unwritten pass. In that run the waiting-writer test that follows failed, as
expected without its fix. With this commit's runtime changes left out (95f22fb742, the same
validation tests), all three device tests fail on the M3 Max:
- the CPU-write test's second read held the write (0 texels carried);
- the signal test's second read missed the fill;
- the signal-seen test's read after the signal missed the write.
The checks at this landing's tip are in its last commit.

(cherry picked from commit 4cf86795b2430feb28062aa467333249dc62310e)
(cherry picked from commit 4b8b5eda8025d7abaaaacc929eacdfd1f1bcc968)
2026-11-03 04:25:30 -08:00
Anees Iqbal f9f498f9a5 Pin the runtime sources after ExtendedRange's public read and write models and the rgb10a2 sRGB bound
(cherry picked from commit a39b99678f7a121c5b81c105c885479c067f1eb2)
2026-11-03 04:10:31 -08:00
Anees Iqbal d8d76438cd Hold the extended-range lanes to DevicePackConversion's bound, against Metal's answers
The eleven extended-range and padded lane tests compared the device's
texels, reads and samples digest for digest with Metal's. A shader's
conversion of such a texel is the device's own (no Vulkan format holds
them), which PrecisionNote::DevicePackConversion records and the
runtime announces. Its documented bound allows a code within one of
Metal's (two for R10Unorm_X6_sRGB's and RGB10A2Unorm_sRGB's colour below
0.0031308), a linear read within one f32 ulp, an sRGB twin's decoded
value within half a 2^-13 step of Metal's table (1.64 steps for those
two formats) beyond the Pow's bound, a half within one half ulp, and a
NaN's code the device's. So the digests did not match on the M3 Max
(MoltenVK) or the RTX 5080, and these tests stayed red on both.

Each test now checks every value within that bound of Metal's own
answer, and each bit Metal does not read equal to Metal's. It asserts
that the note was announced wherever a value moved, and it still pins
Metal's answer by its digest:
- xr_codes (new): the shared helpers. It splits a texel into codes and
  the bits Metal does not read, holds codes, reads, sRGB steps and halves
  to the bound, gives Metal's half rounding (ties away from zero), and
  loads Metal's M3 Max macOS 27.0.1 answer from a conformance recording.
  as_metal_reads replaces the device's lanes that are within the bound
  by Metal's values, so a digest of the rest can still be compared.
- extended_range_targets: draws compared code by code, two-plane reads
  through the nearest code of Metal's read; clears' reads through the
  cleared codes. A CPU test holds the models to Metal's digests.
- extended_range_planes: joined and split texels within a code.
- extended_range_blends: one-zero blends against a model of Metal's
  blend, which clamps the source to its range, alpha to [0, 1] and a NaN
  to the low end. A CPU test holds the model to Metal's digests.
- padded_loads: every drawn word within a code of a model of Metal's
  store (a float output rounded to half toward zero, then the write
  code), held to Metal's digests by a CPU test.
- rgb10a2_srgb: reads, writes, nearest samples and stores compared with
  the rgb10a2-srgb-* recordings, whose digests are asserted equal to the
  test's constants. Linear samples run and are counted, their blend
  being the unbounded BicubicFilterArithmetic, which is asserted to be
  announced.
- two_plane_samples: nearest cases against the xr-two-plane-samples-*
  recordings, a half case against the float recording.
- extended_range_two_planes: plane reads and in-view buffer words
  within the bound, through as_metal_reads.
No note set changes. Test code only; no version bump.

Verified on the Apple M3 Max (MoltenVK 1.4.2, macOS 27.0.1): every test
in the seven files passes (34 of 34), including the eleven that were
red. In the run before the bound was corrected, both rgb10a2_srgb tests
failed at exactly three words each, the shape the bound now states.
Clippy (all targets, all features, --cfg m2v_gpu) is clean.

(cherry picked from commit f097486e7a84a116c2c119114db4b665eb045600)
(cherry picked from commit 4c972dab0c58ef908b7ac6c826afb8a5e07f1732)
2026-11-03 04:10:31 -08:00
Anees Iqbal aa9b38e6fd State the padded sRGB twins' code and decode bounds as measured
DevicePackConversion's documented bound for the extended-range and
padded conversions said "a code within one" of Metal's. For
R10Unorm_X6_sRGB and RGB10A2Unorm_sRGB that is wrong. Metal's write of
these formats rounds the value clamped to [0, 1] to 2^-13 (nearest even)
and then looks it up in its encode table (R10X6_SRGB_ENCODE_FIRST). The
device writes the MSL transfer by its own maths, times 1023, RoundEven.
In the transfer's linear segment, one 2^-13 step spans 1.6 codes, so the
two can land two codes apart.

Measured: for each 2^-13 step over [0, 1], the f32s at and next to both
edges, where Metal's code is constant within a step and the device's
code rises with the value. The device's code (exact transfer) lies at
most two from Metal's table. It reaches two only below 0.0031308: at
1.5/8192, just above 6.5/8192, and at 24.5/8192. Everywhere else it is
within one, beyond the Pow's bound. Metal's recorded writes and stores
of RGB10A2Unorm_sRGB on the M3 Max under macOS 27.0.1
(rgb10a2-srgb-writes, -stores-f, -stores-h) show exactly that: three
words each, at k/16384 for k = 3 and 49, and at the 1.5/8192 special.

Metal's decode of RGB10A2Unorm_sRGB's colour (the rgb10a2-srgb-reads
recording, every code) lies up to 1.637 steps of 2^-13 from the exact
transfer (code 952: Metal 0.84912109, exact 0.84932096). That is the
1.64 the docs gave for R10Unorm_X6_sRGB only.

So artifact.rs's DevicePackConversion, the FAST-PATHS air.pack row and
API.md's catalogue entry now give, for those two formats only: a colour
code within two below 0.0031308, and a decoded colour within 1.64
steps. Doc text only: the device's conversion is unchanged (rule 1),
and so is behaviour. No version bump.

(cherry picked from commit 8bfaab43bd6c6368c41d58caa7e9c91fe64820d5)
(cherry picked from commit e728f0fa394c46c528d2f99df89a33751f5691d7)
2026-11-03 04:10:31 -08:00
Anees Iqbal 24d2ada6af Answer Metal's extended-range read and write models publicly
The validation lanes that hold extended-range texels to Metal compare the
device's conversion with Metal's answer within PrecisionNote::DevicePackConversion's
bound (a code within one of Metal's, a read within its bound of Metal's).
That needs Metal's code-to-value mapping and its write's rounding, which the
runtime's clear model already holds as the private `code_value` and `code`.

ExtendedRange gains two thin public wrappers:
- `read_value(code, alpha) -> Option<f32>`: Metal's float read of a code of
  an extended-range form, or None for the padded and bfloat forms and a code
  past 1023.
- `write_code(v, alpha) -> Option<u32>`: Metal's kernel write's code of a
  float of an extended-range or padded form, or None for the bfloat forms.
Each doc comment states Metal's mapping and rounding, and says that a
shader's conversion is the device's, bounded against this one.
api_signatures.tsv gains the two method rows. The api_surface table lists
items, not methods, and ExtendedRange's row is unchanged.

No behaviour changes and no version bump. The pin needs recomputing, since
metal/format/mod.rs is a hashed translator file.

Verified: cargo nextest run -p metal2vulkan (api_signatures, api_surface and
metal::format tests) 64 passed; clippy -D warnings plain and --cfg m2v_gpu;
rustdoc -D warnings for metal2vulkan.

(cherry picked from commit 753e6ac604e2f4be8150d787e50574ee880798a6)
(cherry picked from commit 99e4bd12fd251ee97615d0ab535980089e5e0a71)
2026-11-03 04:10:31 -08:00
Anees Iqbal e71efbe0e9 Pin the runtime sources after the joined residency, host import counts, spec_key lists and sampler prunes
(cherry picked from commit 4f0a1043b16311ccd498714627a2650ded1f2ece)
2026-11-03 03:36:43 -08:00
Anees Iqbal 1926a601ac Bump RUNTIME_VERSION to 1747: residency joined where read, host imports counted in place, sampler prunes amortised
A run of an unchanged artifact and plan now records and holds differently:

- A command buffer joins its ended encoders' resources into its residency where its work first
  reads it, not as each encoder ends, and counts the joins in the new
  WorkCounts::resident_resources_joined; its encoders' shadowed textures are found where the
  next encoder opens.
- A commit counts its buffers' host imports without making a list for the first sixteen
  (Buffer::distinct_host_imports).
- The translator's spec_key makes its two lists once each, at the first constant given a value,
  and none for a key of no value.
- A sampler state's creation prunes the device's map of live states only where it has grown to
  twice what the last prune left, so entries of states gone stay longer.

The Vulkan commands, barriers, notices and refusals keep their meaning at the same calls. 1747 is
the lane's 1746 (noted textures' pattern reads logged without an allocation per draw) plus one;
it stands for the compute bind branch's 1744.

(cherry picked from commit 6b4606e2e5d46f0aca873bf9f10f015f64c5f758)
2026-11-03 03:36:43 -08:00
Anees Iqbal e94d068b3b State the queue sharing row's measured rates over the 5080's spread
What: docs/FAST-PATHS.md's queue sharing row now gives each shape's measured range with its
run count, in place of the first three-run set's.

Why: two more sets on the RTX 5080 Laptop GPU (NVIDIA 615.71.09, release, one-draw command
buffers, each thread its own queue) widened the ranges:
- 2 threads with 3 in flight: Adaptive 27.0k to 46.5k a second in 13 runs after a hold's first.
  It fell within one hold, from 42.5k to 27.0k, while PerQueue stayed at 25.6k to 27.5k. Two
  more runs gave 15.4k and 17.7k; in both, one of the two queues was marked long as it began
  (gone long 2 or more, against 1 in every fast run). PerQueue: 25.2k to 27.7k in 14.
- 2 threads with 1 in flight: 16.9k to 20.7k against 10.1k to 11.5k (5 each).
- One thread over 16 queues in turn: 21.7k to 43.3k against 10.2k to 11.1k. Over 2,048:
  20.0k to 39.2k against 10.2k to 11.2k (4 each).
The 8-thread shapes keep their three-run ranges. One third of one hold, where both policies
fell to 8.1k to 13.0k, is left out. Under PerQueue the pair of VkQueues made no difference:
2 x 3 with the second queue 1, 7 or 13 places after the first ran 25.6k to 27.5k.

Verified: tests::fast_paths (19 passed).
(cherry picked from commit adb362078504cca24358e8d9c331eb1b831a2b57)
(cherry picked from commit 27999318cbb31bc8a46f24a28c40a6b80c7e2f4d)
2026-11-03 03:36:43 -08:00
Anees Iqbal ec6fbca8f8 LiveSamplers' doc: the map's bound is twice the states live at its last prune
The previous commit's doc said the map holds at most about twice the live states. A prune sets
the next bound from the states live then, so after states are dropped the map can hold up to
twice that earlier count (or PRUNE_FROM entries) until its next prune: each a Weak of a state
gone, holding its allocation alone. The doc now says so. No code changes.

(cherry picked from commit 5e813b916ec5a5ca6b10714aced20d164f562aab)
(cherry picked from commit cb79bc65d748f7877ffa57a950ebd963b9fe5cd3)
2026-11-03 03:36:43 -08:00
Anees Iqbal 26ead7a1b5 A sampler state's creation prunes the live states' map at a doubling bound, not every time
Each new state's creation ran live.retain over the device's whole map of live sampler states,
so a creation cost time linear in the states live (reims measured about 1.1 ns a live state on
an RTX 5080). The map is now sampler::LiveSamplers: a creation prunes the entries of the states
gone only where the map has grown to twice what the last prune left, and at least to 64 entries
(PRUNE_FROM), so each creation's share of the prunes is a few entries however many states live,
and the map holds at most about twice the live states, plus 64.

An equal request still gets the live state: the lookup upgrades the key's entry, so an entry
whose state is gone answers none, and the creation's insert replaces it. A prune lets go of
Weak entries alone, so no state is dropped under the map's lock, as before. The same Vulkan
calls, notices and refusals at the same call; only when the map lets go of dead entries moved.

Release numbers, M3 Max (reims's repro: N states live, a create of another descriptor and then
the oldest dropped, mean of 2000 creates, µs; two interleaved runs each):

  live      before          after
  1         0.46   0.35     0.44   0.72
  64        0.58   0.58     0.43   0.90
  1000      1.97   2.01     0.56   0.54
  10000    16.75  16.93     0.48   0.49

Check that fails without it: tests/sampler_prunes.rs makes 4096 states and keeps them live; their
creations' prunes must look at fewer than 8192 entries. With a prune at every creation they look
at 8,386,560 and the test fails. It also checks an equal request gets the live state, and that
4096 more creations, each state dropped at once, leave the map at 65 entries or fewer.

Verified: the runtime GPU suite on the M3 (1528 passed, 3 skipped); cargo clippy -p
metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu.

(cherry picked from commit 61e1796535c6d07f384db2e4da7d31e8e4c2d5fb)
(cherry picked from commit bf6578fd927e73f7d17ddc4b1a558dc347ff9cc6)
2026-11-03 03:36:43 -08:00
Anees Iqbal 4a5e49684c joined_residency test: compare against a slice of the texture, not a cloned array
cargo clippy --cfg m2v_gpu (cloned_ref_to_slice_refs) refused the shadowed-textures test's first
assert, `[first.clone()]`, which the previous commit added after its clippy run: the assert now
compares against std::slice::from_ref(&first). Nothing else changes.

Verified: cargo clippy -p metal2vulkan-runtime --all-targets --all-features -D warnings with
--cfg m2v_gpu and without.

(cherry picked from commit 8e7a8f43523ecabb06c1d95e489e960d7b36ed12)
(cherry picked from commit 942c58d90c028f36a0508bf3d106400fe16cacdc)
2026-11-03 03:36:42 -08:00
Anees Iqbal b85685ae41 host_ab percall: re-bless the gate's stale rows to what the runtime does now
The percall gate (HELD) held calls to counts the runtime no longer makes, so it failed on
every run for reasons that were not regressions, and a real one hid among them. Each row now
holds what one percall round on the M3 measured (gate/stack6 with this landing):

- draw_strip, draw_triangles, draw_indexed: the draw is recorded at the call (rt_draws_at_call
  1, rt_recorded_cmd_draw_indexed_at_call 1), not at the commit.
- end_render: its render pass is begun at the call (rt_render_passes_begun_at_call 1).
- end_compute, end_blit: 8 allocations, held to 8 where they were 7.
- dispatch: recorded at the call (rt_dispatches_at_call 1); 8.13 allocations, held to 8.2
  where it was 19.
- heap_texture_256: 20.25 allocations, held to 20.25.
- buffer_texture_256: one image and one binding at the call, no memory of its own and no view
  (held to 0 images and 1 view before).
- use_resources_read_256: 16 allocations, held to 16 where it was 277.

Two rows keep their bounds and still fail: the draws' 1.055 allocations a draw (held to 0.2;
0.041 before this base) and end_render's 27 (held to 25). Neither has a cause found here, so
neither is blessed.

Verified: host_ab --only percall --rounds 1 on the M3, built with this table (its gate made to
print rather than fail): the gate reports those four rows alone, and every row that holds a
call to some work names a count its group moved.

(cherry picked from commit c01e79adc1944a6f86ce63d13163c1b7f612b429)
(cherry picked from commit 48e3b1e102411b6877258c1c91c142d5f014b0ca)
2026-11-03 03:36:42 -08:00
Anees Iqbal 2f9a3a3782 A command buffer joins its ended encoders' resources where its work reads them, not as each ends
Each compute or render encoder's end joined everything it made resident into its command buffer's
residency (Residency::join_encoder: a clone and a hash insert per resource), and each later
encoder's open walked every texture of that union for the shadowed ones. Most command buffers'
work never reads the union: only the commit's and host steps' recordings against every encoder's
resources (CommandBuffer::residency), the resident set of a GPU-alone recording, a texture made in
a heap since, and an encoder encoded again do.

- command_buffer/mod.rs: an encoder's end joins its heaps at once (join_encoder_heaps) and leaves
  its resources in its record; State::joined_residency joins the records not joined yet, in the
  order they ended, at the first read (CommandBuffer::residency, make_resident, fresh_ranges, a
  splice of an encoder encoded again, before the textures its heaps made since). The union holds
  what the eager join made, in the same token order: State::sync_heaps joins the records first
  where a heap made textures, as each encoder's join came before them. The commit's sync of its
  heaps and an encoder's open (State::inherited) read no resource list unless one did.
- residency.rs: each residency lists its shadowed textures' tokens (shadowed), found where an
  open first asks for them (find_shadowed) and each texture looked at once, so making a texture
  resident reads nothing of it, and an open starts with the shadowed textures of the joined union
  and of the records not joined yet, in the order they were made resident, with the joined usage
  and stages, at the cost of their count. The join's resource and heap halves and sync_heaps's
  finding and joining halves are split out.
- WorkCounts::resident_resources_joined counts the joins (api_signatures.tsv blessed: one field).

The records hold what their encoders made resident until the command buffer completes, as before,
and the union goes with them, so nothing lives longer or shorter. The same resources, usages,
stages, tokens, shadows and heaps at every read.

Release numbers, M3 Max (host_ab --only encode, runtime side, median of 3 rounds, µs; before is
this landing without this commit, after with it, two or three interleaved runs each):

                                    before (3 runs)          after (3 runs)
  resident_0 end_call             14.1   11.6   14.9      11.3   14.4   15.1
  resident_256 end_call           34.7   25.6   37.3      11.1   13.3   15.4
  resident_4096 end_call         230.3  152.3  244.3      11.4   14.1   15.5
  resident_moving_4096 end_call  170.5  154.3  248.6      10.7   11.8   15.2
  resident_textures_256 end_call  41.5   29.5   43.1      11.2   13.0   15.3
  resident_textures_4096 end_call 287.8 193.5  294.6      11.5   12.9   15.8
  resident_4096 use_call         346.1  379.3  335.1     326.1  297.3  342.0
  resident_textures_256 use_call  38.0   37.0   36.9      35.1   35.1   37.2
  resident_textures_4096 use_call 450.3 481.0  430.3     409.5  419.6  438.3
  resident_4096 encode/dispatch    1.73   1.32   1.62      1.74   1.65   1.65
  resident_textures_4096 encode    2.20   1.78   1.93      1.93   1.99   1.97
  static encode/dispatch           1.75   1.74   1.61      1.62   1.64   1.60

The end call no longer grows with what the encoder made resident, and the useResources call does
not take the cost instead. A first form of this change looked for a texture's shadow as it was
made resident; that put about 80 µs into resident_textures_4096's use_call (260 to 317 against
188 to 200 before, four interleaved runs each), which is why the shadowed textures are found
where an open first asks for them. Percall's counts are the same with and without this commit;
the calls workload's end_compute allocates 5 a call where it allocated 8.5.

Checks that fail without it, in tests/joined_residency.rs:
- ended_encoders_join_their_command_buffer_s_residency_where_it_is_read: with the second
  encoder's open joining the records (the eager join's timing), its first assert fails (16 joined
  where 0).
- shadowed_textures_made_resident_reach_the_next_encoders_in_order: with find_shadowed looking
  at none, its first assert fails (no shadowed texture inherited).

Verified: the runtime GPU suite on the M3 (1527 passed, 3 skipped); cargo clippy -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features -D warnings, with and without --cfg m2v_gpu;
scripts/api-signatures/signatures.py --check.

(cherry picked from commit 18553c295c98dabe4c74fc226be6b45955c0c13a)
(cherry picked from commit ae56cfdfdd2e4cb1e9b189c7ce303d680fbc2b7f)
2026-11-03 03:36:42 -08:00
Anees Iqbal c6ff058263 host_ab encode: time each dispatch_resident variant's endEncoding call
The dispatch_resident variants timed the useResources call and the dispatches after it, but not
the encoder's end, where a command buffer joined everything the encoder made resident into its
residency: a cost that grows with the resident count and fell outside every row. Each variant
now emits dispatch_resident_<name>_end_call, the end_compute call alone (before the commit), on
Metal and on the runtime alike.

Verified: host_ab --only encode on the M3 prints the new rows for every variant.
(cherry picked from commit 87d8341d269d126b1edac5d3935485f0997b47be)
(cherry picked from commit 400bf537e6efaaa15cdb1e6a8fcb1c7836de53f3)
2026-11-03 03:36:42 -08:00
Anees Iqbal 1d984c190e spec_key makes no list for a key of no value
The reserve that made spec_key's two lists at their whole size at once ran before any constant was
given a value, so a key of none, which made no list before, made two empty ones of the layout's
size. The reserve now runs at the first constant given a value, for it and every later one; a key
of no value allocates nothing, and a key of values still makes each list once.

Check that fails without it: bind::plan::compute::tests::specialization_lists_are_made_whole_at_once
now also asserts a key of no value has no capacity in either list.

Verified: with the reserve at the top the new assert fails (capacity (5, 17) for a key of no
value); with this, the bind::plan::compute tests pass.

(cherry picked from commit a52c75a9c1653ff26d98a20dfd748f85a1a752db)
(cherry picked from commit ae8b8f95515085c586181f472534c0649c85d685)
2026-11-03 03:36:41 -08:00
Anees Iqbal 917fa5adf2 host_ab percall: the no-copy commit group's buffers live only in its windows
commit_no_copy_dispatch kept its two buffers over host pages alive in Objects for the whole run,
so every other group's calls ran beside two live buffers over host pages and counted
differently: use_resources_read_256 24 allocations a call where it makes 16 (16 before the group
was added, 24 with it, 16 again with this; one percall round each on the M3). The group now
makes its two buffers in each window's preparation, over the first two megabytes of the no-copy
pages (Objects::pages, which buffer_no_copy_1m's windows use too), and lets them go with its
drain. end_render's 27 allocations a call (25 before) is not this group's: it stays 27 with
this change.

(cherry picked from commit e2671b315330440b360abcd7a797ab414861068e)
(cherry picked from commit fac1d2aeb20253c7593ce14a053d3a5c4506efce)
2026-11-03 03:36:41 -08:00
Anees Iqbal 11edfb6daf A commit counts its buffers' host imports without making a list for the first sixteen
Buffer::distinct_host_imports, which every commit calls for WorkCounts::host_imports_used,
collected the import of each used buffer over host pages into a Vec, sorted it and removed the
repeats. It now tells the first 16 distinct imports apart in a stack array (FEW_IMPORTS), and
lists and sorts them only past that. The count is the same.

The audit proposed a per-import epoch stamp instead. The call runs outside any device-wide lock
(command_buffer/mod.rs, in the commit), so two command buffers committed at once on two threads
would share the stamps and miscount each other's imports; the stack array is exact under any
concurrency and makes no allocation in the common case.

The other half of the audit's commit-cost finding, the scheduler's wake broadcast, is the owner's
question (spinning, or the committing thread submitting itself) and is not changed here.

Checks:
- host_ab percall now holds commit_one_dispatch to 4 allocations and commit_no_copy_dispatch (its
  two buffers over host pages) to 9. Before this change the latter makes 10, so the gate fails
  without it.
- tests::host_import_counts::a_commit_counts_each_import_once_past_the_few_it_tells_apart_in_place
  checks the count at 1, 15, 16, 17 and 18 imports, each buffer twice and one import holding two
  buffers, on both sides of the fallback. Verified on MoltenVK with the other host-import tests (6
  passed).

Release, M3 Max, MoltenVK 1.4.2, host_ab percall, before (9f56956ef3) and after interleaved twice:

| row | before | after |
|---|---:|---:|
| commit_no_copy_dispatch allocs/call (both rounds) | 10 | 9 |
| commit_one_dispatch allocs/call (both rounds) | 4 | 4 |
| commit_no_copy_dispatch self, ns/call (round 1, round 2) | 2414, 1477 | 2354, 1495 |

The times ran under a load average of 30-60 from other builds and moved more between rounds than
between builds.

(cherry picked from commit 7b1b75bdddfafd3cb3dd835d4b5f87ab2db2f7a0)
(cherry picked from commit e3b963bdc0e5c41766b6a42892860a4eec7c005b)
2026-11-03 03:36:41 -08:00
Anees Iqbal 6b13f54c5e host_ab percall: time a commit whose dispatch binds two no-copy buffers
commit_no_copy_dispatch is commit_one_dispatch with the dispatch's two buffers made over host
pages of their own (Objects::no_copy), so the commit counts the host imports its used buffers lie
in (WorkCounts::host_imports_used), which commit_one_dispatch's buffers, the runtime's own, never
reach. The group is declared in TIMED under CommandBuffer::commit; the API cost coverage is
unchanged (commit was timed already).

(cherry picked from commit 506eccf91672f23d8f669b7a519e5449735124a6)
(cherry picked from commit cf0e5cf9513d17c21e539e0ed9354fc780066470)
2026-11-03 03:36:41 -08:00
Anees Iqbal 535c931153 The translator's spec_key makes its two lists at their whole size at once
spec_key, which each instantiated dispatch region and each plan calls, pushed its entries and its
data one constant at a time, so both lists grew by reallocation (the audit measured about 35 of
88 instantiate_dispatch samples there). It now reserves room for every constant of the layout:
one entry each, and each constant's low size bytes (at most 8). The same keys.

Check that fails without it: bind::plan::compute::tests::specialization_lists_are_made_whole_at_once
(five constants, each given a value: each list's capacity equals its length; without the reserve
the entries hold 8 and the data 32).

Release, M3 Max, MoltenVK 1.4.2, host_ab calls, before (d16266d2af) and after interleaved twice,
allocations per call (deterministic; the same both rounds):

| row | before | after |
|---|---:|---:|
| many_dispatch | 41 | 38 |
| many_dispatch_resident | 44 | 41 |
| wide_dispatch | 27.516 | 24.516 |
| wide_dispatch_resident | 27.406 | 24.406 |

The times of those rounds ran under a load average of 50-60 from other builds on the host and
moved by more between rounds than between builds (dispatch_offsets encode 4.96/4.43/3.36 us
before against 4.18/2.85/3.04 after), so they show no measured change either way.

(cherry picked from commit 0f89c223969badc3cec18909810ff26032c9c577)
(cherry picked from commit 75e22ef43b50e68fec19c2a40da02ead2bd33230)
2026-11-03 03:36:41 -08:00
Anees Iqbal 0c696948bc Pin the runtime sources after noted textures' pattern reads logged without an allocation per draw
(cherry picked from commit 94431cc652aff19bee45088740ef01dc9b97b88a)
2026-11-03 03:23:03 -08:00
Anees Iqbal ce8ec6c9c1 Bump RUNTIME_VERSION to 1746: noted textures' pattern reads logged once each, with no allocation per draw
A run of an unchanged artifact and plan records the same first-use answers for noted textures,
taken at the commit in commit order as before, but a draw logs an event only for a texture noted
now that the record weighs (a write for any, a read for any but a signed-depth texture, a depth
load for a signed-depth one), skips a repeat of its texture's last entry, and builds no temporary
list: host_ab percall's draw rows are back to 0.039 allocations per draw (from 1.055) and
end_render to 25 per call. 1746 is the lane's 1745 (VkQueue sharing) plus one.

(cherry picked from commit 2b83f5fe6084569b6a7f2d988d629b003d57d230)
2026-11-03 03:23:03 -08:00
Anees Iqbal 549609b26f device-color-conversion: state the measured unorm rounding at a tie
The note's doc said every Vulkan driver measured but MoltenVK rounds the
f32 product with ties to even and that Metal "rounds a half toward zero".
Neither fits an exact tie in an 8-bit unorm attachment: Metal stores 0x80
for 0.5 (127.5), and the RTX 5080 stores 0x7f, which ties to even would
not give. "A half" meant a half-float channel, which read as 0.5.

Measured over every 8-bit code's exact value and every tie with two f32
steps either side, BGRA8Unorm and RGBA8Unorm:
- Apple M3 Max, macOS 27.0.1, plain Metal (a probe of our own): all 1531
  inputs store the exact product rounded to nearest, the tie up; 128 of
  them differ from the f32 product rounded with ties to even. 0.5 -> 0x80,
  f32(1.5/255) -> 2, f32(2.5/255) -> 3.
- RTX 5080 Laptop GPU, NVIDIA 615.71.09, through the runtime (the
  color_writes lane's pipeline, plain draw and an indirect command
  buffer's draw of the same state): plain and ICB identical in every
  channel; every input on a tie or up to two f32 steps above one stores
  the lower code (0x7f, 1, 2 for the three above), every other input
  Metal's code; 638 of 1531 inputs differ from Metal.

The doc now says so (artifact.rs, the color_writes module, API.md's
catalogue entry), names the half-float channel plainly, and keeps the
ties-to-even claim for ANV, RADV and lavapipe only, as earlier
measured; the RTX 5080 is no longer among them.

The fragment stage records DeviceColorConversion on the 5080 for that
pipeline, plain and ICB alike (verified: both stages' notes printed, and
with device-color-conversion asked at every occurrence the plain draw and
the ICB's replayed draw each announced it once).

Docs and comments only.

(cherry picked from commit 5021f1c4ba7f29a6dc54f76f4d12402795af7162)
(cherry picked from commit e21d7c945b383ddfbfe54a8d82fc89342e6f7d13)
2026-11-03 03:23:03 -08:00
Anees Iqbal e2f928c57a Log only noted textures' pattern reads and writes, once each, with no allocation per draw
What: FreshLog::push, which took a Vec of events a command built for every image it read or
wrote while any noted texture was live, is replaced by FreshLog::add, which logs one event at a
time and only where the record weighs it. That means a write of a noted texture, a read of a
noted one other than a SignedDepth one, and a pass's depth load of a SignedDepth one. It also
skips an event equal to its texture's last entry within the last 8 (REPEATS). observe_reads,
begin_pass, loads_signed_depth, cleared, resolved and wrote build no temporary Vec. The commit
takes the log with mem::take of the command buffer's own Vec of events.

Why: since the pattern reads moved to the commit (48ec97832d), every draw that read any image
while a noted texture was live allocated the events' Vec. That is 1.055 allocations a draw on
host_ab's percall gate, held to 0.2 (draw_strip, draw_triangles, draw_indexed). The commit's
answer does not change:
- A texture not noted now is never noted again, since its entry is made with its image and
  never after.
- An entry's kind never changes.
- A read, write or load that repeats its texture's last entry, with nothing of that texture
  between, finds the record as the first one left it.
While a texture is noted, a draw takes the record's lock once for each image it reads, as it
did before the log.

Verified: host_ab --only percall --rounds 1, release, Apple M3 Max (MoltenVK 1.4.2). The draw
rows run 512 draws in one command buffer and one encoder per window. Allocations a draw on the
calling thread:
- d3e66f9415, before the log: 0.0390625 (20 a window).
- f7abac8bbb, development's stack6 without this fix: 1.0546875 (540 a window), which fails the
  gate.
- f7abac8bbb with this fix: 0.0390625 (20 a window).
The fix also restores end_render's allocations a call: 25 before the log, 27 without the fix,
25 with it. So the log adds no allocation to these windows. Every other gate row the run
reports failing fails the same way at d3e66f9415. tests::fresh_unwritten passes (8/8, --cfg
m2v_gpu, the M3 Max). clippy -D warnings is clean for the runtime crate, all targets and
features, plain and --cfg m2v_gpu. Measured on f7abac8bbb; this commit is the same diff on
development (0e1d6be65a), where neither file changed since.

(cherry picked from commit 3af7afc8089cba929d64c7277a726730e918befd)
(cherry picked from commit c9d58a50f2a7764456c6314736765ac5a3d15dea)
2026-11-03 03:23:03 -08:00