fix(agc): count pending storage writes over a depth plane as a later writer #10854
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10854"
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-25T05:22:39Z.
What
Forspoken (PPSA03984) sometimes stops in its opening on:
It happened in 2 of the 19 runs I made today: one on
main52a8bed576, one on a branch that does not touch this code. Across the 196 Forspoken runs I have logs of, it happened 3 times. The T# describes a 5-level R32 float chain (MAX_MIP4,SW_64KB_R_X) at the base of the title's single-level 1920x1080 D32 depth surface. The title builds that chain with compute passes, which write it as storage images (levels0-0,1-1and so on), and then samples it whole. The depth plane cannot serve that view.DepthSurfaceTexturefollows a last-writer rule, pinned byagc_driver_depth_surface_last_writer. While the depth surface is the last writer of its memory, a view its plane cannot serve is refused. Once a later write lands in the plane, the surface is retired and the view is read from guest memory. Only writes the CPU can see counted, though. The chain passes are a later writer too, but their results stay pending in storage images until something flushes them. When the title sampled the chain before they were flushed, the surface still looked current, so the view was refused.A diagnostic build logged the 5-level view 13 to 35 times per 250 s run. Each time, pending storage results overlapped the plane (the chain's
1-1storage image at the base). In those runs they had already reached memory, so the surface was retired. The stop is the same sample taken before they reached memory.How
DepthSurface::OverwrittenOnGpu(): whether a storage image with pending results overlaps the depth or stencil plane (StorageTexture::AnyPendingOverlaps).DepthSurfaceTexture: the branch that retires the surface (storing what the plane holds that memory lacks) and leaves the view to guest memory now also takes a view the plane cannot serve whenOverwrittenOnGpu()holds, as it does when the plane's memory was written. Every view the plane serves, and every refusal while nothing else writes the plane, is unchanged.Tested
main951f374c87asc1db5c5b37, after #12207 changed theplanesline inDepthSurfaceTexture(cube arrays). The resolution keeps #12207's line and this PR'sOverwrittenOnGpu()condition, andgit range-diffshows only that context change. On this head, the 45 tests matchingdepth|^agc_driver_graphics$|sampled_cache_budget$pass 3 of 3. Khronos validation 1.4.363 over the same 45 passes 45 of 45 onmain951f374c87and on this head, with 42 Vulkan devices created on each, noVUID-message and no layer-missing line.bd0f124c89, test only, from XairRrR's review): a new case draws depth 0.5 that is only on the GPU, writes level 1 of the chain, then takes the view, which retires the surface, and flushes. Level 1 in guest memory matches a run without the depth write, and level 0 holds the drawn depth.agc_driver_depth_surface_from_storageandagc_driver_depth_surface_last_writerpass 3 of 3.Linux: Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, NVIDIA 615.71.09, on
maine7e3e9c198.Red/green:
agc_driver_depth_surface_from_storagegainsPendingChainCase:With only the test on
main(43ce466d69) it fails 3 of 3 with the title's message (sampling the depth plane of depth surface ... (64x32, vk format 126) as a 64x32 texture of guest format 22 (vk 100), tile mode 4, dimension 1, levels 0-1, slice 0 is not implemented). With this change it passes 3 of 3.Focused tests: the 38 tests matching
depth|^agc_driver_graphics$|sampled_cache_budget$pass 3 of 3, includingagc_driver_depth_surface_last_writer,agc_driver_depth_plane_samplingandagc_driver_depth_plane_guest_layers, which pin the refusals and the plane-served views.Khronos validation 1.4.363 over the same 38, each arm run as
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R "$R" -V -j4: 38 of 38 pass onmaine7e3e9c198and on this head. Neither log has a layer-missing line or aVUID-message. Correction (10-27): not all of these tests put the layer to work. On currentmainthe regex matches 39 tests, and 29 of them create a Vulkan device (counted fromPhysical device selectedper test). The 10 that run on a test fixture's own device and never load the layer areagc_depth_copy_kept_bytes,agc_depth_range_remap,agc_driver_depth_bounds_emulation_draw,agc_driver_depth_bounds_state,agc_driver_depth_plane_guest_layers,agc_driver_depth_storage,agc_driver_depth_surface_last_writer,agc_driver_graphics,agc_driver_sampled_cache_budgetandagc_driver_unused_viewport_depth, so the clean result doesn't cover those.Windows 11 VM (GT 1030, driver 582.78, WinLibs GCC 15.2.0 r7), the same regex: 37 of the 38 pass 3 of 3 on the merge base
e7e3e9c198and on this head alike, includingagc_driver_depth_surface_from_storagewith the new case. The other one,agc_driver_depth_plane_partial_store, fails the same way on both (repeated lookups of the first layer of an unchanged array proved no refresh), so it is not caused by this change.Forspoken: 4 runs of 250 s on this change plus a report line in both branches of the decision (not part of this PR), warm, 16G, pad input. All 4 ran to the timeout. The 5-level view was retired 1, 3, 3 and 6 times, always through the existing written-in-memory path, so the stop's race didn't come up in those runs. It is rare: 2 stops in today's 19 runs on code without this change. The case it fixes is the one the new test builds.
AMD, Linux (tablefrogpillow, RADV, Mesa 25.2.8): RX Vega 56 (GCN5), RX 7900 GRE (RDNA3) and the 7800X3D iGPU (RDNA2).
agc_driver_depth_surface_from_storagepasses on all three with the Khronos layer on. The 787 shader/AGC tests fail identically on this head and the merge base (4 pre-existing GCN5 float tests). WithDepthSurface.cppreverted and the new test kept, the test fails.AMD, Windows (brummilab, RX 6600 XT, driver 32.0.21045.16010, WinLibs GCC 15.2.0 r7): the same 38 under the Khronos layer, 37 of 38 on
maine05ba6feeand on the merge with this head, 0VUID-messages on either. The one failure on both isagc_driver_depth_plane_partial_store(#10664).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 MarcZX10 on 2026-10-25T05:34:09Z.
Review: APPROVED
Reviewed exact head bddb3093f6c32ef193cb01a17127f51c23506977 against current main
e7e3e9c. The new predicate queries pending and currently-flushing storage textures against both depth and optional stencil address ranges; it only participates when the cached depth plane cannot serve the requested view, preserving the existing supported-view path. On a later overlapping GPU write, the existing stale-plane retirement/store path runs before refusing the depth-plane import, allowing the texture path to use guest memory. The new regression writes and flushes a mip-chain storage image, draws a depth surface over that memory, leaves another level write pending, then verifies the incompatible multi-level view is not served by the stale depth surface and that the surface retires. The PR reports focused Linux/Vulkan-validation and Windows tests, plus a stated baseline-identical Windows failure; these are author-reported. I independently ran the conventions checker and diff whitespace check on this exact head; both pass. GitHub conventions/intake/labels/eligibility/report pass; product jobs are skipped. I found no blocking issue in this focused change.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T04:14:26Z.
Review: APPROVED
Reviewed — approved
The change merges cleanly onto current
main, the focused depth tests pass under the Khronos layer with no newVUID-messages, and revertingDepthSurface.cppmakes the newPendingChainCasefail with the title's message; one non-blocking gap in test coverage is noted below.What I ran
bddb3093f6c32ef193cb01a17127f51c23506977main:b433c40f2f46aa2e59e19806010a839ac8572d64(merge base of the PR:e7e3e9c1984c293f06bff08428b8c89b7b932ac2)main+ PR head with--no-ff, in a clean worktree. Release, GCC 16.2.1, Ninja.Results
mainDepthSurface.cpp)git diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.mainmain, Khronos layerVUID-lines, merged tree /mainwas not found but was requested by env var VK_INSTANCE_LAYERSVK_LAYER_KHRONOS_validationagc_driver_graphics)agc_driver_depth_surface_from_storagerun timeMerged tree, ctest excerpt
Probe output, merged tree
With
APS5_TRACE_FLUSH=1, the last flushes for plane 8 are:No
depth plane storeflush appears, so the retire inPendingChainCasestores nothing from the depth plane.Negative control
I restored only
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppfrommainand kept the PR's test.agc_driver_depth_surface_from_storagefailed in 3 of 3 runs:Failure
This is the failure the description gives for
main. It matches tablefrogpillow's revert check on RADV.Findings
Blocking
None.
Non-blocking
The new case does not cover a retire that stores stale depth units under pending results. The new condition at
DepthSurface.cpp:2385sends a surface toretireStoringStalewhen results are pending on the GPU. That function was written for the memory-written case. AtDepthSurface.cpp:1826-1832, it leaves out only the units thatWrittenUnitsreports as written in guest memory. Results still pending in a storage image are not in memory yet, so their units stay inunits, andStoreDepthPlanestores the older depth contents for them. TheFlushPendingatDepthSurface.cpp:1836then writes back both the chain image and the mirror. It collects them in pending-list order (Texture.cpp:4229-4249) and stores them in that order (Texture.cpp:4298-4305). The mirror joins that list during the retire, after the chain image, so where their texels overlap, the older depth data would be written last.I could not show this going wrong. In
PendingChainCasethe surface has no stale units at the retire: the trace shows nodepth plane storeflush, and the chain's 32 level-1 texels are intact afterwards. The case therefore pins the refusal and the retire, but not what guest memory holds after a retire whose surface has unstored depth.Suggested follow-up: add a case where the drawn depth is still only on the GPU when the view is taken, then check the chain texels in guest memory after the flush. If they are lost, leave out the units that
StorageTexture::AnyPendingOverlapsreports, or store the plane before the pending images are written back. This is the title's situation if the chain is built while its depth is unstored, so it is worth confirming before relying on the retired view's contents.Not verified
SW_64KB_R_Xlayout, where the chain's levels lie inside the depth plane's bytes.agc_driver_graphicsdid not load the validation layer on either side, so its cleanVUID-result does not cover it.depth|...regex (for example the multisample, native-depth and depth-bounds ones) or any AMD or Windows configuration.main, but I did not check the two PRs against each other.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T05:37:28Z.
Review: APPROVED
Re-checked — approved
The only new commit,
bd0f124c89, adds the test-onlyRetireStoresDepthCasein answer to my earlier non-blocking finding. The production change is unchanged and still merges, builds and passes under the Khronos layer on currentmain. The new case does not check what its description says, though; details are under New findings (non-blocking).What changed since my last review
bd0f124c89(test(agc): a retire that stores depth drawn on the GPU keeps the pending chain over it). It touches onlytests/execution/DepthSurfaceFromStorage.cpp: it addsRetireOverPendingChain/RetireStoresDepthCaseand grows the test block from 9 to 11 planes.What I ran
bd0f124c890381d21433494e3c7837a5534cc089(previously reviewed:bddb3093f6c32ef193cb01a17127f51c23506977)main:52c09d567d2fa453494dd720fcf53a98149468e4main+ PR head with--no-ff, in a clean worktree. Release, GCC 16.2.1, Ninja.Results
mainDepthSurface.cpp)git diff --checktools/check_conventions.py --base origin/mainAll conventions checks passed.main, Khronos layerVUID-lines, merged tree /mainwas not found but was requested by env var VK_INSTANCE_LAYERSagc_driver_graphics)agc_driver_depth_surface_from_storagerun timeanyStale=0 mirrorable=0at the retirelevel1 texels 16384 differ 0; level0 texels 16384 at 0.5 0; disjoint 0anyStale=0 mirrorable=1at the retire; adepth plane storeflush runs before it; 2048 level-1 texels differ (0.25 → 0.5), the new case failsProbe (c) output (swizzle 24), drawn plane, two runs
Run with probe (a) and
APS5_TRACE_FLUSH=1:Run with probe (b):
Negative control
I restored only
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppfrommain. WithPendingChainCasein place the binary stops there first, so I also disabled that call for this run.RetireStoresDepthCasethen failed 3 of 3, atDepthSurfaceTexture:So the new case needs the fix, but it fails on the same refusal
PendingChainCasealready pins, before reaching its own guest-memory checks.Previous findings
FlushDepthPlanes(DepthSurface.cpp:2078, flush reasondepth plane storeat L2136) beforeretireStoringStaleis entered. At the retire,AnyStale()is false, so the ordering I described cannot arise. The chain row and the drawn 64x32 depth were both in guest memory afterwards. In the PR's own configuration the path is never reached at all (see New findings 1), so this conclusion comes from my probe, not from the committed test.New findings
Blocking
None.
Non-blocking
RetireStoresDepthCasepasses without checking the drawn depth, and does not reach the store path it is named after. The description says "Level 1 in guest memory matches a run without the depth write, and level 0 holds the drawn depth". On this tree, neither half holds:Plane()(DepthSurfaceFromStorage.cpp:152-153), which leaves the harnessswizzleat its default 0 (DepthFastClearHarness.hpp:44).mirrorable()requiresSW_64KB_Z_X(DepthSurface.cpp:1778-1779), soretireStoringStaletakes its plainretirebranch (L1818-L1819). Probe (b) shows that none of the 16384 texels of the plane hold 0.5 after the flush, so the drawn depth never reaches guest memory in this case.DescribeSurfacegives both levels the same 64 KiB range (disjoint 0in probe (b)). The level-0 check is skipped byif (!stored.disjoint) return;(L234). The "level 1" comparison at L233 compares the whole plane. It is equal only because no depth was written in either run.Why it matters: the case adds a guest-memory claim to the Tested section that the test does not check, and a future regression in that path would not fail it. Suggested fix: draw with
swizzle = 24so the surface is mirrorable and matches the T#. Compare only the texels the chain dispatch writes (the rowStoreRowstores at level 1), and check the drawn texels for 0.5, instead of relying ontiledOffset/tiledSizeranges that overlap here. Also drop the silentreturnwhen the ranges overlap, so the depth check always runs. Then correct the Tested line to match.Not verified
FlushDepthPlanesstore before the retire in probe (c). I saw it in the flush trace beforeretireStoringStale, and did not trace the call stack.agc_driver_graphicsdid not load the validation layer on either side. I did not run the full suite or the other tests matching the description's regex.