fix(agc): release buffer slabs when metadata allocation fails #6882

Merged
Ondra97 merged 1 commit from upstream-pr/6882 into main 2026-10-17 11:10:12 +00:00
Ondra97 commented 2026-10-16 15:53:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-16T15:53:38Z.


What

BufferPool::TakeSlot lost an already allocated Vulkan memory block when a subsequent C++ metadata allocation threw. Failure while inserting the block into the pool could also leave a published block that no later request could reuse. Under host memory pressure, these failures retained additional device-local or mapped host memory.

The new block now owns its Vulkan allocation through a scoped deleter until publication succeeds. The available-block vector reserves capacity before ownership is transferred, and the map allocates its node before receiving the block. Subsequent publication steps do not allocate. Mapping errors use the same cleanup path.

The CPU regression sweeps metadata allocation failures, checks unmapping/freeing and successful retries, and covers VK_ERROR_MEMORY_MAP_FAILED. The existing native Vulkan buffer fixture adds the same single-fault sweep for mapped host-visible and unmapped device-local memory. It then runs its original compute/readback and buffer-reuse controls. Both test executables compile the production buffer-pool translation unit with a shared test allocator so that metadata failures can be injected on Windows too; the test allocator is not linked into the runtime library.

The cleanup follows Vulkan's memory lifetime rules. This change concerns newly allocated slabs that have not been handed to a buffer or submitted to GPU work.

Tested

Base 4524944396dfe91bd7c6949a3d7ac01935a2b840; head a4485bd8216075064799fd023d6147a326961be3. The full upstream delta 82ddae75b6761757f3d3ba9c0723647469270f76..4524944396dfe91bd7c6949a3d7ac01935a2b840 and this patch were reviewed before execution, including build/workflow paths and new test files. Related buffer-pool PR implementations/tests and complete large-PR file lists were checked; no existing PR fixes this slab-publication failure path.

Windows (native host): AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742; Windows 11 Pro 10.0.26300. WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF.

Vulkan was required (ANYPS5_REQUIRE_VULKAN=1) and the selected physical NVIDIA device and driver were verified. ANYPS5_GPU=NVIDIA GeForce RTX 4070 Ti SUPER and ANYPS5_NO_SHADER_CACHE=1 were set. The allocation regression uses native Vulkan directly; the wider AGC suite exercises the recompiler/runtime. Driver caches were not controlled.

Before / after — Windows (native host)

Same final CPU/native fixtures, Release build, hardware and inputs, one invocation per variant. The negative control restored the exact base BufferPool.cpp, then restored and checked the fixed source bytes. The native fixture injects one C++ allocation failure at each of four metadata allocations per memory type, with a successful retry/control. Each newly requested block is 2 MiB.

The following counts are unreleased VkDeviceMemory payloads, summed from allocationSize, after the local pools are destroyed and before the fixture's teardown cleanup. They are not process RSS measurements.

Metric Before (base) After (fix)
Unreleased device-local memory 6 MiB 0
Unreleased mapped host-visible memory 6 MiB 0
Failure scenarios retaining an allocation before retry 8/8 0/8

The base also leaves one unusable published block in each memory-type sweep. Both new regression groups fail on base and pass with the fix; existing allocation retry, mapping-error and native buffer controls pass with the fix.

  • Full Windows application/library build passed with #6452's exact test-only alignment correction (4fe92c9c23c7bd861d63664d4efde3033b6226f6) temporarily applied. It was removed and is not in this PR.
  • Related Windows suite: 19/19 passed, 0 failures, 0 skips, including buffer loads/stores, atomics, BDA span reads, descriptor runtime, storage/sampled-cache budgets and patched-library validation.
  • Conventions, whitespace and test registration passed (903 test executables registered).

With the configured full build and environment above:

cmake --build build-runtime --target all libs --parallel 4
ctest --test-dir build-runtime -V --parallel 2 -R '^(agc_buffer_pool|agc_driver_(pooled_buffer_range|buffer.*|bda_span_reads|flat_cache_bits|storage_cache_budget|sampled_cache_budget|constant_store)|patched_libraries)$'

Linux (VirtualBox): Ubuntu 24.04.5 LTS, kernel 7.0.0-31-generic, GCC 13.3.0; VirtualBox 7.2.20 on the Windows host above, 4 vCPU / 8 GiB assigned. Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=OFF. Graphics: not exercised.

  • Exact final head and all six changed source files verified against Git blobs in the separate Linux checkout.
  • Full application/library build, including both changed test executables and graphics components, passed.
  • agc_buffer_pool (including metadata fault injection and mapping failure), agc_structurizer, agc_shader_mode_register, agc_shader_control_flow and agc_constant_phi: 5/5 passed, 0 failures, 0 skips.
  • Conventions and test registration passed (913 test executables registered).

The existing Linux build retained its CMake cache paths through its compatibility directory:

cmake --build ~/anyps5-rwlock-20261016/build --target all libs agc_buffer_pool_tests agc_driver_pooled_buffer_range_tests --parallel 2
ctest --test-dir ~/anyps5-rwlock-20261016/build --output-on-failure -R '^(agc_buffer_pool|agc_structurizer|agc_shader_mode_register|agc_shader_control_flow|agc_constant_phi)$'

Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested.

The full CTest suite was not run. The failure scenarios are synthetic, bounded fault injection; no title, actual system exhaustion, FPS improvement or AMD/PS5 run is claimed. Full hosted builds require a collaborator's manual dispatch under the current CI policy.

