feat(libSceAgcDriver): GPU-readback staging for writable-copy write-back #23596
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23596"
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 nydal91 on 2026-11-19T09:50:32Z.
What
RecordCopyBacksGPU-copies a writable copy region of at leastAPS5_COPY_READBACK_MIN_KIB(default 64 KiB) into a staging buffer at completion, andWriteBackdiffs that staging instead of the write-combined copy buffer, so a large descriptor write-back no longer reads uncached memory at ~10 MiB/s. The heap-mirror readback path is unchanged (same eligibility, sameRecordReadback); the loop is restructured to serve both kinds from one merged-writes pass.APS5_TRACE_COPY_BACKStraces, once per range of at least 1 MiB, why a readback was or was not recorded;APS5_TRACE_BIGBUFwrite-back lines gainreadback=. The staging uses the defaultHOST_VISIBLE|HOST_COHERENTmemory type:Context::BufferMemoryTypeprefers cached GTT but falls back to the non-cached VRAM aperture when that heap's budget is exhausted, soAPS5_HOST_IMPORT_MIBmust leave headroom (5000 MiB on a 16 GB / 8 GiB-GTT box; 6000 fills GTT and the stall returns). Debt fragment records the headroom sensitivity and the unmeasured console equivalence.Tested
Linux PikaOS 4 (kernel 7.3.3), Intel Core Ultra 7 265KF, AMD Radeon RX 6950 XT (RADV Mesa 26.3.0), Vulkan 1.4.363, validation layer 1.4.363.
main(7c836568c8) vs this branch, same machine/GPU:ctest --test-dir build -R "agc_driver_.*(copy|write_back|writeback|staging|bigbuf|mirror)" -V --timeout 300withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. Both logs showInsert instance layer "VK_LAYER_KHRONOS_validation"(51 inserts each) and no missing-layer line; 36/36 passed in both arms, zeroVUID-errors in either, no new VUID types or test+VUID pairs (work/vuid_compare.pycomparison; logs kept locally, available on request).APS5_HOST_IMPORT_MIB=5000, 1920x1080 fifo: the 248 MiB descriptor write-back runs 110x withreadback=1and no stall; at 6000 MiB GTT fills and the ~10 MiB/s stall returns (frame ~490), as the debt fragment records.mainwith zeroVUID-validation errors in either arm.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)Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-19T10:18:04Z.
Review: COMMENTED
Tested on NVIDIA, since the description's runs are on RADV.
Setup: Windows 11 Pro (build 26300), AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24), WinLibs GCC 15.2.0 r7, Release. Base
maincac6e5714dwith #22373 (it only addssetenvfor the AGC tests on Windows); "this PR" is the same tree with head16a62f705amerged. Your focused set,ctest -R "agc_driver_.*(copy|write_back|writeback|staging|bigbuf|mirror)" -V -j1(36 tests), 3 runs each, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1:not foundlinesVUID-To check that the new path runs on this driver, one more run of the same set on this PR with
APS5_TRACE_COPY_BACKS=1: two ranges of at least 1 MiB took the staging readback (code=6, writable buffer region, not a heap mirror), a 16 MiB range inagc_driver_indexed_copyand one inagc_driver_stream_copy, and both tests passed. Ranges between 64 KiB and 1 MiB are not traced, so I can't say how many of those took it.On point 1 of the review above: on this machine
agc_driver_recorded_draw_stagingruns and passes on both arms (it is not skipped), and the two existing tests above already send a 16 MiB writable copy through the staging buffer. None of the 36 fails on the base, though, so this does not give the failing-without-the-change test that was asked for.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T10:42:13Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed code and documentation were inspected at head
16a62f705a2d90f2911c9c8eff66c96a7bef0326; I found no verified blocking defect.What I ran
I inspected the prepared diff and the relevant changed-file sections using the pinned repository reader. No build or tests were run.
Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Changed implementation at the reviewed head
Not verified
Build and test results were not independently verified. The description reports test runs and performance observations; console equivalence is stated as unmeasured. The full
GuestBufferMemory.cpptext was excluded from the review bundle; its changed sections were read through the pinned reader. The other changed files were read in the included bundle or at their changed sections.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:35:56Z.
Review: COMMENTED
A writable-copy readback can cause
RecordCopyBacksto skip the barrier needed by a later changed-copy dispatch in the same call. The readback setsrecordingafter a barrier with destinationTRANSFER/TRANSFER_READ. ThegpuCopyloop emits its barrier coveringCOMPUTE_SHADER/SHADER_READonly whenrecordingis false. If the batch has both a staged writable copy and a changed copy, the compute dispatch can read shader results without the dependency that the changed-copy-only path supplies. The heap-readback path already shared this flag. The new writable-copy case makes the same problem possible without a heap mirror. Could the first barrier cover both consumers, or could the compute path track its dependency independently?Source review of
16a62f705a. The local merge into currentmainconflicts inGuestBufferMemory.cpp.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.