fix(sound): above 60 fps the Lens of Truth's on and off sounds are no longer lost #2983

Merged
HumanBean merged 2 commits from cuecuemoar/Longshot:fix/lens-sfx-high-fps into main 2026-12-02 14:57:55 +00:00
Contributor

Summary

With the Frame rate cap above 60, the Lens of Truth's on and off sounds were often missing: at 144 fps, about half of 20 toggles had no sound. At a cap of 60 they always play.

How to see it on main:

  1. Get the Lens of Truth (Debug tools > Inventory, see #2980) and a Magic Meter.
  2. Set the Frame rate cap to 120 or higher.
  3. Turn the Lens on and off about 20 times.

On main, many on and off sounds are missing. With this PR, every one plays.

Why it happened: above 60 fps the gate in hos_oot_sound_gate keeps the sound manager's job (f_80435300) at 60 Hz, so on the frames it holds, the job returned at once. The Lens queues its sound as a one-frame xlink event on the game thread, and when the job skipped that frame, the event was gone before the job ran again.

What this changes:

  • Phase 0 runs on every frame. On a held frame it runs with a step of 0 handed to the engine, so the sound engine's clock still totals real time.
  • Music and song notes stay at 60 Hz. Two new jump sites in phase 0's module loops (f_80435860), sound.moduleUpdate and sound.moduleUpdateLate, skip only the music manager's and the song playbacks' note module's calls on held frames. Their existing latches (the held music change flags, the song note cue) keep counting the job's real runs.
  • Phases 1 and 2 stay held, as before.

Two other variants, both tested by ear at 144 fps:

  • Running only the sound system's update (f_8012f9c0) on held frames, with all the modules skipped, still lost about half the sounds (16 of 20 on, 10 of 20 off). The module that plays the event is in those loops, so skipping all of them is not enough.
  • Running the whole job on held frames is what cfw34683 found works, but it breaks the music and song-note checks (test_music_manager_flags, test_song_note_cue.py).

Read first: the paragraph in game/oot_high_fps.h and its four inline functions (oot_sound_held, oot_sound_phase_runs, oot_sound_job_step, oot_sound_module_held), then hos_oot_sound_gate in game/oot_high_fps.c, then hos_site_sound_module in game/oot_sites.c, then tests/test_sound_held_frames.py.

The cause was found by cfw34683 (on the issue).

Fixes #2721

Testing

Tested: Windows 10, RTX 4090, the user's own save with the Lens of Truth, in Zora's Domain, frame rate cap above 60 (about 144 fps), keyboard and controller. 20 Lens toggles in each run, counted by ear:

Build Missed on Missed off
main 468bb8d2e 7 13
Phase 0's modules all skipped on held frames (an experiment) 16 10
This PR, 268319f29 0 0

On 268319f29 the music sounded normal, and an ocarina song played correctly. The head, b49a6f952, differs from it only in two places, both from review. hos_oot_sound_gate now works out its return value while it holds sound_lock; the value is the same. The new test now takes its clang from $CLANG. So I did not repeat the by-ear count on b49a6f952. The head did run in the game for the audio-on measurement below, with the held-frame path active.

The checks:

  • The new test, tests/test_sound_held_frames.py, fails on the test commit, as on main. For example: FAIL: 144 fps: 1681 of 2880 one-frame sound events lost (the gate held the job on 1681 of 2880 frames; phase 0 reached the sound system on 0 of them). It passes on the head, b49a6f952, with 89 checks at 120, 144, 165 and 240 fps, uncapped, and capped at 60. Undoing the module skip or the step of 0 makes it fail again.
  • The existing checks tests/test_high_fps_fixes.py and tests/test_song_note_cue.py pass on the head.
  • cargo test -p sites passes on the head (53 tests), including the check that the outcome lines match the site table.
  • Linux, WSL, with --strict: the host code builds with no new warnings, and tests/run_all.py gives 828 passed and 89 failed on the head, b49a6f952, against 827 passed and 89 failed on main 468bb8d2e. The failing files are the same on both, and the one extra pass is the new test. tests/test_oot_cloth.py is among the failures on main too.

Still to test:

  • Steam Deck and Linux at a cap above 60: Lens on and off, music, an ocarina song, expecting every sound to play and the music unchanged (@Beanstalk).

Measurements

Verdict: no measurable cost, with the audio on or off. With the audio on, this PR and main differ by +2.2 fps (+1.4%) and -0.05 ms median frame time. That is inside both sides' own spread across their three runs: 156.8 to 162.0 fps for main, 157.5 to 163.9 fps for this PR. The pairs differ by -0.1, +3.0 and +1.9 fps. GPU time is the same.

Setup:

  • Windows 10, RTX 4090, NVIDIA 617.42.
  • Adult Zora's Domain on the same save, Link standing at the same spot, 2560x1440.
  • Frame rate cap Uncapped, V-Sync Off, frame generation Off.
  • Headless, with the default profile, so the audio plays as for a player. Every run's log has audio: output on the default device (4 devices), stereo.
  • Three interleaved pairs: main, this PR, main, this PR, main, this PR.
  • Each run measured RX_VK_FRAME_TRACE per-frame data over 40 s, after an 18 s settle. The table gives the median of each side's three runs.
  • The held-frame path was active in every run, for example: oot: sound job ran 224 of the last 600 frames (step 0.382, held to 60 Hz).
Audio on Before: main @ 468bb8d2e After: this PR @ b49a6f952
fps, average 157.6 (157.6 / 156.8 / 162.0) 159.8 (157.5 / 159.8 / 163.9)
1% low 117.2 fps 121.0 fps
Median frame time 6.250 ms 6.200 ms
p99 frame time 7.850 ms 7.850 ms
GPU time a frame 4.6 ms 4.6 ms
Main thread CPU a frame 1.722 ms 1.740 ms

The first measurement used the headless test profile, which sets HOS_AUDIO=0. It was the same setup otherwise, with this PR at 268319f29. It also showed no cost:

Audio off (HOS_AUDIO=0) Before: main @ 468bb8d2e After: this PR @ 268319f29
fps, average 165.7 (164.7 / 165.7 / 165.9) 166.5 (166.5 / 166.5 / 167.1)
1% low 128.8 fps 134.3 fps
Median frame time 6.000 ms 5.970 ms
p99 frame time 6.850 ms 6.840 ms
GPU time a frame 4.50 ms 4.50 ms
Main thread CPU a frame 1.712 ms 1.684 ms

Risks

  • What could break: above 60 fps, phase 0's other modules now run on every frame with a step of 0. A module that counted its own calls, rather than reading the step, would run faster.
    • The music manager and the song notes, the two known to count runs, stay at 60 Hz.
    • In game, the music, the ocarina and the Lens sounded right.
  • At a cap of 60: nothing changes. The gate never holds a frame there.
  • Turning it off: there is no switch; a revert is enough.
  • For players: nothing changes in saves, longshot_options.ini or the caches.

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). (The strict suite on Linux: the failures are the same as main's, and test_oot_cloth.py 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 check under tests/ that reads changed source is updated, not weakened.
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VxeaZm4vGmQAmJWyCvQFuA

## Summary With the Frame rate cap above 60, the Lens of Truth's on and off sounds were often missing: at 144 fps, about half of 20 toggles had no sound. At a cap of 60 they always play. **How to see it on main:** 1. Get the Lens of Truth (Debug tools > Inventory, see #2980) and a Magic Meter. 2. Set the Frame rate cap to 120 or higher. 3. Turn the Lens on and off about 20 times. On main, many on and off sounds are missing. With this PR, every one plays. **Why it happened:** above 60 fps the gate in `hos_oot_sound_gate` keeps the sound manager's job (`f_80435300`) at 60 Hz, so on the frames it holds, the job returned at once. The Lens queues its sound as a one-frame xlink event on the game thread, and when the job skipped that frame, the event was gone before the job ran again. **What this changes:** - **Phase 0 runs on every frame.** On a held frame it runs with a step of 0 handed to the engine, so the sound engine's clock still totals real time. - **Music and song notes stay at 60 Hz.** Two new jump sites in phase 0's module loops (`f_80435860`), `sound.moduleUpdate` and `sound.moduleUpdateLate`, skip only the music manager's and the song playbacks' note module's calls on held frames. Their existing latches (the held music change flags, the song note cue) keep counting the job's real runs. - **Phases 1 and 2 stay held**, as before. **Two other variants, both tested by ear at 144 fps:** - Running only the sound system's update (`f_8012f9c0`) on held frames, with all the modules skipped, still lost about half the sounds (16 of 20 on, 10 of 20 off). The module that plays the event is in those loops, so skipping all of them is not enough. - Running the whole job on held frames is what cfw34683 found works, but it breaks the music and song-note checks (`test_music_manager_flags`, `test_song_note_cue.py`). **Read first:** the paragraph in `game/oot_high_fps.h` and its four inline functions (`oot_sound_held`, `oot_sound_phase_runs`, `oot_sound_job_step`, `oot_sound_module_held`), then `hos_oot_sound_gate` in `game/oot_high_fps.c`, then `hos_site_sound_module` in `game/oot_sites.c`, then `tests/test_sound_held_frames.py`. The cause was found by cfw34683 (on the issue). Fixes #2721 ## Testing **Tested:** Windows 10, RTX 4090, the user's own save with the Lens of Truth, in Zora's Domain, frame rate cap above 60 (about 144 fps), keyboard and controller. 20 Lens toggles in each run, counted by ear: | Build | Missed on | Missed off | |---|---|---| | main 468bb8d2e | 7 | 13 | | Phase 0's modules all skipped on held frames (an experiment) | 16 | 10 | | This PR, 268319f29 | 0 | 0 | On 268319f29 the music sounded normal, and an ocarina song played correctly. The head, b49a6f952, differs from it only in two places, both from review. `hos_oot_sound_gate` now works out its return value while it holds `sound_lock`; the value is the same. The new test now takes its clang from `$CLANG`. So I did not repeat the by-ear count on b49a6f952. The head did run in the game for the audio-on measurement below, with the held-frame path active. The checks: - **The new test**, `tests/test_sound_held_frames.py`, fails on the test commit, as on main. For example: `FAIL: 144 fps: 1681 of 2880 one-frame sound events lost (the gate held the job on 1681 of 2880 frames; phase 0 reached the sound system on 0 of them)`. It passes on the head, b49a6f952, with 89 checks at 120, 144, 165 and 240 fps, uncapped, and capped at 60. Undoing the module skip or the step of 0 makes it fail again. - **The existing checks** `tests/test_high_fps_fixes.py` and `tests/test_song_note_cue.py` pass on the head. - **`cargo test -p sites`** passes on the head (53 tests), including the check that the outcome lines match the site table. - **Linux, WSL, with `--strict`:** the host code builds with no new warnings, and `tests/run_all.py` gives 828 passed and 89 failed on the head, b49a6f952, against 827 passed and 89 failed on main 468bb8d2e. The failing files are the same on both, and the one extra pass is the new test. `tests/test_oot_cloth.py` is among the failures on main too. **Still to test:** - Steam Deck and Linux at a cap above 60: Lens on and off, music, an ocarina song, expecting every sound to play and the music unchanged (@Beanstalk). ## Measurements **Verdict:** no measurable cost, with the audio on or off. With the audio on, this PR and main differ by +2.2 fps (+1.4%) and -0.05 ms median frame time. That is inside both sides' own spread across their three runs: 156.8 to 162.0 fps for main, 157.5 to 163.9 fps for this PR. The pairs differ by -0.1, +3.0 and +1.9 fps. GPU time is the same. **Setup:** - Windows 10, RTX 4090, NVIDIA 617.42. - Adult Zora's Domain on the same save, Link standing at the same spot, 2560x1440. - Frame rate cap Uncapped, V-Sync Off, frame generation Off. - Headless, with the default profile, so the audio plays as for a player. Every run's log has `audio: output on the default device (4 devices), stereo`. - Three interleaved pairs: main, this PR, main, this PR, main, this PR. - Each run measured `RX_VK_FRAME_TRACE` per-frame data over 40 s, after an 18 s settle. The table gives the median of each side's three runs. - The held-frame path was active in every run, for example: `oot: sound job ran 224 of the last 600 frames (step 0.382, held to 60 Hz)`. | Audio on | Before: main @ 468bb8d2e | After: this PR @ b49a6f952 | |---|---|---| | fps, average | 157.6 (157.6 / 156.8 / 162.0) | 159.8 (157.5 / 159.8 / 163.9) | | 1% low | 117.2 fps | 121.0 fps | | Median frame time | 6.250 ms | 6.200 ms | | p99 frame time | 7.850 ms | 7.850 ms | | GPU time a frame | 4.6 ms | 4.6 ms | | Main thread CPU a frame | 1.722 ms | 1.740 ms | The first measurement used the headless test profile, which sets `HOS_AUDIO=0`. It was the same setup otherwise, with this PR at 268319f29. It also showed no cost: | Audio off (`HOS_AUDIO=0`) | Before: main @ 468bb8d2e | After: this PR @ 268319f29 | |---|---|---| | fps, average | 165.7 (164.7 / 165.7 / 165.9) | 166.5 (166.5 / 166.5 / 167.1) | | 1% low | 128.8 fps | 134.3 fps | | Median frame time | 6.000 ms | 5.970 ms | | p99 frame time | 6.850 ms | 6.840 ms | | GPU time a frame | 4.50 ms | 4.50 ms | | Main thread CPU a frame | 1.712 ms | 1.684 ms | ## Risks - **What could break:** above 60 fps, phase 0's other modules now run on every frame with a step of 0. A module that counted its own calls, rather than reading the step, would run faster. - The music manager and the song notes, the two known to count runs, stay at 60 Hz. - In game, the music, the ocarina and the Lens sounded right. - **At a cap of 60:** nothing changes. The gate never holds a frame there. - **Turning it off:** there is no switch; a revert is enough. - **For players:** nothing changes in saves, `longshot_options.ini` or the caches. ## 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). (The strict suite on Linux: the failures are the same as main's, and `test_oot_cloth.py` 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 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. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VxeaZm4vGmQAmJWyCvQFuA
The Lens of Truth's on and off sounds are often lost at 144 fps: the gate holds the sound job to 60 Hz and returns at once on
the frames between its runs, so an xlink event the game queues for one frame on such a frame never reaches the sound system.
The check runs an authored job (phase 0's step load, f_80435860's two module loops, the sound system's update) with the
sound sites' hooks as the lift lowers them over game/oot_high_fps.c, and fails on main at every partial step.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZm4vGmQAmJWyCvQFuA
fix(sound): above 60 fps the sound job's phase 0 runs on the frames its gate holds too, with a step of 0, so the Lens of Truth's on and off sounds are no longer lost (#2721)
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 8s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
268319f292
Above a 60 fps cap the gate holds the sound job (f_80435300) to 60 Hz, and on the frames between its runs the job returned at
once: a sound event the game queues for one frame on such a frame (the Lens's xlink GlassTruth_On and GlassTruth_Off) never
reached the sound system. Phase 0 now runs on every frame, handed a step of 0 on a held frame (sound.jobStep); phases 1 and 2
stay held. In f_80435860's two module loops the music manager and the song playbacks' note module are skipped on a held frame
(the new jump sites sound.moduleUpdate and sound.moduleUpdateLate), so the music clock, its change flags and the song's note
flag still count the job's real runs. In game at 144 fps none of about 20 Lens toggles lost its sound (many did on main); a run
that skipped every module on held frames still lost them.

tests/test_high_fps_fixes.py and tests/test_song_note_cue.py model the music manager and the note module in phase 0 as the
game calls them, skipped where the host says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VxeaZm4vGmQAmJWyCvQFuA
Author
Contributor

Tested in game: Windows 10, RTX 4090 (NVIDIA 617.42), adult Zora's Domain on the user's own save, Frame rate cap above 60 (~144 fps): 20 Lens of Truth toggles each, counted by ear. main 468bb8d2e missed 7 on / 13 off; this head 268319f29 missed 0 / 0. Music normal and an ocarina song played correctly on this head.

Tested in game: Windows 10, RTX 4090 (NVIDIA 617.42), adult Zora's Domain on the user's own save, Frame rate cap above 60 (~144 fps): 20 Lens of Truth toggles each, counted by ear. main 468bb8d2e missed 7 on / 13 off; this head 268319f29 missed 0 / 0. Music normal and an ocarina song played correctly on this head.
Author
Contributor

@Beanstalk On Steam Deck and on Linux with the Frame rate cap above 60: turn the Lens of Truth on and off about 20 times; expecting every on and off sound to play, the music unchanged and an ocarina song played correctly.

@Beanstalk On Steam Deck and on Linux with the Frame rate cap above 60: turn the Lens of Truth on and off about 20 times; expecting every on and off sound to play, the music unchanged and an ocarina song played correctly.
Member

@cuecuemoar only members of BigBeans can start the farm.

One of them can approve this request by reacting 👍 to it or to this comment. This request was for 268319f, and the PR has changed since (b49a6f9), so a 👍 no longer approves it. Comment @Beanstalk again to ask for the new commit.

@cuecuemoar only members of `BigBeans` can start the farm. ~~One of them can approve this request by reacting 👍 to it or to this comment.~~ This request was for `268319f`, and the PR has changed since (`b49a6f9`), so a 👍 no longer approves it. Comment `@Beanstalk` again to ask for the new commit.
Member
@review
BeanBot left a comment

Recommendation: Request changes. The Lens sounds played in the reported Windows run, but the new gate return reads shared state outside its lock. The cost with audio enabled and the Linux and Steam Deck behavior also remain unmeasured.

Phase 0 now runs on held frames to capture one-frame sound events, while music and note modules remain gated. This fixes the reported Lens sound loss in the tested scene, at the cost of extra module work and hook calls above 60 fps.

Blocking (1): must change before merging.

  1. L1 game/oot_high_fps.c:66: The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock. (more on the line) Do: Compute the phase's return value from the local run while holding the lock, and return that saved value.

Should fix (1): not blocking, but worth doing before merging.

  • L4 tests/test_sound_held_frames.py:277: The new test defaults to clang without honoring CC. (more on the line) Do: Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint.

Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)

  • L2 game/oot_sites.c:272: The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates. (more on the line) Do: Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results. (@fix does its part first: Reduce or avoid the additional held-frame module work if it can be narrowed to the event-processing path.)
  • L3 game/oot_high_fps.h:195: The changed sound path has not yet been exercised on Linux or Steam Deck. (more on the line) Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.

@fix can do L1, L2 and L4.

Checks: Still running: 10 checks.

More: does it help, other systems, switches, what was read

Does it help: Yes for the reported case: at approximately 144 fps on Windows, main missed 7 of 20 on sounds and 13 of 20 off sounds; this head missed none. The reported performance comparison used HOS_AUDIO=0, so it does not establish the cost with normal audio output.

Other systems: The phase-0 change affects other sound modules and worker-thread timing above 60 fps on both Windows and Linux. Music and one ocarina song sounded right in the Windows run; Linux and Steam Deck runs are pending. GPU-specific rendering is not changed.

Switches: None added, changed or removed.

Reviewed: 268319f292 against 468bb8d2ee: Read the repository rules and PR template, commit messages, diff, changed sound logic and new test, and the relevant hook and test infrastructure. Skimmed the large site tables and existing test files; no generated files or translations changed. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance.
  • No switch, renderer API, shader or third-party change is present.
  • The new fixture exercises held and running frames and checks the step and module skips.
  • The reported Windows game run reproduces the original symptom on the base and checks the head.

Testing: Read-only review; no tests or project code were run. The supplied CI checks are still running.

Overlaps and merge order: Not checked; network access is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The Lens sounds played in the reported Windows run, but the new gate return reads shared state outside its lock. The cost with audio enabled and the Linux and Steam Deck behavior also remain unmeasured. Phase 0 now runs on held frames to capture one-frame sound events, while music and note modules remain gated. This fixes the reported Lens sound loss in the tested scene, at the cost of extra module work and hook calls above 60 fps. **Blocking (1)**: must change before merging. 1. **L1** `game/oot_high_fps.c:66`: The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock. (more on the line) **Do:** Compute the phase's return value from the local run while holding the lock, and return that saved value. **Should fix (1)**: not blocking, but worth doing before merging. - **L4** `tests/test_sound_held_frames.py:277`: The new test defaults to clang without honoring CC. (more on the line) **Do:** Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint. **Testing before merging (2)** (runs on the systems it can change; it doesn't hold the recommendation) - **L2** `game/oot_sites.c:272`: The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates. (more on the line) **Do:** Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results. *(`@fix` does its part first: Reduce or avoid the additional held-frame module work if it can be narrowed to the event-processing path.)* - **L3** `game/oot_high_fps.h:195`: The changed sound path has not yet been exercised on Linux or Steam Deck. (more on the line) **Do:** Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results. `@fix` can do L1, L2 and L4. **Checks:** Still running: 10 checks. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes for the reported case: at approximately 144 fps on Windows, main missed 7 of 20 on sounds and 13 of 20 off sounds; this head missed none. The reported performance comparison used HOS_AUDIO=0, so it does not establish the cost with normal audio output. **Other systems:** The phase-0 change affects other sound modules and worker-thread timing above 60 fps on both Windows and Linux. Music and one ocarina song sounded right in the Windows run; Linux and Steam Deck runs are pending. GPU-specific rendering is not changed. **Switches:** None added, changed or removed. **Reviewed:** 268319f2923f against 468bb8d2eee7: Read the repository rules and PR template, commit messages, diff, changed sound logic and new test, and the relevant hook and test infrastructure. Skimmed the large site tables and existing test files; no generated files or translations changed. docs/review-checklist.md and ../Tooling/AGENTS.md were absent.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance. - No switch, renderer API, shader or third-party change is present. - The new fixture exercises held and running frames and checks the step and module skips. - The reported Windows game run reproduces the original symptom on the base and checks the head. **Testing:** Read-only review; no tests or project code were run. The supplied CI checks are still running. **Overlaps and merge order:** Not checked; network access is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
@ -62,3 +64,3 @@
hos_log("oot: sound job ran %lld of the last 600 frames (step %.3f%s)", ran, step,
oot_sound_partial(step, t) ? ", held to 60 Hz" : "");
return run;
return oot_sound_phase_runs(&sound_gate, phase);
Member

L1 (blocking): The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock.

When: If a phase-1 or phase-2 callback is returning as a phase-0 callback changes the gate, the unlocked read races with that write and can return the other frame's decision; this is also a C data race.

Do: Compute the phase's return value from the local run while holding the lock, and return that saved value.

**L1** (blocking): The return reads sound_gate.run after releasing sound_lock, while another phase can write it under the lock. *When:* If a phase-1 or phase-2 callback is returning as a phase-0 callback changes the gate, the unlocked read races with that write and can return the other frame's decision; this is also a C data race. **Do:** Compute the phase's return value from the local run while holding the lock, and return that saved value.
@ -183,0 +192,4 @@
static inline int oot_sound_held(const OotSoundGate *g) {
return !g->run;
}
Member

L3 (should fix): The changed sound path has not yet been exercised on Linux or Steam Deck.

When: At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct.

Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.

**L3** (should fix): The changed sound path has not yet been exercised on Linux or Steam Deck. *When:* At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct. **Do:** Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.
game/oot_sites.c Outdated
@ -264,2 +269,4 @@
}
/* sound.moduleUpdate and sound.moduleUpdateLate (jump, before phase 0's call of a module, x0 the module): non-zero skips the
call of the music manager or the song playbacks' note module on a frame the gate held */
Member

L2 (should fix): The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates.

When: Above 60 fps, phase 0 and its module hooks run on held frames while a normal player also has audio output active; the reported headless runs do not measure that combination.

Do: Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results.

**L2** (should fix): The performance comparison disables audio output, so it does not measure the full player workload affected by the extra sound updates. *When:* Above 60 fps, phase 0 and its module hooks run on held frames while a normal player also has audio output active; the reported headless runs do not measure that combination. **Do:** Repeat interleaved base and head runs with normal audio enabled in the target and a heavy scene, reporting frame-time and low-fps results.
@ -0,0 +274,4 @@
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--cc", default="clang")
Member

L4 (should fix): The new test defaults to clang without honoring CC.

When: A developer invoking the test with CC set to an available compiler still invokes clang; if clang is not on PATH the test fails before checking the fix.

Do: Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint.

**L4** (should fix): The new test defaults to clang without honoring CC. *When:* A developer invoking the test with CC set to an available compiler still invokes clang; if clang is not on PATH the test fails before checking the fix. **Do:** Honor CC for the fixture compiler while retaining the explicitly required clang for the generated hook IR, and document any compiler constraint.
cuecuemoar force-pushed fix/lens-sfx-high-fps from 268319f292
Some checks failed
beanstalk/approval waiting for a BigBean's 👍 on the request
PR description / Title and description (pull_request_target) Successful in 8s
CI / What the change needs (pull_request) Has been cancelled
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Has been cancelled
CI / Third-party parts and guide screenshots (pull_request) Has been cancelled
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Has been cancelled
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Has been cancelled
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Has been cancelled
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Has been cancelled
CI / Website build and checks (pull_request) Has been cancelled
to b49a6f9525
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 5s
beanstalk/approval changed since the request: ask again
2026-12-02 04:44:39 +00:00
Compare
Author
Contributor

Pushed b49a6f952. It replaces 268319f29 and is still on main 468bb8d2e. Main has moved one commit since, and that commit does not touch these files. The review's changes are folded into the PR's two commits: test 7416c9b07, fix b49a6f952.

L1 (blocking), game/oot_high_fps.c: fixed. hos_oot_sound_gate now works out its answer, oot_sound_phase_runs, while it holds sound_lock, and returns that saved value. The answer is the same as before. The only difference is that it can no longer read a gate another phase is changing.

L4, the test's compiler: changed, but not to CC. The fixture has to be compiled with clang. It links the hooks' object, which uses native TLS, and mingw's gcc can't link that (tests/sitehooks.py, its docstring). With CC=gcc, honoring CC would break the test instead of fixing it. So --cc now defaults to $CLANG, the same variable tests/run_all.py uses for {clang}. Without it, the test uses the checkout's own tools/llvm clang, then the clang on PATH. If there is none, it fails with a message saying so. The test's docstring now explains why. On Linux the test passed both with no --cc and CLANG unset, and with --cc given.

L2, cost with the audio on: measured. I repeated the interleaved A/B with the audio on. I used the default profile, because the test profile sets HOS_AUDIO=0, and every run's log has audio: output on the default device. Main 468bb8d2e gave 157.6 fps and this PR's b49a6f952 gave 159.8 fps (medians of 3). That is inside each side's own spread (156.8 to 162.0 against 157.5 to 163.9). Median frame time was 6.250 against 6.200 ms, and p99 was 7.850 ms on both. The held-frame path was active in every run. The table is under Measurements. It is the same scene as before: adult Zora's Domain, Uncapped. I did not measure a heavier scene. The added work is a fixed set of sound-module calls on held frames, so it doesn't grow with the scene's load.
As for narrowing the work first: the "all modules skipped" variant in Testing is that narrowing, taken all the way to the sound system's update alone. By ear it still lost about half the sounds (16 of 20 on, 10 of 20 off), so the module that plays the event runs in those loops. Narrowing further, down to that one module, would mean first finding which of phase 0's modules handles xlink events. Given no measurable cost, I left that alone.

L3, Steam Deck and Linux: still open. The Test Farm request is posted above. It needs a BigBean's approval, and it stays under Still to test.

Checks on b49a6f952, Linux (WSL), --strict:

  • The host code builds with the same warnings as main (none in game/oot_high_fps.c).
  • tests/test_sound_held_frames.py fails on the test commit 7416c9b07 with FAIL: 144 fps: 1681 of 2880 one-frame sound events lost ..., and passes on the head with 89 checks.
  • tests/test_high_fps_fixes.py and tests/test_song_note_cue.py pass.
  • cargo test -p sites passes (53 tests).
  • tests/run_all.py gives 828 passed and 89 failed on the head, against 827 and 89 on main. The failing files are the same, and the one extra pass is the new test.
  • The by-ear Lens count (0 missed) was on 268319f29. The head differs from it only in the locked read above, so I did not repeat the count. The head did run in the game for the audio-on measurement.
Pushed b49a6f952. It replaces 268319f29 and is still on main 468bb8d2e. Main has moved one commit since, and that commit does not touch these files. The review's changes are folded into the PR's two commits: test 7416c9b07, fix b49a6f952. **L1 (blocking), `game/oot_high_fps.c`: fixed.** `hos_oot_sound_gate` now works out its answer, `oot_sound_phase_runs`, while it holds `sound_lock`, and returns that saved value. The answer is the same as before. The only difference is that it can no longer read a gate another phase is changing. **L4, the test's compiler: changed, but not to `CC`.** The fixture has to be compiled with clang. It links the hooks' object, which uses native TLS, and mingw's gcc can't link that (`tests/sitehooks.py`, its docstring). With `CC=gcc`, honoring `CC` would break the test instead of fixing it. So `--cc` now defaults to `$CLANG`, the same variable `tests/run_all.py` uses for `{clang}`. Without it, the test uses the checkout's own `tools/llvm` clang, then the clang on PATH. If there is none, it fails with a message saying so. The test's docstring now explains why. On Linux the test passed both with no `--cc` and `CLANG` unset, and with `--cc` given. **L2, cost with the audio on: measured.** I repeated the interleaved A/B with the audio on. I used the default profile, because the test profile sets `HOS_AUDIO=0`, and every run's log has `audio: output on the default device`. Main 468bb8d2e gave 157.6 fps and this PR's b49a6f952 gave 159.8 fps (medians of 3). That is inside each side's own spread (156.8 to 162.0 against 157.5 to 163.9). Median frame time was 6.250 against 6.200 ms, and p99 was 7.850 ms on both. The held-frame path was active in every run. The table is under Measurements. It is the same scene as before: adult Zora's Domain, Uncapped. I did not measure a heavier scene. The added work is a fixed set of sound-module calls on held frames, so it doesn't grow with the scene's load. As for narrowing the work first: the "all modules skipped" variant in Testing is that narrowing, taken all the way to the sound system's update alone. By ear it still lost about half the sounds (16 of 20 on, 10 of 20 off), so the module that plays the event runs in those loops. Narrowing further, down to that one module, would mean first finding which of phase 0's modules handles xlink events. Given no measurable cost, I left that alone. **L3, Steam Deck and Linux: still open.** The Test Farm request is posted above. It needs a BigBean's approval, and it stays under Still to test. Checks on b49a6f952, Linux (WSL), `--strict`: - The host code builds with the same warnings as main (none in `game/oot_high_fps.c`). - `tests/test_sound_held_frames.py` fails on the test commit 7416c9b07 with `FAIL: 144 fps: 1681 of 2880 one-frame sound events lost ...`, and passes on the head with 89 checks. - `tests/test_high_fps_fixes.py` and `tests/test_song_note_cue.py` pass. - `cargo test -p sites` passes (53 tests). - `tests/run_all.py` gives 828 passed and 89 failed on the head, against 827 and 89 on main. The failing files are the same, and the one extra pass is the new test. - The by-ear Lens count (0 missed) was on 268319f29. The head differs from it only in the locked read above, so I did not repeat the count. The head did run in the game for the audio-on measurement.
Member
@review
BeanBot left a comment

Recommendation: Approve. The code is ready: only testing is left. The reported Lens sound loss is fixed in the Windows test, with no measurable cost in the reported audio-on comparison. Linux and Steam Deck gameplay results are still needed. Recommend approval; not approved on the forge.

Phase 0 now processes one-frame sound events on held frames while keeping music and note modules at 60 Hz. This fixes the reported lost sounds at the cost of extra sound-module work on held frames.

Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)

  • L3 game/oot_high_fps.h:195: The changed sound path has not yet been exercised on Linux or Steam Deck. When: At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct. Do: Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results.

Since the last review (on 268319f292)
Resolved: L1 (The return reads sound_gate.run after releasing sound_lock, while another phase can write…); L2 (The performance comparison disables audio output, so it does not measure the full player w…)
Withdrawn (it was wrong): L4 (The new test defaults to clang without honoring CC.)
Still open: L3 (The changed sound path has not yet been exercised on Linux or Steam Deck.)

Checks: Still running: 10 checks.

Also noticed (1; not asked for, not blocking)
  • The reported performance comparison covers Zora's Domain but not a heavier scene.
More: does it help, other systems, switches, what was read

Does it help: Yes. At about 144 fps, the Windows test missed 7 on and 13 off sounds in 20 toggles on main, versus 0 of each on the tested PR build. Three audio-on performance runs per side showed overlapping spreads: median average fps was 157.6 on main and 159.8 on the PR, with p99 frame time 7.850 ms on both.

Other systems: The sound path runs on Windows and Linux, including Steam Deck, independently of GPU vendor. Windows gameplay covered the Lens, music and an ocarina song; Linux and Steam Deck gameplay remain untested. Other phase 0 modules now run on held frames and could behave differently if they count calls.

Switches: None added, changed or removed.

Reviewed: b49a6f9525 against 468bb8d2ee: Read the repository rules, PR template, standards, full diff, commits, sound gate and helpers, new test and sitehooks helper. Skimmed the changed site tables and existing test changes. The full changed code files and all surrounding callers were not read in full; Tooling's adjacent AGENTS.md was unavailable.; nothing run (a code review).

