Repository navigation
Conversation
…nd commit: Ocarina of Time -0.15 to -0.3 ms a frame on an M1 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A segment could be committed only between passes, so a long pass reached the GPU at its end: Breath of the Wild draws 2,700 of its 4,100 draws a frame into one G-buffer pass, and the GPU, done with the shadow passes, waited about 2.5 ms of a 9 ms frame for it. At a draw, with nothing committed still on the GPU, DM_NVN_PASS_SPLIT draws (default 256, 0 off) since the last cut and a cut that will commit, the pass is ended, the segment committed, and the next draw opens the pass again with loads; at most DM_NVN_PASS_SPLIT_MAX (default 2) splits per NVN pass. The author measured BotW on an M4 Max at 120 fps: frame p50 / p90 8.75 / 9.33 -> 8.34 / 8.68 ms. Beside the pull request: the split ends a pass only when sub_cut will commit after it (sub_cut_ready, shared with sub_cut; before, DM_NVN_CUT=0 or a cut above 256 draws stored and loaded the attachments for nothing); the split's pass end always stores its attachments (the store lookahead skips the rest of the pass and could leave unstored one the reopened pass loads, with DM_NVN_TBDR=1); the resume flag that skips the dispatch-hoist scan is cleared at each target change; the readable-tile check redraw is not split. Checked on an M4 Pro: regress.py check on BotW and OCTOPATH TRAVELER II, shaders unchanged, no new RED lines, screenshots match. BotW's run-to-run noise (GPU 6-12 ms a frame on identical code, including a split-off control) is larger than the change; a second split-on run matched main (GPU 8.4 vs 8.8 ms). Graphics tests pass except t_present_rescue's 2 present-link checks, which fail on main too. Not run: iPhone, Ocarina of Time (the case of PR #2560, which this supersedes). Co-authored-by: Xipzer <60103178+Xipzer@users.noreply.github.com>
|
Thank you for this, and for the Ocarina of Time probe data. It's closed as a duplicate of #1468, which landed on main as 1831312. Both end a long pass and commit when the GPU runs dry. #1468 caps the splits at 2 per NVN pass. Without a cap, a 24-draw threshold can split a host-bound pass many times: the GPU finishes each short segment and runs dry again. #1468 also keeps |
What
sub_cutcommits a segment only between passes, at a render-target change. When the GPU ran out of committed work in the middle of a long draw pass, it sat idle until the host had encoded to the pass's end.With
DM_NVN_CUT_DRY(on by default;=0off,abfor theDM_ABphases), before each draw the host checks two things:g_seg_inflight == 0);DM_NVN_CUT_DRY_N(default 24) draws were encoded since the last commit.When both hold, the pass ends and the segment commits there, whatever
DM_NVN_CUT's draw count. The draw then reopens the pass, loading its attachments.It isn't tried while a pass is deferred, merged or hoisted, while the readable-tile check runs, or for geometry-emulation draws: the same states
sub_cutalready avoids.Why
A probe at each moment the GPU ran out of committed work (Ocarina of Time, Kokiri Forest, M1) found:
A Metal System Trace showed the same thing: one 0.5–1.7 ms gap a frame between fragment and vertex work.
Splitting a full-resolution pass costs about 65 µs on the M1. That was measured by forcing extra splits: +33 passes a frame gave +2.1 ms.
Performance
Ocarina of Time (0400486024DEC000), Kokiri Forest, MacBook M1 (8-core GPU), fullscreen. Measured in a tree with other local changes, including #2526's first-segment cut. Frame p50 per phase:
DM_NVN_CUT_DRY=ab, 300-frame phases=ab:0/2(polarity swapped), 450-frame phasesThe game paces to 30 fps, so 33.3 ms is its floor; the on-phases sit there. About 2 more passes a frame. With it on, the slow spot holds 30 fps: on-screen frame time p99 is 33.33 ms, against 50 ms before. Screenshots look right.
Switches (in
docs/env_switches.tsv)DM_NVN_CUT_DRY=0|1|ab: on by default.DM_NVN_CUT_DRY_N=<draws>: default 24.Checked
sub_cuthas no first-segment or idle rule, so the dry cut forces its commit there (g_cut_dry).Not run
🤖 Generated with Claude Code