fix(libSceAgc): emit NOP packets for the DCB workload calls #3789

Merged
xXPBSXx merged 2 commits from upstream-pr/3789 into main 2026-10-12 11:44:27 +00:00
xXPBSXx commented 2026-10-11 16:43:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T16:43:36Z.


What

sceAgcDcbSetWorkloadsActive and sceAgcDcbSetWorkloadComplete threw. They now follow KytyPS5 (src/libs/agc.cpp): an 18-dword (active) or 12-dword (complete) IT_NOP packet carrying the stream id, and for active the 64-bit mask of the workload ids, for complete the workload id and the 64-bit clear mask. Both return null for a null command buffer, an unregistered or out-of-range stream (1 to 31), a workload id above 63, and for active a duplicate id or a count of 0 or above 63. sceAgcDriverRegisterWorkloadStream and sceAgcDriverUnregisterWorkloadStream record the stream ids that the DCB calls check; registration still returns 0 for every argument, since the console's error codes for an invalid or repeated registration are unknown. This changes the first version of this PR (a plain two-dword NOP), after review.

Tested

  • Windows 10, MinGW/Ninja build of main a11c8f7f7 plus this branch: ctest -R "agc_commands|agc_initialization|guest_agc_driver_resources" passes. testWorkloads pins the packet header, stream id, mask, clear mask and the zero tail for ids {3,4} and workload 33, and each null case above, including after unregistration. python tools/check_conventions.py --base upstream/main passes.
  • I did not run the test against the previous version of the implementation. No title was run (PPSA29866 calls sceAgcDcbSetWorkloadsActive). Not tested: Linux, macOS.
  • The packet layouts and the validation come from KytyPS5 alone. The console oracle in prosper (agcbuild.golden.tsv) measures a null return for unregistered streams, not the packet of a registered one; this and the registration behaviour are in TechnicalDebt.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820650218 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-11T16:43:36Z. --- ### What `sceAgcDcbSetWorkloadsActive` and `sceAgcDcbSetWorkloadComplete` threw. They now follow KytyPS5 (`src/libs/agc.cpp`): an 18-dword (active) or 12-dword (complete) `IT_NOP` packet carrying the stream id, and for active the 64-bit mask of the workload ids, for complete the workload id and the 64-bit clear mask. Both return null for a null command buffer, an unregistered or out-of-range stream (1 to 31), a workload id above 63, and for active a duplicate id or a count of 0 or above 63. `sceAgcDriverRegisterWorkloadStream` and `sceAgcDriverUnregisterWorkloadStream` record the stream ids that the DCB calls check; registration still returns 0 for every argument, since the console's error codes for an invalid or repeated registration are unknown. This changes the first version of this PR (a plain two-dword NOP), after review. ### Tested - Windows 10, MinGW/Ninja build of `main` a11c8f7f7 plus this branch: `ctest -R "agc_commands|agc_initialization|guest_agc_driver_resources"` passes. `testWorkloads` pins the packet header, stream id, mask, clear mask and the zero tail for ids {3,4} and workload 33, and each null case above, including after unregistration. `python tools/check_conventions.py --base upstream/main` passes. - I did not run the test against the previous version of the implementation. No title was run (PPSA29866 calls `sceAgcDcbSetWorkloadsActive`). Not tested: Linux, macOS. - The packet layouts and the validation come from KytyPS5 alone. The console oracle in prosper (`agcbuild.golden.tsv`) measures a null return for unregistered streams, not the packet of a registered one; this and the registration behaviour are in TechnicalDebt. ### 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 - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-11 16:44:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T16:44:34Z.


Progress report (bca7a29 → 2a7b38a)

📈 System libraries: 86.53% (+0.06%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceAgc sceAgcDcbSetWorkloadComplete
libSceAgc sceAgcDcbSetWorkloadsActive
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111304880 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6111304880). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T16:44:34Z. --- <!-- progress-report --> ### Progress report (bca7a29 → 2a7b38a) 📈 **System libraries**: 86.53% (+0.06%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libSceAgc | `sceAgcDcbSetWorkloadComplete` | | libSceAgc | `sceAgcDcbSetWorkloadsActive` | </details>
adriadam10 commented 2026-10-11 16:52:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T16:52:36Z.

Review: DISMISSED