Checklist

  • Based on current main; no other open PR implements this slab-publication cleanup
  • One topic per PR; follow-ups go in a new PR
  • No comments in code added
  • No new stubs or unimplemented paths
  • No notes, investigation files or images added to the repository
  • New third-party code: n/a
  • Generic allocation behavior, not specific to one title
  • Depends on: #6452 for the complete Windows test build
  • Unblocks: none established for a title
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42, Windows 11 Pro 10.0.26300
  • AI-assisted: yes, Codex; code and local test results checked in this task
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4890862534 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-16T15:53:38Z. --- ### What `BufferPool::TakeSlot` lost an already allocated Vulkan memory block when a subsequent C++ metadata allocation threw. Failure while inserting the block into the pool could also leave a published block that no later request could reuse. Under host memory pressure, these failures retained additional device-local or mapped host memory. The new block now owns its Vulkan allocation through a scoped deleter until publication succeeds. The available-block vector reserves capacity before ownership is transferred, and the map allocates its node before receiving the block. Subsequent publication steps do not allocate. Mapping errors use the same cleanup path. The CPU regression sweeps metadata allocation failures, checks unmapping/freeing and successful retries, and covers `VK_ERROR_MEMORY_MAP_FAILED`. The existing native Vulkan buffer fixture adds the same single-fault sweep for mapped host-visible and unmapped device-local memory. It then runs its original compute/readback and buffer-reuse controls. Both test executables compile the production buffer-pool translation unit with a shared test allocator so that metadata failures can be injected on Windows too; the test allocator is not linked into the runtime library. The cleanup follows [Vulkan's memory lifetime rules](https://docs.vulkan.org/refpages/latest/refpages/source/vkFreeMemory.html). This change concerns newly allocated slabs that have not been handed to a buffer or submitted to GPU work. ### Tested Base `4524944396dfe91bd7c6949a3d7ac01935a2b840`; head `a4485bd8216075064799fd023d6147a326961be3`. The full upstream delta `82ddae75b6761757f3d3ba9c0723647469270f76..4524944396dfe91bd7c6949a3d7ac01935a2b840` and this patch were reviewed before execution, including build/workflow paths and new test files. Related buffer-pool PR implementations/tests and complete large-PR file lists were checked; no existing PR fixes this slab-publication failure path. **Windows (native host):** AMD Ryzen 9 7900X, 32 GB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42 / 32.0.16.1742; Windows 11 Pro 10.0.26300. WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Vulkan was required (`ANYPS5_REQUIRE_VULKAN=1`) and the selected physical NVIDIA device and driver were verified. `ANYPS5_GPU=NVIDIA GeForce RTX 4070 Ti SUPER` and `ANYPS5_NO_SHADER_CACHE=1` were set. The allocation regression uses native Vulkan directly; the wider AGC suite exercises the recompiler/runtime. Driver caches were not controlled. #### Before / after — Windows (native host) Same final CPU/native fixtures, Release build, hardware and inputs, one invocation per variant. The negative control restored the exact base `BufferPool.cpp`, then restored and checked the fixed source bytes. The native fixture injects one C++ allocation failure at each of four metadata allocations per memory type, with a successful retry/control. Each newly requested block is 2 MiB. The following counts are unreleased `VkDeviceMemory` payloads, summed from `allocationSize`, after the local pools are destroyed and before the fixture's teardown cleanup. They are not process RSS measurements. | Metric | Before (base) | After (fix) | | --- | --- | --- | | Unreleased device-local memory | 6 MiB | 0 | | Unreleased mapped host-visible memory | 6 MiB | 0 | | Failure scenarios retaining an allocation before retry | 8/8 | 0/8 | The base also leaves one unusable published block in each memory-type sweep. Both new regression groups fail on base and pass with the fix; existing allocation retry, mapping-error and native buffer controls pass with the fix. - Full Windows application/library build passed with #6452's exact test-only alignment correction (`4fe92c9c23c7bd861d63664d4efde3033b6226f6`) temporarily applied. It was removed and is not in this PR. - Related Windows suite: **19/19 passed, 0 failures, 0 skips**, including buffer loads/stores, atomics, BDA span reads, descriptor runtime, storage/sampled-cache budgets and patched-library validation. - Conventions, whitespace and test registration passed (903 test executables registered). With the configured full build and environment above: ```sh cmake --build build-runtime --target all libs --parallel 4 ctest --test-dir build-runtime -V --parallel 2 -R '^(agc_buffer_pool|agc_driver_(pooled_buffer_range|buffer.*|bda_span_reads|flat_cache_bits|storage_cache_budget|sampled_cache_budget|constant_store)|patched_libraries)$' ``` **Linux (VirtualBox):** Ubuntu 24.04.5 LTS, kernel 7.0.0-31-generic, GCC 13.3.0; VirtualBox 7.2.20 on the Windows host above, 4 vCPU / 8 GiB assigned. Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=OFF`. Graphics: not exercised. - Exact final head and all six changed source files verified against Git blobs in the separate Linux checkout. - Full application/library build, including both changed test executables and graphics components, passed. - `agc_buffer_pool` (including metadata fault injection and mapping failure), `agc_structurizer`, `agc_shader_mode_register`, `agc_shader_control_flow` and `agc_constant_phi`: **5/5 passed, 0 failures, 0 skips**. - Conventions and test registration passed (913 test executables registered). The existing Linux build retained its CMake cache paths through its compatibility directory: ```sh cmake --build ~/anyps5-rwlock-20261016/build --target all libs agc_buffer_pool_tests agc_driver_pooled_buffer_range_tests --parallel 2 ctest --test-dir ~/anyps5-rwlock-20261016/build --output-on-failure -R '^(agc_buffer_pool|agc_structurizer|agc_shader_mode_register|agc_shader_control_flow|agc_constant_phi)$' ``` Linux graphics/Vulkan tests: NOT RUN — intentionally excluded from VirtualBox validation. Native/bare-metal Linux was not tested. Native Linux GPU validation: not tested. The full CTest suite was not run. The failure scenarios are synthetic, bounded fault injection; no title, actual system exhaustion, FPS improvement or AMD/PS5 run is claimed. Full hosted builds require a collaborator's manual dispatch under the current CI policy. ### Checklist - [x] Based on current `main`; no other open PR implements this slab-publication cleanup - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code added - [x] No new stubs or unimplemented paths - [x] No notes, investigation files or images added to the repository - [x] New third-party code: n/a - [x] Generic allocation behavior, not specific to one title - [x] Depends on: #6452 for the complete Windows test build - [x] Unblocks: none established for a title - [x] GPUs tested: NVIDIA GeForce RTX 4070 Ti SUPER, driver 617.42, Windows 11 Pro 10.0.26300 - [x] AI-assisted: yes, Codex; code and local test results checked in this task
MarcZX10 commented 2026-10-16 16:04:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T16:04:55Z.

Review: COMMENTED


