fix(agc): order DCC clear fills against GPU writes in resident presentation #13879
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13879"
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 sktharunbalaji13-cmd on 2026-10-31T10:53:28Z.
What
This change orders DCC clear fills against GPU writes in resident presentation and refresh:
esident != nullptr) prior to presentation in \PresentDisplayBuffer, ensuring guest CPU memory written after writeback is merged while keeping \unsuitable\ and
otPending\ counters semantically accurate.
Tested
Checklist
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T10:55:35Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new
FindLivefallback can present stale pixels after a CPU write, and the PR body currently fails the repository's required template check.What I ran
Reviewed head
6ad4d175b94664acf2aab0764f39e32e4f57433fagainst PR base602c0e417ca11f53de54ffe7b3253e95cb93c0d4; the merge preview was clean against that base. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or tests were run.Results
### What,### Tested, and### Checklistheadings.602c0e417ca11f53de54ffe7b3253e95cb93c0d4.agc_display_buffer_dccandagc_driver_dcc_keys_first_writepassed; I did not independently run them.Unedited convention-check output
Findings
Blocking
Refresh the
FindLivefallback before presenting it.PresentableResidentsetspendingfromFindPendingSlicebefore falling back toFindLive, so a fallback resident is returned withpending == false. The primary presentation path callsRefreshPresentedonly whenpendingis true, then still passes the non-null resident topresent(). If guest CPU memory changed after the texture's last writeback/refresh, this path can display the stale resident image instead of merging those newer bytes. Refresh any selected resident before presenting it, including theFindLivefallback; keep the pending-only counters semantically accurate. Add a regression case that performs a CPU write after writeback and verifies the presented resident reflects it.Restore and complete the required PR template. The current body omits the required headings and checklist, and the repository convention check fails as a result. Restore the full template and fill its required fields and boxes.
Non-blocking
None identified beyond the unverified hosted checks noted below.
Sources
Not verified
I did not build or run CTests, verify the reported GPU/game captures, or test other GPUs and platforms. Hosted checks were pending in the latest snapshot.
To get this to a good state
Refresh the
FindLiveresident before presentation and add the CPU-write-after-writeback regression case; restore and complete the PR template. I will rerun the same checks on the updated head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T11:40:58Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The live-resident refresh fix is now present, but the DCC clear-drop decision still uses a texture-wide write counter for per-layer refreshes.
What I ran
Reviewed head
63ad794c49dcfe6e8db2f0893317427072ce74f9against PR base602c0e417ca11f53de54ffe7b3253e95cb93c0d4; the merge preview was clean against currentmaincbed91529193c47194bef11811906c7cb6054af1. Environment: Linux x86_64, Python 3.11.2. No local build or C++ test was run.Results
mainDisplayBufferDcc.cppis listed in the AGC driver CMake fileUnedited local check output
Findings
Blocking
HasWritesSinceFill()is one counter for the wholeStorageTexture, butdroppable(unit)uses it to decide whether to drop each pending unit. After a clear fill, a GPU write to one layer or part of the image makesHasWritesSinceFill()true for every unit. The code then keeps pending results for untouched units too; a pre-fill result in an untouched layer can therefore survive a clear that should invalidate it. The new tests callResidentServesDisplaydirectly and do not exerciseStorageTexture::refresh, partial writes, or multiple layers. Please scope post-fill writes to the same units/layers used by the drop decision, or otherwise preserve the clear for untouched regions, and add a regression covering a partial write with untouched clear regions (including an untouched array layer where supported).The
FindLiveCPU-freshness path is now refreshed before presentation, but the added test does not exercise the reported CPU-write-after-writeback sequence. Please add a regression that changes guest pixels after writeback and verifies the presented resident contains those pixels.Non-blocking
The two new
Expectfailure messages describe the opposite outcome from their assertions: the first expectsResidentServesDisplayto be true but says it does not serve; the second expects false but says it serves. Please correct the messages so a failure identifies the actual expected behavior.Sources
Not verified
I did not build or run CTests, reproduce the partial-clear scenario, or independently run the GPU/title test. The Windows test and title results in the PR description are author-reported; current Windows CI was still queued.
To get this to a good state
Make clear invalidation granular enough to preserve only post-fill writes, add the partial-write/untouched-region and CPU-write-after-writeback regressions, and correct the two failure messages. I will rerun the same checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:33:08Z.
Review: APPROVED
Re-checked — new head, looks good
The exact head
0bdf054b93a864a7cca17ee6fe1d61d458c46b83addresses the previously identified per-layer clear tracking and stale-resident refresh gaps, with regressions for both cases.What I ran
Reviewed the updated head against PR base
602c0e417ca11f53de54ffe7b3253e95cb93c0d4and inspected the update from prior reviewed head63ad794c49dcfe6e8db2f0893317427072ce74f9. The merge preview against currentmain60bdb061356db736928eee431cd8bd4c9ba68036was clean. Environment: Linux x86_64, Python 3.11.2.Results
mainUnedited precheck output
Sources
Not verified
I did not build or run CTests or independently reproduce the GPU/title run. Hosted Windows remained queued at the final status refresh; Linux and specialized jobs were skipped.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T14:04:27Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The new BDA writeback path skips non-sparse writable heap mirrors larger than 256 MiB, so BDA stores into those guest ranges do not reach guest memory.
What I ran
Reviewed head
1ce469442aea3e0a5e865e0f5b3b841826c0bbceagainst PR base602c0e417ca11f53de54ffe7b3253e95cb93c0d4; the live merge preview against currentmain73f4f7e06e4f210a8c6570e335fd654dc0a86134was clean. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5. I inspected the changed write-span and writeback paths; I did not build or run C++ tests.Results
Unedited check output
git diff --checkexited successfully with no output.Findings
Blocking
In
addAddressStoreSpans, the loop overspace->baseskips every non-sparse mirrored region whose served range exceeds 256 MiB. The skipped region is still a writable heap mirror and can be exposed to a shader's BDA table;addressStoresis enabled for writable address-based bindings. For a shader that writes through BDA without an overlapping explicit writable V# span, this range is not added towrites;takeHeapReferencestherefore does not snapshot it andWriteBackdoes not copy shader changes from the mirror to guest memory. A valid BDA store can be silently lost solely because its containing writable heap is larger than the threshold. Please preserve writeback for those writable ranges, or explicitly refuse/fall back for such a binding before dispatch rather than silently accepting stores that will be dropped.Non-blocking
None.
Sources
Not verified
To get this to a good state
Ensure stores to every accepted writable BDA heap range reach guest memory, and add a focused regression at or above the size boundary (or test an explicit pre-dispatch refusal). I will rerun the same checks on the updated head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T18:09:26Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The new failure path can skip a heap mirror's write-back reference and then silently discard that GPU write during
WriteBack.What I ran
Reviewed head
95ce8090aab7bdcead80c4e70764c2d215a7063eagainst PR base602c0e417ca11f53de54ffe7b3253e95cb93c0d4; the merge preview against livemainca073ec3ad0d766ea9f4658e418a5c977001a353was clean. Environment: Debian Linux 6.1, Python 3.11.2, GCC 12.2.0; no build or CTest run.Results
mainca073ec3ad0d766ea9f4658e418a5c977001a353.growResidentfails while taking a heap reference snapshot. The added C++ regression suites were inspected, not run.82ba74b, so it does not validate this head.Raw outputs
git diff --checkproduced no output:Conventions output:
Precheck helper errors:
Stack report:
Hosted checks:
Negative control
growResidentcannot provide the bytes for a writable heap mirror, the GPU write must not be silently reported as committed.Findings
Blocking
takeHeapReferences()now catchesstd::runtime_errorfromgrowResident()and continues without adding aheapReferencesentry for that write span.WriteBack()then continues again when the reference is absent or has the wrong length. SincegrowResident()throws when the mirror cannot be grown withinheapMirrorBudget()(or its resident bind fails), an allocation/budget failure can therefore let the operation proceed while silently dropping the corresponding GPU result instead of writing it to guest memory or failing the operation. Please make this path fail safely or use a valid fallback that preserves the write; add a regression that forces the growth/bind failure and verifies the guest-visible result is not silently lost.Non-blocking
None.
Sources
growResidentthrows when budget or resident binding cannot be satisfied at this PR headNot verified
No build, CTest, Linux runtime, GPU, or console run was performed. The latest reported NVIDIA pass covers the older
82ba74bhead, not95ce809. Windows CI was still running; Linux and specialized jobs were skipped.To get this to a good state
Preserve or explicitly fail the GPU write when heap-reference growth fails, and add a regression that exercises that failure path. I will rerun the same no-build checks on the new head.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-01T05:08:14Z.
Review: CHANGES_REQUESTED
Thanks for the work on the DCC clear ordering; the first two commits (
63ad794c49,0bdf054b93) match the title and look right. What blocks the PR:1ce469442a,a3c5f14155,338ba7d05f,59f44917c1,229d36bf03,d53b956f53,02f9dc2f77; the same changes as #12840 and #10304), native depth-stencil resolve / MSAA stencil sampling / HTILE relaxations (69ae34b730,8a9d858251,547a4d1760,93f70269fd,2f6fd3e765,82ba74badd,587f4a5e47,f6c6ce89db,95ce8090aa), triple buffering by default (352710034b) and the compute pipeline cache key (b22714c17a). Please drop them and open each as its own PR; if the DCC change needs #12840 / #10304, list them under Depends on (as @EagleBearerYS asked).growResidentfails while taking a heap reference snapshot, the mirror's write-back reference is skipped and the GPU write is discarded inWriteBack. This goes away with the BDA commits, but if it stays in some PR it needs a fix and a test.tools/trace_digest.pysummaries ofmainand the change from the same machine and scene, in its own PR.main; please rebase after splitting.Welcome back once the PR contains only the DCC clear ordering.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-01T07:05:31Z.
Review: CHANGES_REQUESTED
The merge queue's Linux run for this head (run 41282047209) fails two tests that pass on main:
agc_driver_recorderandagc_storage_write_back(same binary,storageRefreshTests). Last line before the failure:AGC graphics: results dead under new clear keys were stored(tests/Recorder.cpp:5994).Texture.cpp:2448:droppablenow drops a clear only when!HasWritesSinceFill(unit). In that test the keys change by a CPU store into the DCC key memory, with noNoteKeysFill, solayerWrittenSinceFillis still true from the earlier draw. The draw's result is dead under the new clear keys but is now stored, which the test pins (new 0001 clear keysmust leave guest memory unchanged). "Written since the fill" only means "written after these keys" when the keys came from a fill; keys changed by the CPU need a reset point too (or the check must compare against the keys' own change).Texture.cpp:2485:droppableis no longer behindblockUnits, so thekeysChanged && IsDccClear(keys)drop now also applies to textures without block units. If that is intended, say why and add a test; otherwise keep theblockUnitscondition around the clear-drop as before.Please run
agc_driver_recorderandagc_storage_write_backon your side (they needANYPS5_REQUIRE_VULKAN=1) and keep the new ordering tests alongside this existing one.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:09:19Z.
Review: COMMENTED
Re-checked — new head, tests needed for the clear-key reset
The call-site guard is back at
90f0b5fd3b, which answers the non-block question from my earlier comment, but the new clear-key reset also changes the presentation check at this head, and no test or build result covers that yet.What I ran
90f0b5fd3b22d57a8d42a8bd133005003e93dcf4, the PR's current head. Its parent ise250a91f48127e1a69099a38491702c006ba0ccf; the new commit is90f0b5fd3b.bafc1a1346is no longer in the PR's history, so this review compares againste250a91f48(the PR-level delta) and against currentmain.main26fa1212b82f76dd49cf12d65e445d6ff3e0844c. The live stack check reports the PR as mergeable; the merge state isBLOCKED(checks pending), not conflicting.The precheck's ABI and test-quality helpers failed because the head tree has no
tools/directory, so both were run by hand as listed above.Results
BLOCKED, checks pendingAPS5_VABIdeclaration changedpossible-unregistered-cpp-testfindings, both false positives:DisplayBufferDcc.cppis registered intests/cmake/agc_display_buffer_dcc_tests.cmakeline 1, andDccKeysFirstWrite.cppis picked up by thefile(GLOB ... tests/execution/*.cpp)inCMakeLists.txtline 551. The test files are unchanged sincee250a91f4890f0b5fd3bABI audit, unedited output (manual)
Test-quality heuristic, unedited output (manual)
Findings
Blocking: none substantiated by source reading. The request is not for changes; approval is withheld until the evidence below exists at this head.
Non-blocking / needed before approval:
Texture.cppline 2491 isif (blockUnits && droppable(layer)), the same guard asmainline 2483. A non-block texture no longer reachesdroppable, which answers the question in my earlier comment.Texture.cpplines 2331-2334 resetswritesAtFillandlayerWrittenSinceFillfor a CPU-established clear-code change.StorageTexture::HasWritesSinceFill()is read byResidentServesDisplay(VulkanDevice.cppline 3413). InDisplayBuffer.cppline 301, when the display's keys equal the filled clear keys and there are no writes since fill, the resident image is not used (return false). After a CPU clear-key change, that check can now returnfalsewhere it previously went on toKeysServeSurface. The author's reply and the commit describe only the drop rule.20675e51bd, not this head. Hosted CI for this head has not reported.Asks before approval:
90f0b5fd3bforagc_driver_recorder,agc_storage_write_back,agc_display_buffer_dcc, andagc_driver_dcc_keys_first_write, from the Linux merge queue and the Windows path, with the head SHA in each result.ResidentServesDisplay) returns the expected source. If an existing test already covers either part, name it.Sources
Permalinks at head
90f0b5fd3b22d57a8d42a8bd133005003e93dcf4:github.com/boykopovar/AnyPS5@90f0b5fd3b/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp (L2331-L2334)github.com/boykopovar/AnyPS5@90f0b5fd3b/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp (L2491)ResidentServesDisplayearly return:github.com/boykopovar/AnyPS5@90f0b5fd3b/core/libs/prx/libSceAgcDriver/Execution/src/DisplayBuffer.cpp (L294-L301)HasWritesSinceFill():github.com/boykopovar/AnyPS5@90f0b5fd3b/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp (L3412-L3413)Current main call site:
github.com/boykopovar/AnyPS5@26fa1212b8/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp (L2483)Not verified
90f0b5fd3b. No test in the PR is shown to reach the new reset branch; I did not establish whether an existing test does.no watched host import) that skips the watched refresh branch on that host.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:42:15Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Your reply resolves my concern about the non-block texture guard, but it does not verify the new clear-key marker reset that changes whether pending resident data serves the display.
What I ran
Rechecked open PR #13879 at head
90f0b5fd3b22d57a8d42a8bd133005003e93dcf4against base26fa1212b82f76dd49cf12d65e445d6ff3e0844c, including the new commit's diff againste250a91f48127e1a69099a38491702c006ba0ccf, the display call path, and the existing focused tests. I queried current hosted CI. Environment: Debian GNU/Linux 12; no compiler, build, or test was run in this follow-up.Results
90f0b5fd3bchangesTexture.hppandTexture.cpp; it adds no test changes.droppablecase precedes the!blockUnitsguard, and the caller invokes it only whenblockUnitsis true. This resolves that part of my earlier concern.ResidentServesDisplayOrderTeststests the helper withhasWritesSinceFillpassed asfalse, but does not exercise the newrefresh()reset or prove that the display path selects the expected source after a CPU clear-key change.Negative control
Findings
Blocking
The latest commit resets
writesAtFillandlayerWrittenSinceFillwhen a refresh observes a CPU change to clear-code keys.HasWritesSinceFill()feedsResidentServesDisplay(), whose clear-key path rejects the resident when that value is false. The existing helper test only suppliesfalsedirectly; it does not test the new state transition or its display consequence. The explanation about non-block textures establishes that their ordering matchesmain, but it does not validate this separate reset behavior.Please add or identify an exact-head regression test for a pending resident followed by a CPU clear-key change without a GPU key fill, and assert the intended pending-result and display-source behavior. If the expected behavior is different, document that rationale and test the chosen behavior. I will rerun the same focused checks on the updated head.
Non-blocking
The current hosted checks pass, but no product test is listed for this head. The author-reported CTest results in earlier discussion were for the preceding head, not
90f0b5fd3b.Sources
HasWritesSinceFillstate accessorNot verified
No build, CTest, Linux GPU run, Windows product run, or console behavior was verified at head
90f0b5fd3bin this follow-up.To get this to a good state
Add or identify the focused regression described above and post exact-head test results. I will re-run the same source and test checks on the resulting head.