perf(agc): read DCC keys from a pending word fill instead of waiting for the GPU #10844
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10844"
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 Raghav314 on 2026-10-25T04:29:41Z.
What
Before a dispatch, the driver reads the DCC keys of each compressed texture it binds, to tell a cleared surface (filled with the clear colour) from one read as stored. When GPU work still pending can change those keys and the driver can't tell what it writes, it submits and waits for the GPU first.
DepthSurfaceViewrecords a word fill over a surface's keys withNotePendingWordFill. The recorder keeps the word, butKeysAfterPendingWritesonly read a write's single byte value, which a word fill doesn't have, so it took the keys as unknown and the dispatch waited. A word whose bytes differ gives mixed keys, which means the texture is read as stored. That is known without the GPU.KeysAfterPendingWritesnow reads the bytes of a pending word fill over the range it covers, so those dispatches no longer wait.Tested
Linux 7.3.0-3-cachyos, NVIDIA GeForce RTX 4090, driver 615.78.08, AMD Ryzen 7 7800X3D, Release build with SPIR-V tools off. Grand Theft Auto V (PPSA04264) 01.011.001, Fidelity mode, 3840x2160, standing still at the same spot in game. Captured as the Performance report form describes: warm caches (0 shader cache misses),
APS5_TRACE_SECONDS=110:30and no otherAPS5_TRACE_*orAPS5_PROFILE_*switch, same machine and session.1. On main. No measurable change:
e7e3e9c198d2da0f20c62. On top of #10837, which removes the depth plane copy churn that dominates main's frame:
ce9c6cbd6aRecorder.WaitSerialgoes from 105 to 95 ms per frame. 136d978b27 is this PR's commit cherry-picked onto #10837, with no other change. This PR does not depend on #10837 and applies to main on its own.3. Why the gain is small on main and what is left. A temporary diagnostic (not in this PR) logged the writer behind each key-only pre-dispatch wait in GTA V with the heap build and both #10837 fixes. Queue 0 spends about 2 ms of each ~3 ms direct dispatch in that wait, about 88 waits per 10 s at ~32 ms each. Of the waits that the remaining pending writes force:
DepthSurfaceView's word fill, which this PR resolves;On main, the depth plane copies remade on each use (
Resources.Complete~290 ms per frame) hide the saved wait time, so the change only shows once #10837 removes them.Summary lines:
Traces, as written by each capture:
Digests of all four are below.
Focused tests on main and on this PR, same machine and GPU, with
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:agc_driver_dcc_key_presync_tests,agc_driver_dcc_keys_first_write_tests,agc_driver_fill_cover_keys_tests,agc_driver_key_miss_tests,agc_driver_sgpr_pattern_fill_keys_tests,agc_driver_depth_plane_guest_layers_tests,agc_driver_depth_copy_draw_tests,agc_driver_depth_storage_reuse_tests. All pass on both, no log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-error.New cases in
DccKeyPresync.cpp:RunMixedWordKeysrecords a fill of the keys with the word0x00ff00ff, then checks three things. The keys are seen as pending but need no synchronization, the dispatch that samples the texture neither pre-syncs nor waits for the GPU, and it reads the stored texel. On main it fails with "the keys of a recorded fill of a word with different bytes need a synchronization".RunWordFillKeyBytesrecords a fill of the keys with the word0x33221100and checks that each of the first eight key bytes, read singly while the fill is still pending, is the matching byte of the word, and that two adjacent bytes read as different keys. It fails when the byte phase is off by one or only the first byte of the overlap is read.trace_digest: main
seconds 110:30 from present 2802: 71 presents, frame p50 417.7 / p90 457.4 / p99 500.8 / max 500.8 ms, GPU busy 254.0 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit
e7e3e9c198, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 1406.6, Driver.Packet.memory_wait 896.7, Driver.WorkerWait 647.5, Driver.WorkerWait.idle_and_completion_poll 647.5, Driver.Packet.dispatch 413.7, Driver.Dispatch 379.2, Resources.Complete 293.2, Vulkan.Dispatch 293.1, Vulkan.Dispatch.shader_resources 291.8, batch 254.5
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest: this PR on main
seconds 110:30 from present 2933: 71 presents, frame p50 427.3 / p90 467.2 / p99 501.7 / max 501.7 ms, GPU busy 249.9 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit
d2da0f20c6, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 1400.4, Driver.Packet.memory_wait 894.6, Driver.WorkerWait 666.1, Driver.WorkerWait.idle_and_completion_poll 666.1, Driver.Packet.dispatch 405.0, Driver.Dispatch 375.9, Vulkan.Dispatch 287.7, Resources.Complete 287.3, Vulkan.Dispatch.shader_resources 286.3, batch 253.6
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest: #10837
seconds 110:30 from present 2782: 105 presents, frame p50 285.9 / p90 305.4 / p99 330.1 / max 347.1 ms, GPU busy 230.4 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit
ce9c6cbd6a, dropped: noSlowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 873.3, Driver.Packet.memory_wait 556.0, Driver.WorkerWait 491.7, Driver.WorkerWait.idle_and_completion_poll 491.7, Driver.Packet.dispatch 251.4, Driver.Dispatch 231.7, batch 230.4, Recorder.WaitSerial 104.5, Driver.Packet.draw 59.4, Driver.Draw 59.1
Longest waits
Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)
trace_digest: #10837 + this PR
seconds 110:30 from present 2517: 109 presents, frame p50 274.9 / p90 294.3 / p99 308.5 / max 328.2 ms, GPU busy 219.3 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit 136d978b272e, dropped: no
Slowest frames (largest slices inside each, inclusive)
Threads (ms per frame)
Largest slices (ms per frame, inclusive, all threads): Driver.Packet 829.9, Driver.Packet.memory_wait 523.1, Driver.WorkerWait 474.8, Driver.WorkerWait.idle_and_completion_poll 474.8, Driver.Packet.dispatch 233.8, batch 221.4, Driver.Dispatch 221.2, Recorder.WaitSerial 94.8, Driver.Packet.draw 60.7, Driver.Draw 60.5
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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:33:55Z.
Review: APPROVED
Reviewed exact head
d2da0f20c6c24704746a2f534ccd2527cce9d779against currentmain.KeysAfterPendingWritesnow derives each byte of a pending aligned word fill using the byte's offset from the recorded write start, while retaining the newest-write-first coverage logic. It only reportsMixedwhen the bytes actually covering the requested key range disagree, and leaves uncovered bytes to the existing memory comparison. The new regression uses0x00ff00ff, checks the pending writer is known without pre-sync, dispatches without a GPU wait, and verifies the sampled stored texel. The existing uniform-word, writer-wait, and no-writer cases remain in the focused test.git diff --checkandtools/check_conventions.py --base upstream/main --head upstream/pr-10844pass. Hosted eligibility, intake, labels, report, and current conventions checks pass; the product build/test matrix is skipped by repository policy. The author reports the focused test on main and this head under Vulkan validation, plus the GTA V measurements. I could not run the Vulkan test locally: this container has no/dev/dri, and the available shared build was configured without the AGC execution test and would require a broad dependency rebuild.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:35:38Z.
Review: APPROVED
Re-reviewed the updated exact head
ca958bcb6320a1ad124be5a072ebd6a1546a5d28. The addedRunWordFillKeyBytescase checks all eight bytes across two recorded words, with the expected little-endian byte selected by(offset % 4), and confirms a two-byte range containing different values does not produce a uniform metadata byte. This directly covers the range/phase edge cases in addition to the mixed-key dispatch regression from the prior head.git diff --checkandtools/check_conventions.py --base upstream/main --head upstream/pr-10844pass. Hosted eligibility, labels, report, and current conventions pass; product jobs are skipped by repository policy. The added Vulkan case was not runnable locally: there is no/dev/dri, and the available shared build lacks this AGC execution-test configuration. The author-reported Vulkan validation results therefore remain external evidence.