feat(agc): implement sceAgcGetPacketSize #772

Merged
adriadam10 merged 1 commit from upstream-pr/772 into main 2026-10-05 23:43:02 +00:00
adriadam10 commented 2026-10-05 22:51:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-05T22:51:00Z.


What

Implements sceAgcGetPacketSize (was a throwing stub): returns the size in dwords of the PM4 packet at packet.

  • Type-3 header: count + 2 (bits 16-29), as KytyPS5 AgcGetPacketSize (src/libs/agc.cpp).
  • Header-only NOP ((header & 0x3fffff00) == 0x3fff1000, i.e. 0xffff10xx): 1. Same mask as KytyPS5; matches Mesa's PKT3_NOP_PAD (PKT3(PKT3_NOP, 0x3fff, 0), "header-only version", src/amd/common/sid.h, padded by radv/radeonsi).
  • Not a type-3 header (types 0-2): throws. KytyPS5 ignores the type bits (a type-2 filler would give 2, a type-0 0x3fff10xx 1), while PM4 makes a type-2 filler 1 dword, so the references disagree and the call throws instead of guessing. Same check as sceAgcDcbGetSystemSoftwareVersion next to it.
  • Null or misaligned pointer: throws (CheckAddress), like the other functions in PacketInfo.cpp.

No other reference has a body (shadPS4 and fpPS4: name only; SharpProspero: signature only).

New test agc_packet_info_tests (tests/PacketInfo.cpp, in ctest). It isn't added to agc_command_tests because that target isn't registered in ctest and already fails on main ("expected an exception").

Tested

Linux, GCC Release: agc_packet_info_tests passes. It checks real headers (SET_SH_REG count 4 → 6, NOP count 0 → 2, count 0x3ffe → 0x4000, non-NOP count 0x3fff → 0x4001, 0xffff1000/0xffff1001/0xffff10fc → 1), that the packet is left unmodified, and the rejections (types 0/1/2, null, misaligned). Fails on main (the stub throws). I also broke each piece on purpose (pad value, +2, NOP mask, type check, address check) and each change made the test fail. All the other agc_* tests pass, apart from agc_driver_pixel_helper_lanes/pixel_lds/pixel_lds_lane_slots, which also fail on main on local RADV (wave32 on a 64-lane subgroup).

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4751705413 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/772). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-05T22:51:00Z. --- ### What Implements `sceAgcGetPacketSize` (was a throwing stub): returns the size in dwords of the PM4 packet at `packet`. - Type-3 header: `count + 2` (bits 16-29), as KytyPS5 `AgcGetPacketSize` (`src/libs/agc.cpp`). - Header-only NOP (`(header & 0x3fffff00) == 0x3fff1000`, i.e. `0xffff10xx`): 1. Same mask as KytyPS5; matches Mesa's `PKT3_NOP_PAD` (`PKT3(PKT3_NOP, 0x3fff, 0)`, "header-only version", `src/amd/common/sid.h`, padded by radv/radeonsi). - Not a type-3 header (types 0-2): throws. KytyPS5 ignores the type bits (a type-2 filler would give 2, a type-0 `0x3fff10xx` 1), while PM4 makes a type-2 filler 1 dword, so the references disagree and the call throws instead of guessing. Same check as `sceAgcDcbGetSystemSoftwareVersion` next to it. - Null or misaligned pointer: throws (`CheckAddress`), like the other functions in `PacketInfo.cpp`. No other reference has a body (shadPS4 and fpPS4: name only; SharpProspero: signature only). New test `agc_packet_info_tests` (`tests/PacketInfo.cpp`, in ctest). It isn't added to `agc_command_tests` because that target isn't registered in ctest and already fails on `main` ("expected an exception"). ### Tested Linux, GCC Release: `agc_packet_info_tests` passes. It checks real headers (SET_SH_REG count 4 → 6, NOP count 0 → 2, count `0x3ffe` → `0x4000`, non-NOP count `0x3fff` → `0x4001`, `0xffff1000`/`0xffff1001`/`0xffff10fc` → 1), that the packet is left unmodified, and the rejections (types 0/1/2, null, misaligned). Fails on `main` (the stub throws). I also broke each piece on purpose (pad value, `+2`, NOP mask, type check, address check) and each change made the test fail. All the other `agc_*` tests pass, apart from `agc_driver_pixel_helper_lanes`/`pixel_lds`/`pixel_lds_lane_slots`, which also fail on `main` on local RADV (wave32 on a 64-lane subgroup). ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-05 23:04:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T23:04:42Z.


Progress report (bc24783 → 40c1910)

📈 System libraries: 79.57% (+0.03%, +1 implemented functions)

✅ 1 implemented
Library Name
libSceAgc sceAgcGetPacketSize
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6005020734 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/772#issuecomment-6005020734). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T23:04:42Z. --- <!-- progress-report --> ### Progress report (bc24783 → 40c1910) 📈 **System libraries**: 79.57% (+0.03%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceAgc | `sceAgcGetPacketSize` | </details>
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!772
No description provided.