feat(agc): trace device memory allocations and cache budgets #10194

Merged
harry-z-kang merged 7 commits from upstream-pr/10194 into main 2026-10-31 23:54:34 +00:00
harry-z-kang commented 2026-10-23 12:39:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harry-z-kang on 2026-10-23T12:39:16Z.


What

Add optional Vulkan allocation accounting for the missing device-local memory breakdown in #10041. APS5_TRACE_MEMORY_BUDGET=1 records actual allocation sizes by device, heap and allocation category, including host fallback, image-memory reuse and the active/retained parts of buffer slabs. Dynamic storage-cache budget queries report those counts beside heap budget/usage and the sampled, cached, reserved, available, cap and selected-budget terms.

The allocation, fallback, cache-limit and eviction policies keep their existing behavior. The new unattributed_usage/tracked_above_usage fields expose the difference from Vulkan's estimated heap usage; that difference is not claimed to consist only of driver allocations. Failed diagnostic metadata recording marks reports incomplete. The reported storage cap uses main's shared StorageTextureCeiling, including its 512 MiB floor. This provides measurement instrumentation for #10041; no title-unblock or performance improvement is claimed.

Integration with current main preserves #8672's idle-buffer reclaim and fresh budget read, and uses #10551's shared ceiling helper for both reclaim and reporting. Reporting happens once after any reclaim/re-read, using the final snapshot and the budget actually returned. Both the accounting checks and main's IdleReclaimPreservesImages case are retained. The direct-memory audit found the newly merged pixel function LDS pool: its allocation, host fallback attempt and cleanup now use accounting. The existing FirstSampleCopy cleanup hook is retained. This rebase also preserves main's shared ownership of depth-plane images and staging through cache eviction and recorded GPU work. Direct cleanup before the shared image owner exists uses the accounting helper.

Pooled dedicated buffers are reclassified when Buffer and DeviceBuffer reuse each other's allocations. Shared slab blocks keep their block category and partial-retention accounting. This addresses the reported category mismatch.

Merge order: #9712 must land first, as declared below. #10807, #10551 and #10062 have merged and are integrated here. The remaining earlier open overlap is #9188 (render-target image-pool release); its integration point is described in the coordination comment. #8672 has merged and is integrated here; #7833 has closed. The original audit also reported shared files it could not compare because those proposals already conflicted with main, so it did not establish zero overlap with them.

The resolution for #10807's merge order keeps its DeviceMemoryType / AllocateImageMemory / ReleaseImageMemory source-image path. Allocation, host fallback, reuse and retention are counted inside the image pool. The direct source-image MemoryAccounting::Allocate and Free calls are removed; the accounting include stays for the black/letterbox image paths. The new Vulkan regression checks one source allocation through active use, pooled retention, reuse and pool destruction.

The refreshed overlap comment also flags #4472 (pool release policy), #8748 (host-placed buffer reuse) and #10472 (image suballocation). These do not provide the current accounting API. Later integration must preserve ledger removal at actual frees, the host-placement key together with the category argument, and per-block accounting for shared image ranges respectively. No merge order has been agreed for those overlaps; the original audit's incomplete comparisons remain a limitation.

#10062's MoltenVK resolver defers Vulkan memory frees until the graphics queue is idle. The accounting helper recognizes that resolver and leaves queued allocations in the ledger; the deferred drain removes each entry immediately before the underlying Vulkan free, including device cleanup and immediate fallback paths. Queued allocations keep their category and active/retained charge until the actual free. agc_deferred_memory_accounting checks queuing through both APIs, failed idle waits, device loss, final cleanup, direct frees and allocator forwarding. Its mock free callback checks that the ledger entry is already gone when a handle becomes reusable. Reverting the deferred-resolver guard makes this test fail. This path was tested with mocked Vulkan callbacks on both Windows toolchains; no native MoltenVK/macOS run is claimed.

Main's per-slot presentation-upload images are also accounted. Their allocations and frees now go through the ledger as presentation upload; the Vulkan accounting regression uploads two different extents, submits and waits for each, checks exactly one live upload-image entry after resize, then verifies image and buffer-pool cleanup return to the initial allocation count. Omitting the new allocation hook fails this regression with "presentation upload allocation or resize was not counted exactly once" (CTest exit 8, no VUIDs); restoring it passes. Cleanup assertions drain deferred frees first rather than treating queued memory as already released. The rebase also preserves main's bounded search for an exact-sized buffer inside a pool class and its new job-manager test registration.

