fix(agc): copy a shader, context or user config register to memory with COPY_DATA #5477

Merged
LeandroLP23 merged 2 commits from upstream-pr/5477 into main 2026-10-14 20:50:24 +00:00
LeandroLP23 commented 2026-10-13 20:48:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-13T20:48:14Z.


What

PS5 FSR4 Showcase (PPSA99011) stops with AGC driver: COPY_DATA at DWORD 69: COPY_DATA register, GDS or reference-clock source is not implemented once #5163 gets it past sceAgcInit. Right after a DISPATCH_DIRECT it copies three SH registers to memory with COPY_DATA (control 0x00100200: SRC_SEL 0, register; DST_SEL 2, memory):

  • 0x2e0c: COMPUTE_PGM_LO
  • 0x2e07: COMPUTE_NUM_THREAD_X
  • 0x2e00: COMPUTE_DISPATCH_INITIATOR

Changes:

  • Register source. COPY_DATA with a register source and a memory destination reads the value the queue holds. Shader registers are at 0x2c00, context registers at 0xa000 and user config registers at 0xc000. COUNT_SEL copies two consecutive registers.
    • A register outside those three banks is rejected at validation.
    • A register the queue has no value for throws at execution, so the copy never stores a guessed value.
    • ResolveStore leaves such a copy to Execute: the value depends on the registers at the packet's place in the stream.
  • Dispatch registers. The CP writes the dispatch initiator into COMPUTE_DISPATCH_INITIATOR, and the group counts of a DISPATCH_DIRECT into COMPUTE_DIM_X/Y/Z. After each dispatch, Pm4::NoteDispatchRegisters does the same in the queue's shader registers. It runs in both the worker and the dispatch-ahead pass.
    • A DISPATCH_INDIRECT clears the three counts, because they come from memory, so a later copy of them throws.
    • Dispatch keys read only 0x207-0x213 from the shader registers, so they are unchanged.

Copies to a register, and GDS and reference-clock sources, are rejected as before.

Tested

Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, on main a0f5916a2.

  • agc_driver_pm4 (extended) passes. It covers:
    • one and two shader registers, and a context register;
    • the initiator and group counts after a direct dispatch, and the initiator after an indirect one;
    • the throws for an unset register, and for the counts after an indirect dispatch;
    • the rejections outside the banks, including a two-register copy that leaves the shader bank;
    • that ResolveStore does not resolve a register copy.
  • tools/check_conventions.py passes.
  • PPSA99011 01.000.010 (catalog build, relinked with --windows --trap-sdk-syscall-stubs), with this branch and #5163 merged locally, 3 runs of 60 s:
    • without this change, every run stops at the COPY_DATA throw above, 7-10 s in;
    • with it, no run stops there. The title logs FSR4_SHOWCASE_SUBMIT probe_ms=0.61 and reaches FSR4_SHOWCASE_CHAPTER index=0 title=FSR 4 on PlayStation 5.
    • It then stops at later, separate limits: 2 of 3 runs at MUBUF resource descriptor register range overflow, and 1 of 3 runs with its own vkQueueSubmit(...) = -4.
  • ctest -R '^agc_' -j 1 on this machine, test shader cache emptied: 480 passed, 2 skipped, and 1 failed, agc_driver_layered_volume_vertex_no_gpl. That test fails on main on this driver too: GPL-off pipelines on it, #4768.
  • Fork CI (lavapipe), run 38465741353: Linux 1078 of 1079 and Windows 1096 of 1097 pass, and the relinker jobs pass on all three hosts. The one failure in each job is conventions_ci_gate, which fails on any fork.

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 (the title reaches this stop only with #5163)
  • Unblocks: PPSA99011 #4808, after #5163
  • GPUs tested: AMD Radeon 860M (RDNA 3.5), driver 32.0.13058.8001, Windows 11
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4849282112 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5477). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-13T20:48:14Z. --- ### What PS5 FSR4 Showcase (PPSA99011) stops with `AGC driver: COPY_DATA at DWORD 69: COPY_DATA register, GDS or reference-clock source is not implemented` once #5163 gets it past `sceAgcInit`. Right after a `DISPATCH_DIRECT` it copies three SH registers to memory with COPY_DATA (control `0x00100200`: `SRC_SEL` 0, register; `DST_SEL` 2, memory): - `0x2e0c`: `COMPUTE_PGM_LO` - `0x2e07`: `COMPUTE_NUM_THREAD_X` - `0x2e00`: `COMPUTE_DISPATCH_INITIATOR` Changes: - **Register source.** COPY_DATA with a register source and a memory destination reads the value the queue holds. Shader registers are at `0x2c00`, context registers at `0xa000` and user config registers at `0xc000`. `COUNT_SEL` copies two consecutive registers. - A register outside those three banks is rejected at validation. - A register the queue has no value for throws at execution, so the copy never stores a guessed value. - `ResolveStore` leaves such a copy to `Execute`: the value depends on the registers at the packet's place in the stream. - **Dispatch registers.** The CP writes the dispatch initiator into `COMPUTE_DISPATCH_INITIATOR`, and the group counts of a `DISPATCH_DIRECT` into `COMPUTE_DIM_X/Y/Z`. After each dispatch, `Pm4::NoteDispatchRegisters` does the same in the queue's shader registers. It runs in both the worker and the dispatch-ahead pass. - A `DISPATCH_INDIRECT` clears the three counts, because they come from memory, so a later copy of them throws. - Dispatch keys read only `0x207`-`0x213` from the shader registers, so they are unchanged. Copies to a register, and GDS and reference-clock sources, are rejected as before. ### Tested Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, on `main` `a0f5916a2`. - `agc_driver_pm4` (extended) passes. It covers: - one and two shader registers, and a context register; - the initiator and group counts after a direct dispatch, and the initiator after an indirect one; - the throws for an unset register, and for the counts after an indirect dispatch; - the rejections outside the banks, including a two-register copy that leaves the shader bank; - that `ResolveStore` does not resolve a register copy. - `tools/check_conventions.py` passes. - PPSA99011 01.000.010 (catalog build, relinked with `--windows --trap-sdk-syscall-stubs`), with this branch and #5163 merged locally, 3 runs of 60 s: - without this change, every run stops at the COPY_DATA throw above, 7-10 s in; - with it, no run stops there. The title logs `FSR4_SHOWCASE_SUBMIT probe_ms=0.61` and reaches `FSR4_SHOWCASE_CHAPTER index=0 title=FSR 4 on PlayStation 5`. - It then stops at later, separate limits: 2 of 3 runs at `MUBUF resource descriptor register range overflow`, and 1 of 3 runs with its own `vkQueueSubmit(...) = -4`. - `ctest -R '^agc_' -j 1` on this machine, test shader cache emptied: 480 passed, 2 skipped, and 1 failed, `agc_driver_layered_volume_vertex_no_gpl`. That test fails on `main` on this driver too: GPL-off pipelines on it, #4768. - Fork CI (lavapipe), run 38465741353: Linux 1078 of 1079 and Windows 1096 of 1097 pass, and the relinker jobs pass on all three hosts. The one failure in each job is `conventions_ci_gate`, which fails on any fork. ### 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 (the title reaches this stop only with #5163) - [x] Unblocks: PPSA99011 #4808, after #5163 - [x] GPUs tested: AMD Radeon 860M (RDNA 3.5), driver 32.0.13058.8001, Windows 11 - [x] AI-assisted: yes (Claude Code)
xXPBSXx commented 2026-10-13 23:47:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T23:47:41Z.


