feat(agc): write the measured sceAgcDcbResetQueue packet sequence #1629

Merged
ahmedhamouda78 merged 1 commit from upstream-pr/1629 into main 2026-10-10 05:58:23 +00:00
ahmedhamouda78 commented 2026-10-08 15:18:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmedhamouda78 on 2026-10-08T15:18:51Z.


What

sceAgcDcbResetQueue wrote only a single c0001200 <state> CLEAR_STATE packet and ignored op entirely (the KytyPS5 approximation). This replaces it with the sequence measured on a PS5 (firmware 13.60): an envelope (ffff1000 / c0027904 00000342 ce20<op&ffff> <flag> ... c0017904 00000342 cea00000) plus one packet group per set op bit, emitted in ascending bit order.

Groups are emitted for op bits 0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x080, 0x100, 0x800. The three bits whose groups the driver's Pm4::Validate currently rejects — 0x040 (whole-range ACQUIRE_MEM), 0x200 (EVENT_WRITE event 56), 0x400 (opcode 0x1E) — throw a clear error instead of being emitted, so this change cannot make a title stop inside the driver. Supporting those bits needs the driver-side acceptance first and belongs in a separate PR.

state 2 sets the envelope flag dword to 0x00000008; state 3 sets the 0x004/0x800 group's payload dword to 0x00840f80; the other measured state values (0, 1, 4, 8, 0xF) produce the state-0 form.

Tested

Linux, GCC 16.2.0, C++20. The AGC command test suite (agc_command_tests — testPackets) was extended with exact-byte assertions for the envelope, single groups, the state 2 and state 3 variants, op=0x800, and that an unsupported bit throws and leaves the buffer unmodified; the suite passes. Every emitted byte was checked against the hardware probe output in #1581. Not run on hardware or against a title.

Semantics source: the packet bytes and op/state behaviour come from the PS5 firmware 13.60 measurement in issue #1581 (the sceAgcDcbResetQueue probe loading libSceAgc.sprx and dumping the command buffer), not from a cited ISA/driver source.

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 — N/A, no third-party code
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

Fixes #1581

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4788985479 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1629). Originally posted by [ahmedhamouda78](https://github.com/ahmedhamouda78) on 2026-10-08T15:18:51Z. --- ### What `sceAgcDcbResetQueue` wrote only a single `c0001200 <state>` CLEAR_STATE packet and ignored `op` entirely (the KytyPS5 approximation). This replaces it with the sequence measured on a PS5 (firmware 13.60): an envelope (`ffff1000` / `c0027904 00000342 ce20<op&ffff> <flag>` ... `c0017904 00000342 cea00000`) plus one packet group per set `op` bit, emitted in ascending bit order. Groups are emitted for op bits `0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x080, 0x100, 0x800`. The three bits whose groups the driver's `Pm4::Validate` currently rejects — `0x040` (whole-range ACQUIRE_MEM), `0x200` (EVENT_WRITE event 56), `0x400` (opcode 0x1E) — throw a clear error instead of being emitted, so this change cannot make a title stop inside the driver. Supporting those bits needs the driver-side acceptance first and belongs in a separate PR. `state` 2 sets the envelope flag dword to `0x00000008`; `state` 3 sets the `0x004`/`0x800` group's payload dword to `0x00840f80`; the other measured `state` values (0, 1, 4, 8, 0xF) produce the state-0 form. ### Tested Linux, GCC 16.2.0, C++20. The AGC command test suite (`agc_command_tests` — `testPackets`) was extended with exact-byte assertions for the envelope, single groups, the `state` 2 and `state` 3 variants, `op=0x800`, and that an unsupported bit throws and leaves the buffer unmodified; the suite passes. Every emitted byte was checked against the hardware probe output in #1581. Not run on hardware or against a title. Semantics source: the packet bytes and `op`/`state` behaviour come from the PS5 firmware 13.60 measurement in issue #1581 (the `sceAgcDcbResetQueue` probe loading `libSceAgc.sprx` and dumping the command buffer), not from a cited ISA/driver source. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [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 — N/A, no third-party code - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes Fixes #1581
klosixgaming-arch commented 2026-10-08 15:34:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-08T15:34:07Z.

Review: APPROVED


LGTM. Excellent implementation that replaces the simplified KytyPS5 approximation with the actual packet sequence measured on PS5 hardware (firmware 13.60). The structure is clean - envelope construction, per-bit group emission in ascending order, proper state handling for special cases (state=2 flag, state=3 payload), and clear error throwing for unsupported bits that need driver-side acceptance first. Test coverage is thorough with exact-byte assertions against hardware probe output, covering base case, single groups, state variations, upper bits, and all three unsupported bit errors. Significant improvement over the previous implementation.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5459132994 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1629#pullrequestreview-5459132994). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-08T15:34:07Z. **Review:** APPROVED --- LGTM. Excellent implementation that replaces the simplified KytyPS5 approximation with the actual packet sequence measured on PS5 hardware (firmware 13.60). The structure is clean - envelope construction, per-bit group emission in ascending order, proper state handling for special cases (state=2 flag, state=3 payload), and clear error throwing for unsupported bits that need driver-side acceptance first. Test coverage is thorough with exact-byte assertions against hardware probe output, covering base case, single groups, state variations, upper bits, and all three unsupported bit errors. Significant improvement over the previous implementation.
popcoder565 commented 2026-10-09 19:42:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:42:25Z.


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 73eb8465, merged onto main 8b393b6e in one build with 31 other PRs that had no Windows run.

  • This PR's tests pass: agc_commands.
  • Full ctest in that build: 520 of 521. The one failure is guest_offline_imports, broken by #2359 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088018254 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1629#issuecomment-6088018254). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T19:42:25Z. --- 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 `73eb8465`, merged onto `main` 8b393b6e in one build with 31 other PRs that had no Windows run. - This PR's tests pass: `agc_commands`. - Full ctest in that build: 520 of 521. The one failure is `guest_offline_imports`, broken by #2359 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
adriadam10 commented 2026-10-10 05:58:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T05:58:20Z.


Checked the build and agc_commands on Linux (the test fails without the change), the packet groups against the measurements in #1581, and the unsupported bits (0x040/0x200/0x400) throwing without touching the buffer. Windows run by @popcoder565 passes too. Merging once Linux CI is green (the earlier red was a cancelled lavapipe install step, rerun).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094430024 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1629#issuecomment-6094430024). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T05:58:20Z. --- Checked the build and `agc_commands` on Linux (the test fails without the change), the packet groups against the measurements in #1581, and the unsupported bits (0x040/0x200/0x400) throwing without touching the buffer. Windows run by @popcoder565 passes too. Merging once Linux CI is green (the earlier red was a cancelled lavapipe install step, rerun).
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!1629
No description provided.