fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame #3242

Merged
HumanBean merged 2 commits from llun/Longshot:fix/cloth-delta-time into main 2026-12-05 17:07:55 +00:00
Member

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:

  • Too fast (main today, since PR 3206): every frame solves, and each solve steps the cloth a whole 60th of a second. At 130 fps the cloth runs about twice as fast as on the console, so hair and clothes sway too much (#2987).
  • Jittery (PR 3122's default, 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_60 stays, with the same two values: unset or 0 is now delta time (it was the game's every-frame 60th, main's behaviour today, which runs too fast and is gone), 1 is 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_seconds and cloth_solve in game/crates/game-core/src/fixes/high_fps.rs (the module comment's cloth paragraph says why), and the HOS_FPS_CLOTH_60 row in gpu/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), with HOS_FPS_LOG=1:

  • Lost Woods (child) and the Market (child): the game ran each spot 60 s after the warm-up, 6 runs or more each, in delta time, the 60-a-second gate and main's every-frame 60th (Measurements). The log shows what each does: delta 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 way cloth time 16.67 ms ... frame step 0.464 (each solve a 60th); the gate cloth solved 210 of the last 600 solve jobs (step 0.347, ...). No crash, no warning.
  • This head (HOS_FPS_CLOTH_60 unset and =1): one run each in Lost Woods as the child, 60 s after the warm-up: unset 154.6 fps, the log's game: cloth time 6.47 ms (the game's 16.67 ms: frame step 0.388; ...); =1 160.1 fps, game: cloth solved 210 of the last 600 solve jobs (step 0.355, HOS_FPS_CLOTH_60; ...) with each solve cloth time 16.67 ms. No crash, no warning. mise run dev -- smoke: PASS (in play from kokiri-start, 900 frames, the menu opened).
  • By eye (this head, the same PC, Uncapped, one windowed run each from a copy of a save, playing by hand): with HOS_FPS_CLOTH_60 unset (about 105 fps, the log's cloth 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.
  • Checks: the new test the_cloth_steps_by_the_frames_own_time_above_60_fps fails 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-core 411 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 --check and test_switch_table pass.
  • mise run test on Windows: 845 passed, 14 failed, 52 skipped. Not this change: 10 fail on clean main 3a0f7d8f7 too (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.py names the game), test_sync_watch_event, test_turf_budget, test_ui_renderer; test_lifter's only failure is api's a_walked_reshade_folder_counts_a_change_once_two_walks_agree, failing on main; test_present_semaphores, test_invalidate_vcore and test_stack_commit failed 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-deps on game-core.

Still to test:

  • Windows, any GPU, a cap of 120 to 165 against a cap of 60: walk, run and strafe locked on as Link (Kokiri Forest, Kakariko), expecting the hair and cap to sway as much as at 60 (smoothness seen above; by hand: a still picture cannot show it)
  • Any GPU, a cap above 120: the post-Ganondorf ending's cutscenes, expecting the hair and clothes to sway as at 60 (#2987) (by hand)
  • Linux, AMD (RADV) and the Steam Deck: Lost Woods as the child at a cap of 240 with HOS_FPS_LOG=1, expecting cloth time lines 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)
  • Near King Zora (Zora's Domain, the stairs behind him): the heaviest cloth PR 1628 found; its cost with delta time against 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 frame on 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-way HOS_FPS_CLOTH_MODE: unset is this head's default, 60 this head's HOS_FPS_CLOTH_60=1, and frame main'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 ab wrote 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.

Lost Woods, child (median of 3) Before: main's way, every frame a 60th (frame) @ 209e9f342 After: this PR, delta time @ 209e9f342
fps (runs) 155.1 (155.1, 159.1, 123.7) 156.3 (156.3, 156.8, 153.1)
game thread, ms a frame 6.13 (6.13, 5.88, 7.95) 6.10 (6.03, 6.10, 6.21)
Lost Woods, child (median of 3) PR 3122's gate, HOS_FPS_CLOTH_60=1 (60) @ 209e9f342 This PR, delta time @ 209e9f342
fps (runs) 149.3 (149.3, 156.0, 103.5) 151.6 (152.0, 149.6, 151.6)
game thread, ms a frame 6.13 (6.13, 6.06, 9.47) 6.28 (6.28, 6.33, 6.27)
Market, child (median of 5) Before: main's way, every frame a 60th (frame) @ 209e9f342 After: this PR, delta time @ 209e9f342
fps (runs) 122.3 (121.1, 123.4, 123.1, 120.1, 122.3) 123.9 (124.5, 119.6, 121.6, 127.3, 123.9)
game thread, ms a frame 7.84 (7.95, 7.84, 7.79, 8.00, 7.84) 7.69 (7.69, 8.01, 7.90, 7.60, 7.69)
delta:  game: cloth time 6.22 ms (the game's 16.67 ms: frame step 0.373; 351001 setups)
frame:  game: cloth time 16.67 ms (the game's 16.67 ms: frame step 0.464; 348601 setups)
60:     game: cloth solved 210 of the last 600 solve jobs (step 0.347, HOS_FPS_CLOTH_MODE=60; 343800 jobs)   (HOS_FPS_CLOTH_60 in this head)

The game-free test, before the fix (2b4872d59) and after (this head):

2b4872d59: the_cloth_steps_by_the_frames_own_time_above_60_fps ... FAILED (half a 60th stepped the cloth 16.67 ms)
head:      test result: ok. 4 passed; 0 failed (cloth tests)

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=1 remains for a slow CPU.

Risks

  • CPU: the cloth is solved every frame above 60 fps, as on main today (no change against main); against the gate it costs about 0.15 ms a frame in Lost Woods, more where there is more cloth (near King Zora, not measured) and on slower CPUs. HOS_FPS_CLOTH_60=1 brings the gate back.
  • The look: some of Havok's solving runs a fixed number of times a solve, so more solves a second could make cloth a little stiffer above 60 than on the console. Not seen; PR 1384 found 4x the substeps looked the same at 18 fps.
  • The extra pass: when a substep's length changes, Havok rescales every particle's previous position. With delta the frame step changes a little every frame, so that pass runs often; it is a loop over the particles, inside the measured cost above.
  • A cap of 60 and below: unchanged (the rule applies only to steps under 1 with a cap above 60).
  • After updating: nothing (no save, setting or cache changes). HOS_FPS_CLOTH_60=1 in a profile's environment still means the gate; =0 now means delta time, where it meant the game's every-frame 60th.
  • Turning it off: 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

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A switch added or changed: it ships at the default the measurements chose, with its row in gpu/vk/switches.def.
  • A check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (game-core: Windows gnullvm and Linux in WSL; no path code changed)
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## 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: - **Too fast** (main today, since PR 3206): every frame solves, and each solve steps the cloth a whole 60th of a second. At 130 fps the cloth runs about twice as fast as on the console, so hair and clothes sway too much (#2987). - **Jittery** (PR 3122's default, `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_60` stays, with the same two values: unset or `0` is now delta time (it was the game's every-frame 60th, main's behaviour today, which runs too fast and is gone), `1` is 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_seconds` and `cloth_solve` in `game/crates/game-core/src/fixes/high_fps.rs` (the module comment's cloth paragraph says why), and the `HOS_FPS_CLOTH_60` row in `gpu/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`), with `HOS_FPS_LOG=1`: - Lost Woods (child) and the Market (child): the game ran each spot 60 s after the warm-up, 6 runs or more each, in delta time, the 60-a-second gate and main's every-frame 60th (Measurements). The log shows what each does: delta `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 way `cloth time 16.67 ms ... frame step 0.464` (each solve a 60th); the gate `cloth solved 210 of the last 600 solve jobs (step 0.347, ...)`. No crash, no warning. - This head (`HOS_FPS_CLOTH_60` unset and `=1`): one run each in Lost Woods as the child, 60 s after the warm-up: unset 154.6 fps, the log's `game: cloth time 6.47 ms (the game's 16.67 ms: frame step 0.388; ...)`; `=1` 160.1 fps, `game: cloth solved 210 of the last 600 solve jobs (step 0.355, HOS_FPS_CLOTH_60; ...)` with each solve `cloth time 16.67 ms`. No crash, no warning. `mise run dev -- smoke`: PASS (in play from kokiri-start, 900 frames, the menu opened). - By eye (this head, the same PC, Uncapped, one windowed run each from a copy of a save, playing by hand): with `HOS_FPS_CLOTH_60` unset (about 105 fps, the log's `cloth 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. - Checks: the new test `the_cloth_steps_by_the_frames_own_time_above_60_fps` fails 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-core` 411 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 --check` and `test_switch_table` pass. - `mise run test` on Windows: 845 passed, 14 failed, 52 skipped. Not this change: 10 fail on clean main `3a0f7d8f7` too (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.py` names the game), `test_sync_watch_event`, `test_turf_budget`, `test_ui_renderer`; `test_lifter`'s only failure is `api`'s `a_walked_reshade_folder_counts_a_change_once_two_walks_agree`, failing on main; `test_present_semaphores`, `test_invalidate_vcore` and `test_stack_commit` failed 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-deps` on game-core. **Still to test:** - Windows, any GPU, a cap of 120 to 165 against a cap of 60: walk, run and strafe locked on as Link (Kokiri Forest, Kakariko), expecting the hair and cap to sway as much as at 60 (smoothness seen above; by hand: a still picture cannot show it) - Any GPU, a cap above 120: the post-Ganondorf ending's cutscenes, expecting the hair and clothes to sway as at 60 (#2987) (by hand) - Linux, AMD (RADV) and the Steam Deck: Lost Woods as the child at a cap of 240 with `HOS_FPS_LOG=1`, expecting `cloth time` lines 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) - Near King Zora (Zora's Domain, the stairs behind him): the heaviest cloth PR 1628 found; its cost with delta time against `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 `frame` on 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-way `HOS_FPS_CLOTH_MODE`: unset is this head's default, `60` this head's `HOS_FPS_CLOTH_60=1`, and `frame` main'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 ab` wrote 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`. | Lost Woods, child (median of 3) | Before: main's way, every frame a 60th (`frame`) @ 209e9f342 | After: this PR, delta time @ 209e9f342 | |---|---|---| | fps (runs) | 155.1 (155.1, 159.1, 123.7) | 156.3 (156.3, 156.8, 153.1) | | game thread, ms a frame | 6.13 (6.13, 5.88, 7.95) | 6.10 (6.03, 6.10, 6.21) | | Lost Woods, child (median of 3) | PR 3122's gate, `HOS_FPS_CLOTH_60=1` (`60`) @ 209e9f342 | This PR, delta time @ 209e9f342 | |---|---|---| | fps (runs) | 149.3 (149.3, 156.0, 103.5) | 151.6 (152.0, 149.6, 151.6) | | game thread, ms a frame | 6.13 (6.13, 6.06, 9.47) | 6.28 (6.28, 6.33, 6.27) | | Market, child (median of 5) | Before: main's way, every frame a 60th (`frame`) @ 209e9f342 | After: this PR, delta time @ 209e9f342 | |---|---|---| | fps (runs) | 122.3 (121.1, 123.4, 123.1, 120.1, 122.3) | 123.9 (124.5, 119.6, 121.6, 127.3, 123.9) | | game thread, ms a frame | 7.84 (7.95, 7.84, 7.79, 8.00, 7.84) | 7.69 (7.69, 8.01, 7.90, 7.60, 7.69) | ``` delta: game: cloth time 6.22 ms (the game's 16.67 ms: frame step 0.373; 351001 setups) frame: game: cloth time 16.67 ms (the game's 16.67 ms: frame step 0.464; 348601 setups) 60: game: cloth solved 210 of the last 600 solve jobs (step 0.347, HOS_FPS_CLOTH_MODE=60; 343800 jobs) (HOS_FPS_CLOTH_60 in this head) ``` The game-free test, before the fix (`2b4872d59`) and after (this head): ``` 2b4872d59: the_cloth_steps_by_the_frames_own_time_above_60_fps ... FAILED (half a 60th stepped the cloth 16.67 ms) head: test result: ok. 4 passed; 0 failed (cloth tests) ``` 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=1` remains for a slow CPU. ## Risks - **CPU:** the cloth is solved every frame above 60 fps, as on main today (no change against main); against the gate it costs about 0.15 ms a frame in Lost Woods, more where there is more cloth (near King Zora, not measured) and on slower CPUs. `HOS_FPS_CLOTH_60=1` brings the gate back. - **The look:** some of Havok's solving runs a fixed number of times a solve, so more solves a second could make cloth a little stiffer above 60 than on the console. Not seen; PR 1384 found 4x the substeps looked the same at 18 fps. - **The extra pass:** when a substep's length changes, Havok rescales every particle's previous position. With delta the frame step changes a little every frame, so that pass runs often; it is a loop over the particles, inside the measured cost above. - **A cap of 60 and below:** unchanged (the rule applies only to steps under 1 with a cap above 60). - **After updating:** nothing (no save, setting or cache changes). `HOS_FPS_CLOTH_60=1` in a profile's environment still means the gate; `=0` now means delta time, where it meant the game's every-frame 60th. - Turning it off: `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 - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A switch added or changed: it ships at the default the measurements chose, with its row in `gpu/vk/switches.def`. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. (game-core: Windows gnullvm and Linux in WSL; no path code changed) - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A frame of half a 60th should step the Havok cloth by a 120th, and 130
frames at 130 fps by one second in all. On main every step is a whole
60th (each solve a 60th, PR 3122 solving at most 60 a second), so this
fails: half a step gives 16.67 ms.

The old line that pinned a 60th for a step of 0.5 moves into this test
with the new expectation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame
Some checks reported errors
beanstalk/approval approved by llun (reviewed)
beanstalk/any 0/1 pass, 2 error
CI / What the change needs (pull_request) Successful in 9s
CI / Third-party parts and guide screenshots (pull_request) Successful in 14s
PR description / Title and description (pull_request_target) Successful in 7s
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Successful in 16s
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Failing after 12m43s
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Failing after 1m24s
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m41s
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Successful in 10m30s
CI / Website build and checks (pull_request) Failing after 37s
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Failing after 47m44s
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Failing after 1h0m10s
11a456c9a3
Havok cloth steps the time f_81b3aa48 hands it, always a 60th. Above a
60 fps cap that left two choices: solve every frame (main since PR 3206:
smooth, but fps/60 times too fast, #2987), or solve at most 60 times a
second (PR 3122's gate, HOS_FPS_CLOTH_60=1: the right speed, but the
hair and garb jitter while Link moves, #3160, because only the simulate
operator is skipped while skinning and bone deform run every frame).

Now every frame solves and the setup's time is multiplied by the frame
step while it is under 1, as it already is over 1 below 60 fps (PR
1384): the cloth moves every frame at the console's speed. Havok
rescales each particle's previous position and works its damping out
again when the substep's length changes, so a time that changes every
frame is what it expects.

HOS_FPS_CLOTH_60=1 is still the gate, each solve a 60th. The game's own
every-frame 60th (main's default) is gone: it ran too fast.

Credits: the 60-a-second gate is cfw34683's PR 3122 after enum's PR 1628;
the below-60 time rule is dukenheimer's PR 1384; Veix found why the gate
jitters and saw real time every frame look right in game; HumanBean's
handoff for #3160 and PR 3206.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Member

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).

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).
Member

Possibly related, for context:

  • PR #1384 fix(fps): Link's cap and other cloth keep the game's clock below 60 fps — Extends its cloth time scaling rule to above 60 fps
  • PR #1628 fix(fps): Havok cloth keeps the clock above a 60 fps cap, solved at most 60 times a second (HOS_FPS_CLOTH_60=1, off by default) (#1485) — Replaces the gated cloth behavior with per-frame delta timing
Possibly related, for context: - PR #1384 fix(fps): Link's cap and other cloth keep the game's clock below 60 fps — Extends its cloth time scaling rule to above 60 fps - PR #1628 fix(fps): Havok cloth keeps the clock above a 60 fps cap, solved at most 60 times a second (HOS_FPS_CLOTH_60=1, off by default) (#1485) — Replaces the gated cloth behavior with per-frame delta timing
llun changed title from WIP: fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame to fix(cloth): above 60 fps the cloth steps by the frame's own time, every frame 2026-12-05 11:28:46 +00:00
BeanBot left a comment

Recommendation: 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)

  • L1 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.
  • L2 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: 11a456c9a3 against 3a0f7d8f7f: 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:

  • The new arithmetic test exercises the key scaling condition and the retained gate’s unscaled time.
  • The changed files contain no generated game output, API version change, or new path handling.
  • Both commits include AI-assistance trailers.

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.

**Recommendation: 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) - **L1** `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. - **L2** `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. <details> <summary>More: does it help, other systems, switches, what was read</summary> **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:** 11a456c9a3fd against 3a0f7d8f7f34: 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:** - The new arithmetic test exercises the key scaling condition and the retained gate’s unscaled time. - The changed files contain no generated game output, API version change, or new path handling. - Both commits include AI-assistance trailers. **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. </details> --- <sub>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.</sub>
@ -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();
Member

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.

**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);
Member

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.

