perf(agc): expand single-key DCC storage uploads on the GPU from the host import #8484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8484"
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 moong15 on 2026-10-20T13:29:36Z.
What
A storage surface whose DCC keys are comp-to-single (
DccKeys::ClearSingle) carries one element per 256-byte block and every other element of the block repeats it.StorageTexture::uploadhandled it on the CPU: it read the whole surface intooriginal, read it again throughReadTextureSurface, expanded every block withExpandSingleBlocksinto a staging buffer, copied the staging buffer to the device and waited on a separateCommandBatchfor each upload.When the surface lies in one host import, the upload now expands it on the GPU straight from the import: a new mode of
TextureRepack.comp(TextureDetiler::DispatchExpandSingle) writes, for every word, the word at the same element position of its block's leading element, for 1, 2, 4, 8 and 16-byte elements. The existing detiler then detiles it into the image as before. The work is recorded into the active recorder when there is one, so there is no host read, staging buffer orSubmitAndWaiton this path. A surface without a single covering import, with a misaligned import offset, or larger than the storage-buffer range or dispatch limit keeps the CPU path.Uncompressed keys (including keys normalized to Uncompressed) and constant-clear keys are unchanged.
APS5_NO_GPU_SINGLE_UPLOADrestores the CPU expansion. The[storage]profile line reportssingle CPU/GPUcounts.Related: #6848 clears a single-key surface whose blocks all hold one proven color, reading the keys on the CPU; this change covers any single-key surface, including blocks of different colors, and does not depend on it.
Tested
Windows 11 Pro 10.0.26300, AMD Radeon RX 9070 XT.
New tests in
agc_driver_recorder_testscompare the GPU-expanded image texel by texel against the CPU expansion over mip levels and element sizes, on unwatched and watched memory and behind an earlier GPU producer:agc_gpu_single_upload,agc_gpu_single_upload_watched, and the same two withAPS5_NO_GPU_SINGLE_UPLOAD=1(_off,_watched_off).ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build -R 'agc_gpu_single_upload|agc_storage|agc_tiled|repack|^agc_driver_graphics$' -V -j1:main30fda0a03: 13/13 passed, 0VUID-, no missing-layer line.VUID-, no missing-layer line.Performance: Stellar Blade (PPSA13197, 01.014.001) gameplay, 3840x2160,
APS5_TRACE_SECONDS=400:90(90 s from 400 s after the first present), caches warm (a warm-up run first),APS5_PREBUILD_THREADS=16on both, noAPS5_PROFILE_*.main30fda0a03and this PR b57c5be9d alternated in one session on the same machine (Ryzen 7 9800X3D, RX 9070 XT, driver 26.8.1), runs in order 1-6.Driver.Packet.memory_waitms per framemainmainmainmainGPU busy time per present is unchanged; the gain is on the CPU side. Per frame,
Driver.Packetfalls from 430 to 309 ms andGraphics.Draw.draw_and_resource_releasefrom 105 to 60 ms, consistent with single-key uploads no longer reading, expanding and staging the surface on the CPU and waiting on a separate submission for each. Every PR run is faster than everymainrun.Summary lines, in run order:
Traces (release assets, 32-44 MB each): 1
mainaps5-trace-30fda0a03a43-26316.json.gz, 2 PR aps5-trace-b57c5be9da28-20872.json.gz, 3mainaps5-trace-30fda0a03a43-25524.json.gz, 4 PR aps5-trace-b57c5be9da28-26796.json.gz, 5mainaps5-trace-30fda0a03a43-12724.json.gz, 6 PR aps5-trace-b57c5be9da28-1480.json.gz.1 main 1: trace_digest aps5-trace-30fda0a03a43-26316.json.gz
seconds 400:90 from present 4053: 435 presents, frame p50 195.1 / p90 252.3 / p99 368.6 / max 467.9 ms, GPU busy 97.4 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
30fda0a03a, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 392.1, Driver.Packet.memory_wait 204.1, batch 97.1, Graphics.Draw 95.2, Graphics.Draw.draw_and_resource_release 83.2, Driver.Packet.draw 79.0, Driver.Draw 78.5, Driver.Packet.dispatch 57.5, Driver.Dispatch 55.3, Driver.Draw.shader_compile_and_link 38.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
2 PR 1: trace_digest aps5-trace-b57c5be9da28-20872.json.gz
seconds 400:90 from present 4455: 567 presents, frame p50 154.3 / p90 181.7 / p99 207.2 / max 362.9 ms, GPU busy 93.8 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit b57c5be9da28, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 295.8, Driver.Packet.memory_wait 156.3, batch 93.8, Driver.Packet.draw 70.7, Driver.Draw 70.3, Graphics.Draw 68.5, Graphics.Draw.draw_and_resource_release 56.8, Driver.Packet.dispatch 39.1, Driver.Draw.shader_compile_and_link 37.2, Driver.Dispatch 36.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
3 main 2: trace_digest aps5-trace-30fda0a03a43-25524.json.gz
seconds 400:90 from present 4011: 392 presents, frame p50 222.2 / p90 258.4 / p99 357.5 / max 527.1 ms, GPU busy 104.2 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
30fda0a03a, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 436.1, Driver.Packet.memory_wait 227.1, Graphics.Draw 122.7, Graphics.Draw.draw_and_resource_release 110.7, batch 104.1, Driver.Packet.draw 82.2, Driver.Draw 81.7, Driver.Packet.dispatch 49.4, Driver.Dispatch 47.1, Driver.Draw.shader_compile_and_link 38.9
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
4 PR 2: trace_digest aps5-trace-b57c5be9da28-26796.json.gz
seconds 400:90 from present 4466: 529 presents, frame p50 167.8 / p90 186.1 / p99 235.7 / max 462.2 ms, GPU busy 98.9 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit b57c5be9da28, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 317.9, Driver.Packet.memory_wait 167.2, batch 98.9, Driver.Packet.draw 73.1, Driver.Draw 72.6, Graphics.Draw 71.0, Graphics.Draw.draw_and_resource_release 59.1, Driver.Packet.dispatch 44.3, Driver.Dispatch 41.9, Driver.Draw.shader_compile_and_link 38.7
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
5 main 3: trace_digest aps5-trace-30fda0a03a43-12724.json.gz
seconds 400:90 from present 4071: 421 presents, frame p50 207.3 / p90 235.4 / p99 341.9 / max 479.3 ms, GPU busy 95.8 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit
30fda0a03a, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 405.3, Driver.Packet.memory_wait 210.9, Graphics.Draw 118.0, Graphics.Draw.draw_and_resource_release 106.1, batch 95.7, Driver.Packet.draw 80.3, Driver.Draw 79.9, Driver.Packet.dispatch 42.3, Driver.Dispatch 40.0, Driver.Draw.shader_compile_and_link 38.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
6 PR 3: trace_digest aps5-trace-b57c5be9da28-1480.json.gz
seconds 400:90 from present 4569: 646 presents, frame p50 137.1 / p90 151.2 / p99 179.8 / max 295.9 ms, GPU busy 96.0 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 3840x2160, commit b57c5be9da28, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 258.9, Driver.Packet.memory_wait 136.8, batch 95.8, Driver.Packet.draw 60.5, Driver.Draw 60.2, Graphics.Draw 57.8, Graphics.Draw.draw_and_resource_release 48.6, Driver.Packet.dispatch 36.4, Driver.Dispatch 33.8, Driver.Draw.shader_compile_and_link 29.8
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
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-20T13:29:51Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T11:01:03Z.
Review: CHANGES_REQUESTED
Re-review against current
main(the head is unchanged). The shader mode, descriptor and dispatch limits, barriers with and without a recorder, and the four new tests still read correctly. What blocks it:main: #6848 merged and rewroteStorageTexture::upload(uniformClearSinglesurfaces are now cleared instead of uploaded).Texture.cppandtests/Recorder.cppconflict, and the GPU path has to be re-placed on the new upload logic, not just rebased. Please rebase and decide how the two paths order (uniform proof first, GPU expansion for the mixed-block remainder looks like the natural split).mainis unmeasured: the 4.62 → 6.45 fps numbers were taken on30fda0a03, before #6848. @tibzejoker reports on GTA V (RTX 4090) thatmain+ #6848 alone gave the same FPS as adding a similar GPU path, i.e. the one-colour-block surfaces are already handled, and what remains is the mixed-block case. Please repeat the Stellar Blade comparison (mainvs this PR, same machine and scene, summary lines andtools/trace_digest.pyoutput) on currentmain, and split thesingle CPU/GPUcounter into uniform and mixed surfaces so it shows what this adds on top of #6848.TextureRepack.comp:22reads the block's leading element from the import for every word, so on a discrete GPU each is a separate PCIe read (@tibzejoker measured host-import reads 270-340x slower than device-local on a 4090). Reading it once per block (one invocation per block, or shared memory) should be tried and measured on NVIDIA as well as AMD.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-28T11:58:06Z.
Review: CHANGES_REQUESTED
Re-checked against current
main; the head is unchanged since the last review, so these points still stand. The shader mode, descriptor and dispatch limits, barriers and the four new tests read correctly.main: #6848 merged and rewroteStorageTexture::upload(uniformClearSinglesurfaces are cleared instead of uploaded).Texture.cppandtests/Recorder.cppconflict, and the GPU expansion has to be placed on the new logic (uniform proof first, GPU expansion for the mixed-block remainder looks like the natural split).mainis unmeasured: the 4.62 → 6.45 fps comparison was taken on30fda0a03, before #6848. @tibzejoker reports on GTA V (RTX 4090) thatmain+ #6848 alone gave the same FPS as adding a similar GPU path. Please repeat the Stellar Blade comparison (mainvs this PR, same machine and scene, summary lines andtools/trace_digest.pyoutput) and split thesingle CPU/GPUcounter into uniform and mixed surfaces, so it shows what this adds on top of #6848.TextureRepack.comp:22reads the block's leading element from the import for every word; on a discrete GPU each one is a separate PCIe read. Try one read per block (one invocation per block, or shared memory) and measure it on NVIDIA as well as AMD.We can do the rebase, but the measurement on Stellar Blade needs your setup. Feel free to push when ready and we'll look again.
Pull request closed