fix(fps): the Shadow Temple's barge carries Link and the enemies above 100 fps #1528
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!1528
Loading…
Reference in a new issue
No description provided.
Delete branch "CraftyCorvid/Longshot:fix/floor-carry-above-60"
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?
Type: fix · Risk: low · Tested on: Linux, RTX 5090 · Needs: none
TL;DR
Above 100 FPS, Link and the Stalfos standing on the Shadow Temple's barge slid to its back as it moved. The game carries a
character standing on a moving floor by the floor's velocity, but on a frame under 10 ms it keeps only a tenth of it (a
guard for slowed time at 60 FPS), and above 100 FPS every frame is under 10 ms. Now that test is the one the game would make
at 60 FPS. At 140 FPS neither Link nor the Stalfos slide; a new test fails on main and passes here.
Breakdown
which at 60 FPS means slowed time, but above 100 FPS is every frame.
at 140 FPS, where the game's test held 13,800 times and the whole velocity carried every time.
Why
On the Shadow Temple's barge, with the Game frame rate cap above 60 and the game running above 100 FPS, Link and the
enemies that spawn on it (Stalfos) slide to its back as it moves; at 60 they stand still on it. Fixes #439.
The findings on #439 (#439 (comment)) put it in Havok's
contact coupling; it turned out to be the game's own carry code, before the physics step.
How to reproduce
Seen on: CachyOS Linux (kernel 7.3), RTX 5090, NVIDIA 620.70.06
Settings and switches: Game frame rate cap Uncapped (about 140 FPS there), everything else default
Steps: in the Shadow Temple, stand on the barge's Triforce mark, play Zelda's Lullaby, and stand still as it moves
Expected: Link (and the Stalfos that drop on it) move with the barge, as at a cap of 60
Actual: they keep about a tenth of its velocity and slide to its back rail
What changed
A character standing on a moving floor is carried by the floor's velocity, which one of three update modules adds to the
character's (
f_80159dc0, the one that runs for Link;f_8015d490;f_838baa40). Each first compares the physics timeobject's 1/dt (
[[[0x84c9df00]]+0xc0]+0x28) with 100.0 and, above it, multiplies the floor's velocity by 0.1 (the float at0x83e60fb4). At 60 FPS 1/dt is 60, so this only fires when the physics' time is slowed below 0.6 of real time. Above100 FPS it fires on every frame. The branch to the tenth now also asks the host: above a 60 cap, 1/dt times the frame's
step (the game's time object's,
[[0x84c9e890]]+0x10, 0.5 at 120 FPS) over 100. That is the game's test as it would be at60 FPS, so slowed time still takes the tenth. At a cap of 60 the game's verdict stands; on a frame of a 60 FPS one or
longer the product is at least 1/dt, so it is the game's too.
nx2/oot_patches.pypatch_floor_carry: in each of the three modules, the branch after the 1/dt test (by its label,once in its function) gains
&& hos_oot_floor_carry_slow(...);reportwarns when fewer than three are found.host/oot_high_fps.hoot_floor_carry_slow(the rule, and why at the top of the file);host/oot_high_fps.chos_oot_floor_carry_slow(reads the frame's step as the horse's jump fix does;HOS_FPS_LOGcounts the tenths kept).tests/test_floor_carry_step.py.How it was found (a local diagnostic build, not in this PR, driven through the control bridge):
10 ms or more, and exactly a tenth (-0.3500) on shorter ones, switching frame by frame around 100 FPS whatever he had
before.
f_804f5030, from the velocity request the character updatef_80150180makes).f_80159dc0turning the floor's velocity into a tenth of it.Measurements
Verdict: fixed. At 140 FPS neither Link nor the Stalfos slide, and the game's under-10 ms test, which held 13,800 times
in that ride, never kept the tenth; the game-free test fails on
mainfor this bug and passes here.Hardware: CachyOS Linux (kernel 7.3), RTX 5090, NVIDIA 620.70.06
Scene: the Shadow Temple's barge from a save on it; Game frame rate cap Uncapped (about 140 FPS), 120, 144 and 60
Method:
tests/test_floor_carry_step.py(gcc and clang); in the game, a diagnostic build onmain's code logging Link's andthe barge's physics velocities each frame, then this branch ridden uncapped with
HOS_FPS_LOG=1How to reproduce:
python -I -B tests/test_floor_carry_step.py; in the game, the steps aboveBaseline: the in-game before is that diagnostic build (logging, and a cap set from a file; no change to the game) on
main310e7c9d; the after is this branch's fix at310e7c9d, both built as dev packs over a base of71b1edd8. The branch is now rebased onto4b68c42b, which touches none ofthe files this PR changes; the test fails at its commit and passes at the fix there too.
4b68c42b(with the test,48e556f3)d54442c0test_floor_carry_step.pyFlags and settings
None (
HOS_FPS_LOG, the existing diagnostic switch, gets one more line).Testing
Tested:
310e7c9d) built as a dev pack over a base of71b1edd8:the lift reports "a moving floor's carry above 60 fps" in
code_001.candcode_050.c, and no warning (all threemodules found). Riding the barge uncapped at about 140 FPS, Link and the Stalfos that drop on it stood still on it. In a
driven ride at about 100 FPS (another game held the CPU), Link moved at the barge's 3.5 m/s at caps 60, 120, 144 and
uncapped. A diagnostic build with the same rule logged 400 frames under 10 ms, the full velocity on 398 of them (on the other
two the physics' time was under 0.6 of the frame's, so the rule kept the game's tenth).
tests/test_floor_carry_step.pywith gcc and clang: fails at48e556f3(the test alone, onmain), passes atd54442c0.Broken on purpose it fails: the tenth always kept (120 FPS), never kept above 60 (slowed time), the rule at a cap of 60
too (a cap of 60 with a time object at 0.5), 1/dt divided by the step, a threshold of 166.7.
python -I -B tests/run_all.py(Linux): 630 passed, 37 failed, 102 skipped (Vulkan and SPIR-V headers missing here). The37 also fail on
main4b68c42b(run there), for reasons in files this PR doesn't touch (test_dev_packs, which reads thepatch file, fails the same way on
main: "a game patch shows in the objects"): test_bug_report_defaults,test_compute_warm_apart, test_cpu_report, test_crt_options, test_damage_debug_menu, test_dev_packs, test_discover,
test_display_startup_failure, test_dlss_feature_size, test_failed_compile_keeps_objects, test_guest_imported,
test_hud_layout_row, test_invalidate_quick, test_invalidate_vcore, test_libc_hooks, test_lift_lookups,
test_linux_preflight, test_linux_pressure, test_linux_update, test_log_open_failure, test_mirror_budget, test_missing_nup,
test_mods_size_table, test_pending_guest_import, test_pipeline_play_cache, test_present_thread, test_profiling_mode,
test_psychov35_fsr3_fg, test_readback_timeout_source, test_run_all_changed, test_slow_frames, test_switch_table,
test_target_image_pool, test_upscaler_rows, test_vcore_escape, test_walk, test_walk_key.
host/oot_high_fps.ccompiled alone (-fsyntax-only -Wall -Wextra, the build's include folders) with gcc and clang forLinux and with llvm-mingw clang (tools.lock's, 20261104) and MinGW gcc for Windows: no warnings, as on
main.Not tested:
game-free test covers it above 60 and at 60).
Must be tested: None.
Risks
What could break: how a character standing on a moving floor is carried above a 60 FPS cap, on frames under 10 ms. Slowed
time below 0.6 of real time still takes the game's tenth (the rule assumes the game's time object's step is the frame's own,
as the horse's jump fix does); at a cap of 60 and on frames of a 60 FPS one or longer nothing changes.
Turning it off: revert the commit, or a cap of 60.
Compatibility: Nothing changes for saves, options or caches; an update translates the game's code again, as for any
change to the lift's patches.
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened. (None needed: the checks thatread
host/oot_high_fps.*ornx2/oot_patches.py,test_high_fps_fixes.py,test_horse_jump_step.pyandtest_patch_hooks_defined.pyamong them, pass unchanged.)🤖 Generated with Claude Code
Tested in game: RTX 5090, NVIDIA 620.70.06, Linux (CachyOS): the Shadow Temple's barge, Game frame rate cap Uncapped (about 140 fps): after Zelda's Lullaby, Link and the Stalfos stood still on the moving barge (on main they slide to its back); HOS_FPS_LOG: the game's under-10 ms test held 13,800 times and the full velocity carried every time. Built as a dev pack over a base of
71b1edd8.WIP: fix(fps): the Shadow Temple's barge carries Link and the enemies above 100 fpsto fix(fps): the Shadow Temple's barge carries Link and the enemies above 100 fps