**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.
Author
Member

@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 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.)
Member

Beanstalk test farm · ⚠️ couldn't be judged on any

Commit 11a456c · approved by llun (reviewed) · dashboard

Done (started 11:32 UTC). Comment @Beanstalk to run it again.

Target Result Reports Frame time p99 (ms), main → PR VRAM peak (MB) Crashes
any ⚠️ couldn't be judged 0 of 1 — — —
What 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.

  • Where: any (any PC, 1-2 reports).
  • title: from the title screen, then measure title for 20 s (after 5 s warm-up); 2 runs on each side.
  • hyrule-field: from the repository's save kokiri-start, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side.
  • Measured: crashes, boot time, frame times, stutters and hitches, VRAM use, the game's log.
  • The PR fails if: it crashes; or peak VRAM is more than 10% above main; or frame time (p99) is more than 15% above main.
  • Time: about 47 min of game runs per tester (8 game starts), plus the two builds.
<!-- beanstalk:sticky --> ### Beanstalk test farm · ⚠️ couldn't be judged on any Commit `11a456c` · approved by llun (reviewed) · [dashboard](https://beanstalk.magicbean.dev/prs/3242) Done (started 11:32 UTC). Comment `@Beanstalk` to run it again. | Target | Result | Reports | Frame time p99 (ms), main → PR | VRAM peak (MB) | Crashes | | --- | --- | --- | --- | --- | --- | | `any` | ⚠️ couldn't be judged | 0 of 1 | — | — | — | <details><summary>What was tested</summary> **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. - **Where:** any (any PC, 1-2 reports). - **title:** from the title screen, then measure title for 20 s (after 5 s warm-up); 2 runs on each side. - **hyrule-field:** from the repository's save `kokiri-start`, then teleport to Hyrule Field, measure field for 60 s (after 10 s warm-up); 2 runs on each side. - **Measured:** crashes, boot time, frame times, stutters and hitches, VRAM use, the game's log. - **The PR fails if:** it crashes; or peak VRAM is more than 10% above main; or frame time (p99) is more than 15% above main. - **Time:** about 47 min of game runs per tester (8 game starts), plus the two builds. </details>
Author
Member

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.

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.
HumanBean deleted branch fix/cloth-delta-time 2026-12-05 17:07:56 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!3242
No description provided.