fix(agc): let a storage write over a whole depth plane supersede a clear noted before it #14475
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14475"
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 hugodearaujo on 2026-11-01T14:53:44Z.
What
DepthSurface::StoreBackCoveringcopies a storage image that covers a whole depth (or stencil) plane into the surface's host image after the write, but it left the surface's pending fast clear in place. A clear noted on the surface before that write was then applied after it, at the surface's next bind (ApplyFastClearinDepthSurfaceView), and the pending clear also madeSyncFromMemoryreturn early. The plane ended up atDB_DEPTH_CLEARinstead of the bytes the shader stored.The copy now forgets the pending clear of the aspect it replaced (
ForgetClear). A clear noted after the write comes after the copy and still wins.Where it shows
LEGO Horizon Adventures (PPSA14632, UE5) renders most of the world black in gameplay: ground, foliage, Aloy's face. Its Nanite material pass draws one set of tiled quads per material with depth test
EQUALand no depth write, against a D32S8 "material depth" target that no draw writes. A compute export writes that depth plane through a 2112x1188 R32F view with the target's Z swizzle, and writes the HTILE as a buffer (expanded tiles over the render area). Each frame the title reuses that memory for other targets after the material pass, so the depth surface is retired before the export runs. The export then goes throughStoreBackCoveringinto the retired surface, and the material pass binds that surface again.From a diagnostic build (addresses from one run):
EQUALdraw, after a recorder sync. It held a single value,0x00000000, in all 2,509,056 texels.EQUAL, and the GBuffer kept its clear.With this change, the same readback holds the 89 k/16383 values (
StoreBackCoveringran on that surface,pending=0at the bind), and the scene renders.Tested
Arch Linux, kernel 7.2.11, Radeon RX 9070 XT (RADV GFX1201, Mesa 26.2.6), Release.
agc_driver_depth_surface_from_storagehas two new cases. Each uses a D32 surface with HTILE that is retired and then bound again:main'sDepthSurface.cppthis case fails:2048 pixels passed, expected 15(the clear depth, 1.0).VK_LAYER_KHRONOS_validation(ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1), onmainac26e59d9aand on this branch. Both pass, and neither run printed aVUID-line.mainac26e59d9a+ #11580 + #4449 (without #11580 the title stops at 29 s). Right: the same + this PR.Without the change, everything below the HUD at both times is purple fog over black silhouettes: the ground, the plants, the arch and Aloy's face. With it, the brick ground, plants, logs, snow and Aloy render in full, at the same spot and HUD state. Side by side, base on the left and this PR on the right, 240 s on top and 290 s below: pr14475-lego-base-vs-fix.png.
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)Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-01T17:21:51Z.
Review: APPROVED
Reviewed head
3755dd3610ffmerged locally onto mainf2d874c1fdcc(PR baseac26e59d9abf, clean merge). Linux, lavapipe only, no dump, so I couldn't check the title itself.What I ran:
agc_driver_depth_surface_from_storagewithANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1andVK_LAYER_KHRONOS_validation: passes on the PR.DepthSurface.cpp: fails only on the new clear-then-write case,2048 pixels passed, expected 15. The write-then-clear case passes on both, as you said.ctest -R agc_driver(843 tests) on both: 775 pass, 68 skipped, 0 failed on the PR. The only other difference wasagc_driver_depth_fast_clear_submitfailing once on the main-file run under-j 12. It passed 5/5 alone and 48/48 in parallel stress on both sides, so it's a timing flake and has nothing to do with this change.tools/check_conventions.py --base origin/main: passes.VUID-vkCmdCopyImage-srcImage-01548/-01551(R32F to D32 copies) for this test. It prints the same set and counts with main's file, so the PR adds nothing new.Code I read: the pending-clear paths in
DepthSurface.cpp. A clear gets noted byNoteHtileDepthClear,NoteDepthMetadataFilland the bind-time HTILE scan (storeBackClearedHtile). It gets used up byApplyFastClearat bind and before liveStorage()access, andSyncFromMemoryskips the reload while it's pending. Live surfaces already apply the clear before a storage write. A retired surface only reachesStoreBackCoveringthroughDepthSurfaceStoreBack, so the newForgetClearcloses that gap. It's per aspect, so a pending stencil clear on D32S8 survives a depth write.Approving. Two small optional things:
NoteHtileDepthCleardrops the cached HTILE read, so the next bind rescans, sees ZMask 0 and notes the clear again. I checked it with a third case built from your helper, and it passes on the PR (2048 pass): That's the same setup asRetiredSurfaceCase: first draw, retire, then the lines above. It needsBlockBytesat 17 planes. Without it, a later change could drop the rescan and nothing would catch it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T05:42:40Z.
Review: COMMENTED
Reviewed — no blocking findings
StoreBackCoveringnow callsForgetClearfor the aspect it overwrites, so a fast clear noted before a whole-plane storage write no longer applies after the write. The one-line change matches the mechanism the PR describes. The new test cases are not run by the hosted Windows job, because the job'sANYPS5_AGC_EXECUTION_TESTSlist does not includeDepthSurfaceFromStorage, so the test builds as a skip stub. The GPU and game results in the PR body are the author's and were not checked here.What I ran
3755dd3610ffdb9317ef03bae18440ea2b1e0f1a; basee4501451406e4d3516c5b0eaa854d6ec1a28082d. 2 files, +18/-1:Graphics/src/DepthSurface.cpp(+1) andtests/execution/DepthSurfaceFromStorage.cpp(+17/-1).StoreBackCovering,DepthSurface.cpplines 723-736),ForgetClear(lines 497-498, which clearspendingClearbits), and the test diff (RetiredSurfaceCaseand its two calls inmain).windows, job 124888443425): the configure step setsANYPS5_AGC_EXECUTION_TESTS=F16ToF32Unpack;F64FmaSubnormals;RegistrationPrepareShutdown.Results
ForgetClearinStoreBackCovering)ApplyFastClear,SyncFromMemory, HTILE handling)ForgetClearandStoreBackCovering; the consumers ofpendingClearwere not readagc_driver_depth_surface_from_storage(hosted)ANYPS5_AGC_EXECUTION_TESTSlist, so it builds as a skip stubVUID-line)Read-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: not applicable. Stack check: passed. Hosted:
gh api repos/boykopovar/AnyPS5/commits/3755dd3610ffdb9317ef03bae18440ea2b1e0f1a/check-runs, and the log of job 124888443425.Negative control
Not run here. A negative control needs a GPU run or a build, and code from this head is not run here.
Findings
Blocking
None.
Non-blocking
DepthSurfaceFromStorageis not one of them, so the new cases build as skip stubs. If this test is meant to run on the Windows runner, it needs to be in that list. The only run of the new cases is the author's local Linux run, which is not verified here.Sources
github.com/boykopovar/AnyPS5@3755dd3610/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppgithub.com/boykopovar/AnyPS5@3755dd3610/core/libs/prx/libSceAgcDriver/tests/execution/DepthSurfaceFromStorage.cppgithub.com/boykopovar/AnyPS5@3755dd3610/core/libs/prx/libSceAgcDriver/CMakeLists.txt(lines 553-557)windows, job 124888443425Not verified
pendingClear(ApplyFastClear,SyncFromMemory, HTILE handling) and whether a pending clear also carries HTILE state thatForgetClearleaves alone.To get this to a good state
DepthSurfaceFromStorageto the WindowsANYPS5_AGC_EXECUTION_TESTSlist.