Skip to content

fix(agc): free a completed batch's command buffer instead of keeping it - #9565

Merged
oneandonlydean merged 5 commits into
boykopovar:mainfrom
EagleBearerYS:port/fable-fix-command-buffer-release
Oct 30, 2026
Merged

oneandonlydean merged 5 commits into
boykopovar:mainfrom
EagleBearerYS:port/fable-fix-command-buffer-release

Conversation

@EagleBearerYS

@EagleBearerYS EagleBearerYS commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

The recorder keeps up to 64 completed command buffers for reuse and begins new batches on them. fable-void found that on Windows drivers, a command buffer keeps the host memory of its largest recording until it is freed. Neither the implicit reset at begin nor a releasing reset gives that memory back. So every kept command buffer holds the peak of its own recordings. In one of his title runs, the driver's command arenas grew by 3.4 GiB in 17 s, until the run hit the RAM cap.

This adapts fable-void's dfbbdfd from his fork (wip/new-gpu-path). His recorder keeps a pool and a spare list per stream, and main has one of each:

  • c6bb8c5: Recorder::release frees a batch's command buffer, and every batch allocates its own from the context's pool. The pool then holds only what batches still recording or in flight need. Fences are still kept for reuse. The spare list's comment, which described command buffers being kept, goes with them.
  • 22bf8fc (counter): with APS5_PROFILE_DRAW set, the [recorder] submits line also gives command buffers freed at batch release N, fences kept for reuse N. Without the profile it costs one test of a static const bool.

The cost is one vkAllocateCommandBuffers per batch, where main reused a kept one.

fable-void's own test, idle_command_memory, reads Windows private bytes through a test fixture main doesn't have, so it isn't carried.

Overlap: checked with git merge-tree against every open PR touching these files, on main 8c26eac. Two conflict:

