The host step that first finds a page's records unchanged records its chunks apart to keep them
(render/executions/kept.rs). Each chunk's encoder started from nothing but the bind state, so
each worked out again what an execution recorded inline works out once: on the replayed_textured
page (5001 commands, 20 chunks, 5001 textures and 15018 buffers resident) that step took
host_step_ms 82-85 where an inline step takes 27-31. Per chunk:
- the heap parts (draw_heap_parts_made 40 against 2), let go as each chunk's encoder ended;
- the instance's gathering of the 5002 uses of what the encoder made resident
(resident_uses_gathered 100044 against 5006);
- the chunk core's note of those uses, then its summary, its kept effects and the pass's core
taking them;
- the resident textures' shadow copies and those a carrier holds (draw_resident_textures_looked_at
21 against 2), and the heaps of the resident resources.
Now each chunk's encoder starts from what the one before left (kept.rs's Carried), each piece kept
by what names it, so a chunk's draw takes it as the next draw of one encoder does:
- LiveBind::end_chunk keeps the heap parts (HeapOf::holds compares what each is made of) and the
shadows' copies listed (ResidentShadows, keyed by the residency's generation and the usage
shadows made);
- the instance's gathering (InstanceShadows, by the identity of the resident uses), the
unreadable textures found (ResidentUnreadable, by generation) and the unwritten facts
(RenderLowering::resident_again, by identity) go to the next chunk's encoder;
- Residency::resident_heaps finds the resident heaps once a generation.
The chunks' cores (EncoderCore::capture_apart) note their draws' uses past those of what the
encoder made resident; those go in a ResidentPart, made once a step, which the pass's core notes
once (EncoderCore::absorb), and a kept chunk holds it so a command buffer that runs the kept
chunks again notes it once for them (EncoderCore::run_kept), not once a chunk.
Verified on the M3 Max (MoltenVK 1.4.2), release, the replayed_textured page, 2 rounds of 3 frames
in one job, interleaved, b960f51b05 (this branch's base before commit 1, the code of bfcfa638ee:
every step inline) against this tree:
- frame 1, the step that records the chunks apart: host_step_ms 29.1/28.3 now, 27.4/25.7 inline;
encoding to completion 60.7/59.3 ms now, 57.9/56.7 inline. resident_uses_gathered 5006 and
draw_heap_parts_made 2, as inline. At 791b4fbf58 (another job, 4 frames) that step took
host_step_ms 82.4/84.5 and 112.3/116.6 ms to completion, gathering 100044 uses and making 40
heap parts.
- frame 2, the first kept step: host_step_ms 3.6/3.5 now, 25.7/24.3 inline (7.4/7.2 at
791b4fbf58); encoding to completion 33.9/33.8 ms now, 57.6/57.2 inline. resident_uses_gathered
4, draw_heap_parts_made 0: a kept step's run notes the resident part once, not once a chunk.
- A step that records apart at every frame (a temporary case, since removed, that swaps one
texture every other frame; a build of this change before Residency's heaps cache went behind an
Arc, a layout change for clippy's large_enum_variant): host_step_ms 31-33 at each of 8 frames,
against 85-92 at 791b4fbf58 and 51-53 with the heap parts alone kept.
New checks:
- runtime tests::kept_heap_uses now also compares the step that records the chunks apart: its
planned uses equal the inline step's, as the kept step's do.
- lane kept_textured: the step that records apart gathers, notes, works heap parts out and looks
at the resident textures no more often than the inline step before it (steady()).
Negative controls, each fails its test on the M3:
- the gathering not carried: kept_textured's keeping test (frame 1 gathers 1030 uses,
frame 0 517);
- each chunk's core noting the resident uses itself: the same test (frame 1 notes 1030, frame 0
517);
- the heap parts let go at each chunk: the same test (frame 1 makes 4 heap parts, frame 0 2);
- the unreadable textures found again at each chunk: the same test (frame 1 looks at
3 resident textures, frame 0 2);
- absorb not noting the resident part: tests::kept_heap_uses (frame 1 lacks the 512 textures);
- run_kept not noting it: tests::kept_heap_uses (frame 2 lacks the 512 textures).
Checks run on the M3 on this tree: clippy -D warnings with --cfg m2v_gpu over the runtime and
validation crates (all targets, all features); the runtime suite (1660 passed); the residency,
draw and notice lanes (248 passed); the kept, step and replayed lanes (62 passed); the frame-cost
lanes in debug and release (4 and 3 passed); the API signature table (unchanged). The earlier
controls still fail their tests: the old plain rule, run_kept noting none of the recording's uses
(now 520 uses lacking at frame 2), RenderKey's samplers and the resident key left out, commit 1's
hand-back dropped.
(cherry picked from commit df484df0fe15e38b4c459fe1653baeb066062209)