fix(vi): below 60 fps at the default 60 cap, the game's whole-frame counters keep their fractions (HOS_FRAME_CARRY) #1828

Merged
HumanBean merged 1 commit from GummiNaomi/Longshot:fix/below-60-time-carry into main 2026-11-20 06:48:05 +00:00
Member

Summary

At the default Frame rate cap of 60, when the game runs slower than 60 fps, several of its clocks fall behind: the time of day, the water's ripples, the spider-web floor and the Scarecrow's Song advance by whole frames only, and the fraction each slow frame should add was thrown away. At 46 fps they ran at 77 % of their speed. This keeps those fractions, as Longshot already does above a 60 cap: a new game-free test shows the day at 77 % on main and at full speed here.

Why: with Game speed Real time and the cap at 60, realtime_step (host/nn_vi.c) gives the game the rate of the last frames (15 to 60), and the game steps 60 / rate a frame (1.30 at 46 fps), so its world keeps real time. The game then cuts some counters to whole frames (the time of day, the water's ripple substeps, the floor web and the Scarecrow's Song: nx2/oot_patches.py patch_whole_frames; the clock of a loop of one frame or less: patch_loop_steps, patch_loop_pose). Longshot keeps the fraction each cut drops and hands it back later, but only while the frames' own time is the step, which is the case for every cap except 60. Now carry_fractions() also keeps them at a 60 cap when the step is not a whole number of frames (HOS_FRAME_CARRY, on). Whole steps (60, 30, 20, 15 fps), Game speed Per frame, caps above 60 and movies are unchanged.

How to see it on main: play somewhere the frame rate stays under 60 at the 60 cap with HOS_FPS_LOG=1: the log's vi: whole-frame counters line shows about 0.77 of the step at 46 fps (fractions cut), and the day runs slow. My PC held 60 fps in every run, even with 6 ms of sleep added to each frame, so here the effect shows in the test only.

Read first: carry_fractions() and whole_seen() in host/nn_vi.c, then tests/test_frame_carry_cap60.py.

See #1591 (one pacer for the frames; its test passes on this tree), #1585 (a 45 cap, which goes through the timed path and so already carried), #1384 (Link's cap and other cloth keep the clock below 60).

Testing

Tested: Windows 11, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, the game held to 4 cores: Hyrule Field (child), standing 130 s after a teleport from the kokiri-start save, Frame rate cap 60, HOS_FPS_LOG=1, 2560x1440, no window, on a build of main @ f505340b with this change, HOS_FRAME_CARRY=0 against on, and a third run with a 6 ms sleep a frame: every run held about 60 fps (59.2 with the sleep), so the carry had almost nothing to keep (0.989 of the step cut against 0.999 kept, in the loading stretch at 33 to 42 fps); 0 errors in each log. The bug itself shows in the test, not on this PC.
Checks: tests/test_frame_carry_cap60.py passes on this head (7 cases) on Windows (clang) and Linux (gcc 13.3, WSL Ubuntu 24.04, -Wall -Wextra -Werror); on main its carry case fails (46 frames, 92 day seconds, 184 water substeps a second at 46 fps).
Suite: tests/run_all.py with every check on main @ 068fb8eb in WSL Ubuntu 24.04 (740 pass, 61 fail, 69 skipped: no clang or spirv-val there), then this head's --changed checks in WSL (31 pass, 6 fail, 1 skipped) and on Windows (32 run, 11 fail). Every failure also fails on main @ 068fb8eb on the same OS: in WSL test_crash_dialog, test_dev_ab, test_frame_overlap, test_linux_pressure, test_present_queue_default, test_vk_occlusion_queries; on Windows those six and test_driver_env_choose, test_mesh_fallback_layout, test_pipeline_tour, test_realtime_rate, test_water_substeps (most of them this PC's compiler wrapper or a missing tool; test_water_substeps passes in WSL on both and fails the same two cases on Windows on both, a link error).

Still to test:

  • A Steam Deck, or a PC under 60 fps at the default cap: Hyrule Field two minutes each with HOS_FPS_LOG=1 and HOS_FRAME_CARRY=0 against unset, expecting the vi: whole-frame counters line near 1.000 unset and under 1 with =0 where the frames run under 60, and the day passing at real time (by hand)

Measurements

Verdict: the fix works where the game runs under 60 at the 60 cap, shown by the game-free test (at 46 fps: 46 whole frames, 92 game seconds of day and 184 water substeps a second on main; 60, 120 and 240 here); in the game on my PC it had nothing to change, because every run held 60 fps. No measurable cost: a few relaxed loads and compares per counter call, under the counters' lock as before.

Setup: the test on main @ 0de25c3e and on this PR; in the game, Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, 32 GB, held to 4 cores (affinity 0xF00); Hyrule Field standing, cap 60, HOS_FPS_LOG=1; the log's vi: whole-frame counters lines and the frame trace's last 100 s.

Baseline: the test rows are main @ 0de25c3e against this change on it (the carries' code is the same on 068fb8eb); the game rows are one build of main @ f505340b with this change, HOS_FRAME_CARRY=0 (main's cut) against on.

