feat(libSceAgc): implement sceAgcAcquireMemSetEngine #1060
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1060"
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 Kikoarl on 2026-10-07T06:49:07Z.
What
Implements
sceAgcAcquireMemSetEngineinlibSceAgcfollowing the PS5 12.70 module (0xd450).Provenance & Semantics:
W0WEyog0f74) from compatibility analysis of New Joe & Mac Caveman Ninja (PPSA02801).0xd450): validates that the packet opcode byte is0x58(returns0x8a6c000cif not, leaving packet untouched), leaves packet length unchecked, and patches bit 31 of word 1 using(engine << 31u).int sceAgcAcquireMemSetEngine(std::uint32_t* packet, std::uint8_t engine)incore/libs/prx/libSceAgc/include/Agc.hpp.docs/dev/debt/libSceAgc.md.Tested
core/libs/prx/libSceAgc/tests/Commands.cpp:ACQUIRE_MEMpackets emitted by bothsceAgcDcbAcquireMemandsceAgcAcbAcquireMem.engine = 0, 1, 2, 3, 4, 0xff).0x8a6c000cand leave payload unmodified.ctest --test-dir /tmp/anyps5_build -R agc_commands(100% passed).ctest --test-dir /tmp/anyps5_build -R agc_initialization(100% passed).python3 core/libs/tests/test_public_headers.py --audit-only(12,368 exports verified).python3 tools/check_conventions.py(all checks passed).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:16Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
ef1a412d, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.agc_commands.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-10T04:14:58Z.
Windows run of this PR alone on current
main. Headef1a412dmerged ontoc72d5ce1(clean); Windows 11 10.0.26200, RTX 4090 (NVIDIA 616.92, subgroup 32, so every GPU execution test runs), MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON.video_out_flip_lifetime,video_out_flip_controls,guest_video_out_wqhd_detection_no_vulkan), same asmainon this machine.SDL_DIRECTINPUT_ENABLED=0was set for the run because of #1042; it does not touch this PR's code.No title was run. Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T08:55:25Z.
Hi! This PR currently conflicts with
main, so I rebased it onto the latestmain(d3e84f85, includes #3296). The only conflict was the extern-declaration list incore/libs/prx/libSceAgc/tests/Commands.cpp, resolved by keeping both sides' declarations. It builds andagc_command_testspasses locally.If it helps, the rebased branch is available to pull:
Feel free to ignore this if you'd rather rebase yourself.
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-11T10:58:25Z.
@blawesom Thank you for the heads-up and resolving the declarations in Commands.cpp! Rebased cleanly onto latest main, verified agc_commands tests pass, and pushed.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-10-31T15:20:41Z.
Review: APPROVED
Checked against firmware 13.42's
libSceAgc.sprxat head134717ebf5:sceAgcAcquireMemSetEnginedoes what this PR implements, on every input I ran. Read from the disassembly and run under an emulator, not on a console.13.42 body (export at
0xd500, 0x2b bytes; the thread's 12.70 address was0xd450):d500-d512: the opcode byte atpacket+1must be0x58, else it returns0x8a6c000cwith the packet unchanged. The length isn't read.d514-d527: dword 1 becomes(dword1 & 0x7fffffff) | ((uint8_t)engine << 31)on a 32-bit register, so only the engine's low bit lands, and it returns 0.This is the same as the 12.70 reading here and as the code at this head.
Run. I compared the module with this PR's logic on 140 cases: five header words (
0x58with two lengths,0x59,0x10, and a0x58byte without the type bits), four dword-1 values (0x1234,0x80001234,0xffffffff, 0) and engines 0, 1, 2, 3, 4,0xffand0x1ff. All 140 gave the same result and dword 1, dword 0 and the next two words were never written, and three runs gave identical output.The one difference is a pointer the module doesn't check: a null packet faulted on the first read in the harness, and a packet one byte off was read as given (its opcode byte then came from the next byte, giving
0x8a6c000c). This PR throws for both, as asked earlier in the thread.The whole diff looks right to me: the implementation, the test (DCB and ACB packets, the custom-length packet, the non-
ACQUIRE_MEMpacket left unchanged, the null and misaligned refusals) and the debt move.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T23:44:21Z.
Review: APPROVED
Reviewed — approved
sceAgcAcquireMemSetEnginenow matches the module behaviour described in the thread: it checks only the opcode byte, returns0x8a6c000cand leaves the packet unchanged when that byte isn't 0x58, and writes the engine's low bit into bit 31 of dword 1. The PR merges and builds cleanly, its tests pass, and the extended test fails when the production change is reverted.What I ran
Head
134717ebf58a309ca14b5f5340e2ab8ae0866980,main1c8c0efc8c41314402e6966da5bef6ea3d639d10, merged with--no-ff(tree20c09cd624fb7988fa04f029c46418007e61d6cc), Debian 13 VM (Intel Xeon Gold 6136), GCC 14.2.0, Release, Ninja.Results
git diff --checkcheck_conventions.pylibs(script)agc_commands,agc_initializationpublic_headersunwrap_self_..._destination_directory_group) also fails onmainand isn't relatedagc_driver_image_gather_volume, marked "test not run on main" because the baseline is an oldermainthat doesn't have that test. This PR doesn't touch the AGC driver, the shader recompiler or VideoOut, so those lines don't come from itgit status --porcelainemptyNegative control
I restored
Patch/src/WaitRegMem.cppandUnimplemented.cppfrommainand kept the new tests. After rebuildinglibs,agc_commandsfails:output
With the merged files restored and rebuilt,
agc_commandspasses again.Findings
Blocking
None.
Non-blocking
packetthrows. The module doesn't check the pointer at all: it reads a null pointer and faults, and it reads a misaligned pointer as given, as BunnyFl's 13.42 run showed. Suggested fix: reduce the entry to that difference, e.g. "a null or non-4-byte-aligned packet throws; the module (12.70 0xd450, 13.42 0xd500) dereferences it unchecked". Refusing these pointers is consistent with the otherPatchfunctions and was requested earlier in the thread, so the code itself should stay as it is.TechnicalDebt.md, while the entry went todocs/dev/debt/libSceAgc.md, as fogydes noted. This is cosmetic.On earlier comments:
Fixes,UnblocksandGPUs tested.engineis promoted fromuint8_ttouint32_tbefore<< 31, so only bit 0 lands and the shift is well defined. The test runs engines 2, 3, 4 and 0xff and confirms this.Not verified
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T20:44:09Z.
Review: APPROVED
@Kikoarl re-checked at
8163f83295— still approved.The only commit after my approval of
134717ebf5is the merge ofmain(8163f83295). Againstmainthe PR's code and test lines are unchanged:WaitRegMem.cpp,Unimplemented.cppandtests/Commands.cppcarry the same +/- lines as before. The one difference is indocs/dev/debt/libSceAgc.md, wheremainhad already splitsceAgcCbMemsetExclusiveout of the shared entry, so the PR now just removes the one-linesceAgcAcquireMemSetEngineentry.What I ran
Windows 11 Pro 10.0.26300, WinLibs GCC 15.2, Release, this head merged cleanly onto
mainb611e634f7(97c40eba69):agc_initializationandagc_commands: 2 of 2 pass.core/libs/prx/libSceAgc/Patch/src/WaitRegMem.cppandcore/libs/prx/libSceAgc/Unimplemented.cppfrommainfailsagc_commands.tools/pr_overlap.py --branchon this head: 5 open PRs share files. The 2 it couldn't compare share onlydocs/dev/debt/libSceAgc.md: #14085 edits thesceAgcAcbAtomicGds_0900and workload entries, and #14212 only adds blank lines between entries. Neither touches thesceAgcAcquireMemSetEngineentry.