What: a new public bind::BufferRanges (a device's maxUniformBufferRange and
maxStorageBufferRange, BufferRanges::of(limits)), carried on each StageTable (buffer_ranges,
serde default), which the runtime sets on every table it reads (argument_table's AtBindViews,
beside the view base alignment: stage_table_reading, refresh_reading and the in-part
refreshes, AtBindViews::holds, and the debug check of a kept table). A buffer's shape states its
length class rounded up to the greatest class that fits the same limits
(BufferRanges::length_class); a class past both stays its own. BoundBuffer::shape and same_shape
take the ranges; BoundKind::of_bound and instantiate::bound_buffer class the bound length under
the table's ranges, so the instantiation's kind check takes a binding exactly where its class is
the plan's. The default (both 0) tells every class apart, as before.
Why: a guest compositor's serial compute encoder of ~1,140 fix-up dispatches over buffers of
many sizes made a new bind shape at 46% of its dispatches and planned again at 69% (the
consumer's XTX walks). A plan reads a length class only through class_fits against those two
limits (storage_view_variant and large_view_candidates against maxUniformBufferRange,
psb_variant and range_variant against maxStorageBufferRange); otherwise it only stores the class
for the kind check. On an RX 7900 XTX both limits are 4294967295, so every buffer below 4 GiB
takes the same plan decisions, and the dispatch_chain bench's 44 length-class shapes were one
plan. The bench there (job m3-max-34605, interleaved) matched the walk's split exactly (made
46%, found 18%, kept 36%) at 7.1-7.6 us a dispatch, against 4.1-4.4 us for the same stream of
one shape.
Exact: under the device's own limits, every class_fits answer of the rounded class is the exact
class's, so every plan decision, variant key and specialization is the same; under any other
limits the rounded class still bounds the padded length from above (padded < 2^class), so no
plan reads a range past a limit (it may take only a longer buffer's form).
Digests, cache keys and stored records: none carries the class. BindShape keys only in-memory
memos (Variant::plans, a state's kept Planned entries, the dispatch memo, the render draw
shapes); artifact digests and region keys are functions of the variant key and specializations,
which this leaves equal; validation and executor states keep the default ranges, so their shapes
and plans are unchanged; no pipeline record or warm record holds a shape. The serde form of
StageTable gains a defaulted field. So no SEMANTICS bump, in my reading.
Tests: bind::plan::slots length_classes_are_told_apart_as_far_as_a_plan_reads_them (4 GiB
limits, 64 KiB/128 MiB both ways round, 16 KiB, and none: every length's class answers both
limits' class_fits as the exact class does, bounds its padded length, is exact under none, and
bound_buffer takes a binding for another length's kind exactly where the classes are one, only
where the exact classes answer both limits alike); bind_shape_of's has_shape states and
same_shape pairs over range limits; runtime grid_classes
lengths_the_device_tells_apart_nowhere_plan_once (outputs of four length classes under 16 KiB,
one shape, 23 of 24 dispatches planned as before; 20 without this), and
shapes_and_classes_in_turn_each_plan_once re-made from the constant's binding (inline bytes, a
buffer, a buffer with a per-bind stride), since its three length classes are now one shape.
API: signatures blessed, api_surface, docs/API.md.
Also: 674c995a42 (dispatch_chain --zero-classes and --stay: a guest's fix-up dispatches over buffers of
many sizes), ad406afa87 (clippy in the new test).
Verified in the lane (m3-max-34674, gem10, at ad406afa87): clippy -D warnings -p metal2vulkan
-p metal2vulkan-runtime --all-targets --all-features; translator tests 21/21 (the new
length_classes test, bind_shape_of, the slots tests). Still running when landed: the XTX bench before
and after (release, interleaved), the lavapipe bench, the runtime suite under m2v_cpu_icd on lavapipe,
the negative control (AtBindViews ranges set back to the default fails the new runtime test), clippy
gpucfg and cpuicd, rustdoc.
API: adds bind::BufferRanges and StageTable::buffer_ranges (serde default); additive.