fix(agc): claim a multisampled color target that a single-sample storage image store overlaps #13248
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13248"
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 hugodearaujo on 2026-10-30T07:48:07Z.
What
#8223 retires a multisampled color target that the title reused: a CPU write over it, or a depth, stencil, HTILE or color target bound over its memory, claims it, and the next guarded access retires it. A title can also reuse that memory through a dispatch, by storing to a single-sample storage image that overlaps it. That store gets none of #8223's evidence, so the cached image check in
Revalidate(or the storage image lookup of a fresh build) still throws "overlaps multisampled color target … whose samples are only on the host".This PR counts that store as a claim, like the binds in #8223:
resolveImageBinding: a storage image element that the binding records as stored (imageWritten[element]) claims, before its own guard, every target whose guarded ranges overlap the bytes of the level it stores to (WrittenStorageBytes, the same whole-block ranges main uses to retire covered depth surfaces). The element's descriptor words and level are kept in itsDescribedRange.revalidateFull: a kept stored element claims the same way before itsa cached image accessguard, so a resource set built before the target existed passes too. Ranges keep the build's binding order, so a read that comes before the store in the same set is still refused.MultisampleTarget.cpp:MultisampleColorTargetOverlaps(a cheap check before the level's bytes are described) andClaimMultisampleTargetStore, which sets #8223'sclaimedflag on the overlapped non-FMASK ranges and logs the first 8 claims.Still refused: an element the binding does not record as stored (an empty
imageWritten, which main treats as written for store-back), an element that only reads, any other access to the memory, and a one-fragment target's FMASK guard (never claimed, as in #8223). Unlike #10049, the store does not have to cover the whole target, and a store whose shader also loads the image counts too, as a color target bound with blending does in #8223. A new debt entry, "Multisampled color targets under single-sample storage stores", says what is not exact: a target still sampled after such a store loses its samples, and where the store leaves the target's memory unwritten, guest memory keeps the bytes it held before the target instead of its samples.Why: Assassin's Creed Mirage (PPSA13960 01.007.000). With #8223, the title stops at 73-85 s on
As traced in this #8223 comment and the following one: every frame draws a 1x 1920x1080 color target at 0x10dc1d0000 and samples it, then draws the 4x 960x540 target at 0x10dc450000 (guarded for 0x480000 bytes, so its first 0x200000 bytes are the 1x image's last 0x200000), then compute shader 0x1000810a00, a 14-instruction clear with one
image_storeand no image load, writes the whole 1x image, and the next draws render into the 1x target again. The clear covers 0x200000 of the target's 0x480000 bytes, so #10049's full-cover rule does not fire. The resource set was built before the target first appeared, so the refusal comes fromRevalidate.A diagnostic build that logs every color target, guard, claim and retirement over that range shows the patched sequence on each of the 16 frames of that screen: the 4x target is guarded at its draw, the clear's
Revalidateclaims it (claim-by-store 0x10dc450000+0x480000 by 0x10dc450000+0x70000), the same cached image access retires it, and the next frame draws and guards it again.#8223 (
claimed,TargetUse) is merged now; this branch mergedmain42d009f5f3(11cfa16b5e), so its diff againstmainis this change only.Tested
Linux 7.2.11, RADV (Mesa 26.2.6), AMD Radeon RX 9070 XT, Release,
BUILD_TESTING=ON, onmain3b32cc7b61+ #8223d488531766(base 3ce340bf7a), this change on top (6a40548ab2; the same commit was first tested onmain66b8e907e4).main42d009f5f3merged in (11cfa16b5e; the only conflict was the debt file, where this PR's new entry sits next to #6498's). Paired validation onmain42d009f5f3and this head, the same 56 entries with the Khronos layer: 55 of 56 on both with identical per-test results and noVUID-lines (agc_driver_native_multisample_depthfails on both on this machine, as below). Negative control:main42d009f5f3with only this PR'sCachedImageMultisampleGuard.cppfailsagc_driver_cached_image_multisample_guardwitha cached image access of …+0x4000 overlaps multisampled color target …+0x10000 (4 samples).agc_driver_cached_image_multisample_guard, newCheckStoredImage, for compute and draw sets: a 64x64 linear storage image whose last 8 KiB overlap the first 8 KiB of a 4x 64x64 target (64 KiB guarded, different base):Revalidatepasses and the target no longer reports host-only samples, and a read of its unstored half passes. The target is drawn again and guarded again; a fresh build passes and retires it; drawn once more, it is guarded.imageWritten = {false}) and unknown use (imageWritten = {}):Revalidateand a fresh build both throw, and the target stays guarded.Revalidate:a cached image access of …+0x4000 overlaps multisampled color target …+0x10000 (4 samples); no claim in the build:a storage image access of …+0x4000 overlaps multisampled color target …; claiming for elements of unknown use:a fresh storage image that does not store over the guarded memory was accepted; claiming FMASK ranges:a cached storage image that does not store over the guarded memory was accepted.ctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1: 55/56 on both. The one failure on both,agc_driver_native_multisample_depth(the native depth buffer-write fixture was not bound as a host import, afterhost import … failed at vkAllocateMemory (-1000072003)), also fails on plainmainon this machine. Neither log has aVUID-line orwas not found but was requested; both have the same 25Undefined-Value-ShaderOutputNotConsumedwarnings from tests inmain.main3b32cc7b61: stops at 73 s ona storage image access of 0x10dfd20000+0x1fe0000 overlaps multisampled color target 0x10e0720000+0x870000, thena CPU readof the same range in presentation (66b8e907e4: same, 73 s).main+ #8223: stops at 73 s on the cached image access above (66b8e907e4+ #8223: 81 s).main+ #8223 + this PR: the store claims the target each frame ([gpu] a single-sample storage image store to 0x10dc450000+0x70000 claims the memory of multisampled color target 0x10dc450000+0x480000 (4 samples), 8 of 8 reports). In 12 of 14 runs (300 s or 110 s, on both bases) the title gets past the autosave notice where the two builds above stop, shows "Update! New Game+ Available", accepts Cross, and reaches the Menu Narration screen, still there at 300 s (about 15 frames per 10 s from 70 s on). In 2 of 14 runs it stops at 79 s on a different refusal, a follow-up this PR does not touch:[videoout] presentation failed: AGC graphics: a CPU read of 0x10dc1d0000+0x480000 overlaps multisampled color target 0x10dc450000+0x870000 (4 samples). That is a second 4x target (960x540, B10G11R11, 4-byte texels) drawn at the same address right after the last claim, and the read covers exactly the 1x image the clear stored.tools/check_conventions.py --base 3ce340bf7apasses.bf30501d66merged ontomainb8194198cf;agc_driver_cached_image_multisample_guardpasses 3 of 3. With only this PR's test file onmainb8194198cf, it fails atchecking a compute storage image store over part of a 4x targetwitha cached image access of ... overlaps multisampled color target ... (4 samples), whose samples are only on the host.main5546586fb1; the test passes 3 of 3.mainalone, with its own version of the test, passes 3 of 3 too.bf30501d66merged ontomain510d0bf986, Windows 11 Pro, Radeon Vega iGPU (GCN, Ryzen 5 7530U), AMD driver 23.19.24.04, WinLibs GCC 16.2.0, Release, with the validation layer.agc_driver_cached_image_multisample_guardpasses 3 of 3, the log has the store's claim of the 4x target, and noVUID-line.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryShaderResources.hpp/.cpp,CachedImageMultisampleGuard.cpp; it retires a target only when a store covers all of it, this PR claims it on any overlapping store, so the two would need reconciling) and #12745 (ShaderResources.cpp), and #7002, #9700, #10492 and #10497 for the debt file only. Whichever lands first, I'll rebase this PR over it.a cached image access of 0x1238ba0000+0x1560000 overlaps multisampled color target 0x1238d30000+0x2d0000 (4 samples)); its menu renders and the run stops later on #17251. That run was by freneza, with88091bc014onmain4977f64052together with #10049 (comment).agc_driver_cached_image_multisample_guard: fails without the change and passes with it on both); NVIDIA RTX 4070 Ti (615.71.09), Linux, and GeForce GT 1030, Windows 11 VM (the same test: fails without the change on Linux, passes with it on both); AMD Radeon Vega iGPU (GCN, driver 23.19.24.04), Windows 11 (the same test passes with the change).Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T21:05:24Z.
Review: APPROVED
Reviewed — approved
A storage image element that the binding records as stored now claims the multisampled color targets it overlaps, both in a fresh build and in
Revalidate. The change builds, and the changed test passes here and fails againstmain's driver code.What I ran
Head
11cfa16b5e4bd19714b154aa35f460e32eb3a4fa,main9090972b7e91fd266819cbd77a8b058e177b5682, merged with--no-ffin a clean worktree. Machine: Debian 13 VM, GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19), no GPU.Results
git diff --checkcheck_conventions.pylibs(script)agc_driver_division, the denormal-mode tests,unwrap_self,vector_constant_factor_tininess) also fail onmainVUID-lines compared withmainagc_driver_sample_multisample_targetat 8.2 sagc_driver_cached_image_multisample_guardCheckStoredImagecases run (compute and draw × store / read / unknown use / FMASK), and the claim line is printed 4 timesNew cases in the changed test
Negative control
I restored
MultisampleTarget.hpp,ShaderResources.hpp,MultisampleTarget.cppandShaderResources.cppfrommainand kept the PR's test, then rebuilt. The test failed at the first new case:Output
This matches the negative controls JJenkx and jacknieland reported. After I restored the merged files and rebuilt, the test passes again and
git status --porcelainis empty.Findings
Blocking
None.
Non-blocking
Unblocksline has no Game bring-up discussion. CONTRIBUTING asks for the title ID together with its Game bring-up discussion (Unblocks: PPSA01325 #3232). The line names PPSA13960 but no discussion. Please add the discussion number if one exists.core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:5196the claim is made before the element's own lookup and before the later bindings of the same set. If a later binding is refused (for example a read of a different, still-guarded range), the target is alreadyclaimed, and the next guarded access anywhere retires it. This is the same "a bind counts as reuse" trade-off as #8223, and the new debt entry covers the visible effect (a target sampled after the store loses its samples). I mention it so the reconciliation with #10049 that the description already plans can take it into account.On the code itself:
revalidateFull(DecodeTextureResource(*range.storedWords)) matches the build.record->resourcecomes from the sameDecodeTextureResource(words)(ShaderResources.cpp:4972), and the storedmipalready includes the dedupemipOffset.ClaimMultisampleTargetStorechanges only the atomicclaimedflag, under the shared lock. Retirement still happens under the unique lock inRequireNoMultisampleColorTarget.k2DMsaastorage elements leave through the earliercontinueatShaderResources.cpp:5172-5187, so they never claim.Not verified
Revalidate(ShaderResources.cpp:3663-3678) skips both the claim and the guard, as it already did onmain. No test here exercises a target guarded between two epoch-proved reuses.Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T15:35:53Z.
Review: COMMENTED
Ran
01ef7271b7merged onmain302864d48con Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.368),ctest -R '^agc_driver_cached_image_multisample_guard' -V:mainmain+ only this PR'sCachedImageMultisampleGuard.cppmainsince the branch point, so the middle column is the PR's own test onmain's code.was not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has aVUID-. To be sure validation messages reach these logs, the same layer with best practices on printed 28BestPractices-warnings into anagc_driver_recorderlog on each GPU.AI-assisted: yes.