feat(agc): return null from the workload builders for unregistered streams #4709

Merged
fdfawef324 merged 1 commit from upstream-pr/4709 into main 2026-10-12 20:41:40 +00:00
fdfawef324 commented 2026-10-12 19:37:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-12T19:37:00Z.


What

sceAgcDcbSetWorkloadStreamInactive, sceAgcAcbSetWorkloadsActive, sceAgcAcbSetWorkloadComplete and sceAgcAcbSetWorkloadStreamInactive threw for every call. sceAgcDcbSetWorkloadsActive read the workload ids before checking the stream.

The prosper console oracle measured all six workload builders on a PS5 (ACB at lines 48-56, DCB at lines 196-204). Each was called with three argument patterns and no workload stream registered. Every call returned null and wrote nothing. Pattern b passes stream 1 with the workload ids at address 2 and still returns null without faulting, so the console checks the stream before it reads the ids. Here that call read address 2 and crashed.

Changes:

  • The four builders now return null, without writing, for a null command buffer or a stream that is not registered (out-of-range ids included). They still throw NotImplemented for a registered stream. That packet is not measured, KytyPS5 has no body for these four, and the two references disagree on the DCB layout: KytyPS5 writes an IT_NOP, while OpenAGC derives a SET_UCONFIG_REG, WRITE_DATA and SET_WORKLOAD sequence from the driver. No layout is guessed.
  • The signatures are OpenAGC's DCB ones (game_compat.c). OpenAGC says the ACB calls use the same driver builders; no ACB declaration was found.
  • sceAgcDcbSetWorkloadsActive now checks the stream before it reads the ids, in OpenAGC's order. Its packet for a registered stream is unchanged.
  • The four builders were removed from Unimplemented.cpp. The ACB ones live in Acb/src/Control.cpp so no CMake change is needed.
  • docs/dev/debt/libSceAgc.md records what is measured and what is not.

Other functions in the same import list were left alone:

  • The marker spans and sceAgcCbMemsetExclusive faulted on the oracle (agcbuild.unmeasured.tsv, fault:11), so they have no measurement. The shader instrumentation calls are not in the oracle at all. Markers are in #2847, instrumentation in #2850 and sceAgcAcquireMemSetEngine in #1060.
  • The occlusion query sizes are measured (16 and 16), but #2848 already implements them.

Tested

