Repository navigation
fix(libSceNgs2): let render skip a grain while another thread holds the system lock - #7072
Conversation
…he system lock Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BywPXoZACVi8ALV4JKvuPZ
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
@mrfelek thanks for picking this up, and for the core dump that showed the I built and tested the head (40f4506) on Ubuntu 24.04, GCC 13.3, Release:
The Peace Walker path looks right to me. A few points:
Last thing: your Peace Walker runs were on a port to 8856f18, where the silent grain cleared whole buffers. One run on this exact head, ideally with points 1-2 in, would be great. AI-assisted: yes (Claude Code) |
What
sceNgs2SystemLocktook the library's process-wideNgs2Mutex()and kept it untilsceNgs2SystemUnlock. So while a title held the system lock,sceNgs2SystemRenderand every other NGS2 call on any other thread waited for it.On the console, render does not wait. prosper's notes, re-derived from the PS5
libSceNgs2.nativemodule (found by @SandstromPL), say:Peace Walker (PPSA18216) deadlocks on this during its
dlctexloads:sceNgs2SystemRenderand eightsceNgs2VoiceGetStateFlagscalls.A core of a frozen run with render made non-blocking alone shows the audio thread blocked in
sceNgs2VoiceGetStateFlagsinstead (details in #5268).Changes:
sceNgs2SystemLockandsceNgs2SystemUnlockkeep a per-system owner thread and depth behind their own mutex and condition variable, and no longer holdNgs2Mutex()after they return.sceNgs2SystemRendertries the system lock.sceNgs2SystemLockfrom another thread waits for the grain.Ngs2Mutex()only for its own work, so none of them waits for the system lock.sceNgs2RackLockis unchanged.Tested
Linux (Ubuntu 26.10), GCC 15.3, Release, Ryzen 9 5950X.
ngs2_*tests pass.TestLockis rewritten. It checks:GetInfoandVoiceGetStateFlagsnot blocking while another thread holds the lock;SystemLockfrom another thread waiting until both holds are released;main'sSystem.cpp,TestLockfails at the check that the other thread finished (line 907). With this change it passed 11 of 11 repeats.main8856f18 + fix(agc): rasterize a single-sample scan into a multisampled depth target at the pixel center #5915, fix(agc): rasterize a multisampled target without MSAA_ENABLE at the pixel center #5882, fix(agc): rasterize a multisampled depth target without MSAA_ENABLE at the pixel center #6014 and fix(agc): rasterize into one-sample targets as one sample when MSAA_ENABLE is clear #6196, started through the launcher hand-over, X pressed every 2 s. The change was applied to that tree, where a silent grain clears whole buffers as that tree's render does. OnlylibSceNgs2.prxdiffers between the runs:libSceNgs2dlctexloadsmain's locksceNgs2VoiceGetStateFlags)[present]lines in the 240 s after the last load each, then it opens its music file; no NGS2 errors)The same freeze happens on Windows 11 with
main's lock (3 of 4 runs, RTX A2000 Laptop). This PR was not run on Windows.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)AI-assisted: this PR was written with the help of Claude Code and checked against the runs by us.