Files
metal2vulkan/docs
Anees Iqbal cc6b083fc2 Let what every write route of a command buffer may write reach every buffer it made resident for writing
What: what an indirect command buffer's records may hold (WrittenCommands, command_writes) took a
writer's writes only from the encoder that made the buffer resident for writing (Writers: the
state set then, each set after, and that encoder's executions). The routes that mark the buffer
(write_routes.rs) were already the command buffer's. Routes now keeps what all of its routes may
write (states set in any encoder, before the residency or after it, and what executed buffers'
records may name) and adds it to every buffer made resident for writing, at the call that brings
either; an encoder opens with what the ended ones met. For two encoders open together (a parallel
render encoder's) the commit adds what each did not see of the other, and the followers that
sets off are marked outside the command buffer's lock, as the commit's marks are. Writers is
gone: Routes holds a superset of what it held.

Why: Metal runs what a kernel wrote with the buffer resident for writing in any encoder of the
command buffer, before the kernel's or after it (the probe icb_routed_writes.m, M3 Max, macOS
27.0.1). The marks matched that; the summary did not, and an execution of a buffer that inherits
the encoder's state decides on the summary whether the GPU alone runs it, as draws of the one
primitive type it allows. With the residency in another encoder than the kernel's, the GPU alone
ran the kernel's point as a draw of the CPU's triangles, which drew nothing (the previous commit's
lane). The bug is older than the write routes: the summary was per encoder before them too.

What it moves: an execution of a buffer whose command buffer sets, in another encoder than the
one that made the buffer resident, a state that may write what the GPU-alone forms rule out: a
render execution takes the host step where that state may write more than draws of one primitive
type, buffers, resets and cleared barriers; a compute execution in a concurrent encoder orders its
commands where it may set a barrier, and a checked one calls its check where the records may name
a state that may encode. The lanes that made a buffer writable with a state set in an encoder of
its own (indirect_host_steps::encoding_state_set: icb_replay_encode's, which may set pipelines,
dispatch, set threadgroup lengths and barriers) showed it: with it, 6 of the 480 tests of the 40
modules changed (render_merged_executions' GPU forms into a shadowed target took the host step,
6 executions; five dispatch_executions tests saw barriers, check calls and a host step), all
others as before, resident_draws among them (its writer and residency share an encoder: no host
step on its write path, its chunks kept). Those lanes are about the GPU-written path, not about
what the state writes, so the lever now sets icb_reset_encode's state (resets alone, which no
GPU-alone form rules out).

Docs: written_commands.rs and write_routes.rs module docs, IndirectCommandBuffer::command_writes,
render/executions/gpu.rs, the runtime README and docs/API.md section 10.

How verified (debug, --cfg m2v_gpu, M3 Max under MoltenVK): runtime_lane::write_routes passes
(it failed before this commit: After and Before drew no point); the 39 ICB lane modules and
write_routes, 480 tests, pass with the reset lever; the runtime's
tests::write_routes_device::a_route_reaches_every_buffer_its_command_buffer_made_writable (new:
a later encoder's state, one set before the residency, and a parallel encoder's at the commit)
and tests::written_commands pass; clippy -D warnings with --cfg m2v_gpu is clean.

(cherry picked from commit 7d13a4dee21162a972b40fd9868e3e2f9112a677)
(cherry picked from commit 13b9646e48b767defdd189bf156a2a9130b3b857)
2026-11-04 18:50:27 -08:00
..