The October 28 rebase preserves main's per-device deferred-destruction resolvers and its allowance for a later Vulkan loader after the last live device is gone. The immediate fallback resolves the free callback for that device, then removes its accounting entry immediately before the actual free. Both main's loader-reload test and the accounting cases are retained. The added accounting regression checks an earlier device's immediate free while a later resolver is installed and queues and drains the later device through its own callback, including heap/byte charges and allocator forwarding. Deliberately selecting the latest resolver instead of the device's resolver makes this case fail; restoring the resolution passes. The fresh raw-allocation/free audit found no additional allocation sites to instrument. Vorbis is checked out at main's required c2aa86b05e981c96bf381fc6aa11cdd03eccc2fb.

The October 29 rebase applied without textual conflicts. The allocation/free audit found main's new mesh-window storage buffer. Its allocation and cleanup now use MemoryAccounting::Allocate / Free under mesh window, preserving main's placement, initialization and failure cleanup. The real Vulkan regression prepares the pool twice, checks exactly one live allocation with actual bytes, heap and active state, verifies the second preparation reuses it, then releases and drains it back to the initial ledger count. Omitting the allocation hook makes the new check fail with "mesh window allocation was not counted exactly once" (CTest exit 8, zero VUIDs); restoring it passes. Main's existing agc_driver_mesh_vector_window_waves draw test is added to both comparison arms, and the new accounting case executes on the RTX 5080 with both Windows toolchains. FreeType is at main's required 37515cf56ba3349656049edbed89ffc6f6466f2d revision.

The latest October 31 rebase onto main 684dfc1d56 keeps the merged DLL initialization fix #13668. Main moved AGC test registrations into tests/cmake/<executable>.cmake. During each stopped rebase, python3 tools/agc_test_split.py resolve migrated this PR's registrations into the buffer-pool, deferred-destruction and Vulkan accounting fragments. The five accounting cases retain their commands, environment settings, 30-second timeouts and budget-output checks. Main's sorted fragment inclusion and automatic execution-test registration are preserved. The runtime accounting changes remain intact, and the raw-allocation/free audit found no new sites to instrument.

Tested

Windows 11 10.0.26300, Ryzen 7 9800X3D, NVIDIA GeForce RTX 5080, NVIDIA 617.42, Release, BUILD_TESTING=ON. Rebased onto main with #10807, #10551 and #10062 integrated and repeated focused validation:

  • Main baseline: 684dfc1d561d09a8c35c7c153c95bcfed7e49896.
  • PR head: 4eb530d609478d091dd97a52be738ffcfb2cc453, with the accounting, category and integration fixes on that baseline.
Native Windows toolchain Full libs build on main and PR Same focused tests on main Same focused tests on PR New accounting tests on PR
WinLibs GCC 15.2.0 r7 pass / pass 13/13 13/13 5/5
MSYS2 UCRT64 GCC 16.2.0-6 pass / pass 13/13 13/13 5/5

The earlier unmodified-main run at b7105f7285719ead25fde7cf44f5c891e790e756 failed configuration because nghttp2's install export included windows_seh_personalities, which is not in an export set. Both refreshed MSYS2 arms retain the local -DCMAKE_SKIP_INSTALL_RULES=ON setting to validate compilation and runtime without generating install/export rules. No source workaround is included in this PR; installation was not validated. WinLibs uses its existing default install-rule setting.

The previous main builds at 319621ba2e578bd053b0baba2877fe70520e0737 stalled in ccache while compiling SDL. This refresh uses CCACHE_DISABLE=1 from the start for main and PR builds with both compilers. Compiler flags and dependency revisions are unchanged by that bypass.

