fix(agc): store a written storage image over a depth plane into the surface #5113
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5113"
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-13T12:03:46Z.
What
DepthSurfaceStoreBackonly took the storage image a depth surface had handed out for its plane (DepthSurfaceStorage). A storage image over the same plane that the surface did not hand out was written but never reached the depth image, so later depth tests and plane reads used the surface's old contents. For example:Changes in
Graphics/src/DepthSurface.cpp:copyPlanetakes the storage image to copy from or to, instead of always the plane's own one.Test in
tests/execution/DepthStorage.cpp:StorageTexture::Create, filled with 0.125 and stored back, reaches the depth surface (read back through the surface's own storage view);The first check fails on
main.Uncharted: Legacy of Thieves Collection (PPSA05684) writes a 640x360 downsampled depth with a compute shader, then tests its mist particles against that memory as a depth target. The storage image was created before the depth surface, and the dispatch kept reusing it, so the depth target stayed at its clear value and the mist drew over the foreground cage in the main menu. On that title's branch, an equivalent local change (making such a written storage image the plane's writer, taken at the next bind) puts the mist behind the cage. That branch carries other depth work, so this PR's exact code was verified by the test, not in the title.
Related: #454 (retiring a surface when another writer covers it) and #5003 (2D array storage views of a depth plane) also touch storage access to depth planes. Neither stores an outside view back into the plane.
Tested
BUILD_TESTING=ON.ff8fe4dbc. Full ctest: 1041/1041. One run hit an unrelated failure inguest_kernel_fcntl, which passed when rerun. 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 kr4y4 on 2026-10-13T14:58:54Z.
First Windows and Intel run.
Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU (NVIDIA 595.97) and an Intel Raptor Lake-S iGPU (32.0.101.6790). The head dfc28bd55 merged into
main0f2683cb7, which passes 1069 of 1069 on both GPUs.agc_driver_depth_storage,--repeat until-fail:3: passes on both GPUs.DepthSurface.cppfrommain,agc_driver_depth_storagefails on both GPUs withAGC graphics: a storage image over the depth plane that the depth surface did not hand out was not stored back.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T16:05:16Z.
DepthSurfaceStoreBackgoes throughsurfaces()oldest first and stops at the first surface whoseStoreBackreturns true (DepthSurface.cpp L712-L718). The newCoversPlaneloop (L204-L211) lets an older surface with the same depth address, extent and format take the copy before the loop reaches the surface that handed the view out.Such surfaces exist when one depth plane is bound with different stencil planes, because
sameSurfaceincludes the stencil address in its key (L460-L462). #4683 reports that PPSA05684 binds one depth plane with three stencil planes.DepthSurfaceTexture(L609),DepthSurfaceAt(L690) andDepthSurfaceStorage(L706) all resolve a plane address to the newest surface (rbegin), so they never see a copy made into an older one.Both of these work on
mainand break with this PR:CoversPlaneaccepts the view before the owning surface's replaced check runs. The PR description says this case still throws.An outside image takes the same loop, so it also lands in the oldest pairing.
Repro: a copy of
tests/execution/DepthStorage.cppwith thisRun:Results (WSL2 Ubuntu, GCC 15.2, CI CMake configuration, Release, lavapipe):
mainfdefd7660: the read back has 4096 texels of 0.75. The second store back throws... through a view that another view of the plane ... replaced are not implemented.fdefd7660: the read back has 4096 texels of 0.5 (the second pairing's clear value). The second store back returns true and does not throw.agc_driver_depth_storagepasses on the merge.A fix I tried locally: first run the identity and replaced checks on every surface, then run the
CoversPlanecopy newest first, in the same orderDepthSurfaceStorageuses:With that change (+8 lines), the PR's test and the repro both pass.
AI-assisted: written with Claude Code; I checked the code paths and ran what is described above.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-13T16:52:56Z.
@nikowolf123 thanks, you're right on both points. I pushed 6d1893f40 with your fix:
StoreBacknow only takes the surface's own view or throws for a view that another view replaced, and that check runs over every surface first.StoreBackCovering, whichDepthSurfaceStoreBackcalls newest first, in the orderDepthSurfaceStorageresolves a plane.Your repro is now the
RunPairingspass oftests/execution/DepthStorage.cpp: one depth plane bound with two stencil planes, a store back through the newest pairing's view, a read back throughDepthSurfaceStorage, and a store back through the replaced view that must still throw.agc_driver_depth_storagepasses.DepthSurface.cppreverted to dfc28bd55, it fails witha storage image stored back went into an older pairing instead of the pairing that handed it out.main0214069e3(Linux, RTX GPU, NVIDIA driver, Release), all 487 agc tests pass (agc_driver_stencil_ref_exportis skipped), andcheck_conventions.pypasses.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:57:37Z.
Rebased onto current
main(one conflict intests/execution/DepthStorage.cpp, next to the new layered-view checks; kept both). Checked:agc_driver_depth_storage*pass, the new check fails withDepthSurface.cppfrommain, the pairing order fix from the earlier review is covered byRunPairings, and the rest of the scoped ctest passes exceptagc_driver_tessellation, which crashes inside RADV's shader compiler and doesn't touch this code. Windows/Intel run by @kr4y4 also green. Merging once the full Build is green.