fix(agc): sample resident depth surfaces when a stage-A texture record hits #1957
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1957"
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 orbz22 on 2026-10-09T02:16:01Z.
What
ShaderResources::fastTexture(the stage-B check for a stage-A image record) reused theTextures()cache entry for the descriptor without asking whether a depth surface is resident at the address.cachedTexturereturnsDepthSurfaceTexturebefore it looks at that cache; the fast path skipped that step.So once a guest-memory entry exists for a depth target's descriptor (made while no surface was resident there, or while it was retired), every later sampled read of the target takes the fast path and gets the guest-memory texture. The memory under a depth target is never written (the depth lives only in the Vulkan depth image), and
UnchangedSincekeeps proving that entry current, so the reads stay on it for good.fastTexturenow returnsnullptrwhileDepthSurfaceAt(address)finds a resident depth or stencil plane there. The lookup then falls back tocachedTexture, which asksDepthSurfaceTexturefirst.Found in Astro's Playroom (PPSA01325):
0x5002a8500, 240x135 groups over the 3840x2160 D32S8 target0x517370000) reduces each 16x16 tile's depth in LDS. It skips a tile when the max depth is <= 0 or the min depth is >= 1.APS5_NO_STAGE_A_IMAGES=1, or with this change, the classifier counts about 2900 tiles on the title screen and those objects are lit.DepthSurfaceTexturewas never reached for those dispatches before the change. After it, the lookup picks the same image the G-buffer pass draws into.0x50028e000, which feeds the game's AO and particle soft fade, read the same zeros.Related open PRs, no overlap in the changed lines: #1430 changes
fastRevalidate, the reuse proof of a whole set; this is the per-image record path. #425 and #454 changeDepthSurfaceTextureand depth surface retirement.Tested
Windows 11, WinLibs GCC 15.2, RTX 3060 Laptop:
agc_driver_tests,agc_driver_graphics_testsandagc_driver_recorder_testsbuilt on this branch; all pass.tools/check_conventions.py --base upstream/mainpasses.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
https://claude.ai/code/session_01UTjpbMX7BUFMZZaxJE98zV
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T02:21:32Z.
Review: APPROVED
Reviewed the full diff and the surrounding lookup paths. The regular cachedTexture path asks DepthSurfaceTexture before the guest-memory cache; this guard makes a stage-A cache hit take that same full lookup whenever the address belongs to a resident depth/stencil surface. DepthSurfaceAt is synchronized and checks both depth and stencil addresses. Current-main ancestry is exact. Upstream Build passed on Linux and Windows, along with Conventions; the PR also reports targeted AGC suites and a before/after Astro reproduction. No targeted automated regression test was added, so future coverage of this fast-path fallback would be useful, but the reported GPU reproduction and full CI provide good evidence for this focused change.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T02:53:56Z.
Review: COMMENTED
Verified on Linux, which checks the claim in code and re-runs the suites on a second device.
The claim, in code — confirmed.
cachedTextureasksDepthSurfaceTexturebefore it looks at the cache (ShaderResources.cpp:288), the diff adds exactly the one line to the fast path (if (DepthSurfaceAt(address)) return nullptr;), andDepthSurfaceAtis the same depth/stencil predicate already used for the storage-image refusal at line 567. So the fast path was the only route to a guest-memory texture that skipped the resident-surface question, as the body says.Your suites, on lavapipe (the author's run was Windows/NVIDIA):
That third one is not this change: with the guard reverted to
main, everything else identical, it fails the same way —AGC graphics: the partial publish did not copy exactly the partly covered unit, exit 1. Pre-existing and lavapipe-only (it is the same assertion I ran into verifying #1046), so it should not hold this up.Not verified here: the effect. There is no Astro's Playroom dump on this machine, so the title evidence — the tile classifier counting ~2900 tiles, the lit objects, the GDS counters — stands on the author's setup. Worth saying plainly, because for a one-line change with no test that evidence is the whole proof. A test that asserts "the stage-A fast path refuses while a depth surface is resident at the address" would make it self-protecting.
Related-PR check: no changed-line overlap. #1430 touches
DepthSurfaceTexturecall sites but notfastTexture; #425 and #454 touchDepthSurfaceAtcall sites (storage images,RetireDepthSurfaces) but not this guard. They do share the predicate, which is the same source of truth, so they should compose rather than conflict.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-09T04:36:44Z.
Linux results, since this was tested on Windows only. Everything passes here.
Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
BUILD_TESTING=ON. This PR merged ontomainf1451396cleanly.mainf1451396main+ this PRctest -R agc_driver -j1-E agc_driver)The CPU failure is
guest_dynamic_loader, which fails the same way onmain.Imported from boykopovar/AnyPS5. Originally posted by orbz22 on 2026-10-09T05:17:15Z.
A side effect I found running Astro's Playroom further in, after opening this PR:
DepthSurfaceTexturealso sees reads that don't match it.0x5001c6a00samples the shadow memory at0x529430000as a 1536x1536 2D array (guest format 7, R16 unorm). The surface resident there is still the earlier 2048x2048 D16 one.ValidateSampledthrowssampling the depth plane of depth surface 0x529430000 (2048x2048, vk format 124) as a 1536x1536 texture ... is not implemented, and the title aborts.mainthis read goes through the slow path whenever no stale cache entry exists, so the same throw is already reachable there. This change only removes the stale entry that was hiding it.DepthSurfaceTexturetreat an other-shaped view as reused memory. With that rule (applied locally, plus preferring a resident surface of the sampled extent when several share the address), the scene runs on to the in-game DualSense platform with correct lighting.I kept this PR to the fast-path check. The shape rule is #1495's topic.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T11:24:33Z.
The reachability half checks out in the code, and it is worth putting on the record because it is what makes this a known gap rather than a regression from your PR.
The throw you quote is at
DepthSurface.cpp:98, inside the depth-resolution path, and its only public caller isDepthSurfaceTexture(DepthSurface.cpp:166), called fromShaderResources.cpp:389— the single file this PR changes. So the fast-path check and the throw sit in the same call chain, and onmaina cold cache reaches the same function with the same mismatched shape, which is exactly the sequence you describe. I have not run PPSA01325 here, so I am confirming the path, not the run.Two things I would keep as they are. Reporting that your change exposes an existing throw rather than causing one, with the
maincomparison, is the difference between a side effect and a regression — and a reviewer can act on it either way. And keeping the shape rule in #1495 rather than folding it in here means each PR can be judged on one change; a PR that fixed both would hide which edit did what.Written with AI assistance.