test(libSceAgc): check ten packet sizes against the packets their writers emit #16987

Merged
milescoviello merged 1 commit from upstream-pr/16987 into main 2026-11-12 00:05:04 +00:00
milescoviello commented 2026-11-08 04:11:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-08T04:11:07Z.


What

Ten AGC size functions had no test: the ones a game calls to reserve command buffer space before it writes the packet. Our relinked titles import them:

Size function Titles importing it
sceAgcDcbDrawIndexAutoGetSize, sceAgcDcbDrawIndexIndirectGetSize, sceAgcDcbDrawIndirectMultiGetSize, sceAgcDcbCondExecGetSize, sceAgcAcbCondExecGetSize, sceAgcAcbRewindGetSize Crimson Desert (PPSA25286), Call of Duty: Black Ops II (PPSA34502), Steins;Gate Reboot (PPSA36591)
sceAgcDcbSetIndexBufferGetSize, sceAgcDcbGetLodStatsGetSize the same three
sceAgcCbSetShRegisterRangeDirectGetSize Borderlands 4 (PPSA01494), Crimson Desert, MXGP (PPSA30839), Super Meat Boy 3D (PPSA31162), Black Ops II, Steins;Gate and Metal Gear Solid 4 (PPSA18194)
sceAgcCbSetUcRegisterRangeDirectGetSize none of ours yet; it is the same register range packet with the UC opcode

A size that is smaller than the packet makes a game's own reservation too short, so each check writes the packet into an empty command buffer with the writer of the same name and compares the bytes it took with the size function's answer. The register range checks use three values.

sceAgcDcbSetBaseDrawIndirectArgsGetSize, sceAgcDcbSetBaseDispatchIndirectArgsGetSize and sceAgcCbQueueEndOfPipeActionGetSize are imported too, but no writer of the same name exists, so they are left out.

Test only.

Tested

  • Linux, Ubuntu 26.04, GCC 15.2, Release, ctest -R '^(agc_commands|agc_initialization)$':
    • 78ac647a46: 2 of 2 in 3 of 3 runs.
    • main 13b19a1dca: 2 of 2.
    • With a local change (not in this PR) that makes the graphics CondExec size 16 instead of 20, agc_commands fails with "graphics conditional execution size differs from its packet", so a size that is shorter than its packet is caught.
  • Windows 11 VM, WinLibs GCC 15.2, Release, the same two tests: 3 of 3 runs pass on 78ac647a46 and on main 13b19a1dca.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (command buffer writers only, no GPU work)
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5208542991 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16987). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-11-08T04:11:07Z. --- ### What Ten AGC size functions had no test: the ones a game calls to reserve command buffer space before it writes the packet. Our relinked titles import them: | Size function | Titles importing it | |---|---| | `sceAgcDcbDrawIndexAutoGetSize`, `sceAgcDcbDrawIndexIndirectGetSize`, `sceAgcDcbDrawIndirectMultiGetSize`, `sceAgcDcbCondExecGetSize`, `sceAgcAcbCondExecGetSize`, `sceAgcAcbRewindGetSize` | Crimson Desert (PPSA25286), Call of Duty: Black Ops II (PPSA34502), Steins;Gate Reboot (PPSA36591) | | `sceAgcDcbSetIndexBufferGetSize`, `sceAgcDcbGetLodStatsGetSize` | the same three | | `sceAgcCbSetShRegisterRangeDirectGetSize` | Borderlands 4 (PPSA01494), Crimson Desert, MXGP (PPSA30839), Super Meat Boy 3D (PPSA31162), Black Ops II, Steins;Gate and Metal Gear Solid 4 (PPSA18194) | | `sceAgcCbSetUcRegisterRangeDirectGetSize` | none of ours yet; it is the same register range packet with the UC opcode | A size that is smaller than the packet makes a game's own reservation too short, so each check writes the packet into an empty command buffer with the writer of the same name and compares the bytes it took with the size function's answer. The register range checks use three values. `sceAgcDcbSetBaseDrawIndirectArgsGetSize`, `sceAgcDcbSetBaseDispatchIndirectArgsGetSize` and `sceAgcCbQueueEndOfPipeActionGetSize` are imported too, but no writer of the same name exists, so they are left out. Test only. ### Tested - **Linux, Ubuntu 26.04, GCC 15.2, Release**, `ctest -R '^(agc_commands|agc_initialization)$'`: - `78ac647a46`: 2 of 2 in 3 of 3 runs. - `main` `13b19a1dca`: 2 of 2. - With a local change (not in this PR) that makes the graphics `CondExec` size 16 instead of 20, `agc_commands` fails with "graphics conditional execution size differs from its packet", so a size that is shorter than its packet is caught. - **Windows 11 VM, WinLibs GCC 15.2, Release**, the same two tests: 3 of 3 runs pass on `78ac647a46` and on `main` `13b19a1dca`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a (command buffer writers only, no GPU work) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16987
No description provided.