fix(agc): preserve hand-built user VGPR offsets #3496

Merged
MarcZX10 merged 4 commits from upstream-pr/3496 into main 2026-10-11 21:29:06 +00:00
MarcZX10 commented 2026-10-11 11:44:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T11:44:22Z.


What

Issue #3457 reports four titles with hand-built shader headers (PPSA99039, PPSA99505, PPSA99515 and PPSA99997) stopping in sceAgcCreatePrimState: their ge_user_vgpr_en special is stored at GE_USER_VGPR1 (0x25c) with value 0. This change passes that special through at the offset recorded by the shader header instead of rejecting or relocating it.

This follows OpenAGC's clean-room reconstruction of the FW 5.50 SPRX, which copies the special register pairs verbatim. GE_CNTL, VGT_SHADER_STAGES_EN and a used VGT_GS_OUT_PRIM_TYPE remain checked at the offsets the driver reads. Offset errors now identify the special and the offset found.

The implementation adopts screamm's commit aeaa5080, shared on #3457 after the intake check prevented them from opening a PR. The regression test covers the 0x25c pass-through and the GE_CNTL diagnostic.

Tested

Linux, GCC 12.2, Release: built agc_shader_helpers_tests; agc_shader_helpers passed three consecutive runs. python3 tools/check_conventions.py --base upstream/main and git diff --check passed. The issue contributor reports all four titles get past sceAgcCreatePrimState with this pass-through change; the title then encounters the separately reported GetImageResource shader-recompiler error. Windows and console behavior have not been independently retested on this PR head.

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
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818803288 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T11:44:22Z. --- ### What Issue #3457 reports four titles with hand-built shader headers (`PPSA99039`, `PPSA99505`, `PPSA99515` and `PPSA99997`) stopping in `sceAgcCreatePrimState`: their `ge_user_vgpr_en` special is stored at `GE_USER_VGPR1` (`0x25c`) with value 0. This change passes that special through at the offset recorded by the shader header instead of rejecting or relocating it. This follows OpenAGC's clean-room reconstruction of the FW 5.50 SPRX, which copies the special register pairs verbatim. `GE_CNTL`, `VGT_SHADER_STAGES_EN` and a used `VGT_GS_OUT_PRIM_TYPE` remain checked at the offsets the driver reads. Offset errors now identify the special and the offset found. The implementation adopts screamm's commit [`aeaa5080`](https://github.com/screamm/AnyPS5/commit/aeaa5080d9595305aa73e74d966f989c88b79839), shared on #3457 after the intake check prevented them from opening a PR. The regression test covers the `0x25c` pass-through and the `GE_CNTL` diagnostic. ### Tested Linux, GCC 12.2, Release: built `agc_shader_helpers_tests`; `agc_shader_helpers` passed three consecutive runs. `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. The issue contributor reports all four titles get past `sceAgcCreatePrimState` with this pass-through change; the title then encounters the separately reported `GetImageResource` shader-recompiler error. Windows and console behavior have not been independently retested on this PR head. ### 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 - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
adriadam10 commented 2026-10-11 12:00:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T12:00:50Z.


Checked the change against main merged: agc_shader_helpers passes, and without the change the new test case doesn't build/fail. Only {0x25c, 0} is normalized to GE_USER_VGPR_EN; a non-zero value still throws, which is covered by the test.

Added by us (pushed to your branch):

  • TechnicalDebt line under "Unknown function info" for sceAgcCreatePrimState: the normalization is inferred from the title's headers and the console's behaviour is unknown.

Rebased on current main, scoped build and ctest green; merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108797592 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6108797592). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T12:00:50Z. --- Checked the change against `main` merged: `agc_shader_helpers` passes, and without the change the new test case doesn't build/fail. Only `{0x25c, 0}` is normalized to `GE_USER_VGPR_EN`; a non-zero value still throws, which is covered by the test. Added by us (pushed to your branch): - TechnicalDebt line under "Unknown function info" for `sceAgcCreatePrimState`: the normalization is inferred from the title's headers and the console's behaviour is unknown. Rebased on current `main`, scoped build and ctest green; merging once CI is green.
adriadam10 commented 2026-10-11 12:09:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T12:09:40Z.


CI on this head failed in actions/checkout on all jobs (No url found for submodule path '3rdparty/imgui' in .gitmodules), which comes from main (gitlink without a .gitmodules entry), not from this diff. Verdict unchanged; merging once main is fixed and CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108869209 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6108869209). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T12:09:40Z. --- CI on this head failed in `actions/checkout` on all jobs (`No url found for submodule path '3rdparty/imgui' in .gitmodules`), which comes from `main` (gitlink without a `.gitmodules` entry), not from this diff. Verdict unchanged; merging once `main` is fixed and CI is green.
LeandroLP23 commented 2026-10-11 12:31:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-11T12:31:34Z.


