fix(agc): render partially resident depth and stencil planes whose pages are all mapped #16644
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16644"
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 freneza on 2026-11-07T12:20:36Z.
What
DecodeStaterefused every depth or stencil plane withPARTIALLY_RESIDENT(bit 12 ofDB_Z_INFOorDB_STENCIL_INFO):That bit only changes how the DB treats pages that are not mapped. So a plane with it whose every page is mapped renders like any other plane, and this change lets it render.
DecodeStatenow marks the plane (DepthTarget::depthPartiallyResident,stencilPartiallyResident) instead of refusing it. The mark needs the plane: a depth format or a stencil plane.DepthSurfaceViewchecks residency each time it binds the plane, not at decode. Draw decodes are cached by their registers, and a title can unmap pages between two draws with the same registers. The check covers the range the driver reads and writes: the depth plane and its HTILE, and the stencil plane, each throughGuestMemory::DescribeCommitted.... with pages that are not mapped is unsupported). What the depth and stencil tests read from such a page, and whether a write to it lands, is not modeled.docs/dev/debt/libSceAgcDriver.mdrecords it.Where this was found. PPSA01317 (01.710.000) draws into a 2304x2304 D16 plane at
0x2900000000, withDB_Z_INFO = 0x80001181and no stencil or HTILE. A local log showed the following:sceKernelSetPrtAperture(0, 0x2900000000, 0x100000000).sceKernelBatchMap, from0x2900000000to0x2900a20000, exactly the plane's0xa20000bytes.DescribeCommittedreported the whole plane as mapped, in one run.This replaces #14173, which GitHub refuses to reopen (
Could not open the pull request) after the open PR limit closed it.Tested
Linux (Bazzite 44, Fedora-based), GCC 16.2.1, Release,
BUILD_TESTING=ON.New tests:
tests/Graphics.cpp:DecodeStatemarks aPARTIALLY_RESIDENTdepth plane and stencil plane, and doesn't mark a plane without the bit.tests/DepthSurfaceReuse.cpp(TestPartiallyResidentPlanes), over real memory with pages left unmapped:PARTIALLY_RESIDENTstill renders.Focused tests with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(loader output confirmsVK_LAYER_KHRONOS_validationis inserted),ctest --test-dir build-test -R '<pattern>' -V -j1, onmain4977f64052and on this change merged onto it (20a0a6450d). The pattern isagc_driver_graphics,agc_driver_depth_bounds_state,agc_depth_copy_kept_bytes,agc_driver_unused_viewport_depth,agc_driver_depth_plane_.*,agc_driver_native_depth_.*andagc_driver_depth_surface_last_writer.VUID-lineswas not found but was requested by env var VK_INSTANCE_LAYERSmainPPSA01317 on a local branch of
main92d2fdc343with the GPU pull requests listed in #4697 and this change draws past the point where it used to stop onpartially resident depth. It now stops in two refusals that are not this one:0x120aed7f00, whose table holds 140 distinct targets (limit 64).the depth target's sample count differs from the rasterizer's, when entering one of the areas the World Map opens (#14861).That game run predates the merge of current
main; the focused tests above are from the merged head.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-07T13:03:07Z.
Review: APPROVED
Windows check of head
20a0a6450d, merged ontomain4977f64052(clean merge). The PR was tested on Linux only, so this is the first run of the_WIN32branch of the new fixture (VirtualAllocreserve, then commit page by page).Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release,BUILD_TESTING=ON. Both GPUs, selected withANYPS5_GPU: an RTX 5070 Ti (driver 621.01) and the Ryzen 7 7700X's integrated Radeon (AMD 26.10.2).ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.Full
^agcsuite (1,406 tests,-j 8):mainThe same tests fail with and without this PR, and they fail on
mainon this machine:agc_driver_quad_pixel_maskon the RTX (#14341), andagc_driver_scratch_pool(#15566) andagc_driver_sample_order_grid_reference(#9503) on the Radeon. NoVUID-lines and no missing-layer lines in any run.agc_driver_graphics, which runs both new test blocks, passes on both GPUs.Red checks,
agc_driver_graphicson both GPUs with the PR's tests kept:main'sDepthSurface.cpp(no residency check), it fails witha partially resident depth plane with an unmapped page must be refused.main'sState.cpp(the decoder refuses the bit), it fails withpartially resident depth (DB_Z_INFO) is unsupported (register 0x10 = 0x80001180).So each of the two production changes has a test that catches its removal.
Reading the code:
Draw.cpp,DepthSurfaceViewWithStencilWriteIntentat 3330 and 4142). A replayed draw with unchanged registers therefore still checks residency, which is the case the description gives for checking at bind rather than at decode.ClaimMultisampleTargetMemory, so a refused plane claims nothing.State.cpp:2491), as the description says.tools/check_conventions.py --base mainpasses.Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T14:27:56Z.
Review: COMMENTED
Ran
20a0a6450dmerged onmain302864d48con Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.368),ctest -R '^(agc_driver_graphics|agc_driver_depth_surface)' -V.mainmain'sState.cppmain, because they use the newDepthTargetfields. For the middle column I kept the PR whole and put backmain'sState.cpp, which refuses thePARTIALLY_RESIDENTbits and doesn't decode them.agc_driver_graphicsfails on both GPUs with "partially resident depth (DB_Z_INFO) is unsupported (register 0x10 = 0x80001180)". With it, the test passes every time.agc_driver_depth_surface_from_storageand_last_writerpass in all three builds. They open the real device: the layer was inserted in each, no log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has aVUID-.agc_driver_graphicsruns againstMockVulkan, so the layer doesn't apply to it.Not covered here: a plane whose pages aren't all mapped, where the new
RequireinDepthSurfaceViewWithStencilWriteIntentthrows. These tests only map whole planes.AI-assisted: yes.