A program that opens a compute encoder for each dispatch (Geekbench's compute workloads, and
dispatch_chain's encoders shape) instantiated every dispatch's commands again. The dispatch memo
goes when its encoder ends. The textures such a program binds in turn change the bind state at
every dispatch, though a compute plan's commands read no texture binding except a texel buffer's
range, a texture's in-place planes or a handle table's member. At development dd1481cfa0,
instantiate_dispatch was 6.4% of the calling thread's CPU (profile m3-max-29022, msi lavapipe,
encoders shape, tex --heap). The keyed regions, the move of the commands into the memo and their
drop at encoder end were about 2% more.
- Translator: BindingPlan::dispatch_reads(class), whether a compute plan's commands may read the
values bound at slots of a class past their shape. Buffer slots: always. Texture slots: only
through a texel buffer's range, a YCbCrInPlace push field, or a handle table's member bound at a
slot. Sampler slots: never. New test bind::dispatch::tests::dispatch_reads_names_the_slot_values_the_commands_read:
equal commands for states that differ only in texture and sampler values where it answers false;
other commands for another texel range or handle-table resource ID where it answers true.
docs/API.md section 6.
- Runtime: live_bind::Reshape notes the kinds of values each bringing in place changed
(ValueKinds: each slot class's bindings, and every other field). stage_in_region and the
constant fields now go through Reshape::unshaped. compute::Instantiated, on LiveDispatch, keeps
the last direct dispatch's Arc<DispatchCommands> with its Planned held weakly, and goes on with
the state to the next encoder. A moved kind the plan may read lets it go. KeptDispatch shares
the Arc. Builds with debug assertions instantiate again at every dispatch that takes the kept
commands, and assert they are equal.
- WorkCounts: dispatches_instantiated and dispatches_instantiated_as_before (new).
api_signatures.tsv (+3). host_ab lists the two counters.
- New tests::compute_instantiated (m2v_gpu / m2v_cpu_icd):
- textures of one shape in turn, an encoder each, keep the commands and sample their own
texels;
- an output bound at another offset instantiates again;
- a buffer made resident instantiates again;
- texture buffers in turn, for a plan that reads texel ranges, instantiate at every dispatch and
read their own texels.
Verified (dispatch2, msi lavapipe; tree d43025b439): check job m3-max-29038 under --cfg m2v_cpu_icd:
clippy of the runtime and translator, --all-targets --all-features -D warnings 0; touched tests
40/40 (compute_instantiated 4/4, compute_bind_memo 3/3, live_bind 2/2, bind::dispatch::tests 15/15,
api_signatures, api_surface). Negative control m3-max-29048 (texture changes ignored):
texture_buffers_bound_in_turn_instantiate_again fails on the debug assertion; the other three pass.
Release A/B m3-max-29047 (own target dirs, md5 efd53108 base 3e0262099b / 0c57ca78 tip, one run
each, encoders shape, 2300 dispatches): dispatches_instantiated_as_before 1.00 per dispatch; --binds
tex dispatch 3467 -> 2868 ns, thread CPU 6586 -> 5882 (-10.7%); --heap 3834 -> 3123, 6827 -> 6044
(-11.5%); end_encoding unchanged. Lint in the other configurations and the suites run after landing.