Windows test of #5477: Windows 10 (19045), MinGW-w64 GCC 15.2, Release, ninja -j 4, ctest called directly. Tree: main 7a0c838ca + merge of 5e36c08748c6cf464521faac41b24caddb4f6c32 (local merge 9fa5d9168), target agc_driver_pm4_tests.

  • agc_driver_pm4: exit code 0, 3 of 3 runs.
  • agc_driver_pm4_failure: exit code 0, 3 of 3 runs.
    Not tested: that the new Pm4 test cases fail without the change (no baseline run), Linux, a title run (PPSA99011 not available here), AMD, other ctest targets. These tests select no GPU.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157610072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5477#issuecomment-6157610072). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T23:47:41Z. --- Windows test of #5477: Windows 10 (19045), MinGW-w64 GCC 15.2, Release, `ninja -j 4`, ctest called directly. Tree: `main` `7a0c838ca` + merge of `5e36c08748c6cf464521faac41b24caddb4f6c32` (local merge `9fa5d9168`), target `agc_driver_pm4_tests`. - `agc_driver_pm4`: exit code 0, 3 of 3 runs. - `agc_driver_pm4_failure`: exit code 0, 3 of 3 runs. Not tested: that the new Pm4 test cases fail without the change (no baseline run), Linux, a title run (PPSA99011 not available here), AMD, other ctest targets. These tests select no GPU. AI-assisted (Claude Code).
adriadam10 commented 2026-10-14 20:13:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T20:13:07Z.


Rebased onto current main (conflict in Pm4.cpp with the CopyDataSource/CopyDataBytes refactor; the register source now goes through those helpers) and added the missing technical-debt line in docs/dev/debt/libSceAgcDriver.md for COPY_DATA from a register and the dispatch registers it reads.

Checked: agc_driver_pm4 and the libSceAgcDriver scope pass on the rebase (only agc_driver_tessellation segfaults, as on main); the new test no longer builds without the change; COMPUTE_DISPATCH_INITIATOR/COMPUTE_DIM_* (0x2e00-0x2e03) are outside DrawKeyRegisters, so draw keys are unchanged. Merging once the full build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6177411403 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5477#issuecomment-6177411403). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T20:13:07Z. --- Rebased onto current `main` (conflict in `Pm4.cpp` with the `CopyDataSource`/`CopyDataBytes` refactor; the register source now goes through those helpers) and added the missing technical-debt line in `docs/dev/debt/libSceAgcDriver.md` for COPY_DATA from a register and the dispatch registers it reads. Checked: `agc_driver_pm4` and the libSceAgcDriver scope pass on the rebase (only `agc_driver_tessellation` segfaults, as on `main`); the new test no longer builds without the change; `COMPUTE_DISPATCH_INITIATOR`/`COMPUTE_DIM_*` (0x2e00-0x2e03) are outside `DrawKeyRegisters`, so draw keys are unchanged. Merging once the full build is green.
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!5477
No description provided.