fix(shader): verify materialized snapshot identity before memo reuse #4757
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4757"
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 Ondra97 on 2026-10-12T20:55:31Z.
What
Two different resource captures can have the same snapshot hash. The result memo accepted that hash as identity and returned the first capture's push constants for the second request. A CPU-only pixel-shader regression uses the colliding user-data pairs
{0x252becb5, 0}and{0xb3d4134a, 0x94fffe4d}: on main the second request receives0x252becb5instead of0xb3d4134a.Keep the hash as a lookup prefilter, but require equality with an owned resource snapshot and the request state used to populate the result. Check both the initial lookup and the second lookup after materialization outside the mutex. A collision replaces the memo entry without changing already returned immutable results. The existing admission policy and 256-entry limit remain unchanged; #1298 proposes a separate admission policy in the old materialization path and does not fix snapshot identity.
The tradeoff is memory: with MinGW GCC 15.2 the inline entry grows from 32 to 280 bytes, at most about 62 KiB extra per source at the 256-entry limit, plus owned vector payloads and allocation overhead. Copies occur on insertion; matching hits do not allocate. No shader instruction semantics, cache format or NID exports change.
Tested
Windows, MinGW-w64 GCC 15.2, Release, BUILD_TESTING=ON. Full build exits 0 and the 14 relevant CPU shader/patched-library tests pass (0.53 s, no skips) on main
c952c2b0eplus this commit. The new memo case takes 0.03 s. Registration finds 730 built test executables, none unregistered, and 1011 CTests. The newagc_shader_snapshot_memocase covers A -> B -> A, repeated-hit identity, retained-result immutability and 16 synchronized concurrent collision pairs, comparing the values to uncached references. It fails on the original recompiler and passes with this change. Tests disable the disk cache and use the existing Prepare/CaptureResources/MaterializeShader path.Test-executable registration and patched/unpatched Driver export audits pass; no ResultMemoEntry, Matches or default-equality helpers become NIDs.
git diff --checkand the committed-change conventions check pass. No game, console, Vulkan device or performance workload was run; no title unblock or speed improvement is claimed.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 github-actions[bot] on 2026-10-13T01:56:35Z.
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/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppL45core/shader/recompiler/IntermediateRepresentation/include/IntermediateRepresentation/IrMetadata/ResourcePlan.hppL45core/libs/prx/libSceAgcDriver/CMakeLists.txtL1223Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T03:27:11Z.
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main
0c3dc9ca2together with eight other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:tests/ShaderMemory.cpp(agc_shader_memory): 3 of 3 runs passed.Not tested: no game run. The batch was built once, not per PR; it had no failures, so no bisect was needed.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:32:39Z.
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed