fix(fps): Link's cap and other cloth keep the game's clock below 60 fps #1384
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!1384
Loading…
Reference in a new issue
No description provided.
Delete branch "dukenheimer/Longshot:fix/hat-cloth-low-fps"
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: Windows 11, RTX 5090; Steam Deck OLED (SteamOS, RADV) · Needs: none
Why
When the game runs below 60 fps, Link's cap floats: after he stops, it swings far out to the side and takes about a second to
settle. On the Steam Deck (17 to 24 fps) players see it all the time. At 60 fps it settles in about 0.2 s.
The cap is Havok cloth, and the game steps it a fixed 1/60 of a second each frame, whatever the game's own frame step for that
frame. With an engine frame step of 3.3 (about 18 fps), the cloth advances 1/60 s while the rest of the game advances 3.3/60 s,
about 0.3 of it. So the cloth lags behind Link: each cloth step sees his head move about 3.3 times as far, the cap swings wide,
and its settling takes about 3.3 times as long in real time. On a fast PC held to 18 fps it looks the same, so the frame step
alone causes it. The console would step the cloth the same way whenever its frame-rate controller drops to 30, 20 or 15 fps,
so this improves on the original's behaviour at low frame rates.
How to reproduce
Seen on: Windows 11, RTX 5090 (NVIDIA 621.14); the Steam Deck (reported)
Settings and switches: defaults at the game's 60 cap;
HOS_FRAME_SLEEP_MS=53(about 18 fps) on a fast PC, or any PC orDeck that runs under 30 fps
Steps: in Kokiri Forest, run Link forward for 2 s and let go of the stick.
Expected: the cap follows his head and settles within about 0.2 s after he stops, as at 60 fps.
Actual: on main, the cap's tail flares out sideways 0.2 to 0.45 s after the stop and takes about a second to settle.
What changed
While the engine's frame step is over 1, the cloth's simulate setup steps by the game's 1/60 times that step, so the cloth
advances as far as the rest of the game that frame. The solve count stays the same. With a step of 1 or less nothing changes
(at 60 fps and above; a 60-capped game can still have steps over 1 on slow frames, and those are scaled). The cloth above
60 fps, which still steps 1/60 a frame, is left for a separate change.
nx2/oot_patches.pypatch_cloth_time:f_81b3aa48, the Havok simulate operator's per-frame setup, the load of the step context's time (+8) goes throughhos_oot_cloth_secondswith the engine's frame step: the floatf_83b6ea90writes at 0x84d61fc8,60 / its frame rate.f_81b47080) reads.f_81b3a964) is not touched.reportwarns when the site isn't found once.host/oot_high_fps.{h,c}:oot_cloth_secondsmultiplies the time by the step only for 1 < step ≤ 8. A step of 1 or less, 0, a negative step, NaNor Inf keeps the game's time.
hos_oot_cloth_secondsreadsHOS_FPS_CLOTHby the repository's rule (env_value_off: unset, or anything but 0, off,false or no, is on). With
HOS_FPS_LOGit logs anoot: cloth timeline every 600 setups.docs/development.md: a row forHOS_FPS_CLOTH=0.tests/test_oot_cloth_time.py(new): it fails on main.f_81b3aa48's frame-data lines as lifted go throughpatch_fileand are compiled with the host function cut from thereal source and with
gpu/vk/compat/longshot_env.h.the same context, and
HOS_FPS_CLOTHunset, 1, yes, 0 and off.up to it; the counts are the game's; the context is untouched and a second setup is the same.
tests/test_high_fps_fixes.py: its stand-ins include<stdlib.h>and anenv_value_off, for the host file it compiles.Measurements
Verdict: fixed at an 18 fps engine step on Windows and on the Steam Deck. The cloth's time a frame follows the engine's
step (55.6 to 66.7 ms on the PC, smoothed steps 3.33 to 4.0) instead of 16.7 ms, and in the stills the cap settles faster and
flares less, qualitatively like the 60 fps reference. The solve count is unchanged. On the Deck (handheld, about 18 fps) the
stills show the same; fps, median frame time, process CPU and GPU time show no detectable cost in these two runs per arm, and
the tail differences (p99, 1% low) are inconclusive at n=2. The PC's CPU sample of the cloth solve was inconclusive: medians
6.79% (off) and 6.88% (on) of a core, with interference on the PC.
Baseline:
HOS_FPS_CLOTH=0on this PR's build (the log and CPU rows:5ddc9a7b). It switches off the one hook and runs thegame's own cloth path, on the same build, save and caches; there was no separate main base. The stills' before row comes from
an earlier build of this branch, 05bbcfd5, with
HOS_FPS_CLOTH=0: the same unscaled path (=0returns the game's timeunchanged in both), since the
5ddc9a7b=0runs took no shots.Hardware: Windows 11, RTX 5090 (NVIDIA 621.14), i7-13700K, 96 GB
Scene: Kokiri Forest beside Link's house, a child save; 2560x1440, quality preset 6 (Auto's), DLSS, frame generation off,
the game's 60 cap; headless (
longshot_ctl.py launch --profile test); about 18 fps fromHOS_FRAME_SLEEP_MS=53Method: the cloth's time from the log, the cloth solve's CPU share in 2 interleaved runs a side (the median), and stills:
oot: cloth timelines (HOS_FPS_LOG).HOS_SAMPLE_ALLandscripts/cpu_report.py(inclusive share off_81b47080), 2 interleaved pairs, the median.times after the stop.
How to reproduce: as How to reproduce;
HOS_FPS_LOG=1;HOS_FPS_CLOTH=0for the before column.HOS_FPS_CLOTH=0: this PR @5ddc9a7b5ddc9a7bf_81b47080, % of a core (run 1 / run 2, median)HOS_FPS_CLOTH=0, 60 capHOS_FPS_CLOTH=0: 05bbcfd5, 18 fps5ddc9a7b, 18 fpsTimes are the shots' present times after the stop (estimates from sampled frames, not measured settling times).
Steam Deck
Hardware: Steam Deck OLED, 16 GB (AMD Custom GPU 0932, RADV VANGOGH, Mesa 26.2.0-devel git 5c65d4fc31), SteamOS 3.9.5
(build 20261023.100), Game Mode, handheld on AC, 15 W power cap, GPU profile_peak
Build: this PR @
5ddc9a7b, built natively for Linux (Longshot's Linux build image, tools.lock's tools,RX_MARCH=x86-64-v3;longshotsha256 fee0f163…,longshot_vk.soc0b77984…)Scene: Kokiri Forest, the owner's own settings (render at 100%, frame generation off), 1280x800 at 90 Hz, about 18 fps
Method: standing, 45 s windows; a warm-up of each arm, then
=0, unset, unset,=0(4 measured windows and 2 warm-ups,all valid); frame times from the frame log, the process's CPU time per game frame (the bridge's frame counter) and GPU time a
frame from the renderer; then a scripted 30-frame run and stop with every present shot. Power-limit (FPPT) throttle flags
were set in 2-7% of the samples of the measured windows.
HOS_FPS_CLOTH=0: this PR @5ddc9a7b5ddc9a7bHOS_FPS_CLOTH=0: this PR @5ddc9a7b5ddc9a7bNo obvious stretching or clipping in the inspected frames (up to +0.67 s); these sequences are not a general stability test.