Tested

  • Red/green on GitHub's Linux runner (run), on Mesa llvmpipe. agc_recorder_command_buffer_release (new mode --command-buffer-release-only of the recorder tests) counts the recorder's vkAllocateCommandBuffers and vkFreeCommandBuffers calls through a resolver probe, over three completed batches. Each batch must free the command buffer it allocated.
    • Red: with main's code, it fails ×3 with "command buffer release: after 1 completed batches 1 command buffers were allocated and 0 freed (a completed batch kept its command buffer)".
    • Green: it passes ×10, and so do 49 of the other 55 AGC tests of that run; the other 6 skip on llvmpipe, and none fail.
    • The libc and libkernel suites pass.
  • GitHub's Windows runner (same run): it builds, and the libc and libkernel suites pass. It has no Vulkan device, so the recorder tests skip there.
  • Linux, whole tree: both commits are part of a port of twelve of fable-void's fixes, mirrored as CI's Linux job on main cf2c667: 1812/1818, with the same 6 failures as main.
  • Validation layer, main against this PR (CONTRIBUTING's AGC rule), on one GitHub Linux runner (run). Both runs used VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, with VK_LOADER_DEBUG=layer to show the layer loading. The device was llvmpipe (LLVM 20.1.2) on Mesa 25.2.8, Ubuntu 24.04.5, Khronos validation layers 1.3.275.
    • Tests: this PR's agc_recorder_command_buffer_release, plus the 56 tests whose build inputs this PR touches, such as agc_storage_write_back, agc_host_import_unmap and agc_pipeline_cache: 57 with this PR and 56 on main, where the new test doesn't exist. On both trees 6 of them skip on llvmpipe, agc_unit_shadow among them, and none fail: main ran its other 50 once and this PR its other 51 three times.
    • The loader inserted the layer 54 times on main and 153 with this PR, and neither log has was not found.
    • Both logs report the same two messages, VUID-VkImageViewCreateInfo-usage-02275 and VUID-vkCmdCopyBuffer-srcBuffer-00118, from tests this PR doesn't change. This PR adds no VUID- message.
  • jotitadev's run (review): Ubuntu 26.04, GCC 15.2.0, this PR's 22bf8fc merged onto main 6ef5a1c, ANYPS5_NO_SHADER_CACHE=1.
    • agc_recorder_command_buffer_release passes 3 of 3 on an NVIDIA GeForce RTX 3070 (proprietary driver) and on llvmpipe (LLVM 21.1.8).
    • With Recorder.cpp and Recorder.hpp at main and the test kept, it fails on both devices with the expected message.
    • The recorder and graphics ^agc tests have the same pass set as main on the 3070 (lds_atomics64, driver_flip and display_buffer_dcc left out).
  • Scramblrrrr's Windows run (comment): Windows 11 10.0.26200, NVIDIA GeForce RTX 5070 Ti (617.42), WinLibs GCC 15.2 r7, Release. This PR's 22bf8fc on main 7e2ba73 plus other open PRs, with this PR's change the only difference between the two arms.
    • With main's Recorder.cpp and Recorder.hpp and the new test, it fails after batch 1, with 1 command buffer allocated and 0 freed. With this PR it passes.
    • All 74 existing recorder modes pass without this PR, and all 75 with it, in a set of 233 cases: 231 pass and 2 skip as expected.
    • Validation: Khronos layers 1.4.363, loaded and inserted 191 times with this PR, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and ctest -V. Both arms log the same two VUID-VkImageViewCreateInfo-usage-02275 errors, from agc_sampled_storage_base_level_usage. This PR adds no VUID- message.
  • 1da6fea, main 4777cac merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run): On Linux, agc_recorder_command_buffer_release and 49 of the other 55 AGC tests run with it pass 10 of 10, and 6 skip; none fail. On Windows all 69 build: 3 pass 10 of 10 and the other 66, the new test among them, skip without a Vulkan device. On Linux's one run with main's implementation, agc_recorder_command_buffer_release fails, agc_gpu_timing_complete times out, 48 pass and 6 skip. libkernel's suite passes on both and libc's on Windows. On Linux libc's one failure is precise_wait, a timing test this PR doesn't touch.
  • 3c44708, main b7d1d47 merged in (clean; the PR's own diff is unchanged), on GitHub's runners (run): agc_recorder_command_buffer_release and the AGC tests run with it pass 10 of 10. On Linux that is 56 tests, 6 of them skipped. On Windows all 69 build and pass, and 66 skip without a Vulkan device. On Linux agc_recorder_command_buffer_release fails with main's implementation. The libc and libkernel suites pass on both runners. The libc and libkernel suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • check_conventions.py passes, with no comment lines added.
  • Resident Evil Village (PPSA01556), 5 minutes at the static main menu, on the RTX 3070 Laptop GPU (NVIDIA 617.42, Windows 11), on a local tree with this PR and our other two ports of fable-void's shared fixes, with APS5_PROFILE_DRAW=1; no fatal error. The last [recorder] line reads submits 44845, ... command buffers freed at batch release 44844, fences kept for reuse 44844, so the release path runs for every batch in this title.
  • Not measured: the memory this saves on Windows. The Resident Evil Village pair run didn't use a matching control, so it gives no memory figure, and this PR makes no claim about the size of the saving. The counter above shows the path runs for every batch.
  • 3629538, a merge of main f3eb573 (run). The one conflict was the Windows set_tests_properties list in core/libs/prx/libSceAgcDriver/CMakeLists.txt, where Astronaut10's perf(agc): repeat a draw shape's resident targets and pipeline instead of looking them up again #11696 adds agc_repeat_storage_guard and this PR adds agc_recorder_command_buffer_release; the merge keeps both. This PR's other changed lines are the same. On Linux, agc_recorder_command_buffer_release fails with main's code and passes 10 runs in a row with the change, run with the recorder and AGC tests that share its executable and perf(agc): repeat a draw shape's resident targets and pipeline instead of looking them up again #11696's agc_repeat_storage_guard. Linux: 75 run, 68 pass, 7 skip, 0 fail; the skips (agc_driver_unit_shadow, agc_driver_unit_shadow_budget, agc_import_settle_initial_dcc, agc_pipeline_cache_file, agc_shadowed_key_stores, agc_storage_clear_hand_over and agc_unit_shadow) skip with main's code too. Windows: 91 run, 4 pass, 87 skip (the Vulkan device tests), 0 fail. Suites: libc and libkernel pass on Linux (171 and 289). On Windows libc passes (199), and libkernel passes 309 of 312: exec_arguments, guest_timed_join_import_libkernel_sys and guest_timed_join_import_libkernel_web fail at their setup in the verify's Windows build (FileNotFoundError starting the title, or copying the libraries they load), with main's code too, and pass in main's own Windows job at 1829def (job). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.

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: none (merges before feat(agc): batch a dispatch run's staged copy-ins ahead of it #9289, agreed in its thread; no order with fix(agc): save the guest bytes of results that become pending over a surface that is no longer fully write-watched #7048; see Overlap)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: Mesa llvmpipe (LLVM 20.1.2), Ubuntu 24.04, GitHub's Linux runner, with the validation comparison (Mesa 25.2.8); NVIDIA GeForce RTX 3070 (proprietary driver) and llvmpipe (LLVM 21.1.8), Ubuntu 26.04, in jotitadev's run. NVIDIA GeForce RTX 5070 Ti (617.42), Windows 11, in Scramblrrrr's run. GitHub's Windows runner has no Vulkan device.
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

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 6182 core/libs/prx/libSceAgcDriver/CMakeLists.txt L2008
PR 9875 core/libs/prx/libSceAgcDriver/CMakeLists.txt L2008
PR 9898 core/libs/prx/libSceAgcDriver/CMakeLists.txt L2008
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp L12416

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 1368 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1395 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 1896 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 2434 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 4449 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5021 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 5371 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 5925 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6185 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6186 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6187 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6188 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6192 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6209 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6280 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6300 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6412 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6481 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6501 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6808 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 6905 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6970 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 6971 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7048 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7085 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7275 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7457 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7464 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 7514 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 7604 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 7622 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 7689 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8014 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8246 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8484 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 8542 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 8592 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9020 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9335 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9356 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9387 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 9700 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9712 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 9748 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9852 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 9884 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10026 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10049 core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10193 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10233 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10249 core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 10442 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10472 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 10492 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10757 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 10920 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
PR 11351 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 11442 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 11444 core/libs/prx/libSceAgcDriver/CMakeLists.txt
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
PR 11554 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12120 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12324 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12828 core/libs/prx/libSceAgcDriver/CMakeLists.txt
PR 12862 core/libs/prx/libSceAgcDriver/CMakeLists.txt

@MarcZX10

Copy link
Copy Markdown
Contributor

Early review feedback while this remains a draft: the Linux red/green allocation probe gives useful evidence that completed batches free their command buffers, and the change is scoped to the recorder. Before marking this ready, please resolve the listed overlap with #9289 in Recorder::release and #7048 in tests/Recorder.cpp with the affected authors; add Depends on where an agreed order is required and retain both PRs’ behavior/tests. The repo’s AGC rule also requires a same-machine, same-GPU focused main/change run with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and the Khronos validation layer, confirming it loaded and comparing VUIDs. The current report has a Linux llvmpipe regression test but no such paired validation run, and it says the Windows memory measurement is still pending. I did not run tests locally.

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this on real hardware (Linux, NVIDIA and lavapipe). Head 22bf8fcc9, merged onto origin/main at 6ef5a1c4c.

Machine: Ubuntu 26.04, GCC 15.2.0, ninja -j3, ANYPS5_NO_SHADER_CACHE=1, device picked with VK_ICD_FILENAMES.

agc_recorder_command_buffer_release (the new --command-buffer-release-only case), ctest --repeat until-fail:3:

device result
NVIDIA GeForce RTX 3070 Passed (3/3)
llvmpipe (lavapipe, LLVM 21.1.8) Passed (3/3)

Negative control: reverting Recorder.cpp/Recorder.hpp to origin/main and keeping only the test + its add_test makes it fail on both devices with the expected message, so the test is a genuine red→green guard:

AGC graphics: command buffer release: after 1 completed batches 1 command buffers were allocated and 0 freed (a completed batch kept its command buffer)

No regression in the recorder/graphics ^agc suite versus origin/main on the RTX 3070 (same pass set; lds_atomics64/driver_flip/display_buffer_dcc excluded).

GPUs tested: NVIDIA GeForce RTX 3070 (proprietary), llvmpipe/lavapipe (Mesa, software).

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

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@jotitadev thanks for running it on the RTX 3070 and lavapipe, with the negative control and the ^agc comparison. It's in Tested now, and the 3070 is on the GPUs tested line.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Windows native cross-test of22bf8fcc92 completed on c915980. Baseline62cf2d1a04 is current main7e2ba73e4 plus our #9591/#6918 prerequisites and #9652; the memory change is the only difference between these recorder arms. All authors' commits retained:
https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-oct22-join-memory

Windows11 10.0.26200, RTX5070Ti/NVIDIA617.42, Ryzen7800X3D, WinLibs GCC15.2r7 Release, SPIRV Tools OFF:

  • All74 existing recorder modes pass on the baseline,29.28s.
  • Built your new fixture against unchanged baseline production Recorder.cpp/hpp (verified hashes): it fails after batch1, allocated1/freed0. Same fixture source with the candidate passes (0.251746s). Temporary fixture changes restored before switching to the clean candidate.
  • Candidate gate233 unique cases:231PASS +2expected skips,91.87s; includes all75 recorder modes, zero recorder skips/failures, plus the broader existing graphics/shader/HLE selection.
  • Actual Khronos1.4.363 layer loaded (candidate191instance insertions), ANYPS5_REQUIRE_VULKAN=1 / ANYPS5_NO_SHADER_CACHE=1 / ctest -V. No missing-layer errors. Both baseline and candidate have exactly the same two validation errors: VUID-VkImageViewCreateInfo-usage-02275 from agc_sampled_storage_base_level_usage. No new VUIDs;00118 is absent with fix(agc): give copied guest buffer regions transfer-source usage #7961 now upstream.

Clean final packaging and all369 runtime-module SHA256 values verified before staging. A combined007 loading probe has just started with the same28GiB private/2GiB free guard. No isolated Windows memory saving claimed yet: this title run also carries #9652, and its prior large pipeline was not completely warmed. I will report observed private memory and your freed-buffer counter without attributing an unpaired saving. Raw title data stays local. AI-assisted: Codex.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Correction to the title-run status above: c915's first007 launch aborted after about29s with VOP2 opcode is not implemented (std::invalid_argument), well below the RAM cap. It is not a Windows memory-saving result. Native results stand unchanged.

I am separating the changes: isolated memory headc4162b2156b8 differs from c915 only by retaining the old joinedRun predicate, plus removing #9652's added fixture assertion. Rebuilt successfully, same recorder/import native gate is running before its title control. No attribution to #9565 yet. The other author's coordination thread has the exact heads:
#9652 (comment)
AI-assisted: Codex.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@Scramblrrrr thanks for the Windows run on the RTX 5070 Ti, with the red control against main's recorder and the validation comparison. It's this case's first run on a Windows GPU, and it's in Tested and on the GPUs tested line now. Thanks too for keeping the title runs apart until the memory arms are isolated.

@Scramblrrrr

Copy link
Copy Markdown
Contributor

Isolated #9565 control c4162b2 reached the correctly rendered offline007 menu and did not reproduce c915's VOP2 startup abort during its17-minute run. Menu78/62.137794s=1.25527FPS, GPU196.17083ms/present, effectively unchanged versus b36's1.22951FPS. Freed-command-buffer counter was active. This is one run, not sufficient to attribute the combined build's early failure.

Resume09:13:12.714UTC; the game then logged a RenderThread access violation reading0xffffffffffffffff at the previously discussed terrain/quadtree site. The guard terminated it at09:14:29.572UTC,76.858s after input, while the fatal report was being written. It was NOT the28GiBprivate cap: last private23,834,996,736bytes. Free memory fell from~5.3GB just after a trim to166MB at the final sample; the causal ownership of that late drop is unverified. The guest fault is present before guard termination, so this must not be reported as a pure memory-guard exit or a completed gameplay pass.

No isolated Windows RAM-saving claim from this pair. The five-frame menu trace has no dropped events: p50803.7ms/GPU196.0ms, queue0~748.6ms busy per frame, other queues mostly waiting. Next controlled work is #8887; runtime remains c416, no opcode/guest-title bypass. AI-assisted: Codex.

@MarcZX10

MarcZX10 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Rechecked the exact head 22bf8fcc928ab5d7b2a87f80da9c25cdf0a4a9b3: the three targeted vkAllocateCommandBuffers/vkFreeCommandBuffers tests have strong red/green evidence across llvmpipe, RTX 3070 and RTX 5070 Ti, with the required validation-layer comparisons. Conventions and diff-check pass. check_main_sync.py reports 2 ahead / 116 behind (94fbb8cea merge base), cleanly mergeable; please refresh from current main before merge.

The stated ordering with #9289 is documented and its author agrees. One integration caveat: #9289 is stacked on open #9176 → #9287, neither of which is in this PR's ancestry. Three-way merge checks of #9565 with #9176/#9287/#9289 flag shared AGC files and CMakeLists.txt as changed on both branches (including Recorder.cpp and shader/resource files). That does not invalidate this PR's isolated command-buffer result, but please ensure the whole #9176 → #9287 → #9289 stack is rebased and the combined AGC tests/validation suite pass after #9565 lands; the earlier direct merge-tree result against stacked heads alone does not verify this change is integrated into the stack.

I found no isolated code blocker in the current diff.

@github-actions github-actions Bot added build agc libSceAgc* labels Oct 22, 2026
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

Thanks, @MarcZX10. The branch now has main at 4777cac merged in (1da6fea), with the PR's own diff unchanged. On GitHub's runners (run), agc_recorder_command_buffer_release and the other recorder tests pass 10 of 10 on both, and the set fails with main's implementation on Linux. It's in Tested.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated head 1da6feaf1699ecdaaee9eaa1a124cf22466edafc has strong red/green evidence: the new resolver-probe test fails against main and passes with the implementation, repeated on llvmpipe, RTX 3070 and RTX 5070 Ti; the paired validation-layer comparisons report no new VUIDs. Hosted eligibility, conventions, labels and report pass; product and relinker jobs are skipped. I did not run a local GPU build.

I refreshed upstream/main to 329efe1bfdaff116c57cdf62718026ee4f5521ae. This head is 3 ahead / 45 behind (merge base 4777caca343bf09a3fe245830acd9e9f433e8e18); current-base merge-tree, diff-check and conventions pass. The intervening main changes do not touch this PR’s recorder implementation, test or CMake registration. Please bring the branch up to current main and rerun the focused command-buffer-release recorder case before merge, per the branch rule.

The current #9289 head 2f412bb25fd3c389381ad6cac1cabda75137438c includes the #9176 → #9287 stack, but it does not contain this PR’s latest head; the current pairwise merge-tree still conflicts in Graphics/src/Recorder.cpp. The stated order is #9565 first, then #9289 rebases. Please ensure #9289 is rebased over the merged #9565 head and the combined recorder tests are run before that stacked change merges. This is an integration follow-up, not a new defect in this PR’s isolated fix.

@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

Thanks, @MarcZX10. main at b7d1d47 is now merged in (3c44708), and the PR's own diff is unchanged. On GitHub's runners (run), agc_recorder_command_buffer_release passes 10 of 10 on Linux, along with the other AGC tests in that run, and fails there with main's implementation. On Windows they build and pass, with the tests that need a Vulkan device skipping. It's in Tested. The combined recorder tests with #9289 come after this PR merges, when #9289 rebases over it, in the order agreed in its thread.

@MarcZX10

Copy link
Copy Markdown
Contributor

I’ve noticed that asking you to hold this PR was unnecessary. It’s fine to keep submitting PRs; maintainers will handle them in due course.

EagleBearerYS and others added 3 commits October 24, 2026 01:32
The recorder kept up to 64 completed command buffers for reuse and began
new batches on them. fablevoid found that on Windows drivers a command
buffer keeps the host memory of its largest recording until it is freed:
neither the implicit reset at begin nor a releasing reset gives that
memory back. Every kept command buffer held the peak of its own
recordings, and in a title run the driver's command arenas grew by
3.4 GiB in 17 s until the run hit the RAM cap.

Recorder::release now frees a batch's command buffer, and every batch
allocates its own from the context's pool, so the pool holds no more
than the batches still recording or in flight need. Fences are still
kept for reuse.

agc_recorder_command_buffer_release (new mode
--command-buffer-release-only of the recorder tests) counts the
recorder's vkAllocateCommandBuffers and vkFreeCommandBuffers calls
through a resolver probe over three completed batches: each must free
the command buffer it allocated.

Adapts fable-void's dfbbdfd (his recorder keeps a pool and a spare
list per stream; main has one of each). His GPU test
idle_command_memory reads Windows private bytes through a test fixture
main does not have and is not carried.
With APS5_PROFILE_DRAW set, the [recorder] submits line now counts the
command buffers freed when their batch was released and the fences kept
for reuse (cumulative). The host memory a driver held in those command
buffers is not visible to the recorder; on Windows the process's
private bytes show it.
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@adriadam10
adriadam10 force-pushed the port/fable-fix-command-buffer-release branch from 3c44708 to c47f504 Compare October 23, 2026 23:39
@EagleBearerYS

Copy link
Copy Markdown
Contributor Author

@MarcZX10 3c44708 refreshed main with agc_recorder_command_buffer_release 10 of 10, and the #9289 rebase follows this PR's merge as agreed. Could you re-review?

@oneandonlydean oneandonlydean self-assigned this Oct 24, 2026
@oneandonlydean

oneandonlydean commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

@adriadam10 I've added myself as a co-assignee here (you stay on it). #9287 and #9289 build on this PR and have already passed review on our side, so I'd like to get this one reviewed too and keep both moving. If you'd rather keep it to yourself, just say so and I'll step back.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 27, 2026
…st list, add agc_recorder_command_buffer_release
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 27, 2026
# Conflicts:
#	core/libs/prx/libSceAgcDriver/CMakeLists.txt
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 28, 2026
@TechLevelZero

TechLevelZero commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

✅ NVIDIA GPU test: passed

PR head 3629538 merged onto main 98ddd9c · tested 2026-10-30 11:28 UTC · 26 min

GPU NVIDIA RTX 2000 Ada Generation, driver 595.99.02, Vulkan 1.4.329
Host Ubuntu 26.04.1 LTS, kernel 7.0.0-38-generic, container ubuntu:24.04
Logs build and test logs for this run
Build ✅ passed (Release, -DANYPS5_ENABLE_SPIRV_TOOLS=ON)
Tests ✅ 2,366 passed · 4 failed (0 new, 2 also fail on main, 2 unstable on main) · 41 skipped (ANYPS5_REQUIRE_VULKAN=1)
Test setup CPU-only tests without a GPU; GPU tests (and any CPU-only test that failed or skipped without one) once on the GPU with VK_LAYER_KHRONOS_validation and ANYPS5_NO_SHADER_CACHE=1; main ran the same way
Test selection 2,411 of 2,987 tests run: the ones this change can reach, chosen by tools/select_tests.py from main's build graph
Vulkan validation ✅ no new validation IDs vs main (904 tests run on the GPU)
Slow tests (>30 s, GPU tests timed with validation layers) ⚠️ agc_driver_sdwa_move_selectors 34.6 s, ⚠️ agc_driver_bda_device 32.7 s
Unstable on main (2, these also failed in recent main runs on this machine; not counted against this PR)
agc_submit_progress: failed in 5 of the last 8 main runs
agc_submit_progress_no_timeline: failed in 6 of the last 8 main runs
Failing on main too (2, not counted against this PR)
guest_mmap_executable
guest_socket_options_multicast
Validated but not compared (1, not in the main baseline's validation pass)
agc_recorder_command_buffer_release
Validation IDs already present on main (4 IDs in 425 tests)
VUID-VkDeviceCreateInfo-pNext-pNext (425 tests): agc_compute_pipeline_replay, agc_driver, agc_driver_address_passes_draw_transitions, agc_driver_address_passes_targets_split, agc_driver_array_layer_target_cpu, agc_driver_bda_span_reads, agc_driver_bda_span_reads_draw_pipeline, agc_driver_bitfield_mask, and 417 more
VUID-vkCmdCopyImage-srcImage-01548 (13 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 5 more
VUID-vkCmdCopyImage-srcImage-01551 (13 tests): agc_driver_depth_clear_hle, agc_driver_depth_plane_buffer_memory, agc_driver_depth_plane_cpu_write_after_memo, agc_driver_depth_plane_cpu_write_after_page_unwatch, agc_driver_depth_plane_cpu_write_after_partial_unwatch, agc_driver_depth_plane_partial_store, agc_driver_depth_plane_partial_store_unimported, agc_driver_depth_plane_sampling, and 5 more
VUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605 (2 tests): agc_driver_prepared_exports, agc_driver_srgb8_color_target
Skipped (41)
agc_driver_bda_reads_shadowed_results: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_bda_reads_shadowed_results_per_build: skipped, the device reports watched host memory written when it imports or reads it
agc_driver_msaa_dcc_compared_import_2: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_4: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_msaa_dcc_compared_import_8: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them
agc_driver_sample_order_grid_reference: skipped, the device does not keep depth drawn at custom sample locations at those locations, even after a transition that names them: the composite of uniform renders holds the guest's depth in 0 of 3005 sloped samples, so no path can be compared with it bit for bit
agc_driver_sparse_dma_buf_import: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_driver_stencil_ref_export: skipped, the device lacks VK_EXT_shader_stencil_export
agc_driver_vertex_elected_atomic_max: skipped, the device runs vertex programs in subgroups, so they keep their cross-lane reductions
agc_host_import_sparse: skipped, host imports are unavailable: /dev/udmabuf is not accessible
agc_import_settle_initial_dcc: skipped, the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows
agc_unit_shadow_completion_store: skipped, the device reports watched host memory written when it imports or reads it
guest_http_uri_locale: 
guest_net_ctl: skipped, the host has no IPv4 address
guest_video_out_color_space: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_hdr: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_high_frame_rate: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_output_mode: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_resolution_status: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
guest_video_out_wqhd_detection: skipped, no display or Vulkan device: SDL_InitSubSystem(VIDEO | GAMECONTROLLER) failed: wayland,x11 not available
video_out_flip_controls: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_cpuflip_in_order: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_aftergpu: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_eop_main: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or platform
video_out_flip_fresh: skipped, no display or Vulkan device: DisplayWindow: Vulkan support is either not configured in SDL or not available in current SDL video driver (offscreen) or plat
Reproduce
git fetch origin 3629538bc0a1c88057c0c8211d9a7d719cd10338 98ddd9c1792bbab016ceed5db267a93d1d61f00a
git checkout 98ddd9c1792bbab016ceed5db267a93d1d61f00a && git merge --no-ff 3629538bc0a1c88057c0c8211d9a7d719cd10338
git submodule update --init --recursive
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON
cmake --build build && cmake --build build --target libs
VK_DRIVER_FILES=/nonexistent/icd.json ctest --test-dir build -E '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 32 --output-on-failure
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
  ctest --test-dir build -R '^(agc|shader|recompiler|videoout|video_out|guest_video_out|vulkan)|gpu' --timeout 120 --parallel 4 --output-on-failure
# failures are then re-run alone: --timeout 360 --parallel 2; new validation IDs: the test alone, twice, --parallel 1

Automated build and test on a contributor's NVIDIA machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants