Repository navigation
fix(agc): return a synchronous draw's render target memory to the image pool - #9188
Conversation
|
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.
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.
|
5640d84 to
c9a9831
Compare
|
RTX 4090 (Ada) on Windows, head NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release,
AI-assisted: yes (Claude Code) |
…ge pool RenderTarget, the per-draw image of a synchronous draw, took its memory from the image pool but freed it with vkFreeMemory, so the pool never got it back and every synchronous draw created and freed device memory of the target's size. It now keeps the allocation's size and memory type and returns the memory with ReleaseImageMemory, as OwnedImage does. Co-Authored-By: Claude <noreply@anthropic.com>
c9a9831 to
fc74d93
Compare
|
@thuanquang Draft #10194 adds opt-in allocation accounting for #10041. The overlap audit flags the render-target release path in The combined code should keep your I propose your PR first, then rebasing accounting around that release path. Your PR does not need to wait for #10194. Does that order work for you? If accounting lands first, I can help resolve the overlap here. Test results are in #10194. AI-assisted: yes. |
|
@harry-z-kang, that order works for me: this PR first, then #10194 rebases its accounting around the release path. Keeping the |
|
(Duplicate of the reply above, sent at the same time; nothing to add.) |
|
Windows 11 (10.0.26300), RTX 5070 Ti, NVIDIA driver 617.42, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release, Ninja. Head fc74d93 merged onto main 6cd36e6 (clean); full build, ninja exit 0. Title: ASTRO BOT (PPSA21567, v01.018, own dump), skipping the intro through the menu. Both builds with In this scene the game runs at about 1 fps, and #9188 does not change it:
The run ended cleanly: 361 s, 0 error lines. In a committer sample of main in this scene, none of the 15,372 samples has a Not run: the PR's own tests on this GPU, the validation layer, PPSA14363 (the title this PR was measured on), AMD, Linux, and a main-vs-PR comparison on the same main commit (the baseline is the previous main). |
|
@cadenasynyster I checked these counters against the scope of #9188. The miss totals are cumulative and sampled at different times: the two intervals work out to about 68.5 misses/s on main and 70.0/s with the PR, rather than a several-fold increase. With one run per side and different main commits, that is not enough to attribute a regression or establish no harm. The sampled |
|
@oneandonlydean, a status note now that #9879 is on
So no title we run needs this change on AI-assisted: yes (Claude Code) |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (2, not counted against this PR)Validation IDs already present on main (4 IDs in 425 tests)Skipped (42)ReproduceAutomated 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. |
|
@thuanquang thanks for checking. Since #9879 landed, neither title we run makes synchronous draws, so this no longer changes anything they do. The fix is still correct, though. A synchronous draw keeps its target-sized memory out of the image pool until the draw's batch retires, and returning it is right whichever title triggers it. So we'll judge this PR as a correctness change. That means review plus exact-head CI, with no title A/B; the registered tests cover the path. If you'd rather close it, that's fine too. |
|
@oneandonlydean thanks, please keep it open as a correctness change. The head is still |
# Conflicts: # core/libs/prx/libSceAgcDriver/CMakeLists.txt # core/libs/prx/libSceAgcDriver/Graphics/src/Resources.cpp
|
@oneandonlydean thanks for merging
The merged head itself (on |
✅ NVIDIA GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (3, not counted against this PR)Validation IDs already present on main (5 IDs in 484 tests)Skipped (45)ReproduceAutomated 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. |
What
A synchronous draw (a draw into a color target that has no resident image) renders into a
RenderTarget, a per-draw image of the target's size.RenderTargettakes its memory from the image pool (AllocateImageMemory) but freed it withvkFreeMemory, so the pool never got the memory back. Every synchronous draw therefore created and freed device memory of the whole target's size.It now keeps the allocation's size and memory type and returns the memory with
ReleaseImageMemory, asOwnedImagedoes. The next synchronous draw of the same size takes it from the pool. The image is still destroyed before its memory is released. Today the only productionRenderTargetis the synchronous draw's, and it is destroyed afterSubmitAndWait.Tested
Rechecked merged onto
main14c99b52ac(2026-10-26, AMD Windows driver 32.0.21045.16010):RenderTargetMemoryReusefails withmain'sResources.cpp(the twoFAIL:lines below) in 3 of 3 rounds; with this change it passes 3 of 3.agc_driver_cmask_fast_clear,agc_driver_srgb8_color_targetandagc_driver_packed_unorm4444_color_target.VUID-errors are 3 ofVUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605inagc_driver_srgb8_color_target. Plainmain14c99b52acreports the same 3 there (fix(agc): enable independentBlend for color targets with different blend states #6782 enablesindependentBlend).Rebased onto
main513ca7e558(headfc74d9349f) for the needs-rebase conflict: #7919 added theagc_snapshot_copy_failuretest block next toagc_buffer_pool_tests, whosetarget_sourcesline this PR extends withResources.cpp. Both are kept and the PR's change is unchanged (git range-diff). On this head, built clean: the 12 tests below, 3 rounds, all pass; under the Khronos validation layer 12 of 12 pass with 0VUID-lines, the layer inserted 11 times, no "was not found" line.New test case:
RenderTargetMemoryReuseinagc_buffer_pool(mock device, CPU only). It checks that a released render target's memory stays in the image pool and that the next render target of the same size takes it.agc_buffer_pool_testsnow also compilesResources.cpp.mainf90a3f7297with only the test fails:RX 6700 XT (gfx1031), AMD Windows driver 32.0.21045.5002, Windows 11 26200, MinGW GCC 15.2 Release:
agc_buffer_pool, 10 tests that draw through non-resident color targets andagc_driver_linear_target_resident, whose target is imported and resident:agc_driver_uint8x4_color_target_no_residentagc_driver_color1555_target,agc_driver_color565_targetagc_driver_packed_float_color_target,agc_driver_packed_unorm_color_target,agc_driver_packed_mip_tail_targetagc_driver_pixel32_ar_export,agc_driver_pixel_uint16_exportagc_driver_pixel_ancillary_word,agc_driver_pixel_fixed_point_positionagc_driver_linear_target_residentKhronos validation layer A/B (
VK_LOADER_DEBUG=layershows the layer inserted in all 11 GPU test processes on both sides, with no "was not found" line), same 12 tests:mainwith only the new test: 11 of 12 pass (the new case fails as above), 0VUID-lines.VUID-lines.PPSA14363 (METAL GEAR SOLID Master Collection Vol. 1, own dump), RX 6700 XT:
APS5_PROFILE_DRAW=1, warm shader cache, the same scripted input (title screen, Game Selection, Start Game).sceNpTrophy2GetTrophyInfo: trophy 19 is not in .../trophy00.ucp, was bypassed locally; fix(libSceNpTrophy2): return INVALID_TROPHY_ID for a trophy that is not in the title's data #9115 fixes it.[draws]and[bufferpool]lines, per 10 s window in the PS1 section:mainf90a3f7297preparephase per synchronous draw (allocation and image creation)writeBackphase per synchronous draw (includes the free)The game reached its 3000th guest flip (
flipcounts of the[packets]lines, PS1 logos) after 107.9 s onmainand 69.4 s with this change. On both sides the host stopped presenting about 60 s into the run, while the guest kept flipping. That happened withAPS5_PROFILE_DRAW=1on this unattended desktop, so treat the flip times as rough. The per-draw rows above don't depend on it.Gameplay, 2026-10-22:
main6ef5a1c4c9+ #9115 + #9373 on both sides.libSceAgcDriver.prxwas built with and without #9188 and #9202; nothing else differs. Two 600 s runs per side, alternating, with the same scripted input andAPS5_PROFILE_DRAW=1:No run stopped. The second run with both changes was slower at the Dock (107 to 147 presents per 10 s, against 124 to 196 in the first). These runs held only this PC's GPU lock, so other work on the PC may have slowed it. The title's progress is tracked in its bring-up discussion, #9615.
With #9879: #9879 creates the host import of these three targets. In our runs with its branch (2026-10-23), the PS1 part made no synchronous draws on the RX 6700 XT, so once #9879 is merged this change no longer affects PPSA14363 on that GPU. It still applies to every target #9879 keeps synchronous (listed in #9879). The two PRs don't depend on each other and merge cleanly in either order.
Other GPUs, from reviewers: @MaxLikesCode, NVIDIA GeForce RTX 4090, driver 617.42, Windows 11 Pro 26200, head
c9a9831f7merged ontomain38d3c0858:mainand with this PR, without and with the validation layer, with noVUID-lines.tools/select_tests.pyon the merged tree: 1166 of 1169 pass. The 3 that fail (agc_driver_sample_order,_grid_reference,_recipe_depth_locations) fail the same way onmainon that GPU (AGC: agc_driver_sample_order tests read a depth target as all zeros on an NVIDIA Windows device and pass on Intel #9313).Not tested: AMD GPUs other than the RX 6700 XT, Linux. The PS1 section is still far from 60 fps: each synchronous draw also copies the whole 24 MiB target in and out. That is a separate change.
Overlap: #10194 (@harry-z-kang) adds allocation accounting on the same render-target release path in
Resources.cpp; agreed order: this PR first, then #10194 rebases around itsReleaseImageMemorycall.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code