fix(libSceAgc): preserve versioned register defaults layout #7681
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7681"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T22:42:02Z.
What
Fixes #7678 by keeping the legacy no-argument
sceAgcGetRegisterDefaults()key/bank pair table while restoring the original three-word compact entries forsceAgcGetRegisterDefaults2(version)and its internal counterpart. This preserves the homebrew layout measured for the legacy path without changing the versioned SDK tables used by retail titles. Adds regression coverage for public versions 0 and 10 and internal version 0.Tested
Linux, GCC 12.2: syntax-checked the changed command source, export source, AGC command test source and
guest_shader_linktest source. A focused standalone runtime smoke test confirmed legacy public pairs, versioned public compact entries for versions 0 and 10, and the internal version 0 compact entry.git diff --check, conventions against currentupstream/main, and the open-PR overlap check passed. Full CMake/CTest was not run locally because configuration is blocked by the uninitialized SDL2 submodule and missing XRandR development files.Windows contributor report on the prior code-identical head: Sword of the Sea (PPSA25344) reached the title screen in one 180-second run with no indirect-register sentinel abort. The full build passed
agc_initializationandagc_commands;guest_shader_linkinitially failed on its pointer-equality assertion. Replacing that assertion with a comparison of the four bank register counts (the test-only correction now in this PR) made all three tests pass in the contributor's local build. The retail-title run preceded that test-only correction. No local retail-title or GPU runtime test is claimed.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)Imported from boykopovar/AnyPS5. Originally posted by m335671 on 2026-10-18T22:53:15Z.
Full build and title run of this PR's head
cf386a16bon Windows 11 Pro 26200, Ryzen 9 7900, RTX 4070 12 GB (NVIDIA 616.92), WinLibs GCC 15.2.0, Release,BUILD_TESTING=ON.Tests.
agc_initializationandagc_commandspass.guest_shader_linkfails (exit0xc0000409, aRequireabort):core/libs/tests/GuestShaderLink.cpp:39still requires the pointer this PR splits:One way to keep that test's intent: compare the table contents instead of the pointer, i.e. the four bank register counts at
0x20. The test already includes<cstring>:With that line applied locally on top of
cf386a16b, all three pass (agc_initialization,agc_commands,guest_shader_link). Could you fold it into this PR?Title. Sword of the Sea (PPSA25344, 01.510.000, imports
sceAgcGetRegisterDefaults2), the second title in #7678, relinked with this head's relinker and every library built at it. A 180 s boot from a cold shader cache (1,324 misses) has noindirect register sentinelabort and no other abort. It reaches the title screen and holds 124–125 presents per 10 s there, the same rate as before #6270. One run. Onmain0bc3003f8the same boot stops a few seconds in (details in #7678).AI-assisted: yes (Claude Code). The build, the tests, the run and this comment were done and written by Claude Code on my machine.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T22:54:46Z.
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.
core/libs/tests/GuestShaderLink.cppImported from boykopovar/AnyPS5. Originally posted by WhiteAssassins on 2026-10-18T23:13:11Z.
Additional Linux title confirmation: ASTRO BOT (PPSA21567, v01.019.000) reaches in-game with this fix. Thanks for addressing this regression.
Host: CachyOS/Arch Linux, Ryzen 7 5700G, Radeon RX 6750 XT, RADV/Mesa 26.2.4, GCC 16.2.1.
Controlled comparison
Base:
8b8edc56195f2ff6ec8e1a87b2463dc408580c54. Same relinked executable, bundled guest modules, assets and other runtime libraries in both runs. We rebuiltlibSceAgc.prxwith the production change captured from this PR, including the callers affected by theGetRegisterDefaultssignature change, and selected the library per process. This was an isolated test of the PR's change on that base, not a full build of the latest PR head.libSceAgc.prxThe actual loaded
libSceAgc.prxpath was checked through/proc/<pid>/mapsin each run. The focusedagc_initializationandagc_commandstests also passed. The full test suite was not run.Original failure
Repeated launches stopped in the title's bundled
libc.prx.guest.prx. GDB confirmed:This is the first write of a memset-like operation over 1,016 MiB. The destination belonged to the reserved
0x40b800000–0x500000000VMA with---ppermissions. The kernel's file offset0x143c6corresponds to ELF virtual offset0x103c6in this PRX. There was no preceding assert or unimplemented-function message explaining this stop.A separate temporary GDB experiment restoring the original compact type tables for the public and internal version-13 calls also passed that failure point. Applying the real production change to the library then reproduced the improvement without GDB. We have not traced every instruction between reading the defaults table and the allocator's invalid write, so this does not claim a complete corruption trace.
Manual follow-up
After installing the corrected library for my normal Astro Bot launch, I confirmed that the game reaches in-game, beyond the automated startup test. I have not yet measured the duration of that manual session or established long-term stability, performance gains or complete visual correctness.
AI-assisted: Codex performed the controlled builds/debugging/tests and helped draft this report; I manually confirmed the in-game result and authorized posting it.
Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-18T23:29:23Z.
Another retail title with the same regression: EA SPORTS UFC 6 (PPSA23566, SDK 9.04 per its process parameters).
On current
mainit stops right after loading its render module withsceAgcCbSetShRegisterRangeDirect: invalid register range. The call comes from the title'sEngine.Render.Core2.PlatformPs5.prxwith offset0xffffffff, count 4. Tracing the title's code:it calls
sceAgcGetRegisterDefaults2(13)(NID2JtWUUiYBXs), walks the root's type table at+0x30in 12-byte steps (count at
+0x38), compares the key at+0and decodesbank = word & 3,index = word & 0x3fcfrom+4. Over the 8-byte pairs it finds none of its keys, stores -1 asthe register offset, and later passes it to
sceAgcCbSetShRegisterRangeDirect.I tested a change equivalent to this PR (legacy
sceAgcGetRegisterDefaultskeeps the pairs,sceAgcGetRegisterDefaults2/2Internalreturn the compact 12-byte entries over the same blocks), not this PR's head:UFC 6 gets past the crash and plays its intro cinematic.
agc_commands,agc_initializationand
guest_shader_linkpass with the test updates.Windows 11 Pro, Ryzen 7 5700X, RTX 4060 8 GB (driver 32.0.16.1664), 32 GB RAM, WinLibs GCC 15.2.0, Release.
Imported from boykopovar/AnyPS5. Originally posted by WhiteAssassins on 2026-10-18T23:33:01Z.
Nice catch. This lines up very well with the Astro Bot regression I reported above.
In my case the bad table layout did not fail immediately with invalid register range; Astro continued further and eventually crashed in its bundled libc.prx.guest.prx while writing to an unmapped guest range. Applying the #7681 layout fix removed that crash and the game reached in-game.
Your trace showing the 12-byte walk, failed key lookup, and resulting 0xffffffff register offset is very useful evidence for the underlying mechanism.
Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-18T23:35:06Z.
Tested this PR's head (
0c2260e30) on a retail SDK title, and the title's own code agrees with the layout it restores. EA SPORTS FC 25 (PPSA20049) importssceAgcGetRegisterDefaults2(2JtWUUiYBXs) andsceAgcGetRegisterDefaults2Internal(wRbq6ZjNop4) inEngine.Render.Core2.PlatformPs5.prx, and walks the type table at+0x30in 12-byte steps after both calls:A key it can't find becomes
-1, which fits the0xffffffffoffsets in the indirect register lists that #7678 and the other reports stop on.Runs on Linux, RX 9070 XT, RADV (Mesa 26.2.5),
main8b8edc561with #6343, #7606, #7413 and #6960; onlylibSceAgc.prxdiffers between them:main'slibSceAgc, with #6270: stops 9 s after start withindirect register sentinel semantics are not implemented;Imported from boykopovar/AnyPS5. Originally posted by Longziip on 2026-10-18T23:38:27Z.
@WhiteAssassins Thanks! That difference makes sense with the mechanism: when the 12-byte walk misses a key, UFC 6 stores -1 and the range check stops it right away, but if a misaligned read happens to match a key, the title gets a wrong block index instead and computes a plausible but wrong register or memory location, so it can fail much later and somewhere else, like your libc.prx write. That would explain why each title breaks differently with the same root cause.
I can also run UFC 6 on this PR's exact head if that helps the merge
Imported from boykopovar/AnyPS5. Originally posted by WhiteAssassins on 2026-10-18T23:44:38Z.
Yes, testing UFC 6 on the exact PR head would definitely help. Your current trace already gives strong evidence for the mechanism, but confirming the actual head would remove the only remaining difference from your current test.
If it gets past the same 0xffffffff / invalid-register failure on the PR head, that would be another very useful retail-title confirmation for the merge. Thanks!
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T23:53:14Z.
Thanks for the Windows test report and the suggested assertion update. The pointer-identity check has already been replaced on the current PR head (
0c2260e30) with a comparison of the four bank counts at offset0x20, preserving the test intent while allowing the versioned layout to differ. Your local run reports all three focused tests passing with that change. The current PR head also has additional title evidence in this thread.Imported from boykopovar/AnyPS5. Originally posted by teepean on 2026-10-19T05:27:43Z.
Stray (PPSA02100, Unreal Engine 4, retail) is another title #6270 stopped, and this PR fixes it there too. Stray imports the versioned getters
sceAgcGetRegisterDefaults2(2JtWUUiYBXs) andsceAgcGetRegisterDefaults2Internal(wRbq6ZjNop4), not the legacy one.main0bc3003f8(contains #6270)indirect register sentinel semantics are not implementedmainfc623324a+ this PR at cf386a16b (the samelibSceAgccode as the merged head0c2260e30)Before this PR, a first-parent bisect from
e1338ff5eto0bc3003f8ended at #6270's merge2da2284de. On0bc3003f8, restoring only the compact type entries inCommand/src/RegisterDefaults.cpp, with the rest of #6270 kept, also made Stray start.Setup: Linux (CachyOS, kernel 7.2.10), Ryzen 9 9950X, RTX 3090 (NVIDIA 615.78.08), GCC 16.2.1, Release, stock
engine.ini.AI-assisted: yes (bisect, tests and text with Claude Code; the runs are from my machine).