What: BindingPlan::instantiate_dispatch_into writes a dispatch's commands over a kept
DispatchCommands, every field set as instantiate_dispatch sets it, the vectors keeping their
storage: each region's specialization (spec_key_into, region_specialization_into) and push
write's bytes, the argument table's bytes, the ranges, extents, holes and uses.
instantiate_dispatch is that method over no commands. The regions a dispatch plans take no list
of each axis's pieces (`Pieces`, numbers alone). In the runtime, compute::Instantiated keeps its
commands as storage when a value they may read moves, and a direct dispatch that instantiates
writes over them where nothing else holds them (the memo entry they were taken into is replaced
first: a dispatch that instantiates settled anew); builds with debug assertions instantiate
afresh and compare. WorkCounts::dispatches_instantiated_in_place counts them.
Why: a guest's compute encoders bind their buffers at moving offsets, one dispatch an encoder,
so their kept commands never serve again (reims's Iris walk: 96.6% of dispatches instantiated
anew). Profile (msi lavapipe, dispatch_chain --host 400 --only encoders --dispatches 5 --groups
64 --states 3 --binds tex-moved, calling thread): instantiate_dispatch 5.6% of its CPU, about
600 ns a dispatch, of it translator instantiate 3.4%, regions 1.6%, region_specialization 1.1%;
about fifteen allocations each instantiation. The commands read the buffer bindings that move,
so no memo of them is exact for this shape: the cut is the work of making them.
Verified: tests::bind::dispatch's
instantiating_over_kept_commands_gives_a_fresh_instantiation (more regions, fewer, none, another
state, the key's storage kept); compute_instantiated's
encoders_of_moving_offsets_instantiate_over_the_kept_commands (five encoders of one command
buffer: 5 instantiated, 4 in place, each writing at its own offset), on lavapipe.
Checks at the lane tip d52118ce95 (msi): clippy -D warnings --all-targets --all-features for metal2vulkan and the runtime, plain (m3-max-37686), m2v_cpu_icd (37688) and m2v_gpu (37689), all 0; rustdoc -D warnings 0 (37689); the translator bind::dispatch, plan::compute and graphics tests 42/42 (37686); the runtime compute, dispatch and encoder tests on lavapipe in a debug build, so every in-place instantiation was compared with a fresh one, 244/244 (37688). gem10 lavapipe m3-max-37685: dispatches_instantiated_in_place 0.80 a dispatch on the tex-moved row, every instantiation; that run's timing was unusable (rows the change does not touch moved more than the cut); one interleaved timing run follows.
With: dispatch_chain: an encoder's dispatch binds as its command buffer's dispatch index says (aac8651f23): at development the encoders shape never moved offsets or swapped textures.