Every draw and dispatch whose functions read loaded pointers uploads a root table per stage
that reads one. Each table embedded the whole resident set: every bound buffer, every
Buffer and Heap made resident, every listed range, sorted and coalesced per command
(resident_entries). The runtime then copied and uploaded those bytes and added each range
to its command buffer's root_ranges. Yet the commit points every table at the command
buffer's own resident set (State::point_root_tables; a host step's table is pointed at
once), so the GPU never reads the embedded copy. With N draws among N resident resources
that was N^2 work and bytes: 13% of the M3 profile of the argument-table shape at N 2000.
BindState::resident_apart is a consumer's opt-in, not part of the shape. It says the
consumer points every root table of the command at a resident set it uploads apart
(ResidentSet, RootTable::resident_fields). That set must hold every Buffer and Heap of
used_resources and every listed range, as well as the table's own ranges. With the flag, a
root table's own resident set holds the bound buffers alone (resident::table_entries), and
RootTable::resident_ranges lists only those. Without it, nothing changes, and replay
preprocess tables keep resident_entries either way.
The runtime sets the flag on the states whose tables go through binding::root_table:
RenderLowering::refresh_bind_state, the compute bind_state and dispatch_tiles_resident. It
leaves it off for gpu_execute and the GPU form, whose tables carry live ranges and are
pointed nowhere. The set the commit points at already holds what was dropped:
State::make_resident adds the joined residency's resident_ranges (every encoder's used
buffers and heaps) beyond the live buffers, and first_submission's remake does too.
Counted: WorkCounts::root_table_ranges_noted (State::root_table).
Functions: bind::resident::{table_entries (new), coalesced (new), bound_allocations (new),
resident_allocations, resident_entries}; bind::graphics and bind::dispatch build root tables
from table_entries; BindState gains resident_apart; State::root_table counts its ranges.
docs/API.md says what the flag asks of the consumer.
Verified:
- bind::resident::tests::a_state_resident_apart_keeps_the_used_resources_out_of_its_tables
(300 pseudo-random states whose bound buffers, used buffers and heaps and listed ranges
nest, overlap, touch and repeat): without the flag the table holds resident_entries; with
it, the bound buffers' set. A set made of the table's ranges plus the used and listed
ranges, as the runtime makes its own, resolves every address alike either way. The shape
is unchanged. A negative control (an empty table under the flag) fails it.
- bind::resident, bind::heap, bind::graphics, bind::dispatch and pipeline::api_tests pass
(74 tests).
- M3 numbers at the tip of this series are in its last commit. At N 300, every counter but
the new ones is the parent's on every path and binding of both shapes, barriers and uses
included, except the upload arena's buffers parked and recycled (54 -> 4: smaller tables).
The pixels are the parent's too.
(cherry picked from commit dcda2dc0368867436fb37ac78af79265088d6596)
(cherry picked from commit d6f17f77ab484eef479aa15df9c08055cf1101da)