perf(agc): reuse user-data callee links and check a cached raw shader's range once #9899

Merged
savvaniss merged 4 commits from upstream-pr/9899 into main 2026-11-02 07:59:11 +00:00
savvaniss commented 2026-10-22 20:50:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-22T20:50:00Z.


What

Get-fix/AnyPS5#13 and #15, moved upstream as one pull request. Both cut the shader preparation a draw or dispatch repeats when its draw cache entry misses. Neither is PS4-only, so it goes straight on main. Each is its own commit.

1. A program's user-data callee link is reused while its callees are unchanged (Get-fix/AnyPS5#13)

InvocationFor links the user-data callees of a compute shader, and of a GCN vertex shader (its fetch subroutine), before it looks up the prepared artifact. Until now it did that from scratch on every draw and dispatch:

  • decode the whole program (RdnaInstructionDecoder::Decode, which for a GCN program re-encodes and decodes each instruction);
  • search it for s_swappc calls through user data and table calls (FindUserDataCalls, FindTableCalls);
  • read each callee from guest memory and measure it (ReadUserDataCallee, UserDataCalleeLength);
  • link (LinkCalls).

The registered code never changes, and the callees rarely do. On Monopoly Plus's language screen, after #12, the queue worker is the bottleneck: draws there change their user data on almost every draw, so the draw cache rarely holds them and each draw prepares its stages again. A sampling profile of the worker put 28.8% of its time in InvocationFor, 17.4% of all its time in decoding the vertex programs again, and about 5% in reading and measuring their fetch subroutines.

This commit keeps the result with the program's prepared state (PreparedShaderState::userDataLinks):

  • The decoded program and its call sites, keyed by the code offset and the user-data layout and wave size they were found with. They depend only on the registered code.
  • Up to eight links per program: the callee addresses, the callee words and the linked code.
  • A link is reused when the user data points at the same addresses and the guest memory there is readable and still holds the same words (the same Accessible check and Read as the first read). Anything else reads and links the callees as before, so a callee rewritten in place, a callee moved or an unreadable callee behave as today, with the same errors.
  • A program that loads call targets from a table keeps its call sites but reads its tables and links every time.
  • The lookup copies the candidate links under the program's mutex and compares guest memory outside it.

Nothing depends on the title: any registered compute shader or GCN vertex shader with user-data callees takes this path.

On main, LinkUserDataCallees links compute programs only, so here the memo serves compute dispatches. With #9431 it also links GCN vertex programs, and the memo covers those the same way.

2. A raw shader's address range is checked only when its snapshot is read again (Get-fix/AnyPS5#15)

ReadRawShader (a PS4 program with no header, read from guest memory by its address) began with GuestMemory::CheckRange on its first four bytes, then looked the address up in its snapshot cache. A cached snapshot is then compared with guest memory by GuestMemory::CompareMapped, which walks the same page states and returns Unmapped for a page that is no longer readable. So on a cache hit the range check was a second page walk whose answer the compare gives anyway.

DecodeProgramsCurrent calls ReadRawShader for each raw program of every draw that reuses a kept decode. On Monopoly Plus's language screen, after #14, a sampling profile of the queue worker put 8.2% of its time in ReadRawShader; CheckRange was about half of that.

This commit runs the range check only when the snapshot is read again from guest memory: on a cache miss, or when the compare found the bytes changed or unmapped. Nothing else changes:

  • An address that was never cached (null, misaligned, unreadable) fails the check first, as before; the cache only holds addresses that passed it.
  • A cached snapshot is returned only when its bytes compare equal, which needs every page readable.
  • A cached program whose pages became unreadable compares Unmapped, reaches the check and throws as before.

Get-fix/AnyPS5#14 (bypassing an unhit result memo) is not here: #6733 replaced that memo with a set-associative table on main, and its eviction cost, which #14 avoided, would have to be measured again.

Tested

Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, on main 3bbd2321de, AMD Radeon RX 9070 XT (driver 32.0.31041.1004), ANYPS5_GPU=AMD.

  • agc_driver_user_data_link_reuse (new, Vulkan) runs a compute program that calls two user-data callees three times in a loop. It is invoked through InvocationFor and dispatched each time, and every lane must hold the sum of the callees' constants.

    • The first invocation keeps one link with both callees. A second one with the same callees reuses it.
    • Rewriting the first callee in place gets a new link. Restoring its words reuses the old link.
    • Pointing both calls at the second callee gets a new link.
    • Ten more rewrites leave the program's eight most recent links.

    With ShaderRegistry.cpp as on main it fails with "the first invocation did not keep exactly one user-data link with both callees".

  • The raw shader commit moves one existing check, so it has no test of its own. agc_driver_scalar_swappc, agc_driver_scalar_swappc_fetch, both agc_driver_compute_user_data_calls modes and the user-data tail tests pass.

  • Merge of main b7488e1ff5 (30 Oct, merge commit 009fc42f03): the only conflict was LinkUserDataCallees. #9431 made it link GCN vertex shaders too, and the merge keeps that rule with this branch's memo. On the merge, 11 of 11 pass on the RX 9070 XT under the validation layer, with no VUID- line: agc_driver, agc_shader_memory, both agc_driver_compute_user_data_calls modes, agc_driver_scalar_swappc, agc_driver_scalar_swappc_fetch, agc_driver_queued_raw_shader, agc_driver_user_data_link_reuse, agc_driver_user_data_call_after_branch, and the fragment and vertex user-data tail tests. The focused 100-test set and the per-case failures below are from before this merge and were not rerun. Linux was not compiled here; PreparedShaderState has no size guard.

  • Merge of main cc26ab4438 (1 Nov, merge commit 89f30e45f0): the only conflict was libSceAgcDriver/CMakeLists.txt: main moved the AGC test registrations into tests/cmake, and tools/agc_test_split.py resolve moved this branch's include line to the agc_driver_user_data_link_reuse_tests fragment. agc_driver, agc_shader_memory, both agc_driver_compute_user_data_calls modes, agc_driver_scalar_swappc, agc_driver_scalar_swappc_fetch, agc_driver_queued_raw_shader, agc_driver_user_data_link_reuse and agc_driver_user_data_call_after_branch pass, 3 of 3 on the RX 9070 XT under the validation layer, no VUID- line. Not rerun: the other tests, Linux, games.

  • Validation layer: 100 focused tests on main and the same 100 plus the new one on this branch, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The set is the same as for the store pull request. All pass: 100 of 100 and 101 of 101. Both logs have the same four VUID-VkImageViewCreateInfo-usage-02275 lines from agc_sampled_storage_base_level_usage, which main already logs; the change adds none. Neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS, and every device line names the RX 9070 XT.

