feat(agc): retain and refresh sampled depth array storage #1368
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1368"
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 TibixDev on 2026-10-08T00:31:44Z.
What
Sample resident depth/stencil surfaces through 2D-array descriptors, including views starting at a later base slice. Assemble matching resident slices on the GPU and detile guest-backed slices. Uncommitted guest pages read as zero, matching the existing partially resident texture path.
Refresh array storage after recorded depth/stencil writes and HTILE fast clears. Component mappings share backing storage; depth and stencil changes are tracked separately. Preserve current main's reused-memory checks, pending-clear handling and multisampled depth attachments; sampling multisampled depth remains rejected.
Initially rebased on main
d146ec1b6, using and reviewing blawesom's proposed rebase. Fixed the additional multisample conflict and malformed lines in that rebase.Refreshed onto main
e013f8c9cafter newer upstream changes. PreserveDepthResummarizeDrawsNothingand register main's in-place draw-input tests alongside the depth tests, including Windows PATH setup.Evidence and merge order
XairRrR's Uncharted report identifies PPSA05684 stopping when sampling a 2048×2048 D16 surface through a four-layer array T#, and a 2560×1440 stencil plane through a one-layer array T#. The new tests decode and sample those descriptor shapes.
fisherjoey's Demon's Souls report identifies an 80-layer D32 atlas with uncommitted layer 17. A reduced-size 80-layer regression checks zero reads, subsequent commitment and decommitment, and preservation of the resident slice.
Depends on: none. Proposed merge order: this PR first, then reconcile #425 and its #1186/#2490/#2491 follow-ups. Those branches implement an alternative depth-plane-copy path; this PR already covers later base slices, guest-layer refresh and unchanged resident-slice reuse for its supported 2D-array path. Their cube, integer-plane and storage-image behavior is outside this PR. The later branch needs to retain one implementation of the overlapping array behavior.
Tested
Refreshed head on
e013f8c9c:Fedora 44 Release: nine targeted CTests pass on RX 6600 RADV (depth arrays/shapes/failure/clear, graphics, PM4, multisample guest access, in-place draw inputs and read-only resummarize), and six depth/graphics/resummarize CTests pass on lavapipe. Core and synchronization validation logs contain no validation errors. Conventions and diff checks pass.
Earlier validation (
d146ec1b6base)Fedora 44, GCC 16.2.1, Release:
agc_driver_recorder_tests,agc_driver_graphics_tests,agc_driver_mesh_tests.agc_depth_array,agc_depth_array_shapes,agc_depth_array_failure,agc_depth_clearpass with Vulkan core and synchronization validation; no validation errors.git diff --checkpass.The four depth tests are now registered in CTest with 30-second timeouts. No fresh title run or Windows runtime run is claimed. Console layout equivalence and remaining limitations are recorded in TechnicalDebt.
Checklist
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T06:37:31Z.
Which title samples a depth array on main, and where does it stop? The description says no game was run, and this is 810 lines in the draw path; with the title ID and the log line it can be reviewed.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-08T07:19:49Z.
Rebased on
e705d430. Preserved the latest CMASK, mesh, inert-pixel-stage and import fixes. Grouped depth-array limitations with the graphics notes to avoid section-header conflicts. The title-evidence request remains open.Fedora 44 Release:
agc_driver_graphics_tests,agc_driver_recorder_testsbuild; the targeted tests and contribution checks pass. Windows CI is pending.RADV and lavapipe:
--depth-array-only,--depth-clear-only,--depth-array-failure-onlypass with core and synchronization validation; no validation errors.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T17:42:45Z.
Heads-up for merge order: #1430 fast-proves depth lookups and skips
DepthSurfaceTexture. With this PR, array lookups refresh slices there, so #1430 now limits its fast path to 2D depth views and leaves arrays on the full walk.Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T19:50:55Z.
One more case from Demon's Souls for the guest-layer path, in case it's useful.
The title samples an 80-layer D32 shadow atlas at
0x2a4700000as one array view, and not every layer's memory is committed: layer 17 (0x2a8b00000) is unmapped. Sampling the whole array then throwsguest memory is not readablewhile the slices are read from guest memory (run295). On a local branch we read uncommitted pages as zeros, the way partially resident textures read, and the level gets past it. With this PR such arrays go throughCopySlices, so the same layers would need that rule (or a skip) there.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-09T11:55:22Z.
Uncharted: Legacy of Thieves Collection (PPSA05684) needs this: a compute shader samples a 2048x2048 D16 depth surface as a 4-layer 2D-array T# (probably shadow cascades) and stops on
mainwith:Another shader reads a stencil plane through a one-layer 2D-array T#:
I worked around both locally (consecutive slices copied into an array image, one-layer arrays viewed directly) to reach the title's main menu, but I'm not opening a competing PR since this one covers it. I have not run this branch itself with the title.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:14:33Z.
Please rebase: it conflicts with main in
State.hpp,tests/Recorder.cpp,tests/shaders/SampleArray.comp,CMakeLists.txtandTechnicalDebt.md. PPSA05684's stop above (XairRrR) answers the title question.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:07:44Z.
Review: CHANGES_REQUESTED
Thanks for the rebase on 10-08.
mainhas moved (2350+ commits) and the PR now conflicts inCMakeLists.txt,State.hpp,Texture.hpp,DepthSurface.cpp,Draw.cpp,tests/Recorder.cpp,tests/shaders/SampleArray.compandTechnicalDebt.md. TheDepthSurface.cpp/Draw.cppones are not mechanical, so this needs a rebase from you, as @oneandonlydean already asked:mainand rerun the PR's own tests (agc_driver_recorder_tests, the array, clear and failure-cleanup cases) after it; theSampleArray.compand test-list changes in particular.0x2a8b00000). Guest-backed layers go throughCopySliceshere, soGuestMemory::Readwill throwguest memory is not readablethere. Either read uncommitted pages as zeros, as partially resident textures do, or add a test showing the intended behaviour.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T09:09:20Z.
Hi! This PR currently conflicts with
main, so I rebased its 7 commits onto the latestmain. This was the deepest of the three TibixDev memory PRs — main rewroteDepthSurface(HTILE fast clears, pending clears, write notes) while this PR rebuilt it for depth/stencil arrays — so the rebased branch merges both, with a few semantic decisions the author should review:ValidateSampled,NoteDepthSurfaceWrite, shared backing) is kept, alongside main'sDepthSurfaceHolds, HTILE helpers (HtileFillClears/HtileMetadataBytes/HtileFillCovers/NoteDepthMetadataFill),pendingClearandApplyFastClear.DepthSurfaceTexture: main's newer reused memory model returnsnullptrfor a view of another extent or format over a surface's memory; the PR'sValidateSampledthrows for those. The merge keeps main's lenient extent/format pre-checks (returningnullptr) before the PR's strict validation, so both this PR's array tests and main'sDepthSurfaceReusetests pass.ApplyFastClear) is applied to the base and the resident slices beforeSampled.DepthSurfaceView: main's clear-value/pendingClear updates run together with the PR's registration.RuntimeAbi::FirstImageBinding,context.nullDescriptors = true, and theDepthSurfaceReusestub setsmaxImageArrayLayers.It builds, and
agc_driver_recorder_tests(including this PR's--depth-array-onlyand--depth-clear-onlymodes and the full default suite),agc_driver_graphics_testsandagc_driver_mesh_testsall pass locally.The rebased branch is available to pull:
Feel free to ignore this if you'd rather rebase yourself.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T03:35:38Z.
@adriadam10 @oneandonlydean Updated to
db7951d87, rebased on maind146ec1b6.Fedora 44 Release: all four depth CTests pass on RX 6600 RADV and lavapipe with core and synchronization validation, with no validation errors. Graphics, mesh and multisample checks pass on RADV; the full recorder suite passes on lavapipe. Removing either the sparse-read or fast-clear fix makes its regression fail. Contribution checks pass.
Ready for another review. Fresh title and Windows runtime runs are still outstanding; the title-shaped regressions are not a claim that I reran those games.
Imported from boykopovar/AnyPS5. Originally posted by TibixDev on 2026-10-12T04:58:16Z.
Main moved again during this review pass, so I refreshed the branch onto
e013f8c9cand pushed42d1193c4. The resolution keeps main's newDepthResummarizeDrawsNothingdeclaration and in-place draw-input CTest alongside the array tests, including the combined Windows PATH setup. The depth implementation is unchanged from the reviewed fixes.Fresh Release validation: all nine targeted RADV tests pass (depth arrays/shapes/failure/clear, graphics, PM4, multisample guest access, in-place draw inputs and read-only resummarize); all six selected lavapipe depth/graphics/resummarize tests pass. Both runs use core/synchronization validation with no validation errors. Conventions and diff checks pass. The body now separates these refreshed-head results from the earlier broader checks. Full platform CI still needs collaborator dispatch. AI-assisted update.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T08:23:40Z.
Conflicts with main again in
Graphics/include/DepthSurface.hpp; please rebase. Two things in the same push:RunDepthClearPass,DepthClearPassandDepthSurface::Clear(const DepthClearPass&)are only called fromtests/Recorder.cpp. Drop them from this PR and drive the clears in the tests through a path the driver already takes; they belong with #1395.DepthSurfaceTexturegained a two-line comment ("A view of another extent or format over a surface's memory is reused memory ..."). No code comments, please.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T09:15:18Z.
Review: CHANGES_REQUESTED
Thanks for the repeated rebases. This can't land as is, and a plain rebase won't fix it:
DepthPlaneCopyinDepthSurface.cpp: 2D arrays, later base slices, guest-backed layers, plus the follow-ups for storage views). The "merge this first, then reconcile #425" order in the description no longer applies. Please rebase onto currentmainand keep one implementation of the overlapping array behaviour: either extendDepthPlaneCopywith what is only in this PR (zero-read of uncommitted guest pages, HTILE fast-clear invalidation of cached copies, depth/stencil change tracking), or justify and replace it, with the numbers that show why.DepthSurface.cpp,Texture.cpp,Texture.hpp,tests/DepthSurfaceReuse.cppanddocs/dev/TechnicalDebt.md(the debt entries moved todocs/dev/debt/libSceAgcDriver.md).RunDepthClearPass,DepthClearPassandDepthSurface::Clear(const DepthClearPass&)(onlytests/Recorder.cppcalls them; they belong with #1395), and remove the new code comment inDepthSurfaceTexture.Welcome to push again once these are addressed.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T13:55:52Z.
Review: CHANGES_REQUESTED
Checked the current head against
main: it still conflicts inDepthSurface.cpp,DepthSurface.hpp,Texture.cpp,Texture.hpp,tests/Recorder.cpp,tests/DepthSurfaceReuse.cppanddocs/dev/TechnicalDebt.md. The debt entries now live indocs/dev/debt/libSceAgcDriver.md. The code conflicts are not mechanical.mainalready hasDepthPlaneCopy(#425,DepthSurface.cpp), which covers 2D arrays, later base slices and guest-backed layers. This PR adds a second implementation of the same behaviour, and the "merge this first" order no longer applies. Please rebase and keep one implementation: either extendDepthPlaneCopywith what is only here (zero-read of uncommitted guest pages, HTILE fast-clear invalidation of cached copies, depth/stencil change tracking), or justify replacing it with numbers.RunDepthClearPass,DepthClearPassandDepthSurface::Clear(const DepthClearPass&)(onlytests/Recorder.cppcalls them; they belong with #1395), and remove the code comment inDepthSurfaceTexture.Happy to look again once it is rebased onto current
main.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T06:31:56Z.
@TibixDev a heads-up on merge order: #9406 adds a check in
FlushDepthPlanes(DepthSurface.cpp) and a test inRunDepthSurfaceReuseTests(DepthSurfaceReuse.cpp). The check drops pending depth for a plane whose guest memory was unmapped, instead of throwingstorage texture has no committed guest pages.This PR and #1395 touch the same files, but as far as I can see not that function. Whichever lands second will need a textual merge in those files; nothing else should be needed. If you see an interaction with your array-storage path, please mention it on #9406.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T04:44:25Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the targeted tests reported by the author cover the added depth-array paths, and the inspected implementation is consistent with the stated scope.
What I ran
Reviewed head
42d1193c467f12a58a09249235929d893a5a30dcusing the prepared diff and pinned repository reader. No build or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No independent runtime, build, or test run was performed. The changed files listed in
review/manifest.jsonwere all included and read:CMakeLists.txt,DepthSurface.hpp,State.hpp,Texture.hpp,DepthSurface.cpp,Draw.cpp,Texture.cpp,DepthSurfaceReuse.cpp,Recorder.cpp,SampleArray.comp, andTechnicalDebt.md. No changed files were excluded.To get this to a good state
Nothing is required.
Pull request closed