fix(agc): treat other-shaped views of a depth surface's memory as reused memory #1495
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1495"
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 TideOPL on 2026-10-08T09:15:18Z.
What
Engines alias transient render targets, so a texture can sit at the address of a depth surface after that memory has been handed to a color image: a 384x384 R11G11B10 texture over a 384x384 D32S8 surface, for example.
DepthSurfaceTexturesent every texture at a depth surface's address toDepthSurface::Sampled, which threwsampling the depth plane ... is not implemented, and the draw was skipped.Now a view with a different extent, or a depth-plane view in a format that cannot hold the plane, is treated as reused memory. "Cannot hold the plane" means it is neither the plane's own R32F / R16 unorm nor a T# that reads the raw depth bits. The lookup returns null, so the texture goes through the ordinary texture path, as it would at any other address. Stencil-plane views keep their current handling.
#425 rewrites
DepthSurfaceTexturefor array and cube depth reads but has no reuse rule. The two touch the same function, so whichever merges second needs a small rebase.Tested
Windows 11, NVIDIA RTX 5070 (driver 610.88).
... as a 384x384 texture of guest format 36 (vk 122), tile mode 7 ...) was skipped every frame. It now records, and that skip no longer appears in the log.ctest: 426 of 426 pass on currentmainwith this PR and #1494 (unrelated files) applied.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 klosixgaming-arch on 2026-10-08T11:30:56Z.
Review: APPROVED
Good improvement to depth surface texture matching. This adds proper validation to ensure the depth format matches between the requested resource and existing depth surfaces, preventing incorrect texture reuse that could cause rendering issues.
Strengths:
This will improve rendering correctness by preventing mismatched depth texture reuse. Ready to merge.
Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T07:12:01Z.
Another case this rule fixes, from Astro's Playroom (PPSA01325), Windows 11 / RTX 3060 Laptop:
0x529430000as a 1536x1536 depth target. An earlier scene had used the same memory as a 2048x2048 D16 surface (vk format 124), and that surface is still resident.0x5001c6a00samples the memory as a 1536x1536 2D array (guest format 7, R16 unorm, tile mode 4, slice 0). Onmain,ValidateSampledthrows, and because the format is depth-like the title aborts:mainthis crash only shows up when no stale stage-A cache entry hides the depth surface; #1957 removes that stale entry, so it shows up more often.The preference matters when both shapes are resident: a newest-first search can return the other one. That could be a follow-up; it's not needed for this PR.
Imported from boykopovar/AnyPS5. Originally posted by hugodearaujo on 2026-10-09T18:08:14Z.
Another title that hits this: Hollow Knight: Silksong (PPSA12544) on Linux (RX 9070 XT), after lowering the in-game resolution scale.
Before this PR:
With this PR, that stop is gone. The same reuse then happens on the stencil plane, which this PR leaves as it was:
The extent matches, but an R8G8B8A8 view cannot be a stencil read:
Sampledonly acceptsVK_FORMAT_R8_UINTfor that plane. Applying the same rule to the stencil plane gets the title past this point:I only ran it locally, so I'm leaving it here in case you want it in this PR rather than opening a separate one.
Base for these runs:
main+ #1836 + #1431 + #846 + #2323 + #861 + #2401 + #1902.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:04:24Z.
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.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL169-172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL172Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:37:14Z.
Review: CHANGES_REQUESTED
Thanks for the fix, and for the title logs. The rule looks right to me, but it needs a test before it can merge:
libSceAgcDrivergraphics tests: a depth surface plus a texture at the same address with (a) a different extent, (b) the same extent but a colour format that cannot hold the plane (e.g. R11G11B10), (c) a 2D array view of a different extent (the Astro's Playroom case reported by @orbz22). Each must go through the ordinary texture path instead of throwing, and a texture of the surface's own extent and R32F/R16 must still hitDepthSurface::Sampled. The new tests must fail onmain.DepthSurface.cpp:178-179: please pin the "raw depth bits" exception (DepthBitsTextureWidth) with a test row too, so the!depthBitsbranch is covered both ways.R8_UINTcheck for the stencil plane here, add a test row for it as well. Otherwise it is a separate PR.Imported from boykopovar/AnyPS5. Originally posted by TideOPL on 2026-10-10T00:21:11Z.
Thanks. I added
RunDepthSurfaceReuseTeststoagc_driver_graphics(tests/DepthSurfaceReuse.cpp, mock device, no GPU needed). It registers a 384x384 D32 and a 256x256 D16 surface:DepthSurface::SampledSampled; R32 uint in a render-target layout → nullOn current
mainit fails inSampled("sampling the depth plane ... is not implemented"). Full ctest passes on Linux and Windows. I left the stencil-plane check for a separate PR.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T01:04:11Z.
Review: APPROVED
Thanks for the test. Checked: the new cases pass, and they fail with
DepthSurface.cppreverted (negative check);libSceAgcDriverctest 270/270 green on current main. Merging once CI is green.