Thanks for the PR. Two problems, both about returning a plausible result where main threw:

  • Workload.cpp:13-19: the packet size and contents are invented. KytyPS5 (src/libs/agc.cpp, AgcDcbSetWorkloadsActive/AgcDcbSetWorkloadComplete) writes an 18-dword (active) / 12-dword (complete) IT_NOP packet carrying the stream id and the workload mask (complete: stream id, workload id, clear mask). A 2-dword NOP is not what any reference emits, and the TechnicalDebt line itself says the real packet is unknown.
  • No argument validation: prosper's console oracle (tests/data/console_oracle/agcbuild.golden.tsv, agcbuild_DcbSetWorkloadsActive_* / agcbuild_DcbSetWorkloadComplete_*) measures a null return on a real console for unregistered streams, and KytyPS5 also returns null for stream id outside 1..31, workload id > 63, duplicate ids, and count 0 or > 63 (active). This PR returns a packet in all those cases, and testWorkloads pins that.

Suggested direction: follow KytyPS5's packet layouts and checks (the workload stream registry comes from sceAgcDriverRegisterWorkloadStream, so that is a prerequisite, or the unregistered case has to throw), pin the values in the test from the reference, and keep unverified parts in TechnicalDebt. Otherwise keep throwing.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5484124785 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#pullrequestreview-5484124785). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T16:52:36Z. **Review:** DISMISSED --- Thanks for the PR. Two problems, both about returning a plausible result where `main` threw: - `Workload.cpp:13-19`: the packet size and contents are invented. KytyPS5 (`src/libs/agc.cpp`, `AgcDcbSetWorkloadsActive`/`AgcDcbSetWorkloadComplete`) writes an 18-dword (active) / 12-dword (complete) `IT_NOP` packet carrying the stream id and the workload mask (complete: stream id, workload id, clear mask). A 2-dword NOP is not what any reference emits, and the TechnicalDebt line itself says the real packet is unknown. - No argument validation: prosper's console oracle (`tests/data/console_oracle/agcbuild.golden.tsv`, `agcbuild_DcbSetWorkloadsActive_*` / `agcbuild_DcbSetWorkloadComplete_*`) measures a null return on a real console for unregistered streams, and KytyPS5 also returns null for stream id outside 1..31, workload id > 63, duplicate ids, and count 0 or > 63 (active). This PR returns a packet in all those cases, and `testWorkloads` pins that. Suggested direction: follow KytyPS5's packet layouts and checks (the workload stream registry comes from `sceAgcDriverRegisterWorkloadStream`, so that is a prerequisite, or the unregistered case has to throw), pin the values in the test from the reference, and keep unverified parts in TechnicalDebt. Otherwise keep throwing.
xXPBSXx commented 2026-10-11 17:11:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T17:11:43Z.


Thanks, both points are right. Pushed a167cb231: the packets now follow KytyPS5 (18-dword active with stream id and 64-bit workload mask, 12-dword complete with stream id, workload id and 64-bit clear mask), and both calls return null for a null buffer, an unregistered or out-of-range stream, a workload id above 63, and for active a duplicate id or a count of 0 or above 63. The registry is the one you suggested: sceAgcDriverRegisterWorkloadStream / sceAgcDriverUnregisterWorkloadStream record ids 1 to 31, and registration still returns 0 for every argument because I have no source for the console's error codes. testWorkloads pins the values from the reference. The description is updated; the layouts rest on KytyPS5 only (the prosper oracle covers the unregistered case, not a registered packet), which TechnicalDebt now says.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111555544 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6111555544). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-11T17:11:43Z. --- Thanks, both points are right. Pushed `a167cb231`: the packets now follow KytyPS5 (18-dword active with stream id and 64-bit workload mask, 12-dword complete with stream id, workload id and 64-bit clear mask), and both calls return null for a null buffer, an unregistered or out-of-range stream, a workload id above 63, and for active a duplicate id or a count of 0 or above 63. The registry is the one you suggested: `sceAgcDriverRegisterWorkloadStream` / `sceAgcDriverUnregisterWorkloadStream` record ids 1 to 31, and registration still returns 0 for every argument because I have no source for the console's error codes. `testWorkloads` pins the values from the reference. The description is updated; the layouts rest on KytyPS5 only (the prosper oracle covers the unregistered case, not a registered packet), which TechnicalDebt now says. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-11 23:17:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T23:17:05Z.


Conflicts with main in docs/dev/TechnicalDebt.md; please rebase.

