fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame #3242
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3242
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/cloth-delta-time"
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
Above a 60 fps cap the Havok cloth (Link's cap and hair, people's clothes) had two ways to go wrong, and main has picked one of them each week:
HOS_FPS_CLOTH_60=1): at most 60 solves a second, each a 60th. The speed is right, but on the frames in between only Havok's simulate operator is skipped while skinning, bone deform and Prepare Matrices still run, so the hair and garb are drawn from particles a step behind while Link moves (#3160).This makes the cloth step by the frame's own time and solve every frame: at 150 fps each solve moves it about a 150th of a second. It moves every frame, at the console's speed. The rule already existed for slow frames (PR 1384 multiplies the cloth's time by the frame step when the step is over 1); this applies it to steps under 1 too, above a 60 cap. Havok's cloth expects a time that changes: when the substep's length changes, the game's code rescales each particle's previous position (keeping its velocity) and works its damping out again for the new length.
HOS_FPS_CLOTH_60stays, with the same two values: unset or0is now delta time (it was the game's every-frame 60th, main's behaviour today, which runs too fast and is gone),1is still PR 3122's gate, each solve a 60th, for a slow CPU or an A/B.How to see it on main: a cap above 60 (120 or more shows it best). With main's default, watch the post-Ganondorf ending's hair, or Link's cap in the wind standing still: it sways faster than at a cap of 60. With
HOS_FPS_CLOTH_60=1, walk or strafe while locked on: the hair and cap jitter.Read first:
cloth_seconds_rule,cloth_secondsandcloth_solveingame/crates/game-core/src/fixes/high_fps.rs(the module comment's cloth paragraph says why), and theHOS_FPS_CLOTH_60row ingpu/vk/switches.def.See #3160, #2987.
Credits: the 60-a-second gate is cfw34683's PR 3122 after enum's PR 1628; the below-60 time rule this extends is dukenheimer's PR 1384. Veix found why the gate jitters (only the simulate operator is skipped) and saw real time every frame look right in the game; HumanBean's handoff for #3160 named this as the fallback, and PR 3206 turned the gate off meanwhile. klimovich008 measured the gate's saving on PR 1628 and suggested smoothing it.
Testing
Tested: Windows 11 Pro, RTX 5080, NVIDIA 621.47, Ryzen 9 9900X3D. This branch's runtime over a shared base, run through the job queue, cap off (
HOS_FPS_MAX=1000), withHOS_FPS_LOG=1:game: cloth time 6.22 ms (the game's 16.67 ms: frame step 0.373; ...)(each solve the frame's own time, ~160 fps); main's waycloth time 16.67 ms ... frame step 0.464(each solve a 60th); the gatecloth solved 210 of the last 600 solve jobs (step 0.347, ...). No crash, no warning.HOS_FPS_CLOTH_60unset and=1): one run each in Lost Woods as the child, 60 s after the warm-up: unset 154.6 fps, the log'sgame: cloth time 6.47 ms (the game's 16.67 ms: frame step 0.388; ...);=1160.1 fps,game: cloth solved 210 of the last 600 solve jobs (step 0.355, HOS_FPS_CLOTH_60; ...)with each solvecloth time 16.67 ms. No crash, no warning.mise run dev -- smoke: PASS (in play from kokiri-start, 900 frames, the menu opened).HOS_FPS_CLOTH_60unset (about 105 fps, the log'scloth time 9.49 ms ... frame step 0.570) the hair and clothes looked smooth; then=1(about 130 fps,cloth solved 278 of the last 600 solve jobs) beside it. No crash in either.the_cloth_steps_by_the_frames_own_time_above_60_fpsfails on main (3a0f7d8f7: a frame of half a 60th steps the cloth 16.67 ms) and passes here; with the fix's key condition broken by hand it fails again.cargo test -p game-core411 passed; the cloth tests also build and pass on Linux (WSL, cargo 1.99.1).cargo fmt --all --check,cargo clippy -p game-core --all-targets --no-deps -D warnings,ffi-gen --check,schema-gen --checkandtest_switch_tablepass.mise run teston Windows: 845 passed, 14 failed, 52 skipped. Not this change: 10 fail on clean main3a0f7d8f7too (run there):test_present_geometry_trace,test_present_image_free,test_present_held_image,test_present_acquire_ahead(their fixtures do not compile),test_dlssg,test_no_map_reload,test_no_game_title(tests/test_lower_cs2r_depbar.pynames the game),test_sync_watch_event,test_turf_budget,test_ui_renderer;test_lifter's only failure isapi'sa_walked_reshade_folder_counts_a_change_once_two_walks_agree, failing on main;test_present_semaphores,test_invalidate_vcoreandtest_stack_commitfailed under the full suite's load and pass run alone, here and on main. build-core's clippy (unused import: note_lines) fails on main too, so clippy ran with--no-depson game-core.Still to test:
HOS_FPS_LOG=1, expectingcloth timelines below 16.67 ms and no crash (@Beanstalk linux, amd and the Steam Deck: Lost Woods as the child at a cap of 240 with HOS_FPS_LOG=1; check the log's "cloth time" lines are under 16.67 ms)HOS_FPS_CLOTH_60=1(by hand: no scene or route reaches it)Measurements
Verdict: against main, no cost in Lost Woods (the heaviest cloth of the scenes): delta and main's every-frame 60th both solve every frame. Against PR 3122's gate (
=60), delta costs about 0.15 ms of game-thread time a frame in Lost Woods (about 1 to 3 % fps at 150 fps). In the Market (5 pairs, a quiet PC) delta and main's way are the same within the noise: 123.9 against 122.3 fps, 7.69 against 7.84 ms of game thread.Baseline: main's own behaviour, every frame solved a 60th, run as
frameon this branch's first version (209e9f342) in the same runtime as the other side, so the two differ only in the cloth's time: that code path is main's default since PR 3206. The second Lost Woods table also compares PR 3122's gate (HOS_FPS_CLOTH_60=1), the cost of dropping it as the default.Setup: Windows 11 Pro (26300), RTX 5080 (NVIDIA 621.47), Ryzen 9 9900X3D;
mise run dev -- ab --env HOS_FPS_CLOTH_MODE=<frame|60> --set HOS_FPS_LOG=1 --scene <lost-woods|market>, one runtime of this branch's first version (209e9f342), each run one timing job of the queue, interleaved A B A B, 60 s measured after the warm-up, 1280x720, Render resolution 67 %, cap off; medians of the runs. That version had a three-wayHOS_FPS_CLOTH_MODE: unset is this head's default,60this head'sHOS_FPS_CLOTH_60=1, andframemain's default (every frame a 60th), dropped since; the cloth code each runs is the same. The PC was shared with other sessions' jobs in Lost Woods: two runs there (main's way's third, 123.7 fps; the gate's third, 103.5 fps) were slowed by them, so game-thread medians are given too. The Market's 5 pairs ran on a quiet PC.dev.py abwrote no measurements.md: it counts per-run handle numbers (LONGSHOT_BUILDER_PIPES,LONGSHOT_CRASH_BLOCK) as differing switches; the numbers are its per-run lines and the frame traces'game_ms.frame) @ 209e9f342HOS_FPS_CLOTH_60=1(60) @ 209e9f342frame) @ 209e9f342The game-free test, before the fix (
2b4872d59) and after (this head):Earlier, on main
ca830e895(the same PC): PR 3122's gate against every frame cost 0.23 ms of game thread a frame in Lost Woods (157.2 against 152.1 fps) and 0.11 ms in the Market (124.7 against 123.7 fps), 3 pairs each; one solve is about 0.3 to 0.4 ms there.Delta time ships as the default: it fixes both #2987 and #3160 at no cost against main, and
HOS_FPS_CLOTH_60=1remains for a slow CPU.Risks
HOS_FPS_CLOTH_60=1brings the gate back.HOS_FPS_CLOTH_60=1in a profile's environment still means the gate;=0now means delta time, where it meant the game's every-frame 60th.HOS_FPS_CLOTH_60=1(the gate); main's every-frame 60th has no switch now, a revert brings it back.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.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
Tested in game: Windows 11 Pro (26300), RTX 5080, NVIDIA 621.47, Ryzen 9 9900X3D, this branch's runtime over a shared base through the job queue, cap off: Lost Woods and the Market as the child, 60 s each after the warm-up. Default (HOS_FPS_CLOTH_60 unset): every frame solves, the log's 'cloth time 6.47 ms (the game's 16.67 ms: frame step 0.388)' at 154.6 fps; HOS_FPS_CLOTH_60=1: 'cloth solved 210 of the last 600 solve jobs' with each solve 16.67 ms. No crash, no warning; dev.py smoke PASS. Against main's every-frame 60th: no cost (Lost Woods 6.10 against 6.13 ms of game thread, Market 7.69 against 7.84 ms).
Possibly related, for context:
WIP: fix(cloth): above 60 fps the cloth steps by the frame's own time, every frameto fix(cloth): above 60 fps the cloth steps by the frame's own time, every frameRecommendation: Approve. The code is ready: only testing is left. The new time calculation is covered by a game-free test, but the reported runs do not yet show that cloth looks correct in the affected movement and cutscenes. The remaining supported-platform runs and head CI results are also needed before merge. Recommend approval; not approved on the forge.
The default advances cloth by the frame step on every solve above 60 fps, addressing excessive cloth speed while avoiding the existing gate’s held frames. It retains the gate as an alternative; the visual result and behavior across supported systems remain to be verified.
Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
game/crates/game-core/src/fixes/high_fps.rs:1039: The reported runs confirm the time passed to cloth, but do not check the visual problems this change is intended to fix. (more on the line) Do: Compare walking, running and locked-on strafing at 60 and 120–165 fps, and compare the post-Ganondorf cutscenes above 120 fps with 60 fps; record the observed motion on this head.game/crates/game-core/src/fixes/high_fps.rs:1040: The changed cloth timing has not yet been exercised on the Linux and AMD systems named in the test plan. (more on the line) Do: Run the proposed high-cap cloth checks on Linux with AMD RADV and on Steam Deck, recording the cloth-time log and visible behavior.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the player-visible fix. The test reports that 130 frames advance one second of cloth time, and the Windows log reports a 6.47 ms cloth step at 154.6 fps, but neither establishes that hair and clothing move smoothly or match their 60 fps appearance. The reported performance comparisons against an equivalent earlier branch path show overlapping run spreads.
Other systems: The hook runs in game code on Windows and Linux, independent of GPU vendor; AMD RADV and Steam Deck runs remain outstanding. The existing gate, caps at or below 60, fast-forward, and the native cloth path also depend on frame timing. The arithmetic tests cover the gate’s time rule and below-60 scaling, but do not establish their in-game appearance.
Switches: HOS_FPS_CLOTH_60 remains off by default; off now uses frame-step time on every solve, while 1 retains the 60 Hz gate. Its switch-table row is updated. The default’s visual suitability still needs the requested in-game checks.
Reviewed:
11a456c9a3against3a0f7d8f7f: Read AGENTS.md, CONTRIBUTING.md, the pull request template, docs/dev/standards.md, the diff and commit messages. Inspected the changed cloth rules, tests, switch row, hook callers and frame-time producer; the rest of high_fps.rs and switches.def were skimmed. docs/review-checklist.md and ../Tooling/AGENTS.md were absent. Reviewed the supplied description, comment and CI status.; nothing run (a code review).Checked and fine:
Testing: No code or tests were run, as requested. The author reports game-free tests and Windows in-game timing runs; all listed head CI checks are still running.
Overlaps and merge order: Not determined from the supplied information; network access was unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.
@ -1023,2 +1038,2 @@// (HOS_FPS_CLOTH, the C's A/B of this settled fix, is gone: always on)let seconds = cloth_seconds_rule(seconds_bits, step_bits, true);// (HOS_FPS_CLOTH, the C's A/B of the below-60 fix, is gone: always on)let fine = !cloth_60() && timed();L1 (should fix): The reported runs confirm the time passed to cloth, but do not check the visual problems this change is intended to fix.
When: At a high frame cap, changing the solve duration and solve frequency can change hair and clothing motion even when the accumulated time is correct; the reported Lost Woods and Market runs do not say whether the jitter or excessive sway is gone.
Do: Compare walking, running and locked-on strafing at 60 and 120–165 fps, and compare the post-Ganondorf cutscenes above 120 fps with 60 fps; record the observed motion on this head.
@ -1024,1 +1038,3 @@let seconds = cloth_seconds_rule(seconds_bits, step_bits, true);// (HOS_FPS_CLOTH, the C's A/B of the below-60 fix, is gone: always on)let fine = !cloth_60() && timed();let seconds = cloth_seconds_rule(seconds_bits, step_bits, fine);L2 (should fix): The changed cloth timing has not yet been exercised on the Linux and AMD systems named in the test plan.
When: The same game hook runs on Linux and Steam Deck, but the supplied evidence covers an NVIDIA Windows machine only; a Linux build of the arithmetic test does not exercise the game’s cloth path.
Do: Run the proposed high-cap cloth checks on Linux with AMD RADV and on Steam Deck, recording the cloth-time log and visible behavior.
@Beanstalk linux, amd (RADV) and the Steam Deck: Lost Woods as the child at a cap of 240 with HOS_FPS_LOG=1, once with HOS_FPS_CLOTH_60 unset and once with HOS_FPS_CLOTH_60=1. Check the log's "game: cloth time" lines are under 16.67 ms with it unset, and "cloth solved N of the last 600 solve jobs" lines with =1; no crash or warning in either.
(For BeanBot's L2. L1, the look by eye at 120 to 165 fps on this head, comes from a run by hand on Windows.)
Beanstalk test farm · ⚠️ couldn't be judged on any
Commit
11a456c· approved by llun (reviewed) · dashboardDone (started 11:32 UTC). Comment
@Beanstalkto run it again.anyWhat was tested
What will be tested · default plan (AI failed: the plan was refused: probe[2].value[1].none: a count is 0 when no line matches)
The AI plan failed: the plan was refused: probe[2].value[1].none: a count is 0 when no line matches; using the default plan.
kokiri-start, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side.Tested by eye on this head (for BeanBot's L1, in part): Windows, RTX 5080, Uncapped, playing by hand. With HOS_FPS_CLOTH_60 unset (about 105 fps there) the hair and clothes looked smooth, then =1 beside it. Still to test keeps the rest of L1: the sway against a cap of 60, and the post-Ganondorf cutscenes above 120 fps.