fix(libSceAgc): encode ACQUIRE_MEM ranges and fields as the console does #18479
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18479"
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 LeandroLP23 on 2026-11-11T17:43:59Z.
What
The follow-up to #16855 that xXPBSXx agreed to there. #16855 made the poll and cache control words match a PS5. This makes the rest of the ACQUIRE_MEM packet match two sets of console packets:
sceAgcDcbAcquireMemandsceAgcAcbAcquireMemnow write the packet through one function,Agc::Command::WriteAcquireMem.mainengine> 10x11→ 1,0x22→ 0)cbDbOpCP_COHER_CNTL0x7fffffff→0x06007fc0;0x1-0x10,0x10000,0x100000dropped;0x100,0x1000kept), prosper (0x22222222→0x02002200,0x44444444→0x04004440)cbDbOpbit 14 or 26 (DB): page 1 to the top of a 48-bit space (0xfffffffe,0xff, 1, 0)0x7fffffff), prosper (0x44444444)0xffffffffffffffff)0x3333333344444444→0x33444444,0x333333)gcrControl0x11111111→0x11111)Nothing throws any more; the console returned the packet for every argument above.
Not measured, recorded in the libSceAgc debt:
The old debt entry for the 2^40 boundary is removed: #16855 measured 2^40 as a plain block count.
Tests:
agc_commandsnow checks:cbDbOppackets, word for word;0x7fffffff;engineof 3,gcrControlabove 19 bits, and the ACB engine.The rejection cases that no longer throw are removed. The
sceAgcAcquireMemSetEnginechecks usecbDbOp0x1200, since0x1234loses its low bits now.Tested
Windows 11, Radeon 860M, MinGW GCC Release, on
mainf57c971559.agc_commandspasses. Negative control: withmain's three ACQUIRE_MEM sources and these tests, it fails.main, four of them throw and two differ. This needs #17730's replay to pass zero for the arguments on the stack: prosper's DCB cases give five integers, sopollCycles(the seventh argument) is read from the stack. I added that to #17730.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R '^(agc|job)': 1607 of 1616 pass. The other 9 also fail onmainon this machine: eight float16 shader tests andagc_driver_sample_order_grid_reference.tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branchmerged all three overlapping pull requests cleanly. It could not compare #14212 and #17742, which conflict withmain: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 MarcZX10 on 2026-11-12T14:27:29Z.
Review: COMMENTED
Reviewed — no blocking findings
The diff moves the ACQUIRE_MEM encoding for
sceAgcDcbAcquireMemandsceAgcAcbAcquireMeminto one function, and the code I read matches the description. One non-blocking edge case at the 2^48 cutoff is unmeasured on the console.What I ran
8d21d67e961136e4422de53a0d986701b8756b5e, basemain.Results
agc_commandsAcquireMemFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgc/Command/src/Memory.cpp:14: for a size from 2^48 − 255 to 2^48 − 1 with a 256-byte-aligned base,(sizeBytes + 0xff) >> 8is 2^40. The high field keeps only 8 bits, so the packet encodes size 0. The< (1ull << 48u)guard does not catch this, and no test covers the range. The console's result there is unmeasured (the debt entry says the switch point is unmeasured), so this is a decision for the author: either move the cutoff below the wrap, or say which packet a size in that range should produce, and add a case toCommands.cpp.Not verified
agc_commandspassing with a negative control, the prosper oracle rows matching, andctest -R '^(agc|job)'at 1607 of 1616. Those are author-reported runs.Acb/src/Memory.cpp:14). Two callers incore/libs/prx/libSceJobManager/Export.cpp(lines 92 and 528) usesceAgcAcbAcquireMem, so their packets change too. Whether the console's compute path needs engine 1 is not verified here. The PR cites the measurement for engine 0 but does not state the context it was taken in.Commands.cppanddocs/dev/debt/libSceAgc.mdwere read only through their diff hunks, not in full.Sources
8d21d67e96, read through the reader. No external permalinks cited.To get this to a good state
agc_commandson the new head.Files read: the six files in
files.jsonunderreviewed, through their diff hunks and the head headers above. Excluded by rule: none.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T00:25:40Z.
Review: COMMENTED
Reviewed — comments
Nothing blocks this review, but the range encoding needs clarification before its behavior can be confidently assessed.
What I ran
a4f24bc2653b41a3ba96e59b5c44f049ace4c33eusingrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgc/Command/src/Memory.cpp:14: The new size calculation switches to “range to the top” when the rounded block count would exceed the 40-bit field. The description identifies this switch point as not measured on console, while the tests assert behavior immediately around the inferred boundary. Please record that this is an inference and add console evidence when available; the current tests establish the implementation’s arithmetic, not its hardware behavior.Not verified
To get this to a good state
Nothing is required. The range-boundary comment above is optional.