feat(libSceAgcDriver): storage image access to depth surfaces #4500
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4500"
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 ee6aba54 on 2026-10-12T13:39:50Z.
What
Compute shaders bind the depth and stencil planes of a depth surface as storage images, to read the depth or to write it before later draws test against it. The driver kept depth on the GPU and refused such bindings ("storage image access to depth/stencil surface ... is not implemented").
A depth surface now owns one storage image per plane (
R32_SFLOATorR16_UNORMfor depth,R8_UINTfor stencil). Binding applies a pending fast clear and copies the plane into the storage image through a staging buffer (the depth image is created withVK_IMAGE_USAGE_TRANSFER_SRC_BITfor that copy); a written element is copied back into the depth image during write-back, so the next draw sees the shader's depth. A view of another extent, or of a format that is not the plane's, takes the ordinary texture path, asDepthSurfaceAtalready decides for sampled views; a view of another level still throws.A
D16_UNORM_S8_UINTsurface that the device stores asD24_UNORM_S8_UINTorD32_SFLOAT_S8_UINTholds 4 bytes per depth texel, so a storage view of its depth plane throws, naming both formats; its stencil plane is supported.This is the storage counterpart of the depth copy that comparison sampling takes since
d024709cf. The refused binding is the stop reported in #1409 (PPSA10112); that title is not tested here.Tested
1c5e62878.ctest: 996 tests pass.agc_driver_depth_storage(RTX 5080) checks both copy directions for depth and stencil, the reuse of the storage image, the fall-through for another extent or format and the refusal of another level;agc_driver_depth_storage_reuseandagc_driver_depth_compare_copystill pass.agc_driver_graphics: on a device withoutD16_UNORM_S8_UINT, a storage view of the depth plane of a D16 surface with stencil throws.D32_SFLOAT_S8_UINTtarget through storage images every frame; the dispatch that stopped the title now runs, and together with #4586 and layered rendering into 3D color targets (the change #1077 proposes) the title reaches its main menu.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 xXPBSXx on 2026-10-12T14:51:12Z.
Windows build of head
dfa876696merged onto currentmain(d592d54e1, clean merge): Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. The driver andagc_driver_graphics_tests,agc_driver_depth_storage_reuse_testsandagc_driver_depth_compare_copy_testsbuild, but the new test does not compile:std::aligned_allocis not provided by the MinGW-w64 C runtime. The neighbouring tests avoid it (DepthStorageReuse.cppusesalignas(4096) std::arrayfor the guest memory); a 64 KiBalignasarray or a platform switch to_aligned_malloc/_aligned_freewould build on both systems.std::freeat line 249 would have to follow, since memory from_aligned_mallocneeds_aligned_free.Not run: the GPU tests (
agc_driver_depth_storage,agc_driver_depth_storage_reuse,agc_driver_depth_compare_copy) are waiting for the machine to be free; I will post their result here. Related: #425 also addresses #1409 (sampling and storage access to depth surfaces) and breaksagc_driver_depth_storage_reuseonmain(https://github.com/boykopovar/AnyPS5/pull/425#issuecomment-6125624406); the two PRs overlap inDepthSurface.cppandShaderResources.cpp.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-12T15:34:16Z.
@ee6aba54 I ran the stencil test from my follow-up to #425 against this PR (
dfa87669, merged withmain). It passes on Intel Arc (Mesa 26.2.3 ANV) and lavapipe, and on plainmainit fails withstorage image access to depth/stencil surface ... is not implemented. The other depth tests (depth_storage,depth_storage_reuse,depth_compare_copy,depth_fast_clear*,depth_bias_per_face,stencil_ref_export) pass on both devices with this PR.It checks the one path
DepthStorage.cppdoesn't: a stencil plane written through a storage image, and seen by the next draw's stencil test. On a D32S8 surface:It's a single file,
tests/execution/DepthStencilStorage.cpp(agc_driver_depth_stencil_storage), onThatsLeo/AnyPS5:feat/agc-depth-stencil-storage-v2. Take it into this PR if it's useful.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-12T16:07:59Z.
For coordination: #425 had a storage path for depth surfaces too. I've taken it out, so storage access to depth surfaces is this PR's alone. #425 now only samples depth planes as 2D arrays, cubes and R16_UINT views (
DepthPlaneCopy). The two still touchDepthSurface.cpp, but in different functions (DepthSurfaceTextureand its copy class there, the storage seed and take-back here). One point to check against this PR: #425's copy needsVK_IMAGE_USAGE_TRANSFER_SRC_BITon the depth image as well.Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-12T16:22:45Z.
Thanks for the reviews. Updated to
0d32f7e00, rebased onto2a5eca11c:std::aligned_allocandstd::freeare gone.VK_IMAGE_USAGE_TRANSFER_SRC_BIT.DepthStorage.cppdoes not. I would rather not take another author's file into this PR; it fits well as a follow-up of yours once this merges.ctest: 960 tests pass on Linux (RTX 5080).Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-12T22:34:20Z.
Updated to
cdfba5144, rebased onto5efd09afc:mainnow storesD16_UNORM_S8_UINTasD24_UNORM_S8_UINTorD32_SFLOAT_S8_UINTon devices without it. Copying the depth aspect of such a surface yields 4 bytes per texel, so a storage view of its depth plane now throws, naming both formats; the stencil plane is unaffected.agc_driver_graphicschecks the refusal on a device without the 16-bit format.ctest: 993 tests pass on Linux (RTX 5080).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-12T22:41:15Z.
Data point from a title we test with, on
main682ef0c1with the head before cdfba5144: onmainit stops before its title screen atstorage image access to depth/stencil surface 0x53a500000 is not implemented (storage=960x540 guest format=22 mip=0 dimension=1 tile=4), compute shader0x50073d500. With this PR it gets past that and stops at the depth plane sampling refusal that #425 covers. With both, 330 s with no stop, error line or device loss.Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-13T00:33:22Z.
Rebased onto
1c5e62878(#425 merged):ac2ffc48f. The conflicts were adjacent additions inDepthSurface.cpp(theDepthPlaneCopyclass next toStorageandStoreBack) and inDepthSurfaceReuse.cpp(both D16 checks are kept). No change to the code of this PR.ctest: 996 tests pass. @jdmagic #2076 needs the new head as its base.Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-13T00:41:31Z.
Windows data point: Windows 11, WinLibs GCC 15.2.0, Release, RTX 5070 Ti. This PR as is (
cdfba5144), plus #4491 and a local CMASK fix to get that far.The Pathless (PPSA01825) reaches a compute dispatch that writes the stencil plane of a 256x256
D32_SFLOAT_S8_UINTdepth target: oneIMAGE_STORE(dmask 0x1) through a one-layer 2D-arrayR8_UINTview, tilekZ64KBX, HTILE without stencil. Onmainit stops there withstorage image access to depth/stencil surface ... is not implemented (storage=256x256 guest format=5 mip=0 dimension=2 tile=4). With this PR it gets past it in 4 of 5 runs and next stops atcolor views of several array slices are unsupported(#2102). The fifth run ended earlier in an intermittent segfault in the title's own code that also happens without this PR.Update: with head
ac2ffc48fand #3763 (53dae55dc), both onmain758aca737, LEGO Horizon Adventures (PPSA14632) gets past its 2112x1188 depth-plane storage stop (#1409) in 5 of 5 runs and plays its intro; one run faulted in the title, as it also does with #3763 alone.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-13T00:57:03Z.
Astro's Playroom (PPSA01325) data point for head
ac2ffc48f, Linux, RTX 5080.On
main1c5e62878it enters its first level, renders 34 frames in 80 s and then stops withcompute shader 0x50028e000: AGC graphics: storage image access to depth/stencil surface 0x54d420000 is not implemented (storage=1920x1080 guest format=22 mip=0 dimension=1 tile=4).With this PR merged onto
main284a1c334the stop is gone in four of four runs of about four minutes each (all with a local frame-capture patch, two also with an unrelated local driver change), and the frame I captured in the level's opening scene renders correctly. It is slow there: 0.4 to 0.8 fps,Graphics::Drawat 300 to 520 us per draw packet underAPS5_PROFILE_DRAW=1. I have not looked at where that time goes, so I can't say whether this PR has a part in it.agc_driver_depth_storageandagc_driver_depth_storage_reusepass on RTX 5080, Radeon 610M (RADV) and lavapipe, onmain4430780bdplus this head.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T01:38:02Z.
Pushed two commits on top of your rebase (848b97b611), fast-forward, yours untouched:
26dfc464a7: three cases the plane copy cannot serve now throw instead of going through. A storage view that is not 2D throws main'sstorage image access to depth/stencil surface ... is not implemented, as before this PR; a store to a multisampled depth surface throws; andStoreBackthrough a view that another view of the same plane replaced throws, since its writes would be dropped. The debt entry lists them.848b97b611:agc_driver_depth_storage_dispatch, which goes through dispatches: depth and stencil stores read back by depth- and stencil-tested draws and in guest memory after the flush, plus the three refusals.agc_driver_depth_storagealone still passed with the twoDepthSurfaceStoreBackcalls removed.Linux, RTX 4090:
ctest -R "agc|shader"463/463, validation layer clean on the depth tests, and the new test passes on llvmpipe. Not built on Windows.The 2D-array case is the one The Pathless (PPSA01825) hits in the Windows report above, so it stops there again until one-layer array views are handled; that is a separate change.
This will conflict with #2491 in
DepthSurface.cpponce that is merged. I'll rebase it then;StoreBackalso has to bump the write serial there.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T02:39: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)docs/dev/debt/libSceAgcDriver.mdL28-30docs/dev/debt/libSceAgcDriver.mdL28-30