No title was run. Please run PPSA29866 on the branch and quote the line where it stops on main and the one where it stops with this.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115006302 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6115006302). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T23:17:05Z. --- Conflicts with main in `docs/dev/TechnicalDebt.md`; please rebase. No title was run. Please run PPSA29866 on the branch and quote the line where it stops on main and the one where it stops with this.
xXPBSXx commented 2026-10-11 23:46:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-11T23:46:51Z.


@adriadam10 rebased onto current main (bca7a29d2): the branch conflicted in docs/dev/TechnicalDebt.md only, and I resolved it by keeping main's three entries at the end and placing this PR's entry in front of them, away from the end of the file. The code is unchanged since the review round: the two points from your review (packet layouts and checks after KytyPS5, null for unregistered streams through the driver's workload-stream registry) are answered as in my earlier comment. Built and tested on Windows after the rebase: agc_initialization, agc_commands and guest_agc_driver_resources pass, and tools/check_conventions.py --base upstream/main passes. The branch was force-pushed (own PR branch, --force-with-lease).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115256673 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6115256673). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-11T23:46:51Z. --- @adriadam10 rebased onto current `main` (bca7a29d2): the branch conflicted in `docs/dev/TechnicalDebt.md` only, and I resolved it by keeping `main`'s three entries at the end and placing this PR's entry in front of them, away from the end of the file. The code is unchanged since the review round: the two points from your review (packet layouts and checks after KytyPS5, null for unregistered streams through the driver's workload-stream registry) are answered as in my earlier comment. Built and tested on Windows after the rebase: `agc_initialization`, `agc_commands` and `guest_agc_driver_resources` pass, and `tools/check_conventions.py --base upstream/main` passes. The branch was force-pushed (own PR branch, `--force-with-lease`). AI-assisted (Claude Code).
github-actions[bot] commented 2026-10-12 00:34:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T00:34:36Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#2847 core/libs/prx/libSceAgc/tests/Commands.cpp L210, L561
#4377 docs/dev/TechnicalDebt.md L709
#4382 docs/dev/TechnicalDebt.md L709
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6115659492 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6115659492). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T00:34:36Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2847 | `core/libs/prx/libSceAgc/tests/Commands.cpp` [L210](https://github.com/boykopovar/AnyPS5/blob/ac2ad045fc7e890a2ac081e3742c13df29d2b00a/core/libs/prx/libSceAgc/tests/Commands.cpp#L210), [L561](https://github.com/boykopovar/AnyPS5/blob/ac2ad045fc7e890a2ac081e3742c13df29d2b00a/core/libs/prx/libSceAgc/tests/Commands.cpp#L561) | | | | #4377 | `docs/dev/TechnicalDebt.md` [L709](https://github.com/boykopovar/AnyPS5/blob/ac2ad045fc7e890a2ac081e3742c13df29d2b00a/docs/dev/TechnicalDebt.md#L709) | | | | #4382 | `docs/dev/TechnicalDebt.md` [L709](https://github.com/boykopovar/AnyPS5/blob/ac2ad045fc7e890a2ac081e3742c13df29d2b00a/docs/dev/TechnicalDebt.md#L709) | | |
xXPBSXx commented 2026-10-12 01:58:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T01:58:10Z.


Title run as requested, PPSA29866 (Tomba! 2 SE), Windows, GCC, RTX 4080 SUPER, on current main + #3819 (the title's missing imports):

  • without this PR it stops at: what(): sceAgcDcbSetWorkloadsActive not implemented, then SIGABRT;
  • with this PR (#3789 merged locally on top) there is no abort or exception during a 150 s run; the log shows draws, shader disk cache activity and extra threads starting. I did not judge the rendered picture.

Only the workload calls were checked this way; whether the packet contents match a console is not tested (layouts follow KytyPS5 as in the earlier comment).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6116392113 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3789#issuecomment-6116392113). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T01:58:10Z. --- Title run as requested, PPSA29866 (Tomba! 2 SE), Windows, GCC, RTX 4080 SUPER, on current main + #3819 (the title's missing imports): - without this PR it stops at: `what(): sceAgcDcbSetWorkloadsActive not implemented`, then SIGABRT; - with this PR (#3789 merged locally on top) there is no abort or exception during a 150 s run; the log shows draws, shader disk cache activity and extra threads starting. I did not judge the rendered picture. Only the workload calls were checked this way; whether the packet contents match a console is not tested (layouts follow KytyPS5 as in the earlier comment). AI-assisted (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!3789
No description provided.