fix(agc): share a depth plane's contents across its stencil pairings #4683
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4683"
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 XairRrR on 2026-10-12T18:57:47Z.
What
A depth surface is looked up by its depth address, stencil address, extent, format and sample count. When a title binds one depth plane with several stencil planes, each pairing gets its own Vulkan image. Depth written through one pairing, and an HTILE fast clear consumed by one, never reach the others, so later draws test against stale depth.
Changes in
Graphics/src/DepthSurface.cpp:vkCmdCopyImage. If the previous surface still has a pending fast clear for that aspect, the clear is carried over instead.TRANSFER_SRCusage for the copy.Related: #454 retires a depth surface once another writer covers its memory. It does not carry contents between surfaces that share a plane.
Test in
tests/DepthSurfaceReuse.cpp:It fails on
mainwith "a depth plane paired with another stencil plane must carry its depth over".Uncharted: Legacy of Thieves Collection (PPSA05684) binds the depth plane of its main menu scene with three stencil planes. Its tile-lighting compute writes a constant colour into sky pixels (depth == 1.0) and relies on the sky dome draw (depth test LEQUAL) to cover them. That draw tested against a stale image, failed everywhere, and the menu background showed a magenta gradient instead of the sky, cliff and fog. With this change the menu renders correctly. Frame rate is unchanged (8.5 fps with the change, 8.3 without).
Tested
BUILD_TESTING=ON.2a5eca11c. Full ctest: 959/959. Conventions check passed.maindoes not run it yet).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:04:11Z.
Combined source branch is prepared on current main43e3a70f8143f014f621c48abbdb137fffd7346e: https://github.com/Scramblrrrr/AnyPS5/tree/codex/depth-filter-plane-pairing-current-main , head9d5d0f94965dd100a52015abf78bec34349ddaf1. This retains both #4646 commits and author-preserved #4683 head35c4b5cde, resolving only DepthSurface.cpp conflicts. Negative admission check now lives at the start of planeSurface; both addresses are admitted before a newly created surface is constructed, and device cleanup keeps both key and owner-map removals. All #4683 pairing/copy tests and #4646 recorder lookup/CLI coverage remain. Source/diff-check/conventions pass. Not built/staged; native combined validation will follow after the separate007 test ends. No game/FPS claim, no competing PR. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:16:07Z.
Combined Windows validation completed for9d5d0f94965dd100a52015abf78bec34349ddaf1 on main43e3a70f8143f014f621c48abbdb137fffd7346e: both #4646 commits plus author-preserved #4683 35c4b5cde. Fresh graphics/recorder target builds, RTX5070Ti/GCC15.2/Release/toolsOFF.
Full mocked agc_driver_graphics PASS4.67s and native agc_depth_surface_lookup PASS0.55s,2/2 in5.56s, no skip. Production-only negative restores DepthSurface.cpp from preceding814a830e2 (filter kept, pairing fix removed), fixtures/CMake unchanged: graphics FAIL "a depth plane paired with another stencil plane must carry its depth over", native lookup control PASS,2-test total5.16s. Restore/touch/rebuild positive: graphics4.84s/native lookup0.35s,2/2 PASS5.24s. Source clean/diff-check/conventions pass. All both PRs' fixture/registration changes retained; address guard is in the common planeSurface helper before lookup/fallback scan, keys admitted before construction and cleared by device.
Branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/depth-filter-plane-pairing-current-main . This is combined PR compatibility/native validation, not a game cross-test or real-GPU readback of pairing copies. None of these generic build artifacts were staged into007; its ongoing runtime stack remains separate. No FPS claim. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T23:26:16Z.
One integration concern before I carry this into007: that runtime stack also contains #454's last-writer retirement (headde90e241e, on #425), unlike the isolated current-main9d5d0f949 validation above. Binding a different overlapping depth target retires older surfaces; color/storage/CPU/driver reuse can retire them too.
A compatible plane-pairing switch should carry the source aspect even if that source's whole surface was retired by the pairing switch. Conversely, a real color/storage/CPU overwrite must invalidate that plane's owner so an old depth image cannot be copied back over reused memory. Simply ignoring retired owners loses the first case; simply copying any matching owner risks the second. This is source-level reasoning, not evidence that #4683 fixes007's black scene, and the main-only fixture does not cover the combination.
Have you cross-tested owner tracking with #454, or do you have a combined head to try? I can cross-test the pairing and last-writer controls on Windows. Until then, the public main+#4646+#4683 branch9d5d0f949 remains separate from the007 game stack. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-13T11:34:34Z.
Thanks for carrying it with #4646 and for the Windows runs.
No, I have not cross-tested it with #454. My stack is main from 10 Oct plus #425, #757/#758 and #2076, without #454. I agree with both cases you describe. Here is how I would combine them; it is untested with #454:
takePlanesbefore the retirement. Retiring a surface then does not lose the plane: the new pairing already holds it.In short, ownership follows the plane's memory, and #454's last-writer rule decides when an owner is no longer valid.
If you have a combined head with #454 I can run it on my side. Note that PPSA05684 does not exercise #454's retirement, as far as I know.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T11:36:48Z.
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/DepthSurface.cppL608-612core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL598-606, L608-612, L677-682, L723-727core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppL37, L40-41core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL145core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL598-606, L608-612, L677-682, L706-709, L723-727, L758-763core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppL37, L40-41core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL598-606, L608-612, L677-682, L706-709, L723-727, L758-763core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppL37, L40-41core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL541-543, L597-606, L608-612core/libs/prx/libSceAgcDriver/tests/DepthSurfaceReuse.cppL11, L37, L41, L99, L278Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T14:59:41Z.
Checked on current main (merged cleanly):
agc_driver_graphics(includesDepthSurfaceReuse) passes, and fails withDepthSurface.cppreverted, so the new pairing test pins the change. Rest of the libSceAgcDriver ctest scope is green exceptagc_driver_tessellation, which segfaults on main too. Owner pointers are cleared together with the surfaces inClearDepthSurfaces. Merging once the full build is green.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-13T18:51:46Z.
Rebase handoff — rebased onto current
main(staleness only, applied cleanly — matching @adriadam10's earlier "merged cleanly" check), authorship unchanged.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727)To pick it up:
Head is
c9ce705cc.