AGC: cached depth surfaces miss CPU edits after direct memory becomes compared shared #10797
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 lgqdaxia on 2026-10-25T01:40:14Z.
What happens
After Windows direct memory becomes shared and uses byte comparisons instead of continuous write watching, later CPU edits can be missed by a cached depth surface. A draw then uses old depth values.
This reproduces the existing depth-surfaces-over-compared-shared-memory debt entry. I found it while following up on #10746 and have a tested candidate fix.
Title, test or build step
Synthetic Vulkan regression:
agc_driver_depth_compared_shared. No game or homebrew run.The test source uses a 256x128 D32 depth plane containing two 64 KiB units. It establishes GPU depth 0.5, shares the backing, consumes the initial sharing report, then writes 0.75 into the left unit on the CPU. A subsequent LESS test at 0.5 should cover the left 16384 pixels and preserve the right unit's pending GPU results. The old runtime covers zero pixels.
The sharing step follows the existing unpin, map and registration sequence, retiring the original resident host import before its private backing becomes shared.
AnyPS5 commit
e3e3cdd1b0002300567bf8011f49500ad0e5c266, based on mainbd8e13428a10d9332c2911816ab672ea1b41418f.7e32da99051c7c6baad3b691a25c96da4ad07d29, whose parent is maincf528e78c6c8fd30696ccfca6c097f9828be2cf6. That local commit changes onlytests/Recorder.cpp. Production AGC and shader sources are unchanged between that main revision andbd8e13428a.bd8e13428a.System
Windows 11 Pro 10.0.26200; NVIDIA GeForce RTX 3080 Laptop GPU, driver 610.74; WinLibs GCC 15.2.0 r7; Release.
Steps to reproduce
In a separate Windows checkout of main
bd8e13428a10d9332c2911816ab672ea1b41418f, with the toolchain from BUILD and the Khronos validation layer available, fetch the candidate and copy only its test source:Set
VK_LAYER_PATHto the installed validation layer directory if the Vulkan loader needs it, and select the available GPU. CMake discovers the added test automatically; no production fix or CMake change is needed for the red reproduction.Run the same test in a checkout of the candidate for the green comparison. The measured test runs take about 0.5 seconds on the GPU above.
Log
Old runtime:
Candidate:
The excerpts omit CTest line prefixes. Both logs confirm that
VK_LAYER_KHRONOS_validationwas inserted and contain zeroVUID-errors and no missing-layer warning.What was checked
windows_write_watch,agc_rewatched_direct_shared,agc_import_alias_shared,agc_compared_shared_generations,agc_driver_depth_fast_clear,agc_driver_depth_plane_buffer_memory,agc_driver_depth_surface_from_storage,agc_driver_compared_shared_snapshot, andagc_driver_depth_plane_partial_store_unimported.libsandrelinkerbuilds and conventions pass for the candidate.Proposed fix and status
The public fix branch keeps a guest-byte baseline, compares units when write collection is unavailable, and refreshes the units that changed. Actual GPU write-back bytes update the baseline after completion, so a later bind can retain newer GPU results.
The host-import fixture question remains in #10746/#10785. This report tracks the separate depth-cache defect. I plan to submit the candidate PR once the current contribution slot becomes available.
Limits: tested only on the Windows/NVIDIA configuration above. No game, other GPU vendor, Linux, macOS, performance improvement or title unblock is claimed. Outside the write watch, same-value CPU stores remain unobservable; CPU and GPU changes within one tracking unit are not merged.
AI-assisted: Codex assisted with the investigation, implementation, tests and this report. The results above are from local execution.