fix(agc): place the presentation source in host memory when device memory runs out #10807
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10807"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-25T02:09:56Z.
What
Forspoken (PPSA03984) on
mainstopped once at 118 s with:That run was on Linux, RTX 4070 Ti (12 GB), NVIDIA 615.71.09, with about 2.3 GB of the card held by other processes on the machine. The title fills the device-local heap (on that card it already reports
device-local heap 0 uses 9164 of its 9164 MiB budgetfor textures), so when the presentation source image was recreated, itsvkAllocateMemoryreturnedVK_ERROR_OUT_OF_DEVICE_MEMORY.PresentationScaler::EnsureSourceImageasked for device-local memory only and threw, and the presentation failure terminated the title. Any card whose device-local heap the title fills can hit this.How
PresentationScaler::EnsureSourceImagepicks the source's memory type withContext::DeviceMemoryType, as textures do: a device-local type while the heap's budget has room, else a host type. It takes the memory from the buffer pool's image path (AllocateImageMemory). On a refused device-local allocation that path reclaims cached pool memory first, then falls back to host memory throughRefusedDeviceMemoryFallback.release()gives the memory back withReleaseImageMemoryinstead ofvkFreeMemory. The scaler keeps the allocation's size and memory type for that.Overlap (
tools/pr_overlap.pyandgit merge-treeof each head with this one):tests/PresentationPass.cpp: #9508 adds itsGpuHeapEnabled()block right afterresidentPresentTests(device->GetContext())inmain, where this PR addssourceImageOutsideDeviceMemoryTests(device->GetContext()). #7642 and #10193 carry that block through #9508. #10507 adds its own test call there, and #10043 adds helpers just beforemain, where this PR adds its allocation-refusing wrappers. Each resolves by keeping both sides, with this PR's call above the heap block.PresentationScaler.cpp: #10194 changes the same two lines (the source's allocate and free) toMemoryAccounting::Allocate/Free. With #10194,BufferPool::AllocateMemory,TakeImageMemory,PutImageMemoryandReleaseImageMemoryrecord the accounting themselves, so the merge keeps this PR'sAllocateImageMemory/ReleaseImageMemoryand drops #10194's two calls; proposed on #10194.Tested
Linux (Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, NVIDIA 615.71.09) unless noted.
agc_driver_presentation_passgains a case that gives the scaler a context whosevkAllocateMemoryrefuses every device-local memory type. It requires the source image to be created, at least one device-local refusal, and the image's memory to come from a host heap. With the test alone onmain(7d24e61d28) it fails 3 of 3 with the title's message,AGC graphics: vkAllocateMemory presentation source: Vulkan result -2. With this change it passes 3 of 3, and the pool logsvkAllocateMemory presentation source: memory type 1 is out of device memory for 16384 bytes ...; placed in host memory type 0. The case skips on a device with no host memory type for the image.presentation|buffer_pool|^agc_driver_graphics$|displaypass 3 of 3. On the Windows 11 VM (GT 1030, driver 582.78, WinLibs GCC 15.2.0 r7) the same 8 pass 3 of 3 on the merge base and on this head. The new case runs there too (memory type 7 refused, placed in host memory type 1).VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R "$R" -V -j4: 8 of 8 onmainbd8e13428aand on this head, no layer-missing line, noVUID-message on either.main2e22b67032plus a local diagnostic that only recordsVK_EXT_device_address_binding_reportevents: 2 of 15 runs stopped as quoted above (at 118 s and 115 s).presentation sourceline), so they show nothing regressed, not the fallback in the title.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
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T02:13:42Z.
Review: COMMENTED
I reviewed the fallback path and test. The host-memory fallback is exercised by injecting a device-local allocation refusal, and the test verifies both the refusal and resulting heap class. I did not find an additional correctness blocker in the changed ownership path: the source allocation records its size/type and returns through
ReleaseImageMemory. The hosted workflow has conventions/intake/report green; platform product jobs are skipped. No separate local Vulkan rerun was available here.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T03:03:27Z.
Review: CHANGES_REQUESTED
Thanks for confirming that #7642 and #10193 add the same
GpuHeapEnabled()/OpenVulkanTestDevice()fixture block. Both PRs are still open, while this PR checklist remainsDepends on: none. CONTRIBUTING.md requires the authors to agree which overlapping PR goes first and declare it withDepends on. Please coordinate with #7642 and #10193 and update the checklist (and have the other affected checklist(s) reflect the agreed order). I have not modified or rebased any branch. The hosted policy checks currently pass; product jobs are skipped.