A shadowed texture's pass that opened a run left its merge to its batch's submission
(`Deferred::RunMerge`). That splits its encoder's commands into a continuation VkCommandBuffer and
records a segment of batch work at the submission. A pass that no later pass goes on from paid for
this and saved nothing. The conformance cases rotated-planes-load-0-64x16 and -32x32, one such pass
each, measured alone on the M3 Max: command_buffers_begun 3 -> 6, command_buffers_submitted 2 -> 5,
submit_infos 1 -> 2, end_command_buffer 3 -> 6, encoder_command_buffers_begun 2 -> 3, batch work
1 -> 2, and one batch barrier and one continuation that the recordings do not have. Reverting the
shadow runs alone restored the recorded counts; reverting the twin-shadow fix changed nothing.
Now the pass that would open a run merges in place as its encoder ends, as a pass alone does, and
only marks where a run may start (`PassRuns::placed`). The pass after it opens the run
(`Joined::Placed`): its image is carried, with no copy in, and it keeps the texture again.
The second keep is required. A run's merge compares its keep with the image its last pass left,
byte by byte, and a byte equal in both keeps the buffer's byte. A first attempt went on over the
in-place pass's keep instead. Bytes that the later passes changed and changed back then kept the
in-place merge's value, and the byte comparisons failed:
- tests::shadow_runs::runs_over_host_pages: 1,176 bytes;
- tests::merge_scratch's passes over host pages;
- the validation lane's many_passes_over_host_pages tests.
So a run of k >= 2 passes costs two keeps, two merges and k - 1 continuations, and a lone pass
costs nothing extra.
Verified on the M3 Max (MoltenVK 1.4.2, --cfg m2v_gpu):
- `conformance cost --runs 8 --alone --show` for both rotated-planes cases: every count that rose
equals the recording again. The four counts that differ alone from the whole-set measurement
(command_buffers_deferred, cmd_push_constants, device_memory_allocated,
queues_sharing_a_vk_queue) also differ with the shadow runs reverted.
- New test tests::shadow_runs::a_pass_alone_merges_in_place. A pass alone: 0 continuations,
3 shadow copies. Three passes: 2 continuations, 5 copies. The bytes equal a private texture's.
Negative controls:
- with the in-place path disabled, it fails at (1, 1, 3);
- with the pass after a marker opening the run without a keep (`Joined::Opens`), it fails at
(3, 0, 7).
- tests::shadow_runs and tests::merge_scratch, 10 of 10, with updated counts:
- runs_over_host_pages: 32 copies, 14,680,064 texels kept;
- the scissored passes keep at [0, 1, 2];
- the rebind encodes 4 passes again.
- The runtime's shadow, merge, linear, rebind, re-encode and replay tests: 155 of 155.
- The validation lane's shadow, padded, linear, rotated and surface tests: 145 of 145.
- The 700-pass probe now takes 5 shadow copies and keeps 2,097,152 texels (3 and 1,048,576
before). Release builds of this tree and of its parent, interleaved, three processes each, the
second to fourth command buffers: commit to completion was 32.7-35.6 ms against the parent's
31.6-36.1 ms, and with an empty encoder between every two passes, 61.5-67.2 ms against
60.4-67.0 ms.
docs/FAST-PATHS.md gives the new counts and the M3 times. The RTX 5080 Laptop numbers are removed:
they described the previous form, and that host was running VMs, so they were not measured again.
(cherry picked from commit 2bc0f1eac676dcc86dadfbd37a81313977515d45)
(cherry picked from commit 55c7f307a92c67125d31b08c33b3f91c7d14a67b)