Skip to content

Breath of the Wild: every segment commits on the Mac (104 → 115 fps circling outdoors at 120 fps), with cut_draws / cut_busy profile keys - #2286

Open
dontpokethebear3893 wants to merge 3 commits into
seedds:mainfrom
dontpokethebear3893:upstream/botw-segment-commits
Open

dontpokethebear3893 wants to merge 3 commits into
seedds:mainfrom
dontpokethebear3893:upstream/botw-segment-commits

Conversation

@dontpokethebear3893

@dontpokethebear3893 dontpokethebear3893 commented Nov 11, 2026 •

Copy link
Copy Markdown

What and why

On the Mac, Breath of the Wild in the open world is held back by the CPU, not the GPU. With a 120 fps target it ran at about 104 fps while the Metal HUD showed 5–7 ms of GPU time. The game waits on the fence of the frame it just submitted, so a frame is the GPU's span plus the host's translation of the next submission. Segmented submission (sub_cut) is meant to let the GPU start while the host is still translating. Since the rule added for Ocarina of Time (6121fd7: a segment commits only once earlier work has reported back), this game's segments mostly wait: 1.8 commits a frame, and the GPU waits for the translation inside each frame (fence wait p50 7.3 ms).

  • Two profile keys (game.py, Mac only):
    • cut_draws: the draws between segment commits, 0–4096 (default 64).
    • cut_busy: on (the default) or off. With off, every cut commits, even while earlier work is running.
    • DM_NVN_CUT and DM_NVN_CUT_BUSY still override both. iOS keeps 64 and the rule for every game, since neither was measured there.
  • Breath of the Wild's profile sets cut_draws 32 and cut_busy off, about 12.6 commits a frame.
  • The host (nvn_mtl.m): cut_draws() and sub_cut take their defaults from the profile, and log when the rule is off.
  • t_feedback's cut boundary case now follows the setting, and the Makefile runs it with the rule on and with it off, so both paths are checked whatever game the tests are built for.

Conflict with #2282 (encode thread): both edit the check_t_feedback line of dm/gfx/tests/Makefile. Whichever goes in second needs the two edits combined: DM_NVN_CUT_BUSY=1 DM_NVN_ENC_THREAD=0 … ./t_feedback; DM_NVN_CUT_BUSY=0 DM_NVN_ENC_THREAD=0 … ./t_feedback.

Suggestion: make the busy rule Ocarina of Time's own

The busy rule went in for every game to stop Ocarina of Time's stalls (the GPU idling 5–40 ms in front of a command buffer already committed). Their cause in the kernel is still unknown. For a game like Breath of the Wild, which waits on its newest fence, the rule costs about 10% of the frame rate. BotW also ran at about the commit rate where Ocarina of Time stalled (12.6 a frame against about 12) without showing the stalls.