Windows Server 2025, RTX 3060, GCC 15.2 (winlibs), Release.

  • New testWorkloadStreams in agc_commands, against the three measured patterns for all six calls. It checks that each returns null and leaves the buffer and cursor untouched. It also covers an exhausted and a null buffer, and a registered stream that throws without touching the buffer.
  • On upstream/main 1acfa7f78 the test fails with sceAgcDcbSetWorkloadStreamInactive not implemented. Run alone, the sceAgcDcbSetWorkloadsActive pattern b segfaults (read of 0x0000000000000002 in libSceAgc.prx). With the change it passes (0.13 s after the rebase).
  • All 20 libSceAgc tests pass (agc_initialization, agc_commands, agc_platform_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_dma_data_tests, agc_write_data_patch_tests, agc_prime_utcl2_tests, agc_cond_exec_patch_tests, agc_shader_helpers).
  • tools/check_conventions.py passes.
  • The branch is rebased onto upstream/main 682ef0c17. The commits between 1acfa7f78 and 682ef0c17 only change docs and CI files. The 20 tests above were run again after the rebase and pass.
  • Linux was not built or tested; only the Windows build above was run.
  • Not tested with a title.

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
  • Unblocks: none
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4834144697 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4709). Originally posted by [fdfawef324](https://github.com/fdfawef324) on 2026-10-12T19:37:00Z. --- ### What `sceAgcDcbSetWorkloadStreamInactive`, `sceAgcAcbSetWorkloadsActive`, `sceAgcAcbSetWorkloadComplete` and `sceAgcAcbSetWorkloadStreamInactive` threw for every call. `sceAgcDcbSetWorkloadsActive` read the workload ids before checking the stream. The [prosper console oracle](https://github.com/mattias800/prosper/blob/df074498e56c0df22d74f9c6622e4709bc1c9a19/prosper/tests/data/console_oracle/agcbuild.golden.tsv) measured all six workload builders on a PS5 (ACB at lines 48-56, DCB at lines 196-204). Each was called with three argument patterns and no workload stream registered. Every call returned null and wrote nothing. Pattern b passes stream 1 with the workload ids at address 2 and still returns null without faulting, so the console checks the stream before it reads the ids. Here that call read address 2 and crashed. Changes: - The four builders now return null, without writing, for a null command buffer or a stream that is not registered (out-of-range ids included). They still throw `NotImplemented` for a registered stream. That packet is not measured, KytyPS5 has no body for these four, and the two references disagree on the DCB layout: KytyPS5 writes an `IT_NOP`, while [OpenAGC](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/agc_workload_packet.c) derives a SET_UCONFIG_REG, WRITE_DATA and SET_WORKLOAD sequence from the driver. No layout is guessed. - The signatures are OpenAGC's DCB ones ([game_compat.c](https://github.com/OpenAGC/OpenAGC/blob/3c7e8072f0d7684e930454794fd5c02056946d73/src/game_compat.c#L2317-L2384)). OpenAGC says the ACB calls use the same driver builders; no ACB declaration was found. - `sceAgcDcbSetWorkloadsActive` now checks the stream before it reads the ids, in OpenAGC's order. Its packet for a registered stream is unchanged. - The four builders were removed from `Unimplemented.cpp`. The ACB ones live in `Acb/src/Control.cpp` so no CMake change is needed. - `docs/dev/debt/libSceAgc.md` records what is measured and what is not. Other functions in the same import list were left alone: - The marker spans and `sceAgcCbMemsetExclusive` faulted on the oracle (`agcbuild.unmeasured.tsv`, `fault:11`), so they have no measurement. The shader instrumentation calls are not in the oracle at all. Markers are in #2847, instrumentation in #2850 and `sceAgcAcquireMemSetEngine` in #1060. - The occlusion query sizes are measured (16 and 16), but #2848 already implements them. ### Tested Windows Server 2025, RTX 3060, GCC 15.2 (winlibs), Release. - New `testWorkloadStreams` in `agc_commands`, against the three measured patterns for all six calls. It checks that each returns null and leaves the buffer and cursor untouched. It also covers an exhausted and a null buffer, and a registered stream that throws without touching the buffer. - On upstream/main 1acfa7f78 the test fails with `sceAgcDcbSetWorkloadStreamInactive not implemented`. Run alone, the `sceAgcDcbSetWorkloadsActive` pattern b segfaults (`read of 0x0000000000000002` in `libSceAgc.prx`). With the change it passes (0.13 s after the rebase). - All 20 libSceAgc tests pass (`agc_initialization`, `agc_commands`, `agc_platform_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_dma_data_tests`, `agc_write_data_patch_tests`, `agc_prime_utcl2_tests`, `agc_cond_exec_patch_tests`, `agc_shader_helpers`). - `tools/check_conventions.py` passes. - The branch is rebased onto upstream/main 682ef0c17. The commits between 1acfa7f78 and 682ef0c17 only change docs and CI files. The 20 tests above were run again after the rebase and pass. - Linux was not built or tested; only the Windows build above was run. - Not tested with a title. ### 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] Unblocks: none - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-12 19:38:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T19:38:43Z.


Progress report (2f4cc89 → f8257a1)

📈 System libraries: 86.45% (+0.09%, +3 implemented functions)

✅ 3 implemented
Library Name
libSceAgc sceAgcAcbSetWorkloadComplete
libSceAgc sceAgcAcbSetWorkloadStreamInactive
libSceAgc sceAgcAcbSetWorkloadsActive
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131318248 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4709#issuecomment-6131318248). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T19:38:43Z. --- <!-- progress-report --> ### Progress report (2f4cc89 → f8257a1) 📈 **System libraries**: 86.45% (+0.09%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | libSceAgc | `sceAgcAcbSetWorkloadComplete` | | libSceAgc | `sceAgcAcbSetWorkloadStreamInactive` | | libSceAgc | `sceAgcAcbSetWorkloadsActive` | </details>
github-actions[bot] commented 2026-10-12 19:45:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T19:45:03Z.


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
#1060 core/libs/prx/libSceAgc/Unimplemented.cpp L18-37
#4377 docs/dev/debt/libSceAgc.md L35
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131417591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4709#issuecomment-6131417591). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T19:45:03Z. --- <!-- 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 | |---|---|---|---| | #1060 | `core/libs/prx/libSceAgc/Unimplemented.cpp` [L18-37](https://github.com/boykopovar/AnyPS5/blob/fa0cc752a674e157745021394fcc6ff2efe0037d/core/libs/prx/libSceAgc/Unimplemented.cpp#L18-L37) | | | | #4377 | `docs/dev/debt/libSceAgc.md` [L35](https://github.com/boykopovar/AnyPS5/blob/fa0cc752a674e157745021394fcc6ff2efe0037d/docs/dev/debt/libSceAgc.md#L35) | | |
adriadam10 commented 2026-10-12 20:41:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T20:41:36Z.


Checked the six workload builders against the prosper console oracle rows you cite (ACB lines 48-56, DCB 196-204): null in all three patterns matches. Built on Linux merged onto main: all 20 libSceAgc tests pass, and the new testWorkloadStreams fails without the change. The registered-stream throw keeps the unmeasured packet out. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132255047 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4709#issuecomment-6132255047). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T20:41:36Z. --- Checked the six workload builders against the prosper console oracle rows you cite (ACB lines 48-56, DCB 196-204): null in all three patterns matches. Built on Linux merged onto main: all 20 libSceAgc tests pass, and the new `testWorkloadStreams` fails without the change. The registered-stream throw keeps the unmeasured packet out. 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!4709
No description provided.