fix(vi): below 60 fps at the default 60 cap, the game's whole-frame counters keep their fractions (HOS_FRAME_CARRY) #1828
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1828
Loading…
Reference in a new issue
No description provided.
Delete branch "GummiNaomi/Longshot:fix/below-60-time-carry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.pypatch_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. Nowcarry_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'svi: whole-frame countersline 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()andwhole_seen()inhost/nn_vi.c, thentests/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-startsave, Frame rate cap 60,HOS_FPS_LOG=1, 2560x1440, no window, on a build of main @f505340bwith this change,HOS_FRAME_CARRY=0against 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.pypasses 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.pywith every check on main @068fb8ebin WSL Ubuntu 24.04 (740 pass, 61 fail, 69 skipped: no clang or spirv-val there), then this head's--changedchecks in WSL (31 pass, 6 fail, 1 skipped) and on Windows (32 run, 11 fail). Every failure also fails on main @068fb8ebon the same OS: in WSLtest_crash_dialog,test_dev_ab,test_frame_overlap,test_linux_pressure,test_present_queue_default,test_vk_occlusion_queries; on Windows those six andtest_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_substepspasses in WSL on both and fails the same two cases on Windows on both, a link error).Still to test:
HOS_FPS_LOG=1andHOS_FRAME_CARRY=0against unset, expecting thevi: whole-frame countersline near 1.000 unset and under 1 with=0where 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 @
0de25c3eand 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'svi: whole-frame counterslines and the frame trace's last 100 s.Baseline: the test rows are main @
0de25c3eagainst this change on it (the carries' code is the same on068fb8eb); the game rows are one build of main @f505340bwith this change,HOS_FRAME_CARRY=0(main's cut) against on.0de25c3e(test);HOS_FRAME_CARRY=0@f505340b(game)0de25c3e(test);HOS_FRAME_CARRYon @f505340b(game)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;=0brings the old cut back.HOS_FPS_LOGalso writes thevi: whole-frame countersline 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.inior the caches.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.gpu/vk/switches.def.tests/that reads changed source is updated, not weakened.host/nn_vi.ccode compiled and run by its test with clang on Windows and gcc 13.3-Werroron WSL Ubuntu 24.04; not a whole Linux build.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
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)