The same thirteen-test pattern in all four comparison runs was ^(agc_buffer_pool.*|agc_device_memory_fallback|agc_driver_graphics|agc_driver_pooled_buffer_range|agc_driver_multisample_retirement|agc_driver_host_import_failure_handles|agc_storage_write_back|agc_driver_depth_plane_sampling_evicting|agc_driver_presentation_pass|agc_driver_mesh_vector_window_waves|agc_deferred_destruction)$. Every run used CTest -V, ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=error,warn,layer, ANYPS5_GPU=RTX 5080 and APS5_TRACE_MEMORY_BUDGET=1. The trace flag is ignored by main and exercises accounting on the PR.

All four comparison logs confirm eight validation-layer insertions. Neither baseline nor PR logs contain the missing-layer warning or any VUID- error. Both accounting-test runs also loaded validation, reported complete=1 and contained zero VUIDs. All 62 test executions pass; none skipped.

The MSYS2 0xc0000142 startup failure recorded on the prior baseline de83e8f270 is resolved by the merged #13668 in this baseline. Main includes its merge commit bdabbb8415aecb83d30300c6e7b485981d3c70ce. The selected MSYS2 tests now run through DLL initialization and Vulkan execution successfully. This is focused validation of this PR; the full MSYS2 test suite was not rerun.

agc_memory_accounting covers image retention/reclassification, host fallback heap attribution, failed allocation output, slab sharing/retention/reuse, separate devices and cleanup. The added reclaim case runs through ReclaimIdleDevice and BufferPool::destroy: the cold 2 MiB allocation leaves the ledger, while the active 8 MiB buffer and retained 4 MiB image keep their correct charges; fixture cleanup leaves no Vulkan or ledger allocation.

agc_memory_accounting also checks DeviceBuffer -> Buffer -> DeviceBuffer reuse of one allocation, both with equal buffer sizes and with exact-size rebinding. Each step verifies category, heap, allocated and retained bytes, allocation count and final cleanup; the slab reuse check also verifies its block category. Before the fix, the new test fails on a2fd88fb9e because Buffer retains the device-buffer category.

agc_memory_accounting_budget_cap checks the emitted diagnostic cap and selected budget for an unpressured 2 GiB heap. The old report printed a 512 MiB cap beside the actual 1 GiB selection and fails this test; the corrected report prints 1 GiB for both. agc_memory_accounting_budget_floor also checks a 256 MiB heap and budget: the diagnostic cap and actual selection both use the shared 512 MiB floor. Restoring the old raw half-budget formula makes this new test fail with a 128 MiB cap beside a 512 MiB selection. Cache policy is unchanged.

agc_driver_memory_accounting creates and binds real Vulkan images, verifies allocation bytes and heap, checks image-pool reuse, prints a budget report and verifies cleanup returns to the initial allocation count. It now checks the merged presentation-source path: exactly one allocation is tracked, retained bytes match the image pool, a retained allocation is reused, and pool destruction restores the initial ledger count. It also retains the first-sample image cleanup case and now creates, submits work using, and releases a real pixel function LDS buffer. The focused comparison now also includes agc_driver_depth_plane_sampling_evicting with its 1 MiB copy-cache budget, exercising the depth-plane ownership change. Both toolchain logs confirm that the added idle-reclaim and pixel-LDS cases executed and passed. The pixel-LDS case uses a 16 MiB test limit and runs when the device supports the fragment subgroup operations that path needs.

Conventions (python3 tools/check_conventions.py --base origin/main) and git diff --check pass. The original overlap audit completed before opening; merge-order requests and the concrete integration resolutions are recorded in the coordination comment.

