feat(agc): suballocate sampled and storage image memory #10472
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10472"
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 nikhilpanchal1 on 2026-10-24T02:18:16Z.
What
Small texture images currently consume one Vulkan memory allocation each, even when many compatible images could share a block. Allocate eligible optimal images up to 1 MiB from aligned ranges in 4 MiB blocks, using the existing buffer-pool infrastructure with a separate image arena.
APS5_NO_IMAGE_SLABSdiagnostic switch.The deterministic allocation-count test serves 4,096 simultaneous 64 KiB images with 64 driver allocations, compared with 4,096 with suballocation disabled. Both modes allocate 256 MiB. No game frame-time or throughput measurement is claimed.
Related to #6890; this does not resolve cases where the live image working set itself exceeds available memory. No issue is closed by this PR.
Overlap audit:
The required
tools/pr_overlap.py --branch perf/agc-image-suballocation --repo boykopovar/AnyPS5audit completed. It found four text conflicts with separate features:None implements this image suballocator or is a functional prerequisite. Merge order has not been agreed. The audit also reports stale branches that already conflict with main and can only be compared at shared-file level. The allocator-related changes in #4472, #7642, #9508 and #10193 were inspected separately: they concern device-buffer retention or descriptor addressing, not image backing-memory suballocation. No combined-runtime result with those open branches is claimed.
Tested
Debian 13 x86-64, Release, GCC 14.2.0. Vulkan execution used Mesa llvmpipe/lavapipe 25.0.7 (LLVM 19.1.7, 256 bits) and Khronos validation 1.4.309.
Fresh focused comparison after rebasing onto
maindb6af9e0fd8c75366dabc2066dbf90117f7490d0:db6af9e0fd13829a4bb9No new failures or skips. The same eight write-watch-related failures and four native-depth expectation failures occur on both revisions. Three skips require unavailable write watching; the fourth concerns lavapipe pipeline-cache behavior. This is a focused runtime/allocator matrix, not a full-suite pass.
Both revisions ran the same focused matrix on the same machine with
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, using verbose CTest output. Both logs have zeroVUID-messages and no missing-validation-layer message.13829a4bb9after the rebase (100/100), all with 30-second timeouts. The native pressure cases executed rather than skipping.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-10-24T16:01:12Z.
Review: CHANGES_REQUESTED
The allocator design and the extensive earlier test report are useful, but the evidence stops at commit
13829a4bb9. The current PR head adds05b1532d74, changing the allocation path for alignments that can hold only one image per 4 MiB block and adding new pressure/alignment coverage; the reported 25-repeat matrix and main-vs-change validation comparison do not include this head. Because this is an AGC change, please rerun the focused allocator/Vulkan tests on the current head and compare the same validation-layer matrix against current main3fcb5e4d76on the same device, confirming the layer loaded and no new VUIDs. Also resolve the current-main merge conflict indocs/dev/debt/libSceAgcDriver.mdwhile retaining both debt updates. I did not run the full Vulkan matrix locally.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:18:57Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
fb8c3ee7ad49cda6dded674627b6dddcfddbe8f5against livemain4c7d275bef89d309313d16bc2bc05d37a1b50be2.The earlier debt-file merge conflict is resolved; the current-main preview is clean (
1975f3e3ac766b4dfce869ae171cd465173795d3),git diff --checkpasses, and conventions pass. The new commits also address the WinLibs stack overflow in the test fixture, restore the publicAllocateMemorycontract, avoid 4 MiB slabs that cannot fit a second image, and check device-teardown allocations.Changes requested
13829a4bb9; the current branch addse231a7ddc0andfb8c3ee7ad, which change the allocator, Vulkan fixture lifecycle andDepthSurface.cppintegration. Please rerun the focused matrix on exact currentmainand this exact head, including validation-layer load/VUID results and the new alignment/teardown cases. Hosted AGC product jobs are skipped, so they do not cover these changes.tests/execution/ImageMemory.cpp, sharing is required only wheneligible > 1, andCachePressurereturns normally when its probe image requires/prefer dedicated memory or cannot fit a shared pair. The RTX 3080 report confirms those subcases ran on that machine (8/8 and 16/16 eligible), but another supported device can report the test as passed without exercising the central sharing/pressure checks. Please report a CTest skip when those preconditions are unavailable, or fail explicitly when a test mode promises sharing coverage.The report that none of the RTX 3080 fixture images preferred dedicated allocation is useful for that device only; it does not establish how often titles hit the dedicated path. I did not run the Vulkan/GPU tests locally. The current code and checks otherwise look materially improved; this review is held on exact-head runtime coverage and the test-skip semantics above.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-30T21:58:21Z.
Review: COMMENTED
A run of the current head on NVIDIA and lavapipe under Linux. The four ImageMemory failures @bunbeans2-arch saw on RDNA 4 reproduce on the RTX 3070 at this head. They come from the test's hook bookkeeping, not from a leak: the leftover 512 KiB host-pointer import is freed, but through a
vkFreeMemorythe hook doesn't wrap. A 2-line test change makes them pass.Setup. Ubuntu 26.04, GCC 15.2, Release. RTX 3070 (NVIDIA 595.99.02, the NVIDIA CI's driver) and lavapipe (Mesa 26.0.3).
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest-j1. Head0077d11da8merged ontomain7d9a2fc713(clean). I ran the 128 tests of the binaries the PR touches:agc_image_memory, theagc_driver_image_memory*tests, the storage cache budget tests,agc_driver_graphics*andagc_driver_recorder*.agc_driver_image_memory,_teardown_failureagc_driver_image_memory_no_slabs,_no_slabs_teardown_failureAll four fail with
image memory: device teardown retained hooked driver allocations. That is the same split @bunbeans2-arch saw with and without the layer.Cause. I added local prints to
~RetiredImport,ClearHostImportsandCheckDeviceReleased. The leftover handle is the 524288-byte host import fromcreateHostPointerImport. It is released before the check, by~RetiredImport, through thevkFreeMemorythe host-import state holds:fn=0x7f3bca6326e0, a driver/layer address, while the hook'sFreewas at0x5a659baa8200.HostImports::freeMemoryis only set when it is null or the device changes (GuestBufferMemory.cpparound line 2340), so it keeps a pointer resolved through a context without the test'sdeviceProc. The import's allocation does go through the hooked context, soAllocaterecords it andFreenever sees it. In the passing run (no layer, slabs on), the one retired import was not in the hook's map. I didn't trace why the layer changes which import goes through the hooked context.Fix (test only), verified. Don't record host-pointer imports in
Allocate. They aren't image memory, and the import cache frees them itself:With it, the five
image_memorytests pass 3/3 on the 3070 with 1.4.341, 1/1 with no layer, 1/1 with 1.3.275 (only the knownpNext-pNext), and 3/3 on lavapipe.On the sharing check (@MarcZX10's point). On both devices every image is eligible and the pairs are observed: 8 images, 8 eligible, 28 pairs, and 16 images, 16 eligible, 120 pairs. As a red check,
APS5_NO_IMAGE_SLABS=1without--no-sharing-checkfails 3/3 on the 3070 and on lavapipe with "simultaneous small production images each allocate separate memory". Theeligible > 1guard still lets a device with 0 or 1 eligible images pass silently, as he says; these two devices just don't hit it.GPUs tested: NVIDIA RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3).
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-31T04:38:48Z.
Review: COMMENTED
Re-run of head
eddcd8f4a6merged ontomain0835ec8bdc: the four ImageMemory teardown failures from my earlier review are fixed on the RTX 3070.Same setup as before: Ubuntu 26.04, GCC 15.2, Release,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest-j1.image_memorytests (including the new_hooksand fourdedicated_*_skip): pass 3/3 with VVL 1.4.341, 1/1 with no layer, 1/1 with VVL 1.3.275 (only the knownpNext-pNext). The sharing checks still observe pairs (8/8 eligible, 28 pairs; 16/16, 120 pairs), so they are not skipping.VUID-errors.&& !ImportsHostPointer(info)inAllocatebrings backdevice teardown retained hooked driver allocationson the 3070 (9 of 10 fail). On lavapipe, the newagc_driver_image_memory_hooksregression catches it, so the change is covered even on a device where the original failure doesn't show.GPUs tested: NVIDIA RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3).
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:03:47Z.
Review: CHANGES_REQUESTED
Re-checked — new head, current-main GPU comparison still needed
The new head resolves the earlier teardown and silent-skip findings, but the required paired Vulkan run does not yet compare this head with current
mainon the same machine and GPU.What I ran
Reviewed head
eddcd8f4a6007bdd59b0d57dfb6980db811a88e7against PR basebff0289787c98570491c8f175179c8a5651c8017; its preview against currentmainb8f0a6b2025605b78eb70646bda79f458a577c82was clean. Environment: Debian Linux x86-64, Python 3.11.2. I did not build or run C++/Vulkan tests locally.I also inspected the new exact-head test coverage and skip handling, the added cache-eviction/dedicated-allocation debt, and the test reports posted on the PR.
Results
b8f0a6b2025605b78eb70646bda79f458a577c82.0835ec8bdc, not a paired comparison with current main. These are supplied results, not runs I reproduced.b8f0a6b2025605b78eb70646bda79f458a577c82and this head on the same machine/GPU. The PR body’s earlier paired matrix used maindb6af9e0fdand PR head13829a4bb9.Negative control
&& !ImportsHostPointer(info)Findings
Blocking
This changes AGC image allocation behavior, so repository guidance requires the same focused Vulkan tests on
mainand the change, from the same machine and GPU, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; the logs must confirm the layer loaded and show no newVUID-errors. The current-head participant runs are useful, but there is no corresponding run on currentmainb8f0a6b2025605b78eb70646bda79f458a577c82. The older paired matrix does not cover the later allocator, depth-image integration, and teardown changes. Please provide that current-base pair and update### Testedwith the exact base/head commits and raw log or artifact links.Non-blocking
None found in the source review. The earlier silent-skip and cache-eviction documentation findings are addressed in this head.
Sources
Not verified
I did not reproduce the author/participant GPU tests, run a build, or test on a physical PS5. Hosted product Linux and specialized GPU jobs are skipped for this PR; hosted Windows passed, but it does not replace the missing same-device current-main comparison.
To get this to a good state
Run the prescribed focused Vulkan tests on current
mainand this exact head on the same machine/GPU, confirm the layer marker and compare VUIDs, then update the### Testedevidence. I will re-check the exact new head and rerun the same no-build checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T09:55:53Z.
Review: CHANGES_REQUESTED
Re-checked — new head, current-base evidence and overlap update needed
The new head adds accounting and skip-path regressions, but the paired GPU report uses an older
mainsnapshot and an open overlapping PR still conflicts with this branch.What I ran
Reviewed head
71ef22cc91c2b77542e70f54ce7b17530874152f; the PR base recorded by GitHub is7c4dcf0ad84de7a473ce97bb21644c614f1c3bd3. Currentmainis26fa1212b82f76dd49cf12d65e445d6ff3e0844c. A merge preview of the exact PR head onto currentmainwas clean. The local environment was Linux x86-64, Python 3.11.2, GCC 12.2.0; I did not build or compile AnyPS5 locally.Commands and checks:
The precheck verified head and base stayed unchanged. Its ABI and test-quality helpers were not present in the PR snapshot, so I ran the available workspace copies against these exact SHAs and manually checked their findings. The CMake registration uses an execution-source glob plus explicit CTest fragments.
Results
CheckImageMemorySkip.pyat the exact head.tests/ImageMemory.cppis listed inagc_image_memory_tests.cmake, whiletests/execution/ImageMemory.cppis discovered by the AGC execution-source glob.71ef22contomain26fa121.Texture.hppandTexture.cpp; #9875 merges cleanly with this head. #7085 is still open; #8419 and #9626 named in the PR's audit are closed.71ef22c71ef22c; it compares againstmain3741ca9, not currentmain26fa121.Unedited local check output
Conventions:
Python syntax command wrapper:
ABI audit:
Test-quality heuristic (warnings manually checked against the CMake source list and registrations):
Current-main merge preview:
Pairwise #7085 preview:
Pairwise #9875 preview:
The precheck isolated-snapshot helper stderr:
Negative control
Findings
Blocking
main. The new NVIDIA report is useful and covers the exact PR head, but its paired baseline is3741ca9327246d0df81638726a986cef862b6db5; currentmainis26fa1212b82f76dd49cf12d65e445d6ff3e0844c. Commits after the report's baseline changed files also touched by this PR, so the report does not establish the required current-main comparison. Please rerun the same focused Vulkan tests on currentmainand this head, on the same machine and GPU, with the required validation environment, and update the evidence.a4261716f85826c149a80b7387e652c0a68e4beawith this head reports conflicts inTexture.hppandTexture.cpp. The PR body says the order is not agreed and its checklist saysDepends on: none. Please coordinate which PR lands first with #7085's author, update the overlap audit to reflect current open/closed PRs, and declare the agreed order in the applicableDepends onchecklist.Non-blocking
Sources
26fa121require overlap order/dependency declarations and paired AGC validation runs.71ef22cand test registration.71ef22c.Not verified
To get this to a good state
Please refresh the paired Vulkan evidence against current
main, coordinate and declare the #7085 landing order, and update the stale overlap/test summary. I will rerun the same no-build checks and re-evaluate the new exact head.