fix(agc): return 0 for out-of-range sceAgcInit without table lookup #5163
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5163"
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 mazen320 on 2026-10-13T13:16:34Z.
What
Pointer-shaped / out-of-range
sceAgcInitvalues (>=14) return 0 without a register-default lookup. Versions 0–13 still select their tables.sceAgcInit_0090checks the state pointer and then callssceAgcInit, as OpenAGC does.#4808 console probe (firmware 13.60):
sceAgcInit(&buf, 8)(NIDkW3GLb7QfPg) returns 0 and writes nothing. The probe does not establish that table 13 is selected. Scalar versions 2–13 return0x8A6C0004on that console but still return 0 here (documented in debt; not changed by this PR).Tested
BUILD_TESTING=ONctest --test-dir build-win -R 'agc_initialization|agc_commands' --output-on-failure— 2/2 passedpython -I tools/check_conventions.py --base upstream/main --head HEAD— passedChecklist
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 MarcZX10 on 2026-10-13T13:17:58Z.
Review: COMMENTED
I checked the call path and the
GetRegisterDefaultsresults are used only to initialize the cached table objects;sceAgcInitdoes not store a selected version or return that table. The two reported firmware runs therefore support returning success for these pointer-shaped calls, while they do not establish which table firmware selects. The PR description and debt entry preserve that distinction, so I found no blocking issue in this diff.Imported from boykopovar/AnyPS5. Originally posted by coltken95 on 2026-10-13T18:51:10Z.
Tested on Linux x86-64 (Release build), with 0cc51023b merged into main
9d0a41d5a:agc_initializationandagc_commandspass.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T20:37:52Z.
Title runs on Windows with AMD, since the description says the titles were not rerun. Setup: Windows 11 (26300), Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release.
0cc51023bmerged ontomaina0f5916a2. Catalog builds, 40 s runs. PPSA99011 was relinked with--trap-sdk-syscall-stubs.agc_initializationandagc_commandspass.mainmain+ this PR (3 runs)FSR4_SHOWCASE_ERROR vkCreateDevice(physical, &di, NULL, &device) = -3,result=FAILFSR4_SHOWCASE_READY version=01.000.010 display=1920x1080. Stops 7-10 s in at the next, unrelated limit (below)launcher video=stateand no window appearslauncher video=okand presents: windowProspero Win | FPS: 1.02at 40 s, 3 of 3 runsThe next stop of PPSA99011 with this PR is
AGC driver: COPY_DATA at DWORD 69: COPY_DATA register, GDS or reference-clock source is not implemented. These are three COPY_DATA packets (control0x00100200) that copy the SH registers0x2e0c,0x2e07and0x2e00(COMPUTE_PGM_LO,COMPUTE_NUM_THREAD_X,COMPUTE_DISPATCH_INITIATOR) to memory, next to aDISPATCH_DIRECT.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T20:50:29Z.
Thanks for the Windows/AMD follow-up. This adds useful title-level evidence: PPSA99011 gets past device creation and reaches the later
COPY_DATAstop, while Prospero Win opens and presents in all three runs. The next FSR4 stop is now covered separately by #5477, which implements the register-to-memory copies and tests the dispatch register values. The table-selection behavior above version 13 remains unverified, as the PR description states.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T00:10:20Z.
The console measurement is in #4808 now (https://github.com/boykopovar/AnyPS5/issues/4808#issuecomment-6149448503):
sceAgcInit(&buf, 8)returns 0 and writes nothing. So return 0 for these calls without picking table 13 for a stack address; choosing a table the firmware is not shown to use is a fallback. Please cite the measurement in the debt entry and the description, and note there that scalar values 2 to 13 return0x8A6C0004on the console but 0 on main and here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T00:15:42Z.
Review: COMMENTED
The PS5 probe linked from #4808 changes the evidence for this fallback:
sceAgcInit(&buf, 8)returns 0 and leaves the buffer unchanged, while every tested scalar value >=2 returns0x8A6C0004. Selecting table 13 for a pointer-shaped argument is therefore unsupported. Please make the pointer-shaped path return success without a register-default lookup, cite the probe in this PR and the debt entry, and document that scalar 2–13 still differ from the current AnyPS5 behavior. The probe does not establish that table 13 is selected or that scalar 2–13 should use those tables.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-14T00:38:03Z.
Windows test of #5163: Windows 10 (19045), MinGW-w64 GCC 15.2, Release,
ninja -j 4, ctest called directly. Tree:mainfeddf7f4c+ merge of PR head0cc51023b130ddb251198b05c4a8d6eee4044b71(local merge6429dab37).agc_commands(built fromlibSceAgc/tests/Commands.cpp): exit code 0 in 3 of 3 runs (0.05 s each). The test selects no GPU.Not tested: that the new test case fails without the change (no baseline run), other ctest targets, Linux, a title run (PPSA99011 not available here). The PR state was UNSTABLE when I looked (CI not finished); I did not look at which check.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-14T00:40:27Z.
Thanks for the controlled Windows run:
agc_commandspasses 3/3 on the merged PR head, which confirms the suite is stable on that setup. The new report does not cover the console-observed pointer-shapedsceAgcInit(&buf, 8)behavior, and the current diff still maps that value to table 13. The firmware evidence in #4808 remains the unresolved point in my review; please update the pointer-shaped path and cite the measurement before I can approve this revision.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T07:51:58Z.
Linux x86-64 (WSL2 Ubuntu 24.04, GCC 13.3.0), Release,
BUILD_TESTING=ON, PR headeb1b9eca9:ctest --test-dir build-linux -R 'agc_initialization|agc_commands' --output-on-failure— 2/2 passedpython3 -I tools/check_conventions.py --base upstream/main --head HEAD— passed (also on Windows WinLibs 15.2.0 r7 for the same head)AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T11:17:53Z.
Closing temporarily to free the first-contributor open-PR slot so I can open a RetroArch Windows bring-up fix (select on regular files + AGC
8_8UINT). Will reopen this AGC init fallback PR after that one merges (or sooner if preferred).Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T14:14:09Z.
Reopened — keeping this PR open to wait for merge. The RetroArch select +
8_8UINT fix is parked onmazen320:fix/retroarch-windows-select-and-8_8-uint/ https://github.com/boykopovar/AnyPS5/pull/5795 and will be reopened after this lands.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T14:18:47Z.
Re the overlap bot vs #5845: Depends on: none.
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T14:20:08Z.
Triple-check follow-up (trial merges on current
upstream/main066b58fa1):Commands.cppInit.cppdocs/dev/debt/libSceAgc.mdsceAgcInit/sceAgcInit_0090; #5845:sceAgcGetDefaultCxStateFlat).sceAgcInitline). That is the whole overlap the bot reported.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-14T15:22:32Z.
Windows 10 evidence for this PR: merge 0d69a9ee8 (this branch onto main
066b58fa1), MinGW-w64, 0 build warnings.agc_initializationandagc_commands: 5/5 each.launcher video=state, no window. Merge:launcher video=ok, a window presenting at "FPS: 1.01 (55)" and "1.02 (55)", still running at 60 s with no throws.--trap-sdk-syscall-stubsand--registry). Main:FSR4_SHOWCASE_ERROR vkCreateDevice(...) = -3, thenFSR4_SHOWCASE_END result=FAIL, no window. Merge: window opens, passes PIPELINES and OUTPUT, printsFSR4_SHOWCASE_READY version=01.000.010 display=1920x1080, then stops withAGC driver: COPY_DATA at DWORD 69: COPY_DATA register, GDS or reference-clock source is not implemented. That next stop is the one #5477 addresses.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T15:25:44Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgc/DcbState/src/Init.cppL14-23core/libs/prx/libSceAgc/tests/Commands.cppL627-632docs/dev/debt/libSceAgc.mdL10Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-14T15:28:05Z.
Re the overlap bot vs #5889: Depends on: none — this is a competing change to the same exports, not a base we build on.
sceAgcInitABI kept asuint32_t(void*, uint32_t)>=14GetRegisterDefaultsGetRegisterDefaults+0x80890001above 13Same files because both touch
Init.cpp/ tests / thesceAgcInitdebt bullet. Same exports:sceAgcInit/sceAgcInit_0090. Merging one supersedes the other for those lines — second merger rebases or closes as duplicate.Prefer this PR for the out-of-range path reviewers already asked for; #5889 can close or retarget if maintainers want the two-arg signature separately (still needs the
>=14→ 0 without lookup to unblock the same titles).Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:50:11Z.
Checked the diff against the #4808 console measurement (
sceAgcInit(&buf, 8)returns 0, writes nothing): values >=14 return 0 with no register-default lookup,sceAgcInit_0090checks the pointer and delegates, and the debt entry cites the probe and the scalar 2–13 difference.agc_commandsbuilds and passes with the PR (libSceAgc scope, 22/22) and fails without the change; the Windows/AMD title runs in the thread cover the rest. Merging once CI is green.