fix(agc): enforce MSAA guards for ordinary image cache hits #7650
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7650"
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 alex73630 on 2026-10-18T19:37:26Z.
What
An ordinary sampled or storage image can remain cached after a multisampled color target is registered over the same guest memory. The resource reuse proof accepts unchanged memory stamps without checking the new owner. A fresh sampled build can also bypass the guard through its precollected texture shortcut. Check the color-target guard before either shortcut accepts an ordinary image. [1] [2]
Keep image-table entries outside this eager guard: they can contain valid native MSAA views, and invalid entries need per-element fault handling. The existing combined color/depth guard retains its behavior. The standalone regression covers draw and compute sampled/storage bindings, disjoint and overlapping targets, retirement, and a native MSAA table entry. The separate reused-table registration gap is recorded in technical debt. [3] [4] [5] [6]
No title unblock or speed improvement is claimed. This branch does not depend on the GT7 integration branch or PR #6636.
Overlap: #7154 adds depth-plane flushing adjacent to both checks; it does not implement the color-target guard. Either integration must retain the guard before the fast sampled lookup and retain the depth flushes. The debt paragraph also overlaps #6215, #6571 and the #6973/#6987/#6989/#6995/#7002 MSAA layout series; those changes do not add these ordinary-cache checks. Some comparisons are unavailable because those PRs already conflict with main; shared-code review found no equivalent fix. #7642 adds an opt-in device image-table path and does not replace this guard. #6946/#6947 add earlier reuse returns, which must remain after this ordinary-image guard when combined.
Tested
Arch Linux, kernel 7.2.11-zen1-1-zen, NVIDIA GeForce RTX 3070, driver 615.78.08. RelWithDebInfo, BUILD_TESTING=ON, bundled dependencies, ANYPS5_ENABLE_SPIRV_TOOLS=OFF, ANYPS5_REQUIRE_VULKAN=1. Based on main
48d61f53b.These are resource construction/validation regressions, not a title runtime or performance benchmark. Windows and other GPU vendors were not tested locally. The existing fresh storage guard is checked for consistency; it is not newly implemented here.
git diff --checkandpython3 tools/check_conventions.py --base origin/mainpass.python3 tools/pr_overlap.py --branch fix/agc-cached-image-msaa-guard --jobs 1completed with the overlap limitations above.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-18T19:56:17Z.
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/Graphics/src/ShaderResources.cppL3230-3231, L4489-4490Some 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.
docs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-18T20:52:08Z.
AMD on Windows: the new
agc_driver_cached_image_multisample_guardfails here, 3 runs of 3. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release,BUILD_TESTING=ON. Build:maine8ad642fewith #7651, #7650, #7647, #7655 and #7648 merged together (each merge clean, built once).The failure is the fixture's own precondition, not a wrong result: on this GPU and driver the test doesn't reach the fast image proof it means to check. The other tests in this area pass 3 of 3:
agc_driver_graphics,agc_driver_image_table_reuse,agc_driver_multisample_fill_host_only,agc_driver_native_multisample_depth,agc_driver_sample_mask_depth_stencil,agc_driver_sample_mask_drawandagc_driver_sample_mask_multisample.AI-assisted
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T21:52:57Z.
Windows data on an Intel UHD 770 and an AMD RX 9070 XT. The new
agc_driver_cached_image_multisample_guardfails on both, with and without the driver change, at the fixture's fast-proof precondition, before it reaches the guard:Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (RDNA 4,1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head36b059672merged intomainf3059421f.agc_driver_cached_image_multisample_guard, ×3the fixture did not exercise the fast image proofmain, without the rest of the PRAPS5_NO_FAST_REVALIDATE=1Why the fast proof isn't taken on Windows:
HostImportFor,Texture.cpp).decideImportWatch(GuestBufferMemory.cpp:1094) always setsunwatchImports. This log also prints[write-watch] Windows direct host imports use comparisons (no second queue to settle imports on).GuestMemory::CollectWritesreturns 0 for it.fastRevalidatethen stops atfail(FastFail::Collect)(ShaderResources.cpp:2796), andRevalidatesucceeds through the full walk, reportingProofPath::Full.An existing pattern would keep the guard covered on Windows.
tests/Recorder.cpp:3184checksAgcDriver::GuestMemory::Watched(address, bytes)and printshost imports are compared, not watched: draw snapshot reuse not testedinstead of failing. The fast-pathRequirehere could depend on the same check. The run withAPS5_NO_FAST_REVALIDATE=1shows that the rest of the test passes on both GPUs.Full CTest with this PR and the 14 other open AGC PRs I tested in the same batch merged together: the only failure beyond
main's own is this test, on both GPUs.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by alex73630 on 2026-10-18T23:52:34Z.
Thanks @LeandroLP23 and @savvaniss for the Windows reports and diagnosis. Pushed the fixture correction in ad1bf47f78ea9181f40401628131503eed80ce56 and rebased the branch onto main
a6dd29b3d.The fixture now checks
GuestMemory::Watched(address, bytes)before requiringProofPath::Fast. Watched image memory must still take the fast path unless it is explicitly disabled. When imports use comparisons instead of write tracking, the fixture reports that fast-proof coverage is unavailable and continues through all existing MSAA guard checks using the full proof. There is no early return, Windows-specific exception, or production-driver change in this follow-up.Validation on Linux / RTX 3070:
APS5_WRITE_WATCH_IMPORTS=unwatch.agc_driver_cached_image_multisample_guardpasses in default,APS5_NO_EPOCH_REVALIDATE=1,APS5_NO_FAST_REVALIDATE=1, andAPS5_WRITE_WATCH_IMPORTS=unwatchmodes.agc_driver_multisample_retirementalso passes after the rebase.I do not have a Windows test host, so the Linux comparison-mode check is not Windows validation. Could you rerun
agc_driver_cached_image_multisample_guardon the updated head, with default settings and withAPS5_NO_FAST_REVALIDATE=1, on the GPUs you reported? Please include the head revision and output, including any message about compared image memory. The default run should now retain the guard assertions without requiring a fast proof for unwatched imports.AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T07:01:56Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One conflict inShaderResources.cpp:mainrefactored the inline texture-placement block into aplace()lambda — the merged version keepsmain'splace()call, which already covers your placement logic; your test changes replay on top.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; the cached-image and image-table tests pass; full suite green apart from the two knownmainregressions (agc_driver_tessellation— Mesa, #5444;agc_driver_bda_device— #7584), neither from this PR.To pick it up:
Head is
ad1bf47f7.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-19T07:10:28Z.
Rerun on Windows as asked:
agc_driver_cached_image_multisample_guardpasses at ad1bf47f7, 3 of 3, and 3 of 3 withAPS5_NO_FAST_REVALIDATE=1. It printsimage memory is compared, not watched: fast image proof not tested; checking the image guards through the full prooffor the compute and draw storage cases, as the new fixture intends. AMD Radeon 860M, WinLibs GCC 15.2.0, Release.One thing to watch in the rebase. ad1bf47f7 still conflicts with current
main(6b8228b2b) inShaderResources.cppanddocs/dev/debt/libSceAgcDriver.md:mainmoved the image-table texture placement into theplace()lambda inresolveImageTables. Keepingmain'splace()call alone drops this PR's, true(theimageTablefield) from that lambda'sdescribedRanges.push_back({"texture", ...}). I tried that resolution: the test fails 3 of 3, atchecking draw sampled image reuse, witha cached image access of 0x200000000+0x10000 overlaps multisampled color target ... guest access to it is not implemented., trueadded insideplace(), it passes as above.mainand this PR both edit the lines around "Multisampled target guest access". I keptmain's lines and appended this PR's new sentence ("Ordinary sampled and storage bindings check the color-target guard …").AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by alex73630 on 2026-10-19T09:45:07Z.
Rebased onto main
64e2a810a; new head is56d183dc946700720fa8eb71b36d56ebd6d27ab7.Resolved the image-table conflict by retaining upstream's shared
placehelper and replay path, and marking table ranges inside that helper. This preserves the native-MSAA exemption for both newly bound and replayed sampled table entries. Retained upstream's updated MSAA documentation alongside this PR's guard/reuse limitation. The compared-import fixture correction is unchanged.Validation on Arch Linux, kernel 7.2.11-zen1-1-zen, NVIDIA RTX 3070, driver 615.78.08:
ANYPS5_REQUIRE_VULKAN=1andAPS5_BARRIER_VALIDATE=1.APS5_NO_EPOCH_REVALIDATE=1,APS5_NO_FAST_REVALIDATE=1, andAPS5_WRITE_WATCH_IMPORTS=unwatch.APS5_NO_TABLE_REPLAY=1.git diff --checkandpython3 tools/check_conventions.py --base origin/mainpassed.Windows was not tested locally. A Windows rerun of the updated head is still needed; the Linux compared-import run does not substitute for that validation.
AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-19T09:49:42Z.
Windows rerun of
56d183dc9, merged intomain64e2a810a(clean merge). AMD Radeon 860M, WinLibs GCC 15.2.0, Release:agc_driver_cached_image_multisample_guardpasses 3 of 3. It also passes once each withAPS5_NO_FAST_REVALIDATE=1,APS5_NO_EPOCH_REVALIDATE=1andAPS5_NO_TABLE_REPLAY=1.agc_driver_image_table*tests pass withAPS5_NO_TABLE_REPLAY=1.agc_driver_graphics, the image-table tests (includingvouched_lookupsandvouch_queued_draws), and themultisample*tests (includingretirement,readback*andpass_order).The
place()helper now marks its ranges withtrue, so the case that failed 3 of 3 with the bare resolution is covered.AI-assisted: yes (Claude Code)