Checked and fine:

  • The locked return preserves phase 0's held-frame behavior.
  • The clang selection follows the shared sitehooks helper and run_all convention.
  • The reported game-free test fails on the test commit and passes on the head.

Testing: No code or tests were run during this review. The author reports Windows gameplay, Linux host checks and an audio-on comparison; CI is still running.

Overlaps and merge order: Not checked; the network is closed.


Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.

**Recommendation: Approve.** The code is ready: only testing is left. The reported Lens sound loss is fixed in the Windows test, with no measurable cost in the reported audio-on comparison. Linux and Steam Deck gameplay results are still needed. Recommend approval; not approved on the forge. Phase 0 now processes one-frame sound events on held frames while keeping music and note modules at 60 Hz. This fixes the reported lost sounds at the cost of extra sound-module work on held frames. **Testing before merging (1)** (runs on the systems it can change; it doesn't hold the recommendation) - **L3** `game/oot_high_fps.h:195`: The changed sound path has not yet been exercised on Linux or Steam Deck. *When:* At a cap above 60, these systems run phase 0 and its other sound modules on held frames too; the reported Windows run cannot show whether their output and timing remain correct. **Do:** Run the requested Lens toggles, music and ocarina checks above 60 fps on Linux and Steam Deck, and report the results. **Since the last review** (on 268319f2923f) Resolved: L1 (The return reads sound_gate.run after releasing sound_lock, while another phase can write…); L2 (The performance comparison disables audio output, so it does not measure the full player w…) Withdrawn (it was wrong): L4 (The new test defaults to clang without honoring CC.) Still open: L3 (The changed sound path has not yet been exercised on Linux or Steam Deck.) **Checks:** Still running: 10 checks. <details> <summary>Also noticed (1; not asked for, not blocking)</summary> - The reported performance comparison covers Zora's Domain but not a heavier scene. </details> <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Yes. At about 144 fps, the Windows test missed 7 on and 13 off sounds in 20 toggles on main, versus 0 of each on the tested PR build. Three audio-on performance runs per side showed overlapping spreads: median average fps was 157.6 on main and 159.8 on the PR, with p99 frame time 7.850 ms on both. **Other systems:** The sound path runs on Windows and Linux, including Steam Deck, independently of GPU vendor. Windows gameplay covered the Lens, music and an ocarina song; Linux and Steam Deck gameplay remain untested. Other phase 0 modules now run on held frames and could behave differently if they count calls. **Switches:** None added, changed or removed. **Reviewed:** b49a6f952575 against 468bb8d2eee7: Read the repository rules, PR template, standards, full diff, commits, sound gate and helpers, new test and sitehooks helper. Skimmed the changed site tables and existing test changes. The full changed code files and all surrounding callers were not read in full; Tooling's adjacent AGENTS.md was unavailable.; nothing run (a code review). **Checked and fine:** - The locked return preserves phase 0's held-frame behavior. - The clang selection follows the shared sitehooks helper and run_all convention. - The reported game-free test fails on the test commit and passes on the head. **Testing:** No code or tests were run during this review. The author reports Windows gameplay, Linux host checks and an audio-on comparison; CI is still running. **Overlaps and merge order:** Not checked; the network is closed. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.</sub>
HumanBean deleted branch fix/lens-sfx-high-fps 2026-12-02 14:57:55 +00:00
Some checks are pending
CI / What the change needs (pull_request) Blocked by required conditions
CI / Lint (pre-commit, ShellCheck, actionlint) (pull_request) Blocked by required conditions
CI / Third-party parts and guide screenshots (pull_request) Blocked by required conditions
CI / Rust (rustfmt, clippy, cargo test, end to end) (pull_request) Blocked by required conditions
CI / Host C for Windows (llvm-mingw, compile only) (pull_request) Blocked by required conditions
CI / Renderer build check (Windows, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Renderer build check (Linux, compile --only renderer, without and with FSR 4) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 1/2) (pull_request) Blocked by required conditions
CI / Game-free checks (run_all.py, part 2/2) (pull_request) Blocked by required conditions
CI / Website build and checks (pull_request) Blocked by required conditions
PR description / Title and description (pull_request_target) Successful in 5s
beanstalk/approval changed since the request: ask again
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
4 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!2983
No description provided.