Skip to content

perf: a long render pass is split and committed while the GPU idles, with a settings panel switch (after nxnative) - #2191

Open
Enokine wants to merge 3 commits into
ly05010419:mainfrom
Enokine:perf/pass-split-pr
Open

Enokine wants to merge 3 commits into
ly05010419:mainfrom
Enokine:perf/pass-split-pr

Conversation

@Enokine

@Enokine Enokine commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What

Mid-submission commits (chunk_maybe_split) happen only between render passes, so a long pass reaches the GPU in one piece when it ends. Breath of the Wild 1.9.0 draws about 2,700 of its 4,100 draws a frame into one G-buffer pass: several same-target SetRenderTargets, continued into one Metal pass. The GPU, done with the shadow passes, waits for that pass to be translated.

seedds/nxnative fixed this with pass_split_try (their PR #1468). This PR applies the same rule to this repository's chunks:

  • When it splits: at a draw, with nothing committed still on the GPU (g_q4_inflight) and TOTK_PASS_SPLIT draws since the last commit (default 256, 0 off).
  • What it does: draw_inner ends the pass, commits the chunk as chunk_maybe_split does, and the draw opens the pass again.
  • Why the picture is unchanged: attachments are always stored and a reopened pass loads them, the same as after a compute dispatch inside a pass.
    • TAA keeps its jitter for the reopened G-buffer pass.
    • MetalFX does not take its depth again.
    • A counting occlusion query counts into a new slot, which its report adds up (vis_count_begin, g_pass.serial).
  • Limit: at most TOTK_PASS_SPLIT_MAX splits per NVN pass (default 2).
  • Never split: passes opened without all their attachments; ranged, layered or cube-merged passes; hoisted or pending clears; the TBDR rewrites; geometry draws.

Controls and diagnostics:

  • Settings panel: the Display page has a "Long-pass split" switch, saved in pass-split.txt like the GPU keep-alive. TOTK_PASS_SPLIT decides first and greys the switch out.
  • Live flag: flag pass_split <draws> through TOTK_INPUT_FILE.
  • Log: the chunk line counts splits per frame. A second line counts the draws that could have been split, by command buffers in flight and by passes that may not be split.

Measured

BotW 1.9.0 + DLC, M4 Max, macOS 27.2, Kakariko, standing still, uncapped. The flag alternated every 25 s with powermetrics running. There were about 2–3 splits per frame.

Block GPU clock Frame p50 GPU time / frame CPU + GPU power
split 641 MHz 10.9 ms 7.9 ms 13.5 W
no split 380 MHz 14.2 ms 11.6 ms 9.5 W
split 641 MHz 10.9 ms 7.9 ms 13.6 W
no split 344 MHz 19.1 ms 13.8 ms 8.9 W

The GPU clock followed the flag in both pairs. Feeding the GPU earlier appears to keep macOS from lowering its clock. With Game Mode on, this Mac otherwise falls to 338–380 MHz after about two minutes in fullscreen. It is only two pairs. Power rises with the higher frame rate, which is why the split has a switch.

No visual difference was seen in game.

Tests

  • Passing: tests.test_settings_panel (with updated row counts and stubs for the switch), tests.test_frame_lock, tests.test_shot_share and tests.test_text_keyboard.
  • Compiles: nvn_mtl.m for BotW 1.9.0, TotK 1.4.3 and Ocarina of Time.

Not tested

  • TotK and Ocarina of Time in game.
  • iOS.
  • A capped frame rate. The player reports no drops at 60+60.

🤖 Generated with Claude Code

…with a settings panel switch (after nxnative)

Mid-submission commits (chunk_maybe_split) happen only between render passes, so a long pass reaches the GPU in one piece
when it ends. Breath of the Wild 1.9.0 draws about 2,700 of its 4,100 draws a frame into one G-buffer pass (several
same-target SetRenderTargets continued into one Metal pass), and the GPU, done with the shadow passes, waits for it to be
translated. seedds/nxnative fixed this with pass_split_try (its PR ly05010419#1468); this is the same rule on this repository's chunks.

At a draw, with nothing committed still on the GPU (g_q4_inflight) and TOTK_PASS_SPLIT draws (default 256, 0 off) since
the last commit, draw_inner ends the pass, commits the chunk as chunk_maybe_split does, and the draw opens the pass again.
Attachments are always stored and a reopened pass loads them, as after a compute dispatch inside a pass: TAA keeps its
jitter for the reopened G-buffer pass, MetalFX does not take its depth again, and a counting occlusion query counts into
a new slot that its report adds up (vis_count_begin, g_pass.serial). At most TOTK_PASS_SPLIT_MAX (default 2) splits per
NVN pass. Not split: passes opened without all their attachments, ranged, layered or cube-merged passes, hoisted or
pending clears, the TBDR rewrites and geometry draws.

The settings panel's display page has a switch for it (pass-split.txt above the game's folder, like the GPU keep-alive;
TOTK_PASS_SPLIT decides first and greys it out), and "flag pass_split <draws>" (TOTK_INPUT_FILE) sets it while the game
runs. The chunk line of the log counts the splits per frame, and a second line counts the draws that could have been
split, by command buffers still in flight and by passes that may not be.

Measured on BotW 1.9.0 (M4 Max, Kakariko, uncapped, flag alternated every 25 s): about 2-3 splits a frame; with the split
the GPU stayed at 641 MHz and frames at 10.9 ms p50, without it the clock fell to 344-380 MHz and frames to 14-19 ms, in
both pairs. No visual difference was seen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ly05010419

Copy link
Copy Markdown
Owner

Thanks for porting this and for the paired runs; the GPU clock going from ~350 to ~640 MHz on BotW 1.9.0 is a real finding. Before we merge, two things:

  1. It is on by default for every game, on the Mac and on iOS, but it was measured only on BotW 1.9.0 on the Mac (two pairs, uncapped). Tears of the Kingdom, Ocarina of Time, iOS and a 30/60 fps cap are untested. Please make the default on only where it was measured (BotW on the Mac), with the switch and TOTK_PASS_SPLIT available everywhere else, and widen it as more games are measured.
  2. Splitting a pass changes how the GPU executes the frame, so we need a picture check rather than the reasoning that every attachment is stored and reloaded. Please add same-frame screenshots, split vs not split, from a scene with MSAA resolve or other resolve attachments, and say how the exclusions cover those.
    This addresses the same GPU clock drop as the GPU keep-alive already on main (feat(mac): a GPU keep-alive switch on the settings panel's Display page #2049). Please also say how the two interact: the clock and frame time with each one alone and with both on.

Enokine and others added 2 commits November 18, 2026 18:30
settings_panel.h is now a link to shared/runtime/settings_panel.h upstream, so the switch's row moves to
games/totk/runtime/settings_game.h, beside the GPU keep-alive's.
… 1.9.0 on the Mac, where it was measured

Review of PR ly05010419#2191: the gain was measured on BotW 1.9.0 on an M4 Max only. PASS_SPLIT_DEFAULT (nvn_mtl.m) is now 256
draws there (GAME_BOTW190 on the Mac) and 0 elsewhere: Tears of the Kingdom, Breath of the Wild 1.6.0, Ocarina of Time,
the Switch 2 games and iPhone / iPad start with it off. The settings panel's switch (pass-split.txt) and TOTK_PASS_SPLIT
still turn it on everywhere, at PASS_SPLIT_DRAWS (256) draws. tools/gfx_matrix.py: every configuration, Mac and iOS,
compiles with the same warnings as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Enokine

Enokine commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Two commits are pushed:

  • Merged current main. games/totk/runtime/settings_panel.h is now a link to the shared panel, so the switch's row moved to games/totk/runtime/settings_game.h, beside the GPU keep-alive row. Apart from that move, the PR's lines are the same.
  • Point 1, the default (daa11d4). The split is on by default only in Breath of the Wild 1.9.0 on the Mac (PASS_SPLIT_DEFAULT in nvn_mtl.m, GAME_BOTW190 && !TARGET_OS_IPHONE). Tears of the Kingdom, BotW 1.6.0, Ocarina of Time, the Switch 2 games and iPhone / iPad start with it off. The settings switch and TOTK_PASS_SPLIT=256 still turn it on everywhere. tools/gfx_matrix.py: every configuration, Mac and iOS, compiles with the same warnings as before.

Points 2 and 3 need the game running, so they will come in a later comment on BotW 1.9.0 (M4 Max):

  • same-frame screenshots, split and not split, from a scene with resolve attachments, and how the exclusions cover them;
  • the GPU clock and frame time with neither on, the split alone, the keep-alive alone, and both.

@Enokine

Enokine commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Point 2: pictures, split vs not split. Short version: no visible change. Split and not split differ no more than two unsplit frames taken a second apart, and the frame has no multisample attachment or resolve for a split to cut. Details below.

BotW 1.9.0 + DLC, M4 Max, Kakariko, standing still, 60+60, 1920×1080 render. Everything comes from one session: TOTK_INPUT_FILE switched flag pass_split (0 / 256), and shot took a picture about every second, in the order off, off, on, on, three times. BotW never draws the same frame twice: grass, trees and banners move in the wind, the fire flickers, NPCs walk and TAA jitters. So two neighbouring pictures with the same setting are the null control, and two neighbouring pictures with different settings are the comparison, at the same spacing. Compared on the 1920×1080 game picture:

neighbouring pairs mean abs. difference (0–255) pixels off by > 16
null control (off/off, on/on), 6 pairs 4.16 (3.69–4.85) 8.2 % (6.3–11.5)
split vs not split (off/on, on/off), 5 pairs 4.42 (3.70–5.90) 8.9 % (4.6–13.4)

Not split / split (the first off → on pair):

Difference ×8, null control (off/off) / split vs not split (off/on):

Both kinds of pairs differ in the same places: grass, leaves, banners, the fire, the NPCs and edge shimmer. The largest off/on pair (5.90) differs by edge outlines across the whole frame, a sub-pixel shift, not in one region and not by a missing object. I see no difference between split and not split. The splits did happen: the first one came at frame 9693, right after the first switch on, and the log counts 4.2–4.6 splits a frame while the split stayed on. No errors in the log.

Resolves, and how the exclusions cover them

  • No resolve inside a pass. No Metal render pass in this backend sets a resolveTexture or a MultisampleResolve store action. NVN's Downsample calls are not implemented (removed from the no-op list in hle_nvn.c, so a real call stops at the stub). A split can't separate draws from their resolve, because no pass resolves.
  • No multisample attachments in this scene. I dumped one frame with the split on (passdump 1, frame 11031): 166 render passes, 229 colour attachments, all at 1 sample. I don't know of a BotW scene with MSAA. If TotK or OoT has one, I'll run the same check there before the split is turned on by default in those games.
  • Every attachment is stored. The split never runs with the TBDR rewrites (tbdr_on() is one of its exclusions). Without them, sd_finish stores every attachment, so the first half is stored and the reopened pass loads it. The same dump shows the 8 splits of that frame:
    • G-buffer, 3 splits (after 246, 256 and 1,791 draws): 4 colour attachments at 1920×1080 plus depth, all reopened with load. This Metal pass continues several same-target SetRenderTargets, so TOTK_PASS_SPLIT_MAX = 2 per NVN pass allows 3 here.
    • Shadow maps, 5 splits (896×896 depth): halves that began with a clear are reopened with load. The clear has already happened when the pass opened. A clear still pending is the excluded case.
  • Multisample attachments, if a split ever met one, would be stored with Store, which keeps every sample, and loaded again. The split itself does not resolve anything.

Point 3 (GPU clock and frame time with neither, the split alone, the keep-alive alone, and both) will follow in its own comment.

@Enokine

Enokine commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Point 3: the split and the GPU keep-alive, alone and together

BotW 1.9.0 + DLC, M4 Max, on AC power, Kakariko, standing still, 60+60 (the game capped at 60 fps), 1080p render. Each of the three phases was about 2 minutes: keep-alive off, then on, then off again (A-B-A, so a slow clock drift doesn't count against one setting). Within each phase flag pass_split alternated off / on every 30 s. The GPU clock, active residency and power come from powermetrics (1 s samples, the first 5 s after each switch dropped), and frame and GPU time from the game's 300-frame timing lines. Values are medians.

keep-alive split 30 s windows GPU clock GPU active CPU+GPU power GPU time / frame frame p50
off off 4 832 MHz 89 % 8.8 W 6.43 ms 16.72 ms
off on 4 753 MHz 95 % 10.7 W 7.16 ms 16.70 ms
on off 2 1578 MHz 100 % 25.1 W 4.11 ms 16.72 ms
on on 2 1577 MHz 100 % 25.7 W 4.24 ms 16.70 ms

The split ran whenever it was on: 3.2–4.6 splits a frame with the keep-alive off, 5.6 with it on.

  • At a 60 fps cap, neither changes the frame time. It stays 16.7 ms in all four.
  • The keep-alive pins the GPU at its top clock. 1578 MHz, 100 % active, about 25 W against 9 W, with no frame gained at this cap. It only shortens the GPU's time per frame, because the clock is higher.
  • The split alone does not keep the clock up at this cap, and costs about 2 W. Without either, the GPU stayed around 830 MHz here, so there was no 344–380 MHz drop for the split to prevent (the uncapped measurement in the PR description, keep-alive off: 641 against 344–380 MHz). In two of the four split windows, both 90–120 s into a phase, the clock fell to 600–660 MHz with the GPU 99–100 % busy and 3 W more; the window without the split just before stayed at 770–870 MHz. I can't tell from this run whether that comes from the split or from the time spent in fullscreen.
  • Both together behave like the keep-alive alone. The split runs but adds nothing measurable (+0.6 W, +0.1 ms GPU).

So the two address the same clock drop. With the keep-alive on, the split is redundant. Uncapped with the keep-alive off, the split kept the clock up (PR description). At a 60 fps cap it gave nothing here and used a little more power. I haven't re-measured uncapped with the keep-alive on.

One caveat on that last point: an M4 Max has a lot of GPU headroom at 60 fps (about 6.4 ms of GPU work in a 16.7 ms frame), so a lower clock still fits the frame and the cap hides what the split is for. On a Mac with less GPU headroom (a base or Pro chip), the same frame takes a larger share of the 16.7 ms, which is closer to the uncapped case where the split helped. The split only fires while nothing is on the GPU (g_q4_inflight), so a busier GPU also splits less. That is reasoning, not a measurement: those Macs are untested. I'm leaving the default as it is (on only in BotW 1.9.0 on the Mac). Results from a base or Pro chip would show whether it should stay on at a cap or be limited to uncapped play.

@ly05010419

Copy link
Copy Markdown
Owner

Thank you for the careful pictures and the powermetrics runs. They answer both questions: the split does not change the picture, and at the 60 fps cap it gains no frame time and uses about 2 W more; with the GPU keep-alive on it adds nothing measurable, because both address the same clock drop.

The keep-alive is on by default on the Mac, so we will not merge the split for now. If you measure a gain on a base or Pro chip with the keep-alive on (uncapped and at the 60 cap), please post it here and we will look again.

@orcakhan

Copy link
Copy Markdown
Contributor

Results on an M4 Pro (16-core GPU), the base/Pro data point asked for above

BotW 1.9.0 + DLC, macOS 27.2.1, on AC power, Kakariko at night by the campfire, standing still, 2560×1440 render. This PR was merged onto current main (786ddc00; conflicts only in settings_game.h, nvn_mtl.m's forward declarations and the panel probe's row counts) and put into a copy of the app with an express update. flag pass_split alternated 0 / 256 every 30 s through TOTK_INPUT_FILE. The first 2 timing blocks after each switch were dropped. Power, GPU clock and residency come from powermetrics (1 s samples, the first 5 s after each switch dropped). All values are medians over the windows.

Uncapped and 60+60 interpolation (keep-alive off, 6 + 4 pairs)

mode split fps GPU / frame GPU clock GPU active CPU+GPU GPU
uncapped off 112.6 7.88 ms 1570 MHz 100 % 26.4 W 17.8 W
uncapped on 114.2 7.82 ms 1569 MHz 100 % 26.5 W 18.3 W
60+60 off 60.0 7.89 ms 1577 MHz 99.8 % 22.5 W 17.0 W
60+60 on 60.1 8.11 ms 1577 MHz 99.8 % 22.9 W 17.4 W

The uncapped medians differ only because the scene went from ~97 to ~116 fps during the third pair, with the split on and off alike. The pairs themselves match: 97.6 / 96.4, 96.4 / 96.9, 115.8 / 115.9, 112.5 / 112.8. Once the scene got faster, the split fired 0.01–0.1 times a frame, because a command buffer was always in flight. A first uncapped / 60+60 run with the keep-alive on gave the same frame rates (no power data for that run).

60 fps frame lock, no interpolation (5 pairs each)

keep-alive split fps p99 GPU / frame GPU clock GPU active CPU+GPU GPU
off off 60 18.1 ms 10.4 ms ~970 MHz 89 % 8.1 W 2.9 W
off on (2.2–2.7 / frame) 60 18.2 ms 10.6 ms ~970 MHz 86 % 7.9 W 3.0 W
on off 60 18.1 ms 7.9 ms 1578 MHz 100 % 16.1 W 11.0 W
on on (3.6–3.9 / frame) 60 18.2 ms 8.0 ms 1578 MHz 100 % 16.6 W 11.2 W

Summary for this Mac and scene

  • The split gained nothing in any mode: uncapped, 60+60 and a 60 lock, with the keep-alive on or off.
  • At a cap it costs a little: about 0.4–0.5 W and 0.1–0.3 ms of GPU time a frame.
  • No 340–380 MHz clock drop happened here:
    • Uncapped and at 60+60, the GPU stayed at its top clock and 100 % active even without the keep-alive.
    • At a 60 lock without the keep-alive, it settled near 970 MHz, still well inside the 16.7 ms budget.
  • At a 60 lock in this scene, the keep-alive doubles CPU+GPU power (about 16 W against 8 W) for the same frame rate and p99.

Not tested: other scenes, battery power, base M-series chips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants