fix(agc): retire fully unmapped multisample targets #4474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4474"
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 JJenkx on 2026-10-12T12:57:20Z.
What
After a multisampled color target is freed, its guest-read guard and cached host image survive. A texture reusing that allocation is rejected as a read of live multisampled data. Notify the graphics registry after successful allocation removal or unmap, retire targets fully covered by the released range, and skip their cached images in later draws and metadata updates.
Protection changes and failed unmaps retain the guard. Retired Vulkan images remain allocated until device teardown so outstanding commands retain valid resources. Partial unmap/reuse and reads of live multisampled data remain unsupported. No new guest system exports.
Rebased onto upstream main
b478fbbb1con October 13. A subsequent merge-tree check against upstream61b8742b6b4is clean, including its newer multisample mutex initialization. The allocation callback follows the newer successfulapplyPatchmutation. Retirement preserves the upstream fragment-block guard sizing and checks target activity before the newer color-fill notification. The regression retains the upstream 2x/4x/8x guard-boundary cases alongside allocation removal, unmap, address reuse, protection and failed-unmap checks.Tested
The full fork workflow passes with published head
f7fd7569famerged into current main0214069e33c. Linux: 1,031 passed, 46 skipped, zero failed of 1,077; its multisample regression passes. Windows: 708 passed, 387 skipped, zero failed of 1,095. Windows multisample guest access and copied-direct ordering are skipped, so their Windows runtime behavior remains unvalidated. These are the repository-defined full workflow and test selections; skipped cases are untested. Upstream-maintainer CI remains pending.Independent full Linux Release build of
f7fd7569fa, BUILD_TESTING=ON, bundled pinned dependencies, default SPIRV-Tools option OFF, also passes. Nine selected checks pass on Radeon RX 6650 XT without skips: patched_libraries, guest_memory_pool_stats, agc_copied_direct_ordering, agc_host_import_unmap, agc_parked_import_unmap, agc_multisample_guest_access, agc_driver_graphics, guest_memory and guest_module_info. Multisample guest access and copied-direct ordering also pass on Mesa lavapipe without skips. Conventions pass. Removing only the unmap-observer installation makes the multisample regression fail on both Radeon and lavapipe at the stale texture-read guard after allocation reuse; exact restoration and rebuilding make both pass.The earlier complete local lavapipe suite on this standalone head had 1,007 passed, 44 skipped and six failures of 1,057 with a 30-second timeout and parallelism 4, running as root. The five timeout cases pass individually at the upstream 120-second timeout with GALLIUM_OVERRIDE_CPU_CAPS=avx; the named-shared-memory permission case passes as normal user jjenkx. These follow-up results are not a single full-green local run. The first fork CI attempt on older main
091c136ba6failed only guest_math, also failing on untouched main. Current upstream fixes that acosf NaN-bit issue, and the new full workflow above passes without adding unrelated math code to this PR.Crazy Chicken Shooter Bundle (PPSA03117) motivated this fix. Earlier combined integration runs reached gameplay near 60 FPS and closed normally; they include other fixes and are not standalone validation of this rebased PR. No title run or game performance improvement is claimed for the current rebase.
Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-12T16:25:56Z.
Windows run and the full suite, which the description lists as not run.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 012379fa5 merged into
main2a5eca11c.libSceAgcDriver's call into the newGuestAllocationsSetUnmapObserver_nid_postfixinlibc.agc_multisample_guest_access,agc_host_import_unmap,agc_parked_import_unmap,agc_driver_graphics,guest_memory,guest_memory_pool_statsandpatched_librariespass on both GPUs with--repeat until-fail:3.agc_multisample_guest_accessprintsMultisampled target guest access tests passedon both.main'sMultisampleTarget.cppandGuestAllocations.cpp/.hppand the new test,agc_multisample_guest_accessfails on both GPUs:a texture read of 0x…+0x50000 overlaps multisampled color target 0x…+0x40000 (4 samples), whose samples are only on the host: guest access to it is not implemented.ctest --timeout 120 --parallel 4):agc_driver_f32_dot2_rounding, fails the same way onmain(noshaderFloat64, #4528).agc_driver_graphicsfailed after 0.16 s (it normally takes about 8 s), and I didn't capture its output. Two more full runs passed 973 of 973, and 60 runs ofagc_driver_graphics_tests.exe, four at a time, all passed. So I can't tie that exit to this change.main2a5eca11cpassed 973 of 973 in its one run.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T02:40:46Z.
@JJenkx The unchanged-head Windows validation and the separate two-library conditional title comparison are recorded below. The adaptation passes the private color reuse refusal and reaches the depth frontier in #3262; it is preserved in our fork for reference.
Canonical main rebase aid
@JJenkx I prepared a separate upstream-only rebase onto pinned main
e51428bf23a531a0e575222f2833be90ce103096: 828e6e461, fork branchcodex/validate-pr4474-main-e514. This carries your026c198e retirement commit, preserving main's aligned tiled guard footprint, synchronized2x/8x tiled tests and color-fill notifications. The retirement loop restores the original linear tile mode after main's tiled cases; current debt entries are retained. It contains none of the private native-color/depth integration below. You can use this as a rebase reference; your upstream branch remains026c198e/conflicting until you update it.Full Windows Release build/libraries, conventions and registration pass. Eight relevant groups pass×20 without skips. Replacing the three production files with exact e514 main, while keeping the rebased Recorder regression, makes full-removal/address-reuse fail at the stale texture-read guard. Exact source restoration/full rebuild passes.
Full NVIDIA:1017 passed /3 failed /8 skipped of1028, max22.678s (
--parallel2 --timeout30), WinLibs15.2r7/c++.exe, RTX5080/610.62, shader cache off. Failures: BDA device, BDA span reads and pixel interlock. In isolated repeats, BDA device passes×5; span reads/interlock fail on their first executions. The same latter pair fails with all three changed production files replaced by exact e514 main, with unchanged BDA/interlock fixtures, then fails again after exact restoration/full rebuild. BDA device passes×5 in both controls. This is a matched production/fixture comparison, not a whole untouched checkout or proof of the initial BDA-device failure's cause. No full-green/CI/AMD/Linux claim. Our existing #3291 report is updated with these observations; no duplicate issue or inferred root cause.AI-assisted rebase/validation/reporting: Codex. Original-head and conditional title scopes below remain separate.
Windows validation of unchanged PR head
Exact 026c198eab75a48c35a8dd26bb5979506a8adbd4, based on main
1acfa7f788: full Windows Release build/patched libraries, conventions and registration pass. Full NVIDIA: 988 passed /0 failed /7 skipped of995, maximum23.883s (ctest --parallel2 --timeout30). WinLibs GCC15.2.0r7 (c++.exe), Ninja, bundled dependencies/SPIRV-ToolsOFF, Windows11 Enterprise26200 /RTX5080 driver610.62. Shader cache disabled; driver coldness unverified.Eight groups each pass20 repetitions without skips:
patched_libraries,guest_memory_pool_stats,agc_host_import_unmap,agc_parked_import_unmap,agc_multisample_guest_access,agc_driver_graphics,guest_memory,guest_module_info. The MSAA fixture's verbose log confirms RTX5080. It covers protection/failed-unmap retention, successful unmap and allocation removal, address reuse/new image, and queued-work synchronization before teardown.Failing-main control: the three changed production files (
MultisampleTarget.cpp, GuestAllocations header/source) are temporarily replaced with exact parent-main files, leaving the PR's Recorder regression. The target is rebuilt and the fixture fails after full removal witha texture read ... overlaps multisampled color target ... guest access to it is not implemented. Original source is restored byte-for-byte, the full build/libraries rebuilt, and the20-run selection above passes. All tracked source remains clean at026c198e. A retained initialized3rdparty/libusb-cmakedirectory from newer main is untracked on this older head; it was neither edited nor built as part of this head.These results validate your standalone original head, not a later-main merge or the private adaptation. GitHub now reports this PR conflicting with main; no rebase/promotion or upstream full-CI pass is claimed. Skips: stencil-ref export, flip lifetime/reopen/controls/overlay/unopened, WQHD detection without Vulkan. No AMD/Linux or new game-launch claim from this Windows run.
Conditional title observation — separate scope
The earlier fac106b2b stack replay ends at the private MSAA reuse guard after787.785s, restored/hash-verified. Before the refusal, the first sampled shared views at0x405fc00000 are freshly mapped again (seen0/generation2, map-shared, one alias; map serial483530→2570294). The collected span0x21e7c000 contains color0x1fe00000 and metadata; all8160 color blocks receive newer Cpu collector stamps. This identifies new mapping records, not completed CPU stores or coverage of a successful registry notification. The existing #2132 report holds exact traces and limits.
The main495 conditional integration separately passes full NVIDIA1034/0/8 of1042. The documented adaptation b553a8f76, branch
codex/experimental-ppsa99902-unmap-retire, is now preserved in our fork. It carries your exact GuestAllocations header/source from026c198e and adapts retirement to the private stack's grouped color/DCC/CMASK/FMASK guards. Retirement requires the successful release to cover every guarded range of that resident target; protection changes, failed unmaps and partial releases retain the guards. Inactive targets are excluded from acquisition/publication/snapshot/clear paths; old Vulkan objects remain alive until device teardown.Adaptation native validation (separate from unchanged-head results above): full Windows Release build/all patched libraries, conventions, registration and diff checks pass. Full NVIDIA1035 passed /0 failed /8 skipped of1043, maximum23.514s,
--parallel2 --timeout30. Sixteen relevant groups each pass×5 without skips: retirement, target import, metadata reset, native snapshot, depth target/clear/refusals, readback, XOR views, tile transfer, initial contents, layout, write tracking, guest memory, host-import unmap and parked-import unmap. The four retirement cases combine full Remove/Unmap with prior partial color/CMASK release; they check retained guards, fresh image identity and exact new sample contents. The fixture uses a no-op host-unmap callback, so its Unmap cases test registry/retirement semantics rather than the OS unmapping operation. Replacing all three production files with pre-adaptation0c74657e while retaining the regression makes it fail at the stale color/metadata guard; exact source restoration/full rebuild makes it pass. Hardware/toolchain as above, usingg++.exefor this build.Controlled title comparison completed (conditional stack): PPSA99902/01.003.000, same frozen f609 executable/converted guest libc, Windows/RTX5080 as above. The baseline is0c74657e on main495; the changed profile uses b553a8f76 for
libcandlibSceAgcDriveronly, with all122 other patched libraries byte-identical to baseline. The all-rebuilt native-suite profile is separate; the full-byte PE audit proves its other122 changes are only COFF/export timestamps, checksum and named-import hints, with identical import names.guest writes to a resident multisample target or its metadata are not implementedguest writes over native multisample depth are not implementedBoth exit0xC0000409 without the1080s observation timeout. Both show the opening movie;60/61 sparse private captures, respectively. Six300ms input pulses are sent on the same100/150/180/210/600/610s schedule; these uninstrumented runs do not independently log each pulse's consumption/release. Originals, exact baseline runtime/guest module and user data are restored/hash-verified after each run. Shader cache is disabled/Vulkan required, with bypass flags absent.
This isolates an advance past the private color-target reuse refusal to the two-library adaptation. It is not unchanged-PR/main game validation, a rendering/gameplay/FPS result, or proof of completed CPU stores. Successful unmap notification counts/ranges and the first depth predicate were not instrumented here. The newly reached private depth refusal is recorded in existing #3262; trace its mapping/ownership before proposing a depth fix. No duplicate retirement PR or new upstream capability issue from a private guard. Private assets remain local. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:54:04Z.
Needs a rebase: #4199 is merged and this now conflicts with it in
MultisampleTarget.cpp(guard()) andtests/Recorder.cpp. It gets a full build once it is clean.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-13T15:52:56Z.
The rebase is now pushed as
f7fd7569fa; GitHub reports MERGEABLE. It includes the #4199 guard changes and the newer Recorder regression cases. A merge-tree check against current main091c136ba6is clean.The independent full Linux Release build passes. Nine selected checks pass on Radeon RX 6650 XT; multisample guest access and copied-direct ordering also pass on lavapipe, without skips. Removing only the unmap-observer installation makes the regression fail on both drivers; restoring it makes both pass. The PR description includes the broader suite results and their limitations.
Ready for the full build you offered once the conflicts were resolved. Thank you.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-13T16:24:41Z.
The published rebase has completed full fork build results: PR build. Windows passes: 705 passed, 386 skipped, 0 failed of 1,091. Linux builds successfully: 1,026 passed, 46 skipped, 1 failed of 1,073; the multisample regression passes. Windows multisample guest access and copied-direct ordering are among the skipped cases, so no Windows runtime validation is claimed for them.
The single Linux failure is
guest_math, which also aborts in the untouched upstream-main build at the same base091c136ba6. An Ubuntu 24.04/GCC 13.3 probe of that production libc reproduces the failure at theacosf(2.0f)NaN-bit assertion. Current upstream already fixes it in0265f336368; the same probe passes on0214069e33c. This is a reduced libc/test build, not the entire runner environment.A fresh full PR build against current main is queued. No unrelated math changes were added to this PR. Skipped cases remain unvalidated.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-13T16:58:30Z.
The published head
f7fd7569fanow passes the full fork workflow against current main0214069e33c.The earlier Linux failure on base
091c136ba6was the upstreamacosfNaN-bit issue; current main includes its existing fix. No unrelated math changes were added to this PR. Ready for the upstream full build/review you offered once the rebase was clean.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T17:20:41Z.
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)docs/dev/debt/libSceAgcDriver.mdL29-30docs/dev/debt/libSceAgcDriver.mdL29core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL7, L177, L207-217, L219, L235-237, L242-246, L390core/libs/prx/libSceAgcDriver/tests/Recorder.cppL5124-5125docs/dev/debt/libSceAgcDriver.mdL29core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL221-222