fix(agc): keep an unstored depth or stencil plane out of an import rewatch #22508
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22508"
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 relativespace2K on 2026-11-17T18:17:15Z.
What
rewatchSettledImportscan return a settled host import to the write watch while a depth surface over that memory still has a pending clear or stencil fill. The rewatch then proves the plane unchanged from guest memory, and the pending depth or stencil result is dropped. This is the Windows regression thatagc_driver_stencil_plane_memoryreports asa consumed stencil clear was lost on a read-only rebind; it passes withAPS5_NO_REWATCH_UNDER_IMAGES=1orAPS5_NO_DEFERRED_SETTLES=1onmain.The new
DepthSurfacePendingResultsOverlapreports whether a range overlaps a live depth surface with unstored depth or stencil work: a pending clear, stale depth units, stencil stale state, or a pending depth/stencil fill.rewatchSettledImportskeeps the import compared instead of returning it to the write watch while that is true. The import is rewatched after the plane is stored.rewatchRetirednow applies the same overlap check to the spans it returns to the watch when eviction, refresh orClearHostImportsretires an import, so those pages cannot be stamped as CPU-written either. The check is generic and does not name a title.Tested
Windows 11 IoT Enterprise LTSC 10.0.26100, AMD Radeon RX 6800 XT, driver 32.0.21045.16010, MinGW GCC 15.2.0 Release.
agc_driver_stencil_plane_memory:main(a72186d3cf): fails withAGC graphics: a consumed stencil clear was lost on a read-only rebind.APS5_NO_REWATCH_UNDER_IMAGES=1orAPS5_NO_DEFERRED_SETTLES=1, which confirms the rewatch path.Focused tests with
ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1passed (14/14):agc_driver_stencil_plane_memory,agc_driver_stencil_copy_draw,agc_driver_stencil_known_replace,agc_driver_stencil_logic_operations,agc_driver_stencil_null_feedback,agc_driver_stencil_ref_export,agc_driver_stencil_ref_export_unused,agc_driver_stencil_replay,agc_driver_stencil_ref_export_push_budget,agc_graphics_profile_draw,agc_driver_partial_resident_alias,agc_driver_recorder,agc_driver_stencil_replay_no_gplandagc_driver_stencil_replay_unsuppressed.Validation layer, same test on
main(a72186d3cf) and this branch withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1throughctest -V: both logs showInsert instance layer "VK_LAYER_KHRONOS_validation", neither reportswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither logs aVUID-error. Themainrun still fails the stencil-clear assertion; the branch run passes.The follow-up commit
479f05f602adds the retired-import filter; the author's hardware runs above were made on12b4a90a2a. Mr-Fawx ran it on an RTX 5090 (driver 621.24) and a gfx1036 iGPU:mainfails the stencil test 3/3 on both, this head passes 3/3 on both, with the validation layer inserted and noVUID-. With #22774, this PR, #22950 and #23751 together, 2055agc|shader|bda|spirv|videoout|recompilertests pass except the intermittentagc_driver_store_over_untracked(#24663). miura16 ran it on a GTX 1060 (Pascal, driver 582.78, Windows 11 22631):mainfails the stencil test 3/3, this head passes 3/3, and the 2034-testagcrun has only the two failures that also fail onmain(#22670, #22931), with 0VUID-. wendelledgardossantoschabaud ran it on an RTX 5070 Ti Laptop (driver 621.14, Windows 11 26300):mainfails 3/3, this head passes 3/3, and the 2122-testagc|shader|bda|video_out|recompiler|spirvrun has the same three failures asmain(#22773, #22930, #23708) with no new one; 11 stencil tests under validation had noVUID-,SYNC-HAZARD-orUNASSIGNED-ID. Jirka135 ran the final head on an RTX 5090 (driver 617.42) and the RDNA2 iGPU of the same machine (32.0.21045.29003), basemain7a3e4fc5f6:mainfails the stencil test 5/5 and 3/3, this head passes 5/5 and 3/3, and the 31 stencil/depth tests pass on both with the validation layer inserted and noVUID-lines. kiwe147 also ran the final head on an RTX 3080 (driver 621.24) and an RDNA2 Ryzen iGPU (32.0.21036.18):mainfailsagc_driver_stencil_plane_memoryon both, this head passes 10 of 10 on both, and the 35 stencil/depth tests plusagc_driver_recorder,agc_driver_partial_resident_aliasandagc_graphics_profile_drawpass on both. AbuMshMsh24 ran the final head on an RX 9070 XT (AMD Software 26.11.2, driver 32.0.32029.2010, Windows 10 22H2):ctest -R '^agc_driver_(stencil|depth_plane|depth_surface)'onmainfd7fe562edgave 31/32 withagc_driver_stencil_plane_memoryfailing 3/3, and the same 32 tests with this head gave 32/32, 0VUID-lines and the validation layer inserted. Lavapipe (LLVM 15.0.7, Mesa 25.1.5, Vulkan 1.4.311, Pop!_OS 22.04),ANYPS5_REQUIRE_VULKAN=1,agc_driver_stencil_plane_memory: passes, but the guest-write and shared-plane sections printnot write-watched here, so that run does not exercise the rewatch path.python tools/check_conventions.py --base origin/mainpasses.python tools/pr_overlap.py --names DepthSurfacePendingResultsOverlapreports no open declaration.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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T19:37:28Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional. The head is
a9abf75c0d20f6fc7bed57a3d052a37d41a179f7, and I ran no build or test.What I ran
a9abf75c0d20f6fc7bed57a3d052a37d41a179f7: description, commits, manifest, files list and diff.repo_read.py) and the copies infiles/.Results
Findings
Blocking
None.
Non-blocking
GuestBufferMemory.cpp:1440: when the new check keeps an import compared, the loop has already erased itspendingSettlesentry and does not put it back insettleReady. The import stays unwatched until some other path rewatches it. The description says it is rewatched after the plane is stored, but I did not find that path. The existingkeepUnderImagesbranch atGuestBufferMemory.cpp:1436uses the same pattern, so this is consistent with existing behaviour.DepthSurface.cpp:4182: the PR adds no regression test. Coverage relies onagc_driver_stencil_plane_memory, which the author reports as passing. I did not run it.Sources
a9abf75c0d20f6fc7bed57a3d052a37d41a179f7:DepthSurface.hpplines 24–37.DepthSurface.cpplines 1440–1455, 1796–1803, 2982 and 4170–4191.GuestBufferMemory.cpplines 1405–1460, through the reader.Not verified
DepthSurface.hpp: only the changed declaration and its surrounding lines were read, not all 179 lines.DepthSurface.cpp(5228 lines) andGuestBufferMemory.cpp(8112 lines): read in part only.GuestBufferMemory.cppis excluded fromfiles/, so it was read only through the reader.DepthSurfacePendingResultsOverlaptakes the recursivesurfacesMutex()insiderewatchSettledImports. I did not check whether the caller holds the GPU mutex, or whether any path takessurfacesMutex()and then the GPU mutex in the reverse order.stencilStaleis assumed to be aboolmember. It is assigned atDepthSurface.cpp:1343, but I did not read its declaration.To get this to a good state
Nothing is required.
Optional: confirm the rewatch path that picks up the kept import (see the first non-blocking point), and consider a unit test for
DepthSurfacePendingResultsOverlap.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T11:17:58Z.
Review: APPROVED
Reviewed — looks good
The reviewed changes at head
12b4a90a2a11a3bd72e642dc257b06945d080361add an overlap guard that keeps settled imports under active depth surfaces with pending results in the comparison path; no concrete blocking defect was found in the code read.What I ran
No tests or build commands were run. I read the prepared review bundle and used the pinned
repo_read.pyreader to inspect the changed lines and targeted surrounding functions.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
GuestBufferMemory.cppwas excluded fromfiles/because it was too large; its added lines and surrounding functions were read through the pinned reader.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:34:25Z.
Review: APPROVED
Reviewed — looks good
The added overlap checks keep imports out of write watch while an overlapping live depth surface has pending results; the final follow-up commit was not covered by the author’s reported hardware run.
What I ran
Reviewed head
479f05f60213296ed0d9d36cc72c55791cac65b7using the prepared diff andrepo_read.pyreader. No tests or build commands were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
GuestBufferMemory.cppwas excluded from the review folder because of its size; its changed lines and relevant functions were read throughrepo_read.py. No other changed files were excluded. The Windows hardware test on the final head was not rerun; the description says the follow-up retirement filter was added after the reported hardware run. No build or tests were run during this review.To get this to a good state
Nothing is required.