Repository navigation
fix(agc): remember shader variants that failed to prepare at use - #7682
BiladeiroSupremo wants to merge 1 commit into
Conversation
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.
|
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.
|
|
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,
AI-assisted: yes (Claude Code) |
|
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 ( This PR adds no test, so I ran full CTest (
AI-assisted: yes (Claude Code) |
adriadam10
left a comment
There was a problem hiding this comment.
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.- No test: the PR adds none. A test that prepares a failing variant twice and shows the second call does not recompile (and that it retries after the interval, e.g. with the interval injectable) is needed so the behaviour stays pinned.
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the update. This is still changes, the head also conflicts with main now.
- Main already remembers failed preparations:
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. - If that case exists, the state belongs in
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. - Bound it (a small cap per
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).
MarcZX10
left a comment
There was a problem hiding this comment.
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 01b2bf1045c0cd73ba2f26b27ab9a02a7a0489bd using repo_read.py to read the prepared bundle and targeted source ranges. No build or tests were run.
Results
| Check | Result | Note |
|---|---|---|
| Diff and source review | passed | One changed source file read |
| Build and tests | not run | No commands available |
| Negative control | not run | Not available in this review |
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), and core/libs/prx/libSceAgcDriver/Execution/include/Driver/Shaders/ShaderRegistry.hpp (selected range). The prepared review bundle listed only ShaderRegistry.cpp as reviewed; no excluded-file manifest was available through the reader.
To get this to a good state
Nothing is required.
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
main6e27fc8 with-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 onmain6e27fc8 on 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)