The times (+0.2 s, +0.45 s, +0.67 s) are estimates from the sampled presents' game times, not measured settling times.
About the PC's CPU sample: a WSL session not part of the test started at 23:14:28 during it, and the second
=1run shows higherworker-thread totals (69.7% against 46–51% of a core), so it shows neither a cost nor its absence. Also tried and rejected:
multiplying the substeps by the step as well (4× at 18 fps) looked the same and took the solve from about 6% to about 26% of
a core (about +11.5 ms of CPU a frame).
Flags and settings
One new switch, to compare against the game's behaviour.
HOS_FPS_CLOTH0,off,false,no: the game's0only to compareTesting
Tested:
python -I -B tests/run_all.pyon5ddc9a7b: 624 pass, 46 fail, 52 skipped. The same 46 fail on main @544229a2(623 pass), so this PR adds no failure; they are listed below.
tests/test_oot_cloth_time.pyfails on main and passeshere. Six mutants fail it: no scaling, scaling at steps of 1 or less, no upper bound, NaN let through,
atoiparsing, andthe default off.
5ddc9a7b, headless, the route above at an 18 fps engine step,=0and=1(log and CPU samples, 2 pairs) and=1with shots. The lift applied the site once(
oot_patches: the cloth's time below 60 fps in code_024.c, no warning).5ddc9a7b(Longshot's Linux build image, tools.lock's tools,RX_MARCH=x86-64-v3) finished with thesite applied and no warnings (
longshotsha256 fee0f163…,longshot_vk.soc0b77984…).=0against unset, 2 interleaved 45 swindows each after a warm-up, the log lines, and every present around a stop (Measurements).
Not tested:
Must be tested: None.
Risks
What could break: while the engine's step is over 1, every character's cloth (Link's cap, NPC clothes) steps by it, with
substeps up to 4 times as long as at 60 fps (the host caps the step at 4). At 18 fps nothing unstable was seen in Kokiri
Forest, but no other area was played, and the same solve count doesn't prove the cloth is stable everywhere.
Turning it off:
HOS_FPS_CLOTH=0, or revert.Compatibility: nothing changes for saves, options, caches or the vk ABI. The lifted code changes, so the game is translated
again on update, as with any
oot_patches.pychange.Issues
No issue filed; the tracker was searched (cloth, hat, Link's cap, floaty, low fps, frame step). Seen by dukenheimer on his
Steam Deck.
Checklist
Everyone
type(scope): description) of the status line's type.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.docs/tested/for each new measured run (format indocs/tested-configurations.md): nine files, one a run(the Deck's 4 measured windows, the PC's 5 runs of the final build), in their own commit. Each passes
scripts/tested_configurations.py's row reader;tests/test_tested_configurations.pyfails on main already, on a file from #1256 with six rows and a Windows line-ending case.mainand passing here.tests/that reads changed source updated in this PR, not weakened.The 46 checks that fail on main @
544229a2and on this branch: test_auto_handheld, test_bug_report_defaults, test_cpu_report,test_crash_dialog, test_crt_options, test_damage_debug_menu, test_discover, test_display_startup_failure,
test_dlss_feature_size, test_failed_compile_keeps_objects, test_framegen_preset, test_fsr_uniform_ownership,
test_guest_imported, test_hud_layout_row, test_import_reach, test_invalidate_vcore, test_job_queue, test_lift_lookups,
test_linux_preflight, test_linux_pressure, test_mirror_budget, test_missing_nup, test_pads_after_menu,
test_parallel_init_order, test_pending_guest_import, test_perf_report, test_pipeline_play_cache, test_present_thread,
test_profiling_mode, test_readback_timeout_source, test_recorder_sync, test_replay_write_order, test_rumble_menu,
test_run_all_changed, test_slow_frames, test_staging_burst, test_switch_table, test_target_image_pool,
test_tested_configurations, test_upscaler_round_trip, test_upscaler_rows, test_vcore_escape, test_vk_occlusion_queries,
test_vk_swapchain_compat, test_walk_key, test_walk (all under tests/).
Tested in game: Windows 11, RTX 5090 (NVIDIA 621.14): a full build of
5ddc9a7b, headless, Kokiri Forest at about 18 fps (HOS_FRAME_SLEEP_MS=53), HOS_FPS_CLOTH=0 against unset: the oot: cloth time line follows the engine step (55.6-66.7 ms against 16.67 ms) and Link's cap settles by about +0.2 s after a stop instead of flaring out. Steam Deck OLED (SteamOS 3.9.5, RADV, handheld on AC): a native Linux build of5ddc9a7b, Kokiri Forest at about 18 fps, the same A/B: the same in the stills and the log, with fps, median frame time, process CPU and GPU time unchanged within 2 runs per arm.The stills (Link's cap around a stop, crops of shots taken every present; times are the shots' present times after the stop, estimates from sampled frames).
PC, Windows 11, RTX 5090. Rows: the 60 fps reference (05bbcfd5,
HOS_FPS_CLOTH=0, 60 cap); Before,HOS_FPS_CLOTH=0: 05bbcfd5, 18 fps (the same unscaled path; the5ddc9a7b=0runs took no shots); After: this PR @5ddc9a7b, 18 fps.Steam Deck OLED, handheld on AC, about 18 fps. Rows: Before,
HOS_FPS_CLOTH=0: this PR @5ddc9a7b; After: this PR @5ddc9a7b.WIP: fix(fps): Link's cap and other cloth keep the game's clock below 60 fpsto fix(fps): Link's cap and other cloth keep the game's clock below 60 fpsBelow 60 fps the cloth steps as far as the rest of the game that frame, and the number of solves stays the same. I read head
e8a8137f. It applies onto current main. This can merge as it is.f_81b3aa48loads the step context's time and, while the engine's frame step is over 1 and at most 8, multiplies that time by the step. A step of 1 or less, 0, a negative step, NaN or Inf keeps the game's 60th.HOS_FPS_CLOTH=0(also off, false or no) does the same. The fixed 1/60 mode is not patched. The site has to be found once, or the lift warns and leaves it. The game-free test runs the patched frame-data lines: the substeps add up to the scaled time, the counts stay the game's, and a second setup from the same context matches. The played code is5ddc9a7b; the tip only adds the measured rows, one file each. On that build, at about 18 fps, the cloth's time follows the step on Windows and on the Steam Deck, and the cap settles instead of flaring out. Above 60 fps the cloth is unchanged.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.