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)
This commit is contained in:
1 parent
e924d293c5
commit
cc6b083fc2
15 files changed
+166
-124
No files matched your search
+9
-4
@@ -3803,10 +3803,15 @@ each item named states the rule in full.
|
||||
it. From then on an execution runs the records as they stand once the work before
|
||||
it completed. A buffer made resident for writing alongside functions that call no such operation
|
||||
stays unmarked, and its executions run the CPU's records as a buffer made resident for reading
|
||||
does (`WorkCounts::indirect_write_residencies_unmarked` counts each such commit's buffers). A
|
||||
buffer no encoder of the command buffer made resident for writing is outside Metal's contract for
|
||||
a function's write: its executions run the CPU's records, where Metal on an M3 Max ran a compute
|
||||
execution's commands as the kernel wrote them (and a render execution's as the CPU did).
|
||||
does (`WorkCounts::indirect_write_residencies_unmarked` counts each such commit's buffers). What
|
||||
the records may hold (`IndirectCommandBuffer::command_writes`) takes what each such state, and
|
||||
each state such an execution's records may name, may write, in whichever encoder of the command
|
||||
buffer it was set: Metal on an M3 Max runs what a kernel wrote with the buffer resident for
|
||||
writing only in an encoder before the kernel's or after it, as it does with the buffer resident
|
||||
in the kernel's own. A buffer no encoder of the command buffer made resident for writing is
|
||||
outside Metal's contract for a function's write: its executions run the CPU's records, where
|
||||
Metal on an M3 Max ran a compute execution's commands as the kernel wrote them (and a render
|
||||
execution's as the CPU did).
|
||||
- **What an execution runs, where its records are read**
|
||||
(`CommandBuffer::add_executed_commands_handler`, no Metal counterpart): a handler is called each
|
||||
time the runtime reads an execution's records, at `commit`, in a host step, or not at all for an
|
||||
|
||||
Reference in new issue
Block a user