fix(agc): store a multi-mip DCC image whole only while another live image overlaps it #8707
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8707"
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 LeoFeitosa on 2026-10-20T21:37:34Z.
What
A storage image with DCC metadata and more than one mip now stores every pending 64 KiB block unit at each write-back while another live storage image overlaps its memory, as an image under a clear code already does, instead of only the units the access touches. Without an overlapping image it keeps
main's selection: applied to every multi-mip DCC image, the first head stopped PPSA10112 presenting after 30 to 60 s (see the comments). The rule is one private method,StorageTexture::storesWhole(), used by the seven places that computed it:writeBack,pendingUnitInside(the flush pretest),evictStale,skippedResultsInside,clearHandOver(#7427),noteLayersBehindandPrepareCreation. The others carry the comment "writeBack's selection for the access", so they follow the same selection.This is the RoboCop menu fix in the block path, replacing #7579, which tracked these images as one unit and was reverted in #8265 because it stopped SILENT HILL: The Short Message (PPSA10112).
In RoboCop: Rogue City - Unfinished Business (PPSA28329) the main menu background is a 1920x1080, six-mip DCC storage image with uncompressed keys whose memory other surfaces of the frame also use. Stored unit by unit, a local trace shows its last 59 units stored only by a late access each frame, and the menu shows bokeh lights and stale purple tiles instead of the RoboCop artwork. Which reader takes those bytes before they are stored is not identified; the debt entry says so.
New test
agc_storage_dcc_mip_writeback(agc_driver_recorder_tests --dcc-mip-writeback-only): a 512x512, three-mipR_Ximage, cleared and pending, flushed through an access to its first 64 KiB. With DCC keys uncompressed and a live one-mip image over the same memory every texel of every mip must reach memory; with DCC keys uncompressed alone, and without DCC, only the accessed unit's texels must. Each case flushes the rest before it ends.Tested
Windows 11 (build 26200), NVIDIA GeForce RTX 5070 Ti, driver 617.42, WinLibs GCC 15.2.0 r7, Release. #8310 applied locally (not part of this PR) so the test targets build with WinLibs.
anyps5.logof each run kept:main559f35d685wrong 3 of 3, this change on559f35d685right 3 of 3, no fatal error in any run. The same onbcf29de5dbefore the rebase. One local build with only thewriteBackrule behind a switch: wrong with it off, right with it on (one run each).ctest -R "agc|storage|texture|tiling|dcc" -j8onmain559f35d685and on this change on it: 859/860 and 859/861 passed. The failures areagc_shader_disk_cache_large_fileon both ("cannot remove the large file test directory", a Windows file lock) andagc_driver_lookup_log_fits_buildon this change; both pass when run again alone on both builds.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -R 'agc_storage|agc_tiled|repack|dcc|^agc_driver_graphics$|pending_after_unwatch|texture_format|clear_keys|hand' -V -j1, LunarG layer 1.4.363:main31/31, this change 32/32 (the 31 plus the new test), 0VUID-in both logs, no "was not found but was requested by env var VK_INSTANCE_LAYERS" line.VUID-).writeBackrule only) againstmaine9a5a0c84, 3 runs each: theoutside the write watch without the guest bytes savedstop did not come back (0 of 3) (report). This version also changes the three other selections; a run of it there would be welcome.python tools/check_conventions.py --base origin/main: passes.Known risk: storing every pending unit at once widens the span
writeBackLayerschecks withChangedBlocks. A span that reaches a block outside the write watch makes every stored unit need its saved bytes, which is the refusal #8265 removed. #7048 and #7604 (APS5_TRACE_WATCH=unsaved) are the ways to look at it if it shows up.Overlap: #6202 and #6718 add new copies of the old
dccAddress != 0 && uploadedKeys != DccKeys::Uncompressedtest; whichever lands after this one would readstoresWhole()instead.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 janzezno on 2026-10-20T23:04:28Z.
Run on AMD hardware.
Host: Arch Linux, kernel 7.2.11, AMD Radeon RX 7900 GRE (RADV NAVI31), Mesa 26.2.5, GCC 16.2.1, Release,
BUILD_TESTING=ON.maine25333e39; PR heade614e9cc95merged on top (clean merge).ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'compare|denorm|f32|f16|f64|agc_shader_memory|agc_shader_disk_cache|request_serializer|dcc|storage|pm4|indirect' -Vmain: 137 of 137 pass. PR: 138 of 138 pass, including the newagc_storage_dcc_mip_writeback.VUID-set and counts on both; none is new. The validation layer loaded in both runs.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T05:54:42Z.
@LeoFeitosa thanks, the single
storesWhole()rule across the five selections reads well, and the old-rule failure of the new test is clear. Two small things before this can go further:docs/dev/debt/libSceAgcDriver.mdnames a title ID. Debt docs describe the mechanism without naming titles; could you describe the surface only (for example "a 1920x1080 six-mip DCC storage image of a menu background")? The title can stay in the PR description.Texture.cpp,storesWhole()landed between the comment that starts "Whether a pending unit of the image lies inside the range" andpendingUnitInside(), so that comment now sits abovestoresWhole(). Could you movestoresWhole()above that comment?Also a heads-up: #6202, #6718 and #6820 each add a new
other->descriptor.dccAddress != 0 && other->uploadedKeys != DccKeys::Uncompressedcheck innoteLayersBehind. They merge cleanly with this PR, so whichever lands second needs to switch that line toother->storesWhole().Imported from boykopovar/AnyPS5. Originally posted by LeoFeitosa on 2026-10-21T06:00:31Z.
@oneandonlydean thanks, both done in 0b5b1969d:
storesWhole()now sits above the "Whether a pending unit of the image lies inside the range" comment, so that comment is back overpendingUnitInside().Neither change touches behaviour (a moved definition and a docs line);
tools/check_conventions.pypasses. Noted on #6202, #6718 and #6820: whichever of them lands after this one should switch itsnoteLayersBehindcheck toother->storesWhole(), as the overlap note in the description says.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T06:08:32Z.
@LeoFeitosa thanks, both look right. A delta review of
0b5b1969dis next, then full CI.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T14:16:49Z.
Review: APPROVED
@LeoFeitosa thanks. Putting the rule in one
storesWhole()(core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:4498) makes the five selections agree by construction. In the tree merged with currentmainthere's no copy of the olddccAddress != 0 && uploadedKeys != DccKeys::Uncompressedtest left, including thenoteLayersBehindcopy that #6718 brought in.Lock order, since
storesWhole()now takesLive().mutex:overlappingPendingholdspending.mutex(Texture.cpp:5386) when it callspendingUnitInside()(:5390), which now callsstoresWhole(). That nests the live-image lock inside the pending one.pending.mutexis a plainAgcDriver::Mutex(Texture.cpp:141), andLive().mutexis aMapImportGate::LeafMutex(Texture.cpp:232, defined inGraphics/include/MapImportGate.hpp:19). The leaf is the one taken last here, which is how a leaf mutex is meant to be used. While held, it only runsoverlapsLive, which takes no lock. I found no path that holds the live lock and then takes the pending one. A small non-blocking cost: for a multi-mip DCC image with uncompressed keys, each selection now scans every live image under that lock.What I ran: head
ff8b1a9219merged ontomainb11c7bf84f, Windows 11, WinLibs GCC, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, using your regexagc_storage|agc_tiled|repack|dcc|^agc_driver_graphics$|pending_after_unwatch|texture_format|clear_keys|hand:agc_driver_msaa_dcc_compared_import_*cases skip on this machine, the same on both arms;Texture.cppandTexture.hpptaken frommainwith the new test kept: onlyagc_storage_dcc_mip_writebackfails, with "the write-back stored 16384 of 344064 texels", as you reported;ctest -V, the same set onmainand on the merge): noVUID-and noSYNC-HAZARDIDs on either side, and nowas not found but was requested by env var VK_INSTANCE_LAYERSline;tools/check_conventions.py --base upstream/mainon the head: all checks passed;tools/pr_overlap.py --branch: no open PR shares lines. Of the 46 PRs it couldn't compare, plus the three you name, only #6202 (closed) and #6718 (merged) carry the old condition.These are AMD results for this head, next to the earlier-head AMD run in your description. I didn't run SILENT HILL or RoboCop, so the PPSA10112 check of this version that you ask for is still open. Approving.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T15:46:51Z.
Review: APPROVED
@LeoFeitosa re-checked at
02a5bfcceb. Againstff8b1a9219, the head I approved, the only change to your commit is the debt entry, back indocs/dev/debt/libSceAgcDriver.md; the rest is a merge ofmain.On
02a5bfccebmerged ontomain78e4248fea(Windows 11, WinLibs GCC 15.2.0, Release, AMD Radeon RX 9070 XT, driver 32.0.32015.12012),ctest -VwithANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationand your regexagc_storage|agc_tiled|repack|dcc|^agc_driver_graphics$|pending_after_unwatch|texture_format|clear_keys|hand:agc_driver_msaa_dcc_compared_import_*skip ("Linux comparison mode only");main'sTexture.cppandTexture.hpp, onlyagc_storage_dcc_mip_writebackfails ("the write-back stored 16384 of 344064 texels"), as before;VUID-orSYNC-HAZARDmessage on either side.check_conventions.pypasses.pr_overlap.py --branchfinds no shared exports; #6926 shares lines indocs/dev/debt/libSceAgcDriver.md, and 72 PRs that conflict withmaincouldn't be compared.Approving again at
02a5bfcceb.AI-assisted: yes (Claude Code)