What the performance numbers below can and cannot show.

  • There is no main/change pair from this title. CUSA03312 does not start on main (it needs #9430 to #9432), so both pairs below come from the unpublished local stack on ps4/limbo-gpu described next, and cannot be rebuilt from published commits. The traces named in their summary lines are not attached.
  • On main the memo serves only compute programs with user-data callees, because LinkUserDataCallees links only those; GCN vertex programs reach it with #9431. EdouardSence's alternated A/B on ASTRO BOT (PPSA21567, Sky Garden, RX 9070 XT, RADV), on main plus #9852 with and without this head, is level: frame p50 207.1 ms against 209.4 ms, inside that scene's ±1.5 % run-to-run spread (comment). Neither main nor this change counts reused links, so that run cannot show how often the memo was hit there.
  • So this pull request makes no speed claim against main. It stands as an optimisation with identical output: agc_driver_user_data_link_reuse checks the dispatch results with a reused link, after a rewrite and after the cap of eight links. The CUSA03312 numbers show what it does on the title stack it was written for.
  • Dropped events: each trace's queue worker filled its event buffer 3.1 to 3.7 s into the 15 s window and lost 0.80 to 1.0 million slices, but totals_full is false in every line. The summary fields (frame_ms, gpu_busy_ms_per_present, worker_busy_pct, top_phases_ms_per_frame) are built from the complete totals and hold. Only the per-slice parts of tools/trace_digest.py (slowest frames, the threads table, longest waits) miss the queue worker's slices after the buffer filled.

Monopoly Plus (CUSA03312). The title doesn't run on main: it needs #9430 to #9432. As agreed on #6977, these numbers come from ps4/limbo-gpu at 93eeee0141 (#6977's head then), with and without the change, on the local stack the title needs to start: the Get-fix pull requests named with each pair, and local stand-ins for sceGnmDrawInitDefaultHardwareState200 and sceGnmUpdate*Shader. The base and change commits named with each pair are commits of that local stack, which isn't published. Base and change alternated on the same machine and scene.

  1. Callee link, on the language screen. Pair: base 3fe75b613c, change 60aac9783f, both with Get-fix/AnyPS5#1, #2, #5, #8 and #10 to #12:
build fps frame p50 frame p90 GPU busy ms/present worker Driver.Packet ms/frame shader_compile_and_link ms/frame prepared_invocation ms/frame materialize ms/frame capture_resources ms/frame
base 18.49, 18.23, 17.95 54.1 to 54.9 ms 55.3 to 59.1 ms 13.0 to 14.5 52.6 to 54.2 33.7 to 34.6 15.9 to 16.3 9.3 to 9.7 6.8 to 7.0
change 24.87, 24.14, 24.39 40.1 to 40.9 ms 41.1 to 44.4 ms 13.6 to 14.5 38.7 to 39.9 19.8 to 20.4 not in the top eight 9.3 to 9.8 6.5 to 6.7

Summary lines; the two traces they name will be attached by hand:
Base (3fe75b613c):

{"commit":"3fe75b613c46","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":2876,"ms":15038.359},"presents":278,"frame_ms":{"p50":54.109,"p90":55.275,"p99":56.926,"max":58.172},"gpu_busy_ms_per_present":14.539,"worker_busy_pct":{"queue worker 0x0":97.434},"top_phases_ms_per_frame":{"Driver.Packet":52.609,"Driver.Packet.draw":41.991,"Driver.Draw":41.672,"Driver.Draw.shader_compile_and_link":33.732,"Shader.DrawStage":32.164,"Shader.DrawStage.prepared_invocation":15.939,"Shader.DrawStage.materialize":9.366,"Shader.DrawStage.capture_resources":6.791},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.109,"events_lost":1002952,"totals_full":false}},"trace":"aps5-trace-3fe75b613c46-35740.json.gz"}

Change (60aac9783f):

{"commit":"60aac9783f36","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3535,"ms":15037.086},"presents":374,"frame_ms":{"p50":40.132,"p90":41.068,"p99":42.454,"max":46.176},"gpu_busy_ms_per_present":13.558,"worker_busy_pct":{"queue worker 0x0":96.566},"top_phases_ms_per_frame":{"Driver.Packet":38.718,"Driver.Packet.draw":28.054,"Driver.Draw":27.762,"Driver.Draw.shader_compile_and_link":19.752,"Shader.DrawStage":18.1,"Shader.DrawStage.materialize":9.315,"Shader.DrawStage.capture_resources":6.547,"Driver.Packet.device_lock":6.078},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.357,"events_lost":909859,"totals_full":false}},"trace":"aps5-trace-60aac9783f36-9108.json.gz"}
tools/trace_digest.py of the two traces

Base, aps5-trace-3fe75b613c46-35740:

seconds 120:15 from present 2876: 278 presents, frame p50 54.1 / p90 55.3 / p99 56.9 / max 58.2 ms, GPU busy 14.5 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 3fe75b613c46, dropped: yes

{"commit":"3fe75b613c46","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":2876,"ms":15038.359},"presents":278,"frame_ms":{"p50":54.109,"p90":55.275,"p99":56.926,"max":58.172},"gpu_busy_ms_per_present":14.539,"worker_busy_pct":{"queue worker 0x0":97.434},"top_phases_ms_per_frame":{"Driver.Packet":52.609,"Driver.Packet.draw":41.991,"Driver.Draw":41.672,"Driver.Draw.shader_compile_and_link":33.732,"Shader.DrawStage":32.164,"Shader.DrawStage.prepared_invocation":15.939,"Shader.DrawStage.materialize":9.366,"Shader.DrawStage.capture_resources":6.791},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.109,"events_lost":1002952,"totals_full":false}},"trace":"aps5-trace-3fe75b613c46-35740.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 3029: 58.2 ms at 8210 ms: batch (gpu) 14.7, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1
  • present 3060: 57.0 ms at 9906 ms: batch (gpu) 14.6, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2
  • present 3091: 56.9 ms at 11597 ms: batch (gpu) 14.9, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 10.0 (18 %) 0.1 (0 %) 44.1 10.6 Driver.Packet 10.0, Driver.EndSubmission 0.0
presenter 0.3 (1 %) 0.1 (0 %) 53.7 0.0 Driver.Present 0.4
gpu 14.5 (27 %) 0.0 (0 %) 39.6 0.0 batch 14.5

Largest slices (ms per frame, inclusive, all threads): batch 14.5, Driver.Packet 10.0, Driver.Packet.draw 8.7, Driver.Draw 8.6, Driver.Draw.shader_compile_and_link 6.8, Shader.DrawStage 4.3, Shader.DrawStage.prepared_invocation 1.7, Driver.Packet.device_lock 1.0

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 2665 ms, present 2926
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 54 ms, present 2877
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 1861 ms, present 2911
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 797 ms, present 2890
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 214 ms, present 2880
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 2986 ms, present 2932
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 1225 ms, present 2899
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 587 ms, present 2887

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 51438: 2.9 ms at 7046 ms, present 3007: GPU no ranges; recorded by no CPU slices
  • batch 49400: 2.9 ms at 2749 ms, present 2927: GPU no ranges; recorded by no CPU slices
  • batch 54459: 2.9 ms at 13380 ms, present 3123: GPU no ranges; recorded by no CPU slices

