Skip to content

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

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
LeandroLP23:fix/agc-copy-data-register-source
Oct 14, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
LeandroLP23:fix/agc-copy-data-register-source

Conversation

@LeandroLP23

@LeandroLP23 LeandroLP23 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(agc): return 0 for out-of-range sceAgcInit without table lookup #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, AMD Windows: identical AGC executables invert GPL pass/fail results after relocation #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

@LeandroLP23
LeandroLP23 marked this pull request as ready for review October 13, 2026 21:15
@github-actions github-actions Bot added the agc libSceAgc* label Oct 13, 2026
RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 13, 2026
- skip pure PM4 NOP packets in the Metal packet loop (upstream PR boykopovar#5481)
- note the dispatch registers after direct and indirect Metal dispatch so
  COPY_DATA from a shader register works there (upstream PR boykopovar#5477)
- NullImageDescriptor delegates to IsNullTextureResource (upstream PR boykopovar#4779)
- tests: pm4 compute replay reads the dispatch initiator and group counts
  back through COPY_DATA; metal utility tests cover a type-0 image descriptor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj
RINNECODER added a commit to RINNECODER/AnyPS5 that referenced this pull request Oct 13, 2026
* perf(agc): fast-skip pure PM4 NOP packets during queue execution

(cherry picked from commit 139bf04)

Ported from upstream PR boykopovar#5481

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

A dispatch now leaves its initiator and, for DISPATCH_DIRECT, its group
counts in the shader registers, where the CP puts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5e36c08)

Ported from upstream PR boykopovar#5477

* fix(agc): accept reported vertex stage state

(cherry picked from commit 632331d)

Ported from upstream PR boykopovar#4341

* fix(agc): initialize stencil control and reference masks

(cherry picked from commit 85e0d98bba896002539365bb29a7a39a8e43f501)
(cherry picked from commit 13dca48)

Ported from upstream PR boykopovar#5347

* fix(agc): accept inactive vertex point size on non-point draws

(cherry picked from commit d4b59ce)

Ported from upstream PR boykopovar#4715

* fix(agc): treat type-0 texture descriptors as null

(cherry picked from commit 7e1e1ce)

Ported from upstream PR boykopovar#4779

* fix(agc): fall back out-of-range sceAgcInit versions to table 13

Pointer-shaped NID kW3GLb7QfPg calls from public homebrew succeed on console; returning an error left those titles failing init after boykopovar#4835.

(cherry picked from commit 939f784)

Ported from upstream PR boykopovar#5163 (debt-doc hunk dropped: file absent on main)

* fix(agc): clamp sceAgcInit versions above 13 inline

(cherry picked from commit 0cc5102)

Ported from upstream PR boykopovar#5163 (second commit)

* metal: adapt the shared AGC driver slice to the Metal execution loop

- skip pure PM4 NOP packets in the Metal packet loop (upstream PR boykopovar#5481)
- note the dispatch registers after direct and indirect Metal dispatch so
  COPY_DATA from a shader register works there (upstream PR boykopovar#5477)
- NullImageDescriptor delegates to IsNullTextureResource (upstream PR boykopovar#4779)
- tests: pm4 compute replay reads the dispatch initiator and group counts
  back through COPY_DATA; metal utility tests cover a type-0 image descriptor

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DgW4n3qYgi5jAAohEmXRQj

---------

Co-authored-by: Kikoarl <7354010+Kikoarl@users.noreply.github.com>
Co-authored-by: LeandroLP23 <leandroplacidi@gmail.com>
Co-authored-by: MarcZX100 <marczxrr@gmail.com>
Co-authored-by: MathiasDevelopes <25400788+MathiasDevelopes@users.noreply.github.com>
Co-authored-by: lorkydey <57268822+Lorkydey@users.noreply.github.com>
Co-authored-by: mazen <mazenshaar@hotmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

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).

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@adriadam10 adriadam10 self-assigned this Oct 14, 2026
LeandroLP23 and others added 2 commits October 14, 2026 22:03
…th COPY_DATA

A dispatch now leaves its initiator and, for DISPATCH_DIRECT, its group
counts in the shader registers, where the CP puts them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rs it reads

Co-Authored-By: Claude <noreply@anthropic.com>
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 force-pushed the fix/agc-copy-data-register-source branch from 5e36c08 to 5d9def6 Compare October 14, 2026 20:13
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@adriadam10
adriadam10 merged commit 6ff02d2 into boykopovar:main Oct 14, 2026
8 checks passed
@LeandroLP23
LeandroLP23 deleted the fix/agc-copy-data-register-source branch October 14, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants