fix(agc): defer a shader whose code does not decode instead of aborting the title #2257
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2257"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T13:25:18Z.
What
A shader whose code does not decode ended the whole title. The decode ran outside the
try/catchthat#1836 added for shaders that cannot be prepared at registration, so one instruction this decoder does not
know reached the top and terminated the process.
Ghost of Yōtei (PPSA26344) hits it:
unsupported MIMG opcode 229(0xE5) — issue #1941.The decode now sits in the same deferral path, but only for the failure class that is a capability gap: a
new
ShaderRecompiler::UnsupportedInstructionError, thrown when a family the decoder understands contains anopcode it does not. Everything else — an unknown instruction family, a truncated instruction, reserved
control bits — still throws exactly as before, so the existing contract that registering corrupt code fails
loudly is unchanged (and remains covered at
tests/execution/PreparedShaders.cpp:239).What this does not do: it does not implement
0xE5. The opcode is still unidentified — it is absent fromLLVM's gfx1013 tables, from LLVM's MC tests for that part, and from sharpemu's decoder, yet it appears 38
times in this title's own shader store (see #1941 for that evidence). The affected shaders are deferred with
the opcode named in the reason, and they still throw when a draw actually needs them.
Tested
Linux, RTX 3080 Ti.
agc_driver_prepared_shaders_tests— the full run passes, including the corrupt-code registration case thatmust keep failing.
agc_driver_prepared_shaders_tests --deferred-undecodable— new mode, passes. It registers a shader whosesecond word is the image instruction this title carries and checks that the failure surfaces on use rather
than at registration. Honest limitation: it passes with and without the registry change (both paths
surface the same message; only the log line differs), so it documents the behaviour rather than guarding
it. The discriminating evidence is the title run below.
#757+#1836+ the aperture decode):terminate … unsupported MIMG opcode 229, exit 134, during shader preparation;Shader 0x… could not be prepared at registration (unsupported MIMG opcode 229); preparing it when it is usedfor the affected shaders, and the title carries on instead of aborting.cache_ps5/all_shaders.xpps,code word 260), which is how the test fixture was checked before it was written.
Checklist
main— Depends on #1836 (this change uses the deferral path that PR introduces)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T13:31:06Z.
Heads-up: #1836 changed under this PR. After @oneandonlydean's review, its current head (pushed about 14:20 UTC) has no
try/catchinPrepareRegisteredany more.The review said a catch around preparation is a retry after an error, which isn't allowed here. The deferral now has to be decided before preparing, in two cases only:
ShaderRecompiler::UnresolvableSwappcTarget, a predicate inGraphBuilderthat shares its condition withanalyzeSwappcCalls, finds ans_swappc_b64whose target can't be resolved.Every other error throws at registration.
So this PR is stacked on #1836's old head (177c4b2b) and no longer applies on top of it. If you keep this approach, the shape that matches the review would be an up-front check rather than a narrower catch: for example, a decoder query that reports the first known-family opcode it doesn't implement, called beside the swappc predicate before
GraphBuilder::Build. Whether a decode gap is an acceptable reason to defer at all is for the maintainers to say. The review only listed the two cases above.Written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T13:40:39Z.
Narrow-build numbers, as promised — same stack (
#757+#1836+ the aperture decode), Linux, RTX 3080 Ti.terminate … unsupported MIMG opcode 229, exit 134, during shader preparation.unsupported MIMG opcode 229(0xE5), 104 thes_swappc_b64class #1836 already defers — no abort anywhere, and the run ended only when the process was killed externally (exit 137). Shader cache: 912 misses, 910 writes.Two things the measurement settled:
PreparedShaders.cpp:239still fails loudly).0xE5remains unidentified (#1941), and a draw that needs one of them still throws, with the opcode named in the message.The failing word is reproducible offline from the title's own shader store (
cache_ps5/all_shaders.xpps, code word 260), so re-checking this does not need a game run.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T13:48:48Z.
Rebased onto current
main(the branch was opened against a base that has since moved, which is why it read CONFLICTING).Because this is stacked on #1836, the diff now also contains that PR's changes — they share
ShaderRegistry.cpp, and #1836 is itself behindmain. The part that is this PR is only:core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp— the decode moved into the deferral path, catching onlyUnsupportedInstructionErrorcore/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp+CMakeLists.txt— the deferral test and its ctest entrycore/shader/recompiler/RdnaDecoder/**— the typed error and the seven family-scopedunsupported … opcodethrows that now use itOnce #1836 lands, that diff shrinks to these files. Re-verified after the rebase: build clean, both test paths pass (
--deferred-undecodableand the full run path, i.e. the corrupt-code contract), and the repository's convention checks pass.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by EdouardSence on 2026-10-09T14:05:57Z.
The rebased head (83c247d3) still carries #1836's old commit. Its
ShaderRegistry.cpphascatch (const std::exception& error)around preparation, at line 405, which is the catch-all the review on #1836 rejected.#1836's current head is
52b77c20, onmain43972e69. It has notryinPrepareRegisteredat all; the deferral is decided up front throughUnresolvableSwappcTarget. Stacking on that commit should drop the broad catch from this diff. What remains is then only your decode change, and you can see how it fits with the review.Written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:14:40Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
83c247d3, merged ontomaind70b8998in a batch with other AGC/shader PRs.agc_driver_prepared_shaders_deferredUndecodablefails under ctest on Windows in every run (Exit code 0xc0000135, DLL not found). The test passes; its registration is what fails:deferredbranch, so the loop's shared properties apply only to${preparedTest}. The new test gets noPATHprepend on Windows, noANYPS5_NO_SHADER_CACHE=1, noSKIP_RETURN_CODE 77, and it runs in the build directory instead of the source directory.PATH,--deferred-undecodablepasses 5 of 5.tools/check_test_registration.pypasses:The rest of the suite passed in the same build (514 of 515), including
agc_driver_prepared_shaders_deferredand the other fiveagc_driver_prepared_shaders*tests. No title was run.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T17:52:16Z.
Re-stacked onto #1836's current change (its head
52b77c20, cherry-picked here as81a32faf— an identical patch). The broadcatch (const std::exception&)is gone from this diff: the branch is now #1836 + the decode change (6 files); once #1836 lands this diff is only the decode change.What the change is now:
UnsupportedInstructionError(astd::runtime_error) is raised by the five family-scoped SOP opcode defaults (unsupported SOP1/SOP2/SOPC/SOPK/SOPP opcode …) and by the MIMG opcode lookup, which now names the opcode (unsupported MIMG opcode 229).PrepareRegistered: the decode is wrapped for that type only — anUnsupportedInstructionErrordefers the shader with the reason; anything else still throws, so the corrupt-code contract is unchanged.deferred_undecodablenow has its ownforeachentry, so it gets the samePATHprepend,SKIP_RETURN_CODE 77and source-dir as the other variants. The earlier form was nested inside thedeferredbranch and lacked that setup, which matches the Windows ctest failure @popcoder565 reported (0xc0000135); I have not reproduced it here.Scope — this defers the scalar-family and MIMG opcode gaps only. The vector (VOP*) and memory (SMEM/MUBUF/MTBUF/FLAT/DS) opcode lookups still throw
std::invalid_argument/std::runtime_error, as do the modifier-level "not supported" throws and the malformed/truncated throws, so a title that hits one of those still aborts at registration. Whether the deferral should cover every decode gap, rather than the opcode gaps the #1941 investigation reaches, is the question @EdouardSence left to the maintainers — so I have kept this change to that set rather than widen it unilaterally.Evidence for the fixture: the failing word is
0xf1949f05, an MIMG whose opcode field is 229 (0xE5), and it comes from the title's own shader store —cache_ps5/all_shaders.xpps, the pairf1949f05 || 00060018at file offset 3235676. The fixture{0xbe842104, 0xf1949f05, 0x00060018}reproduces the exception path offline; it does not adjudicate #1941's still-open question of whether the word is a reserved encoding or a mis-aligned walk.Verified on Linux, Release (gcc 16.2.1), base
f8c2f072:Negative control — reverting only the decode-deferral hunk (test kept) rebuilds and the case fails:
so without the deferral the decode error propagates out of registration instead of deferring the shader, which is the #1941 abort.
Wider
ctestover the agc/shader/recompiler/decoder tests: 263 ran, 262 passed, 1 failed. The failure,agc_driver_dcc_keys_first_write("an unchanged pending image was uploaded again"), also fails on a pristinef8c2f072build — pre-existing and unrelated to this change.Not verified: no Windows run by me, and macOS/arm64 was not run. The test exercises the MIMG path only; the SOP typing is not covered by a fixture.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:23:11Z.
@Dextroid17 confirmed on Windows with
5b8316ff, merged ontomain8b393b6e(Windows 10, RTX 3060 Laptop, NVIDIA 616.92, MinGW-w64 GCC 15.2.0, Release). From a clean shell, all sevenagc_driver_prepared_shaders*tests pass under ctest, includingagc_driver_prepared_shaders_deferred_undecodable. The full suite passes in that build (513 of 513, with #2193 and a local fix for its Windows build).🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T19:58:15Z.
Confirmed and much appreciated — all seven
agc_driver_prepared_shaders*passing under ctest on Windows, including..._deferred_undecodable, is the evidence this PR was missing.One thing I would like to pin down, because two of your comments read differently. On #1940 you noted the one Windows failure in that build was "#2257's new test, which is registered without the Windows
PATHsetup". In this PR's CMake the two new modes are appended to the existingforeach(preparedMode ...)list, and the PATH line is applied inside that loop:so the new tests inherit it exactly as the existing ones do. Your later run here passing — with "#2193 and a local fix for its Windows build" — fits that: a missing DLL from #2193 rather than a gap in this registration.
Could you say which of the two it was? If the registration really is incomplete I will fix it in this PR, but I would rather not change CMake that looks correct on a guess.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T22:24:11Z.
@Dextroid17 both were right, for different heads, so no CMake change is needed now.
83c247d3, the head in the batch my #1940 comment refers to. There, thedeferredbranch added a second test,add_test(NAME ${preparedTest}Undecodable ...). The loop'sset_tests_properties(${preparedTest} ...)and theWIN32PATHline only apply to${preparedTest}, soagc_driver_prepared_shaders_deferredUndecodablegot noPATH, environment or working directory. It failed 3 of 3 from a clean shell with0xc0000135.5b8316ffgivesdeferred_undecodableits ownforeachentry, as suggested in my first comment here, so it gets the loop'sPATHline like the others. That's the run that passed.resultundeclared insceKernelFcntl). It had nothing to do with this registration or a missing DLL.🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:17:46Z.
Rebased onto current
main(#1836 is merged, so the branch is now just the decode change). Checked:agc_driver_prepared_shaders*pass, includingdeferred_undecodable; with the non-test changes reverted that test fails, so it pins the behaviour.UnsupportedInstructionError(known family, unimplemented opcode) is deferred; unknown family, truncated instruction and reserved bits still throw at registration, covered by the existing corrupt-code case.std::invalid_argumentfrom these decoders.5b8316ff(513/513, all sevenprepared_shaders*).Not verified here: the PPSA26344 run itself.
Merging after CI on the rebased head.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:54:18Z.
Rebased onto current
main(conflict inRdnaImageOpDecoder.cpp:mainnow prints the opcode as0x%02x; kept that format and throwUnsupportedInstructionErrorwith it). Checked:agc_driver_prepared_shaders*.UnsupportedInstructionError(known family, unimplemented opcode) is deferred; unknown family, truncated instruction and reserved bits still throw at registration.5b8316ff(513/513, all sevenprepared_shaders*).Not verified here: the PPSA26344 run itself.
Merging after CI on the rebased head.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:06:03Z.
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.
main)core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cppL371