agc: return the Sh register-list size Returnal queries #2576
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2576
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2576"
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?
@lordra9-svg on GitHub · 2026-11-27 01:31 UTC · original
lordra9-svg:fix/returnal-agc-sh-size→main· +55 −0 · 4 files · 1 commits · openReturnal (PPSA01285, 03.005) calls
sceAgcCbSetShRegistersDirectGetSize(NIDyUBESvCCJ4I) before writing a shaderregister list. The writer (
AgcCbSetShRegistersDirect) was already implemented, butthe size query was never registered, so the call landed on the unresolved-import stub
and the main-menu path stopped instead of reaching the next stage.
Return three dwords per register — the writer's worst case when no two registers are
adjacent. Adjacent registers still merge into one range and use less than the queried
size, so this is a safe upper bound. Reject register counts whose byte size would
overflow the 32-bit result.
Register the NID and cover the upper bound, merged ranges, the NID lookup and the
overflow guard in
agc_tests.Refs #2373.
Tests
agc_tests:Agc.SetShRegistersDirectSizeCoversOnePacketPerRegisteragc_tests:Agc.SetShRegistersDirectSizeCoversMergedRangesagc_tests:Agc.SetShRegistersDirectSizeResolvesItsNidAgcDeathTest.SetShRegistersDirectSizeRejectsOverflow61db2f88; Linux build and the above tests pass.eboot.binimportsyUBESvCCJ4I.Files:
src/libs/agc.cpp,src/libs/agc.h,src/libs/libAgcDriver.cpp,tests/AgcTests.cpp.AI assistance
The implementation and tests were drafted with AI assistance. I reviewed the code,
ran the tests above, and verified the NID import in Returnal's executable before
submitting.
@coderabbitai[bot] on GitHub · 2026-11-27 01:35 UTC · original
No actionable comments were generated in the recent review.
Walkthrough
The change adds and registers
AgcCbSetShRegistersDirectGetSize. The function reports a maximum size of 12 bytes per register and terminates if the calculation would overflowuint32_t. Tests cover size results, packet writing for scattered and adjacent register offsets, symbol resolution, and overflow termination.Suggested reviewers:
nmzik,superkekaChange: Bug fix
Merge Risk:
Minimal · up to
26a6eThis adds the missing size-query export that Returnal calls before writing shader registers, so the call no longer hits an unresolved-import stub. The reported size is a safe upper bound and overflowing counts are rejected. No actionable merge-blocking risk remains.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the main change: registering and returning the size for the Sh register-list query that Returnal calls. It matches the changeset in src/libs/agc.cpp, agc.h, libAgcDriver.cpp and tests/AgcTests.cpp. It is specific and single-sentence, so it passes.
Full details: Description check
Explanation
The description explains why the size query is needed (Returnal calls sceAgcCbSetShRegistersDirectGetSize with NID yUBESvCCJ4I before writing shader registers), how the size is computed (three dwords per register as an upper bound), the overflow guard, and the tests added. These all match the changed files. It is detailed and on-topic, so it passes.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
00d7ac73-6e31-4e00-9385-4a9f594b0244Reviewing files that changed from the base of the PR and between
61db2f8874and26a6eb6bd4.src/libs/agc.cppsrc/libs/agc.hsrc/libs/libAgcDriver.cpptests/AgcTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.