Repository navigation
Conversation
RecordCopyBacks GPU-copies a writable copy region of at least APS5_COPY_READBACK_MIN_KIB into a staging buffer at completion, and WriteBack diffs that staging instead of the write-combined copy buffer, so a large descriptor write-back no longer reads uncached memory at ~10 MiB/s. APS5_TRACE_COPY_BACKS traces the per-range decision; APS5_TRACE_BIGBUF reports readback=. The staging prefers cached GTT but falls back to the non-cached VRAM aperture when GTT is full, so APS5_HOST_IMPORT_MIB must leave headroom (5000 MiB on a 16 GB / 8 GiB-GTT box; 6000 fills it and stalls again). Verified on Marvel's Wolverine (PPSA03671 v01.001.005): the 248 MiB write-back runs 110x with readback=1 and no stall at 5000 MiB; at 6000 MiB GTT fills and the ~10 MiB/s stall returns. Heap-mirror readback behaviour is unchanged. Debt: docs/dev/debt/changes/wolverine-copy-readback-writeback.md
|
Focused ctest A/B results (same machine/GPU, sequential runs, validation layer 1.4.363): Overlap disclosure: |
|
@nydal91 I read 16a62f7. Staging the copy through a GPU readback is a sound direction for the 248 MiB Wolverine write-back, and the 36 existing ctests passing A/B is good. Before this can pass I need these:
Since this runs for any title with a writable copy of 64 KiB or more, please also add paired PPSA21564 runs inside a perf window with frame time and GPU time with and without the change, against its noise floor, and one more title that hits this path. #12840 and #15296 touch the same lines, so a rebase may be needed. |
Jazeupoi
left a comment
There was a problem hiding this comment.
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 main cac6e5714d with #22373 (it only adds setenv for the AGC tests on Windows); "this PR" is the same tree with head 16a62f705a merged. Your focused set, ctest -R "agc_driver_.*(copy|write_back|writeback|staging|bigbuf|mirror)" -V -j1 (36 tests), 3 runs each, with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1:
| result | layer inserted | not found lines |
VUID- |
|
|---|---|---|---|---|
| base | 36/36, 3/3 runs | 51 per run | 0 | 0 |
| this PR | 36/36, 3/3 runs | 51 per run | 0 | 0 |
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 in agc_driver_indexed_copy and one in agc_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_staging runs 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)
MarcZX10
left a comment
There was a problem hiding this comment.
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
| Check | Result | Note |
|---|---|---|
| Changed-code review | passed | All four changed files inspected |
| Build and tests | not run | No command execution available |
| Negative control | not run | No test harness run |
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.cpp text 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.
|
Ran the focused copy/write-back set from the Tested section with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
No test skips on either side; No new AI-assisted: yes (Claude Code) |
|
On the order with #12840 (BDA stores into writable heap mirrors), which conflicts with this PR in one hunk of The two compose. #12840 runs the loop over Whichever goes second runs #12840's |
|
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.
|
GPU test run: ✅ no new failures or validation errors on Windows / NVIDIABasis: built and ran · this PR's head Checked
Findings: none from this run; this is a correctness run on a GPU, not a code review or a speed measurement. AI-assisted test run (Claude Code) · head |
ligmaSec
left a comment
There was a problem hiding this comment.
A writable-copy readback can cause RecordCopyBacks to skip the barrier needed by a later changed-copy dispatch in the same call. The readback sets recording after a barrier with destination TRANSFER / TRANSFER_READ. The gpuCopy loop emits its barrier covering COMPUTE_SHADER / SHADER_READ only when recording is 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 current main conflicts in GuestBufferMemory.cpp.
AI-assisted: yes.
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(7c83656) 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)