fix(agc): reclaim retired multisample color targets #6215
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6215"
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 Ondra97 on 2026-10-15T04:09:34Z.
What
A fully unmapped multisampled color target loses its guest-read guard, but the global target cache used to retain its Vulkan image until device teardown. In the original reproduction on main
a077a88df5bc4ec26a3049aa721ac37ec8f02305, 32 create/unmap cycles left 32 images allocated. The cache now removes retired owners at the next target, sampled, or storage lookup. Recorded commands and sampled views retain the target for as long as they use it; framebuffer reuse checks live owner identities.This rebase uses main
9121a9e4554e55105d6afddcf39073bb9c5fc259at head65f6549e0f6ab442aff09a15dd3adf21c802b11a. Main now keys multisampled sampled views by four component swizzles and view type and cachesshared_ptr<Texture>values. The returned sampled view aliases its target owner, without a reference cycle. Storage promotion retains the old sampled views and both image allocations until their final use, including an already-promoted target used in a later batch. Ownership pins and allocation accounting use the target's recording device.#6175 has merged, so its carried commit is removed. #6522 is still open; its current patch is carried with Mehran's authorship preserved and remains the declared prerequisite.
Tested
Windows (native host): Windows 11 Pro build 26300; AMD Ryzen 9 7900X, 31.7 GiB RAM; NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742. Release, MinGW-w64 GCC 15.2.0 r7, Ninja,
BUILD_TESTING=ON, SPIRV-Tools OFF. Five AGC execution fixtures were built as real tests; other execution fixtures use the configuration's skip stubs.cmake --build <build> --target all libs --parallel 4.agc_driver_multisample_retirement,agc_driver_multisample_fill_host_only,agc_driver_multisampled_pass_order,agc_driver_pass_input_hazard, andagc_driver_sample_multisample_target: 5/5 PASS once, followed by five repeat runs of each (25/25 PASS); no failures or skips. UsedANYPS5_REQUIRE_VULKAN=1,ANYPS5_GPU=NVIDIA, andANYPS5_NO_SHADER_CACHE=1. Each test's log confirms the NVIDIA device was selected.agc_driver_graphics, including framebuffer owner identity checks: 1/1 PASS.Linux (VirtualBox): NOT RUN for this rebase, as requested. Native Linux build, runtime, and GPU validation: NOT RUN; testing is requested in the PR discussion. Earlier Linux (VirtualBox) results belong to an older head and are not counted here. Retail titles, console timing, and other GPU vendors were not tested. The pass-order fixture asserts recorded barriers; it does not resolve the multisampled image into guest memory. Retirement remains lazy at the next lookup; partial unmaps keep the guard.
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 github-actions[bot] on 2026-10-15T04:17:30Z.
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/Graphics/src/Pipeline.cppL636docs/dev/debt/libSceAgcDriver.mdL56docs/dev/debt/libSceAgcDriver.mdL132-133core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL1817core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL2315core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL254-257, L368-369core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppL1603docs/dev/debt/libSceAgcDriver.mdL132Some 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/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/Pipeline.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Pipeline.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-16T19:34:39Z.
@Ondra97 Updated integration validation: #6973 uses your exact #6215 head
dca54b2d7, preserving authorship, as the ownership prerequisite for initial native color uploads. It also contains actual #6965/#6522 and mainaf0fff762. This is a dependent initializer, with no competing retirement implementation.The dependency adaptation dedc318d9 carries your lifetime handling across main's storage promotion: old unique sampled views remain with their retained owner and both image allocations are accounted for. The earlier adaptation below remains available too.
On composition a0e261006, your original retirement fixture passes three fresh processes each on Windows/NVIDIA RTX 5080, Windows/AMD Radeon Graphics and Linux/llvmpipe. Each reports
created=32 destroyed=31 live=1after 32 idle remaps. Sampling/storage and original two-device fill fixtures also pass three times per device. #6973 records the full 93-process selected matrix, exact drivers, omissions, builds and matched initializer control. Main's subsequent audio/time-zone refresh leaves the entire AGC/shader trees unchanged; the final head is 714ad0f04.This verifies the adapted composition. It is not a retest of your unchanged submitted head, a new validation-layer run or a title replay. AI-assisted: Codex; author responsible.
Earlier composition and validation at its original pins
@Ondra97 I composed your exact head dca54b2d7 with main
f474fb776(which includes #5881's MSAA storage-image writes), resolving the native-target source conflict here: merge d8e94fe4a. The complete composition with exact #6601 is 0c4a26b6.The resolution retains DCC initialization through the new allocator, keeps both storage-write barriers and owner retention, retains the old unique sampled textures alongside retired image allocations during storage migration, and includes both allocations in the recorder's retained-byte accounting. The sampled texture pointers stay valid while their shared owner survives.
The original sampling/storage execution fixture builds and passes once per verified RTX 5080 and Radeon Graphics on that composition. With my additional read-only sample getter/test, 2f5307248, the existing fixture and new readback fixture each pass three times per NVIDIA/AMD/llvmpipe device: 18 passes, maximum 0.52 s. Application/libraries and selected fixtures build on Windows GCC 15.2 r7 and Ubuntu 24.04 WSL GCC 13.3. The new Linux fixture excludes its unavailable 2x/8x RGBA16F subcases; 4x runs. No whole-test skips.
This covers the adapted composition and storage migration exercised by those fixtures. Your retirement fixture and unchanged submitted head were not retested. The fork composition is available for the rebase; no competing ownership PR opened. AI-assisted: Codex; author responsible.
Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-17T11:02:12Z.
@Amoenus Thanks for the adaptation and the integration validation. I rebased this PR onto
mainat864729dc0das68ce4470d3and incorporated the storage-promotion lifetime handling from dedc318d9, with your co-authorship retained. The retirement regression now checks old sampled-view lifetime, accounting for both allocations, and retention when an already-promoted target is used in a later batch.I also integrated #6522 with its original authorship preserved and restricted ownership pins to the target's device. The original two-device fill fixture now checks that a target lookup does not charge the other device's recorder and that the target can retire without draining that recorder.
My validation of
68ce4470d3:Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested. The environment details, commands and validation limits are in the updated PR description; no title-level validation is claimed.
#6973 remains a follow-up depending on this ownership work. The declared prerequisites here are #6175 and #6522; #5939 has merged and its carried commit is removed.
AI-assisted: yes. — Codex
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-18T22:19:05Z.
Review: CHANGES_REQUESTED
This conflicts with
maininMultisampleTarget.hpp,MultisampleTarget.cppandDraw.cpp, and the conflicts are not mechanical:mainnow hasMultisampleTargetTexture(context, resource, components, viewType)with a texture cache keyed on 5 values and holdingstd::shared_ptr<Texture>. This PR still keys on 4 values withstd::unique_ptr<Texture>plusretiredTextures, andacquire()returns{shared_from_this(), texture.get()}. The ownership model has to be reconciled with theshared_ptrcache (the sampled view must still keep the owner alive without a cycle).MultisampleTargetView(context, target, owner, image)andKeepMultisampleTarget_nid_no_patchneed re-fitting against main's current declarations and theDraw.cppcall sites.f67e82caa) should be dropped from the branch.Please rebase onto current
main, rerunagc_driver_multisample_retirement,multisample_fill_host_only,multisampled_pass_orderandpass_input_hazardon the result, and push. #6522 is still open, so it stays carried until it lands.Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-18T23:12:37Z.
@adriadam10 In reply to your review: I rebased #6215 onto main
9121a9e4554e55105d6afddcf39073bb9c5fc259as65f6549e0f6ab442aff09a15dd3adf21c802b11a.viewType, and itsshared_ptr<Texture>values. Returned views alias the target owner without a reference cycle. Old sampled views and both image allocations stay alive through storage promotion and later recorded use.MultisampleTargetViewsupplies both owner and image toDraw.cpp, which retains the owner and records the image hazard.On Windows (native host), the full application and patched-library build passed. The four requested tests (
agc_driver_multisample_retirement,agc_driver_multisample_fill_host_only,agc_driver_multisampled_pass_order,agc_driver_pass_input_hazard) each passed once and five additional times.agc_driver_sample_multisample_targetfollowed the same pattern, andagc_driver_graphicspassed once. There were no failures or skips. Vulkan was required, and each GPU test selected the NVIDIA GeForce RTX 4070 Ti SUPER (driver 617.42).I intentionally skipped Linux (VirtualBox) for this rebase. Could a collaborator run the full Linux Build workflow for #6215 at this exact head and report its Linux build and test results? A run of the four requested tests on a native Linux Vulkan GPU would also be useful; please include the distribution, compiler, GPU, driver, and exact head SHA. Native Linux and Linux GPU results are still pending.
AI-assisted: yes. — Codex