Change, aps5-trace-60aac9783f36-9108:

seconds 120:15 from present 3535: 374 presents, frame p50 40.1 / p90 41.1 / p99 42.5 / max 46.2 ms, GPU busy 13.6 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 60aac9783f36, dropped: yes

{"commit":"60aac9783f36","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3535,"ms":15037.086},"presents":374,"frame_ms":{"p50":40.132,"p90":41.068,"p99":42.454,"max":46.176},"gpu_busy_ms_per_present":13.558,"worker_busy_pct":{"queue worker 0x0":96.566},"top_phases_ms_per_frame":{"Driver.Packet":38.718,"Driver.Packet.draw":28.054,"Driver.Draw":27.762,"Driver.Draw.shader_compile_and_link":19.752,"Shader.DrawStage":18.1,"Shader.DrawStage.materialize":9.315,"Shader.DrawStage.capture_resources":6.547,"Driver.Packet.device_lock":6.078},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.357,"events_lost":909859,"totals_full":false}},"trace":"aps5-trace-60aac9783f36-9108.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 3617: 46.2 ms at 3286 ms: Driver.Packet (queue worker 0x0) 38.1, Driver.Packet.draw (queue worker 0x0) 29.6, Driver.Draw (queue worker 0x0) 29.1, Driver.Draw.shader_compile_and_link (queue worker 0x0) 18.5
  • present 3744: 43.3 ms at 8419 ms: batch (gpu) 13.6, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1
  • present 3634: 42.6 ms at 3983 ms: batch (gpu) 13.7, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 7.3 (18 %) 0.1 (0 %) 32.8 12.4 Driver.Packet 7.4, Driver.EndSubmission 0.0
presenter 0.3 (1 %) 0.1 (0 %) 39.8 0.0 Driver.Present 0.4
gpu 13.6 (34 %) 0.0 (0 %) 26.6 0.0 batch 13.6

Largest slices (ms per frame, inclusive, all threads): batch 13.6, Driver.Packet 7.4, Driver.Packet.draw 5.9, Driver.Draw 5.8, Driver.Draw.shader_compile_and_link 3.6, Driver.Packet.device_lock 1.2, Shader.DrawStage 1.0, Driver.Present 0.4

Longest waits

  • Driver.WorkerWait (queue worker 0x0) 0.7 ms at 2647 ms, present 3600
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 1203 ms, present 3565
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 2368 ms, present 3594
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 3286 ms, present 3617
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 1284 ms, present 3567
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 120 ms, present 3538
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 3332 ms, present 3618
  • Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 2167 ms, present 3589

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 60861: 2.8 ms at 2709 ms, present 3602: GPU no ranges; recorded by no CPU slices
  • batch 61208: 2.7 ms at 3311 ms, present 3617: GPU no ranges; recorded by no CPU slices
  • batch 67306: 2.7 ms at 13815 ms, present 3878: GPU no ranges; recorded by no CPU slices

In each trace the queue worker's event buffer filled 3.1 to 3.4 s into the 15 s window (trace_dropped_threads). Its later slices are missing from the trace, so the thread, slice and wait lists cover only that part of the queue worker's time.

  1. Raw shader range check. Pair: base 819cd3db26, change cb626a70e8, both with Get-fix/AnyPS5#1, #2, #5, #8 and #10 to #14: the queue worker's profile share of the check fell from 8.2% to 5.1%, and fps stayed within noise (26.3 vs 26.7).

Summary lines; the two traces they name will be attached by hand:
Base (819cd3db26):

{"commit":"819cd3db2630","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3744,"ms":15011.733},"presents":395,"frame_ms":{"p50":37.904,"p90":39.212,"p99":41.53,"max":57.233},"gpu_busy_ms_per_present":13.184,"worker_busy_pct":{"queue worker 0x0":96.232},"top_phases_ms_per_frame":{"Driver.Packet":36.474,"Driver.Packet.draw":25.08,"Driver.Draw":24.757,"Driver.Draw.shader_compile_and_link":16.413,"Shader.DrawStage":14.794,"Shader.DrawStage.capture_resources":7.109,"Driver.Packet.device_lock":6.646,"Shader.DrawStage.materialize":5.454},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.577,"events_lost":839072,"totals_full":false}},"trace":"aps5-trace-819cd3db2630-35708.json.gz"}

Change (cb626a70e8):

{"commit":"cb626a70e8ae","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3828,"ms":15012.513},"presents":419,"frame_ms":{"p50":35.608,"p90":37.677,"p99":39.354,"max":50.076},"gpu_busy_ms_per_present":13.86,"worker_busy_pct":{"queue worker 0x0":96.109},"top_phases_ms_per_frame":{"Driver.Packet":34.329,"Driver.Packet.draw":23.134,"Driver.Draw":22.824,"Driver.Draw.shader_compile_and_link":15.864,"Shader.DrawStage":14.352,"Shader.DrawStage.capture_resources":6.875,"Driver.Packet.device_lock":6.55,"Shader.DrawStage.materialize":5.268},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.702,"events_lost":795786,"totals_full":false}},"trace":"aps5-trace-cb626a70e8ae-27232.json.gz"}
tools/trace_digest.py of the two traces

Base, aps5-trace-819cd3db2630-35708:

seconds 120:15 from present 3744: 395 presents, frame p50 37.9 / p90 39.2 / p99 41.5 / max 57.2 ms, GPU busy 13.2 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 819cd3db2630, dropped: yes

{"commit":"819cd3db2630","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3744,"ms":15011.733},"presents":395,"frame_ms":{"p50":37.904,"p90":39.212,"p99":41.53,"max":57.233},"gpu_busy_ms_per_present":13.184,"worker_busy_pct":{"queue worker 0x0":96.232},"top_phases_ms_per_frame":{"Driver.Packet":36.474,"Driver.Packet.draw":25.08,"Driver.Draw":24.757,"Driver.Draw.shader_compile_and_link":16.413,"Shader.DrawStage":14.794,"Shader.DrawStage.capture_resources":7.109,"Driver.Packet.device_lock":6.646,"Shader.DrawStage.materialize":5.454},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.577,"events_lost":839072,"totals_full":false}},"trace":"aps5-trace-819cd3db2630-35708.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 3931: 57.2 ms at 7074 ms: batch (gpu) 14.8, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1
  • present 3932: 43.2 ms at 7131 ms: batch (gpu) 13.8, Driver.Present (presenter) 0.7, Driver.Present.acquire_image (presenter) 0.5, Vulkan.Acquire (presenter) 0.5
  • present 3865: 42.0 ms at 4564 ms: batch (gpu) 12.2, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 7.0 (18 %) 0.1 (0 %) 30.9 13.3 Driver.Packet 7.1, Driver.EndSubmission 0.0
presenter 0.3 (1 %) 0.1 (0 %) 37.6 0.0 Driver.Present 0.4
gpu 13.2 (35 %) 0.0 (0 %) 24.8 0.0 batch 13.2

Largest slices (ms per frame, inclusive, all threads): batch 13.2, Driver.Packet 7.1, Driver.Packet.draw 5.3, Driver.Draw 5.2, Driver.Draw.shader_compile_and_link 2.6, Driver.Packet.device_lock 1.4, Shader.DrawStage 0.6, Driver.Present 0.4

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x0) 1.2 ms at 2595 ms, present 3813
  • Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 114 ms, present 3747
  • Vulkan.Acquire.acquire_fence_wait (presenter) 0.7 ms at 8700 ms, present 3973
  • Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 2672 ms, present 3814
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 671 ms, present 3762
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 2900 ms, present 3821
  • Vulkan.Acquire.acquire_fence_wait (presenter) 0.6 ms at 6269 ms, present 3910
  • Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 2790 ms, present 3818

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 63256: 3.2 ms at 1323 ms, present 3779: GPU no ranges; recorded by no CPU slices
  • batch 63348: 3.2 ms at 1477 ms, present 3783: GPU no ranges; recorded by no CPU slices
  • batch 66601: 3.2 ms at 6789 ms, present 3923: GPU no ranges; recorded by no CPU slices

Change, aps5-trace-cb626a70e8ae-27232:

seconds 120:15 from present 3828: 419 presents, frame p50 35.6 / p90 37.7 / p99 39.4 / max 50.1 ms, GPU busy 13.9 ms per present
AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit cb626a70e8ae, dropped: yes

{"commit":"cb626a70e8ae","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3828,"ms":15012.513},"presents":419,"frame_ms":{"p50":35.608,"p90":37.677,"p99":39.354,"max":50.076},"gpu_busy_ms_per_present":13.86,"worker_busy_pct":{"queue worker 0x0":96.109},"top_phases_ms_per_frame":{"Driver.Packet":34.329,"Driver.Packet.draw":23.134,"Driver.Draw":22.824,"Driver.Draw.shader_compile_and_link":15.864,"Shader.DrawStage":14.352,"Shader.DrawStage.capture_resources":6.875,"Driver.Packet.device_lock":6.55,"Shader.DrawStage.materialize":5.268},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.702,"events_lost":795786,"totals_full":false}},"trace":"aps5-trace-cb626a70e8ae-27232.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 4100: 50.1 ms at 9720 ms: batch (gpu) 15.2, Driver.Present (presenter) 2.1, Driver.Present.acquire_image (presenter) 1.8, Vulkan.Acquire (presenter) 1.8
  • present 4131: 39.7 ms at 10858 ms: batch (gpu) 14.9, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2
  • present 4075: 39.7 ms at 8806 ms: batch (gpu) 15.0, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 6.5 (18 %) 0.1 (0 %) 29.2 13.9 Driver.Packet 6.6, Driver.EndSubmission 0.0
presenter 0.3 (1 %) 0.1 (0 %) 35.4 0.0 Driver.Present 0.4
gpu 13.9 (39 %) 0.0 (0 %) 22.0 0.0 batch 13.9

Largest slices (ms per frame, inclusive, all threads): batch 13.9, Driver.Packet 6.6, Driver.Packet.draw 4.8, Driver.Draw 4.8, Driver.Draw.shader_compile_and_link 2.5, Driver.Packet.device_lock 1.4, Shader.DrawStage 0.6, Driver.Present 0.4

Longest waits

  • Vulkan.Acquire.acquire_fence_wait (presenter) 1.7 ms at 9720 ms, present 4100
  • Driver.Packet.memory_wait (queue worker 0x0) 0.9 ms at 2168 ms, present 3889
  • Driver.Packet.memory_wait (queue worker 0x0) 0.8 ms at 348 ms, present 3838
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 1383 ms, present 3867
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 3019 ms, present 3913
  • Vulkan.Acquire.acquire_fence_wait (presenter) 0.5 ms at 12787 ms, present 4185
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 957 ms, present 3855
  • Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 279 ms, present 3836

Largest GPU batches (GPU ranges inside, and the CPU slices that recorded each, inclusive)

  • batch 66804: 3.2 ms at 3563 ms, present 3928: GPU no ranges; recorded by no CPU slices
  • batch 73993: 3.2 ms at 14842 ms, present 4242: GPU no ranges; recorded by no CPU slices
  • batch 73158: 3.1 ms at 13523 ms, present 4205: GPU no ranges; recorded by no CPU slices

In each trace the queue worker's event buffer filled 3.6 to 3.7 s into the 15 s window (trace_dropped_threads). Its later slices are missing from the trace, so the thread, slice and wait lists cover only that part of the queue worker's time.

  • tools/check_conventions.py --base origin/main passes.
  • tools/pr_overlap.py lists #8658 (macOS host), which changes neighbouring lines of ShaderRegistry.cpp, and #9842. #9431 and the pull requests stacked on it, #9842 among them, change the first lines of LinkUserDataCallees to link GCN vertex programs as well. With both in, that line returns nullptr for a program that is neither compute nor a GCN vertex program, and the memo covers both. None implements the same thing.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: CUSA03312 #7198
  • GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.31041.1004, Windows 11 Pro 26300
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4973933252 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9899). Originally posted by [savvaniss](https://github.com/savvaniss) on 2026-10-22T20:50:00Z. --- ### What Get-fix/AnyPS5#13 and #15, moved upstream as one pull request. Both cut the shader preparation a draw or dispatch repeats when its draw cache entry misses. Neither is PS4-only, so it goes straight on `main`. Each is its own commit. **1. A program's user-data callee link is reused while its callees are unchanged** (Get-fix/AnyPS5#13) `InvocationFor` links the user-data callees of a compute shader, and of a GCN vertex shader (its fetch subroutine), before it looks up the prepared artifact. Until now it did that from scratch on every draw and dispatch: - decode the whole program (`RdnaInstructionDecoder::Decode`, which for a GCN program re-encodes and decodes each instruction); - search it for `s_swappc` calls through user data and table calls (`FindUserDataCalls`, `FindTableCalls`); - read each callee from guest memory and measure it (`ReadUserDataCallee`, `UserDataCalleeLength`); - link (`LinkCalls`). The registered code never changes, and the callees rarely do. On Monopoly Plus's language screen, after #12, the queue worker is the bottleneck: draws there change their user data on almost every draw, so the draw cache rarely holds them and each draw prepares its stages again. A sampling profile of the worker put 28.8% of its time in `InvocationFor`, 17.4% of all its time in decoding the vertex programs again, and about 5% in reading and measuring their fetch subroutines. This commit keeps the result with the program's prepared state (`PreparedShaderState::userDataLinks`): - The decoded program and its call sites, keyed by the code offset and the user-data layout and wave size they were found with. They depend only on the registered code. - Up to eight links per program: the callee addresses, the callee words and the linked code. - A link is reused when the user data points at the same addresses and the guest memory there is readable and still holds the same words (the same `Accessible` check and `Read` as the first read). Anything else reads and links the callees as before, so a callee rewritten in place, a callee moved or an unreadable callee behave as today, with the same errors. - A program that loads call targets from a table keeps its call sites but reads its tables and links every time. - The lookup copies the candidate links under the program's mutex and compares guest memory outside it. Nothing depends on the title: any registered compute shader or GCN vertex shader with user-data callees takes this path. On `main`, `LinkUserDataCallees` links compute programs only, so here the memo serves compute dispatches. With #9431 it also links GCN vertex programs, and the memo covers those the same way. **2. A raw shader's address range is checked only when its snapshot is read again** (Get-fix/AnyPS5#15) `ReadRawShader` (a PS4 program with no header, read from guest memory by its address) began with `GuestMemory::CheckRange` on its first four bytes, then looked the address up in its snapshot cache. A cached snapshot is then compared with guest memory by `GuestMemory::CompareMapped`, which walks the same page states and returns `Unmapped` for a page that is no longer readable. So on a cache hit the range check was a second page walk whose answer the compare gives anyway. `DecodeProgramsCurrent` calls `ReadRawShader` for each raw program of every draw that reuses a kept decode. On Monopoly Plus's language screen, after #14, a sampling profile of the queue worker put 8.2% of its time in `ReadRawShader`; `CheckRange` was about half of that. This commit runs the range check only when the snapshot is read again from guest memory: on a cache miss, or when the compare found the bytes changed or unmapped. Nothing else changes: - An address that was never cached (null, misaligned, unreadable) fails the check first, as before; the cache only holds addresses that passed it. - A cached snapshot is returned only when its bytes compare equal, which needs every page readable. - A cached program whose pages became unreadable compares `Unmapped`, reaches the check and throws as before. Get-fix/AnyPS5#14 (bypassing an unhit result memo) is not here: #6733 replaced that memo with a set-associative table on `main`, and its eviction cost, which #14 avoided, would have to be measured again. ### Tested Windows 11 Pro 26300, WinLibs GCC 15.2.0, Release, on `main` `3bbd2321de`, AMD Radeon RX 9070 XT (driver 32.0.31041.1004), `ANYPS5_GPU=AMD`. - `agc_driver_user_data_link_reuse` (new, Vulkan) runs a compute program that calls two user-data callees three times in a loop. It is invoked through `InvocationFor` and dispatched each time, and every lane must hold the sum of the callees' constants. - The first invocation keeps one link with both callees. A second one with the same callees reuses it. - Rewriting the first callee in place gets a new link. Restoring its words reuses the old link. - Pointing both calls at the second callee gets a new link. - Ten more rewrites leave the program's eight most recent links. With `ShaderRegistry.cpp` as on `main` it fails with "the first invocation did not keep exactly one user-data link with both callees". - The raw shader commit moves one existing check, so it has no test of its own. `agc_driver_scalar_swappc`, `agc_driver_scalar_swappc_fetch`, both `agc_driver_compute_user_data_calls` modes and the user-data tail tests pass. - **Merge of `main` `b7488e1ff5` (30 Oct, merge commit `009fc42f03`):** the only conflict was `LinkUserDataCallees`. #9431 made it link GCN vertex shaders too, and the merge keeps that rule with this branch's memo. On the merge, 11 of 11 pass on the RX 9070 XT under the validation layer, with no `VUID-` line: `agc_driver`, `agc_shader_memory`, both `agc_driver_compute_user_data_calls` modes, `agc_driver_scalar_swappc`, `agc_driver_scalar_swappc_fetch`, `agc_driver_queued_raw_shader`, `agc_driver_user_data_link_reuse`, `agc_driver_user_data_call_after_branch`, and the fragment and vertex user-data tail tests. The focused 100-test set and the per-case failures below are from before this merge and were not rerun. Linux was not compiled here; `PreparedShaderState` has no size guard. - **Merge of `main` `cc26ab4438` (1 Nov, merge commit `89f30e45f0`):** the only conflict was `libSceAgcDriver/CMakeLists.txt`: `main` moved the AGC test registrations into `tests/cmake`, and `tools/agc_test_split.py resolve` moved this branch's include line to the `agc_driver_user_data_link_reuse_tests` fragment. `agc_driver`, `agc_shader_memory`, both `agc_driver_compute_user_data_calls` modes, `agc_driver_scalar_swappc`, `agc_driver_scalar_swappc_fetch`, `agc_driver_queued_raw_shader`, `agc_driver_user_data_link_reuse` and `agc_driver_user_data_call_after_branch` pass, 3 of 3 on the RX 9070 XT under the validation layer, no `VUID-` line. Not rerun: the other tests, Linux, games. - Validation layer: 100 focused tests on `main` and the same 100 plus the new one on this branch, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`. The set is the same as for the store pull request. All pass: 100 of 100 and 101 of 101. Both logs have the same four `VUID-VkImageViewCreateInfo-usage-02275` lines from `agc_sampled_storage_base_level_usage`, which `main` already logs; the change adds none. Neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`, and every device line names the RX 9070 XT. **What the performance numbers below can and cannot show.** - There is no `main`/change pair from this title. CUSA03312 does not start on `main` (it needs #9430 to #9432), so both pairs below come from the unpublished local stack on `ps4/limbo-gpu` described next, and cannot be rebuilt from published commits. The traces named in their summary lines are not attached. - On `main` the memo serves only compute programs with user-data callees, because `LinkUserDataCallees` links only those; GCN vertex programs reach it with #9431. EdouardSence's alternated A/B on ASTRO BOT (PPSA21567, Sky Garden, RX 9070 XT, RADV), on `main` plus #9852 with and without this head, is level: frame p50 207.1 ms against 209.4 ms, inside that scene's ±1.5 % run-to-run spread ([comment](https://github.com/boykopovar/AnyPS5/pull/9899#issuecomment-6363581584)). Neither `main` nor this change counts reused links, so that run cannot show how often the memo was hit there. - So this pull request makes no speed claim against `main`. It stands as an optimisation with identical output: `agc_driver_user_data_link_reuse` checks the dispatch results with a reused link, after a rewrite and after the cap of eight links. The CUSA03312 numbers show what it does on the title stack it was written for. - Dropped events: each trace's queue worker filled its event buffer 3.1 to 3.7 s into the 15 s window and lost 0.80 to 1.0 million slices, but `totals_full` is `false` in every line. The summary fields (`frame_ms`, `gpu_busy_ms_per_present`, `worker_busy_pct`, `top_phases_ms_per_frame`) are built from the complete totals and hold. Only the per-slice parts of `tools/trace_digest.py` (slowest frames, the threads table, longest waits) miss the queue worker's slices after the buffer filled. **Monopoly Plus (CUSA03312).** The title doesn't run on `main`: it needs #9430 to #9432. As agreed on #6977, these numbers come from `ps4/limbo-gpu` at `93eeee0141` (#6977's head then), with and without the change, on the local stack the title needs to start: the Get-fix pull requests named with each pair, and local stand-ins for `sceGnmDrawInitDefaultHardwareState200` and `sceGnmUpdate*Shader`. The base and change commits named with each pair are commits of that local stack, which isn't published. Base and change alternated on the same machine and scene. 1. Callee link, on the language screen. Pair: base `3fe75b613c`, change `60aac9783f`, both with Get-fix/AnyPS5#1, #2, #5, #8 and #10 to #12: | build | fps | frame p50 | frame p90 | GPU busy ms/present | worker `Driver.Packet` ms/frame | `shader_compile_and_link` ms/frame | `prepared_invocation` ms/frame | `materialize` ms/frame | `capture_resources` ms/frame | |---|---|---|---|---|---|---|---|---|---| | base | 18.49, 18.23, 17.95 | 54.1 to 54.9 ms | 55.3 to 59.1 ms | 13.0 to 14.5 | 52.6 to 54.2 | 33.7 to 34.6 | 15.9 to 16.3 | 9.3 to 9.7 | 6.8 to 7.0 | | change | 24.87, 24.14, 24.39 | 40.1 to 40.9 ms | 41.1 to 44.4 ms | 13.6 to 14.5 | 38.7 to 39.9 | 19.8 to 20.4 | not in the top eight | 9.3 to 9.8 | 6.5 to 6.7 | Summary lines; the two traces they name will be attached by hand: Base (`3fe75b613c`): ```json {"commit":"3fe75b613c46","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":2876,"ms":15038.359},"presents":278,"frame_ms":{"p50":54.109,"p90":55.275,"p99":56.926,"max":58.172},"gpu_busy_ms_per_present":14.539,"worker_busy_pct":{"queue worker 0x0":97.434},"top_phases_ms_per_frame":{"Driver.Packet":52.609,"Driver.Packet.draw":41.991,"Driver.Draw":41.672,"Driver.Draw.shader_compile_and_link":33.732,"Shader.DrawStage":32.164,"Shader.DrawStage.prepared_invocation":15.939,"Shader.DrawStage.materialize":9.366,"Shader.DrawStage.capture_resources":6.791},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.109,"events_lost":1002952,"totals_full":false}},"trace":"aps5-trace-3fe75b613c46-35740.json.gz"} ``` Change (`60aac9783f`): ```json {"commit":"60aac9783f36","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3535,"ms":15037.086},"presents":374,"frame_ms":{"p50":40.132,"p90":41.068,"p99":42.454,"max":46.176},"gpu_busy_ms_per_present":13.558,"worker_busy_pct":{"queue worker 0x0":96.566},"top_phases_ms_per_frame":{"Driver.Packet":38.718,"Driver.Packet.draw":28.054,"Driver.Draw":27.762,"Driver.Draw.shader_compile_and_link":19.752,"Shader.DrawStage":18.1,"Shader.DrawStage.materialize":9.315,"Shader.DrawStage.capture_resources":6.547,"Driver.Packet.device_lock":6.078},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.357,"events_lost":909859,"totals_full":false}},"trace":"aps5-trace-60aac9783f36-9108.json.gz"} ``` <details><summary><code>tools/trace_digest.py</code> of the two traces</summary> Base, `aps5-trace-3fe75b613c46-35740`: **seconds 120:15** from present 2876: 278 presents, frame p50 54.1 / p90 55.3 / p99 56.9 / max 58.2 ms, GPU busy 14.5 ms per present AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 3fe75b613c46, dropped: yes ```json {"commit":"3fe75b613c46","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":2876,"ms":15038.359},"presents":278,"frame_ms":{"p50":54.109,"p90":55.275,"p99":56.926,"max":58.172},"gpu_busy_ms_per_present":14.539,"worker_busy_pct":{"queue worker 0x0":97.434},"top_phases_ms_per_frame":{"Driver.Packet":52.609,"Driver.Packet.draw":41.991,"Driver.Draw":41.672,"Driver.Draw.shader_compile_and_link":33.732,"Shader.DrawStage":32.164,"Shader.DrawStage.prepared_invocation":15.939,"Shader.DrawStage.materialize":9.366,"Shader.DrawStage.capture_resources":6.791},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.109,"events_lost":1002952,"totals_full":false}},"trace":"aps5-trace-3fe75b613c46-35740.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 3029: 58.2 ms at 8210 ms: batch (gpu) 14.7, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1 - present 3060: 57.0 ms at 9906 ms: batch (gpu) 14.6, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2 - present 3091: 56.9 ms at 11597 ms: batch (gpu) 14.9, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 10.0 (18 %) | 0.1 (0 %) | 44.1 | 10.6 | Driver.Packet 10.0, Driver.EndSubmission 0.0 | | presenter | 0.3 (1 %) | 0.1 (0 %) | 53.7 | 0.0 | Driver.Present 0.4 | | gpu | 14.5 (27 %) | 0.0 (0 %) | 39.6 | 0.0 | batch 14.5 | **Largest slices** (ms per frame, inclusive, all threads): batch 14.5, Driver.Packet 10.0, Driver.Packet.draw 8.7, Driver.Draw 8.6, Driver.Draw.shader_compile_and_link 6.8, Shader.DrawStage 4.3, Shader.DrawStage.prepared_invocation 1.7, Driver.Packet.device_lock 1.0 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 2665 ms, present 2926 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 54 ms, present 2877 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 1861 ms, present 2911 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 797 ms, present 2890 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 214 ms, present 2880 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 2986 ms, present 2932 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 1225 ms, present 2899 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 587 ms, present 2887 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 51438: 2.9 ms at 7046 ms, present 3007: GPU no ranges; recorded by no CPU slices - batch 49400: 2.9 ms at 2749 ms, present 2927: GPU no ranges; recorded by no CPU slices - batch 54459: 2.9 ms at 13380 ms, present 3123: GPU no ranges; recorded by no CPU slices Change, `aps5-trace-60aac9783f36-9108`: **seconds 120:15** from present 3535: 374 presents, frame p50 40.1 / p90 41.1 / p99 42.5 / max 46.2 ms, GPU busy 13.6 ms per present AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 60aac9783f36, dropped: yes ```json {"commit":"60aac9783f36","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3535,"ms":15037.086},"presents":374,"frame_ms":{"p50":40.132,"p90":41.068,"p99":42.454,"max":46.176},"gpu_busy_ms_per_present":13.558,"worker_busy_pct":{"queue worker 0x0":96.566},"top_phases_ms_per_frame":{"Driver.Packet":38.718,"Driver.Packet.draw":28.054,"Driver.Draw":27.762,"Driver.Draw.shader_compile_and_link":19.752,"Shader.DrawStage":18.1,"Shader.DrawStage.materialize":9.315,"Shader.DrawStage.capture_resources":6.547,"Driver.Packet.device_lock":6.078},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.357,"events_lost":909859,"totals_full":false}},"trace":"aps5-trace-60aac9783f36-9108.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 3617: 46.2 ms at 3286 ms: Driver.Packet (queue worker 0x0) 38.1, Driver.Packet.draw (queue worker 0x0) 29.6, Driver.Draw (queue worker 0x0) 29.1, Driver.Draw.shader_compile_and_link (queue worker 0x0) 18.5 - present 3744: 43.3 ms at 8419 ms: batch (gpu) 13.6, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1 - present 3634: 42.6 ms at 3983 ms: batch (gpu) 13.7, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 7.3 (18 %) | 0.1 (0 %) | 32.8 | 12.4 | Driver.Packet 7.4, Driver.EndSubmission 0.0 | | presenter | 0.3 (1 %) | 0.1 (0 %) | 39.8 | 0.0 | Driver.Present 0.4 | | gpu | 13.6 (34 %) | 0.0 (0 %) | 26.6 | 0.0 | batch 13.6 | **Largest slices** (ms per frame, inclusive, all threads): batch 13.6, Driver.Packet 7.4, Driver.Packet.draw 5.9, Driver.Draw 5.8, Driver.Draw.shader_compile_and_link 3.6, Driver.Packet.device_lock 1.2, Shader.DrawStage 1.0, Driver.Present 0.4 **Longest waits** - Driver.WorkerWait (queue worker 0x0) 0.7 ms at 2647 ms, present 3600 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 1203 ms, present 3565 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 2368 ms, present 3594 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 3286 ms, present 3617 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 1284 ms, present 3567 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 120 ms, present 3538 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 3332 ms, present 3618 - Driver.Packet.memory_wait (queue worker 0x0) 0.4 ms at 2167 ms, present 3589 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 60861: 2.8 ms at 2709 ms, present 3602: GPU no ranges; recorded by no CPU slices - batch 61208: 2.7 ms at 3311 ms, present 3617: GPU no ranges; recorded by no CPU slices - batch 67306: 2.7 ms at 13815 ms, present 3878: GPU no ranges; recorded by no CPU slices In each trace the queue worker's event buffer filled 3.1 to 3.4 s into the 15 s window (`trace_dropped_threads`). Its later slices are missing from the trace, so the thread, slice and wait lists cover only that part of the queue worker's time. </details> 2. Raw shader range check. Pair: base `819cd3db26`, change `cb626a70e8`, both with Get-fix/AnyPS5#1, #2, #5, #8 and #10 to #14: the queue worker's profile share of the check fell from 8.2% to 5.1%, and fps stayed within noise (26.3 vs 26.7). Summary lines; the two traces they name will be attached by hand: Base (`819cd3db26`): ```json {"commit":"819cd3db2630","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3744,"ms":15011.733},"presents":395,"frame_ms":{"p50":37.904,"p90":39.212,"p99":41.53,"max":57.233},"gpu_busy_ms_per_present":13.184,"worker_busy_pct":{"queue worker 0x0":96.232},"top_phases_ms_per_frame":{"Driver.Packet":36.474,"Driver.Packet.draw":25.08,"Driver.Draw":24.757,"Driver.Draw.shader_compile_and_link":16.413,"Shader.DrawStage":14.794,"Shader.DrawStage.capture_resources":7.109,"Driver.Packet.device_lock":6.646,"Shader.DrawStage.materialize":5.454},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.577,"events_lost":839072,"totals_full":false}},"trace":"aps5-trace-819cd3db2630-35708.json.gz"} ``` Change (`cb626a70e8`): ```json {"commit":"cb626a70e8ae","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3828,"ms":15012.513},"presents":419,"frame_ms":{"p50":35.608,"p90":37.677,"p99":39.354,"max":50.076},"gpu_busy_ms_per_present":13.86,"worker_busy_pct":{"queue worker 0x0":96.109},"top_phases_ms_per_frame":{"Driver.Packet":34.329,"Driver.Packet.draw":23.134,"Driver.Draw":22.824,"Driver.Draw.shader_compile_and_link":15.864,"Shader.DrawStage":14.352,"Shader.DrawStage.capture_resources":6.875,"Driver.Packet.device_lock":6.55,"Shader.DrawStage.materialize":5.268},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.702,"events_lost":795786,"totals_full":false}},"trace":"aps5-trace-cb626a70e8ae-27232.json.gz"} ``` <details><summary><code>tools/trace_digest.py</code> of the two traces</summary> Base, `aps5-trace-819cd3db2630-35708`: **seconds 120:15** from present 3744: 395 presents, frame p50 37.9 / p90 39.2 / p99 41.5 / max 57.2 ms, GPU busy 13.2 ms per present AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit 819cd3db2630, dropped: yes ```json {"commit":"819cd3db2630","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3744,"ms":15011.733},"presents":395,"frame_ms":{"p50":37.904,"p90":39.212,"p99":41.53,"max":57.233},"gpu_busy_ms_per_present":13.184,"worker_busy_pct":{"queue worker 0x0":96.232},"top_phases_ms_per_frame":{"Driver.Packet":36.474,"Driver.Packet.draw":25.08,"Driver.Draw":24.757,"Driver.Draw.shader_compile_and_link":16.413,"Shader.DrawStage":14.794,"Shader.DrawStage.capture_resources":7.109,"Driver.Packet.device_lock":6.646,"Shader.DrawStage.materialize":5.454},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.577,"events_lost":839072,"totals_full":false}},"trace":"aps5-trace-819cd3db2630-35708.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 3931: 57.2 ms at 7074 ms: batch (gpu) 14.8, Driver.Present (presenter) 0.3, Driver.Present.acquire_image (presenter) 0.1, Vulkan.Acquire (presenter) 0.1 - present 3932: 43.2 ms at 7131 ms: batch (gpu) 13.8, Driver.Present (presenter) 0.7, Driver.Present.acquire_image (presenter) 0.5, Vulkan.Acquire (presenter) 0.5 - present 3865: 42.0 ms at 4564 ms: batch (gpu) 12.2, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 7.0 (18 %) | 0.1 (0 %) | 30.9 | 13.3 | Driver.Packet 7.1, Driver.EndSubmission 0.0 | | presenter | 0.3 (1 %) | 0.1 (0 %) | 37.6 | 0.0 | Driver.Present 0.4 | | gpu | 13.2 (35 %) | 0.0 (0 %) | 24.8 | 0.0 | batch 13.2 | **Largest slices** (ms per frame, inclusive, all threads): batch 13.2, Driver.Packet 7.1, Driver.Packet.draw 5.3, Driver.Draw 5.2, Driver.Draw.shader_compile_and_link 2.6, Driver.Packet.device_lock 1.4, Shader.DrawStage 0.6, Driver.Present 0.4 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x0) 1.2 ms at 2595 ms, present 3813 - Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 114 ms, present 3747 - Vulkan.Acquire.acquire_fence_wait (presenter) 0.7 ms at 8700 ms, present 3973 - Driver.Packet.memory_wait (queue worker 0x0) 0.7 ms at 2672 ms, present 3814 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 671 ms, present 3762 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 2900 ms, present 3821 - Vulkan.Acquire.acquire_fence_wait (presenter) 0.6 ms at 6269 ms, present 3910 - Driver.Packet.memory_wait (queue worker 0x0) 0.6 ms at 2790 ms, present 3818 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 63256: 3.2 ms at 1323 ms, present 3779: GPU no ranges; recorded by no CPU slices - batch 63348: 3.2 ms at 1477 ms, present 3783: GPU no ranges; recorded by no CPU slices - batch 66601: 3.2 ms at 6789 ms, present 3923: GPU no ranges; recorded by no CPU slices Change, `aps5-trace-cb626a70e8ae-27232`: **seconds 120:15** from present 3828: 419 presents, frame p50 35.6 / p90 37.7 / p99 39.4 / max 50.1 ms, GPU busy 13.9 ms per present AMD Radeon RX 9070 XT, AMD proprietary driver 26.8.1 (LLPC), Windows 10.0.26300, 1920x1080, commit cb626a70e8ae, dropped: yes ```json {"commit":"cb626a70e8ae","dirty":false,"env":{"APS5_PAD_INPUT_FILE":"<path>","APS5_RESIDENT_LINEAR":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"120:15","APS5_TRACE_SUMMARY_EVERY":"15"},"gpu":"AMD Radeon RX 9070 XT","driver":"AMD proprietary driver 26.8.1 (LLPC)","os":"Windows 10.0.26300","resolution":"1920x1080","window":{"spec":"seconds 120:15","first_present":3828,"ms":15012.513},"presents":419,"frame_ms":{"p50":35.608,"p90":37.677,"p99":39.354,"max":50.076},"gpu_busy_ms_per_present":13.86,"worker_busy_pct":{"queue worker 0x0":96.109},"top_phases_ms_per_frame":{"Driver.Packet":34.329,"Driver.Packet.draw":23.134,"Driver.Draw":22.824,"Driver.Draw.shader_compile_and_link":15.864,"Shader.DrawStage":14.352,"Shader.DrawStage.capture_resources":6.875,"Driver.Packet.device_lock":6.55,"Shader.DrawStage.materialize":5.268},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":3.702,"events_lost":795786,"totals_full":false}},"trace":"aps5-trace-cb626a70e8ae-27232.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 4100: 50.1 ms at 9720 ms: batch (gpu) 15.2, Driver.Present (presenter) 2.1, Driver.Present.acquire_image (presenter) 1.8, Vulkan.Acquire (presenter) 1.8 - present 4131: 39.7 ms at 10858 ms: batch (gpu) 14.9, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2 - present 4075: 39.7 ms at 8806 ms: batch (gpu) 15.0, Driver.Present (presenter) 0.4, Driver.Present.acquire_image (presenter) 0.2, Vulkan.Acquire (presenter) 0.2 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 6.5 (18 %) | 0.1 (0 %) | 29.2 | 13.9 | Driver.Packet 6.6, Driver.EndSubmission 0.0 | | presenter | 0.3 (1 %) | 0.1 (0 %) | 35.4 | 0.0 | Driver.Present 0.4 | | gpu | 13.9 (39 %) | 0.0 (0 %) | 22.0 | 0.0 | batch 13.9 | **Largest slices** (ms per frame, inclusive, all threads): batch 13.9, Driver.Packet 6.6, Driver.Packet.draw 4.8, Driver.Draw 4.8, Driver.Draw.shader_compile_and_link 2.5, Driver.Packet.device_lock 1.4, Shader.DrawStage 0.6, Driver.Present 0.4 **Longest waits** - Vulkan.Acquire.acquire_fence_wait (presenter) 1.7 ms at 9720 ms, present 4100 - Driver.Packet.memory_wait (queue worker 0x0) 0.9 ms at 2168 ms, present 3889 - Driver.Packet.memory_wait (queue worker 0x0) 0.8 ms at 348 ms, present 3838 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 1383 ms, present 3867 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 3019 ms, present 3913 - Vulkan.Acquire.acquire_fence_wait (presenter) 0.5 ms at 12787 ms, present 4185 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 957 ms, present 3855 - Driver.Packet.memory_wait (queue worker 0x0) 0.5 ms at 279 ms, present 3836 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 66804: 3.2 ms at 3563 ms, present 3928: GPU no ranges; recorded by no CPU slices - batch 73993: 3.2 ms at 14842 ms, present 4242: GPU no ranges; recorded by no CPU slices - batch 73158: 3.1 ms at 13523 ms, present 4205: GPU no ranges; recorded by no CPU slices In each trace the queue worker's event buffer filled 3.6 to 3.7 s into the 15 s window (`trace_dropped_threads`). Its later slices are missing from the trace, so the thread, slice and wait lists cover only that part of the queue worker's time. </details> - `tools/check_conventions.py --base origin/main` passes. - `tools/pr_overlap.py` lists #8658 (macOS host), which changes neighbouring lines of `ShaderRegistry.cpp`, and #9842. #9431 and the pull requests stacked on it, #9842 among them, change the first lines of `LinkUserDataCallees` to link GCN vertex programs as well. With both in, that line returns `nullptr` for a program that is neither compute nor a GCN vertex program, and the memo covers both. None implements the same thing. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: CUSA03312 #7198 - [x] GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.31041.1004, Windows 11 Pro 26300 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9899
No description provided.