fix(agc): remember shader variants that failed to prepare at use #7682
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7682"
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 BiladeiroSupremo on 2026-10-18T22:42:25Z.
A draw or dispatch whose variant has no prepared entry prepares it in place. When that failed, nothing was kept, so every later draw of the variant ran the whole recompile again on the draw thread and failed the same way. The failure is now kept per variant (prepared state, code offset, prepared key and code); those draws throw the same error at once, and the variant is prepared again after a minute.
What
A draw or dispatch whose shader variant has no prepared entry prepares it in place (
InvocationForinShaderRegistry.cpp). When that preparation threw, nothing was kept, so every later draw of the same variant ran the whole recompile again on the draw thread and failed the same way, every frame.The failure is now kept per variant (prepared state, code offset, prepared key and code). Draws of that variant throw the same error at once (the caller skips them as before), and the variant is prepared again after a minute.
PR #7644 edits the same lines (
ShaderRegistry.cppL729-730) for its opt-in lazy ABI preparation; the two changes are independent and only overlap textually.Tested
Windows 11 Pro 10.0.26300, MinGW-w64 GCC Release build of this branch on
main6e27fc8f0with-DBUILD_TESTING=ON, AMD Radeon RX 9070: fullctest1501 of 1513 passed. The 12 failures do not come from this change, it's because my windows profile has my name with ' on a letter: 9 fail the same way onmain6e27fc8f0on this machine (select_tests,check_compile,windows_import_modules,agc_driver_division_output_modifiers,agc_driver_division_result_modifiers,agc_driver_f64_conversions,agc_driver_f64_transcendental,agc_driver_quad_pixel_mask,agc_driver_layered_volume_vertex_no_gpl), and 3 came from another change in the same test tree; on this branch aloneagc_write_tracking,agc_driver_partially_resident_*,agc_driver_prepared_*,agc_shader_memoryandguest_memory(31 tests) pass.Seen on a downstream fork with the same code path: in PPSA03671 two gameplay shaders the recompiler rejects ("bindless storage image tables are unsupported") were recompiled and failed again ~170 times each in one session; with the change each failure is prepared once a minute at most.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-19T03:47:53Z.
A clean run on a second vendor, since 12 tests failed on your machine for path reasons: NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ONwith every execution test built. This head (01b2bf104) merged intomainad502d717.select_tests,check_compile,windows_import_modules,agc_driver_division_output_modifiers,agc_driver_division_result_modifiers,agc_driver_f64_conversions,agc_driver_f64_transcendental,agc_driver_quad_pixel_mask,agc_driver_layered_volume_vertexandagc_driver_layered_volume_vertex_no_gpl.tools/select_tests.pyselects: 957 pass, 15 skip and 3 fail. The 3 failures are the onesmainhas on this GPU without this PR:agc_driver_bda_device(#7584),agc_driver_image_table_reuse(#7710) andagc_driver_pixel_lds(#7708).tools/check_skips.py --job windowsaccepts the skips.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T09:32:09Z.
Windows regression check on an Intel UHD 770 and an AMD RX 9070 XT: no new failures in the full CTest results.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built. Intel UHD Graphics 770 (
8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head01b2bf104merged intomain6b8228b2b.This PR adds no test, so I ran full CTest (
--parallel 4) with it merged:mainalone, out of 1605. These are the image-table tests that #6647 addresses andagc_driver_sample_multisample_target(#6957).mainalone, with nodevice-faultlines. I left out the threeAPS5_NO_GPLtests (agc_driver_draw_cache_reuse_off,agc_driver_stencil_replay_no_gpl,agc_driver_layered_volume_vertex_no_gpl). Onmainthey fault the GPU in a parallel AMD run on Windows (#7809, fixed by #7828).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T16:57:37Z.
Review: CHANGES_REQUESTED
Thanks, the idea is sound and the callers all catch
std::exception, so rethrowing a cached error is fine. Points to address:ShaderRegistry.cpp:750-753:failureshas no bound. An entry is only erased when the same identity is drawn again after 60 s, and the identity depends on guest data (code, key, code offset), so a title that keeps producing distinct failing variants grows it for the whole session. Please cap it (entries, derived sensibly) and drop expired entries when inserting, and log once when the cap is hit.ShaderRegistry.cpp:760-769: the identity mixes the rawPreparedShaders*address, which can be reused after the object is freed, and is only a 64-bit hash: a collision (or a reused address) makes an unrelated variant throw a stale error. Key the map on the real data or keep the entry insidePreparedShadersso it dies with it.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T02:23:48Z.
Review: CHANGES_REQUESTED
Thanks for the update. This is still
changes, the head also conflicts withmainnow.core/shader/recompiler/Recompiler.cppkeepsplanFailure(rethrown ingetSource) andemissionFailures, andAPS5_NO_FAILURE_MEMO=1turns it off. The string "bindless storage image tables are unsupported" from the PPSA03671 log does not exist onmain, so the repeated recompile you saw is from the fork. Please show a failing variant onmainthat still goes through a full recompile on every draw (a test that prepares it twice and counts the work), otherwise this duplicates the existing memo.PreparedShaders(ShaderRegistry.hpp):InvocationFornow runs undersnapshot.prepared->mutex, so the global map and its mutex are not needed, and the entry dies with the shaders instead of keying on a reusablePreparedShaders*address plus a 64-bit hash. ComparecodeOffset, the prepared key and the code word for word.PreparedShaders, drop expired entries when inserting) and cover it with a test: second call does not prepare again, and it prepares again after the retry interval (make the interval injectable).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:37:46Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change based on the code inspected; the review is incomplete because the prepared check output and full repository context were unavailable.
What I ran
Reviewed head
01b2bf1045c0cd73ba2f26b27ab9a02a7a0489bdusingrepo_read.pyto read the prepared bundle and targeted source ranges. No build or tests were run.Results
Findings
Blocking
None found in the inspected code.
Non-blocking
None.
Not verified
The full changed source file was not read; only the added code and nearby preparation flow were inspected. No tests, build, concurrency stress, or runtime behavior were verified. The author-reported test results in the PR description were not independently run.
Files read:
review/description.md,review/commits.md,review/manifest.json,review/diff.patch,core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp(selected ranges), andcore/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp(selected range). The prepared review bundle listed onlyShaderRegistry.cppas reviewed; no excluded-file manifest was available through the reader.To get this to a good state
Nothing is required.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.