fix(agc): keep a DCC target's refresh proof while its keys are pending driver stores #10159
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10159"
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 EagleBearerYS on 2026-10-23T11:17:26Z.
What
A color target with DCC whose keys were fast-cleared has its keys decided on the GPU by its first draw, which records an uncompressed key store.
Authorship: the fix is @fable-void's (fable-void/AnyPS5@77e9ac4632), carried unchanged under his authorship as
7fbe9f0b82.ResidentTargetRefresh.cpp) needs fixturesmaindoesn't have, so this PR adds a new one.The commits:
7fbe9f0b82(fable-void): the fix.27fa6746ec: a profile-only counter on the[storage]line behindAPS5_PROFILE_DRAW:refreshes proved N, N of them over pending driver key stores (cumulative). With the profile off it costs one test of astatic const bool.31023e2f7a: the test,agc_storage_pending_key_refresh(tests/Recorder.cpp, besiderefreshProofTestsandpendingKeyStoreTests).kR64KBXtarget with fast-cleared keys gets a first draw that records the uncompressed key store, left pending.d87ce93a0b: the proof also records the id of the recorder that issued its write note, and only that recorder, while active, can confirm it. EveryRecordernumbers its write notes from 1, so before this a proof taken on one recorder could hold on another that had an unsignaled write with the same number over the keys (@oneandonlydean found this in review). The id isRecorder::Id(), taken from a process-wide counter when the recorder is built, so a recorder built at a reused address gets a new one.be127b3be1: those two checks run after the first recorder'sSync, so a failing one reports its message instead of unwinding with the GPU write in flight.Tested
Resident Evil Village (PPSA01556), Windows, RTX 3070 Laptop GPU, clocks not held. Static menu, 5 minutes,
APS5_PROFILE_DRAW=1, on our lane F tree (12aa911767), which carries this fix with fable-void's other shared-code fixes:Each of these would run in full on
main, which drops the proof while the store is pending (this PR's commit alone was not run in the title).The test (
agc_storage_pending_key_refresh), againstmain's code (only the fix's.cpphunks reverted) and against this PR:main's codeAPS5_DRAW_PIPELINE=1: 1 and 15, and every check passes, including the retire check.Linux, CI's configure flags (lavapipe, on a cloud worker):
--repeat until-fail:20: 42 ran 20 times each and passed, and 4 skip on that machine as onmain(agc_driver_msaa_dcc_clear_2,agc_driver_msaa_dcc_clear_8,agc_shadowed_key_stores,agc_storage_clear_hand_over);GitHub's runners (run 39933869671, this head on
mainaef58d4674; the new test andagc_pending_key_stores, plus the 57 more AGC tests mapped from the changed files on Linux, and 70 on Windows):main's implementation, where onlyagc_storage_pending_key_refreshfails ("16 of 16 refreshes … ran in full, not 1"): 52 pass, 1 fails, 6 skip. Green ×10 with this PR: 53 pass, 6 skip, 0 fail. The 6 that skip on both trees areagc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_pipeline_cache_file,agc_shadowed_key_stores,agc_storage_clear_hand_overandagc_unit_shadow.agc_partial_watch_restoration,agc_queued_write_groups,agc_recorder_device_selection) pass on both, ×10 with this PR.Validation layer (Khronos 1.3.275, lavapipe),
mainand this PR over the same 46 tests: the same 87 messages in the same 23 tests (VUID-VkDeviceCreateInfo-pNext-pNext,VkImageViewCreateInfo-usage-02275,VkImageCreateInfo-samples-02258). The new test has none. No newVUID-.Not tested: this commit alone in a title.
40309b2447, a merge ofmaine05ba6feeb(run).mainchanged the lines intests/Recorder.cppnext to where this PR addspendingKeyRefreshTests; the merge keeps both, and nothing else conflicted. Theagc_storage_tests,agc_unchanged_cpu_stampsand the other recorder tests the selection pulls in pass 10 runs in a row. Linux: 67 run, 60 pass, 7 skip (agc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_import_settle_initial_dcc,agc_pipeline_cache_file,agc_shadowed_key_stores,agc_storage_clear_hand_over,agc_unit_shadow), 0 fail;agc_storage_pending_key_refreshpasses, and fails in the before arm. Windows: 83 run, 3 pass, 80 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.a0ee9b5c5f, a merge ofmain7e4f6e0440(run).mainadded a drawn-linear-target part to the texture profile line inTexture.cppnext to this PR's refresh-proof part; the merge keeps both, this PR's part afterevicted staleandmain's after it, with 24 format specifiers for 24 arguments. Nothing else conflicted. Theagc_storage_tests,agc_unchanged_cpu_stampsand the other recorder tests the selection pulls in pass 10 runs in a row. Linux: 77 run, 69 pass, 8 skip (agc_driver_linear_target_direct_write_completion,agc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_import_settle_initial_dcc,agc_pipeline_cache_file,agc_shadowed_key_stores,agc_storage_clear_hand_over,agc_unit_shadow), 0 fail;agc_storage_pending_key_refreshpasses, and fails in the before arm. Windows: 93 run, 3 pass, 90 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 208) and on Windows (171 and 224). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.be127b3be1: d87ce93a0b's recorder check and its test (run 40634626781), against this head with d87ce93a0b'sDccMetadata.hpp,Recorder.hppandDccMetadata.cpphunks reverted (ona0ee9b5c5f):agc_storage_pending_key_refreshfails, with "AGC graphics: the pending key proof held with another recorder active, holding the same write note over the keys" (67 run, 59 pass, 7 skip, 1 fail). With it, the test and the storage and recorder tests the selection pulls in ran 10 times with no failure: 67 run, 60 pass, 7 skip (agc_driver_unit_shadow,agc_driver_unit_shadow_budget,agc_import_settle_initial_dcc,agc_pipeline_cache_file,agc_shadowed_key_stores,agc_storage_clear_hand_over,agc_unit_shadow), 0 fail.agc_storage_pending_key_refreshamong the skips.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.0e12c53ead, a merge ofmain0836dfdf4f(run). #12862 movedlibSceAgcDriver's test registrations intotests/cmake/; the conflict inCMakeLists.txtis resolved withtools/agc_test_split.py resolve, which moves this PR's registration intotests/cmake/agc_driver_recorder_tests.cmake(+6 lines). Nothing else conflicted. Apart from the move, this PR's diff is unchanged, except that oneRecorder.hppline,Id(), drops out of it:mainnow has the same line from #8105. With-DBUILD_TESTING=ON,ctest -Ngives 3076 tests:main's 3075 plusagc_storage_pending_key_refresh, each listed once.agc_pending_key_stores,agc_storage_pending_key_refresh,agc_unchanged_cpu_stampspass 10 runs in a row. Linux: 3 run, 3 pass, 0 skip, 0 fail. Windows: 3 run, 0 pass, 3 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (199 and 308) and on Windows (226 and 330). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.NVIDIA, TechLevelZero's GPU runner (report):
0e12c53eadmerged ontomain0836dfdf4f, NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Linux. Passed: 2,445 passed, 0 new failures (4 fail onmaintoo, and 1 is unstable there), and no new validation IDs againstmainover 925 tests run on the GPU.agc_storage_pending_key_refreshran on the GPU under the validation layer and passed; it isn't inmain's baseline, so its validation wasn't compared.cc62b099acandc64a365d2c, oneandonlydean's merges ofmain3c3b3cda73and88e804b0a7. This PR's diff overmainis unchanged.c64a365d2c(main88e804b0a7): the one conflict wastests/cmake/agc_driver_recorder_tests.cmake, where this PR'sagc_storage_pending_key_refreshregistration sits besidemain'sagc_storage_pending_after_unwatch; both are kept. On GitHub's runners (run, on 4d675060ba, which has the same tree),agc_pending_key_stores,agc_storage_pending_after_unwatch,agc_storage_pending_key_refreshandagc_unchanged_cpu_stampsran 10 times with no failure. Linux: 4 run, 4 pass, 0 skip, 0 fail. Windows: 4 run, 0 pass, 4 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (210 and 310) and on Windows (237 and 331).cc62b099ac(main3c3b3cda73): the one conflict wastests/Recorder.cpp, wheremain's newrepeatedNeighbourStoreTestslands next to this PR's tests; both are kept. On GitHub's runners (run, on f6d0845802, the same merge withmain's function at another place in the file), the same tests withagc_repeated_neighbour_storesran 10 times with no failure. Linux: 5 run, 5 pass, 0 skip, 0 fail. Windows: 5 run, 0 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.fef053fad6and5c9b173556,test(agc): the case skips where a GPU read marks watched imports written. TechLevelZero's AMD bot (report) rancc62b099acmerged ontomaina4eca2aon an AMD Radeon RX 6300 (RADV NAVI24, Mesa 25.2.8).agc_storage_pending_key_refreshfailed, also alone, with "the proof was not taken again over the landed keys". It was the only new failure (2,669 passed, 13 failed, 12 of them onmaintoo, 55 skipped), with no new validation IDs over 1,033 tests on the GPU.5c9b173556narrows fef053fad6's skip:fef053fad6also skipped where the import alone marks watched pages written, the conditionaddressShadowTestsin the same file uses. That skipped the case on TechLevelZero's NVIDIA bot (report,fef053fad6merged ontomain9090972, RTX 2000 Ada, driver 595.99.02), whose probe reads "0 of 4 scratch pages written after a GPU read, 0 after a GPU write, 4 after the import; imported ranges stay watched". The case passed on that GPU at0e12c53ead(above), so5c9b173556drops the import term. Otherwise that run passed: 2,699 passed, 4 failed (none new: 3 fail onmaintoo, 1 is unstable there), 46 skipped, with no new validation IDs over 977 tests on the GPU.fef053fad6, run at5c9b173556).fef053fad6(run):agc_storage_pending_key_refresh,agc_pending_key_stores,agc_unchanged_cpu_stamps,agc_storage_pending_after_unwatchandagc_repeated_neighbour_stores. Linux: 5 run, 5 pass, 0 skip, 0 fail. Windows: 5 run, 0 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.5c9b173556(run), the same 5 tests with their output logged. Linux: 5 run, 5 pass, 0 skip, 0 fail, withagc_storage_pending_key_refreshpassing all 10, each with lavapipe's probe line and "1 full refreshes, 15 proved". Windows: 5 run, 0 pass, 5 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.fef053fad6(report), merged ontomain7feb37e, RX 6300: passed, 2,723 passed, 9 failed (none new: 8 fail onmaintoo, 1 is unstable there), 59 skipped, with no new validation IDs over 935 tests on the GPU.agc_storage_pending_key_refreshskips there, as intended. A GPU read marks 4 of 4 watched pages written on that GPU, so 5c9b173556's narrower skip covers it too.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 MarcZX10 on 2026-10-23T11:24:01Z.
Review: CHANGES_REQUESTED
The implementation and the reported pending-key regression test are promising, but this branch needs a current-main refresh before I can approve it. Its merge base is
aef58d4674, 131 commits behind today’smain; those intervening commits modify the same AGC area, includingDccMetadata.cpp,Texture.cpp,Recorder.cppand the AGC test registrations. The merge preview is clean, but the test evidence in the description is qualified against that older base, so it does not establish behavior with the current recorder/storage changes. Please rebase onto currentmain, resolve any semantic interactions, and rerun the pending-key test and the focused DCC/storage set on both main and the refreshed PR with the validation-layer comparison required for AGC changes. I attempted the focused local build, but configuration is blocked here because the SDL2 submodule has no CMakeLists and this host lacks the XRandR development support required by the project. The manual full-build workflow dispatch was also rejected by GitHub with HTTP 403 (repository admin rights required); I am not counting either as a test run. Exact-headgit diff --checkand the current conventions check pass.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T18:17:48Z.
Review: APPROVED
Re-checked — new head, looks good
The pending-key proof now identifies the recorder that issued its write note, and the new cross-recorder regression test rejects a matching note from another recorder.
What I ran
Reviewed exact PR head
be127b3be14745b51461ebbe33a32c4534791429; the PR base field is7e4f6e0440b3b39206f0a6e21b1d177f6975d930. The no-build stack check previewed this head cleanly against currentmainca073ec3ad0d766ea9f4658e418a5c977001a353. The author’s focused verification run was on merge67785fe378withmain474030e584; currentmainhas 12 later commits, none touching AGC paths. Environment for local checks: Linux x86-64, Python 3.11.2, Git 2.39.5. I did not build or run tests locally.Results
mainVUID-lines; validation layer was inserted and not reported missing.The author’s Linux/Windows repetitions and validation run are evidence from the linked verification workflows, not tests I ran. The verification merge used
main474030e584; the 12 commits since then do not change AGC files, and the current-head merge preview is clean.Findings
Blocking
None found in the re-reviewed changes.
Non-blocking
The PR’s GitHub base SHA still reports
7e4f6e0440b3b39206f0a6e21b1d177f6975d930; the current-main merge preview is clean, and the author supplied focused verification against a merge with474030e584. Linux and specialized jobs for the PR’s own hosted workflow remain skipped.Sources
Not verified
I did not reproduce the author’s focused tests, run a local build, test on a physical console, or run Linux/specialized checks independently.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T14:44:26Z.
Review: APPROVED
Reviewed — approved
The pending-key refresh proof merges cleanly and builds, and its new test passes. The test goes red when the
DccMetadata.cpppart of the fix is reverted, and no new failures or validation IDs show up on lavapipe.What I ran
Head
5c9b17355684a2e5e9a787c5eb60cc98af67606e,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree030b9531e55105c3a0fa84ca8dbccf835afbb0d5. Debian 13 VM, GCC 14.2.0, Release, lavapipe (Mesa 26.1.6, LLVM 19), no GPU.Results
git diff --checkcheck_conventions.pylibs(script)mainVUID-agc_storage_pending_key_refreshgit status --porcelainis emptyagc_storage_pending_key_refresh on the merged tree
Negative control
The test calls
PendingKeyProofHoldsand readsDccKeyProof::pendingNote, so it can't be built againstmain's production files alone. I ran two steps:Texture.cpprestored frommain: the test still passes (1 full refresh, 15 proved). See the non-blocking finding below.DccMetadata.cpprestored frommainas well. The header stays as in the PR. I added two link stubs equivalent tomain's behaviour:PendingKeyProofreturns{}, andPendingKeyProofHoldsreturnsproof.pendingNote == 0. The test fails: This matches the description's red arm. I restored both files from the merged tree and rebuilt; the worktree is clean.Findings
Blocking
None.
Non-blocking
Texture.cpphunks are not pinned by the new test.StorageTexture::ProvedKeysatcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2585takes a pending proof on theWaitForKeyWriterspath.StorageTexture::refreshProvedatcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2620adds thePendingKeyProofHoldscheck.main'sTexture.cpp,agc_storage_pending_key_refreshpasses every check, including "held after its batch retired" and the cross-recorder check. The case therefore goes throughProvedClearKeys(DccMetadata.cpp:732,:751) only.refreshProvedis what keeps a stale pending proof from being reused on the refresh-proof path. A regression there would go unnoticed.WaitForKeyWritersgives the answer (for example, pending fills that leave the keys uncompressed), with a check that the refresh proof is refused once the batch retires or another recorder is active.PendingKeyProofandPendingKeyProofHolds(DccMetadata.cpp:757-781) refuse the proof when the GPU mutex isn't held, when no recorder is active, or when the write is signaled. The recorder-id check fromd87ce93a0bresolves oneandonlydean's cross-recorder concern, and the test covers it. I found no correctness problem.Not verified
5c9b173556) on RADV and NVIDIA is not checked by me. On lavapipe the probe doesn't trigger the skip and the case runs.[storage]output underAPS5_PROFILE_DRAW.