This PR keeps the rule as every game's default and turns it off for BotW alone. The other way round would match how the BotW-only changes are made: cut_busy off by default, with Ocarina of Time's profile setting cut_busy on. That keeps the stall fix where it was measured and gives every other game the earlier behaviour. Before flipping the default, it would be worth checking:

  • The games measured when segments landed (Metroid Dread's p95 improved from 19.6 to 16.9 ms with segments).
  • Any game that reads the GPU timestamps of its reports for dynamic resolution, as Ocarina of Time does.

This PR does not make that change.

Checked

Breath of the Wild 1.9.0 on an Apple M5 Max (48 GB), macOS 27.2.1. The test build also had the 120 fps and dynamic frame rate changes (#2186 and #2181, since closed) and those of #2282 (encode thread), #2283 (Game Mode), #2284 (Game memory) and #2285 (Output resolution), with these settings:

  • 120 fps target
  • Encode thread on
  • Game Mode on
  • 5K output at render scale 0.75, Game memory 10 GB

Link circled outdoors from a save in the open world. All runs used DM_NVN_CUT / DM_NVN_CUT_BUSY, and the GPU clock was about 1,615 MHz in each.

2-minute runs, frames 3,000–9,000:

Segment size / rule Commits a frame fps 1% low Frame p50 Fence wait p50 GPU busy p50 GPU span p50
64, held back (the old default; 2 runs) 1.8 103.9 / 104.5 51 9.47 ms 7.28 ms 6.51 ms 8.30 ms
32, held back 2.4 105.2 51 9.32 ms 7.14 ms 6.48 ms 8.30 ms
16, held back 2.5 104.6 51 9.48 ms 7.27 ms 6.49 ms 8.62 ms
64, every cut 8.9 113.4 55 8.68 ms 6.53 ms 6.00 ms 7.46 ms
32, every cut (this PR) 12.6 115.2 54 8.57 ms 6.42 ms 6.01 ms 7.53 ms
16, every cut (2 runs) 18.2 115.9 / 116.5 52–54 8.48 ms 6.30 ms 6.00 ms 7.63 ms
8, every cut 25.9 115.5 51 8.51 ms 6.28 ms 6.00 ms 7.67 ms
  • The gain comes from committing, not from the segment size. Smaller segments alone change nothing while commits are held back.
  • 32 rather than 16: it gets nearly all of the gain with two thirds of the command buffers, and the second 16 run had 10 frames over 12 ms against 2.
  • 8 hung the GPU. The run at 8 draws ended in a GPU hang (kIOGPUCommandBufferCallbackErrorHang) at frame 8,857. No run at 32 has had one.

Three 10-minute runs at 32, every cut:

  • 116.0, 114.9 and 114.2 fps, with no GPU errors.
  • 2–8 frames over 20 ms in each run, one of them a 0.5 s hitch near frame 60,000 that every run has, including the old default.
  • No minute below 100 fps. Two runs dipped to 100–105 fps around the third minute, with the CPU's power and the GPU clock down, and recovered.

A 10-minute run of the old default for comparison doesn't count. After its third minute the GPU clock dropped to about 685 MHz and stayed there while the GPU was 98% busy, and the run fell to about 61 fps.

In-game, without overrides: the test app rebuilt with this commit logged every 32 draws (the default or the profile's cut_draws) and every segment commits … (the profile's cut_busy off).

  • In a visible window with DM_PRESENT_VRR=1 (variable refresh as in fullscreen), a 2-minute run gave 118.3 fps, 12.7 commits a frame and a fence wait p50 of 5.86 ms, with no GPU errors.
  • Without variable refresh (the same window), the 120/60 frame step held 60 fps. The old default, forced with DM_NVN_CUT=64 DM_NVN_CUT_BUSY=1, did the same, because frames of about 8.5 ms miss the 120 Hz tick. That isn't from this change.

Tests:

  • make -C dm/gfx/tests check_t_feedback (rule on and off) and check_t_reorder_chain pass for GAME=01007EF00011E000 and GAME=0400486024DEC000.
  • make -C dm/host/tests GAME=01007EF00011E000 run passes.
  • dm/tools/tests passes: test_game_profile, test_docs, test_env_switches, test_lint_python, test_lint_c, test_gfx_tests_makefile and test_launcher_settings.

Not checked:

  • The game's other scenes, handheld mode, and the default 1600x900 output.

  • Whether the game's dynamic resolution reads the segment timestamps differently.

  • iOS, which is unchanged.

  • Ocarina of Time and the other games, which are unchanged.

  • After the rebase on main (6a6a018):

    • make -C dm/host/tests GAME=01007EF00011E000 run, check_t_feedback and check_t_reorder_chain (dm/gfx/tests) pass.
    • dm/tools/tests passes: test_docs, test_patches, test_game_profile, test_env_switches, test_launcher_settings, test_settings, test_nsp_mac_app, test_fps_target, test_player_env, test_lint_c and test_gfx_tests_makefile. dm/ios/tests test_launcher_storage passes.
    • lint_python.py --against origin/main reports one new finding, dm/gfx/tools/dmsh_entry.py:7 (F401, an unused import). main itself reports the same one, and this change does not touch that file.
    • The measurements and game runs above were made before the rebase and were not repeated on it.

Docs

  • The game note (dm/games/01007EF00011E000/README.md, GPU work) and docs/reference/frame-rate.md (The GPU idles with the next command buffer already committed) have the measurements.
  • The new keys are in dm/games/README.md and dm/tools/docs_patches.py. The switches are updated in docs/env_switches.tsv and docs/agents/04-graphics.md.
  • python3 dm/tools/docs_symptoms.py and docs_patches.py were run.
  • A chain tool changed: n/a
  • No game files, keys or data extracted from a game in the change or the attachments.

🤖 Generated with Claude Code

…rcling outdoors at 120 fps. Profile keys cut_draws and cut_busy (Mac only) set the segment size and whether a cut waits for earlier work to report back

The rule that holds a segment's commit until earlier work has reported back (for Ocarina of Time's submission-queue stalls) left this game at 1.8 commits a frame, with the GPU waiting for the host's translation inside each frame: the game waits on the fence of the frame it just submitted. Its profile now sets cut_busy off and cut_draws 32 (12.6 commits a frame). M5 Max, 1.9.0, encode thread on, 120 fps target, frames 3,000-9,000: fence wait p50 7.3 → 6.4 ms, GPU span 8.3 → 7.5 ms; three 10-minute runs at 114-116 fps, no GPU errors, 2-8 frames over 20 ms each. Every other game and iOS keep 64 and the rule. t_feedback's cut boundary case follows the setting and runs with the rule on and off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedkoniszewski and others added 2 commits November 12, 2026 15:29
Brings the branch up to date with main (fixes for the t_save_sync cloud
device check and the clang-tidy fixture findings, among others) and
resolves the conflicts with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation game: 01007EF00011E000 The Legend of Zelda: Breath of the Wild nvn NVN on Metal and its tests (dm/gfx/nvn, dm/gfx/tests) tools Tools and scripts (dm/tools, scripts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant