Repository navigation
fix(agc): claim a multisampled color target that a single-sample storage image store overlaps - #13248
Conversation
# Conflicts: # docs/dev/debt/libSceAgcDriver.md
…age image store overlaps
|
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.
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.
|
|
Windows data point to go with the RADV run in the description: AMD Radeon RX 9070 XT (RDNA 4) on AMD's Windows driver 32.0.32015.7029, Windows 11 Pro 22631, MSYS2 UCRT64 GCC 16.1, Release, Tree:
None of these skipped. I did not run the changed tests against AI-assisted: yes (Claude Code) |
|
@bunbeans2-arch thanks for the RDNA 4 run on AMD's Windows driver; good to have the multisample and native-depth tests clean there too. |
✅ NVIDIA GPU test: passedPR head
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validation IDs already present on main (4 IDs in 390 tests)Skipped (40)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
# Conflicts: # docs/dev/debt/libSceAgcDriver.md
|
Windows GPU run of head Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, Radeon RX 6700 XT with AMD proprietary driver 26.10.1 (Vulkan 1.4.315), WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
AI-assisted: yes (Claude Code). |
✅ NVIDIA GPU test: passedPR head
Intermittent validation messages (1, seen once in the parallel run, not reproduced when the test was re-run alone 2 times; not counted against this PR)Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (4, not counted against this PR)Validation IDs already present on main (5 IDs in 484 tests)Skipped (46)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
NVIDIA on Windows, for head GPU: NVIDIA GeForce GTX 1650 (Turing,
Only this test target was built, not the full suite, and no title was run. AI-assisted. |
XairRrR
left a comment
There was a problem hiding this comment.
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 against main's driver code.
What I ran
Head 11cfa16b5e4bd19714b154aa35f460e32eb3a4fa, main 9090972b7e91fd266819cbd77a8b058e177b5682, merged with --no-ff in a clean worktree. Machine: Debian 13 VM, GCC 14.2.0, Release, Ninja, lavapipe (Mesa 26.1.6, LLVM 19), no GPU.
git diff --check 9090972b7e91fd266819cbd77a8b058e177b5682...11cfa16b5e4bd19714b154aa35f460e32eb3a4fa
python3 tools/check_conventions.py --base 9090972b7e91fd266819cbd77a8b058e177b5682
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R "cached_image_multisample_guard|multisample_retirement|multisample_srgb_twin|multisample_fill_host_only|sample_multisample_target|agc_multisample_guest_access"
ctest --test-dir build -V -R cached_image_multisample_guard
# negative control
git show 9090972b7e:<4 production files> > <path>
ninja -C build -j32 -l32 agc_driver_cached_image_multisample_guard_tests
ctest --test-dir build --output-on-failure -R cached_image_multisample_guard
git show 780aab9dc2:<4 production files> > <path>
ninja -C build -j32 -l32 agc_driver_cached_image_multisample_guard_tests
ctest --test-dir build -R cached_image_multisample_guard
git status --porcelain
Results
| Check | Result |
|---|---|
git diff --check |
clean |
check_conventions.py |
All conventions checks passed |
Configure, build, libs (script) |
ok |
| Selected tests (script, 2038 run) | no new failures, no timeouts. The 7 known failures (agc_driver_division, the denormal-mode tests, unwrap_self, vector_constant_factor_tininess) also fail on main |
| Validation layer (script, 757 tests, layer loaded in 756, missing in none) | 0 tests with new VUID- lines compared with main |
| 6 focused multisample tests | 6/6 pass. The longest is agc_driver_sample_multisample_target at 8.2 s |
agc_driver_cached_image_multisample_guard |
passes in 0.21 s. All 8 new CheckStoredImage cases run (compute and draw × store / read / unknown use / FMASK), and the claim line is printed 4 times |
New cases in the changed test
[gpu] a single-sample storage image store to 0x7f1bdde9e000+0x4000 claims the memory of multisampled color target 0x7f1bddea0000+0x10000 (4 samples)
...
checking a compute storage image store over part of a 4x target
checking a compute storage image read over part of a 4x target
checking a compute storage image of unknown use over part of a 4x target
checking a compute storage image store over a one-fragment target's FMASK
checking a draw storage image store over part of a 4x target
checking a draw storage image read over part of a 4x target
checking a draw storage image of unknown use over part of a 4x target
checking a draw storage image store over a one-fragment target's FMASK
cached image multisample guard tests passed
Negative control
I restored MultisampleTarget.hpp, ShaderResources.hpp, MultisampleTarget.cpp and ShaderResources.cpp from main and kept the PR's test, then rebuilt. The test failed at the first new case:
Output
checking a compute storage image store over part of a 4x target
AGC graphics: a cached image access of 0x7fe6c461e000+0x4000 overlaps multisampled color target 0x7fe6c4620000+0x10000 (4 samples), whose samples are only on the host: guest access to it is not implemented
0% tests passed, 1 tests failed out of 1
This matches the negative controls JJenkx and jacknieland reported. After I restored the merged files and rebuilt, the test passes again and git status --porcelain is 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.- A claim survives a build that is refused later. In
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:
- The decode used in
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
- No hardware GPU here: the tests ran only on lavapipe. Other people's comments cover RADV (RX 9070 XT), AMD Windows (RX 9070 XT, RX 6700 XT) and NVIDIA (RTX 2000 Ada Linux, GTX 1650 Windows).
- The Assassin's Creed Mirage (PPSA13960) results: I launched no titles.
- The epoch fast path of
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. - The interaction with #10049 and #12745, which touch the same functions.
|
Windows and NVIDIA Blackwell run, for head
Both failures fail on Not run: the Khronos validation layer is not installed on this machine, so this says nothing about VUIDs. No title was run. AI-assisted: yes. Claude Code ran the builds and tests and drafted this comment; the numbers are from the runs on this machine. |
# Conflicts: # docs/dev/debt/libSceAgcDriver.md
|
Merged current |
✅ NVIDIA GPU test: passedPR head
Failing on main too (4, not counted against this PR)Validation IDs already present on main (9 IDs in 594 tests)Skipped (52)ReproduceAutomated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
✅ AMD GPU test: passedPR head
Unstable on main (1, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (7, not counted against this PR)Validation IDs already present on main (8 IDs in 544 tests)Skipped (58)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
|
Windows AMD RX 7800 XT data point for exact head 01ef727, merged alone into main b611e63 (local merge 2a20b30a94d437c1762df57747fd12af5d643132, clean tree). Windows x64 build 26300.9711, AMD driver 26.10.1 (LLPC), Vulkan 1.4.359, WinLibs GCC 15.2.0 UCRT, Release. agc_driver_cached_image_multisample_guard passed on main and this head; the PR extends that test with the storage-image claim cases. agc_driver_native_multisample_depth also passed on this head (24 cases, none unavailable). Logs selected AMD Radeon RX 7800 XT (1002:747e). I ran ctest --test-dir R:/b-latest -V with ANYPS5_GPU=7800 XT, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The layer loaded from Steam's CEF bundle. It uses older Vulkan headers and reports VUID-VkDeviceCreateInfo-pNext-pNext for unknown extension structs on both main and this head; no additional VUID ID appeared. That limits the validation conclusion. AI-assisted local test; no game or FPS claim. |
|
A GFX8 data point: AMD Radeon RX 570 (RADV POLARIS10), Mesa 26.2.5, SteamOS 3.8.28 (Arch distrobox), GCC 16.2.1, Release. Head
The 1,327 AGC, shader, VideoOut and Vulkan tests, once each:
AI-assisted: yes (Claude Code) |
|
Windows and NVIDIA run on the current head, for
AI-assisted: yes. |
gabichuuuuu
left a comment
There was a problem hiding this comment.
Ran 01ef7271b7 merged on main 302864d on Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Khronos validation layer 1.4.368), ctest -R '^agc_driver_cached_image_multisample_guard' -V:
main |
main + only this PR's CachedImageMultisampleGuard.cpp |
change, 2 runs each | |
|---|---|---|---|
| NVIDIA | passed | failed | passed |
| Intel | passed | failed | passed |
- Without the driver change, the updated test fails on both GPUs with "a cached image access of … overlaps multisampled color target … (4 samples), whose samples are only on the host: guest access to it is not implemented". With the change, the overlapping single-sample store claims the target, and the test passes every time.
- The test file hasn't changed on
mainsince the branch point, so the middle column is the PR's own test onmain's code. - The layer was inserted in the test. No log has
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.
|
Tested on PPSA01317 (01.710.000): Linux (Bazzite 44), RTX 5070, NVIDIA 615.78.08.
On the same stack without this commit, the Licence Centre stops on: It is a 21 MiB storage image over a 4-sample, 2-fragment EQAA target and its FMASK, used every frame (the case described in #17159). With this commit, the Licence Centre loads and its menu renders, and the log has no |
|
This PR merges onto current #6970 (merged 2026-11-08) changed Because of that I could not run its tests on the RTX 3070 Ti (NVIDIA 615.78.08) and the UHD 630 (Mesa 26.2.6), CachyOS. I can rerun them after a rebase. AI-assisted: yes (Claude ran the tests and drafted this comment) |
boykopovar#6970 changed DescriptorBinding::imageWritten from std::vector<bool> to ShaderRecompiler::ElementFlags, so CheckStoredImage takes the flags it assigns there in that type.
|
@Lucke0051 Thanks for catching it. Fixed in Built here (gcc 16.2.1, Release) and ran the depth and storage set with the validation layer on an RX 9070 XT (RADV, Mesa 26.2.6), 61 tests:
I left |
|
@freneza Thanks for running it on PPSA01317. I've added the title to the Unblocks line, noting that your stack also carried #10049. Your resolution keeps #10049's |
|
Thanks,
Failures that
|
|
#12745 added With the validation layer, the same command as before, 62 tests:
|
|
Linux and Windows check of head Linux (Ubuntu 26.04.1, RTX 4070 Ti, NVIDIA 615.71.09, GCC 15.2, Release): this head merged onto
Windows (Windows 11 VM, GeForce GT 1030, WinLibs GCC 15.2 UCRT, Release): AI-assisted: yes (Claude Code) |
|
Windows AMD data point on head Host: Windows 11 Pro 10.0.26300, Ryzen 5 7530U, Radeon Vega 15e7 (GCN), AMD proprietary driver 23.19.24.04, WinLibs GCC 16.2.0, Release.
That adds AMD on Windows to the existing NVIDIA and Intel Windows runs and the RADV run, so the guard is now exercised on all three Windows vendors. AI-assisted. |
|
@milescoviello Thanks, and for the negative control. @Ethan-Hainline Thanks, the first run on AMD's Windows driver. I've added both to Tested. |
|
@gabichuuuuu Thanks for the NVIDIA and Intel runs on Windows, and sorry for the late reply. They match the RADV result: the updated test fails on |
Validation: PR #13248 (queue item 34) — PASSEnvironment
Build
Focused tests (AGC multisample color target vs storage image overlap)
Validation-layer checks (per AGENTS.md)
PR behavior observed
VerdictPASS — build clean, 46/46 focused AGC tests pass identically on base and PR, validation layer active in both, no new VUID-/SYNC-HAZARD IDs introduced. Limitations
|
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 fix(agc): retire a multisampled color target the title wrote over #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 mergedmain42d009f (11cfa16), 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, onmain3b32cc7 + #8223 d488531 (base 3ce340bf7a), this change on top (6a40548; the same commit was first tested onmain66b8e90).main42d009f merged in (11cfa16; the only conflict was the debt file, where this PR's new entry sits next to fix(agc): refuse buffer aliases of native MSAA targets #6498's). Paired validation onmain42d009f and 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:main42d009f with 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.main3b32cc7: 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 (66b8e90: same, 73 s).main+ fix(agc): retire a multisampled color target the title wrote over #8223: stops at 73 s on the cached image access above (66b8e90 + fix(agc): retire a multisampled color target the title wrote over #8223: 81 s).main+ fix(agc): retire a multisampled color target the title wrote over #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 perf(agc): prove cached image tables from a write index behind APS5_TABLE_INDEX #12745 (ShaderResources.cpp), and feat(agc): publish native color for read-only shader buffers #7002, feat(agc): draw EQAA color targets at their coverage sample count #9700, fix(agc): publish native depth before cached buffer recording #10492 and fix(agc): refuse writable buffer feedback with native depth #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 Shader: merged hull factor writes under a lane-index AND fail the control point 0 proof, then a waterfall loop's ballot is refused (PPSA01317) #17251. That run was by freneza, with88091bc014onmain4977f64 together with fix(agc): retire a multisampled color target a write-only storage image overwrites #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).