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
4 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
TL;DR
Below 60 fps Link's cap floats: after he stops it swings far out and takes about a second to settle, because the game steps
the cloth a 60th of a second a frame however long the frame was. This makes the cloth step as far as the rest of the game
when frames are slow, so the cap settles about as at 60 fps. Checked at 18 fps on a PC and on the Steam Deck, with no
measurable CPU cost and nothing unstable seen in four areas, the pause menu and two area changes.
Breakdown
step (3.3/60 s at 18 fps), so the cloth lagged behind Link and over-swung.
HOS_FPS_CLOTH=0turns it off.
Forest, Hyrule Field, Kakariko, the pause menu and area changes) and on the Steam Deck (2 runs a side, stills).
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. On the PC, 3 interleaved pairs on one build (b2d6fb15,
=0against unset, 18 fps, bench lock held, idle PC) show no measurable CPU cost: the cloth solve took a median 2.95 ms a frame
with
=0and 3.15 ms unset, and the pairs differ by −0.70, +0.01 and +0.86 ms (a median of +0.01 ms), inside the=0runs'own spread of 2.47–3.85 ms; the process's CPU a game frame differs by −4.21, +1.55 and −0.56 ms (medians 200.30 and 200.76 ms).
At 18 fps in Kokiri Forest (with the pause menu), Hyrule Field and Kakariko Village, and across two area changes, nothing
unstable was seen in the inspected shots.
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 with Auto tier 5 (the game's own
upscaler: these builds have no 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; a WSL session interfered: see the 3 pairs below)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).
PC: the CPU cost, 3 interleaved pairs (after the rebase)
Build: this PR @ b2d6fb15 (on main
310e7c9d; the code of the fix is unchanged, and the PR's later rebases keptthe same cloth code), one build,
HOS_FPS_CLOTH=0againstunset. Hardware and scene as above,
HOS_FRAME_SLEEP_MS=53, headless, the same save and pinned options.Method: a route of 5 s idle, 2.5 s run, 3 s stop, 2.5 s run back, 3 s stop and 10 s idle (a 29 s window), the whole window
sampled with
HOS_SAMPLE_ALL. fps and process CPU are the window's: the process's CPU time over it, divided by the bridge'sgame frames. The cloth solve is
scripts/cpu_report.py's inclusive share off_81b47080, times the run's frame time.An unsampled warm-up of each arm, then pairs in the order
=0unset, unset=0,=0unset (17 Nov 18:54–19:01 PST).Conditions: the bench lock held; started when both build slots were free, the PC's CPU was under 20% for 60 s and WSL under
10% of a core; WSL was at 1–8% of a core at the end of each run.
HOS_FPS_CLOTH=0: this PR @ b2d6fb15f_81b47080, % of a coreNo measurable cost: the pairs' differences change sign, and they are smaller than the spread between runs of the same arm.
The cloth solve itself costs about 3 ms of CPU a frame at 18 fps on this PC, with or without the fix. The sampler adds to the
process CPU equally in both arms (the unsampled warm-ups: 184.65 and 179.93 ms a game frame, not counted). The fixed-1/60 mode
(
f_81b3a964) is in none of the 6 samples; the frame-time setup (f_81b3aa48) is in all of them.PC: other areas, the pause menu and area changes
Build: this PR @ b2d6fb15,
=0against unset, one run each, 18 fps, headless, every present shot while the route runs.Route: Kokiri Forest, the pause menu opened with PLUS for about 4 s and closed, then a 2.5 s run and stop; a teleport to Hyrule
Field (an area change, with its load) and a 3 s run and a 2 s run to the right, each to a stop; a teleport to Kakariko Village,
a 3 s walk and a 2.5 s run, each to a stop.
HOS_FPS_CLOTH=0: this PR @ b2d6fb15In the inspected shots no jitter, explosion, stretching or clipping was seen in either arm. The log's cloth time stays 16.67 ×
the step (52.63–66.67 ms) through the pause and both loads, and has no warning beyond the 7 start-up lines of every run.
Times are estimates from the shots' present times, 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 first PC CPU sample (
5ddc9a7b, 2 runs a side): a WSL session not part of the test started at 23:14:28 during it, andthe second
=1run shows higher worker-thread totals (69.7% against 46–51% of a core), so it showed neither a cost nor itsabsence; the 3 pairs above replace it. 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.pyon b2d6fb15 (then on main310e7c9d): 665 pass, 50 fail, 53 skipped. On main @310e7c9d: 663 pass, 51 fail, the same 50 andtest_longshot_ctl(a 90 s timeout there; it passes here), so this PR adds nofailure; they are listed below.
tests/test_oot_cloth_time.pyfails on main and passes here. Six mutants fail it (on5ddc9a7b): no scaling, scaling at steps of 1 or less, no upper bound, NaN let through,atoiparsing, and the default off.Main moved again after the runs: rebased onto
430eef4f(the fix commit only merged beside #1528's moving-floor carry in the same files, both kept; the other three commits=ingit range-diff), thentests/test_oot_cloth_time.pypasses andtests/test_floor_carry_step.pyandtests/test_high_fps_fixes.pypass, andrun_all.py --changedgives 42 pass, 6 fail, 2 skipped, the 6 all on main's list.warning); the CPU cost in 3 interleaved pairs, and the other areas, the pause menu and two area changes at 18 fps
(Measurements).
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:
after arriving. Other menus than the pause menu, cutscenes, combat, and adult Link.
game uses it is unknown.
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 (with the pause menu), Hyrule Field and Kakariko Village or across two area changes; cloth elsewhere (other areas,
NPC clothes up close, cutscenes) wasn't checked, and the same solve count doesn't prove it is stable everywhere.
Cost: none measurable. On the PC at 18 fps, in 3 interleaved pairs on one build, the cloth solve's CPU changed by −0.70,
+0.01 and +0.86 ms a frame (a median of +0.01 ms; the
=0runs alone spread over 2.47–3.85 ms), the process's CPU by −4.21,+1.55 and −0.56 ms a game frame (a median of −0.56 ms), and fps by +0.05, +0.10 and −0.02. On the Deck, 152.6 ms of process
CPU per bridge game frame in both arms (n=2). The cloth solve itself costs about 3 ms of CPU a frame at 18 fps on this PC,
with or without the fix.
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.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks. The CPU cost is measured in 3 interleaved pairs (none measurable) and stated in Risks; the other areas, the
pause menu and area changes are in Testing.
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): seventeen files, one arun (the Deck's 4 measured windows, the PC's 5 runs of
5ddc9a7b, and 8 of b2d6fb15: the 6 timed runs and the 2 arearuns), in their own commits; the second also corrects the first's PC settings (Auto tier 5 with the game's own upscaler,
not DLSS). Each passes
scripts/tested_configurations.py's row reader;tests/test_tested_configurations.pyfails onmain already, on a Windows line-ending case.
mainand passing here.tests/that reads changed source updated in this PR, not weakened.The 50 checks that fail on main @
310e7c9dand on this branch: test_auto_handheld, test_bug_report_defaults,test_build_long_paths, test_compute_warm_apart, test_cpu_report, test_crash_dialog, test_crt_options, test_damage_debug_menu,
test_dev_packs, test_discover, test_display_startup_failure, test_dlss_feature_size, test_draw_stream_visibility,
test_failed_compile_keeps_objects, test_fsr_image_retirement, test_fsr_uniform_ownership, test_guest_imported,
test_hud_layout_row, test_import_reach, test_invalidate_quick, test_invalidate_vcore, test_job_queue, test_libc_hooks,
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_pipeline_play_cache, test_present_thread, test_profiling_mode,
test_psychov35_fsr3_fg, test_readback_timeout_source, test_recorder_sync, test_replay_write_order, test_run_all_changed,
test_sdiv_overflow, test_slow_frames, test_staging_burst, test_switch_table, test_target_image_pool, test_tested_configurations,
test_upscaler_rows, test_vcore_escape, test_vk_occlusion_queries, test_walk, test_walk_key (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.Brought up to the ready-for-review standard (#1454): the checklist's Everyone list has two new boxes, added here from what this PR's description and comments show (please check they match what you know).
e8a8137f10a11839b55aNew commits pushed, approval review dismissed automatically according to repository settings
@HumanBean thanks: measured and checked, and the box is ticked now (details in Measurements, Testing and Risks).
HOS_FPS_CLOTH=0against unset, 18 fps, headless, 3 interleaved pairs with the bench lock held on an idle PC. The cloth solve took a median of 2.95 ms of CPU a frame with=0and 3.15 ms unset; by pair the change was −0.70, +0.01 and +0.86 ms (a median of +0.01 ms), inside the=0runs' own spread of 2.47–3.85 ms. Process CPU per game frame: medians 200.30 and 200.76 ms (pairs −4.21, +1.55, −0.56); fps 17.81 and 17.88. So no measurable cost; it's in Risks.Also rebased onto main
ef6038ab(same patches), and the older PC records' "DLSS" is corrected: these builds have none, Auto chose tier 5 with the game's own upscaler.@dukenheimer: #1485 turned out to be Havok cloth above a 60 cap: near King Zora the cloth solve (
f_81b47080) takes ~10.5 ms of CPU a frame against ~2 a few rooms away, and holds the frame at ~55 fps with a 240 cap (numbers: #1485 (comment)). This PR leaves cloth above 60 fps open: is it on your list? If not, we'd like to claim solving the cloth at most 60 times a second above a 60 cap, built on top of this PR'spatch_cloth_timeso the two don't collide.a11839b55ae418c77a6eRebased onto main
430eef4f(heade418c77a) for @TrashPanda's approval: no change in behaviour. The only conflicts were #1528's moving-floor carry landing beside the cloth fix in host/oot_high_fps.{h,c} and nx2/oot_patches.py (its function, header paragraph, patch function and report warning sit next to the cloth's); both kept as they were, nothing of either edited beyond the shared file comment naming both. The test and both docs commits are unchanged (range-diff =). tests/test_oot_cloth_time.py, test_floor_carry_step.py and test_high_fps_fixes.py pass; run_all.py --changed: 42 pass, 6 fail, all failing on main too.@enum Not on our list. #1384 deliberately leaves cloth above a 60 cap as it is: its scope is a step of more than one, below 60 fps. Please go ahead and claim stepping it at most 60 times a second above a 60 cap. Building on
patch_cloth_timesounds right to us.Two things from our side that may help:
test_oot_cloth_time) pin the below-60 behaviour, so a change above 60 should leave those passing as they are.e418c77a, on main430eef4f.If you'd like a Steam Deck run of it once it's up, ask.
@dukenheimer: thanks for the go-ahead; it's up as #1628 (stacked on this PR's
e418c77a, the last three commits are mine). One thing for this PR:tests/test_switch_table.pysaysHOS_FPS_CLOTH is read (host/oot_high_fps.c:147) and has no row in gpu/vk/switches.def. #1628 addsHOS_FPS_CLOTH_60's row right beforeHOS_FPS_LOG;HOS_FPS_CLOTH's would go just above it. Also, if the Steam Deck run you offered is still on:HOS_FPS_CLOTH_60=1at a cap above 60 in Zora's Domain (child) is the case to look at.e418c77a6edc01d2b798@enum thanks, fixed:
HOS_FPS_CLOTHnow has its row ingpu/vk/switches.def, just aboveHOS_FPS_LOG(kindkill, likeHOS_FPS_MOVIEandHOS_FPS_STEP). Headdc01d2b7, rebased on mainc507b98c.test_switch_tableno longer names it; it still fails on the same 8 switches as main.test_oot_cloth_timepasses. #1628'sHOS_FPS_CLOTH_60row would go between it andHOS_FPS_LOG.The Steam Deck run of #1628 is queued after our current Deck blocks. The Deck runs below 60 in Zora's Domain, so what it can show is no crash, the picture against main's, and the "oot: cloth solved" line, not an fps change.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.