I reviewed the ownership and publication sequence in BufferPool::TakeSlot. The new block remains under its scoped deleter through mapping, free-slot initialization, available-vector reserve, and slabBlocks.try_emplace; ownership transfers only after all allocating publication steps complete, and the final push_back uses reserved capacity. The map/vector failure paths therefore release the native allocation and mapping, while the tests exercise retry and map-failure cleanup for mock and native Vulkan paths. I did not find a concrete defect in this diff. Hosted conventions, eligibility, intake and report pass; the Linux/Windows build jobs are skipped by path filters. I have not independently run the tests, so I’m relying on the detailed native Windows and Linux VirtualBox results in the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5550396339 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882#pullrequestreview-5550396339). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T16:04:55Z. **Review:** COMMENTED --- I reviewed the ownership and publication sequence in `BufferPool::TakeSlot`. The new block remains under its scoped deleter through mapping, free-slot initialization, available-vector reserve, and `slabBlocks.try_emplace`; ownership transfers only after all allocating publication steps complete, and the final `push_back` uses reserved capacity. The map/vector failure paths therefore release the native allocation and mapping, while the tests exercise retry and map-failure cleanup for mock and native Vulkan paths. I did not find a concrete defect in this diff. Hosted conventions, eligibility, intake and report pass; the Linux/Windows build jobs are skipped by path filters. I have not independently run the tests, so I’m relying on the detailed native Windows and Linux VirtualBox results in the description.
github-actions[bot] commented 2026-10-16 16:11:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T16:11:56Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 4472 core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp L2, L46

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1341 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4339 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4650 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4891 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5426 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5431 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5499 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5987 core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp
core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp
PR 6044 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6176 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6222 core/libs/prx/libSceAgcDriver/tests/execution/PooledBufferRange.cpp
PR 6259 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6320 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6373 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6503 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6535 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6553 core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp
core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp
PR 6718 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6747 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6937 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6946 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6947 core/libs/prx/libSceAgcDriver/CMakeLists.txt
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6219652774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882#issuecomment-6219652774). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T16:11:56Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 4472](https://www.github.com/boykopovar/AnyPS5/pull/4472) | `core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp` [L2](https://github.com/boykopovar/AnyPS5/blob/ca82d7d882b0ac17d955f6e107fe2eb0cae244af/core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp#L2), [L46](https://github.com/boykopovar/AnyPS5/blob/ca82d7d882b0ac17d955f6e107fe2eb0cae244af/core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp#L46) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1341](https://www.github.com/boykopovar/AnyPS5/pull/1341) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4339](https://www.github.com/boykopovar/AnyPS5/pull/4339) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4650](https://www.github.com/boykopovar/AnyPS5/pull/4650) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 4891](https://www.github.com/boykopovar/AnyPS5/pull/4891) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5431](https://www.github.com/boykopovar/AnyPS5/pull/5431) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5499](https://www.github.com/boykopovar/AnyPS5/pull/5499) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5925](https://www.github.com/boykopovar/AnyPS5/pull/5925) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 5987](https://www.github.com/boykopovar/AnyPS5/pull/5987) | `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6176](https://www.github.com/boykopovar/AnyPS5/pull/6176) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceAgcDriver/tests/execution/PooledBufferRange.cpp` | | [PR 6259](https://www.github.com/boykopovar/AnyPS5/pull/6259) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6320](https://www.github.com/boykopovar/AnyPS5/pull/6320) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6373](https://www.github.com/boykopovar/AnyPS5/pull/6373) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6503](https://www.github.com/boykopovar/AnyPS5/pull/6503) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6535](https://www.github.com/boykopovar/AnyPS5/pull/6535) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6553](https://www.github.com/boykopovar/AnyPS5/pull/6553) | `core/libs/prx/libSceAgcDriver/Graphics/src/BufferPool.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BufferPool.cpp` | | [PR 6718](https://www.github.com/boykopovar/AnyPS5/pull/6718) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6747](https://www.github.com/boykopovar/AnyPS5/pull/6747) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6808](https://www.github.com/boykopovar/AnyPS5/pull/6808) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6937](https://www.github.com/boykopovar/AnyPS5/pull/6937) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/CMakeLists.txt` |
jotitadev commented 2026-10-16 18:00:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T18:00:33Z.

