Skip to content

fix(agc): defer a registered shader whose code does not decode instead of aborting - #15499

Draft
QRMOE wants to merge 1 commit into
boykopovar:mainfrom
QRMOE:fix/agc-defer-registered-decode-errors
Draft

QRMOE wants to merge 1 commit into
boykopovar:mainfrom
QRMOE:fix/agc-defer-registered-decode-errors

Conversation

@QRMOE

@QRMOE QRMOE commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What

PlanRegistered (ShaderRegistry.cpp) decodes a shader as soon as it is registered. If the decoder refuses an instruction it doesn't support (UnsupportedInstructionError), the shader is deferred to its first use. Every other decoder failure escaped the registration call and aborted the title. Those failures are:

  • std::invalid_argument: an unknown instruction family, an unimplemented VOP2/VOP3 opcode, or an unsupported scalar source operand;
  • std::runtime_error from the memory-op decoder.

Registration doesn't run the code; the GPU only executes it at a dispatch or draw. With this PR, registration defers on any decoder failure: it logs the existing "could not be prepared at registration (...); preparing it when it is used" line. A stage whose code still fails to decode when it is used throws there as before.

RESIDENT EVIL requiem (PPSA31246, #11599) hit this in about one New Game load in four on Windows, 2–4 minutes into loading, each time with a different message:

  • unknown RDNA instruction family at program counter 0x00001504 raw word 0xc3800000
  • unknown RDNA instruction family at program counter 0x00002304 raw word 0xff08aa1f
  • unsupported scalar source operand code 112 at program counter 32216
  • VOP2 opcode is not implemented

Both symbolized stacks end in PlanRegistered → RdnaInstructionDecoder::Decode → DecodeRdnaProgram.

Tests:

  • The registration test in tests/execution/PreparedShaders.cpp re-registered a shader with garbage code (0xffffffff) and expected the call to throw. It now expects the registration to succeed, then restores the valid code before its dispatches. Its later check, that a dispatch of an invalid program fails, is unchanged.
  • New mode deferred_unknown_word, sharing a helper with deferred_undecodable: it registers a program whose second word is 0xc3800000, one of the words from the requiem aborts. Registration must not throw, and the dispatch must fail with unknown RDNA instruction family.

Tested

Windows 11 (26200), Ryzen 7 9800X3D, RX 9070 XT (AMD 26.6.2 / 32.0.31021.1015), MinGW GCC 15.2, Release, main 4f41f4c.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R agc_driver_prepared_shaders -V:

Build Passed VUID- lines "was not found but was requested by env var VK_INSTANCE_LAYERS"
main code and tests 23 of 23 0 0
main's ShaderRegistry.cpp with this PR's tests 19 of 24: the four registration modes, and deferred_unknown_word with unknown RDNA instruction family at program counter 0x00000004 raw word 0xc3800000 0 0
This PR 24 of 24 0 0

The loader log shows VK_LAYER_KHRONOS_validation inserted in every run.

Not yet run in the title with this change on its own; the requiem stack it was found on has other local changes. tools/pr_overlap.py reports a one-line conflict with #9563 in the test's argument check.

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: PPSA31246 RESIDENT EVIL requiem (PPSA31246) #11599
  • GPUs tested: AMD Radeon RX 9070 XT, AMD 26.6.2 (32.0.31021.1015), Windows 11 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line build agc libSceAgc* labels Nov 3, 2026
@QRMOE
QRMOE force-pushed the fix/agc-defer-registered-decode-errors branch from 05f7f85 to 29a8a0d Compare November 5, 2026 08:27
@AlfaRojo

AlfaRojo commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Windows red/green of head 29a8a0d971, merged onto main 3cb1cd29ec (308237b745, clean merge), on both vendors.

Setup: Windows 11 Pro (10.0.26200), WinLibs GCC 15.2.0 r7 UCRT, Release, ANYPS5_AGC_EXECUTION_TESTS including PreparedShaders, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ANYPS5_GPU selecting the device; no validation layer on this machine. Red = this PR's test sources with ShaderRegistry.cpp reverted to main.

GPU agc_driver_prepared_shaders_deferred_unknown_word, red green all 24 agc_driver_prepared_shaders*, green
NVIDIA GeForce RTX 4070 (10de:2786, driver 32.0.16.1692) 0 of 3 3 of 3 pass 24 pass
AMD Radeon Graphics 1002:13c0 (RDNA 2 integrated, driver 32.0.21043.5001) 0 of 3 3 of 3 pass 24 pass

In the red arm the default, indirect and uncached modes fail as well, as expected: the fixture now registers the undecodable shader without ExpectFailure, so every mode that reaches that registration aborts on main's registry. No title run.

AI-assisted: yes.

…d of aborting

PlanRegistered decodes a shader when it is registered and defers it to its
first use when the decoder refuses an instruction it does not support
(UnsupportedInstructionError). Every other decoder failure, such as an
unknown instruction family, an unimplemented VOP2/VOP3 opcode or an
unsupported scalar source operand (std::invalid_argument, and
std::runtime_error from the memory-op decoder), escaped the registration
call and aborted the title. Registration does not run the code; the GPU
only executes it at a dispatch or draw. Registration now defers on any
decoder failure, and the stage still throws if the code fails to decode
when it is used.

The prepared-shaders registration test re-registered garbage code and
expected the call to throw; it now expects the registration to succeed and
restores the valid code before dispatching. A new mode,
deferred_unknown_word, registers a program with an unknown-family word and
checks that its dispatch fails with that decoder message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@QRMOE
QRMOE force-pushed the fix/agc-defer-registered-decode-errors branch from 29a8a0d to ea23d0e Compare November 6, 2026 09:03
@QRMOE

QRMOE commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

The windows check has now been cancelled at the job's 45-minute limit three times (on 29a8a0d twice and on ea23d0e), each time while building guest tests, never on a failing test or a compile error.

This PR adds a test mode to agc_driver_prepared_shaders_tests.cmake. tools/build_changed_guest_tests.py counts any .cmake change under core/libs/ as a broad change, so the job builds every guest test target. On ea23d0e it reached step 157 of 1334 of the guest-test batches when the limit hit. The mode can't go into an existing test: each failing registration leaves the driver failed until shutdown, so the new case needs its own process and add_test.

Could a maintainer rerun the windows job once the compiler cache is warm, or run it with a longer limit? AlfaRojo's Windows run above covers the changed tests on NVIDIA and AMD.

AI-assisted: yes.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 6743 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 7682 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 9563 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 11442 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 19181 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 20131 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 20153 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22251 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22328 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22439 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22546 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22628 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 22692 core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 23553 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 24523 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 25489 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28095 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28220 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28252 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28279 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28280 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28289 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28376 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28411 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_prepared_shaders_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 28564 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28586 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28631 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28668 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28702 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28716 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_prepared_shaders_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 28808 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_prepared_shaders_tests.cmake
core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp
PR 28936 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28941 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28952 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28957 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28958 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28962 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 28964 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29042 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29052 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29066 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29067 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29076 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29084 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29085 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29087 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29089 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29095 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29118 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp
PR 29188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp

@Lucke0051

Copy link
Copy Markdown
Contributor

Ran this PR merged onto main 75020cd (PR head ea23d0e) on two Linux GPUs and compared with main on the same machine (CachyOS, Linux 7.3.1, gcc 16.2.1 Release). These are the first Linux runs and the first on an Intel GPU, next to the Windows runs in the description and above.

GPU AGC, shader and VideoOut tests
NVIDIA GeForce RTX 3070 Ti, NVIDIA 615.78.08 no difference from main; agc_driver_prepared_shaders_deferred_unknown_word passes 3 of 3 alone
Intel UHD Graphics 630 (CML GT2), Mesa 26.2.6 no difference from main; agc_driver_prepared_shaders_deferred_unknown_word passes 3 of 3 alone
Failures main has too on this machine

Command: ANYPS5_GPU=<NVIDIA|UHD> ANYPS5_REQUIRE_VULKAN=1 ctest --test-dir build -j8 --timeout 120 -R '^(agc|video_out|shader)'; the new test alone with -R '^agc_driver_prepared_shaders_deferred_unknown_word$' -V. No validation layer installed here, so no VUID- comparison.

AI-assisted: yes (Claude ran the tests and drafted this comment)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Nov 14, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing in the reviewed changes blocks merging; the registration deferral and tests match the stated behavior.

What I ran

Reviewed head ea23d0e6548734e42962f1b2500914fc945a43de using repo_read.py. No commands or tests were run by me; test results in the PR description are author-reported.

Results

Check Result Note
Change review passed Three changed files read
Tests not run Results reported by author

Findings

Blocking

None.

Non-blocking

None.

Not verified

I read ShaderRegistry.cpp, agc_driver_prepared_shaders_tests.cmake, and PreparedShaders.cpp, including the changed hunks and relevant surrounding functions. All three files listed in the manifest as reviewed were read. files.json was not available through the reader, so I could not confirm whether it lists exclusions. I did not run the tests or verify the behavior in the title.

To get this to a good state

Nothing is required.

@ligmaSec ligmaSec left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trial merge onto c1601e56d5 conflicts in the prepared-shader execution fixture and its CMake registration. Please limit deferred registration to decoder failures. The new std::exception catch also handles allocation failure from decoding, which would mark a resource failure as a deferred shader. Keep the unknown-word case, the existing unsupported-instruction case, and the test that a deferred failure reaches its first-use boundary.

AI-assisted: yes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build needs rebase Conflicts with main, rebase needed unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants