Repository navigation
game: Ocarina of Time at 40 fps, frame step in ticks of 1/120 s - #2840
cagatay-io wants to merge 3 commits into
Conversation
…DM_CTL fps) A game whose frame step the host decides through its state page took the Frame rate setting (DM_FPS_TARGET, 30 or 60) only at start; the iPhone's in-game menu could not offer it and a Mac app had no way to change it while playing, though the frame step already changes its cap while the game runs for a movie or the thermal cap. loader.c dm_fps_target_set writes 30 or 60 into the page's target while the game runs (nvn_fstep_target_change; refused for a target of 0, which hands the stubs back to the game's own interval logic, for a game without a page, and where an engine frame limit the host writes takes it at the next start). fps_step_cap reads the page at every present, so the next frame steps at the new cap and the frame step handles it as a movie's start and end. dm_fps_target_live tells a front end whether the running game takes a change at once. - iOS: the in-game menu offers Frame rate where dm_fps_target_live says it applies at once and saves the pick as the settings screen does. - Mac: a new menu-bar menu, Performance › Frame Rate (60 / 30), in such games; disabled with a note elsewhere. The choice holds until the game quits; the settings window's choice is the next start's. - DM_CTL: a line `fps <30|60>` calls dm_fps_target_set as the menu does, so a run without a window (scripts/bench.py, a headless host) can measure one standing scene at 60 and at 30 in one process. - Docs: docs/reference/frame-rate.md (new entry), settings.md, env_switches.tsv, the Duo harness README. Checked: t_fstep (60 → 30 → 60 while running, game time = real time; 120, 45 and 0 refused), t_nvn (fps_present_cap, present_itv and nvn_game_fps follow the page at their next call), dm/host/tests t_nro, t_symbols and t_hid; the Duo harness on the iPhone 17 Pro Simulator (36 tests, 1 skipped, 0 failures; main's harness needs the two link stubs of the separate harness PR to link at all); the Mac host builds. A headless Ocarina of Time run on this branch switched 60 → 30 → 60 → 30 over DM_CTL (numbers in the PR). The menus themselves were used in play only on an earlier tree.
The host's frame step hands the game whole 1/60 s vsyncs, so Ocarina of Time can run at 60, 30 or 20 only. On a 120 Hz screen 40 fps (25 ms, three refreshes) is the rate between them: on the iPhone Duo (A20 Pro) the game does not hold 60 on a heavy route and fell to 30 (72 % of frames at 33.3 ms, none at 25), and DM_FPS_TARGET=40 was refused. The game's own time hook already takes a ratio; its stub divided the step by 60. - patch_nso.py / patches.py: capability FRAME_STEP_120. The ratio stub divides the step by the unit at state +0x38: 120 = ticks of 1/120 s; 0 keeps the division by 60, so every other stub and page stays in vsyncs. - loader.c writes the unit at every start (fixed for the run) and accepts DM_FPS_TARGET=40, and a change to 40 while the game runs, only for such a stub (dm_fps_40_able); elsewhere 40 holds 30 with a red line. - nvn_fstep.h / hle_nvn.c: with the unit the frame step counts holds in ticks at every cap: 2 / 3 / 4 for 60 / 40 / 30. Holds at 60 and 30 still move by whole vsyncs, at 40 by one tick (3 or 4, never 5). The late margin, the debt and the largest step (and the stub's STEP_MAX) are scaled so they stay the same real time, including main's rate window (over_sum); a 40 that does not hold steps to 30 at the 12th late frame. A movie's picture rate and the thermal cap still decide over the target. - 40 needs a screen at a multiple of 120 Hz and no Low Power Mode, else the cap is 30 with one log line; at 40 the display link runs at 120 Hz and the acquire waits 3 ticks. nvn_mtl.m holds presents over 20 ms (HOLD_PERIOD_MIN, was 25 ms) for their whole period, so a 25 ms frame stays three ticks. - settings.tsv offers 40 for a game with FRAME_STEP_120; the iOS in-game menu and the Mac's Performance › Frame Rate offer it where it applies. - Docs: docs/reference/frame-rate.md (new entry), the game's note, settings.md, env_switches.tsv. Checked: t_fstep 153 checks, t_nvn 368, t_link_ticks 70 + 4, t_thermal 26, t_present_hold40 7 (new), 0 failed; dm/host/tests t_nro (the 40 fps loader case) OK; test_frame_ratio_stub (new: the stub at 2 / 3 / 4 ticks, run natively), test_settings, test_launcher_settings, test_fps_target, test_game_profile, test_docs, test_gfx_tests_makefile, test_lint_c, test_lint_python OK; the Duo harness on the iPhone 17 Pro Simulator (36 tests, 1 skipped, 0 failures, with the link stubs of the separate harness PR). Headless on an M3 Max with this branch's host (numbers in the PR): at 40, 1,800 of 1,800 frames a 30 s line held 3 ticks, frame p50 25.00 ms, game time 1.000; at 60, frames at 2 ticks, 16.66 ms p50, game time 1.000. On the iPhone Duo (an earlier base, water route, battery, one run per target): 39.4 fps delivered at 40, 96 % of intervals at 25 ms, game time 1.000; the camera turns as far at 40 as at 30 and 60. The game needs the rewriter run again; no shader rebuild of its own. Front-ends: new: DM_FPS_TARGET takes 40 for a game whose frame-step stub declares FRAME_STEP_120 (dm_fps_40_able), on a screen at a multiple of 120 Hz.
ec4f5d4 to
eec8c89
Compare
|
Rebased onto main 5d54b88. The one conflict was the |
|
Hi! This branch is based on a To pick up the fix, merge the current git fetch origin
git merge origin/main
git pushIf the merge has conflicts, ask here if you want help with them. |
# Conflicts: # dm/gfx/nvn/nvn_mtl.m # dm/gfx/tests/Makefile # dm/host/dm.h # docs/reference/frame-rate.md
|
Thanks @cagatay-io for the 1/120 s tick design, Ocarina of Time stub, tests, and iPhone/Mac measurements! This landed standalone on Checked: host build for Ocarina of Time, iOS launcher Swift type-check, native ARM64 stub tests, loader/settings/docs/lint tests, and graphics frame-step and display-link unit tests (including Metal). Still open: live in-game 40 fps switching (part of #2837), retesting 40 fps in a window and fullscreen on a 120 Hz Mac and on an iPhone with current |
…'s measured frame time kept Ocarina of Time's frame-step stub now divides the step by the page's tick unit (state +0x38, 120 for FRAME_STEP_120: 2 / 3 / 4 ticks are 60 / 40 / 30 fps; nxnative main PR seedds#2840) and declares the capability, and still never steps below the measured frame time, which moves to state +0x1c0 / +0x1c4 (FSTEP_FT_OFF, FSTEP_FT_MARK_OFF; +0x38 is main's unit now). The v0 (1.0.0) main gets the frame ratio and the dynamic resolution (main PR seedds#3319's fingerprints, the division at +0x108); its other sites are v131072's fixed addresses, so render scale, wide view and half rate stay v131072's. Frame rate mode 4, 40 fps (DM_FRAME_MODE: DM_FPS_TARGET 40, hold on, no frame generation), offered on a 120 Hz screen in a build with FRAME_STEP_120 (offeredOptions); the Play panel's tap goes 60 → 40 → 30 there; frame generation on from 40 goes to 30 + frame generation. DM_FPS_TARGET offers 40 as main does. The half-rate request counts the hold in vsyncs (2 * kv), so 40 fps (3 ticks) is not half rate. test_frame_ratio_stub's tick cases and test_settings' 40 fps case run again and pass; t_fstep 186, t_link_ticks 94, t_nvn 580; the v131072 main rewrites with FRAME_STEP_120, RENDER_SCALE, DYNAMIC_RESOLUTION and HALF_RATE; the iOS Swift sources type-check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stacked on #2837: this branch's first commit is that PR's commit, and only the second commit belongs here. It extends
dm_fps_target_set/dm_fps_target_live(40 while running), the Mac Performance › Frame Rate menu (a 40 item) and that PR'st_fstep/t_nrocases, and does not apply without it.What and why
The host's frame step hands the game whole 1/60 s vsyncs, so Ocarina of Time runs at 60, 30 or 20 only. On a 120 Hz screen 40 fps (25 ms, three refreshes) is the rate between them. On an iPhone with an A20 Pro the game does not hold 60 on a heavy route and fell to 30 (72 % of frames at 33.3 ms, none at 25), and
DM_FPS_TARGET=40was refused. The game's time hook already takes a ratio; its stub divided the step by 60.FRAME_STEP_120: the ratio stub divides the step by the unit at state+0x38(120 = ticks of 1/120 s; 0 keeps /60, so every other stub and page stays in vsyncs).loader.cwrites the unit at every start and accepts 40 (at start and while running) only for such a stub (dm_fps_40_able); elsewhere 40 holds 30 with a red line.over_sum): a 40 that does not hold steps to 30 at the 12th late frame. A movie and the thermal cap still decide over the target.settings.tsvoffers 40 forfixups:FRAME_STEP_120; the iOS in-game menu and the Mac's Performance › Frame Rate offer it where it applies.Checked
t_fstep153 / 0,t_nvn368 / 0,t_link_ticks70 / 0 + 4 / 0,t_thermal26 / 0,t_present_hold407 / 0 (new);dm/host/testst_nroOK (the 40 fps loader case); Python:test_frame_ratio_stub(new: the stub at 2 / 3 / 4 ticks, run natively),test_settings,test_launcher_settings,test_fps_target,test_game_profile,test_docs,test_gfx_tests_makefile,test_lint_c,test_lint_pythonOK;test_env_switchesfails as on main (DM_GL_RENDERPROGS); Duo harness on the iPhone 17 Pro Simulator 36 / 1 skipped / 0 failures (with the two link stubs of the Duo harness link fix PR applied temporarily).0400486024DEC000v131072, Mac headless (M3 Max), host from this branch, game files rewritten with a tree on main 2da2c14 that shares this branch's shader chain (82cb7bb335cc), withFRAME_STEP_120(that tree's render-scale stub in those files stays inert at 1.0), water route, docked, render scale 1.0, Dynamic resolution off:frame step in ticks of 1/120 s decided by the host, capped at 40 fps; in the window (100-178 s) all 3,116 frames at 3 ticks, frame p50 / p95 25.00 / 26.05 ms, GPU 22.27 / 23.72 ms, game speed 1.000; the 30 s lines:held … 3 … 1,800 of 1,800,game time 45.00 s in 45.00 s. One step to 4 ticks after the opening movie (3 late frames), back to 3 by a trial 61 presents later.regress.py check(BotW / TotK keep the vsync ABI: their pages leave+0x38at 0; no dumps here).Front ends
Front-ends: new: DM_FPS_TARGET takes 40 for a game whose frame-step stub declares FRAME_STEP_120 (dm_fps_40_able), on a screen at a multiple of 120 Hz.Docs
docs/reference/frame-rate.mdentry and the game's note;docs_symptoms.pyanddocs_patches.pyrun.patch_nso.pychanged; no shader rebuild).