perf(agc): upload a storage image over several host imports on the GPU #11485
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/11485"
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 QRMOE on 2026-10-26T16:54:53Z.
What
A storage image whose guest range no single host import covers was uploaded through the CPU even when every piece of it was imported:
StorageTexture::uploadaskedHostImportForfor one import of the whole surface, and without it read the surface throughGuestMemory::ReadCommitted, which also waits for the GPU writes pending over it. Write-back already handles the same layout: it falls back toimportSegments()and stores through each import (writeBackWindows). With the 8 MiB import window and aligned power-of-two import blocks, an image over registered ranges smaller than the window that crosses a block edge always lands in this case. RESIDENT EVIL requiem (PPSA31246) maps its render targets in 2 MiB pieces, so its 3840x2160 targets (about 32 MiB) took the CPU path on every refresh.uploadnow falls back toimportSegments()for block-unit images, as write-back does, andrefreshtreats such an image as direct.uploadWindowstakes the import segments: with one segment it is unchanged; with several, each segment's pieces are found in its own import and unit shadow (ShadowSources), each window's tiled bytes are copied on the GPU into one device buffer, and the windows are detiled from it as from a slab. Bytes of a window outside the runs (the rest of a tail block) are copied from the import that holds them. The copies are recorded into the open batch and noted as pending reads of the import ranges, like the single-import detile.Tested
Windows 11 Home 26200, Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (AMD 32.0.31021.1015, Vulkan 1.4.349), WinLibs GCC 15.2.0 r7, Release. The head is 1c01a02411 on
main8ff4baf534(rebased;Texture.cppconflicted with #10696, whoseCollectWritesrefresh now runs inside the newif (!segments.empty())block, after the segments are imported). The regression tests and the validation comparison below were run on that head; the title runs further down were run on the earlier head.agc_storage_writeback_blocksgainsuploadBlockTests: a 64 KiB R_X 1024x1024 image, once over 64 adjacent 64 KiB pieces (one import covers it) and once 64 KiB in, over 66 pieces (two aligned import blocks, so two segment imports). Each is created from a byte pattern, must leave aStorageUploadpending read in the recorder (the GPU-direct path; the CPU path leaves none), and is then written back unchanged; every guest byte must still match the pattern.uploadShadowedSegmentTestscovers the gathered-slab branch ofuploadWindows: the surface sits 1 MiB into write-watched memory over three 2 MiB imports, and one whole unit in each import's part of the surface is held fresh by a unit shadow slab, filled with its own byte (0xc1-0xc3) that guest memory doesn't hold. The image is uploaded, written back unchanged and published; the slab-held units must come back with the slab bytes and every other byte must match the pattern.main(Texture.cppandTexture.hppfrom8ff4baf534, with these tests): the two-segment and three-segment cases fail withthe upload took the CPU path. With this PR: all four cases pass, GPU-direct, 4194304 of 4194304 bytes as expected, 196608 of 196608 from the slabs.the round trip changed 195840 bytes, 195840 of them in the slab-held units, so it does exercise that branch.Khronos validation layer (Vulkan SDK 1.4.363.0), same machine and GPU,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ctest --test-dir build -R <pattern> -Vover the 23agc_storage_*,agc_driver_storage_*,agc_driver_graphicsandagc_driver_bda_devicetests on8ff4baf534(22 on88795ed448): neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS(withVK_LOADER_DEBUG=layerthe loader insertsVK_LAYER_KHRONOS_validationfrom the SDK'sVkLayer_khronos_validation.dll);VUID-occurrences are 0 onmainand 0 with this PR;main(8ff4baf534Texture.cppandTexture.hpp, with this PR's tests) passes 22 of 23 (agc_storage_writeback_blocksfails, its multi-segment cases taking the CPU upload), this PR 23 of 23. Before the rebase the same comparison on88795ed448gave 21 of 22 and 22 of 22.uploadWindowsallocates one device buffer holding the tiled bytes of every window it detiles, each window rounded up to 256 bytes, kept by the recorder until the batch retires. For a whole-surface upload the windows cover the surface, so the buffer is the surface'sguestBytesplus at most 255 bytes per window; a partial upload gathers only its runs. For a 3840x2160 64 KiB R_X target (DescribeSurface, height padded to 2176): 33,423,360 bytes (31.9 MiB) at 4 bytes per texel, 66,846,720 (63.8 MiB) at 8 and 133,693,440 (127.5 MiB) at 16; with a full 12-level mip chain at 4 bytes, 46,071,808 (43.9 MiB). Only surfaces that no single import covers take this path.main88795ed448: 22 of 22 each, 0VUID-, and the same negative control fails as expected.On the previous base (
main7a01e6a494),tools/select_tests.pyselected 1524 of 2467 tests for this diff,-j4,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: 7 failures, all also failing onmainon this machine:select_tests,nid_database_cache,agc_host_import_cut_lifetime,agc_driver_depth_plane_partial_store,agc_driver_sample_order_grid_reference,guest_timed_join_import_libkernel_sys,guest_timed_join_import_libkernel_web.Title: RESIDENT EVIL requiem (PPSA31246, 01.200.000), main menu, same machine, four runs in one session alternating the two builds (base, this PR, base, this PR), same script and environment (
APS5_TRACE_SECONDS=660:20 APS5_TRACE_SUMMARY_EVERY=30 APS5_PROFILE_GPU=1 APS5_LOOP_GUARD=100000, noAPS5_PROFILE_DRAW), after one warm-up run of the base build. Both builds are commits with a clean tree, so the summary lines carrydirty: false:e08df2b41307:main88795ed448with #10935, #10304, #9950, #11199 and #11369 merged (the title stops earlier without them), and the merge of #8898 reverted: on currentmainthe title stops at boot withcompute shader ...: reads or writes a converted float image with 16-bit data, which is not implemented(#11580 implements that path; it has not been run with the title yet).c1ed7352b4e9: the base with this branch merged; the diff between the two is this PR's three files.e08df2b41307c1ed7352b4e9e08df2b41307c1ed7352b4e95c93abe8121c, maximum 231 to 235 ms) and one more run ofc1ed7352b4e9with the worker sampler (109 presents, p50 183.6 ms, maximum 239.6 ms). The slow frames are intermittent and not shown to come from this PR; two base runs are too few to rule them out there. This PR does not claim an improvement of the frame-time tail.aps5-summary.jsonl window lines, b1, c1, b2, c2
tools/trace_digest.py, base (b2)
seconds 660:20 from present 3638: 93 presents, frame p50 214.3 / p90 227.3 / p99 266.4 / max 266.4 ms, GPU busy 65.0 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit e08df2b41307, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 493.0, Driver.WorkerWait 363.3, Driver.Packet.memory_wait 228.2, Driver.WorkerWait.dequeue_order 211.5, Driver.Packet.dispatch 204.9, Driver.Dispatch 173.6, Driver.WorkerWait.idle_and_completion_poll 151.8, Resources.Complete 104.1, Vulkan.Dispatch 79.2, Vulkan.Dispatch.shader_resources 77.2
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
tools/trace_digest.py, this PR (c2)
seconds 660:20 from present 4160: 104 presents, frame p50 182.4 / p90 195.5 / p99 489.3 / max 767.1 ms, GPU busy 65.8 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.6.2 (LLPC), Windows 10.0.26200, 3840x2160, commit c1ed7352b4e9, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 451.4, Driver.WorkerWait 315.8, Driver.Packet.memory_wait 222.4, Driver.WorkerWait.dequeue_order 189.5, Driver.Packet.dispatch 155.5, Driver.Dispatch 144.5, Driver.WorkerWait.idle_and_completion_poll 126.3, Graphics.Draw 72.7, Graphics.Draw.draw_and_resource_release 72.0, Resources.Complete 66.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
tools/check_conventions.py --base origin/mainpasses.tools/pr_overlap.py --branch perf/agc-segmented-storage-uploadlists text overlaps, none implementing the same thing:CollectWritesinside the import branch ofupload, which this PR restructures; after the rebase it runs inside the newif (!segments.empty())branch. At 1c01a02411tools/pr_overlap.pyreports no line conflicts; the PRs it could not compare conflict withmainthemselves.HostImportForcall inrefresh'sdirectwith a cached lookup; this PR adds|| (blockUnits && !importSegments().empty())to the same line.tests/Recorder.cpp.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-26T17:07:50Z.
Review: CHANGES_REQUESTED
I reviewed the segmented-upload path and its new round-trip test. The author reports a controlled same-GPU regression test and validation-layer comparison, and the current required policy checks pass. I have not independently run the AGC GPU tests here, and the hosted product jobs are skipped by path policy.
Two repository requirements still block approval:
main(check_main_sync.py --strictreports 1 ahead / 365 behind; merge preview is clean).CONTRIBUTING.mdrequires branches to be based on and kept up to date with currentmain. Please sync the branch, resolve any changed-context effects, and rerun the focused AGC validation tests on the updated base and change.aps5-summary.jsonllines both identify29ce6d87eb5banddirty: true; the reported baseline is also based on7a01e6a494, not currentmain. Please provide a current-main/change pair with distinct commit IDs and put both lines, the trace attachments, and digest output in the PR description. The reported CLI/runtime data is useful, but the current evidence does not yet meet the stated gate.I did not find a separate confirmed code defect in the diff during this pass. The related issue #11481 describes a distinct small-tiled-image shadow/write-before-label case; this PR's segmented upload change does not alter that write-back/label path, so I do not consider it a fix for #11481.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:55:02Z.
Review: DISMISSED
Re-review — changes requested
The new three-segment and shadow-slab tests address the coverage request, and the
CollectWritesrefresh is retained inside the accepted-import block. The current performance report and integration evidence still do not satisfy the repository's review requirements.Findings
[P1] Replace the non-compliant performance capture
This PR is labeled
perf. The report's four captures use the RESIDENT EVIL requiem main menu and setAPS5_PROFILE_GPU=1andAPS5_TRACE_SUMMARY_EVERY=30(along with frame-dump/logging switches). The repository's Performance report form requires a stable gameplay scene, warm caches, no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, and no redirected log. Please provide the required matched main/change captures using that protocol, with the two summary lines, attached traces, andtrace_digest.pyoutput in the PR description. Alternate at least two runs per build asGAME_TESTING.mdrequires. The current captures are useful diagnostic evidence but cannot substantiate this PR's performance claim under the prescribed form.[P2] Validate the current-main integration
The capture/test base is
8ff4baf53489033dae79090640143e82d159ee4d. Currentmainis4c7d275bef89d309313d16bc2bc05d37a1b50be2and has since changedTexture.cppandRecorder.cpp, both touched by this PR. The merge preview is clean, but the current integrated code has not been covered by the reported GPU tests. Please rebase or integrate currentmainand rerun the focused upload tests on both current main and the change with the required Vulkan validation settings.[P2] Close the unexplained long-frame follow-up
The PR description still records 489–767 ms frames only in the candidate captures and says matched repeated controls have not been completed. The later candidate-only runs do not rule out a baseline outlier. Please run the requested matched controls or otherwise identify the cause before retaining the performance claim. I am not treating this as a demonstrated regression; the comparison is currently inconclusive for the tail.
What I checked
1c01a02411d7af40ed02f786ecbd3c0802f118e1; currentmainmerge preview is clean.git diff --checkandtools/check_conventions.pypass against currentmain.Not verified
I did not run a local AGC build or GPU tests; this workspace exposes no Vulkan device.