fix(agc): make sceAgcCreateShader idempotent #18651

Merged
DealPotato merged 1 commit from upstream-pr/18651 into main 2026-11-14 17:43:35 +00:00
DealPotato commented 2026-11-12 00:00:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-11-12T00:00:37Z.


What

A title may call sceAgcCreateShader again on a header it already created. The second call resolved the relative pointers again and added the code base to the program address registers a second time. WWE 2K26 (PPSA34299) does this in its main menu and crashed on the corrupted pointers.

A header whose code pointer is already set keeps its resolved pointers, and its program address is rebased from the previous code address onto the new one.

Tested

Windows 11 Pro (build 26300), NVIDIA GeForce RTX 4070, driver 610.88. Focused tests run with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V on main (3a0a54bbd8) and on this change, from one build directory; the loader inserted the validation layer in both runs.

Passed on main and on the change: agc_create_shader. Neither log has a VUID- message. The build also held four other fixes for the same title on other code; two of them are opened as pull requests next to this one.

The new agc_create_shader case creates a pixel shader twice from one header (pointers and program address unchanged) and a third time from other code (program address rebased onto it). WWE 2K26 reaches its menus with the change on the ps5/wwe2k26 work branch.

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
  • Fixes: none
  • Unblocks: PPSA34299 (WWE 2K26; no Game bring-up discussion yet)
  • GPUs tested: NVIDIA GeForce RTX 4070, driver 610.88, Windows 11 Pro (build 26300)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5268713072 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18651). Originally posted by [DealPotato](https://github.com/DealPotato) on 2026-11-12T00:00:37Z. --- ### What A title may call `sceAgcCreateShader` again on a header it already created. The second call resolved the relative pointers again and added the code base to the program address registers a second time. WWE 2K26 (PPSA34299) does this in its main menu and crashed on the corrupted pointers. A header whose code pointer is already set keeps its resolved pointers, and its program address is rebased from the previous code address onto the new one. ### Tested Windows 11 Pro (build 26300), NVIDIA GeForce RTX 4070, driver 610.88. Focused tests run with `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `ANYPS5_NO_SHADER_CACHE=1`, `ANYPS5_REQUIRE_VULKAN=1` and `ctest -V` on `main` (3a0a54bbd8) and on this change, from one build directory; the loader inserted the validation layer in both runs. Passed on `main` and on the change: `agc_create_shader`. Neither log has a `VUID-` message. The build also held four other fixes for the same title on other code; two of them are opened as pull requests next to this one. The new `agc_create_shader` case creates a pixel shader twice from one header (pointers and program address unchanged) and a third time from other code (program address rebased onto it). WWE 2K26 reaches its menus with the change on the `ps5/wwe2k26` work branch. ### 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] Fixes: none - [x] Unblocks: PPSA34299 (WWE 2K26; no Game bring-up discussion yet) - [x] GPUs tested: NVIDIA GeForce RTX 4070, driver 610.88, Windows 11 Pro (build 26300) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-12 00:38:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-12T00:38:38Z.

Review: APPROVED


Reviewed — looks good

The repeated call now leaves already-resolved header pointers intact and rebases the shader-program register pair from the previous code base to the new one; the focused regression covers both same-code and moved-code calls.

What I ran

Head cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8; base 6183766a30d705f318e2479bd47b392da26353c5. Environment: Debian 12, Python 3.11.2, GCC 12.2.0.

git diff --check 6183766a30d705f318e2479bd47b392da26353c5...cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8
/usr/bin/python3 tools/check_conventions.py --base 6183766a30d705f318e2479bd47b392da26353c5 --head cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8 --title 'fix(agc): make sceAgcCreateShader idempotent' --body /tmp/anyps5-pr-precheck-18651/pr-body.md
/usr/bin/python3 /marc/AnyPS5/tools/pr_abi_audit.py --base 6183766a30d705f318e2479bd47b392da26353c5 --head cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8 --json
/usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 18651 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck-18651/stack
/usr/bin/python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck-18651/head-cbfcb7c2ec94-d67eea35 --json core/libs/prx/libSceAgc/Shader/include/ShaderUtils.hpp core/libs/prx/libSceAgc/Shader/src/CreateShader.cpp core/libs/prx/libSceAgc/Shader/src/ShaderUtils.cpp core/libs/prx/libSceAgc/tests/CreateShader.cpp

The PR description reports agc_create_shader passing on Windows 11 with an RTX 4070 and Vulkan validation enabled, on both main and this change. It also reports WWE 2K26 reaching its menus on a work branch containing this PR; I did not run either test locally.

Results

Check Result Note
Diff whitespace passed Exit 0.
Conventions passed “All conventions checks passed.”
Export ABI audit passed No findings; lexical audit does not prove binary ABI correctness.
Dependency/mergeability passed Report generated.
Test-quality heuristic passed No findings.
Focused GPU test author-reported pass agc_create_shader; not run locally.
Hosted CI not relied on No hosted build result was used as evidence.

Findings

Blocking

None.

Non-blocking

None.

Sources

Not verified

  • I did not build or run the C++/GPU tests locally; the focused CTest result is from the PR description.
  • No console run was independently performed.

To get this to a good state

No follow-up is required for the reviewed head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5867259853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18651#pullrequestreview-5867259853). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-12T00:38:38Z. **Review:** APPROVED --- # Reviewed — looks good The repeated call now leaves already-resolved header pointers intact and rebases the shader-program register pair from the previous code base to the new one; the focused regression covers both same-code and moved-code calls. ## What I ran Head `cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8`; base `6183766a30d705f318e2479bd47b392da26353c5`. Environment: Debian 12, Python 3.11.2, GCC 12.2.0. ```sh git diff --check 6183766a30d705f318e2479bd47b392da26353c5...cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8 /usr/bin/python3 tools/check_conventions.py --base 6183766a30d705f318e2479bd47b392da26353c5 --head cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8 --title 'fix(agc): make sceAgcCreateShader idempotent' --body /tmp/anyps5-pr-precheck-18651/pr-body.md /usr/bin/python3 /marc/AnyPS5/tools/pr_abi_audit.py --base 6183766a30d705f318e2479bd47b392da26353c5 --head cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8 --json /usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 18651 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck-18651/stack /usr/bin/python3 /marc/AnyPS5/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck-18651/head-cbfcb7c2ec94-d67eea35 --json core/libs/prx/libSceAgc/Shader/include/ShaderUtils.hpp core/libs/prx/libSceAgc/Shader/src/CreateShader.cpp core/libs/prx/libSceAgc/Shader/src/ShaderUtils.cpp core/libs/prx/libSceAgc/tests/CreateShader.cpp ``` The PR description reports `agc_create_shader` passing on Windows 11 with an RTX 4070 and Vulkan validation enabled, on both main and this change. It also reports WWE 2K26 reaching its menus on a work branch containing this PR; I did not run either test locally. ## Results | Check | Result | Note | |---|---|---| | Diff whitespace | passed | Exit 0. | | Conventions | passed | “All conventions checks passed.” | | Export ABI audit | passed | No findings; lexical audit does not prove binary ABI correctness. | | Dependency/mergeability | passed | Report generated. | | Test-quality heuristic | passed | No findings. | | Focused GPU test | author-reported pass | `agc_create_shader`; not run locally. | | Hosted CI | not relied on | No hosted build result was used as evidence. | ## Findings ### Blocking None. ### Non-blocking None. ## Sources - [Idempotent pointer resolution and code-base update at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8/core/libs/prx/libSceAgc/Shader/src/CreateShader.cpp#L28-L64) - [Program-address register rebasing and overflow checks at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8/core/libs/prx/libSceAgc/Shader/src/ShaderUtils.cpp#L27-L57) - [Regression for repeated calls and moved code at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/cbfcb7c2ec94fa31b381547eafcacaf85c16cbe8/core/libs/prx/libSceAgc/tests/CreateShader.cpp#L92-L106) ## Not verified - I did not build or run the C++/GPU tests locally; the focused CTest result is from the PR description. - No console run was independently performed. ## To get this to a good state No follow-up is required for the reviewed head.
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!18651
No description provided.