fix(libSceAgcDriver): step over the one-dword NOP pad ffff1000 #1862

Merged
aashishaxo merged 1 commit from upstream-pr/1862 into main 2026-10-10 07:18:40 +00:00
aashishaxo commented 2026-10-08 22:19:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aashishaxo on 2026-10-08T22:19:54Z.


What

Step 1 of #1581. 0xffff1000 is a type-3 NOP with count 0x3fff, which the command processor reads as one dword. sceAgcDcbResetQueue writes it at the start of every call (measured on a PS5 in #1581), and the driver read it as a 16385-dword packet ("invalid PM4 packet size").

Pm4::FillerPacket now also matches exactly 0xffff1000, so every walker (validation, submission, COND_EXEC ranges, execution) steps over it as one dword. The match is on the whole header, as in Mesa: src/amd/common/ac_parse_ib.c checks header == PKT3_NOP_PAD, and sid.h defines PKT3_NOP_PAD as PKT3(PKT3_NOP, 0x3fff, 0). A NOP with count 0x3fff and other header bits set is still sized by its count. d4f7ddaa used the wider 0x3fffff00 mask for range predication; this PR keeps the exact header from Mesa.

Refs #1581

Tested

Fork CI on c975fe54, before rebasing onto current main (84703ca7, same diff) (Linux and Windows build + ctest, relinker on Ubuntu, Windows and macOS): https://github.com/aashishaxo/AnyPS5/actions/runs/37848985909

  • testNopPad: Validate accepts the pad on graphics and compute queues and rejects it with a trailing dword; NOPs with count 0x3fff and header flags, and the largest counted NOP, are still sized by their count.
  • testNopPadSubmission: the measured op = 0 envelope from #1581 submits and the packets after it run; a COND_EXEC range containing the pad counts it as one dword.

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:4793472127 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862). Originally posted by [aashishaxo](https://github.com/aashishaxo) on 2026-10-08T22:19:54Z. --- ### What Step 1 of #1581. `0xffff1000` is a type-3 NOP with count 0x3fff, which the command processor reads as one dword. `sceAgcDcbResetQueue` writes it at the start of every call (measured on a PS5 in #1581), and the driver read it as a 16385-dword packet ("invalid PM4 packet size"). `Pm4::FillerPacket` now also matches exactly `0xffff1000`, so every walker (validation, submission, COND_EXEC ranges, execution) steps over it as one dword. The match is on the whole header, as in Mesa: `src/amd/common/ac_parse_ib.c` checks `header == PKT3_NOP_PAD`, and `sid.h` defines `PKT3_NOP_PAD` as `PKT3(PKT3_NOP, 0x3fff, 0)`. A NOP with count 0x3fff and other header bits set is still sized by its count. d4f7ddaa used the wider `0x3fffff00` mask for range predication; this PR keeps the exact header from Mesa. Refs #1581 ### Tested Fork CI on c975fe54, before rebasing onto current main (84703ca7, same diff) (Linux and Windows build + ctest, relinker on Ubuntu, Windows and macOS): https://github.com/aashishaxo/AnyPS5/actions/runs/37848985909 - `testNopPad`: Validate accepts the pad on graphics and compute queues and rejects it with a trailing dword; NOPs with count 0x3fff and header flags, and the largest counted NOP, are still sized by their count. - `testNopPadSubmission`: the measured `op = 0` envelope from #1581 submits and the packets after it run; a COND_EXEC range containing the pad counts it as one dword. ### 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
popcoder565 commented 2026-10-09 15:23:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:23:09Z.


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 84703ca7, merged onto main d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run.

  • This PR's tests pass: agc_driver_pm4, agc_driver_pm4_failure. None of them reported skipping a case.
  • Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows PATH setup.

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6083885371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862#issuecomment-6083885371). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:23:09Z. --- 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 `84703ca7`, merged onto `main` d70b8998 in one build with 33 other AGC/shader PRs that had no Windows run. - This PR's tests pass: `agc_driver_pm4`, `agc_driver_pm4_failure`. None of them reported skipping a case. - Full ctest in that build: 514 of 515. The one failure is #2257's new test, which is registered without the Windows `PATH` setup. No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
oneandonlydean commented 2026-10-10 03:19:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T03:19:04Z.


This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093233202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862#issuecomment-6093233202). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T03:19:04Z. --- This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.
aashishaxo commented 2026-10-10 05:56:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aashishaxo on 2026-10-10T05:56:40Z.


This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready.

Rebased onto main. The conflict was the test registration in tests/Pm4.cpp main(); both tests are kept. Build and Progress report are waiting for workflow approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094417015 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862#issuecomment-6094417015). Originally posted by [aashishaxo](https://github.com/aashishaxo) on 2026-10-10T05:56:40Z. --- > This conflicts with main after today's merges; could you rebase? It passed testing and is otherwise ready. Rebased onto main. The conflict was the test registration in tests/Pm4.cpp main(); both tests are kept. Build and Progress report are waiting for workflow approval.
aashishaxo commented 2026-10-10 06:08:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by aashishaxo on 2026-10-10T06:08:53Z.


Heads-up: #1629 is merged, so sceAgcDcbResetQueue on main now starts every sequence with ffff1000 (DcbFlow/src/Control.cpp:82). The driver on main still sizes that header as a type-3 packet (Pm4::PacketWords gives 16385 dwords), and this PR is what makes it step over the pad as one dword. It merges cleanly onto current main; Build and Progress report are waiting for workflow approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6094510069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862#issuecomment-6094510069). Originally posted by [aashishaxo](https://github.com/aashishaxo) on 2026-10-10T06:08:53Z. --- Heads-up: #1629 is merged, so `sceAgcDcbResetQueue` on main now starts every sequence with `ffff1000` (`DcbFlow/src/Control.cpp:82`). The driver on main still sizes that header as a type-3 packet (`Pm4::PacketWords` gives 16385 dwords), and this PR is what makes it step over the pad as one dword. It merges cleanly onto current main; Build and Progress report are waiting for workflow approval.
adriadam10 commented 2026-10-10 07:18:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:18:37Z.


Rebase checked: same diff as before. agc_driver_pm4 and agc_driver_pm4_failure pass on the rebased head merged onto current main (scoped to libSceAgcDriver, 304 tests green); the new agc_driver_pm4 test fails without the Pm4.hpp change. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095048057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1862#issuecomment-6095048057). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T07:18:37Z. --- Rebase checked: same diff as before. `agc_driver_pm4` and `agc_driver_pm4_failure` pass on the rebased head merged onto current main (scoped to libSceAgcDriver, 304 tests green); the new `agc_driver_pm4` test fails without the `Pm4.hpp` change. Merging.
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!1862
No description provided.