feat(agc): emit the remaining workload packets for registered streams #6128

Closed
fdfawef324 wants to merge 1 commit from upstream-pr/6128 into main
fdfawef324 commented 2026-10-14 22:52:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T22:52:45Z.


What

sceAgcAcbSetWorkloadsActive, sceAgcAcbSetWorkloadComplete, sceAgcAcbSetWorkloadStreamInactive and sceAgcDcbSetWorkloadStreamInactive threw NotImplemented for a registered workload stream.

Relation to #4709

#4709 made these four return null for a null buffer or an unregistered stream. It kept the registered case throwing because the console packet is not measured, and KytyPS5 (IT_NOP) and OpenAGC (SET_UCONFIG_REG, WRITE_DATA, SET_WORKLOAD) disagree on the layout. This PR does not claim to know the console packet either. It writes an IT_NOP of the console sequence's size, and for each sequence it says what the console packet does and what is dropped here. The sequences are from OpenAGC agc_workload_packet.c, with exact bytes in its test.

Call Console sequence (OpenAGC) Here
stream inactive SET_UCONFIG_REG (4 dwords): 0xcc000000 | streamId and 0 to 0x342 and 0x343. WRITE_DATA (5): 0 to register 0xc343. No SET_WORKLOAD, no slot address 9-dword IT_NOP: stream id, seven zero dwords
active SET_UCONFIG_REG (4): 0xcc000000 | streamId and the low mask to 0x342 and 0x343. WRITE_DATA (5): the high mask to 0xc343. SET_WORKLOAD (0x1e, 9): control word, stream slot address, mask 18-dword IT_NOP: stream id, 64-bit mask (KytyPS5, on main for the DCB since #3789)
complete SET_UCONFIG_REG (3): 0xcd000000 | workloadId << 5 | streamId to 0x342. SET_WORKLOAD (9): control word, slot address, clear mask. No WRITE_DATA 12-dword IT_NOP: stream id, workload id, 64-bit clear mask (KytyPS5, on main for the DCB since #3789)
  • Registers 0xc342 and 0xc343 (uconfig 0x342 and 0x343) are SQ_THREAD_TRACE_USERDATA_2 and _3, at 0x30D08 and 0x30D0C in Mesa's gfx10.json and gfx103.json. RADV writes its RGP markers to them two dwords at a time (radv_sqtt.c). They only feed SQ thread traces, which are not emulated. The AGC driver already drops libSceAgc's predicated tag writes to 0x342 as carrying no register state (IsTagMarker in Pm4.cpp). Stream inactive writes nothing else, so its 9-dword NOP has the console's effect apart from the thread trace.
  • Active and complete also issue SET_WORKLOAD, which writes the mask to the stream's 8-byte slot in a 0x200-byte table. OpenAGC carves that table from the SceGnmGpuInfo region at offset 0x3A000 (driver_prospero.c). It publishes the region as the Sce.Debug:Gnm process property, named SceGnmDumpArea (L925-L940). It is driver memory, not title memory. This write is dropped here, and its effect is not verified. OpenAGC keeps its own use of the sequence disabled on firmware 11.60 after its submissions stalled (L1736-L1742). The DCB active and complete calls on main have dropped this write since #3789; this PR does the same for the ACB.
  • On the console the ACB and DCB sequences differ. OpenAGC passes a control flag for the ACB. The flag clears header bit 2 of SET_UCONFIG_REG and WRITE_DATA (0xc0027904 becomes 0xc0027900) and bit 30 of the SET_WORKLOAD control word. The IT_NOP form carries neither, so here the ACB and DCB calls write identical packets.

So the case against #4709's throw is that the dropped effect is limited to the thread trace and a driver-owned table, that the debt entry records both, and that main has used the same stand-in for the DCB since #3789. Keeping the throw remains the alternative if that is not enough.

Changes

  • DcbState/src/Workload.cpp: the DCB active and complete encoders move into Agc::Workload::WriteActive and WriteComplete, and a new WriteStreamInactive is added. The DCB exports call them; their arguments are renamed to camelCase. The ACB exports in Acb/src/Control.cpp call the same functions.
  • Validation does not change. All six calls return null without writing for a null buffer and for an unregistered or out-of-range stream. Complete also returns null for a workload id above 63. Active also returns null for a null workload id array, a count of 0 or above 63, an id above 63 or a duplicate id. The active calls still check the stream before they read the ids.
  • AGC driver: no change. Pm4::Validate accepts a plain NOP (custom field 0) on graphics and compute queues when it is not predicated. Its only check, against 0x6875xxxx flip markers, cannot match a stream id of 1 to 31. Pm4::Execute returns at once for it.
  • Known gap, recorded in the debt entry: Pm4::Validate throws on a NOP with the predicate bit set. So a workload packet predicated by sceAgcSetRangePredication or sceAgcSetPacketPredication throws at submission. Every IT_NOP libSceAgc writes already behaves this way, including markers and the DCB workload packets on main. Accepting a predicated plain NOP in Validate is a separate change.
  • docs/dev/debt/libSceAgc.md: the two workload entries are merged into one. It describes each sequence separately, the effect argument above, the dropped SET_WORKLOAD write, the ACB control flag and the predication gap. The KytyPS5 link is pinned to 6f0cddd, whose agc.cpp is identical to KytyPS5 main today.

Title IDs: none in core/. No title was run. No title is shown calling these functions on a registered stream, so nothing is claimed to be unblocked.

Tested

Windows Server 2025 (10.0.26100), AMD Ryzen 9 5900X, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON. Rebased on main eea428ca8.

  • New testRegisteredWorkloadStreams in agc_commands:
    • Registers stream 5. Writes the active ({0, 33, 63}), complete (33) and stream inactive packets once through the DCB calls and once through the ACB calls, into two buffers filled with 0xdeadbeef.
    • Checks each returned pointer, the 39-dword cursor advance and the active mask (0x00000001, 0x80000002). Checks the inactive packet (header Header(0x10, 9, 0), stream id, seven zero dwords) and that nothing was written past it.
    • Checks that the two buffers are equal byte for byte. This pins that both calls share the IT_NOP stand-in. It is not console parity: the console ACB and DCB sequences differ by the control flag above.
    • Runs each DCB packet through AgcDriver::Pm4::Validate/Execute on queue 0, and each ACB packet on compute queue 0x20.
    • Checks the ACB rejections without writing: duplicate ids, id 64, count 0 and 64, null ids, complete id 64. Also checks a null buffer, and every call after the stream is unregistered.
    • Replaces the part of testWorkloadStreams that expected the registered calls to throw.
  • Red: with the new test and main's Workload.hpp, Workload.cpp and Control.cpp, agc_commands fails with sceAgcAcbSetWorkloadsActive not implemented.
  • Green: with this change agc_commands passes (0.24 s).
  • The following 25 tests pass, 8 s in total: agc_initialization, agc_commands, agc_platform_tests, agc_semaphore_tests, agc_packet_info_tests, agc_register_command_tests, agc_cb_cond_write_tests, agc_payload_range_tests, agc_end_of_shader_action_size_tests, agc_branch_patch_tests, agc_predication_tests, agc_shader_fusion, agc_context_state_size_tests, agc_interpolant_mapping, guest_shader_link, agc_gs_oversubscription_tests, agc_gs_prim_payload_tests, agc_dma_data_tests, agc_write_data_patch_tests, agc_prime_utcl2_tests, agc_cond_exec_patch_tests, agc_shader_helpers, agc_driver_pm4, agc_driver_pm4_failure and guest_agc_driver_resources.
  • tools/check_conventions.py from main eea428ca8, with --title and --body: passes.

Not tested: Linux, macOS, titles, Vulkan rendering. No test here does GPU work; the driver check is PM4 validation and execution on the CPU.

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
  • Unblocks: none
  • GPUs tested: n/a (no AGC driver change; the test runs Pm4::Validate/Execute on the CPU, no GPU work)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4865650429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6128). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T22:52:45Z. --- ### What `sceAgcAcbSetWorkloadsActive`, `sceAgcAcbSetWorkloadComplete`, `sceAgcAcbSetWorkloadStreamInactive` and `sceAgcDcbSetWorkloadStreamInactive` threw `NotImplemented` for a registered workload stream. #### Relation to #4709 #4709 made these four return null for a null buffer or an unregistered stream. It kept the registered case throwing because the console packet is not measured, and KytyPS5 (`IT_NOP`) and OpenAGC (SET_UCONFIG_REG, WRITE_DATA, SET_WORKLOAD) disagree on the layout. This PR does not claim to know the console packet either. It writes an `IT_NOP` of the console sequence's size, and for each sequence it says what the console packet does and what is dropped here. The sequences are from OpenAGC [`agc_workload_packet.c`](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/agc_workload_packet.c#L18-L104), with exact bytes in its [test](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/tests/test_workload_packet.c#L8-L105). | Call | Console sequence (OpenAGC) | Here | |---|---|---| | stream inactive | SET_UCONFIG_REG (4 dwords): `0xcc000000 \| streamId` and 0 to 0x342 and 0x343. WRITE_DATA (5): 0 to register 0xc343. No SET_WORKLOAD, no slot address | 9-dword `IT_NOP`: stream id, seven zero dwords | | active | SET_UCONFIG_REG (4): `0xcc000000 \| streamId` and the low mask to 0x342 and 0x343. WRITE_DATA (5): the high mask to 0xc343. SET_WORKLOAD (0x1e, 9): control word, stream slot address, mask | 18-dword `IT_NOP`: stream id, 64-bit mask ([KytyPS5](https://github.com/KytyPS5/KytyPS5/blob/6f0cddd4404ec5203e71fea77e75fc373299ba3f/src/libs/agc.cpp#L2181-L2269), on `main` for the DCB since #3789) | | complete | SET_UCONFIG_REG (3): `0xcd000000 \| workloadId << 5 \| streamId` to 0x342. SET_WORKLOAD (9): control word, slot address, clear mask. No WRITE_DATA | 12-dword `IT_NOP`: stream id, workload id, 64-bit clear mask (KytyPS5, on `main` for the DCB since #3789) | - Registers 0xc342 and 0xc343 (uconfig 0x342 and 0x343) are `SQ_THREAD_TRACE_USERDATA_2` and `_3`, at 0x30D08 and 0x30D0C in Mesa's [gfx10.json](https://gitlab.freedesktop.org/mesa/mesa/-/blob/fadee2bd99d47742caf7849bae033a4947f0ff77/src/amd/registers/gfx10.json#L8376-8385) and [gfx103.json](https://gitlab.freedesktop.org/mesa/mesa/-/blob/fadee2bd99d47742caf7849bae033a4947f0ff77/src/amd/registers/gfx103.json#L7777-7786). RADV writes its RGP markers to them two dwords at a time ([radv_sqtt.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/fadee2bd99d47742caf7849bae033a4947f0ff77/src/amd/vulkan/tools/radv_sqtt.c#L107-151)). They only feed SQ thread traces, which are not emulated. The AGC driver already drops libSceAgc's predicated tag writes to 0x342 as carrying no register state (`IsTagMarker` in `Pm4.cpp`). Stream inactive writes nothing else, so its 9-dword NOP has the console's effect apart from the thread trace. - Active and complete also issue SET_WORKLOAD, which writes the mask to the stream's 8-byte slot in a 0x200-byte table. OpenAGC carves that table from the `SceGnmGpuInfo` region at offset 0x3A000 ([driver_prospero.c](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/driver_prospero.c#L851-L855)). It publishes the region as the `Sce.Debug:Gnm` process property, named `SceGnmDumpArea` ([L925-L940](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/driver_prospero.c#L925-L940)). It is driver memory, not title memory. **This write is dropped here, and its effect is not verified.** OpenAGC keeps its own use of the sequence disabled on firmware 11.60 after its submissions stalled ([L1736-L1742](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/driver_prospero.c#L1736-L1742)). The DCB active and complete calls on `main` have dropped this write since #3789; this PR does the same for the ACB. - On the console the ACB and DCB sequences differ. [OpenAGC](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/game_compat.c#L2317-L2318) passes a control flag for the ACB. The flag clears header bit 2 of SET_UCONFIG_REG and WRITE_DATA (`0xc0027904` becomes `0xc0027900`) and bit 30 of the SET_WORKLOAD control word. The `IT_NOP` form carries neither, so here the ACB and DCB calls write identical packets. So the case against #4709's throw is that the dropped effect is limited to the thread trace and a driver-owned table, that the debt entry records both, and that `main` has used the same stand-in for the DCB since #3789. Keeping the throw remains the alternative if that is not enough. #### Changes - `DcbState/src/Workload.cpp`: the DCB active and complete encoders move into `Agc::Workload::WriteActive` and `WriteComplete`, and a new `WriteStreamInactive` is added. The DCB exports call them; their arguments are renamed to camelCase. The ACB exports in `Acb/src/Control.cpp` call the same functions. - Validation does not change. All six calls return null without writing for a null buffer and for an unregistered or out-of-range stream. Complete also returns null for a workload id above 63. Active also returns null for a null workload id array, a count of 0 or above 63, an id above 63 or a duplicate id. The active calls still check the stream before they read the ids. - AGC driver: no change. `Pm4::Validate` accepts a plain NOP (custom field 0) on graphics and compute queues when it is not predicated. Its only check, against `0x6875xxxx` flip markers, cannot match a stream id of 1 to 31. `Pm4::Execute` returns at once for it. - Known gap, recorded in the debt entry: `Pm4::Validate` throws on a NOP with the predicate bit set. So a workload packet predicated by `sceAgcSetRangePredication` or `sceAgcSetPacketPredication` throws at submission. Every `IT_NOP` libSceAgc writes already behaves this way, including markers and the DCB workload packets on `main`. Accepting a predicated plain NOP in `Validate` is a separate change. - `docs/dev/debt/libSceAgc.md`: the two workload entries are merged into one. It describes each sequence separately, the effect argument above, the dropped SET_WORKLOAD write, the ACB control flag and the predication gap. The KytyPS5 link is pinned to 6f0cddd, whose `agc.cpp` is identical to KytyPS5 `main` today. Title IDs: none in `core/`. No title was run. No title is shown calling these functions on a registered stream, so nothing is claimed to be unblocked. ### Tested Windows Server 2025 (10.0.26100), AMD Ryzen 9 5900X, WinLibs MinGW-w64 GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`. Rebased on `main` eea428ca8. - New `testRegisteredWorkloadStreams` in `agc_commands`: - Registers stream 5. Writes the active ({0, 33, 63}), complete (33) and stream inactive packets once through the DCB calls and once through the ACB calls, into two buffers filled with `0xdeadbeef`. - Checks each returned pointer, the 39-dword cursor advance and the active mask (`0x00000001`, `0x80000002`). Checks the inactive packet (header `Header(0x10, 9, 0)`, stream id, seven zero dwords) and that nothing was written past it. - Checks that the two buffers are equal byte for byte. This pins that both calls share the `IT_NOP` stand-in. It is not console parity: the console ACB and DCB sequences differ by the control flag above. - Runs each DCB packet through `AgcDriver::Pm4::Validate`/`Execute` on queue 0, and each ACB packet on compute queue 0x20. - Checks the ACB rejections without writing: duplicate ids, id 64, count 0 and 64, null ids, complete id 64. Also checks a null buffer, and every call after the stream is unregistered. - Replaces the part of `testWorkloadStreams` that expected the registered calls to throw. - Red: with the new test and `main`'s `Workload.hpp`, `Workload.cpp` and `Control.cpp`, `agc_commands` fails with `sceAgcAcbSetWorkloadsActive not implemented`. - Green: with this change `agc_commands` passes (0.24 s). - The following 25 tests pass, 8 s in total: `agc_initialization`, `agc_commands`, `agc_platform_tests`, `agc_semaphore_tests`, `agc_packet_info_tests`, `agc_register_command_tests`, `agc_cb_cond_write_tests`, `agc_payload_range_tests`, `agc_end_of_shader_action_size_tests`, `agc_branch_patch_tests`, `agc_predication_tests`, `agc_shader_fusion`, `agc_context_state_size_tests`, `agc_interpolant_mapping`, `guest_shader_link`, `agc_gs_oversubscription_tests`, `agc_gs_prim_payload_tests`, `agc_dma_data_tests`, `agc_write_data_patch_tests`, `agc_prime_utcl2_tests`, `agc_cond_exec_patch_tests`, `agc_shader_helpers`, `agc_driver_pm4`, `agc_driver_pm4_failure` and `guest_agc_driver_resources`. - `tools/check_conventions.py` from `main` eea428ca8, with `--title` and `--body`: passes. Not tested: Linux, macOS, titles, Vulkan rendering. No test here does GPU work; the driver check is PM4 validation and execution on the CPU. ### 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 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] Unblocks: none - [x] GPUs tested: n/a (no AGC driver change; the test runs `Pm4::Validate`/`Execute` on the CPU, no GPU work) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-14 22:53:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T22:53:26Z.


Progress report (6239cef → b09bf23)

📈 System libraries: 88.8% (+0.11%, +4 implemented functions)

✅ 4 implemented
Library Name
libSceAgc sceAgcAcbSetWorkloadComplete
libSceAgc sceAgcAcbSetWorkloadStreamInactive
libSceAgc sceAgcAcbSetWorkloadsActive
libSceAgc sceAgcDcbSetWorkloadStreamInactive
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180279442 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6128#issuecomment-6180279442). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T22:53:26Z. --- <!-- progress-report --> ### Progress report (6239cef → b09bf23) 📈 **System libraries**: 88.8% (+0.11%, +4 implemented functions) <details> <summary>✅ 4 implemented</summary> | Library | Name | | - | - | | libSceAgc | `sceAgcAcbSetWorkloadComplete` | | libSceAgc | `sceAgcAcbSetWorkloadStreamInactive` | | libSceAgc | `sceAgcAcbSetWorkloadsActive` | | libSceAgc | `sceAgcDcbSetWorkloadStreamInactive` | </details>
fdfawef324 commented 2026-10-14 23:15:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T23:15:42Z.


Closing this myself to respect the queue policy in #4826: no title has been shown to stop here on main yet. The branch stays on my fork; I'll reopen it with the title ID and the log line if one of the titles I run (Demon's Souls, GTA V, Black Myth: Wukong, Resident Evil 4, Astro Bot) stops on it.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6180588142 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6128#issuecomment-6180588142). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-14T23:15:42Z. --- Closing this myself to respect the queue policy in #4826: no title has been shown to stop here on `main` yet. The branch stays on my fork; I'll reopen it with the title ID and the log line if one of the titles I run (Demon's Souls, GTA V, Black Myth: Wukong, Resident Evil 4, Astro Bot) stops on it. AI-assisted: yes

Pull request closed

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!6128
No description provided.