fix(agc): take a storage image's writes to the stencil plane when a depth target binds #12617
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12617"
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 milescoviello on 2026-10-28T23:02:49Z.
What
A title can write a depth target's stencil through an 8-bit storage image over the target's stencil plane: a compute or pixel shader stores
R8_UINTtexels atstencilAddress, and later draws stencil-test against that depth target.DepthSurfacetakes a pending or live storage image's writes into its depth plane when it is created (TakeStorage), but not into its stencil plane. So the stencil test read whatever the stencil aspect held before: the clear, or an earlier frame's stencil.Ghost of Tsushima Director's Cut (PPSA02225 02.024.000) does this in its opening. I counted it with a local diagnostic: in a 910 s run, a one-sample D32S8 depth surface bound over a pending
R8_UINTstorage image of its whole stencil plane 400 times (265 at 3840x2160 and 133 at 1920x2160 planes, plus one other).This is a different path from #12210, which keeps a stencil plane coherent with guest memory written by buffer copies. Here the writes are a storage image's and are still on the GPU. The two merge cleanly together.
How
DepthSurface::TakeStencilStorageruns when a one-sample depth target with a stencil plane binds. It finds a pending (or live) storage image atstencilAddressof the plane's size, with the plane's extent and anR8_UINTorR8_UNORMformat, and copies it into the stencil aspect with the existingcopyPlane. It does this only when that image's content version is newer than the one it last took, so a draw with no new storage write between binds doesn't copy again. Multisampled targets and other storage shapes are left as before.Tested
The lines below name the head they ran on, or were run before the 11-02 rebase onto
maind2ce337078. For the rebased heade056b23d28, the area tests and the paired validation-layer comparison are in this comment.Head
f6355144d9: rebased ontomain673fa865f4after #10854 merged. Both PRs add cases toDepthSurfaceFromStorage.cpp. The block is now 15 planes; #10854's cases keep planes 8–10 and this PR's move from 9–12 to 11–14.StoreRowkeepsmain'slevelargument, through this PR's sharedStorehelper.^agc_driver_depth|^agc_driver_native_depth|^agc_driver_stencil|^agc_driver_storagepass 3 of 3.main673fa865f4and this head: both pass 2 of 2, with no missing-layer message, the 1 device checked on each side and noVUID-messages.Earlier, at
123b2741d9(after oneandonlydean's review: only pending storage images are taken, and the scan waits for a write to an 8-bit storage image):^agc_driver_depth|^agc_driver_native_depth|^agc_driver_stencil|^agc_driver_storagepass 3 of 3.main319621ba2eand this head: both pass 2 of 2, with no missing-layer message, the 1 device checked on each side and noVUID-messages.Earlier, at
bd1c1ffd90:Linux (Ubuntu 26.04.1, GCC 15.2), RTX 4070 Ti (NVIDIA 615.71.09), on
main319621ba2e:agc_driver_depth_surface_from_storage. AnR8_UINTstorage write of 1 over a D32S8 target's stencil plane, then a draw with stencilEQUAL 1:EQUAL 0on the cleared plane;main(dde951ef46) fails the first case:... tested EQUAL to the stored 1: 0 pixels passed, expected 32. At this head (bd1c1ffd90) the cases pass.^agc_driver_depth|^agc_driver_native_depth|^agc_driver_stencil(40 tests) pass 3 of 3.VK_LAYER_KHRONOS_validation1.4.363, LunarG SDK), onmain319621ba2eand at this head:VK_LAYER_PATH=<sdk>/layers VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_depth_surface_from_storage$|^agc_driver_depth_surface' -Vwas not found but was requested by env var VK_INSTANCE_LAYERS.agc_driver_depth_surface_from_storageon each side (agc_driver_depth_surface_last_writercreates none), with noVUID-messages.Windows 11 VM (GeForce GT 1030, WinLibs GCC 15.2, Release):
agc_driver_depth_surface_from_storageandagc_driver_depth_surface_last_writerpass 3 of 3 at this head and onmain319621ba2e.AMD RDNA 2 on RADV, by @crastinator (comment): RX 6700 XT, Mesa 26.2.5, head
e056b23d28merged ontomain98346b748c.tools/vulkan_validation_gate.pyover^agc_driver_depth|^agc_driver_native_depth|^agc_driver_stencil|^agc_driver_storage(57 tests, 3 iterations per side) passes on both sides with noVUID-messages, andmainwith only this PR's test fails the new case 3 of 3.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