fix(agc): apply RADV's HTILE depth fast clears to the host depth surface #2229
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2229"
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 TheAggie on 2026-10-09T12:30:46Z.
What
A depth surface is a host image that AnyPS5 clears once, when it creates the image, to the DB_DEPTH_CLEAR value it sees then. RADV (and real hardware) clears depth differently: it doesn't touch the depth memory, it rewrites the HTILE metadata so every tile reads as "cleared" (ZMASK = 0), and the DB returns DB_DEPTH_CLEAR for those tiles. AnyPS5 doesn't model HTILE, so after the first frame the host depth image is never cleared again.
vkQuake (PPSA99010, the homebrew Vulkan port, through RADV) shows this as a black 3D view. It uses reverse Z (GREATER_OR_EQUAL, clear to 0.0), so the depth buffer keeps the largest depth of every earlier frame, and once the camera moves nearly every world draw fails the depth test. The HUD, the 2D draws and the post-process pass are unaffected.
DepthTargetcarries the surface's HTILE address (DB_HTILE_DATA_BASE / _HI) when DB_Z_INFO.TILE_SURFACE_ENABLE is set and the base register has been written. 0x005 and 0x01e are added toDrawKeyRegisters.clear_htile_maskcompute kernel (17 GFX10 words:htile = (htile & user[5]) | user[4]over the buffer at user[2..3]).HtileDepthClearAddressrecognizes it by its code and 64x1x1 groups, and returns the HTILE address when the update leaves ZMASK at 0. The dispatch still runs, so guest memory is unchanged.DepthSurfaceViewclears the depth aspect of that surface to the draw's DB_DEPTH_CLEAR the next time the surface is bound, throughRecorder::Commands()(which ends any open render pass) with barriers around the clear.HTILE initialization (ZMASK 0xf, "expanded") and the stencil-only update RADV issues alongside it are left alone.
Limits: this matches one RADV kernel. Fast clears done some other way (the SDK's own paths, CP DMA fills, stencil HTILE clears) aren't covered.
Tests:
DepthStencilTests: the HTILE address decodes from DB_HTILE_DATA_BASE and its high byte, is 0 without the base register or without TILE_SURFACE_ENABLE, and every register the decoder reads is inDrawKeyRegisters.htileDepthClearTests: the fast clear is recognized; HTILE initialization, the ZMASK-preserving stencil update, another group size, a changed kernel and a truncated kernel are not.Other open PRs touch the same files (#1684, #2076, #2169 in DepthSurface/State, #2095 in the Graphics tests); I'll rebase onto whichever lands first.
Tested
Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti (driver 610.88).
guest_sce_nettimed out (also when run alone; it doesn't touch the AGC driver, likely my local network filtering). It was run from the generatedCTestTestfile.cmakecommands because antivirus blocksctest.exeon this machine.tools/check_conventions.py --base origin/mainpasses.mainplus my open RADV PRs and some local stubs), so it isn't reproducible onmainalone.Not tested on Linux or macOS.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:24:52Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
dd5a5117, merged ontomaind70b8998in one build with 33 other AGC/shader PRs that had no Windows run.agc_driver_graphics. None of them reported skipping a case.PATHsetup.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:18:16Z.
Please rebase; it conflicts with main in
tests/Graphics.cpp.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T06:24:03Z.
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/include/DepthSurface.hppL17core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppL7-8, L53-60Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T06:48:54Z.
Checked on Linux (RADV host) on the rebased head: scoped build + ctest of libSceAgcDriver green,
agc_driver_graphicsandagc_driver_prepared_graphicspass, andagc_driver_graphicsfails if the ZMASK check onuser[4]is removed. I disassembled the 17-word kernel for gfx1030 and it ishtile = (htile & user[5]) | user[4]as described. Windows run by @popcoder565 also passes.Added by us on top of your rebase:
docs/dev/TechnicalDebt.md, "Functional": a line for the HTILE depth fast clear limits (only RADV's kernel, exact HTILE address match, no HTILE init / stencil / other fast-clear paths).Merging once CI is green.