Repository navigation
audio (every game; changes present_interval display games with FPSLocker rows): no frame pace for a game on its own clock - #1945
Draft
tapionallanaire wants to merge 1 commit into
Conversation
…nt_interval display The follower (peanuts_audiosync.c) takes the game's pace from presented frames / nvn_game_fps. Under present_interval display with no present cap nvn_game_fps answers 60, so a game that reviewed FPSLocker rows run at a frame limit was read by its presented frames: Red Dead Redemption on the AYN Thor at 46 to 55 fps under the 60 limit read as a game at 0.86 of real time, the tempo sat at its 0.99 floor and the integrated lead ramped to its 0.4 s reset (median 188 ms, 28 underruns in 16 minutes), while the game itself steps by measured time (RAGE TIME::Update) and ran at real time. hle_fpslock.c records the limit its rows last wrote (dm_fpslocker_rate). hle_nvn.c nvn_game_clock_own answers whether the game keeps its own clock: present_interval display (only for games whose logic does not count frames), no present cap, and a limit written by reviewed rows. peanuts.c then passes a frame rate of 0 and pn_as_frame counts nothing: the follower sees no pace and the sound stays at real time (tempo 1, no lead). Games without rows, present_interval game and a present cap are counted as before. t_peanuts_audiosync: a game on its own clock presenting 0.86 of its rate (tempo 0.990 and a 250 ms lead before, 1.000 and 0 after). t_fpslock: the recorded limit follows the rows.
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Touches every game's audio follower path; only games with
present_interval display, reviewedfpslockerrows and no present cap behave differently (list below).Symptom. A game run at a frame limit by reviewed FPSLocker rows under
present_interval displaysounds ahead of the picture whenever the device does not hold the limit. Red Dead Redemption with its 60 fps rows (#1801 plus the 60 fps profile PR that follows it) on a hot AYN Thor at 46 to 55 fps: the follower's lines read the game at a median 0.86 of real time, the tempo sat at its 0.99 floor and the sound led the picture by a median 188 ms, up to 392 ms, with 28 underruns in 16 minutes of play.Cause.
peanuts_audiosync.ctakes the game's pace from presented frames /nvn_game_fps. Underpresent_interval displaywith no present cap that is 60, so every frame not presented counts as game time lost. Red Dead Redemption steps by measured time (RAGETIME::Updateadds the tick delta each frame), so its game clock keeps real time at any frame rate: the follower took a slow device for a slow game. The automatic mode only slows the sound by 1 %, so the lead it integrated kept growing.Change.
dm/host/hle_fpslock.c:dm_fpslocker_rate(), the limit the reviewed rows last wrote (0: no rows, or no limit).dm/gfx/nvn/hle_nvn.c:nvn_game_clock_own():present_interval display(whichdm/games/README.mdreserves for games whose logic does not count frames), no present cap, and a limit written by reviewed rows.dm/peanuts/peanuts.cpasses a frame rate of 0 for such a game, andpn_as_framecounts nothing for 0 (it used to treat 0 as 60; no caller passed 0). The follower then sees no pace, so the sound stays at real time: tempo 1, no lead, no resync finding.present_interval game, a present cap, andPN_AUDIO_FOLLOW=0/2semantics.nvn_game_fpsis unchanged (the in-game panel reads it only as "presenting").docs/reference/audio.md: a new entry under the follower's section;docs_symptoms.pyanddocs_patches.py(line numbers inhle_fpslock.c) rerun.Impact on other profiles
Scan of every
dm/games/*/game.tsvforpresent_interval displaytogether withfpslockerrows (README anddocs/reference/*.mdread for how each game steps time).shader_map.tsvtables are not touched. 16 profiles ondevmatch (Red Dead Redemption is the 17th, in #1801):No
fps_target, so no present cap unless the player picks one: the follower now counts none of their frames while the rows write a limit.0100300012F2A000,vsync_u32, limit 60): Unity runsUpdateevery frame and the row only changes how often it renders (its README), so the sound keeps real time as the game does.010055D009F78000,frame_scaled_f32, limit 60): KTGL runs 60 updates a second whatever it shows (its README).010057D006492000, UE 4.18target_f32, limit 60): Unreal's frame delta.010051C0134F8000) and Demon Slayer: The Hinokami Chronicles 2 (0100AD80208A8000), Unreal, limit 30: by the code, the old path counted their 30 presented frames as 1/60 s each (a pace of 0.5, inside the follower's 0.45 to 1.05 window) and held the tempo at 0.99. Now tempo 1. Not measured on these games.0100A6301214E000,vsync_u32+inverse_f32, limit 60): the one profile whose note says part of its logic counts frames (about 96 per-frame pieces step byVsyncFixedCount). Below 60 presented, those run slow, and the old path slowed the sound by up to 1 % with them; now the sound keeps real time and only the game's own resync applies. This is the profile most worth a listen.With
fps_target 60: RAIN CODE (0100149019460000), DRAGON QUEST III HD-2D Remake (01003E601E324000), OCTOPATH TRAVELER 0 (01005270232F2000), FINAL FANTASY RESONANCE (0100606026F12000,0100B8A026F14000), DRAGON QUEST XI S (01006C300E9F0000), No More Heroes 3 (01007C600EB42000), Europa (0100C8E01DD16000), One Piece Odyssey (0100D9601A994000), Breath of the Wild (01007EF00011E000, frame step). Where the host holds the 60 cap (fps_present_cap: an engine limit or the frame step),nvn_game_clock_ownis false and nothing changes; a player's "Game owned" pick, or a game whose engine limit the host does not find, takes the path above. Not confirmed per game on a device.No table, extension, magic or key collision (the change adds no profile key). The documented invariant it relies on is
present_interval display's own ("only right for games whose logic does not count frames"); Engage is the exception the scan found.Open PRs: #1875 also edits
hle_fpslock.c; the code merges cleanly, only the generateddocs/agents/game-patches.md(itshle_fpslock.cline numbers) needsdocs_patches.pyagain for whichever lands second.Smoke shortlist: Fire Emblem Engage (frame-counted logic under the new path), Advance Wars 1+2 (the same
vsync_u32row kind as Red Dead Redemption), DRAGON BALL Z: KAKAROT (a 30 limit).Checked
Unit tests:
t_peanuts_audiosync(Linux x86-64 container, clang): all passed at this head, including the new case (a game on its own clock presenting 0.86 of its rate: tempo 1.000, lead 0 ms). The new case againstdev'speanuts_audiosync.c: FAIL, tempo 0.990, lead 250 ms.devitself: all passed.t_fpslock(NDK 29 static arm64, run under qemu user emulation, with local stubs fornow_nsand threeplat_*functions): the newfpslocker_rate_checkpasses (0 before a tick, 30 with the row writing 2, 60 with it writing 1).step_checkand onecheckcase (line 111, a Unity row's write count) fail the same way atdevand at this head under emulation; not run on a device.Python tests:
python -m unittest discover -s dm/tools/tests, this head anddev07cc0805aon Windows: 1,912 tests, the same 100 failures and 154 errors at both (Windows environment: no clang, POSIX tools, game dumps), no new one.pr_ready.py --base upstream/dev: nothing to fix (the scope warning is answered above).docs_symptoms.py --check,docs_patches.py --checkcurrent.Phone runs: AYN Thor (Snapdragon 8 Gen 2, Adreno 740, 11.0 GiB, Android 13), Turnip 27.0.0-R2 (Mesa 27.0.0-devel
2648b2059f, Vulkan 1.4.367), Red Dead Redemption 1.0.7 (main37531419DA76), base v0 and update v458752 NSZs imported and prepared in the app on the device. The build had the 0.1.10 runtime, games: Red Dead Redemption (01007820196A6000) profile, RAGE RPF6 and Double Eleven pack shader readers #1801's profile with the 60 fps rows, vk_android: start cumulative SAMPLES_PASSED on first report without ResetCounter (every NVN game) #1738, and this change in an earlier form that also madenvn_game_fpsanswer the rows' limit; this PR leaves that out, since the follower no longer readsnvn_game_fpswhennvn_game_clock_ownholds. Log:interval mode display,frame limit 60 fps (game profile fps_limit), no present cap.Follower on and off for the behaviour change (same device, profile and driver; before = the build without it):
TIMEcounter, 30 s)The after run was less throttled than the before run (median 57.9 fps against 46 to 55), so not all of the underrun difference is the follower's. Played on foot around Armadillo (station, saloon, corrals); the before runs also rode out toward Fort Mercer. A second launch at 60 through the opening cutscene: no follower lines, 58 underruns over the load and the cutscene (the 30 limit before had 72 there).
Not checked:
dev07cc0805awith this commit.Docs
docs/reference/audio.md("Sound ahead of the picture below a frame limit withpresent_interval display"), andpython3 dm/tools/docs_symptoms.pywas rundm/third_party/, no change todmsh_chain.lock; the branch starts from the currentdev