Ran it on Windows: Radeon 860M (RDNA 3.5), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, driver and shader caches emptied. agc_shader_helpers passes 3/3. EVO Player (PPSA99039), freshly relinked with this branch's .prx files, gets past sceAgcCreatePrimState and stops at the next blocker reported in #3457: ShaderRecompiler::Recompile: GetImageResource dword 3 is not a valid runtime value.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109047283 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6109047283). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-11T12:31:34Z. --- Ran it on Windows: Radeon 860M (RDNA 3.5), Windows 11 (26300), WinLibs GCC 15.2.0 r7, Release, driver and shader caches emptied. `agc_shader_helpers` passes 3/3. EVO Player (PPSA99039), freshly relinked with this branch's `.prx` files, gets past `sceAgcCreatePrimState` and stops at the next blocker reported in #3457: `ShaderRecompiler::Recompile: GetImageResource dword 3 is not a valid runtime value`.
MarcZX10 commented 2026-10-11 12:36:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:36:18Z.


Thanks for the native Windows run and trace. Getting past sceAgcCreatePrimState confirms the normalization on the reported title; the later GetImageResource failure is the separate next blocker already tracked in #3457. The PR checks remain blocked at checkout by the main imgui mapping issue in #3511.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109086242 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6109086242). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T12:36:18Z. --- Thanks for the native Windows run and trace. Getting past `sceAgcCreatePrimState` confirms the normalization on the reported title; the later `GetImageResource` failure is the separate next blocker already tracked in #3457. The PR checks remain blocked at checkout by the `main` imgui mapping issue in #3511.
MarcZX10 commented 2026-10-11 12:50:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T12:50:29Z.


Update after #3511 merged: I rebased this PR onto current main (a11c8f7f). The patch still only normalizes {GE_USER_VGPR1, 0} to GE_USER_VGPR_EN; the existing helper test and Windows title validation remain the relevant behavior checks. git diff --check and the conventions check pass on the rebased diff, and CI has restarted. The prior checkout failure from the orphan 3rdparty/imgui gitlink should no longer apply.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109202526 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6109202526). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T12:50:29Z. --- Update after #3511 merged: I rebased this PR onto current `main` (`a11c8f7f`). The patch still only normalizes `{GE_USER_VGPR1, 0}` to `GE_USER_VGPR_EN`; the existing helper test and Windows title validation remain the relevant behavior checks. `git diff --check` and the conventions check pass on the rebased diff, and CI has restarted. The prior checkout failure from the orphan `3rdparty/imgui` gitlink should no longer apply.
MarcZX10 commented 2026-10-11 13:12:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:12:43Z.


Update: the rerun on rebased head b33d2e37 is fully green, including conventions and all three relinker jobs. The full Linux/Windows jobs are skipped by the contributor workflow. The previously reported Windows Radeon 860M validation remains the available native title evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109388950 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6109388950). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T13:12:43Z. --- Update: the rerun on rebased head `b33d2e37` is fully green, including conventions and all three relinker jobs. The full Linux/Windows jobs are skipped by the contributor workflow. The previously reported Windows Radeon 860M validation remains the available native title evidence.
MarcZX10 commented 2026-10-11 13:43:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T13:43:41Z.


Update on the revised implementation:

  • The code now passes ge_user_vgpr_en through at the offset recorded by hand-built shader headers, following the SPRX behavior documented by screamm. The earlier zero-value normalization has been removed.
  • The new agc_shader_helpers regression checks the GE_USER_VGPR1 pass-through and the register-specific GE_CNTL diagnostic. Linux/GCC 12.2 Release build succeeded; the focused CTest passed three consecutive runs. Conventions and git diff --check pass.
  • All applicable hosted checks on head afcaf910 are green. Full Linux and Windows jobs are skipped by the contributor workflow.
  • screamm's issue report reports the four affected titles get past this call with the pass-through change. Windows and console behavior have not been independently retested on this PR head.

The PR description now reflects the pass-through behavior and credits the implementation. Please review the revised diff when convenient.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109658589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6109658589). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T13:43:41Z. --- Update on the revised implementation: - The code now passes `ge_user_vgpr_en` through at the offset recorded by hand-built shader headers, following the SPRX behavior documented by screamm. The earlier zero-value normalization has been removed. - The new `agc_shader_helpers` regression checks the `GE_USER_VGPR1` pass-through and the register-specific `GE_CNTL` diagnostic. Linux/GCC 12.2 Release build succeeded; the focused CTest passed three consecutive runs. Conventions and `git diff --check` pass. - All applicable hosted checks on head `afcaf910` are green. Full Linux and Windows jobs are skipped by the contributor workflow. - [screamm's issue report](https://github.com/boykopovar/AnyPS5/issues/3457#issuecomment-6108844830) reports the four affected titles get past this call with the pass-through change. Windows and console behavior have not been independently retested on this PR head. The PR description now reflects the pass-through behavior and credits the implementation. Please review the revised diff when convenient.
github-actions[bot] commented 2026-10-11 14:28:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:28:41Z.


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
#3670 docs/dev/TechnicalDebt.md L603
#3700 docs/dev/TechnicalDebt.md L603
#3781 docs/dev/TechnicalDebt.md L603
#3789 docs/dev/TechnicalDebt.md L603
#3791 docs/dev/TechnicalDebt.md L603
#3800 docs/dev/TechnicalDebt.md L603
#3829 docs/dev/TechnicalDebt.md L603
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110056091 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6110056091). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:28:41Z. --- <!-- 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 | |---|---|---|---| | #3670 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3700 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3781 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3789 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3791 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3800 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | | | #3829 | `docs/dev/TechnicalDebt.md` [L603](https://github.com/boykopovar/AnyPS5/blob/1770f352d7546c1eae9cf1e1441e1ae2428dc3a0/docs/dev/TechnicalDebt.md#L603) | | |
reyani-dev commented 2026-10-11 16:38:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T16:38:42Z.


