fix(agc): retire a depth surface on a storage write only when the write covers a whole plane #7050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7050"
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 SP4C3B4R-8 on 2026-10-17T08:23:41Z.
What
Since #454 a written storage image retires every depth surface its described size overlaps, and a retired surface reads guest memory, which never received the depth image. ee6aba54 reported on #454 that PPSA15304 writes storage views that overlap the scene depth without covering it (the largest reaches 0x11e0000 of the 0x12b0000 depth plane), so the whole depth was thrown away and the scene came out almost black; they keep #454 reverted on their branch.
CoveredMipBytes: whole tile blocks, rows without padding), cover the surface's whole depth or stencil plane. A partial overlap leaves the surface alive, as before #454.DepthSurfaceOverlaps), so a written storage view that touches no depth surface does not describe its layers.By ee6aba54's descriptor table this keeps the 2848x1600 scene depth alive and still retires the 512x512 surface whose planes the 4 MiB views cover.
Tested
Windows 11 Pro (26300), MinGW-w64 GCC 15.2.0, Release, Ryzen 7 7800X3D, RTX 5070 Ti.
agc_driver_depth_storage_reusenow checks, for D32, that a half-width storage write keeps the surface sampled from the depth image (0.5), and that a 128x128 R32 write over the whole 64 KiB plane retires it (0.25 from memory). With the old retire on any overlap it fails ("depth reuse returned the wrong GPU value at lane 0").-R "depth|agc_storage|storage_one_slice|storage_write_back|storage_cache|resource_cache_storage") pass.tools/check_conventions.py --base origin/mainpasses.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)🤖 Generated with Claude Code
https://claude.ai/code/session_01GN8FJFTedayRXLHythXkZ4
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T08:31:00Z.
Thanks @SP4C3B4R-8, the partial-overlap fix looks right: the PPSA15304 view no longer retires the scene depth. One change requested before merge, plus a heads-up about #7044.
Full-plane writes at non-block-aligned extents no longer retire (regression vs main)
CoveredMipBytescounts only whole tile blocks (wholeColumns = width / blockWidth,wholeRows = height / blockHeight, TextureTiling.cpp:296-297), butdepthBytes()is the padded plane (DepthSliceBytes). So a write can only cover a plane whose extent is a multiple of the block size, and real depth planes almost never are:DepthSurfaceStoragedoesn't serve (e.g. R32_UINT) haswholeColumns = 0and never retires.The effect is that after a whole-plane overwrite in another format or layout, the plane's sampled view returns the stale depth image again, which is the pre-#454 behaviour, now limited to block-aligned planes.
Ask: count the edge blocks as covered when the written view reaches the plane's extent (for example in
CoveredBy: same base address and block layout, written extent in bytes per row and rows at least the plane's). Partial overlaps should keep the surface alive, as they do now. Please also add a test case: a full-extent write at the fixture's own 64x32 in a non-served format must retire (expect 0.25 from memory).Heads-up: conflict with #7044
#7044 and this PR merge cleanly as text but don't compile together: both add
bool DepthSurfaceOverlaps(VkDevice, uint64, uint64)(two definitions in DepthSurface.cpp, two declarations in DepthSurface.hpp). #7044's version also checkssurface->active; either body is correct for both callers. Whichever lands second needs to drop its copy. No action needed yet, just so it isn't a surprise.After the fix we'll run full CI on the new head and the usual game checks.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T08:38:52Z.
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.cppL1914core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppL10core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL1006Some 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/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppImported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T09:21:40Z.
AMD / Windows run of this PR at 25c6bb032: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.
agc_driver_depth_storage_reuse: pass (0.33 s)agc_driver_f16_fma_denormal_modes: pass (0.32 s)agc_driver_linear_target_resident: pass (0.31 s)agc_driver_graphics: pass (4.97 s)agc_driver_prepared_graphics,agc_driver_prepared_unregistered_graphics,agc_driver_prepared_graphics_prebuild_unset,agc_driver_prepared_graphics_prebuild_0,agc_driver_prepared_graphics_prebuild_1: passAI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-17T12:37:11Z.
@SP4C3B4R-8 Ran it at the same spot. PPSA15304, start position of the first area after loading the save, frame dumps (
APS5_DUMP_FRAMES) of the title's output at the same camera position, mean gray of the whole frame and of its lower two thirds (0-255). Both builds are plainmainbf2053816, the second with this PR (25c6bb032) merged; nothing else differs.mainmain+ this PRSo this PR fixes the darkening, consistent with the 2848x1600 scene depth no longer being retired; the scene is lit as in our builds with #454 reverted (92.5 to 96.6 there).
Both runs used
APS5_NO_RECT_INDIRECT=1: since #5979, red and blue blotches appear between the tree canopies in this scene (reported on #5979). The switch does not change the brightness; plainmainwithout it measured 50.8.Ubuntu 24.04, kernel 7.0.0, NVIDIA GeForce RTX 5080, driver 595.99.02, Release build.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by SP4C3B4R-8 on 2026-10-18T08:27:58Z.
@oneandonlydean thanks, both done in
a714d1b37(rebased onto mained01d79d3).Full-plane writes at non-block-aligned extents: a written view now also retires a plane when it reaches the plane's extent with the same block layout: same base address (per written layer), same bytes per element, 64 KiB blocks with the depth block's extent (128x128 for 32-bit, 256x128 for 16-bit, 256x256 for stencil), the same blocks per row, and width and height at least the plane's (
WrittenStorageExtent,CoveredBy). Partial overlaps keep the surface alive as before, and the whole-block byte rule still covers the rest.Test:
DepthStorageReuse.cppwrites the fixture's own 64x32 through an R32_UINT view in 64KB_S_X (not served byDepthSurfaceStorage, not a depth-bits layout) and expects the sampled plane to read 0.25 from memory; the 128x128 case runs after a new depth draw. The depth address is now 64 KiB aligned inside the buffer, since a tiled view's base is block aligned. With the new rule disabled the test fails at that read.#7044: it merged first, so this PR now uses its
DepthSurfaceOverlapsand drops its own copy.Local: 37 depth/storage ctests and the agc suite pass (RTX 5070 Ti, Windows 11);
check_conventions.pypasses.Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T21:53:16Z.
Intel and AMD Windows data:
agc_driver_depth_storage_reusefails onmainand passes with this PR on an Intel UHD 770 and an AMD RX 9070 XT.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This heada714d1b37merged intomainf3059421f. "Without" means this PR's test files onmainf3059421f, with none of its other changes.agc_driver_depth_storage_reusedepth reuse returned the wrong GPU value at lane 0: got 1048576000, expected 1056964608I also ran full CTest with this PR and the 14 other open AGC PRs I tested in the same batch merged together (#7647, #7641, #7630, #7627, #7603, #7600, #7591, #7579, #7535, #7533, #7474, #7462, #7048, #7650). Neither GPU showed a failure beyond
main's own, except #7650's new test.AI-assisted: yes (Claude Code)