Each compute command whose layout binds the device's texture or sampler table read the layout
again for those bindings and the table kind (allocating their lists), and took the device-wide
heaps lock three times: for the highest texture ID placed and the texture table, for the sampler
table, and in heap_sets::bind.
- heap_sets.rs: TextureTableAt and SamplerTableAt work out from a layout where it binds the
tables, over how many entries and of which kind, and keep each table's descriptor once read
(the device makes each table once and never replaces it). HeapTables holds both;
texture_table and sampler_table (render's calls, unchanged) build them per call as before.
- The highest texture ID placed, for UnnamedTexturesPastCapacity, is stored under the lock as
textures are placed and unplaced (DeviceShared::heap_textures_end) and read without it, so the
notice is made at the same commands.
- pipeline/objects.rs: VariantObjects::heap_tables makes HeapTables at a variant's first command;
compute's record takes it there. TextureTable and SamplerTable borrow the bindings.
- WorkCounts::heap_tables_worked_out counts the layout reads.
The same descriptors, sets and notices. heap_sets::bind keeps its one lock.
Check that fails without it: runtime_lane::resource_ids::a_variant_reads_its_layout_for_the_device_tables_once
(four dispatches of a kernel reading a texture handle: [1, 0, 0, 0] layout reads; with the
per-call form beside it, [3, 2, 2, 2]).
Release, M3 Max, MoltenVK 1.4.2, host_ab encode, before (d6779a26d9) and after interleaved three
times, us per dispatch (medians of 3 rounds; one thread, so no lock contention is measured):
| workload | before | after |
|---|---:|---:|
| dispatch_handles | 1.075-1.115 | 1.047-1.076 |
| dispatch_handles (process CPU) | 8.95-9.72 | 8.20-9.07 |
| dispatch_static | 0.674-1.009 | 0.664-0.685 |
dispatch_handles_rt_heap_tables_worked_out: 0.000 a dispatch after the first runs.
Verified on MoltenVK: the runtime GPU suite 1505/1505; the validation runtime lanes 534/536 (the
two failing the same at the base); resource_ids, heaps and argument-buffer lanes 153/155, the
two (extended_range_two_planes::two_plane_heap_textures_read_and_write_as_metal_does,
argument_linear_samples::heap_linear_samples_answer_as_slot_samples) failing the same at the base.
(cherry picked from commit b9f35448fd3e947bb02a440a79eec2f9caf705ca)
(cherry picked from commit c327b2e68c82f88698e85637569461b102bc51be)
(cherry picked from commit c6ad3ecd67471216711b5410fbf35201c423f091)
(cherry picked from commit 78be3664f4474a26221b82842cbe5c8df76fead3)