Windows check of head afcaf9101 with the five catalog titles that stop on this throw on main a11c8f7f (Windows 11, RTX 4070, WinLibs GCC 15.2.0 r7, catalog builds with eboot.bin and sce_module/libc.prx unwrapped, 60 s each).

All five get past sceAgcCreatePrimState: EVO Player (PPSA99039), PS5VR (PPSA99177), Jelly5 (PPSA99505), Emby5 (PPSA99515) and Nuvio PS5 (PPSA99997). All five then stop on the same shader at their first draw:

  what():  ShaderRecompiler::Recompile: GetImageResource dword 3 is not a valid runtime value; chain: SelectU32(SLessThan32(ReadConst(GetSrtResource, Immediate), Immediate), ReadConst(GetSrtResource, Immediate), BitwiseAnd32(ReadConst(GetSrtResource, Immediate), Immediate))

That one is separate from this PR. The SRT evaluator handles SLessThan32 since #2072, but IsRuntimeUniformOp leaves it out, so the runtime validator rejects the chain first. I have a one-line fix with a test ready (AchrafReyani:fix/shader-srt-signed-less-than-uniform) and will open it once this PR is in, since that's when it becomes the titles' stop on main. With both changes:

  • PS5VR runs the full 60 s without an error and compiles 150 shaders.
  • The other four stop at AGC graphics: guest 2D texture descriptor has a nonzero depth or base array.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111250460 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6111250460). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T16:38:42Z. --- Windows check of head `afcaf9101` with the five catalog titles that stop on this throw on `main` a11c8f7f (Windows 11, RTX 4070, WinLibs GCC 15.2.0 r7, catalog builds with `eboot.bin` and `sce_module/libc.prx` unwrapped, 60 s each). All five get past `sceAgcCreatePrimState`: EVO Player (PPSA99039), PS5VR (PPSA99177), Jelly5 (PPSA99505), Emby5 (PPSA99515) and Nuvio PS5 (PPSA99997). All five then stop on the same shader at their first draw: ``` what(): ShaderRecompiler::Recompile: GetImageResource dword 3 is not a valid runtime value; chain: SelectU32(SLessThan32(ReadConst(GetSrtResource, Immediate), Immediate), ReadConst(GetSrtResource, Immediate), BitwiseAnd32(ReadConst(GetSrtResource, Immediate), Immediate)) ``` That one is separate from this PR. The SRT evaluator handles `SLessThan32` since #2072, but `IsRuntimeUniformOp` leaves it out, so the runtime validator rejects the chain first. I have a one-line fix with a test ready (`AchrafReyani:fix/shader-srt-signed-less-than-uniform`) and will open it once this PR is in, since that's when it becomes the titles' stop on `main`. With both changes: - PS5VR runs the full 60 s without an error and compiles 150 shaders. - The other four stop at `AGC graphics: guest 2D texture descriptor has a nonzero depth or base array`.
reyani-dev commented 2026-10-11 16:56:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T16:56:24Z.


Follow-up: with this PR plus #3807 (signed compare in SRT values) and a branch that reads a linear 2D T#'s DEPTH as its default pitch (to be opened after #3807), all five titles run the full 60 s on Windows with no error. EVO Player, Jelly5 and Nuvio PS5 present 600 frames. PS5VR compiles 150 shaders. Emby5 sits in its library scan.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6111414666 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6111414666). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T16:56:24Z. --- Follow-up: with this PR plus #3807 (signed compare in SRT values) and a branch that reads a linear 2D T#'s DEPTH as its default pitch (to be opened after #3807), all five titles run the full 60 s on Windows with no error. EVO Player, Jelly5 and Nuvio PS5 present 600 frames. PS5VR compiles 150 shaders. Emby5 sits in its library scan.
adriadam10 commented 2026-10-11 21:29:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:29:03Z.


Checked the revised pass-through against OpenAGC's sceAgcCreatePrimState (copies the special pairs verbatim), build + libSceAgc ctest (20/20) and the new agc_shader_helpers case (it fails to build without the change). CI is green on this head, and the Windows runs above cover the titles. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113976932 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3496#issuecomment-6113976932). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:29:03Z. --- Checked the revised pass-through against OpenAGC's `sceAgcCreatePrimState` (copies the special pairs verbatim), build + libSceAgc ctest (20/20) and the new `agc_shader_helpers` case (it fails to build without the change). CI is green on this head, and the Windows runs above cover the titles. 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!3496
No description provided.