Before: main @ 0de25c3e (test); HOS_FRAME_CARRY=0 @ f505340b (game) After: this PR @ 0de25c3e (test); HOS_FRAME_CARRY on @ f505340b (game)
test, 46 fps at the 60 cap: whole frames, day seconds, water substeps a second 46, 92, 184 60, 120, 240
test, the log line's ratio at 46 fps 0.767 (cut) 1.000 (kept)
game, Hyrule Field at the 60 cap: fps over the last 100 s 60.0 60.0 (59.2 with a 6 ms sleep a frame)
game, the counters during the load stretch (frames at 33 to 42 fps) 0.989 of the step 0.999 of the step

HOS_FRAME_CARRY (new, a kill switch) ships on: the test shows the clocks at real time with it and at 77 % without it at 46 fps, and whole steps are cut exactly as before; =0 brings the old cut back. HOS_FPS_LOG also writes the vi: whole-frame counters line every 3000 calls.

Risks

What could break: a counter the game expected to lose its fractions under 60 now advances at real time, as the same counters already do above a 60 cap; whole steps are cut exactly as before. Turning it off: HOS_FRAME_CARRY=0. After updating, a player under 60 fps sees the time of day, the water and the short loops at real time; nothing changes for saves, longshot_options.ini or the caches.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (The changed host/nn_vi.c code compiled and run by its test with clang on Windows and gcc 13.3 -Werror on WSL Ubuntu 24.04; not a whole Linux build.)
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary At the default Frame rate cap of 60, when the game runs slower than 60 fps, several of its clocks fall behind: the time of day, the water's ripples, the spider-web floor and the Scarecrow's Song advance by whole frames only, and the fraction each slow frame should add was thrown away. At 46 fps they ran at 77 % of their speed. This keeps those fractions, as Longshot already does above a 60 cap: a new game-free test shows the day at 77 % on main and at full speed here. Why: with Game speed Real time and the cap at 60, `realtime_step` (`host/nn_vi.c`) gives the game the rate of the last frames (15 to 60), and the game steps 60 / rate a frame (1.30 at 46 fps), so its world keeps real time. The game then cuts some counters to whole frames (the time of day, the water's ripple substeps, the floor web and the Scarecrow's Song: `nx2/oot_patches.py` `patch_whole_frames`; the clock of a loop of one frame or less: `patch_loop_steps`, `patch_loop_pose`). Longshot keeps the fraction each cut drops and hands it back later, but only while the frames' own time is the step, which is the case for every cap except 60. Now `carry_fractions()` also keeps them at a 60 cap when the step is not a whole number of frames (`HOS_FRAME_CARRY`, on). Whole steps (60, 30, 20, 15 fps), Game speed Per frame, caps above 60 and movies are unchanged. How to see it on main: play somewhere the frame rate stays under 60 at the 60 cap with `HOS_FPS_LOG=1`: the log's `vi: whole-frame counters` line shows about 0.77 of the step at 46 fps (`fractions cut`), and the day runs slow. My PC held 60 fps in every run, even with 6 ms of sleep added to each frame, so here the effect shows in the test only. Read first: `carry_fractions()` and `whole_seen()` in `host/nn_vi.c`, then `tests/test_frame_carry_cap60.py`. See #1591 (one pacer for the frames; its test passes on this tree), #1585 (a 45 cap, which goes through the timed path and so already carried), #1384 (Link's cap and other cloth keep the clock below 60). ## Testing **Tested:** Windows 11, RTX 4070 SUPER (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, the game held to 4 cores: Hyrule Field (child), standing 130 s after a teleport from the `kokiri-start` save, Frame rate cap 60, `HOS_FPS_LOG=1`, 2560x1440, no window, on a build of main @ f505340b with this change, `HOS_FRAME_CARRY=0` against on, and a third run with a 6 ms sleep a frame: every run held about 60 fps (59.2 with the sleep), so the carry had almost nothing to keep (0.989 of the step cut against 0.999 kept, in the loading stretch at 33 to 42 fps); 0 errors in each log. The bug itself shows in the test, not on this PC. Checks: `tests/test_frame_carry_cap60.py` passes on this head (7 cases) on Windows (clang) and Linux (gcc 13.3, WSL Ubuntu 24.04, `-Wall -Wextra -Werror`); on main its carry case fails (46 frames, 92 day seconds, 184 water substeps a second at 46 fps). Suite: `tests/run_all.py` with every check on main @ 068fb8eb in WSL Ubuntu 24.04 (740 pass, 61 fail, 69 skipped: no clang or spirv-val there), then this head's `--changed` checks in WSL (31 pass, 6 fail, 1 skipped) and on Windows (32 run, 11 fail). Every failure also fails on main @ 068fb8eb on the same OS: in WSL `test_crash_dialog`, `test_dev_ab`, `test_frame_overlap`, `test_linux_pressure`, `test_present_queue_default`, `test_vk_occlusion_queries`; on Windows those six and `test_driver_env_choose`, `test_mesh_fallback_layout`, `test_pipeline_tour`, `test_realtime_rate`, `test_water_substeps` (most of them this PC's compiler wrapper or a missing tool; `test_water_substeps` passes in WSL on both and fails the same two cases on Windows on both, a link error). **Still to test:** - A Steam Deck, or a PC under 60 fps at the default cap: Hyrule Field two minutes each with `HOS_FPS_LOG=1` and `HOS_FRAME_CARRY=0` against unset, expecting the `vi: whole-frame counters` line near 1.000 unset and under 1 with `=0` where the frames run under 60, and the day passing at real time (by hand) ## Measurements **Verdict:** the fix works where the game runs under 60 at the 60 cap, shown by the game-free test (at 46 fps: 46 whole frames, 92 game seconds of day and 184 water substeps a second on main; 60, 120 and 240 here); in the game on my PC it had nothing to change, because every run held 60 fps. No measurable cost: a few relaxed loads and compares per counter call, under the counters' lock as before. Setup: the test on main @ 0de25c3e and on this PR; in the game, Windows 11 Pro 26200, RTX 4070 SUPER 12 GB (NVIDIA 617.42), Ryzen 9 9950X3D with SMT off, 32 GB, held to 4 cores (affinity 0xF00); Hyrule Field standing, cap 60, `HOS_FPS_LOG=1`; the log's `vi: whole-frame counters` lines and the frame trace's last 100 s. Baseline: the test rows are main @ 0de25c3e against this change on it (the carries' code is the same on 068fb8eb); the game rows are one build of main @ f505340b with this change, `HOS_FRAME_CARRY=0` (main's cut) against on. | | Before: main @ 0de25c3e (test); `HOS_FRAME_CARRY=0` @ f505340b (game) | After: this PR @ 0de25c3e (test); `HOS_FRAME_CARRY` on @ f505340b (game) | |---|---|---| | test, 46 fps at the 60 cap: whole frames, day seconds, water substeps a second | 46, 92, 184 | 60, 120, 240 | | test, the log line's ratio at 46 fps | 0.767 (cut) | 1.000 (kept) | | game, Hyrule Field at the 60 cap: fps over the last 100 s | 60.0 | 60.0 (59.2 with a 6 ms sleep a frame) | | game, the counters during the load stretch (frames at 33 to 42 fps) | 0.989 of the step | 0.999 of the step | `HOS_FRAME_CARRY` (new, a kill switch) ships on: the test shows the clocks at real time with it and at 77 % without it at 46 fps, and whole steps are cut exactly as before; `=0` brings the old cut back. `HOS_FPS_LOG` also writes the `vi: whole-frame counters` line every 3000 calls. ## Risks What could break: a counter the game expected to lose its fractions under 60 now advances at real time, as the same counters already do above a 60 cap; whole steps are cut exactly as before. Turning it off: `HOS_FRAME_CARRY=0`. After updating, a player under 60 fps sees the time of day, the water and the short loops at real time; nothing changes for saves, `longshot_options.ini` or the caches. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (The changed `host/nn_vi.c` code compiled and run by its test with clang on Windows and gcc 13.3 `-Werror` on WSL Ubuntu 24.04; not a whole Linux build.) - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(vi): below 60 fps at the default 60 cap, the game's whole-frame counters keep their fractions (HOS_FRAME_CARRY)
Some checks failed
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been skipped
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been skipped
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been skipped
Third-party parts / The same as upstream (pull_request) Has been skipped
CI / Conventional Commit title (pull_request) Successful in 12s
CI / Workflow lint (actionlint) (pull_request) Successful in 17s
Guide screenshots / Guide images and local UI source review (pull_request) Failing after 11s
Third-party parts / As their notes say (pull_request) Successful in 11s
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 6s
CI / Website build and checks (pull_request) Failing after 2m49s
14abfcaa15
At a Frame rate cap of 60 with Game speed Real time, realtime_step gives the game the
rate of the last frames and the game steps 60 / rate a frame (1.30 at 46 fps). The
counters the game cuts to whole frames (the time of day, the water's ripple substeps,
the floor web, the Scarecrow's Song) and the clock of a loop of one frame or less kept
their fractions only while the frames' own time is the step, a cap other than 60. At a
cap of 60 the cut threw the fraction away: at 46 fps those ran at 77 %.

Now the carries also keep the fractions at a 60 cap when the step the game was given is
not a whole number of frames. Whole steps (60, 30, 20, 15 fps), Per frame and caps above
60 are cut as before; HOS_FRAME_CARRY=0 brings the old cut back. With HOS_FPS_LOG a line
says what the counters took against the step.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
HumanBean changed title from WIP: fix(vi): below 60 fps at the default 60 cap, the game's whole-frame counters keep their fractions (HOS_FRAME_CARRY) to fix(vi): below 60 fps at the default 60 cap, the game's whole-frame counters keep their fractions (HOS_FRAME_CARRY) 2026-11-20 06:47:56 +00:00
HumanBean deleted branch fix/below-60-time-carry 2026-11-20 06:48:05 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1828
No description provided.