fix(agc): keep resident DCC targets watched under aligned block imports #8172
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8172"
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 wachi35676 on 2026-10-20T01:17:38Z.
What
Fixes #8103. Since #6457,
agc_driver_msaa_dcc_clear_4has failed on Windows on both NVIDIA and AMD. Two separate problems cause it, and this PR fixes both.1.
ImportWatchedunwatched the whole import (Execution/src/GuestMemory.cpp)#6457 imports adjacent registered ranges as one aligned power-of-two block. In the test, that block is
0x200000000+0x400000, and it contains:ImportWatched(..., staysWatched = true)checked whether the whole run was covered. One unwatched block madebeforefalse, and it then calledunwatchLockedover the whole run, which took the resident target out of the watch.checkDccCurrentthen failed withmultisampled DCC target reuse requires watched guest memory.The fix splits the run into maximal runs of watched 64 KiB blocks. For each run it:
It unwatches only the parts that were not watched or whose walk failed.
!staysWatchedpath is unchanged.2. DCC metadata generations came from a walk of the metadata pages only (
Graphics/src/MultisampleTarget.cpp)With (1) alone, the test got further and failed with
writes to a resident multisampled DCC target or its metadata are not implemented (DCC range 0x2003b0000+0x1000). A diagnostic trace showed why:initialDccClearandabsorbDccFilltook the range's generation fromCollectWritesUncached(range). That walk covered only the 4 KiB, so the other 15 pages still had write-watch bits pending.UnchangedSinceand page-levelStoredOverfailed.The generations are now taken from a walk of the whole 64 KiB blocks around the range (
collectBlocks). If that walk returns 0, they fall back to a walk of the range alone. Every write collected this way was made before the generation, so this can only make the tracking more precise.StoredOver.Why there are two changes. Each one fixes a separate refusal, and the test passes only with both (see Tested). Plan (a) in the bisect comment, changing
importRun, was not used:sameRangealso goes throughimportRunwhen imports are refreshed, so its result can't depend on the watch state. This PR leavesimportRunand #6457's block selection unchanged.Credit. @simonbbby's control in the issue,
SetHostImportWindow(BlockBytes)inDccRefillTests, is what pointed at the multi-range block. Their Linux data (the test passes at9127ea36d,524259954and main, because the Linux fixture's mmap addresses never form the block) confirms that the failure depends on the memory layout.Regression tests. Both are layout-independent, so they do not rely on the Windows arena addresses:
agc_write_tracking, newCheckImportWindowOverUnwatchedBlock(GuestMemory level, no Vulkan, both platforms):staysWatched.agc_driver_msaa_dcc_clear_{2,4,8}, newDccImportWindowTests:writes to a resident multisampled DCC.Remaining case, not fixed here: if the CPU stores to another page of the metadata's 64 KiB block after the generation, and an import window later covers the metadata page, the draw is still refused. The window conservatively counts a resolved page as possibly touched by the CPU, and I left that tracker rule alone.
Overlap:
ImportWatchedto run the unwatch hook.CheckImportWindowOverUnwatchedPartasserts the opposite of this PR: that an import over a partly unwatched range unwatches its watched blocks too.GuestMemory.cpp, but notImportWatched's run handling.Tested
Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, Ninja, on
main525344688. Environment:ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 APS5_NO_PIPELINE_JOURNAL=1.The Khronos validation layer is not installed on this machine, so the
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationrun was not done.Focused tests:
agc_write_trackingtook the watched blocks out of the write watchagc_driver_msaa_dcc_clear_4requires watched guest memoryrequires watched guest memorywrites to a resident multisampled DCCagc_driver_msaa_dcc_clear_2,_8writes to a resident multisampled DCC(the newDccImportWindowTests)agc_driver_msaa_dcc_clear_{2,4,8},agc_driver_msaa_dcc_stateandagc_write_trackingpassed 3 runs of 3 on each GPU.ctest -R "agc|shader|spirv|recomp|guest_memory|import|watch" -j6(837 tests):agc_driver_msaa_dcc_clear_4,agc_driver_pass_input_hazard,agc_pipeline_journal.agc_driver_pass_input_hazardandagc_pipeline_journal, both of which also fail on main when run alone.agc_driver_sgpr_pattern_fill_keys. That is a 10 s polling deadline that times out under load on main too: 2 of 8 parallel batches failed on main, and 0 of 8 with this PR on an idle machine. It passes serially.agc_driver_msaa_dcc_clear_4,agc_driver_draw_cache_reuse{,_verify,_inline},agc_driver_layered_volume_vertex_no_gpl,agc_driver_stencil_replay_no_gpl,agc_pipeline_journal.agc_driver_msaa_dcc_clear_4, plus two others:agc_driver_sgpr_pattern_fill_keys, the same load-dependent timeout as above.agc_trimmed_import, which fails 5 of 5 serially on main on this iGPU too (after an unmap of 1440 KiB ... served from the import that pinned the old ones). It passed on main only in that run's parallel batch.#6457's claims:
importRunand the block choice are not touched. The tests that carry #6457's import counts and costs pass on both GPUs:agc_storage_writeback_blocks,agc_driver_graphics(the BdaResources mocks),agc_driver_storage_write_back_overhangand thehost_importtests.Linux: WSL Ubuntu 24.04, gcc 13.3, built from this branch and from main. Same suite:
agc_driver_sgpr_pattern_fill_keys.[memory] write watch unavailable), soagc_write_trackingis skipped and the DCC tests fail atinitial multisampled DCC contents require watched guest memory, on main and here alike.python tools/check_conventions.py --base origin/mainpasses on Python 3.13 and 3.9.Checklist
main; no other open PR implements the same functions (#6308 and #7505 change the same fallback differently; see Overlap)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file (none added).mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T01:21:27Z.
FYI, I have PR #8169 open for the same #8103 report, with a narrower
importRunguard that avoids selecting an aligned block spanning unwatched ranges. Your PR addresses the same initial watch-loss failure and also covers the later DCC metadata-generation refusal with separate tests. I am linking the two for comparison; I have not copied or changed your branch.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T01:26:09Z.
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/Execution/src/GuestMemory.cppL1576core/libs/prx/libSceAgcDriver/tests/WriteTracking.cppL1329core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL38core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppL1544-1563, L1574-1576core/libs/prx/libSceAgcDriver/tests/WriteTracking.cppL1046, L1329-1330Some 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.
core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/tests/WriteTracking.cppcore/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cppImported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-20T02:25:19Z.
Native Linux with working write watching fills the WSL coverage gap for exact head
58f0e89ca353671960a1f38c31a3765ae93d60f5(parent5253446882472f584358007637dd18d77c48e16a). I rebuilt the fixtures and runtime dependencies, retaining the new tests in all controls.The mixed-watch regression is discriminating on Linux:
agc_write_trackingfails 3/3 fresh processes:an import window over an unwatched block took the watched blocks out of the write watch.GuestMemory.cpp, while leavingMultisampleTarget.cppat the parent, makes it pass 3/3.DCC compatibility passes, with an important negative-control limit:
Usingrecords. These are 42 GPU test processes across the two complete-head batches.After exact restoration, the registered
agc_write_tracking,agc_driver_graphics,agc_driver_msaa_dcc_state,agc_storage_writeback_blocks,agc_host_import_unmap,agc_host_import_retirement,agc_driver_host_import_lifetime, andagc_driver_host_import_mutation_racetests pass 8/8, no skips (3.43 s). These nearby fixture tests are not counted as eight additional GPU executions. The source tree is clean; raw logs are retained.Ubuntu 24.04, kernel 7.0.0-38, Ryzen 9950X, GCC 13.3, Release; RTX 3090/NVIDIA 595.99.02; gfx1036
1002:13c0/Mesa 25.2.8; lavapipe LLVM 20.1.2. DCC runs useANYPS5_REQUIRE_VULKAN=1, shader cache and pipeline journal disabled, and other AnyPS5/Vulkan overrides removed. No Khronos validation layer is installed; no validation-layer, Windows, title-performance, or full-suite claim.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T02:52:00Z.
The Linux result matches our CI on this head:
agc_write_trackingpasses on Linux and Windows in run 39353242551. The controls make it usable: the mixed-watch failure at the parent, gone withGuestMemory.cppalone, is exactly the part Linux can show.Your limit stands, and the PR should be read that way: the metadata-generation change in
MultisampleTarget.cppis supported only by the Windows ablation in the PR, since the Linux 4x runs pass without it. Neither run shows it necessary on Linux.