Review: COMMENTED


A native Linux GPU run, which the description lists as not tested (the Linux run there was VirtualBox, graphics excluded).

Machine: Linux, NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same box. Ubuntu 26.04, i7-8700, GCC 15.2, Release, BUILD_TESTING=ON. Head a4485bd82 merged into main 66e290f1c (clean). Red run: same tree with only Graphics/src/BufferPool.cpp restored to main.

RTX 3070 lavapipe
agc_buffer_pool, fix pass 3/3 pass
agc_driver_pooled_buffer_range, fix pass 3/3 pass
agc_buffer_pool, main's BufferPool.cpp fails (leaked the slab's device memory at allocation 0..3, did not unmap its slab, published an unusable slab) fails, same
agc_driver_pooled_buffer_range, main's BufferPool.cpp fails: type 1 (unmapped) leaked=6291456, type 3 (mapped) leaked=6291456, total 12582912 fails: type 0 (mapped) leaked=6291456

The RTX 3070 numbers match your Windows table (6 MiB device-local, 6 MiB mapped host-visible, one unusable block per sweep at allocation 3). lavapipe exposes a single host-visible memory type, so only the mapped sweep runs there; with the fix it reports leaked=0 for all four failure points.

Not run: AMD, the full suite, any title.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5551751972 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882#pullrequestreview-5551751972). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-16T18:00:33Z. **Review:** COMMENTED --- A native Linux GPU run, which the description lists as not tested (the Linux run there was VirtualBox, graphics excluded). **Machine:** Linux, NVIDIA GeForce RTX 3070 (driver 595.99.02) and lavapipe (Mesa 26.0.3, LLVM 21.1.8) on the same box. Ubuntu 26.04, i7-8700, GCC 15.2, Release, `BUILD_TESTING=ON`. Head `a4485bd82` merged into `main` `66e290f1c` (clean). Red run: same tree with only `Graphics/src/BufferPool.cpp` restored to `main`. | | RTX 3070 | lavapipe | |---|---|---| | `agc_buffer_pool`, fix | pass 3/3 | pass | | `agc_driver_pooled_buffer_range`, fix | pass 3/3 | pass | | `agc_buffer_pool`, `main`'s `BufferPool.cpp` | fails (`leaked the slab's device memory at allocation 0..3`, `did not unmap its slab`, `published an unusable slab`) | fails, same | | `agc_driver_pooled_buffer_range`, `main`'s `BufferPool.cpp` | fails: type 1 (unmapped) `leaked=6291456`, type 3 (mapped) `leaked=6291456`, total 12582912 | fails: type 0 (mapped) `leaked=6291456` | The RTX 3070 numbers match your Windows table (6 MiB device-local, 6 MiB mapped host-visible, one unusable block per sweep at allocation 3). lavapipe exposes a single host-visible memory type, so only the mapped sweep runs there; with the fix it reports `leaked=0` for all four failure points. Not run: AMD, the full suite, any title. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02), lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04 Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
simonbbby commented 2026-10-16 18:24:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbbby on 2026-10-16T18:24:09Z.


Independent native RADV allocation-failure check at exact head a4485bd8216075064799fd023d6147a326961be3, adding the AMD case to the NVIDIA/lavapipe results above.

Host: Ubuntu 24.04, kernel 7.0.0-38, GCC 13.3, Ryzen 9 9950X. Selected Vulkan device: AMD Ryzen 9 9950X 16-Core Processor (RADV RAPHAEL_MENDOCINO), vendor/device 1002:13c0, Mesa/RADV 25.2.8 (driverVersion=0x6402008). VK_DRIVER_FILES points only to radeon_icd.json, and ANYPS5_GPU=AMD is checked by the fixture.

To bypass the unrelated SDL/XRandR full-build blocker, I isolated the prefix of PooledBufferRange.cpp through SlabMetadataFailures: the native Device setup, allocation/map/free counters and fault sweeps are unchanged. Removed the unused shader/resource test includes and replaced only SDL's three dynamic-loader calls with dlopen/dlsym/dlclose. The scratch entry point runs that allocation subtest and final handle/live-byte checks. It links the complete unchanged production BufferPool.cpp and upstream AllocationFailure.cpp, with function/data sections and linker garbage collection. All Vulkan allocation/map/unmap/free calls reach the actual RADV device.

