fix(agc): bound the sampled depth-plane copies #7705
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7705"
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 AnthonyClemens on 2026-10-19T01:51:55Z.
What
A depth plane copy (a depth surface sampled as several slices, an integer view or a cube) stayed in
planeCopies()until the device went away. Each copy also kept a staging buffer the size of the copy. A staging buffer it outgrew was moved intoretiredStagingand never freed. So every depth surface a scene ever sampled this way kept its copy, and device memory grew with each new scene.With this change:
OwnedImageowner of the depth-planeTextureconstructor. A copy can leave the cache while a draw or a cached resource set still samples it.APS5_DEPTH_PLANE_COPY_MIB(default 256;0keeps every copy), the least recently used ones leave the cache. A copy made again refills from the depth surface and guest memory, as a new copy does.DepthPlaneCopyCount()returns the number of cached copies, for the test.In Resident Evil 2 (PPSA04288), these were the peak
depth plane copyallocations underAPS5_VK_MEMORY_TRACK:depth plane copyThe scene rendered the same either way. Without the bound, the staging buffers of the same size added roughly as much again under
device buffer.Tested
Windows 11 Pro (10.0.26200), AMD Radeon RX 9070 XT, WinLibs GCC 15.2.0, Release, on
main85029a00f.agc_driver_depth_plane_sampling_evicting. It runs the depth-plane sampling cases withAPS5_DEPTH_PLANE_COPY_MIB=1and--evicting. Every copy but the newest leaves the cache, so later cases rebuild evicted copies and must read the same values. It then requires one copy left in the cache.APS5_DEPTH_PLANE_COPY_MIB=0, which keeps every copy asmaindoes, fails:8 depth plane copies were kept with a 1 MiB budget, expected only the newest.depth_plane_sampling,depth_plane_guest_layers,depth_plane_fill,depth_compare_copy,depth_storage,depth_storage_dispatch,depth_storage_reuse,depth_surface_from_storage,depth_bits_guest_memory.main. As MaxLikesCode noted, theprepared_shaders_abi_deferred_*failures came from the old base.Thanks to MaxLikesCode, savvaniss and jotitadev for the NVIDIA, Intel/AMD and MoltenVK runs.
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 jotitadev on 2026-10-19T03:55:13Z.
Review: COMMENTED
Apple GPU / MoltenVK run.
agc_driver_depth_plane_sampling_evictingand the depth-plane tests pass on Metal. Two of the tests listed as unchanged,depth_plane_guest_layersanddepth_storage, are skipped on macOS onmain. With a loader patch they run and pass with this PR.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Head 0258a057b, PR diff applied cleanly. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704.
Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). Also in the same build: #7707, #7698, #7687, #7691 and #7705 (they touch different files and applied cleanly together), plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branchjotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704.agc_driver_depth_plane_sampling_evicting(APS5_DEPTH_PLANE_COPY_MIB=1),depth_plane_sampling,depth_plane_fill,depth_plane_guest_layers,depth_storage,depth_compare_copy,depth_surface_from_storageanddepth_bits_guest_memory: all pass 3 of 3 on both drivers.depth_storage_dispatchanddepth_storage_reusealso pass in the full-suite runs.DepthPlaneGuestLayers.cppandDepthStorage.cpploadlibvulkan.so.1themselves, without portability enumeration. Without the loader patch they printskipped, no usable Vulkan deviceon macOS, so they don't cover this change there.^agcsuite with the stack: 42 of 730 fail on MoltenVK 1.4.2 and 28 of 730 on MoltenVK main + #2704. That is the base failures plusagc_driver_pooled_buffer_rangeandagc_performance_overlay, which only run because of the loader patch and fail for unrelated reasons. No new failure from this PR.I didn't do a without-the-fix control. Without the fix, the evicting test's variable does nothing, so the test would pass anyway.
GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MaxLikesCode on 2026-10-19T04:08:07Z.
NVIDIA data: GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ONwith every execution test built. Head 0258a057b, which already containsmain79d7d26b6.agc_driver_depth_plane_sampling_evictingpasses. So dodepth_plane_sampling,depth_plane_guest_layers,depth_plane_fill,depth_compare_copy,depth_storage,depth_storage_dispatch,depth_storage_reuse,depth_surface_from_storageanddepth_bits_guest_memory.CMakeLists.txt. 9 fail, none in code this PR touches:agc_driver_bda_device(#7584),agc_driver_image_table_reuse(#7710) andagc_driver_pixel_lds(#7708) fail onmainon this GPU too.agc_driver_prepared_shaders_abi_deferred_*tests abort withlibc: end flush already registered. They fail the same way at this branch's base79d7d26b6without the change, and all 8 of them pass on currentmain9cc0f16f6, so a rebase should clear them.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-19T07:42:34Z.
Windows regression check on an Intel UHD 770 and an AMD RX 9070 XT: no new failures in the full CTest results.
Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built. Intel UHD Graphics 770 (
8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head0258a057bmerged intomain6b8228b2b.This PR adds no test, so I ran full CTest (
--parallel 4, 1606 tests) with it merged:mainalone. These are the image-table tests that #6647 addresses (including the newagc_driver_image_table_vouched_lookups) andagc_driver_sample_multisample_target(#6957).mainalone failed 3 in its parallel run on this machine:agc_trimmed_import,agc_performance_overlay_device_selectionandagc_driver_format_d16. I haven't checked whether those are intermittent, so I'm not attributing that difference to this PR.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T10:51:13Z.
Review: CHANGES_REQUESTED
The full Build of this head fails on Linux (lavapipe) in the new test, which main does not have:
agc_driver_depth_plane_sampling_evicting(run 39348454151):AGC graphics: 2 depth plane copies were kept with a 1 MiB budget, expected only the newest(DepthPlaneSampling.cpp:458).evictPlaneCopiesruns right after the copy is constructed (DepthSurface.cpp:1881), beforeRefreshcreates the staging buffer (DepthSurface.cpp:1024), soHeldBytes()of the newest copy leaves the staging out and the total is under-counted until the next lookup.APS5_DEPTH_PLANE_COPY_MIB=0, and the newest one still present), or make the budget finer than 1 MiB for the test.The rest (shared
OwnedImageownership, recorder keeping the image and staging until the copy runs, ENVIRONMENT.md entry) checked fine.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T02:06:43Z.
Review: COMMENTED
Apple GPU / MoltenVK run of the current head. The new
agc_driver_depth_plane_sampling_evictingfails here the same way adriadam10 saw on lavapipe, so the one-copy check does not hold on MoltenVK either. My earlier run (0258a057b) passed because that head did not have the count check yet.Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Vulkan loader + MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and again against MoltenVK main + SPIRV-Cross #2704. Release,
BUILD_TESTING=ON.Base/method: PR #8658
feat/macos-port@c5fa39620a(currentmainplus the macOS port), notmain, becausemaindoes not build on macOS. This PR's diff atf440e3b238(git diff merge-base..head -- . ':!docs') applied cleanly. The focused runs and the suite were done in one tree that also had #9443 and #9717/#9533. They touch other tests, and the evicting failure below is also there when the binary runs alone. Full rebuild first.agc_driver_depth_plane_sampling_evicting: fails on every run, 4 per driver, on both drivers:Running the same binary by hand with
--evicting:APS5_DEPTH_PLANE_COPY_MIB01So the eviction does work here, from 8 copies down to 2. This matches what adriadam10 described. The newest copy's staging is not counted yet when
evictPlaneCopiesruns, and at a 1 MiB budget two copies fit on this driver too. Any assertion that holds on all drivers would have to accept 2 here.Unchanged and passing (
--repeat until-fail:3, both drivers):depth_plane_sampling,depth_plane_guest_layers,depth_plane_fill,depth_plane_partial_store,depth_compare_copy,depth_storage,depth_storage_dispatch,depth_storage_reuse,depth_surface_from_storage,depth_bits_guest_memory.Full
^agcsuite (877 tests), both drivers: the failures from the #8658 base, plusdepth_plane_sampling_evicting. The suite also showed two failures from #9533's tests in the same tree, which I'm reporting on #9533. Nothing else is new.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; and MoltenVK main + SPIRV-Cross #2704).
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.