Example from the real Vulkan test: the 4,194,304-byte second image appears once on heap 0, with its new category, zero retained bytes and complete=1. The shared host buffer slab is charged to heap 1 and reports active and retained byte counts separately. The forced device-memory refusal case in agc_driver_presentation_pass ran on main and PR with both toolchains and placed the source in host memory. No game binary or private capture was used. Linux runtime and macOS were not tested.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #9712
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5080, NVIDIA 617.42, Windows 11 10.0.26300
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4982855649 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10194). Originally posted by [harry-z-kang](https://github.com/harry-z-kang) on 2026-10-23T12:39:16Z. --- ### What Add optional Vulkan allocation accounting for the missing device-local memory breakdown in #10041. `APS5_TRACE_MEMORY_BUDGET=1` records actual allocation sizes by device, heap and allocation category, including host fallback, image-memory reuse and the active/retained parts of buffer slabs. Dynamic storage-cache budget queries report those counts beside heap budget/usage and the sampled, cached, reserved, available, cap and selected-budget terms. The allocation, fallback, cache-limit and eviction policies keep their existing behavior. The new `unattributed_usage`/`tracked_above_usage` fields expose the difference from Vulkan's estimated heap usage; that difference is not claimed to consist only of driver allocations. Failed diagnostic metadata recording marks reports incomplete. The reported storage cap uses main's shared `StorageTextureCeiling`, including its 512 MiB floor. This provides measurement instrumentation for #10041; no title-unblock or performance improvement is claimed. Integration with current main preserves #8672's idle-buffer reclaim and fresh budget read, and uses #10551's shared ceiling helper for both reclaim and reporting. Reporting happens once after any reclaim/re-read, using the final snapshot and the budget actually returned. Both the accounting checks and main's `IdleReclaimPreservesImages` case are retained. The direct-memory audit found the newly merged pixel function LDS pool: its allocation, host fallback attempt and cleanup now use accounting. The existing `FirstSampleCopy` cleanup hook is retained. This rebase also preserves main's shared ownership of depth-plane images and staging through cache eviction and recorded GPU work. Direct cleanup before the shared image owner exists uses the accounting helper. Pooled dedicated buffers are reclassified when `Buffer` and `DeviceBuffer` reuse each other's allocations. Shared slab blocks keep their block category and partial-retention accounting. This addresses [the reported category mismatch](https://github.com/boykopovar/AnyPS5/pull/10194#issuecomment-6385961998). Merge order: #9712 must land first, as declared below. #10807, #10551 and #10062 have merged and are integrated here. The remaining earlier open overlap is #9188 (render-target image-pool release); its integration point is described in [the coordination comment](https://github.com/boykopovar/AnyPS5/pull/10194#issuecomment-6365845559). #8672 has merged and is integrated here; #7833 has closed. The original audit also reported shared files it could not compare because those proposals already conflicted with main, so it did not establish zero overlap with them. The resolution for [#10807's merge order](https://github.com/boykopovar/AnyPS5/pull/10194#issuecomment-6392935911) keeps its `DeviceMemoryType` / `AllocateImageMemory` / `ReleaseImageMemory` source-image path. Allocation, host fallback, reuse and retention are counted inside the image pool. The direct source-image `MemoryAccounting::Allocate` and `Free` calls are removed; the accounting include stays for the black/letterbox image paths. The new Vulkan regression checks one source allocation through active use, pooled retention, reuse and pool destruction. The refreshed overlap comment also flags #4472 (pool release policy), #8748 (host-placed buffer reuse) and #10472 (image suballocation). These do not provide the current accounting API. Later integration must preserve ledger removal at actual frees, the host-placement key together with the category argument, and per-block accounting for shared image ranges respectively. No merge order has been agreed for those overlaps; the original audit's incomplete comparisons remain a limitation. #10062's MoltenVK resolver defers Vulkan memory frees until the graphics queue is idle. The accounting helper recognizes that resolver and leaves queued allocations in the ledger; the deferred drain removes each entry immediately before the underlying Vulkan free, including device cleanup and immediate fallback paths. Queued allocations keep their category and active/retained charge until the actual free. `agc_deferred_memory_accounting` checks queuing through both APIs, failed idle waits, device loss, final cleanup, direct frees and allocator forwarding. Its mock free callback checks that the ledger entry is already gone when a handle becomes reusable. Reverting the deferred-resolver guard makes this test fail. This path was tested with mocked Vulkan callbacks on both Windows toolchains; no native MoltenVK/macOS run is claimed. Main's per-slot presentation-upload images are also accounted. Their allocations and frees now go through the ledger as `presentation upload`; the Vulkan accounting regression uploads two different extents, submits and waits for each, checks exactly one live upload-image entry after resize, then verifies image and buffer-pool cleanup return to the initial allocation count. Omitting the new allocation hook fails this regression with "presentation upload allocation or resize was not counted exactly once" (CTest exit 8, no VUIDs); restoring it passes. Cleanup assertions drain deferred frees first rather than treating queued memory as already released. The rebase also preserves main's bounded search for an exact-sized buffer inside a pool class and its new job-manager test registration. The October 28 rebase preserves main's per-device deferred-destruction resolvers and its allowance for a later Vulkan loader after the last live device is gone. The immediate fallback resolves the free callback for that device, then removes its accounting entry immediately before the actual free. Both main's loader-reload test and the accounting cases are retained. The added accounting regression checks an earlier device's immediate free while a later resolver is installed and queues and drains the later device through its own callback, including heap/byte charges and allocator forwarding. Deliberately selecting the latest resolver instead of the device's resolver makes this case fail; restoring the resolution passes. The fresh raw-allocation/free audit found no additional allocation sites to instrument. Vorbis is checked out at main's required `c2aa86b05e981c96bf381fc6aa11cdd03eccc2fb`. The October 29 rebase applied without textual conflicts. The allocation/free audit found main's new mesh-window storage buffer. Its allocation and cleanup now use `MemoryAccounting::Allocate` / `Free` under `mesh window`, preserving main's placement, initialization and failure cleanup. The real Vulkan regression prepares the pool twice, checks exactly one live allocation with actual bytes, heap and active state, verifies the second preparation reuses it, then releases and drains it back to the initial ledger count. Omitting the allocation hook makes the new check fail with "mesh window allocation was not counted exactly once" (CTest exit 8, zero VUIDs); restoring it passes. Main's existing `agc_driver_mesh_vector_window_waves` draw test is added to both comparison arms, and the new accounting case executes on the RTX 5080 with both Windows toolchains. FreeType is at main's required `37515cf56ba3349656049edbed89ffc6f6466f2d` revision. The latest October 31 rebase onto main `684dfc1d56` keeps the merged DLL initialization fix #13668. Main moved AGC test registrations into `tests/cmake/<executable>.cmake`. During each stopped rebase, `python3 tools/agc_test_split.py resolve` migrated this PR's registrations into the buffer-pool, deferred-destruction and Vulkan accounting fragments. The five accounting cases retain their commands, environment settings, 30-second timeouts and budget-output checks. Main's sorted fragment inclusion and automatic execution-test registration are preserved. The runtime accounting changes remain intact, and the raw-allocation/free audit found no new sites to instrument. ### Tested Windows 11 10.0.26300, Ryzen 7 9800X3D, NVIDIA GeForce RTX 5080, NVIDIA 617.42, Release, BUILD_TESTING=ON. Rebased onto main with #10807, #10551 and #10062 integrated and repeated focused validation: - Main baseline: `684dfc1d561d09a8c35c7c153c95bcfed7e49896`. - PR head: `4eb530d609478d091dd97a52be738ffcfb2cc453`, with the accounting, category and integration fixes on that baseline. | Native Windows toolchain | Full `libs` build on main and PR | Same focused tests on main | Same focused tests on PR | New accounting tests on PR | | --- | --- | --- | --- | --- | | WinLibs GCC 15.2.0 r7 | pass / pass | 13/13 | 13/13 | 5/5 | | MSYS2 UCRT64 GCC 16.2.0-6 | pass / pass | 13/13 | 13/13 | 5/5 | The earlier unmodified-main run at `b7105f7285719ead25fde7cf44f5c891e790e756` failed configuration because nghttp2's install export included `windows_seh_personalities`, which is not in an export set. Both refreshed MSYS2 arms retain the local `-DCMAKE_SKIP_INSTALL_RULES=ON` setting to validate compilation and runtime without generating install/export rules. No source workaround is included in this PR; installation was not validated. WinLibs uses its existing default install-rule setting. The previous main builds at `319621ba2e578bd053b0baba2877fe70520e0737` stalled in ccache while compiling SDL. This refresh uses `CCACHE_DISABLE=1` from the start for main and PR builds with both compilers. Compiler flags and dependency revisions are unchanged by that bypass. The same thirteen-test pattern in all four comparison runs was `^(agc_buffer_pool.*|agc_device_memory_fallback|agc_driver_graphics|agc_driver_pooled_buffer_range|agc_driver_multisample_retirement|agc_driver_host_import_failure_handles|agc_storage_write_back|agc_driver_depth_plane_sampling_evicting|agc_driver_presentation_pass|agc_driver_mesh_vector_window_waves|agc_deferred_destruction)$`. Every run used CTest `-V`, `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=error,warn,layer`, `ANYPS5_GPU=RTX 5080` and `APS5_TRACE_MEMORY_BUDGET=1`. The trace flag is ignored by main and exercises accounting on the PR. All four comparison logs confirm eight validation-layer insertions. Neither baseline nor PR logs contain the missing-layer warning or any `VUID-` error. Both accounting-test runs also loaded validation, reported `complete=1` and contained zero VUIDs. All 62 test executions pass; none skipped. The MSYS2 `0xc0000142` startup failure recorded on the prior baseline `de83e8f270` is resolved by the merged #13668 in this baseline. Main includes its merge commit `bdabbb8415aecb83d30300c6e7b485981d3c70ce`. The selected MSYS2 tests now run through DLL initialization and Vulkan execution successfully. This is focused validation of this PR; the full MSYS2 test suite was not rerun. `agc_memory_accounting` covers image retention/reclassification, host fallback heap attribution, failed allocation output, slab sharing/retention/reuse, separate devices and cleanup. The added reclaim case runs through `ReclaimIdleDevice` and `BufferPool::destroy`: the cold 2 MiB allocation leaves the ledger, while the active 8 MiB buffer and retained 4 MiB image keep their correct charges; fixture cleanup leaves no Vulkan or ledger allocation. `agc_memory_accounting` also checks `DeviceBuffer` -> `Buffer` -> `DeviceBuffer` reuse of one allocation, both with equal buffer sizes and with exact-size rebinding. Each step verifies category, heap, allocated and retained bytes, allocation count and final cleanup; the slab reuse check also verifies its block category. Before the fix, the new test fails on `a2fd88fb9e` because `Buffer` retains the device-buffer category. `agc_memory_accounting_budget_cap` checks the emitted diagnostic cap and selected budget for an unpressured 2 GiB heap. The old report printed a 512 MiB cap beside the actual 1 GiB selection and fails this test; the corrected report prints 1 GiB for both. `agc_memory_accounting_budget_floor` also checks a 256 MiB heap and budget: the diagnostic cap and actual selection both use the shared 512 MiB floor. Restoring the old raw half-budget formula makes this new test fail with a 128 MiB cap beside a 512 MiB selection. Cache policy is unchanged. `agc_driver_memory_accounting` creates and binds real Vulkan images, verifies allocation bytes and heap, checks image-pool reuse, prints a budget report and verifies cleanup returns to the initial allocation count. It now checks the merged presentation-source path: exactly one allocation is tracked, retained bytes match the image pool, a retained allocation is reused, and pool destruction restores the initial ledger count. It also retains the first-sample image cleanup case and now creates, submits work using, and releases a real pixel function LDS buffer. The focused comparison now also includes `agc_driver_depth_plane_sampling_evicting` with its 1 MiB copy-cache budget, exercising the depth-plane ownership change. Both toolchain logs confirm that the added idle-reclaim and pixel-LDS cases executed and passed. The pixel-LDS case uses a 16 MiB test limit and runs when the device supports the fragment subgroup operations that path needs. Conventions (`python3 tools/check_conventions.py --base origin/main`) and `git diff --check` pass. The original overlap audit completed before opening; merge-order requests and the concrete integration resolutions are recorded in [the coordination comment](https://github.com/boykopovar/AnyPS5/pull/10194#issuecomment-6365845559). Example from the real Vulkan test: the 4,194,304-byte second image appears once on heap 0, with its new category, zero retained bytes and `complete=1`. The shared host buffer slab is charged to heap 1 and reports active and retained byte counts separately. The forced device-memory refusal case in `agc_driver_presentation_pass` ran on main and PR with both toolchains and placed the source in host memory. No game binary or private capture was used. Linux runtime and macOS were not tested. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: <!-- #PR, or none --> #9712 - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> NVIDIA GeForce RTX 5080, NVIDIA 617.42, Windows 11 10.0.26300 - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-23 12:45:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T12:45:13Z.

Review: DISMISSED


Reviewed exact head 3bd56fff7e331c100c4bb70c3eb9f8de99e6d8ed. The accounting API and tests are well scoped for the #10041 measurement step, and the Windows validation runs are detailed. The tested main base e84c529d6 is now 18 commits behind current main fa3dc7f3; that interval modifies Execution/src/VulkanDevice.cpp (including AGC allocation behavior) and tests/ShaderMemory.cpp, which overlap the accounting integration/test surface. Please rebase onto current main and repeat the same focused main-vs-PR allocation/cache tests with validation enabled, then update the base/head and results in the PR description. Current hosted product/runtime jobs are skipped by path policy, so they do not replace that focused rerun.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5628385521 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10194#pullrequestreview-5628385521). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T12:45:13Z. **Review:** DISMISSED --- Reviewed exact head `3bd56fff7e331c100c4bb70c3eb9f8de99e6d8ed`. The accounting API and tests are well scoped for the #10041 measurement step, and the Windows validation runs are detailed. The tested main base `e84c529d6` is now 18 commits behind current main `fa3dc7f3`; that interval modifies `Execution/src/VulkanDevice.cpp` (including AGC allocation behavior) and `tests/ShaderMemory.cpp`, which overlap the accounting integration/test surface. Please rebase onto current main and repeat the same focused main-vs-PR allocation/cache tests with validation enabled, then update the base/head and results in the PR description. Current hosted product/runtime jobs are skipped by path policy, so they do not replace that focused rerun.
adriadam10 commented 2026-10-24 00:45:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T00:45:16Z.

Review: CHANGES_REQUESTED


The accounting itself reads well: every allocate/free in Graphics and Presentation goes through the ledger, slab and image-pool retention are separated from active bytes, and nothing changes without APS5_TRACE_MEMORY_BUDGET. What blocks it is the state of the branch:

  • It conflicts with main now that #8672 is merged. Graphics/src/ShaderResources.cpp: storageBudget became a read lambda with cached.ceiling and a ReclaimIdleDevice re-read, so MemoryAccounting::Report has to be called from there (after the re-read, so the report shows the budget actually used). tests/BufferPool.cpp: the new MemoryAccountingChecks block collides with IdleReclaimPreservesImages.
  • After rebasing, grep main again for raw vkAllocateMemory / vkFreeMemory calls that landed since your base and route them through MemoryAccounting; a missed allocation shows up as unattributed_usage, a missed free as a leaked ledger entry. Add a case in the tests that goes through the reclaim path (ReclaimIdleDevice destroys through BufferPool::destroy).
  • Depends on: #9712 is still open, so this can only land after it.
  • Please repeat the focused main-vs-PR run with validation on the new head, as @MarcZX10 asked.

Welcome back once it is rebased.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5635891205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10194#pullrequestreview-5635891205). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-24T00:45:16Z. **Review:** CHANGES_REQUESTED --- The accounting itself reads well: every allocate/free in Graphics and Presentation goes through the ledger, slab and image-pool retention are separated from active bytes, and nothing changes without `APS5_TRACE_MEMORY_BUDGET`. What blocks it is the state of the branch: - It conflicts with `main` now that #8672 is merged. `Graphics/src/ShaderResources.cpp`: `storageBudget` became a `read` lambda with `cached.ceiling` and a `ReclaimIdleDevice` re-read, so `MemoryAccounting::Report` has to be called from there (after the re-read, so the report shows the budget actually used). `tests/BufferPool.cpp`: the new `MemoryAccountingChecks` block collides with `IdleReclaimPreservesImages`. - After rebasing, grep `main` again for raw `vkAllocateMemory` / `vkFreeMemory` calls that landed since your base and route them through `MemoryAccounting`; a missed allocation shows up as `unattributed_usage`, a missed free as a leaked ledger entry. Add a case in the tests that goes through the reclaim path (`ReclaimIdleDevice` destroys through `BufferPool::destroy`). - `Depends on: #9712` is still open, so this can only land after it. - Please repeat the focused main-vs-PR run with validation on the new head, as @MarcZX10 asked. Welcome back once it is rebased.
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!10194
No description provided.