Same native fixture and fault-injection object, changing only production BufferPool.cpp to HEAD^ for the negative control. Three fresh processes per variant:

RADV memory type Parent, each of 3 runs PR, each of 3 runs
type 0, device-local/unmapped 4 injected failures; 6,291,456 bytes unreleased 4 injected failures; 0 bytes unreleased
type 2, coherent host-visible/mapped 4 injected failures; 6,291,456 bytes unreleased 4 injected failures; 0 bytes unreleased
Total after local pools are destroyed 12,582,912 bytes, exit 1 0 bytes, exit 0

These are counted VkDeviceMemory allocation sizes before the fixture's final teardown cleanup, not RSS. The parent retains a 2 MiB allocation at every injected point before retry; point 3 also exposes one published unusable block in each memory-type sweep. With the PR every point reports retained=0 blocks=0, retries return the correct mapped/unmapped state, and final cleanup reports no invalid handle/mapping state. The selected device and all eight exercised fault points are verified in each process; nothing skips.

This rules out a software-driver fallback or a test that fails before a native allocation exists. The matched pool object identifies the cleanup/publication change as the difference. Repository worktree is clean; the extraction/build script and six full logs are retained separately.

Scope: native allocation cleanup, mapping and retry behavior on RADV. I did not run RobustReadPastEnd, ExactSizes, the full agc_driver_pooled_buffer_range executable, shader compute/readback, the wider runtime suite or a title; this is not a full-fixture pass or a merge onto newer main.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6222028843 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882#issuecomment-6222028843). Originally posted by [simonbbby](https://github.com/simonbbby) on 2026-10-16T18:24:09Z. --- Independent **native RADV allocation-failure check** at exact head `a4485bd8216075064799fd023d6147a326961be3`, adding the AMD case to the NVIDIA/lavapipe results above. Host: Ubuntu 24.04, kernel 7.0.0-38, GCC 13.3, Ryzen 9 9950X. Selected Vulkan device: `AMD Ryzen 9 9950X 16-Core Processor (RADV RAPHAEL_MENDOCINO)`, vendor/device `1002:13c0`, Mesa/RADV 25.2.8 (`driverVersion=0x6402008`). `VK_DRIVER_FILES` points only to `radeon_icd.json`, and `ANYPS5_GPU=AMD` is checked by the fixture. To bypass the unrelated SDL/XRandR full-build blocker, I isolated the prefix of `PooledBufferRange.cpp` through `SlabMetadataFailures`: the native `Device` setup, allocation/map/free counters and fault sweeps are unchanged. Removed the unused shader/resource test includes and replaced only SDL's three dynamic-loader calls with `dlopen`/`dlsym`/`dlclose`. The scratch entry point runs that allocation subtest and final handle/live-byte checks. It links the complete unchanged production `BufferPool.cpp` and upstream `AllocationFailure.cpp`, with function/data sections and linker garbage collection. **All Vulkan allocation/map/unmap/free calls reach the actual RADV device.** Same native fixture and fault-injection object, changing only production `BufferPool.cpp` to `HEAD^` for the negative control. Three fresh processes per variant: | RADV memory type | Parent, each of 3 runs | PR, each of 3 runs | |---|---|---| | type 0, device-local/unmapped | 4 injected failures; 6,291,456 bytes unreleased | 4 injected failures; 0 bytes unreleased | | type 2, coherent host-visible/mapped | 4 injected failures; 6,291,456 bytes unreleased | 4 injected failures; 0 bytes unreleased | | Total after local pools are destroyed | **12,582,912 bytes**, exit 1 | **0 bytes**, exit 0 | These are counted `VkDeviceMemory` allocation sizes before the fixture's final teardown cleanup, not RSS. The parent retains a 2 MiB allocation at every injected point before retry; point 3 also exposes one published unusable block in each memory-type sweep. With the PR every point reports `retained=0 blocks=0`, retries return the correct mapped/unmapped state, and final cleanup reports no invalid handle/mapping state. The selected device and all eight exercised fault points are verified in each process; nothing skips. This rules out a software-driver fallback or a test that fails before a native allocation exists. The matched pool object identifies the cleanup/publication change as the difference. Repository worktree is clean; the extraction/build script and six full logs are retained separately. Scope: native allocation cleanup, mapping and retry behavior on RADV. I did **not** run `RobustReadPastEnd`, `ExactSizes`, the full `agc_driver_pooled_buffer_range` executable, shader compute/readback, the wider runtime suite or a title; this is not a full-fixture pass or a merge onto newer main.
Amoenus commented 2026-10-17 11:30:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T11:30:22Z.


