fix(agc): count depth plane uploads toward the recorder's kept bytes #5344
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5344"
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 fdfawef324 on 2026-10-13T17:35:39Z.
What
DepthPlaneCopy::record(core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp) kept each depth-plane upload buffer withrecorder->Keep(upload), with no size. SoRecorder::BoundKeptBytes, which caps kept bytes at 512 MiB per batch and 1 GiB in flight, never throttled them. When the GPU fell behind, upload buffers piled up in host-visible memory without limit. They are now kept with their byte size, the same way texture uploads are:recorder->Keep(upload, upload->Bytes().size()).Why it matters
In Demon's Souls (PPSA01342), the loading screen after the opening cinematic exhausted heap 1, the 16 GiB host heap on an RTX 3060, and the title aborted on
vkAllocateMemory buffer: allocation=4194304 memoryType=4 ... VK_ERROR_OUT_OF_DEVICE_MEMORY. A local allocation diagnostic showed:DepthPlaneCopy::Refresh)With the change, the title gets past the loading screen into character creation.
Tested
agc_driver_depth_plane_guest_layersgains a phase that samples a depth-plane array with an active Recorder after its guest layer was written. It requires the open batch's kept bytes to grow by at least the layer's 262,144 bytes.added 0 bytes ... less than the 262144 bytes.agc_recorder_kept_bytes,agc_driver_depth_plane_sampling,agc_driver_depth_compare_copyand theagc_driver_depth_storage*tests pass.tools/check_conventions.py --base upstream/mainpasses.A related spot:
GuestBufferMemory::recordGpuCopiesalso keeps its host-visible input snapshot withKeep(inputSnapshot)and no size. It did not matter in this title, so it is left for a separate PR.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 github-actions[bot] on 2026-10-13T17:48:17Z.
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.
main)core/libs/prx/libSceAgcDriver/tests/execution/DepthPlaneGuestLayers.cppL297, L317Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:08:49Z.
Review: COMMENTED
This fix is correct and small: an upload kept without a size is invisible to
BoundKeptBytes, so nothing applied backpressure.The table also points at a follow-up worth flagging. 8 GiB of live 4 MiB depth-plane uploads means
DepthPlaneCopy::Refreshre-uploads the same planes from guest memory on every use (RefreshedPerUse) faster than the GPU consumes them. With this change those uploads now hit the 512 MiB-per-batch cap, so the queue worker waits for the GPU at that point. That converts a memory blow-up into a CPU→GPU sync in the same scene. That is the right trade for correctness, but the loading screen will likely be slower than it needs to be.A depth plane whose guest bytes haven't changed since the last copy (same write generation /
NewestStamp, no pending GPU write over it) doesn't need a new upload. Reusing the previous upload buffer, or skipping the copy into aDepthPlaneCopythat already holds those bytes, would remove most of these uploads instead of throttling them. That can be a separate PR. CountingDepthPlaneCopy::Refreshuploads per 10 s against how many of them had unchanged sources would show how much it would save.Imported from boykopovar/AnyPS5. Originally posted by fdfawef324 on 2026-10-14T01:20:28Z.
Agreed. I will keep unchanged-source reuse as a separate change. Before allowing reuse, it needs the same guest write generation and no overlapping pending GPU write, plus a regression that changes the source between uses. I will measure total Refresh uploads and unchanged-source opportunities over 10-second windows. That fraction has not been measured yet; this PR establishes bounded retained-upload accounting and backpressure, without a loading-speed claim.