Validation at composition fa544a6a2 containing main 20a84154ff: the changed BufferPool/PooledBufferRange source is byte-identical to main. Full Windows/Linux relinker/library builds pass. agc_driver_pooled_buffer_range passes3/3 on verified NVIDIA RTX5080, driver32.0.16.1062, Windows11 Enterprise26200, with Khronos core1.4.363 and zero errors/warnings; it also passes3/3 on Mesa25.2.8 llvmpipe/LLVM20.1.2, Ubuntu24.04 WSL2. Each run reports slab metadata total leaked bytes=0. These are composition tests, not an unchanged PR-head or full-suite claim.

Follow-up against unchanged main 1846719e46: explicitly requesting AMD selects NVIDIA and throws before device creation, 3/3 fresh processes. The independent fixture-only correction is now #7104 (fork commit). At that exact changed head the full pooled-buffer fixture passes 6 AMD processes (full name and substring, three each), 12 NVIDIA processes and 9 llvmpipe processes; six unmatched-name controls still refuse explicitly. Actual vendor/device identity is verified per run; all positive runs report zero retained slab-metadata bytes. Windows positives use Khronos core1.4.363 with zero validation errors/warnings. Full relinker/library targets build on Windows/Linux and the separate CPU graphics group passes3/3 per OS. The PR contains the concise reproduction and complete selector matrix.

The fa544 composition evidence above retains its original scope; the new AMD coverage is the separately tested #7104 head. This is a fixture-selection fix, not a defect attribution to your cleanup or a title-startup improvement.

AI-assisted: yes (Codex); author responsible.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6233368117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6882#issuecomment-6233368117). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-17T11:30:22Z. --- Validation at composition `fa544a6a2` containing main `20a84154ff`: the changed BufferPool/PooledBufferRange source is byte-identical to main. Full Windows/Linux relinker/library builds pass. `agc_driver_pooled_buffer_range` passes3/3 on verified NVIDIA RTX5080, driver32.0.16.1062, Windows11 Enterprise26200, with Khronos core1.4.363 and zero errors/warnings; it also passes3/3 on Mesa25.2.8 llvmpipe/LLVM20.1.2, Ubuntu24.04 WSL2. Each run reports `slab metadata total leaked bytes=0`. These are composition tests, not an unchanged PR-head or full-suite claim. Follow-up against unchanged main `1846719e46`: explicitly requesting AMD selects NVIDIA and throws before device creation, 3/3 fresh processes. The independent fixture-only correction is now #7104 ([fork commit](https://github.com/Amoenus/AnyPS5/commit/3f1dcad6ddcba68a941a8243b1f95e1c48c67b4a)). At that exact changed head the full pooled-buffer fixture passes 6 AMD processes (full name and substring, three each), 12 NVIDIA processes and 9 llvmpipe processes; six unmatched-name controls still refuse explicitly. Actual vendor/device identity is verified per run; all positive runs report zero retained slab-metadata bytes. Windows positives use Khronos core1.4.363 with zero validation errors/warnings. Full relinker/library targets build on Windows/Linux and the separate CPU graphics group passes3/3 per OS. The PR contains the concise reproduction and complete selector matrix. The fa544 composition evidence above retains its original scope; the new AMD coverage is the separately tested #7104 head. This is a fixture-selection fix, not a defect attribution to your cleanup or a title-startup improvement. AI-assisted: yes (Codex); author responsible. <!-- codex-main20-pool-validation-v1 -->
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6882
No description provided.