perf(agc): prebuild compute pipelines and prewarm dispatch shaders ahead of execution #8735

Merged
hamb3r merged 11 commits from upstream-pr/8735 into main 2026-10-25 12:20:13 +00:00
hamb3r commented 2026-10-20 22:45:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-20T22:45:26Z.


What

  • Extend ShaderManager::QueuePrebuild and PrebuildEntry with a compute flag so compute shaders queued by GetPreparedShaders(..., /*compute=*/true) pre-create both the vk::ShaderModule and the compute vk::Pipeline on the background shader prepare thread (GetOrCreateComputePipeline), avoiding synchronous pipeline compilation stalls during Driver::dispatch.
  • Pre-warm compute shaders ahead of execution inside Driver::resolveGroupAhead by scanning the upcoming packet segment up to the next wait/sync boundary (PreviewedUntil()) when the segment contains at least one subsequent dispatch (hasFurtherDispatch), tracking SetShReg / SetContextReg updates on a lightweight preview state and calling RegisteredProgram (GetPreparedShaders(..., true)) for upcoming dispatches (scan > from) before the preceding dispatches finish executing. Single-dispatch segments (!hasFurtherDispatch) skip the preview pass with zero state copies or lookups.

Tested

  • Windows 11, AMD Radeon RX 9070 XT (RADV / AMD proprietary Vulkan driver 26.3.1, Vulkan 1.4.341):
    • ctest --test-dir build-portable -R "^(agc_driver_prepared_shaders_compute_prebuild|agc_driver_prepared_shaders_dispatch_ahead_prewarm|agc_driver_compute_basic_dispatch|agc_driver_compute_multi_dispatch)$" -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation on both main (522e32e3b618) and this branch (dcb04d0aa14d) — all 4 tests pass with 0 VUID- validation errors.
  • Demon's Souls (PPSA01341 v1.07), Windows 11, same machine and boot/intro scene (APS5_TRACE_FRAMES=0:20, default flags, 3 cold-pipeline-cache runs + 3 warm-cache runs per branch). All 12 .json.gz traces are attached below.

Attached Traces (12 runs: 3 Cold + 3 Warm per branch)

  • main (522e32e3b618) Cold 1..3:
    • aps5-trace-522e32e3b618-39024.json.gz (window.ms=7911.797, p50=71.790, p90=899.812, max=5652.293, Driver.Packet=2711.103, Packet.dispatch=471.154, Driver.Dispatch=438.601, materialize=121.787)
    • aps5-trace-522e32e3b618-28612.json.gz (window.ms=8543.938, p50=69.237, p90=893.505, max=5998.794, Driver.Packet=2855.925, Packet.dispatch=562.523, Driver.Dispatch=473.093, materialize=127.010)
    • aps5-trace-522e32e3b618-20240.json.gz (window.ms=8480.218, p50=85.598, p90=1030.123, max=6032.006, Driver.Packet=2950.152, Packet.dispatch=497.480, Driver.Dispatch=460.815, materialize=127.731)
  • perf/agc-compute-prewarm (dcb04d0aa14d) Cold 1..3:
    • aps5-trace-dcb04d0aa14d-31308.json.gz (window.ms=8765.408, p50=85.279, p90=568.491, max=6661.114, Driver.Packet=3035.776, Packet.dispatch=512.372, Driver.Dispatch=482.331, materialize=130.607)
    • aps5-trace-dcb04d0aa14d-47372.json.gz (window.ms=8992.743, p50=85.367, p90=584.385, max=6463.900, Driver.Packet=3064.032, Packet.dispatch=549.805, Driver.Dispatch=515.185, materialize=128.516)
    • aps5-trace-dcb04d0aa14d-23608.json.gz (window.ms=8145.822, p50=81.976, p90=163.222, max=6580.297, Driver.Packet=3031.801, Packet.dispatch=543.130, Driver.Dispatch=452.018, materialize=127.940)
  • main (522e32e3b618) Warm 1..3:
    • aps5-trace-522e32e3b618-28224.json.gz (window.ms=6870.411, p50=78.791, p90=799.413, max=4727.829, Driver.Packet=2287.577, Packet.dispatch=416.237, Driver.Dispatch=383.796, materialize=124.635)
    • aps5-trace-522e32e3b618-38788.json.gz (window.ms=6792.077, p50=75.507, p90=800.919, max=4787.418, Driver.Packet=2293.844, Packet.dispatch=408.587, Driver.Dispatch=373.319, materialize=124.379)
    • aps5-trace-522e32e3b618-32828.json.gz (window.ms=6612.875, p50=70.261, p90=755.799, max=4599.907, Driver.Packet=2234.188, Packet.dispatch=424.879, Driver.Dispatch=388.964, materialize=120.988)
  • perf/agc-compute-prewarm (dcb04d0aa14d) Warm 1..3:
    • aps5-trace-dcb04d0aa14d-33228.json.gz (window.ms=6863.060, p50=68.699, p90=447.956, max=4802.256, Driver.Packet=2303.209, Packet.dispatch=484.234, Driver.Dispatch=439.233, materialize=120.444)
    • aps5-trace-dcb04d0aa14d-39356.json.gz (window.ms=6862.217, p50=85.842, p90=778.916, max=4746.500, Driver.Packet=2333.684, Packet.dispatch=420.290, Driver.Dispatch=388.508, materialize=122.702)
    • aps5-trace-dcb04d0aa14d-51020.json.gz (window.ms=6639.422, p50=71.507, p90=503.585, max=4767.308, Driver.Packet=2218.187, Packet.dispatch=425.453, Driver.Dispatch=391.083, materialize=109.963)

3-Run Median Comparison (APS5_TRACE_FRAMES=0:20, default flags)

Metric main Cold Median PR Cold Median Cold Delta main Warm Median PR Warm Median Warm Delta
window.ms 8480.218 8765.408 +3.4% 6792.077 6862.217 +1.0%
frame_ms.p50 71.790 85.279 +18.8% 75.507 71.507 -5.3%
frame_ms.p90 899.812 568.491 -36.8% 799.413 503.585 -37.0%
frame_ms.max 5998.794 6580.297 +9.7% 4727.829 4767.308 +0.8%
Driver.Packet (ms/f) 2855.925 3035.776 +6.3% 2287.577 2303.209 +0.7%
Driver.Packet.dispatch (ms/f) 497.480 543.130 +9.2% 416.237 425.453 +2.2%
Driver.Dispatch (ms/f) 460.815 482.331 +4.7% 383.796 391.083 +1.9%
Driver.Dispatch.materialize (ms/f) 127.010 128.516 +1.2% 124.379 120.444 -3.2%
Async queues (0x20..0x50) sync Vulkan.ComputePipeline count 30 1 -96.7% 0 0 0
shader prepare prebuilt Vulkan.ComputePipeline count 0 29 +29 0 0 0

tools/trace_digest.py — Cold Median Run (main aps5-trace-522e32e3b618-20240.json.gz vs PR aps5-trace-dcb04d0aa14d-31308.json.gz)

main cold median digest (aps5-trace-522e32e3b618-20240.json.gz)
**frames 0:20** from present 0: 20 presents, frame p50 85.6 / p90 1030.1 / p99 6032.0 / max 6032.0 ms, GPU busy 28.3 ms per present
NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit 522e32e3b618, dropped: no

```json
{"commit":"522e32e3b618","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":8480.218},"presents":20,"frame_ms":{"p50":85.598,"p90":1030.123,"p99":6032.006,"max":6032.006},"gpu_busy_ms_per_present":28.306,"worker_busy_pct":{"queue worker 0x0":89.458,"queue worker 0x20":88.677,"queue worker 0x40":88.027,"queue worker 0x48":86.028,"queue worker 0x50":86.994,"queue worker 0x30":87.706,"queue worker 0x38":87.5,"queue worker 0x28":89.169},"top_phases_ms_per_frame":{"Driver.Packet":2950.152,"Driver.Packet.memory_wait":2432.478,"Driver.Packet.dispatch":497.48,"Driver.Dispatch":460.815,"Driver.Dispatch.materialize":127.731,"Vulkan.Dispatch":117.839,"Vulkan.Dispatch.shader_resources":113.335,"Shader.PrepareArtifact":96.432},"trace_dropped":false,"trace":"aps5-trace-522e32e3b618-20240.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1: 6032.0 ms at 22 ms: Driver.Packet (queue worker 0x0) 5864.8, Driver.Packet (queue worker 0x40) 5862.8, Driver.Packet (queue worker 0x50) 5860.5, Driver.Packet.memory_wait (queue worker 0x50) 5850.3
  • present 18: 1030.1 ms at 7406 ms: Shader.PrepareArtifact (shader prepare) 804.6, Driver.Packet (queue worker 0x30) 540.6, Driver.Packet (queue worker 0x40) 540.4, Driver.Packet (queue worker 0x50) 540.4
  • present 17: 149.5 ms at 7257 ms: Driver.WorkerWait (queue worker 0x48) 118.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 118.2, Driver.WorkerWait (queue worker 0x0) 108.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 108.8
  • present 15: 127.1 ms at 7088 ms: Driver.Packet (queue worker 0x0) 73.0, Driver.Packet (queue worker 0x48) 72.9, Driver.Packet.memory_wait (queue worker 0x48) 72.9, Driver.Packet (queue worker 0x28) 72.6
  • present 2: 114.5 ms at 6054 ms: Driver.Packet (queue worker 0x40) 114.2, Driver.Packet (queue worker 0x50) 114.1, Driver.Packet (queue worker 0x30) 114.0, Driver.Packet (queue worker 0x20) 113.9

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
shader prepare 10.6 (2 %) 0.0 (0 %) 413.5 0.0 Shader.PrepareArtifact 10.6
shader prepare 15.5 (4 %) 0.0 (0 %) 408.5 0.0 Shader.PrepareArtifact 15.5
shader prepare 10.5 (2 %) 0.0 (0 %) 413.5 0.0 Shader.PrepareArtifact 10.5
shader prepare 12.4 (3 %) 0.0 (0 %) 411.6 0.0 Shader.PrepareArtifact 12.4
shader prepare 11.2 (3 %) 0.0 (0 %) 412.8 0.0 Shader.PrepareArtifact 11.2
shader prepare 10.7 (3 %) 0.0 (0 %) 413.3 0.0 Shader.PrepareArtifact 10.7
title 0.9 (0 %) 0.0 (0 %) 423.2 0.0 Shader.Register 0.9, Shader.ResolveGraphicsStagesAbi 0.0
shader prepare 4.2 (1 %) 0.0 (0 %) 419.8 0.0 Vulkan.GraphicsPipelinePrebuild 4.2
shader prepare 12.9 (3 %) 0.0 (0 %) 411.1 0.0 Shader.PrepareArtifact 12.9
shader prepare 12.4 (3 %) 0.0 (0 %) 411.6 0.0 Shader.PrepareArtifact 12.4
title 1.6 (0 %) 0.0 (0 %) 422.4 0.0 Shader.ResolveAbi 1.0, Shader.Register 0.5
title 2.0 (0 %) 0.0 (0 %) 422.1 0.0 Shader.Register 1.8, Shader.ResolveGraphicsStagesAbi 0.1
title 1.7 (0 %) 0.0 (0 %) 422.3 0.0 Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0
title 2.2 (1 %) 0.0 (0 %) 421.8 0.0 Shader.Register 1.5, Shader.ResolveAbi 0.7
title 0.3 (0 %) 0.0 (0 %) 423.7 0.0 Shader.Register 0.3, Shader.ResolveGraphicsStagesAbi 0.0
title 1.9 (0 %) 0.0 (0 %) 422.1 0.0 Shader.Register 1.9, Shader.ResolveGraphicsStagesAbi 0.0
title 1.7 (0 %) 0.0 (0 %) 422.3 0.0 Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0
title 0.8 (0 %) 0.0 (0 %) 423.2 0.0 Shader.Register 0.8, Shader.ResolveGraphicsStagesAbi 0.0
queue worker 0x0 293.8 (69 %) 118.9 (28 %) 11.4 7.2 Driver.Packet 376.3, Driver.EndSubmission 1.3
presenter 0.8 (0 %) 2.7 (1 %) 420.5 0.1 VideoOut.Flip 3.5, Driver.Present 0.1
draw committer 12.1 (3 %) 9.7 (2 %) 402.3 0.3 Graphics.Draw 10.5, Recorder.Sync 1.0
queue worker 0x20 23.8 (6 %) 389.7 (92 %) 10.5 1.8 Driver.Packet 372.4, Driver.EndSubmission 3.1
queue worker 0x40 28.5 (7 %) 384.3 (91 %) 11.2 0.6 Driver.Packet 372.9, Driver.EndSubmission 0.2
queue worker 0x48 0.2 (0 %) 413.7 (98 %) 10.2 0.0 Driver.Packet 364.4, Driver.EndSubmission 0.4
queue worker 0x50 3.4 (1 %) 408.8 (96 %) 11.8 0.4 Driver.Packet 368.5, Driver.EndSubmission 0.2
queue worker 0x30 62.9 (15 %) 349.6 (82 %) 11.5 0.2 Driver.Packet 370.1, Driver.EndSubmission 1.7
queue worker 0x38 8.6 (2 %) 404.1 (95 %) 11.4 0.2 Driver.Packet 359.1, Driver.EndSubmission 11.9
queue worker 0x28 6.8 (2 %) 406.9 (96 %) 10.2 0.9 Driver.Packet 363.8, Driver.EndSubmission 14.1
gpu 32.7 (8 %) 0.0 (0 %) 391.3 0.0 batch 32.7

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 2947.5, Driver.Packet.memory_wait 2432.4, Driver.Packet.dispatch 496.8, Driver.Dispatch 459.8, Driver.WorkerWait 323.4, Driver.WorkerWait.idle_and_completion_poll 323.3, Driver.Dispatch.materialize 126.7, Vulkan.Dispatch 117.1, Vulkan.Dispatch.shader_resources 112.9, Shader.PrepareArtifact 96.4

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x28) 5581.5 ms at 386 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x48) 5556.9 ms at 368 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x50) 5510.9 ms at 544 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 4456.9 ms at 1379 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x30) 3624.4 ms at 2431 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 3459.6 ms at 2596 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 3258.9 ms at 2796 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 1505.6 ms at 1050 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 1117.0 ms at 1370 ms, present 1
  • GpuMutex.wait.dispatch (queue worker 0x0) 1030.5 ms at 1394 ms, present 1

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

  • batch 52: 49.4 ms at 2741 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 195.2, Driver.Packet.dispatch (queue worker 0x0) 195.2, Driver.Dispatch (queue worker 0x0) 195.1, GpuMutex.wait.dispatch (queue worker 0x0) 171.6
  • batch 730: 25.3 ms at 7340 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 108.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 108.8, Recorder.Sync (queue worker 0x0) 26.0, Driver.Packet (queue worker 0x0) 9.2
  • batch 781: 23.7 ms at 8373 ms, present 18: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 253.4, Driver.Packet.dispatch (queue worker 0x0) 253.4, Driver.Dispatch (queue worker 0x0) 252.9, Driver.Dispatch.materialize (queue worker 0x0) 64.5
  • batch 4: 16.5 ms at 428 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x50) 348.7, Driver.Packet.memory_wait (queue worker 0x50) 340.4, Driver.Packet.dispatch (queue worker 0x50) 8.1, Driver.Dispatch (queue worker 0x50) 3.9
  • batch 766: 16.0 ms at 7476 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 488.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 488.4, Recorder.Sync (queue worker 0x0) 16.3, Driver.Dispatch.materialize (queue worker 0x0) 12.4
</details>

<details>
<summary><code>perf/agc-compute-prewarm</code> cold median digest (<code>aps5-trace-dcb04d0aa14d-31308.json.gz</code>)</summary>

```text
**frames 0:20** from present 0: 20 presents, frame p50 85.3 / p90 568.5 / p99 6661.1 / max 6661.1 ms, GPU busy 26.0 ms per present
NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit dcb04d0aa14d, dropped: no

```json
{"commit":"dcb04d0aa14d","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":8765.408},"presents":20,"frame_ms":{"p50":85.279,"p90":568.491,"p99":6661.114,"max":6661.114},"gpu_busy_ms_per_present":25.971,"worker_busy_pct":{"queue worker 0x0":89.256,"queue worker 0x20":88.273,"queue worker 0x28":88.257,"queue worker 0x48":85.635,"queue worker 0x38":87.377,"queue worker 0x50":87.054,"queue worker 0x30":87.728,"queue worker 0x40":87.921},"top_phases_ms_per_frame":{"Driver.Packet":3035.776,"Driver.Packet.memory_wait":2496.965,"Driver.Packet.dispatch":512.372,"Driver.Dispatch":482.331,"Driver.Dispatch.materialize":130.607,"Vulkan.Dispatch":115.845,"Vulkan.Dispatch.shader_resources":110.871,"Vulkan.ComputePipeline":72.394},"trace_dropped":false,"trace":"aps5-trace-dcb04d0aa14d-31308.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1: 6661.1 ms at 21 ms: Driver.Packet (queue worker 0x0) 6441.2, Driver.Packet (queue worker 0x50) 6432.0, Driver.Packet (queue worker 0x30) 6428.1, Driver.Packet (queue worker 0x40) 6427.6
  • present 18: 568.5 ms at 8100 ms: Driver.WorkerWait (queue worker 0x50) 560.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 560.2, Driver.WorkerWait (queue worker 0x30) 553.7, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 553.7
  • present 17: 164.6 ms at 7936 ms: Driver.WorkerWait (queue worker 0x50) 154.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 154.7, Driver.WorkerWait (queue worker 0x30) 143.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 143.0
  • present 11: 154.5 ms at 7439 ms: Shader.PrepareArtifact (shader prepare) 450.8, Driver.Packet (queue worker 0x40) 154.2, Driver.Packet (queue worker 0x30) 153.9, Driver.Packet (queue worker 0x50) 153.7
  • present 2: 132.2 ms at 6682 ms: Driver.Packet (queue worker 0x50) 132.0, Driver.Packet (queue worker 0x30) 132.0, Driver.Packet (queue worker 0x20) 131.4, Driver.Packet.memory_wait (queue worker 0x50) 131.1

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
shader prepare 7.8 (2 %) 0.0 (0 %) 430.5 0.0 Shader.PrepareArtifact 7.8
shader prepare 6.9 (2 %) 0.0 (0 %) 431.3 0.0 Shader.PrepareArtifact 6.9
shader prepare 7.7 (2 %) 0.0 (0 %) 430.5 0.0 Shader.PrepareArtifact 7.7
shader prepare 7.5 (2 %) 0.0 (0 %) 430.8 0.0 Shader.PrepareArtifact 7.5
shader prepare 7.5 (2 %) 0.0 (0 %) 430.7 0.0 Shader.PrepareArtifact 7.5
shader prepare 7.3 (2 %) 0.0 (0 %) 430.9 0.0 Shader.PrepareArtifact 7.3
shader prepare 8.0 (2 %) 0.0 (0 %) 430.3 0.0 Shader.PrepareArtifact 8.0
title 1.0 (0 %) 0.0 (0 %) 437.2 0.0 Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0
shader prepare 7.2 (2 %) 0.0 (0 %) 431.1 0.0 Shader.PrepareArtifact 7.2
shader prepare 14.8 (3 %) 0.0 (0 %) 423.5 0.0 Vulkan.ComputePipeline 10.5, Vulkan.GraphicsPipelinePrebuild 4.2
title 1.1 (0 %) 0.0 (0 %) 437.2 0.0 Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 438.2 0.0 Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 1.6 (0 %) 0.0 (0 %) 436.7 0.0 Shader.Register 0.9, Shader.ResolveAbi 0.7
title 1.1 (0 %) 0.0 (0 %) 437.1 0.0 Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.0
title 2.2 (1 %) 0.0 (0 %) 436.0 0.0 Shader.Register 1.2, Shader.ResolveAbi 1.1
title 0.9 (0 %) 0.0 (0 %) 437.4 0.0 Shader.Register 0.8, Shader.ResolveGraphicsStagesAbi 0.0
title 1.3 (0 %) 0.0 (0 %) 437.0 0.0 Shader.Register 1.3, Shader.ResolveGraphicsStagesAbi 0.0
title 1.0 (0 %) 0.0 (0 %) 437.3 0.0 Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0
queue worker 0x0 312.2 (71 %) 112.1 (26 %) 14.0 7.2 Driver.Packet 388.0, Driver.EndSubmission 1.4
presenter 0.7 (0 %) 1.4 (0 %) 436.1 0.1 VideoOut.Flip 2.1, Driver.Present 0.1
draw committer 11.2 (3 %) 4.9 (1 %) 422.2 0.3 Graphics.Draw 9.9, Recorder.Submit 0.7
queue worker 0x20 21.7 (5 %) 403.4 (92 %) 13.1 1.7 Driver.Packet 373.1, Driver.EndSubmission 13.3
queue worker 0x28 5.1 (1 %) 420.8 (96 %) 12.3 0.9 Driver.Packet 375.9, Driver.EndSubmission 10.7
queue worker 0x48 0.1 (0 %) 425.3 (97 %) 12.9 0.0 Driver.Packet 374.8, Driver.EndSubmission 0.5
queue worker 0x38 18.4 (4 %) 405.9 (93 %) 13.9 0.2 Driver.Packet 371.6, Driver.EndSubmission 11.2
queue worker 0x50 3.3 (1 %) 420.3 (96 %) 14.6 0.4 Driver.Packet 380.9, Driver.EndSubmission 0.5
queue worker 0x30 72.2 (16 %) 351.6 (80 %) 14.5 0.2 Driver.Packet 383.8, Driver.EndSubmission 0.6
queue worker 0x40 26.9 (6 %) 396.9 (91 %) 14.5 0.7 Driver.Packet 384.9, Driver.EndSubmission 0.2
gpu 28.0 (6 %) 0.0 (0 %) 410.2 0.0 batch 28.0

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 3033.1, Driver.Packet.memory_wait 2496.9, Driver.Packet.dispatch 511.7, Driver.Dispatch 481.3, Driver.WorkerWait 324.5, Driver.WorkerWait.idle_and_completion_poll 324.4, Driver.Dispatch.materialize 129.6, Vulkan.Dispatch 115.1, Vulkan.Dispatch.shader_resources 110.4, Vulkan.ComputePipeline 72.4

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x28) 6145.2 ms at 436 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x48) 6090.2 ms at 436 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x50) 6043.7 ms at 636 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 5188.9 ms at 1230 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x30) 4165.4 ms at 2515 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 3963.4 ms at 2718 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 3734.5 ms at 2947 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 1496.1 ms at 1174 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 1411.3 ms at 1189 ms, present 1
  • GpuMutex.wait.dispatch (queue worker 0x0) 1080.8 ms at 1431 ms, present 1

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

  • batch 51: 53.0 ms at 2891 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 222.4, Driver.Packet.dispatch (queue worker 0x0) 222.4, Driver.Dispatch (queue worker 0x0) 222.3, Resources.Prepare (queue worker 0x0) 124.0
  • batch 752: 23.1 ms at 8027 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 115.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 115.0, Recorder.Sync (queue worker 0x0) 24.1, Driver.Packet (queue worker 0x0) 14.1
  • batch 3: 21.6 ms at 597 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 363.2, Driver.Packet.dispatch (queue worker 0x0) 363.1, Driver.Dispatch (queue worker 0x0) 361.5, Resources.Prepare (queue worker 0x0) 84.3
  • batch 797: 11.9 ms at 8175 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 518.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 518.1, Recorder.Sync (queue worker 0x0) 12.2, Driver.Packet (queue worker 0x0) 5.1
  • batch 37: 9.5 ms at 2516 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x30) 5466.4, Driver.Packet.memory_wait (queue worker 0x30) 4176.6, Driver.Packet.dispatch (queue worker 0x30) 1289.8, Driver.Dispatch (queue worker 0x30) 1277.7
</details>

#### `tools/trace_digest.py` — Warm Median Run (`main` `aps5-trace-522e32e3b618-38788.json.gz` vs PR `aps5-trace-dcb04d0aa14d-51020.json.gz`)
<details>
<summary><code>main</code> warm median digest (<code>aps5-trace-522e32e3b618-38788.json.gz</code>)</summary>

```text
**frames 0:20** from present 0: 20 presents, frame p50 75.5 / p90 800.9 / p99 4787.4 / max 4787.4 ms, GPU busy 21.8 ms per present
NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit 522e32e3b618, dropped: no

```json
{"commit":"522e32e3b618","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":6792.077},"presents":20,"frame_ms":{"p50":75.507,"p90":800.919,"p99":4787.418,"max":4787.418},"gpu_busy_ms_per_present":21.76,"worker_busy_pct":{"queue worker 0x0":87.834,"queue worker 0x20":87.181,"queue worker 0x28":86.025,"queue worker 0x30":85.792,"queue worker 0x38":85.242,"queue worker 0x40":86.157,"queue worker 0x48":83.123,"queue worker 0x50":85.022},"top_phases_ms_per_frame":{"Driver.Packet":2293.844,"Driver.Packet.memory_wait":1870.829,"Driver.Packet.dispatch":408.587,"Driver.Dispatch":373.319,"Driver.Dispatch.materialize":124.379,"Vulkan.Dispatch":120.819,"Vulkan.Dispatch.shader_resources":116.63,"Shader.PrepareArtifact":100.823},"trace_dropped":false,"trace":"aps5-trace-522e32e3b618-38788.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1: 4787.4 ms at 9 ms: Driver.Packet (queue worker 0x0) 4658.2, Driver.Packet (queue worker 0x40) 4658.0, Driver.Packet (queue worker 0x50) 4655.5, Driver.Packet (queue worker 0x30) 4645.6
  • present 18: 800.9 ms at 5956 ms: Shader.PrepareArtifact (shader prepare) 912.3, Driver.WorkerWait (queue worker 0x48) 448.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 448.8, Driver.WorkerWait (queue worker 0x28) 448.8
  • present 14: 134.0 ms at 5583 ms: Shader.PrepareArtifact (shader prepare) 123.1, Driver.WorkerWait (queue worker 0x50) 113.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 113.8, Driver.WorkerWait (queue worker 0x30) 108.3
  • present 17: 112.0 ms at 5844 ms: Driver.WorkerWait (queue worker 0x50) 90.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 90.3, Driver.WorkerWait (queue worker 0x48) 88.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 88.1
  • present 12: 96.0 ms at 5430 ms: Shader.PrepareArtifact (shader prepare) 368.5, Driver.Packet (queue worker 0x40) 75.5, Driver.Packet (queue worker 0x0) 73.9, Driver.Packet (queue worker 0x38) 70.7

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
shader prepare 15.4 (5 %) 0.0 (0 %) 324.2 0.0 Shader.PrepareArtifact 15.4
shader prepare 10.4 (3 %) 0.0 (0 %) 329.2 0.0 Shader.PrepareArtifact 10.4
shader prepare 12.6 (4 %) 0.0 (0 %) 327.0 0.0 Shader.PrepareArtifact 12.6
shader prepare 10.8 (3 %) 0.0 (0 %) 328.8 0.0 Shader.PrepareArtifact 10.8
shader prepare 12.0 (4 %) 0.0 (0 %) 327.6 0.0 Shader.PrepareArtifact 12.0
shader prepare 12.7 (4 %) 0.0 (0 %) 326.9 0.0 Shader.PrepareArtifact 12.7
shader prepare 15.7 (5 %) 0.0 (0 %) 323.9 0.0 Shader.PrepareArtifact 15.7
title 1.3 (0 %) 0.0 (0 %) 338.3 0.0 Shader.Register 1.3, Shader.ResolveGraphicsStagesAbi 0.0
shader prepare 11.0 (3 %) 0.0 (0 %) 328.6 0.0 Shader.PrepareArtifact 11.0
shader prepare 0.5 (0 %) 0.0 (0 %) 339.1 0.0 Vulkan.GraphicsPipelinePrebuild 0.5
title 1.8 (1 %) 0.0 (0 %) 337.8 0.0 Shader.ResolveAbi 0.9, Shader.Register 0.9
title 1.2 (0 %) 0.0 (0 %) 338.4 0.0 Shader.Register 1.2, Shader.ResolveGraphicsStagesAbi 0.0
title 1.2 (0 %) 0.0 (0 %) 338.4 0.0 Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.1
title 1.6 (0 %) 0.0 (0 %) 338.0 0.0 Shader.Register 1.6, Shader.ResolveAbi 0.0
title 1.7 (1 %) 0.0 (0 %) 337.9 0.0 Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0
title 2.3 (1 %) 0.0 (0 %) 337.3 0.0 Shader.Register 2.3, Shader.ResolveGraphicsStagesAbi 0.0
title 0.8 (0 %) 0.0 (0 %) 338.8 0.0 Shader.Register 0.7, Shader.ResolveGraphicsStagesAbi 0.1
title 1.4 (0 %) 0.0 (0 %) 338.2 0.0 Shader.Register 0.8, Shader.ResolveAbi 0.6
queue worker 0x0 266.7 (79 %) 64.2 (19 %) 8.7 7.2 Driver.Packet 295.4, Driver.EndSubmission 1.1
presenter 0.6 (0 %) 1.5 (0 %) 337.5 0.1 VideoOut.Flip 2.0, Driver.Present 0.1
draw committer 8.9 (3 %) 15.5 (5 %) 315.2 0.3 Graphics.Draw 7.8, Recorder.Sync 0.7
queue worker 0x20 14.5 (4 %) 317.4 (93 %) 7.8 1.7 Driver.Packet 288.5, Driver.EndSubmission 7.2
queue worker 0x28 7.3 (2 %) 325.1 (96 %) 7.1 0.9 Driver.Packet 281.3, Driver.EndSubmission 10.7
queue worker 0x30 74.5 (22 %) 256.8 (76 %) 8.3 0.2 Driver.Packet 289.9, Driver.EndSubmission 1.5
queue worker 0x38 3.9 (1 %) 327.5 (96 %) 8.1 0.2 Driver.Packet 275.7, Driver.EndSubmission 13.7
queue worker 0x40 22.8 (7 %) 308.5 (91 %) 8.3 0.6 Driver.Packet 292.3, Driver.EndSubmission 0.1
queue worker 0x48 0.1 (0 %) 332.2 (98 %) 7.4 0.0 Driver.Packet 280.8, Driver.EndSubmission 1.5
queue worker 0x50 2.3 (1 %) 328.6 (97 %) 8.7 0.4 Driver.Packet 287.5, Driver.EndSubmission 1.1
gpu 24.5 (7 %) 0.0 (0 %) 315.1 0.0 batch 24.5

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 2291.3, Driver.Packet.memory_wait 1870.7, Driver.Packet.dispatch 408.0, Driver.Dispatch 372.3, Driver.WorkerWait 324.1, Driver.WorkerWait.idle_and_completion_poll 324.0, Driver.Dispatch.materialize 123.4, Vulkan.Dispatch 120.0, Vulkan.Dispatch.shader_resources 116.2, Shader.PrepareArtifact 100.8

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x28) 4360.4 ms at 368 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x48) 4333.5 ms at 368 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x50) 4329.3 ms at 469 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 3645.7 ms at 1008 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x30) 2446.2 ms at 2351 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 2345.2 ms at 2453 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 2136.3 ms at 2662 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 1744.4 ms at 690 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 1605.8 ms at 788 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 626.2 ms at 368 ms, present 1

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

  • batch 53: 55.3 ms at 2602 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 83.5, Driver.Packet.dispatch (queue worker 0x40) 83.5, Driver.Dispatch (queue worker 0x40) 1.7, Vulkan.Dispatch (queue worker 0x40) 0.9
  • batch 569: 19.1 ms at 5663 ms, present 14: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 99.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 99.6, Recorder.Sync (queue worker 0x0) 19.4, Driver.Packet (queue worker 0x0) 0.7
  • batch 2: 16.2 ms at 351 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 215.9, Driver.Packet.dispatch (queue worker 0x0) 215.9, Driver.Dispatch (queue worker 0x0) 215.9, Vulkan.Dispatch (queue worker 0x0) 72.9
  • batch 681: 13.1 ms at 5912 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 80.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 80.5, Recorder.Sync (queue worker 0x0) 13.3, Driver.Packet (queue worker 0x0) 8.5
  • batch 731: 12.8 ms at 6710 ms, present 18: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 168.6, Driver.Packet.dispatch (queue worker 0x0) 155.4, Driver.Dispatch (queue worker 0x0) 152.8, Driver.Dispatch.materialize (queue worker 0x0) 60.6
</details>

<details>
<summary><code>perf/agc-compute-prewarm</code> warm median digest (<code>aps5-trace-dcb04d0aa14d-51020.json.gz</code>)</summary>

```text
**frames 0:20** from present 0: 20 presents, frame p50 71.5 / p90 503.6 / p99 4767.3 / max 4767.3 ms, GPU busy 28.8 ms per present
NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit dcb04d0aa14d, dropped: no

```json
{"commit":"dcb04d0aa14d","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":6639.422},"presents":20,"frame_ms":{"p50":71.507,"p90":503.585,"p99":4767.308,"max":4767.308},"gpu_busy_ms_per_present":28.805,"worker_busy_pct":{"queue worker 0x0":87.185,"queue worker 0x28":82.827,"queue worker 0x20":84.464,"queue worker 0x48":82.124,"queue worker 0x50":84.022,"queue worker 0x30":84.471,"queue worker 0x38":83.511,"queue worker 0x40":84.839},"top_phases_ms_per_frame":{"Driver.Packet":2218.187,"Driver.Packet.memory_wait":1763.587,"Driver.Packet.dispatch":425.453,"Driver.Dispatch":391.083,"Vulkan.Dispatch":118.037,"Vulkan.Dispatch.shader_resources":113.503,"Driver.Dispatch.materialize":109.963,"Resources.Prepare":83.46},"trace_dropped":false,"trace":"aps5-trace-dcb04d0aa14d-51020.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1: 4767.3 ms at 12 ms: Driver.Packet (queue worker 0x0) 4597.8, Driver.Packet (queue worker 0x50) 4595.8, Driver.Packet (queue worker 0x30) 4594.0, Driver.Packet (queue worker 0x40) 4592.2
  • present 18: 503.6 ms at 6046 ms: Driver.WorkerWait (queue worker 0x50) 496.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 496.1, Driver.WorkerWait (queue worker 0x30) 488.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 488.1
  • present 11: 173.5 ms at 5412 ms: Shader.PrepareArtifact (shader prepare) 570.6, Driver.Packet (queue worker 0x30) 173.4, Driver.Packet (queue worker 0x50) 173.3, Driver.Packet (queue worker 0x40) 173.1
  • present 17: 148.0 ms at 5898 ms: Driver.WorkerWait (queue worker 0x50) 135.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 135.3, Driver.WorkerWait (queue worker 0x30) 133.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 133.4
  • present 2: 106.8 ms at 4780 ms: Driver.Packet (queue worker 0x50) 106.5, Driver.Packet (queue worker 0x30) 106.3, Driver.Packet (queue worker 0x40) 105.1, Driver.Packet (queue worker 0x20) 104.3

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
shader prepare 6.4 (2 %) 0.0 (0 %) 325.6 0.0 Shader.PrepareArtifact 6.4
shader prepare 7.0 (2 %) 0.0 (0 %) 325.0 0.0 Shader.PrepareArtifact 7.0
shader prepare 7.2 (2 %) 0.0 (0 %) 324.8 0.0 Shader.PrepareArtifact 7.2
shader prepare 6.7 (2 %) 0.0 (0 %) 325.3 0.0 Shader.PrepareArtifact 6.7
shader prepare 6.9 (2 %) 0.0 (0 %) 325.0 0.0 Shader.PrepareArtifact 6.9
shader prepare 7.6 (2 %) 0.0 (0 %) 324.4 0.0 Shader.PrepareArtifact 7.6
shader prepare 6.8 (2 %) 0.0 (0 %) 325.2 0.0 Shader.PrepareArtifact 6.8
title 1.0 (0 %) 0.0 (0 %) 330.9 0.0 Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0
shader prepare 7.2 (2 %) 0.0 (0 %) 324.8 0.0 Shader.PrepareArtifact 7.2
shader prepare 0.5 (0 %) 0.0 (0 %) 331.5 0.0 Vulkan.GraphicsPipelinePrebuild 0.5
title 0.0 (0 %) 0.0 (0 %) 332.0 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.4 (0 %) 0.0 (0 %) 331.6 0.0 Shader.Register 0.4, Shader.ResolveGraphicsStagesAbi 0.0
title 0.7 (0 %) 0.0 (0 %) 331.3 0.0 Shader.Register 0.6, Shader.ResolveGraphicsStagesAbi 0.1
title 1.5 (0 %) 0.0 (0 %) 330.5 0.0 Shader.ResolveAbi 0.8, Shader.Register 0.6
title 0.7 (0 %) 0.0 (0 %) 331.2 0.0 Shader.Register 0.7, Shader.ResolveGraphicsStagesAbi 0.0
title 1.7 (1 %) 0.0 (0 %) 330.3 0.0 Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0
title 2.0 (1 %) 0.0 (0 %) 330.0 0.0 Shader.Register 1.0, Shader.ResolveAbi 1.0
queue worker 0x0 251.1 (76 %) 70.0 (21 %) 10.9 7.3 Driver.Packet 286.3, Driver.EndSubmission 1.5
presenter 0.6 (0 %) 3.1 (1 %) 328.3 0.1 VideoOut.Flip 3.6, Driver.Present 0.1
draw committer 9.7 (3 %) 3.7 (1 %) 318.6 0.3 Graphics.Draw 8.8, Recorder.Submit 0.5
queue worker 0x28 5.1 (2 %) 317.5 (96 %) 9.3 0.9 Driver.Packet 273.5, Driver.EndSubmission 1.3
queue worker 0x20 18.0 (5 %) 303.9 (92 %) 10.1 1.8 Driver.Packet 277.2, Driver.EndSubmission 2.7
queue worker 0x48 0.3 (0 %) 322.3 (97 %) 9.4 0.0 Driver.Packet 271.9, Driver.EndSubmission 0.7
queue worker 0x50 2.3 (1 %) 318.9 (96 %) 10.8 0.4 Driver.Packet 278.2, Driver.EndSubmission 0.6
queue worker 0x30 74.0 (22 %) 247.2 (74 %) 10.8 0.2 Driver.Packet 280.1, Driver.EndSubmission 0.3
queue worker 0x38 10.0 (3 %) 311.4 (94 %) 10.6 0.2 Driver.Packet 267.1, Driver.EndSubmission 10.1
queue worker 0x40 23.8 (7 %) 297.3 (90 %) 10.9 0.6 Driver.Packet 281.3, Driver.EndSubmission 0.2
title 0.6 (0 %) 0.0 (0 %) 331.3 0.0 Shader.Register 0.6, Shader.ResolveGraphicsStagesAbi 0.0
gpu 31.3 (9 %) 0.0 (0 %) 300.7 0.0 batch 31.3

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 2215.5, Driver.Packet.memory_wait 1763.5, Driver.Packet.dispatch 424.7, Driver.Dispatch 390.0, Driver.WorkerWait 340.0, Driver.WorkerWait.idle_and_completion_poll 340.0, Vulkan.Dispatch 117.3, Vulkan.Dispatch.shader_resources 113.0, Driver.Dispatch.materialize 109.0, Resources.Prepare 83.3

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x28) 4297.5 ms at 405 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x50) 4235.3 ms at 545 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x48) 4129.6 ms at 544 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 3613.7 ms at 1014 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x30) 2440.4 ms at 2340 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 2330.5 ms at 2451 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 2118.8 ms at 2663 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x38) 1440.6 ms at 984 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x40) 1392.6 ms at 996 ms, present 1
  • Driver.Packet.memory_wait (queue worker 0x20) 594.6 ms at 405 ms, present 1

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

  • batch 53: 64.3 ms at 2596 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 85.5, Driver.Packet.dispatch (queue worker 0x40) 85.5, Driver.Dispatch (queue worker 0x40) 1.7, Vulkan.Dispatch (queue worker 0x40) 1.0
  • batch 714: 24.6 ms at 5980 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 107.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.0, Recorder.Sync (queue worker 0x0) 25.2, Driver.Packet (queue worker 0x0) 11.4
  • batch 2: 19.2 ms at 381 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 176.0, Driver.Packet.dispatch (queue worker 0x0) 176.0, Driver.Dispatch (queue worker 0x0) 176.0, Vulkan.Dispatch (queue worker 0x0) 53.8
  • batch 749: 11.9 ms at 6119 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 460.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 460.5, Recorder.Sync (queue worker 0x0) 12.7, Driver.Packet (queue worker 0x0) 10.3
  • batch 81: 8.1 ms at 4731 ms, present 1: GPU no ranges; recorded by Driver.Dispatch.materialize (queue worker 0x0) 20.8, Driver.Packet (queue worker 0x0) 9.7, Driver.Packet.dispatch (queue worker 0x0) 9.7, Driver.Dispatch (queue worker 0x0) 9.7
</details>

### 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: none
- [x] GPUs tested: AMD Radeon RX 9070 XT, driver 26.3.1 (Vulkan 1.4.341), Windows 11
- [x] AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4943532327 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-20T22:45:26Z. --- ### What - Extend `ShaderManager::QueuePrebuild` and `PrebuildEntry` with a `compute` flag so compute shaders queued by `GetPreparedShaders(..., /*compute=*/true)` pre-create both the `vk::ShaderModule` and the compute `vk::Pipeline` on the background shader prepare thread (`GetOrCreateComputePipeline`), avoiding synchronous pipeline compilation stalls during `Driver::dispatch`. - Pre-warm compute shaders ahead of execution inside `Driver::resolveGroupAhead` by scanning the upcoming packet segment up to the next wait/sync boundary (`PreviewedUntil()`) when the segment contains at least one subsequent dispatch (`hasFurtherDispatch`), tracking `SetShReg` / `SetContextReg` updates on a lightweight preview state and calling `RegisteredProgram` (`GetPreparedShaders(..., true)`) for upcoming dispatches (`scan > from`) before the preceding dispatches finish executing. Single-dispatch segments (`!hasFurtherDispatch`) skip the preview pass with zero state copies or lookups. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> - Windows 11, AMD Radeon RX 9070 XT (RADV / AMD proprietary Vulkan driver 26.3.1, Vulkan 1.4.341): - `ctest --test-dir build-portable -R "^(agc_driver_prepared_shaders_compute_prebuild|agc_driver_prepared_shaders_dispatch_ahead_prewarm|agc_driver_compute_basic_dispatch|agc_driver_compute_multi_dispatch)$" -V` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` on both `main` (`522e32e3b618`) and this branch (`dcb04d0aa14d`) — all 4 tests pass with 0 `VUID-` validation errors. - **Demon's Souls (`PPSA01341` v1.07)**, Windows 11, same machine and boot/intro scene (`APS5_TRACE_FRAMES=0:20`, default flags, 3 cold-pipeline-cache runs + 3 warm-cache runs per branch). All 12 `.json.gz` traces are attached below. #### Attached Traces (12 runs: 3 Cold + 3 Warm per branch) - **`main` (`522e32e3b618`) Cold 1..3:** - [aps5-trace-522e32e3b618-39024.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-39024.json.gz) (`window.ms=7911.797`, `p50=71.790`, `p90=899.812`, `max=5652.293`, `Driver.Packet=2711.103`, `Packet.dispatch=471.154`, `Driver.Dispatch=438.601`, `materialize=121.787`) - [aps5-trace-522e32e3b618-28612.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-28612.json.gz) (`window.ms=8543.938`, `p50=69.237`, `p90=893.505`, `max=5998.794`, `Driver.Packet=2855.925`, `Packet.dispatch=562.523`, `Driver.Dispatch=473.093`, `materialize=127.010`) - [aps5-trace-522e32e3b618-20240.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-20240.json.gz) (`window.ms=8480.218`, `p50=85.598`, `p90=1030.123`, `max=6032.006`, `Driver.Packet=2950.152`, `Packet.dispatch=497.480`, `Driver.Dispatch=460.815`, `materialize=127.731`) - **`perf/agc-compute-prewarm` (`dcb04d0aa14d`) Cold 1..3:** - [aps5-trace-dcb04d0aa14d-31308.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-31308.json.gz) (`window.ms=8765.408`, `p50=85.279`, `p90=568.491`, `max=6661.114`, `Driver.Packet=3035.776`, `Packet.dispatch=512.372`, `Driver.Dispatch=482.331`, `materialize=130.607`) - [aps5-trace-dcb04d0aa14d-47372.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-47372.json.gz) (`window.ms=8992.743`, `p50=85.367`, `p90=584.385`, `max=6463.900`, `Driver.Packet=3064.032`, `Packet.dispatch=549.805`, `Driver.Dispatch=515.185`, `materialize=128.516`) - [aps5-trace-dcb04d0aa14d-23608.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-23608.json.gz) (`window.ms=8145.822`, `p50=81.976`, `p90=163.222`, `max=6580.297`, `Driver.Packet=3031.801`, `Packet.dispatch=543.130`, `Driver.Dispatch=452.018`, `materialize=127.940`) - **`main` (`522e32e3b618`) Warm 1..3:** - [aps5-trace-522e32e3b618-28224.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-28224.json.gz) (`window.ms=6870.411`, `p50=78.791`, `p90=799.413`, `max=4727.829`, `Driver.Packet=2287.577`, `Packet.dispatch=416.237`, `Driver.Dispatch=383.796`, `materialize=124.635`) - [aps5-trace-522e32e3b618-38788.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-38788.json.gz) (`window.ms=6792.077`, `p50=75.507`, `p90=800.919`, `max=4787.418`, `Driver.Packet=2293.844`, `Packet.dispatch=408.587`, `Driver.Dispatch=373.319`, `materialize=124.379`) - [aps5-trace-522e32e3b618-32828.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-522e32e3b618-32828.json.gz) (`window.ms=6612.875`, `p50=70.261`, `p90=755.799`, `max=4599.907`, `Driver.Packet=2234.188`, `Packet.dispatch=424.879`, `Driver.Dispatch=388.964`, `materialize=120.988`) - **`perf/agc-compute-prewarm` (`dcb04d0aa14d`) Warm 1..3:** - [aps5-trace-dcb04d0aa14d-33228.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-33228.json.gz) (`window.ms=6863.060`, `p50=68.699`, `p90=447.956`, `max=4802.256`, `Driver.Packet=2303.209`, `Packet.dispatch=484.234`, `Driver.Dispatch=439.233`, `materialize=120.444`) - [aps5-trace-dcb04d0aa14d-39356.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-39356.json.gz) (`window.ms=6862.217`, `p50=85.842`, `p90=778.916`, `max=4746.500`, `Driver.Packet=2333.684`, `Packet.dispatch=420.290`, `Driver.Dispatch=388.508`, `materialize=122.702`) - [aps5-trace-dcb04d0aa14d-51020.json.gz](https://github.com/hamb3r/AnyPS5/releases/download/pr-8735-traces/aps5-trace-dcb04d0aa14d-51020.json.gz) (`window.ms=6639.422`, `p50=71.507`, `p90=503.585`, `max=4767.308`, `Driver.Packet=2218.187`, `Packet.dispatch=425.453`, `Driver.Dispatch=391.083`, `materialize=109.963`) #### 3-Run Median Comparison (`APS5_TRACE_FRAMES=0:20`, default flags) | Metric | `main` Cold Median | PR Cold Median | Cold Delta | `main` Warm Median | PR Warm Median | Warm Delta | |---|---:|---:|---:|---:|---:|---:| | `window.ms` | `8480.218` | `8765.408` | `+3.4%` | `6792.077` | `6862.217` | `+1.0%` | | `frame_ms.p50` | `71.790` | `85.279` | `+18.8%` | `75.507` | `71.507` | **`-5.3%`** | | `frame_ms.p90` | `899.812` | `568.491` | **`-36.8%`** | `799.413` | `503.585` | **`-37.0%`** | | `frame_ms.max` | `5998.794` | `6580.297` | `+9.7%` | `4727.829` | `4767.308` | `+0.8%` | | `Driver.Packet` (ms/f) | `2855.925` | `3035.776` | `+6.3%` | `2287.577` | `2303.209` | `+0.7%` | | `Driver.Packet.dispatch` (ms/f) | `497.480` | `543.130` | `+9.2%` | `416.237` | `425.453` | `+2.2%` | | `Driver.Dispatch` (ms/f) | `460.815` | `482.331` | `+4.7%` | `383.796` | `391.083` | `+1.9%` | | `Driver.Dispatch.materialize` (ms/f) | `127.010` | `128.516` | `+1.2%` | `124.379` | `120.444` | **`-3.2%`** | | Async queues (`0x20..0x50`) sync `Vulkan.ComputePipeline` count | `30` | `1` | **`-96.7%`** | `0` | `0` | `0` | | `shader prepare` prebuilt `Vulkan.ComputePipeline` count | `0` | `29` | **`+29`** | `0` | `0` | `0` | #### `tools/trace_digest.py` — Cold Median Run (`main` `aps5-trace-522e32e3b618-20240.json.gz` vs PR `aps5-trace-dcb04d0aa14d-31308.json.gz`) <details> <summary><code>main</code> cold median digest (<code>aps5-trace-522e32e3b618-20240.json.gz</code>)</summary> ```text **frames 0:20** from present 0: 20 presents, frame p50 85.6 / p90 1030.1 / p99 6032.0 / max 6032.0 ms, GPU busy 28.3 ms per present NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit 522e32e3b618, dropped: no ```json {"commit":"522e32e3b618","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":8480.218},"presents":20,"frame_ms":{"p50":85.598,"p90":1030.123,"p99":6032.006,"max":6032.006},"gpu_busy_ms_per_present":28.306,"worker_busy_pct":{"queue worker 0x0":89.458,"queue worker 0x20":88.677,"queue worker 0x40":88.027,"queue worker 0x48":86.028,"queue worker 0x50":86.994,"queue worker 0x30":87.706,"queue worker 0x38":87.5,"queue worker 0x28":89.169},"top_phases_ms_per_frame":{"Driver.Packet":2950.152,"Driver.Packet.memory_wait":2432.478,"Driver.Packet.dispatch":497.48,"Driver.Dispatch":460.815,"Driver.Dispatch.materialize":127.731,"Vulkan.Dispatch":117.839,"Vulkan.Dispatch.shader_resources":113.335,"Shader.PrepareArtifact":96.432},"trace_dropped":false,"trace":"aps5-trace-522e32e3b618-20240.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1: 6032.0 ms at 22 ms: Driver.Packet (queue worker 0x0) 5864.8, Driver.Packet (queue worker 0x40) 5862.8, Driver.Packet (queue worker 0x50) 5860.5, Driver.Packet.memory_wait (queue worker 0x50) 5850.3 - present 18: 1030.1 ms at 7406 ms: Shader.PrepareArtifact (shader prepare) 804.6, Driver.Packet (queue worker 0x30) 540.6, Driver.Packet (queue worker 0x40) 540.4, Driver.Packet (queue worker 0x50) 540.4 - present 17: 149.5 ms at 7257 ms: Driver.WorkerWait (queue worker 0x48) 118.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 118.2, Driver.WorkerWait (queue worker 0x0) 108.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 108.8 - present 15: 127.1 ms at 7088 ms: Driver.Packet (queue worker 0x0) 73.0, Driver.Packet (queue worker 0x48) 72.9, Driver.Packet.memory_wait (queue worker 0x48) 72.9, Driver.Packet (queue worker 0x28) 72.6 - present 2: 114.5 ms at 6054 ms: Driver.Packet (queue worker 0x40) 114.2, Driver.Packet (queue worker 0x50) 114.1, Driver.Packet (queue worker 0x30) 114.0, Driver.Packet (queue worker 0x20) 113.9 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | shader prepare | 10.6 (2 %) | 0.0 (0 %) | 413.5 | 0.0 | Shader.PrepareArtifact 10.6 | | shader prepare | 15.5 (4 %) | 0.0 (0 %) | 408.5 | 0.0 | Shader.PrepareArtifact 15.5 | | shader prepare | 10.5 (2 %) | 0.0 (0 %) | 413.5 | 0.0 | Shader.PrepareArtifact 10.5 | | shader prepare | 12.4 (3 %) | 0.0 (0 %) | 411.6 | 0.0 | Shader.PrepareArtifact 12.4 | | shader prepare | 11.2 (3 %) | 0.0 (0 %) | 412.8 | 0.0 | Shader.PrepareArtifact 11.2 | | shader prepare | 10.7 (3 %) | 0.0 (0 %) | 413.3 | 0.0 | Shader.PrepareArtifact 10.7 | | title | 0.9 (0 %) | 0.0 (0 %) | 423.2 | 0.0 | Shader.Register 0.9, Shader.ResolveGraphicsStagesAbi 0.0 | | shader prepare | 4.2 (1 %) | 0.0 (0 %) | 419.8 | 0.0 | Vulkan.GraphicsPipelinePrebuild 4.2 | | shader prepare | 12.9 (3 %) | 0.0 (0 %) | 411.1 | 0.0 | Shader.PrepareArtifact 12.9 | | shader prepare | 12.4 (3 %) | 0.0 (0 %) | 411.6 | 0.0 | Shader.PrepareArtifact 12.4 | | title | 1.6 (0 %) | 0.0 (0 %) | 422.4 | 0.0 | Shader.ResolveAbi 1.0, Shader.Register 0.5 | | title | 2.0 (0 %) | 0.0 (0 %) | 422.1 | 0.0 | Shader.Register 1.8, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 1.7 (0 %) | 0.0 (0 %) | 422.3 | 0.0 | Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 2.2 (1 %) | 0.0 (0 %) | 421.8 | 0.0 | Shader.Register 1.5, Shader.ResolveAbi 0.7 | | title | 0.3 (0 %) | 0.0 (0 %) | 423.7 | 0.0 | Shader.Register 0.3, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.9 (0 %) | 0.0 (0 %) | 422.1 | 0.0 | Shader.Register 1.9, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.7 (0 %) | 0.0 (0 %) | 422.3 | 0.0 | Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.8 (0 %) | 0.0 (0 %) | 423.2 | 0.0 | Shader.Register 0.8, Shader.ResolveGraphicsStagesAbi 0.0 | | queue worker 0x0 | 293.8 (69 %) | 118.9 (28 %) | 11.4 | 7.2 | Driver.Packet 376.3, Driver.EndSubmission 1.3 | | presenter | 0.8 (0 %) | 2.7 (1 %) | 420.5 | 0.1 | VideoOut.Flip 3.5, Driver.Present 0.1 | | draw committer | 12.1 (3 %) | 9.7 (2 %) | 402.3 | 0.3 | Graphics.Draw 10.5, Recorder.Sync 1.0 | | queue worker 0x20 | 23.8 (6 %) | 389.7 (92 %) | 10.5 | 1.8 | Driver.Packet 372.4, Driver.EndSubmission 3.1 | | queue worker 0x40 | 28.5 (7 %) | 384.3 (91 %) | 11.2 | 0.6 | Driver.Packet 372.9, Driver.EndSubmission 0.2 | | queue worker 0x48 | 0.2 (0 %) | 413.7 (98 %) | 10.2 | 0.0 | Driver.Packet 364.4, Driver.EndSubmission 0.4 | | queue worker 0x50 | 3.4 (1 %) | 408.8 (96 %) | 11.8 | 0.4 | Driver.Packet 368.5, Driver.EndSubmission 0.2 | | queue worker 0x30 | 62.9 (15 %) | 349.6 (82 %) | 11.5 | 0.2 | Driver.Packet 370.1, Driver.EndSubmission 1.7 | | queue worker 0x38 | 8.6 (2 %) | 404.1 (95 %) | 11.4 | 0.2 | Driver.Packet 359.1, Driver.EndSubmission 11.9 | | queue worker 0x28 | 6.8 (2 %) | 406.9 (96 %) | 10.2 | 0.9 | Driver.Packet 363.8, Driver.EndSubmission 14.1 | | gpu | 32.7 (8 %) | 0.0 (0 %) | 391.3 | 0.0 | batch 32.7 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 2947.5, Driver.Packet.memory_wait 2432.4, Driver.Packet.dispatch 496.8, Driver.Dispatch 459.8, Driver.WorkerWait 323.4, Driver.WorkerWait.idle_and_completion_poll 323.3, Driver.Dispatch.materialize 126.7, Vulkan.Dispatch 117.1, Vulkan.Dispatch.shader_resources 112.9, Shader.PrepareArtifact 96.4 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x28) 5581.5 ms at 386 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x48) 5556.9 ms at 368 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x50) 5510.9 ms at 544 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 4456.9 ms at 1379 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x30) 3624.4 ms at 2431 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 3459.6 ms at 2596 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 3258.9 ms at 2796 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 1505.6 ms at 1050 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 1117.0 ms at 1370 ms, present 1 - GpuMutex.wait.dispatch (queue worker 0x0) 1030.5 ms at 1394 ms, present 1 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 52: 49.4 ms at 2741 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 195.2, Driver.Packet.dispatch (queue worker 0x0) 195.2, Driver.Dispatch (queue worker 0x0) 195.1, GpuMutex.wait.dispatch (queue worker 0x0) 171.6 - batch 730: 25.3 ms at 7340 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 108.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 108.8, Recorder.Sync (queue worker 0x0) 26.0, Driver.Packet (queue worker 0x0) 9.2 - batch 781: 23.7 ms at 8373 ms, present 18: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 253.4, Driver.Packet.dispatch (queue worker 0x0) 253.4, Driver.Dispatch (queue worker 0x0) 252.9, Driver.Dispatch.materialize (queue worker 0x0) 64.5 - batch 4: 16.5 ms at 428 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x50) 348.7, Driver.Packet.memory_wait (queue worker 0x50) 340.4, Driver.Packet.dispatch (queue worker 0x50) 8.1, Driver.Dispatch (queue worker 0x50) 3.9 - batch 766: 16.0 ms at 7476 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 488.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 488.4, Recorder.Sync (queue worker 0x0) 16.3, Driver.Dispatch.materialize (queue worker 0x0) 12.4 ``` </details> <details> <summary><code>perf/agc-compute-prewarm</code> cold median digest (<code>aps5-trace-dcb04d0aa14d-31308.json.gz</code>)</summary> ```text **frames 0:20** from present 0: 20 presents, frame p50 85.3 / p90 568.5 / p99 6661.1 / max 6661.1 ms, GPU busy 26.0 ms per present NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit dcb04d0aa14d, dropped: no ```json {"commit":"dcb04d0aa14d","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":8765.408},"presents":20,"frame_ms":{"p50":85.279,"p90":568.491,"p99":6661.114,"max":6661.114},"gpu_busy_ms_per_present":25.971,"worker_busy_pct":{"queue worker 0x0":89.256,"queue worker 0x20":88.273,"queue worker 0x28":88.257,"queue worker 0x48":85.635,"queue worker 0x38":87.377,"queue worker 0x50":87.054,"queue worker 0x30":87.728,"queue worker 0x40":87.921},"top_phases_ms_per_frame":{"Driver.Packet":3035.776,"Driver.Packet.memory_wait":2496.965,"Driver.Packet.dispatch":512.372,"Driver.Dispatch":482.331,"Driver.Dispatch.materialize":130.607,"Vulkan.Dispatch":115.845,"Vulkan.Dispatch.shader_resources":110.871,"Vulkan.ComputePipeline":72.394},"trace_dropped":false,"trace":"aps5-trace-dcb04d0aa14d-31308.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1: 6661.1 ms at 21 ms: Driver.Packet (queue worker 0x0) 6441.2, Driver.Packet (queue worker 0x50) 6432.0, Driver.Packet (queue worker 0x30) 6428.1, Driver.Packet (queue worker 0x40) 6427.6 - present 18: 568.5 ms at 8100 ms: Driver.WorkerWait (queue worker 0x50) 560.2, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 560.2, Driver.WorkerWait (queue worker 0x30) 553.7, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 553.7 - present 17: 164.6 ms at 7936 ms: Driver.WorkerWait (queue worker 0x50) 154.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 154.7, Driver.WorkerWait (queue worker 0x30) 143.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 143.0 - present 11: 154.5 ms at 7439 ms: Shader.PrepareArtifact (shader prepare) 450.8, Driver.Packet (queue worker 0x40) 154.2, Driver.Packet (queue worker 0x30) 153.9, Driver.Packet (queue worker 0x50) 153.7 - present 2: 132.2 ms at 6682 ms: Driver.Packet (queue worker 0x50) 132.0, Driver.Packet (queue worker 0x30) 132.0, Driver.Packet (queue worker 0x20) 131.4, Driver.Packet.memory_wait (queue worker 0x50) 131.1 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | shader prepare | 7.8 (2 %) | 0.0 (0 %) | 430.5 | 0.0 | Shader.PrepareArtifact 7.8 | | shader prepare | 6.9 (2 %) | 0.0 (0 %) | 431.3 | 0.0 | Shader.PrepareArtifact 6.9 | | shader prepare | 7.7 (2 %) | 0.0 (0 %) | 430.5 | 0.0 | Shader.PrepareArtifact 7.7 | | shader prepare | 7.5 (2 %) | 0.0 (0 %) | 430.8 | 0.0 | Shader.PrepareArtifact 7.5 | | shader prepare | 7.5 (2 %) | 0.0 (0 %) | 430.7 | 0.0 | Shader.PrepareArtifact 7.5 | | shader prepare | 7.3 (2 %) | 0.0 (0 %) | 430.9 | 0.0 | Shader.PrepareArtifact 7.3 | | shader prepare | 8.0 (2 %) | 0.0 (0 %) | 430.3 | 0.0 | Shader.PrepareArtifact 8.0 | | title | 1.0 (0 %) | 0.0 (0 %) | 437.2 | 0.0 | Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0 | | shader prepare | 7.2 (2 %) | 0.0 (0 %) | 431.1 | 0.0 | Shader.PrepareArtifact 7.2 | | shader prepare | 14.8 (3 %) | 0.0 (0 %) | 423.5 | 0.0 | Vulkan.ComputePipeline 10.5, Vulkan.GraphicsPipelinePrebuild 4.2 | | title | 1.1 (0 %) | 0.0 (0 %) | 437.2 | 0.0 | Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 438.2 | 0.0 | Shader.Register 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.6 (0 %) | 0.0 (0 %) | 436.7 | 0.0 | Shader.Register 0.9, Shader.ResolveAbi 0.7 | | title | 1.1 (0 %) | 0.0 (0 %) | 437.1 | 0.0 | Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 2.2 (1 %) | 0.0 (0 %) | 436.0 | 0.0 | Shader.Register 1.2, Shader.ResolveAbi 1.1 | | title | 0.9 (0 %) | 0.0 (0 %) | 437.4 | 0.0 | Shader.Register 0.8, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.3 (0 %) | 0.0 (0 %) | 437.0 | 0.0 | Shader.Register 1.3, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.0 (0 %) | 0.0 (0 %) | 437.3 | 0.0 | Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0 | | queue worker 0x0 | 312.2 (71 %) | 112.1 (26 %) | 14.0 | 7.2 | Driver.Packet 388.0, Driver.EndSubmission 1.4 | | presenter | 0.7 (0 %) | 1.4 (0 %) | 436.1 | 0.1 | VideoOut.Flip 2.1, Driver.Present 0.1 | | draw committer | 11.2 (3 %) | 4.9 (1 %) | 422.2 | 0.3 | Graphics.Draw 9.9, Recorder.Submit 0.7 | | queue worker 0x20 | 21.7 (5 %) | 403.4 (92 %) | 13.1 | 1.7 | Driver.Packet 373.1, Driver.EndSubmission 13.3 | | queue worker 0x28 | 5.1 (1 %) | 420.8 (96 %) | 12.3 | 0.9 | Driver.Packet 375.9, Driver.EndSubmission 10.7 | | queue worker 0x48 | 0.1 (0 %) | 425.3 (97 %) | 12.9 | 0.0 | Driver.Packet 374.8, Driver.EndSubmission 0.5 | | queue worker 0x38 | 18.4 (4 %) | 405.9 (93 %) | 13.9 | 0.2 | Driver.Packet 371.6, Driver.EndSubmission 11.2 | | queue worker 0x50 | 3.3 (1 %) | 420.3 (96 %) | 14.6 | 0.4 | Driver.Packet 380.9, Driver.EndSubmission 0.5 | | queue worker 0x30 | 72.2 (16 %) | 351.6 (80 %) | 14.5 | 0.2 | Driver.Packet 383.8, Driver.EndSubmission 0.6 | | queue worker 0x40 | 26.9 (6 %) | 396.9 (91 %) | 14.5 | 0.7 | Driver.Packet 384.9, Driver.EndSubmission 0.2 | | gpu | 28.0 (6 %) | 0.0 (0 %) | 410.2 | 0.0 | batch 28.0 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 3033.1, Driver.Packet.memory_wait 2496.9, Driver.Packet.dispatch 511.7, Driver.Dispatch 481.3, Driver.WorkerWait 324.5, Driver.WorkerWait.idle_and_completion_poll 324.4, Driver.Dispatch.materialize 129.6, Vulkan.Dispatch 115.1, Vulkan.Dispatch.shader_resources 110.4, Vulkan.ComputePipeline 72.4 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x28) 6145.2 ms at 436 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x48) 6090.2 ms at 436 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x50) 6043.7 ms at 636 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 5188.9 ms at 1230 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x30) 4165.4 ms at 2515 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 3963.4 ms at 2718 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 3734.5 ms at 2947 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 1496.1 ms at 1174 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 1411.3 ms at 1189 ms, present 1 - GpuMutex.wait.dispatch (queue worker 0x0) 1080.8 ms at 1431 ms, present 1 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 51: 53.0 ms at 2891 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 222.4, Driver.Packet.dispatch (queue worker 0x0) 222.4, Driver.Dispatch (queue worker 0x0) 222.3, Resources.Prepare (queue worker 0x0) 124.0 - batch 752: 23.1 ms at 8027 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 115.0, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 115.0, Recorder.Sync (queue worker 0x0) 24.1, Driver.Packet (queue worker 0x0) 14.1 - batch 3: 21.6 ms at 597 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 363.2, Driver.Packet.dispatch (queue worker 0x0) 363.1, Driver.Dispatch (queue worker 0x0) 361.5, Resources.Prepare (queue worker 0x0) 84.3 - batch 797: 11.9 ms at 8175 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 518.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 518.1, Recorder.Sync (queue worker 0x0) 12.2, Driver.Packet (queue worker 0x0) 5.1 - batch 37: 9.5 ms at 2516 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x30) 5466.4, Driver.Packet.memory_wait (queue worker 0x30) 4176.6, Driver.Packet.dispatch (queue worker 0x30) 1289.8, Driver.Dispatch (queue worker 0x30) 1277.7 ``` </details> #### `tools/trace_digest.py` — Warm Median Run (`main` `aps5-trace-522e32e3b618-38788.json.gz` vs PR `aps5-trace-dcb04d0aa14d-51020.json.gz`) <details> <summary><code>main</code> warm median digest (<code>aps5-trace-522e32e3b618-38788.json.gz</code>)</summary> ```text **frames 0:20** from present 0: 20 presents, frame p50 75.5 / p90 800.9 / p99 4787.4 / max 4787.4 ms, GPU busy 21.8 ms per present NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit 522e32e3b618, dropped: no ```json {"commit":"522e32e3b618","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":6792.077},"presents":20,"frame_ms":{"p50":75.507,"p90":800.919,"p99":4787.418,"max":4787.418},"gpu_busy_ms_per_present":21.76,"worker_busy_pct":{"queue worker 0x0":87.834,"queue worker 0x20":87.181,"queue worker 0x28":86.025,"queue worker 0x30":85.792,"queue worker 0x38":85.242,"queue worker 0x40":86.157,"queue worker 0x48":83.123,"queue worker 0x50":85.022},"top_phases_ms_per_frame":{"Driver.Packet":2293.844,"Driver.Packet.memory_wait":1870.829,"Driver.Packet.dispatch":408.587,"Driver.Dispatch":373.319,"Driver.Dispatch.materialize":124.379,"Vulkan.Dispatch":120.819,"Vulkan.Dispatch.shader_resources":116.63,"Shader.PrepareArtifact":100.823},"trace_dropped":false,"trace":"aps5-trace-522e32e3b618-38788.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1: 4787.4 ms at 9 ms: Driver.Packet (queue worker 0x0) 4658.2, Driver.Packet (queue worker 0x40) 4658.0, Driver.Packet (queue worker 0x50) 4655.5, Driver.Packet (queue worker 0x30) 4645.6 - present 18: 800.9 ms at 5956 ms: Shader.PrepareArtifact (shader prepare) 912.3, Driver.WorkerWait (queue worker 0x48) 448.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 448.8, Driver.WorkerWait (queue worker 0x28) 448.8 - present 14: 134.0 ms at 5583 ms: Shader.PrepareArtifact (shader prepare) 123.1, Driver.WorkerWait (queue worker 0x50) 113.8, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 113.8, Driver.WorkerWait (queue worker 0x30) 108.3 - present 17: 112.0 ms at 5844 ms: Driver.WorkerWait (queue worker 0x50) 90.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 90.3, Driver.WorkerWait (queue worker 0x48) 88.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x48) 88.1 - present 12: 96.0 ms at 5430 ms: Shader.PrepareArtifact (shader prepare) 368.5, Driver.Packet (queue worker 0x40) 75.5, Driver.Packet (queue worker 0x0) 73.9, Driver.Packet (queue worker 0x38) 70.7 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | shader prepare | 15.4 (5 %) | 0.0 (0 %) | 324.2 | 0.0 | Shader.PrepareArtifact 15.4 | | shader prepare | 10.4 (3 %) | 0.0 (0 %) | 329.2 | 0.0 | Shader.PrepareArtifact 10.4 | | shader prepare | 12.6 (4 %) | 0.0 (0 %) | 327.0 | 0.0 | Shader.PrepareArtifact 12.6 | | shader prepare | 10.8 (3 %) | 0.0 (0 %) | 328.8 | 0.0 | Shader.PrepareArtifact 10.8 | | shader prepare | 12.0 (4 %) | 0.0 (0 %) | 327.6 | 0.0 | Shader.PrepareArtifact 12.0 | | shader prepare | 12.7 (4 %) | 0.0 (0 %) | 326.9 | 0.0 | Shader.PrepareArtifact 12.7 | | shader prepare | 15.7 (5 %) | 0.0 (0 %) | 323.9 | 0.0 | Shader.PrepareArtifact 15.7 | | title | 1.3 (0 %) | 0.0 (0 %) | 338.3 | 0.0 | Shader.Register 1.3, Shader.ResolveGraphicsStagesAbi 0.0 | | shader prepare | 11.0 (3 %) | 0.0 (0 %) | 328.6 | 0.0 | Shader.PrepareArtifact 11.0 | | shader prepare | 0.5 (0 %) | 0.0 (0 %) | 339.1 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.5 | | title | 1.8 (1 %) | 0.0 (0 %) | 337.8 | 0.0 | Shader.ResolveAbi 0.9, Shader.Register 0.9 | | title | 1.2 (0 %) | 0.0 (0 %) | 338.4 | 0.0 | Shader.Register 1.2, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.2 (0 %) | 0.0 (0 %) | 338.4 | 0.0 | Shader.Register 1.1, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 1.6 (0 %) | 0.0 (0 %) | 338.0 | 0.0 | Shader.Register 1.6, Shader.ResolveAbi 0.0 | | title | 1.7 (1 %) | 0.0 (0 %) | 337.9 | 0.0 | Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 2.3 (1 %) | 0.0 (0 %) | 337.3 | 0.0 | Shader.Register 2.3, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.8 (0 %) | 0.0 (0 %) | 338.8 | 0.0 | Shader.Register 0.7, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 1.4 (0 %) | 0.0 (0 %) | 338.2 | 0.0 | Shader.Register 0.8, Shader.ResolveAbi 0.6 | | queue worker 0x0 | 266.7 (79 %) | 64.2 (19 %) | 8.7 | 7.2 | Driver.Packet 295.4, Driver.EndSubmission 1.1 | | presenter | 0.6 (0 %) | 1.5 (0 %) | 337.5 | 0.1 | VideoOut.Flip 2.0, Driver.Present 0.1 | | draw committer | 8.9 (3 %) | 15.5 (5 %) | 315.2 | 0.3 | Graphics.Draw 7.8, Recorder.Sync 0.7 | | queue worker 0x20 | 14.5 (4 %) | 317.4 (93 %) | 7.8 | 1.7 | Driver.Packet 288.5, Driver.EndSubmission 7.2 | | queue worker 0x28 | 7.3 (2 %) | 325.1 (96 %) | 7.1 | 0.9 | Driver.Packet 281.3, Driver.EndSubmission 10.7 | | queue worker 0x30 | 74.5 (22 %) | 256.8 (76 %) | 8.3 | 0.2 | Driver.Packet 289.9, Driver.EndSubmission 1.5 | | queue worker 0x38 | 3.9 (1 %) | 327.5 (96 %) | 8.1 | 0.2 | Driver.Packet 275.7, Driver.EndSubmission 13.7 | | queue worker 0x40 | 22.8 (7 %) | 308.5 (91 %) | 8.3 | 0.6 | Driver.Packet 292.3, Driver.EndSubmission 0.1 | | queue worker 0x48 | 0.1 (0 %) | 332.2 (98 %) | 7.4 | 0.0 | Driver.Packet 280.8, Driver.EndSubmission 1.5 | | queue worker 0x50 | 2.3 (1 %) | 328.6 (97 %) | 8.7 | 0.4 | Driver.Packet 287.5, Driver.EndSubmission 1.1 | | gpu | 24.5 (7 %) | 0.0 (0 %) | 315.1 | 0.0 | batch 24.5 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 2291.3, Driver.Packet.memory_wait 1870.7, Driver.Packet.dispatch 408.0, Driver.Dispatch 372.3, Driver.WorkerWait 324.1, Driver.WorkerWait.idle_and_completion_poll 324.0, Driver.Dispatch.materialize 123.4, Vulkan.Dispatch 120.0, Vulkan.Dispatch.shader_resources 116.2, Shader.PrepareArtifact 100.8 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x28) 4360.4 ms at 368 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x48) 4333.5 ms at 368 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x50) 4329.3 ms at 469 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 3645.7 ms at 1008 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x30) 2446.2 ms at 2351 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 2345.2 ms at 2453 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 2136.3 ms at 2662 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 1744.4 ms at 690 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 1605.8 ms at 788 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 626.2 ms at 368 ms, present 1 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 53: 55.3 ms at 2602 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 83.5, Driver.Packet.dispatch (queue worker 0x40) 83.5, Driver.Dispatch (queue worker 0x40) 1.7, Vulkan.Dispatch (queue worker 0x40) 0.9 - batch 569: 19.1 ms at 5663 ms, present 14: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 99.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 99.6, Recorder.Sync (queue worker 0x0) 19.4, Driver.Packet (queue worker 0x0) 0.7 - batch 2: 16.2 ms at 351 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 215.9, Driver.Packet.dispatch (queue worker 0x0) 215.9, Driver.Dispatch (queue worker 0x0) 215.9, Vulkan.Dispatch (queue worker 0x0) 72.9 - batch 681: 13.1 ms at 5912 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 80.5, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 80.5, Recorder.Sync (queue worker 0x0) 13.3, Driver.Packet (queue worker 0x0) 8.5 - batch 731: 12.8 ms at 6710 ms, present 18: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 168.6, Driver.Packet.dispatch (queue worker 0x0) 155.4, Driver.Dispatch (queue worker 0x0) 152.8, Driver.Dispatch.materialize (queue worker 0x0) 60.6 ``` </details> <details> <summary><code>perf/agc-compute-prewarm</code> warm median digest (<code>aps5-trace-dcb04d0aa14d-51020.json.gz</code>)</summary> ```text **frames 0:20** from present 0: 20 presents, frame p50 71.5 / p90 503.6 / p99 4767.3 / max 4767.3 ms, GPU busy 28.8 ms per present NVIDIA GeForce RTX 3080, NVIDIA 617.14, Windows 10.0.19045, 1920x1080, commit dcb04d0aa14d, dropped: no ```json {"commit":"dcb04d0aa14d","dirty":false,"env":{"APS5_TRACE_DIR":"logs_bench_8735","APS5_TRACE_FRAMES":"0:20"},"gpu":"NVIDIA GeForce RTX 3080","driver":"NVIDIA 617.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 7 7700 8-Core Processor","cpu_threads":16,"memory_mib":48005,"title_id":"PPSA01341","title":"Demon's Souls","content_version":"01.007.000","resolution":"1920x1080","window":{"spec":"frames 0:20","first_present":0,"ms":6639.422},"presents":20,"frame_ms":{"p50":71.507,"p90":503.585,"p99":4767.308,"max":4767.308},"gpu_busy_ms_per_present":28.805,"worker_busy_pct":{"queue worker 0x0":87.185,"queue worker 0x28":82.827,"queue worker 0x20":84.464,"queue worker 0x48":82.124,"queue worker 0x50":84.022,"queue worker 0x30":84.471,"queue worker 0x38":83.511,"queue worker 0x40":84.839},"top_phases_ms_per_frame":{"Driver.Packet":2218.187,"Driver.Packet.memory_wait":1763.587,"Driver.Packet.dispatch":425.453,"Driver.Dispatch":391.083,"Vulkan.Dispatch":118.037,"Vulkan.Dispatch.shader_resources":113.503,"Driver.Dispatch.materialize":109.963,"Resources.Prepare":83.46},"trace_dropped":false,"trace":"aps5-trace-dcb04d0aa14d-51020.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1: 4767.3 ms at 12 ms: Driver.Packet (queue worker 0x0) 4597.8, Driver.Packet (queue worker 0x50) 4595.8, Driver.Packet (queue worker 0x30) 4594.0, Driver.Packet (queue worker 0x40) 4592.2 - present 18: 503.6 ms at 6046 ms: Driver.WorkerWait (queue worker 0x50) 496.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 496.1, Driver.WorkerWait (queue worker 0x30) 488.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 488.1 - present 11: 173.5 ms at 5412 ms: Shader.PrepareArtifact (shader prepare) 570.6, Driver.Packet (queue worker 0x30) 173.4, Driver.Packet (queue worker 0x50) 173.3, Driver.Packet (queue worker 0x40) 173.1 - present 17: 148.0 ms at 5898 ms: Driver.WorkerWait (queue worker 0x50) 135.3, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x50) 135.3, Driver.WorkerWait (queue worker 0x30) 133.4, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x30) 133.4 - present 2: 106.8 ms at 4780 ms: Driver.Packet (queue worker 0x50) 106.5, Driver.Packet (queue worker 0x30) 106.3, Driver.Packet (queue worker 0x40) 105.1, Driver.Packet (queue worker 0x20) 104.3 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | shader prepare | 6.4 (2 %) | 0.0 (0 %) | 325.6 | 0.0 | Shader.PrepareArtifact 6.4 | | shader prepare | 7.0 (2 %) | 0.0 (0 %) | 325.0 | 0.0 | Shader.PrepareArtifact 7.0 | | shader prepare | 7.2 (2 %) | 0.0 (0 %) | 324.8 | 0.0 | Shader.PrepareArtifact 7.2 | | shader prepare | 6.7 (2 %) | 0.0 (0 %) | 325.3 | 0.0 | Shader.PrepareArtifact 6.7 | | shader prepare | 6.9 (2 %) | 0.0 (0 %) | 325.0 | 0.0 | Shader.PrepareArtifact 6.9 | | shader prepare | 7.6 (2 %) | 0.0 (0 %) | 324.4 | 0.0 | Shader.PrepareArtifact 7.6 | | shader prepare | 6.8 (2 %) | 0.0 (0 %) | 325.2 | 0.0 | Shader.PrepareArtifact 6.8 | | title | 1.0 (0 %) | 0.0 (0 %) | 330.9 | 0.0 | Shader.Register 1.0, Shader.ResolveGraphicsStagesAbi 0.0 | | shader prepare | 7.2 (2 %) | 0.0 (0 %) | 324.8 | 0.0 | Shader.PrepareArtifact 7.2 | | shader prepare | 0.5 (0 %) | 0.0 (0 %) | 331.5 | 0.0 | Vulkan.GraphicsPipelinePrebuild 0.5 | | title | 0.0 (0 %) | 0.0 (0 %) | 332.0 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.4 (0 %) | 0.0 (0 %) | 331.6 | 0.0 | Shader.Register 0.4, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.7 (0 %) | 0.0 (0 %) | 331.3 | 0.0 | Shader.Register 0.6, Shader.ResolveGraphicsStagesAbi 0.1 | | title | 1.5 (0 %) | 0.0 (0 %) | 330.5 | 0.0 | Shader.ResolveAbi 0.8, Shader.Register 0.6 | | title | 0.7 (0 %) | 0.0 (0 %) | 331.2 | 0.0 | Shader.Register 0.7, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 1.7 (1 %) | 0.0 (0 %) | 330.3 | 0.0 | Shader.Register 1.7, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 2.0 (1 %) | 0.0 (0 %) | 330.0 | 0.0 | Shader.Register 1.0, Shader.ResolveAbi 1.0 | | queue worker 0x0 | 251.1 (76 %) | 70.0 (21 %) | 10.9 | 7.3 | Driver.Packet 286.3, Driver.EndSubmission 1.5 | | presenter | 0.6 (0 %) | 3.1 (1 %) | 328.3 | 0.1 | VideoOut.Flip 3.6, Driver.Present 0.1 | | draw committer | 9.7 (3 %) | 3.7 (1 %) | 318.6 | 0.3 | Graphics.Draw 8.8, Recorder.Submit 0.5 | | queue worker 0x28 | 5.1 (2 %) | 317.5 (96 %) | 9.3 | 0.9 | Driver.Packet 273.5, Driver.EndSubmission 1.3 | | queue worker 0x20 | 18.0 (5 %) | 303.9 (92 %) | 10.1 | 1.8 | Driver.Packet 277.2, Driver.EndSubmission 2.7 | | queue worker 0x48 | 0.3 (0 %) | 322.3 (97 %) | 9.4 | 0.0 | Driver.Packet 271.9, Driver.EndSubmission 0.7 | | queue worker 0x50 | 2.3 (1 %) | 318.9 (96 %) | 10.8 | 0.4 | Driver.Packet 278.2, Driver.EndSubmission 0.6 | | queue worker 0x30 | 74.0 (22 %) | 247.2 (74 %) | 10.8 | 0.2 | Driver.Packet 280.1, Driver.EndSubmission 0.3 | | queue worker 0x38 | 10.0 (3 %) | 311.4 (94 %) | 10.6 | 0.2 | Driver.Packet 267.1, Driver.EndSubmission 10.1 | | queue worker 0x40 | 23.8 (7 %) | 297.3 (90 %) | 10.9 | 0.6 | Driver.Packet 281.3, Driver.EndSubmission 0.2 | | title | 0.6 (0 %) | 0.0 (0 %) | 331.3 | 0.0 | Shader.Register 0.6, Shader.ResolveGraphicsStagesAbi 0.0 | | gpu | 31.3 (9 %) | 0.0 (0 %) | 300.7 | 0.0 | batch 31.3 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 2215.5, Driver.Packet.memory_wait 1763.5, Driver.Packet.dispatch 424.7, Driver.Dispatch 390.0, Driver.WorkerWait 340.0, Driver.WorkerWait.idle_and_completion_poll 340.0, Vulkan.Dispatch 117.3, Vulkan.Dispatch.shader_resources 113.0, Driver.Dispatch.materialize 109.0, Resources.Prepare 83.3 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x28) 4297.5 ms at 405 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x50) 4235.3 ms at 545 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x48) 4129.6 ms at 544 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 3613.7 ms at 1014 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x30) 2440.4 ms at 2340 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 2330.5 ms at 2451 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 2118.8 ms at 2663 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x38) 1440.6 ms at 984 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x40) 1392.6 ms at 996 ms, present 1 - Driver.Packet.memory_wait (queue worker 0x20) 594.6 ms at 405 ms, present 1 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 53: 64.3 ms at 2596 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x40) 85.5, Driver.Packet.dispatch (queue worker 0x40) 85.5, Driver.Dispatch (queue worker 0x40) 1.7, Vulkan.Dispatch (queue worker 0x40) 1.0 - batch 714: 24.6 ms at 5980 ms, present 17: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 107.1, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 107.0, Recorder.Sync (queue worker 0x0) 25.2, Driver.Packet (queue worker 0x0) 11.4 - batch 2: 19.2 ms at 381 ms, present 1: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 176.0, Driver.Packet.dispatch (queue worker 0x0) 176.0, Driver.Dispatch (queue worker 0x0) 176.0, Vulkan.Dispatch (queue worker 0x0) 53.8 - batch 749: 11.9 ms at 6119 ms, present 18: GPU no ranges; recorded by Driver.WorkerWait (queue worker 0x0) 460.6, Driver.WorkerWait.idle_and_completion_poll (queue worker 0x0) 460.5, Recorder.Sync (queue worker 0x0) 12.7, Driver.Packet (queue worker 0x0) 10.3 - batch 81: 8.1 ms at 4731 ms, present 1: GPU no ranges; recorded by Driver.Dispatch.materialize (queue worker 0x0) 20.8, Driver.Packet (queue worker 0x0) 9.7, Driver.Packet.dispatch (queue worker 0x0) 9.7, Driver.Dispatch (queue worker 0x0) 9.7 ``` </details> ### 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: none - [x] GPUs tested: AMD Radeon RX 9070 XT, driver 26.3.1 (Vulkan 1.4.341), Windows 11 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-20 22:53:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:53:49Z.

Review: COMMENTED


Review note on the new dispatch look-ahead: in the first scan loop, the / branch reads to derive without validating that the packet has at least five DWORDs. allows shorter packets and this loop only checks that the declared count fits in the submission, so malformed/truncated dispatch packets can cause an out-of-bounds span access before normal validation runs. Could you gate the preview path on the opcode-specific minimum packet length (and skip/fall back safely when it is shorter)?

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5592801150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#pullrequestreview-5592801150). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:53:49Z. **Review:** COMMENTED --- Review note on the new dispatch look-ahead: in the first scan loop, the / branch reads to derive without validating that the packet has at least five DWORDs. allows shorter packets and this loop only checks that the declared count fits in the submission, so malformed/truncated dispatch packets can cause an out-of-bounds span access before normal validation runs. Could you gate the preview path on the opcode-specific minimum packet length (and skip/fall back safely when it is shorter)?
MarcZX10 commented 2026-10-20 22:53:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T22:53:53Z.

Review: COMMENTED


Review note on the new dispatch look-ahead: in the first scan loop, the 0x15/0x16 branch reads packet[4] to derive wave without validating that the packet has at least five DWORDs. PacketWords(header) allows shorter packets and this loop only checks that the declared count fits in the submission, so malformed/truncated dispatch packets can cause an out-of-bounds span access before normal dispatch validation runs. Could you gate the preview path on the opcode-specific minimum packet length (and skip/fall back safely when it is shorter)?

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5592801757 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#pullrequestreview-5592801757). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T22:53:53Z. **Review:** COMMENTED --- Review note on the new dispatch look-ahead: in the first scan loop, the `0x15`/`0x16` branch reads `packet[4]` to derive `wave` without validating that the packet has at least five DWORDs. `PacketWords(header)` allows shorter packets and this loop only checks that the declared count fits in the submission, so malformed/truncated dispatch packets can cause an out-of-bounds span access before normal `dispatch` validation runs. Could you gate the preview path on the opcode-specific minimum packet length (and skip/fall back safely when it is shorter)?
hamb3r commented 2026-10-21 01:18:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-21T01:18:29Z.


Addressed the review note in 8685c2edec:

  1. Opcode-specific minimum packet length gating: both the preview scan loop and the resolve loop in Driver::resolveGroupAhead (DispatchAhead.cpp) now check if (count < (opcode == 0x15 ? 5u : 3u)) before inspecting the dispatch packet.
  2. Reading DISPATCH_INITIATOR via packet.back(): in the preview path, wave is now derived from (packet.back() & 0x8000u) != 0 ? 32u : 64u instead of packet[4], matching Pm4::NoteDispatchRegisters and Pm4::ResolveDispatch so 3- and 4-word 0x16 (DISPATCH_INDIRECT) packets read their initiator word without out-of-bounds access.
  3. Preview state accuracy & bounds guard: userData is populated from preview.shader (0x240u + i), and codeOffset < registered->code.size() is checked before subspan(codeOffset).
  4. Test coverage (DispatchAheadPrewarm in PreparedShaders.cpp): added coverage for pending shader prioritization (PrioritizeRegistrationPreparation), filler packets, and 0x63 (SET_SH_REG_INDIRECT) during resolveGroupAhead.

Line-by-line gcov Diff Coverage (102 / 102 executable lines = 100.0%)

=== core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp ===
      27 :  402 :         if (compiledResult != nullptr) {
      54 :  403 :             SubmitLibraryPrebuild([localDevice, compiledResult, address] {
      27 :  404 :                 try { localDevice->PrebuildComputePipeline(*compiledResult, address); } catch (...) {}
      27 :  405 :             });
Diff executable lines covered: 4 / 4 (100.0%)

=== core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp ===
      26 :  133 :     if (submission.shaders != nullptr) {
      25 :  134 :         QueueState preview = live;
      25 :  135 :         std::vector<PreparedShaders*> pendingShaders;
      25 :  136 :         std::vector<PreparedShaders*> submittedShaders;
     102 :  137 :         for (std::size_t scan = from; scan < commands.size();) {
      77 :  138 :             const auto header = commands[scan];
      77 :  139 :             if (Pm4::FillerPacket(header)) {
       1 :  140 :                 ++scan;
       1 :  141 :                 continue;
      76 :  143 :             const auto count = Pm4::PacketWords(header);
     76* :  144 :             if (scan + count > commands.size()) break;
      76 :  145 :             const auto packet = std::span(commands).subspan(scan, count);
      76 :  146 :             const auto opcode = (header >> 8u) & 0xffu;
      76 :  147 :             const auto next = scan + count;
     76* :  148 :             if (header == FlipPacketHeader || opcode == 0x22 || opcode == 0x3f) break;
      76 :  149 :             if (opcode == 0x15 || opcode == 0x16) {
     30* :  150 :                 if (count < (opcode == 0x15 ? 5u : 3u)) break;
      30 :  152 :                     const auto low = preview.shader.find(0x20c);
      30 :  153 :                     const auto high = preview.shader.find(0x20d);
     30* :  154 :                     if (low != preview.shader.end() && high != preview.shader.end()) {
      30 :  155 :                         const auto address = (static_cast<std::uint64_t>(low->second) << 8u) | (static_cast<std::uint64_t>(high->second & 0xffu) << 40u);
      30 :  156 :                         if (auto registered = RegisteredProgram(*submission.shaders, address, {0}); registered != nullptr && registered->type == 0) {
      19 :  157 :                             bool isPending = false;
      19 :  158 :                             bool isEmpty = false;
      19 :  160 :                                 std::lock_guard lock(registered->prepared->mutex);
      19 :  161 :                                 isPending = registered->prepared->pending;
      19 :  162 :                                 isEmpty = registered->prepared->entries.empty();
      19 :  163 :                             }
      19 :  164 :                             if (isPending) {
       2 :  165 :                                 if (std::ranges::find(pendingShaders, registered->prepared.get()) == pendingShaders.end()) {
       1 :  166 :                                     pendingShaders.push_back(registered->prepared.get());
      22 :  168 :                             } else if (isEmpty && std::ranges::find(submittedShaders, registered->prepared.get()) == submittedShaders.end()) {
       4 :  169 :                                 const auto codeOffset = static_cast<std::size_t>((address - registered->codeAddress) / sizeof(std::uint32_t));
       4 :  170 :                                 if (codeOffset < registered->code.size()) {
       4 :  171 :                                     submittedShaders.push_back(registered->prepared.get());
       4 :  172 :                                     const auto rsrc2 = preview.shader.find(0x213);
      4* :  173 :                                     const auto userCount = rsrc2 != preview.shader.end() ? ((rsrc2->second >> 1u) & 0x1fu) : 0u;
       4 :  174 :                                     std::vector<std::uint32_t> userData(userCount, 0u);
      29 :  175 :                                     for (std::uint32_t i = 0; i < userCount; ++i) {
      25 :  176 :                                         if (const auto reg = preview.shader.find(0x240u + i); reg != preview.shader.end()) userData[i] = reg->second;
       4 :  178 :                                     auto compute = Graphics::DecodeComputeStageInfo(preview.shader, registered->header);
      4* :  179 :                                     const auto wave = (packet.back() & 0x8000u) != 0 ? 32u : 64u;
      8* :  180 :                                     SubmitRegistrationPreparation([registered, localDevice, address, codeOffset, wave, compute, userData = std::move(userData), state = preview.shader]() mutable {
       8 :  181 :                                         std::vector<ShaderRecompiler::MemoryRegion> memory{{registered->codeAddress, std::as_bytes(std::span(registered->code))}};
       4 :  182 :                                         if (!registered->header.empty()) memory.push_back({registered->headerAddress, registered->header});
       4 :  183 :                                         ShaderRecompiler::RecompileRequest request{
       4 :  184 :                                             {ShaderRecompiler::ShaderStage::Compute, address, std::span(registered->code).subspan(codeOffset), registered->headerAddress, registered->header},
       4 :  185 :                                             {wave, 0, userData, compute, std::nullopt, std::nullopt, memory, DispatchFloatMode(*registered, state)},
       4 :  186 :                                             localDevice->ComputeTarget(wave),
       8 :  188 :                                         };
       4 :  189 :                                         try { static_cast<void>(InvocationFor(*registered, codeOffset, request)); } catch (...) {}
       8 :  190 :                                     }, registered->prepared.get());
       4 :  191 :                                 }
      30 :  193 :                         }
      30 :  195 :                     Pm4::NoteDispatchRegisters(packet, preview); } catch (...) {}
      76 :  196 :             } else if (Pm4::IndirectRegisterOpcode(opcode)) {
       1 :  197 :                 const auto found = submission.registerLists.find(scan);
      1* :  198 :                 if (found != submission.registerLists.end() && Pm4::IndirectRegistersValid(found->second)) {
       1 :  199 :                     try { Pm4::ExecuteIndirectRegisters(packet, found->second, preview); } catch (...) {}
      45 :  201 :             } else if (!Pm4::AccessesMemory(header) && opcode != 0x3c && opcode != 0x93 && opcode != 0x37 && opcode != 0x42 && opcode != 0x46 && opcode != 0x49 && opcode != 0x58) {
      37 :  202 :                 try { Pm4::Execute(packet, preview); } catch (...) {}
      76 :  204 :             scan = next;
      26 :  206 :         for (auto it = pendingShaders.rbegin(); it != pendingShaders.rend(); ++it) {
       1 :  207 :             PrioritizeRegistrationPreparation(**it);
      25 :  209 :     }
     30* :  225 :             if (count < (opcode == 0x15 ? 5u : 3u) || resolved.contains(cursor)) break;
      44 :  271 :         } else if (Pm4::IndirectRegisterOpcode(opcode)) {
       1 :  272 :             const auto found = submission.registerLists.find(cursor);
      1* :  273 :             if (found == submission.registerLists.end() || !Pm4::IndirectRegistersValid(found->second)) break;
       1 :  274 :             try { Pm4::ExecuteIndirectRegisters(packet, found->second, scratch); } catch (const std::exception&) { break; }
Diff executable lines covered: 76 / 76 (100.0%)

=== core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp ===
      30 :  229 :     std::size_t aheadCursor = 0;
      32 :  394 :             if (gateOpened() || (resolvedAhead().empty() && cursor >= aheadCursor)) {
      29 :  396 :                 aheadCursor = nextCursor;
     29* :  397 :                 if (!pipelineDispatch() || opcode == 0x16 || !DrawPipeline::Active() || submission.queue != 0) {
Diff executable lines covered: 4 / 4 (100.0%)

=== core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp ===
       4 : 1054 :     if (request.context.pixel) {
      6* : 1124 :             auto* created = new RegistrationPreparePool(Closing() ? 0u : text != nullptr ? std::max(1u, static_cast<unsigned>(std::strtoul(text, nullptr, 10))) : std::max(2u, std::thread::hardware_concurrency() / 2u));
Diff executable lines covered: 2 / 2 (100.0%)

=== core/libs/prx/libSceAgcDriver/Execution/src/Driver/VulkanDevice.cpp ===
      29 : 2138 : void VulkanDevice::PrebuildComputePipeline(const ShaderRecompiler::RecompileResult& shader, std::uint64_t programAddress) {
     51* : 2139 :     if (shader.spirv.size() < 5 || shader.spirv[0] != 0x07230203u) return;
      29 : 2140 :     ShaderRecompiler::RuntimeAbi::RequireVersion(shader.runtimeAbiVersion);
      29 : 2141 :     const auto context = graphicsContext();
     29* : 2142 :     if (context.descriptorCache == nullptr) return;
      29 : 2143 :     const std::array<Graphics::CompiledShader, 1> shaders{{{ShaderRecompiler::ShaderStage::Compute, &shader, 0}}};
      29 : 2144 :     const auto pushStages = Graphics::PushConstantStages(shaders);
     29* : 2145 :     if (pushStages != 0 && state->properties.limits.maxPushConstantsSize < Graphics::ComputePushConstantBytes) return;
      29 : 2146 :     const auto key = ComputePipelineKey::Of(shader, pushStages != 0);
      29 : 2147 :     if (!key.identity.Empty()) {
      29 : 2148 :         std::lock_guard pipelines(state->computePipelinesMutex);
      29 : 2149 :         if (state->computePipelines.contains(key) || state->computePipelinesBuilding.contains(key)) return;
      29 : 2150 :     }
       7 : 2151 :     const auto layouts = Graphics::DescribeSetLayouts(context, shaders);
       7 : 2152 :     static_cast<void>(computePipeline(context, shader, layouts.layouts.main, layouts.mainKey, pushStages, programAddress));
      29 : 2153 : }
Diff executable lines covered: 16 / 16 (100.0%)

Verified with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (6/6 Passed, zero VUID- errors).

cc @MarcZX10

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6305606739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#issuecomment-6305606739). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-21T01:18:29Z. --- Addressed the review note in `8685c2edec`: 1. **Opcode-specific minimum packet length gating**: both the preview scan loop and the resolve loop in `Driver::resolveGroupAhead` (`DispatchAhead.cpp`) now check `if (count < (opcode == 0x15 ? 5u : 3u))` before inspecting the dispatch packet. 2. **Reading `DISPATCH_INITIATOR` via `packet.back()`**: in the preview path, `wave` is now derived from `(packet.back() & 0x8000u) != 0 ? 32u : 64u` instead of `packet[4]`, matching `Pm4::NoteDispatchRegisters` and `Pm4::ResolveDispatch` so 3- and 4-word `0x16` (`DISPATCH_INDIRECT`) packets read their initiator word without out-of-bounds access. 3. **Preview state accuracy & bounds guard**: `userData` is populated from `preview.shader` (`0x240u + i`), and `codeOffset < registered->code.size()` is checked before `subspan(codeOffset)`. 4. **Test coverage (`DispatchAheadPrewarm` in `PreparedShaders.cpp`)**: added coverage for pending shader prioritization (`PrioritizeRegistrationPreparation`), filler packets, and `0x63` (`SET_SH_REG_INDIRECT`) during `resolveGroupAhead`. ### Line-by-line `gcov` Diff Coverage (`102 / 102` executable lines = `100.0%`) ```text === core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp === 27 : 402 : if (compiledResult != nullptr) { 54 : 403 : SubmitLibraryPrebuild([localDevice, compiledResult, address] { 27 : 404 : try { localDevice->PrebuildComputePipeline(*compiledResult, address); } catch (...) {} 27 : 405 : }); Diff executable lines covered: 4 / 4 (100.0%) === core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp === 26 : 133 : if (submission.shaders != nullptr) { 25 : 134 : QueueState preview = live; 25 : 135 : std::vector<PreparedShaders*> pendingShaders; 25 : 136 : std::vector<PreparedShaders*> submittedShaders; 102 : 137 : for (std::size_t scan = from; scan < commands.size();) { 77 : 138 : const auto header = commands[scan]; 77 : 139 : if (Pm4::FillerPacket(header)) { 1 : 140 : ++scan; 1 : 141 : continue; 76 : 143 : const auto count = Pm4::PacketWords(header); 76* : 144 : if (scan + count > commands.size()) break; 76 : 145 : const auto packet = std::span(commands).subspan(scan, count); 76 : 146 : const auto opcode = (header >> 8u) & 0xffu; 76 : 147 : const auto next = scan + count; 76* : 148 : if (header == FlipPacketHeader || opcode == 0x22 || opcode == 0x3f) break; 76 : 149 : if (opcode == 0x15 || opcode == 0x16) { 30* : 150 : if (count < (opcode == 0x15 ? 5u : 3u)) break; 30 : 152 : const auto low = preview.shader.find(0x20c); 30 : 153 : const auto high = preview.shader.find(0x20d); 30* : 154 : if (low != preview.shader.end() && high != preview.shader.end()) { 30 : 155 : const auto address = (static_cast<std::uint64_t>(low->second) << 8u) | (static_cast<std::uint64_t>(high->second & 0xffu) << 40u); 30 : 156 : if (auto registered = RegisteredProgram(*submission.shaders, address, {0}); registered != nullptr && registered->type == 0) { 19 : 157 : bool isPending = false; 19 : 158 : bool isEmpty = false; 19 : 160 : std::lock_guard lock(registered->prepared->mutex); 19 : 161 : isPending = registered->prepared->pending; 19 : 162 : isEmpty = registered->prepared->entries.empty(); 19 : 163 : } 19 : 164 : if (isPending) { 2 : 165 : if (std::ranges::find(pendingShaders, registered->prepared.get()) == pendingShaders.end()) { 1 : 166 : pendingShaders.push_back(registered->prepared.get()); 22 : 168 : } else if (isEmpty && std::ranges::find(submittedShaders, registered->prepared.get()) == submittedShaders.end()) { 4 : 169 : const auto codeOffset = static_cast<std::size_t>((address - registered->codeAddress) / sizeof(std::uint32_t)); 4 : 170 : if (codeOffset < registered->code.size()) { 4 : 171 : submittedShaders.push_back(registered->prepared.get()); 4 : 172 : const auto rsrc2 = preview.shader.find(0x213); 4* : 173 : const auto userCount = rsrc2 != preview.shader.end() ? ((rsrc2->second >> 1u) & 0x1fu) : 0u; 4 : 174 : std::vector<std::uint32_t> userData(userCount, 0u); 29 : 175 : for (std::uint32_t i = 0; i < userCount; ++i) { 25 : 176 : if (const auto reg = preview.shader.find(0x240u + i); reg != preview.shader.end()) userData[i] = reg->second; 4 : 178 : auto compute = Graphics::DecodeComputeStageInfo(preview.shader, registered->header); 4* : 179 : const auto wave = (packet.back() & 0x8000u) != 0 ? 32u : 64u; 8* : 180 : SubmitRegistrationPreparation([registered, localDevice, address, codeOffset, wave, compute, userData = std::move(userData), state = preview.shader]() mutable { 8 : 181 : std::vector<ShaderRecompiler::MemoryRegion> memory{{registered->codeAddress, std::as_bytes(std::span(registered->code))}}; 4 : 182 : if (!registered->header.empty()) memory.push_back({registered->headerAddress, registered->header}); 4 : 183 : ShaderRecompiler::RecompileRequest request{ 4 : 184 : {ShaderRecompiler::ShaderStage::Compute, address, std::span(registered->code).subspan(codeOffset), registered->headerAddress, registered->header}, 4 : 185 : {wave, 0, userData, compute, std::nullopt, std::nullopt, memory, DispatchFloatMode(*registered, state)}, 4 : 186 : localDevice->ComputeTarget(wave), 8 : 188 : }; 4 : 189 : try { static_cast<void>(InvocationFor(*registered, codeOffset, request)); } catch (...) {} 8 : 190 : }, registered->prepared.get()); 4 : 191 : } 30 : 193 : } 30 : 195 : Pm4::NoteDispatchRegisters(packet, preview); } catch (...) {} 76 : 196 : } else if (Pm4::IndirectRegisterOpcode(opcode)) { 1 : 197 : const auto found = submission.registerLists.find(scan); 1* : 198 : if (found != submission.registerLists.end() && Pm4::IndirectRegistersValid(found->second)) { 1 : 199 : try { Pm4::ExecuteIndirectRegisters(packet, found->second, preview); } catch (...) {} 45 : 201 : } else if (!Pm4::AccessesMemory(header) && opcode != 0x3c && opcode != 0x93 && opcode != 0x37 && opcode != 0x42 && opcode != 0x46 && opcode != 0x49 && opcode != 0x58) { 37 : 202 : try { Pm4::Execute(packet, preview); } catch (...) {} 76 : 204 : scan = next; 26 : 206 : for (auto it = pendingShaders.rbegin(); it != pendingShaders.rend(); ++it) { 1 : 207 : PrioritizeRegistrationPreparation(**it); 25 : 209 : } 30* : 225 : if (count < (opcode == 0x15 ? 5u : 3u) || resolved.contains(cursor)) break; 44 : 271 : } else if (Pm4::IndirectRegisterOpcode(opcode)) { 1 : 272 : const auto found = submission.registerLists.find(cursor); 1* : 273 : if (found == submission.registerLists.end() || !Pm4::IndirectRegistersValid(found->second)) break; 1 : 274 : try { Pm4::ExecuteIndirectRegisters(packet, found->second, scratch); } catch (const std::exception&) { break; } Diff executable lines covered: 76 / 76 (100.0%) === core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp === 30 : 229 : std::size_t aheadCursor = 0; 32 : 394 : if (gateOpened() || (resolvedAhead().empty() && cursor >= aheadCursor)) { 29 : 396 : aheadCursor = nextCursor; 29* : 397 : if (!pipelineDispatch() || opcode == 0x16 || !DrawPipeline::Active() || submission.queue != 0) { Diff executable lines covered: 4 / 4 (100.0%) === core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp === 4 : 1054 : if (request.context.pixel) { 6* : 1124 : auto* created = new RegistrationPreparePool(Closing() ? 0u : text != nullptr ? std::max(1u, static_cast<unsigned>(std::strtoul(text, nullptr, 10))) : std::max(2u, std::thread::hardware_concurrency() / 2u)); Diff executable lines covered: 2 / 2 (100.0%) === core/libs/prx/libSceAgcDriver/Execution/src/Driver/VulkanDevice.cpp === 29 : 2138 : void VulkanDevice::PrebuildComputePipeline(const ShaderRecompiler::RecompileResult& shader, std::uint64_t programAddress) { 51* : 2139 : if (shader.spirv.size() < 5 || shader.spirv[0] != 0x07230203u) return; 29 : 2140 : ShaderRecompiler::RuntimeAbi::RequireVersion(shader.runtimeAbiVersion); 29 : 2141 : const auto context = graphicsContext(); 29* : 2142 : if (context.descriptorCache == nullptr) return; 29 : 2143 : const std::array<Graphics::CompiledShader, 1> shaders{{{ShaderRecompiler::ShaderStage::Compute, &shader, 0}}}; 29 : 2144 : const auto pushStages = Graphics::PushConstantStages(shaders); 29* : 2145 : if (pushStages != 0 && state->properties.limits.maxPushConstantsSize < Graphics::ComputePushConstantBytes) return; 29 : 2146 : const auto key = ComputePipelineKey::Of(shader, pushStages != 0); 29 : 2147 : if (!key.identity.Empty()) { 29 : 2148 : std::lock_guard pipelines(state->computePipelinesMutex); 29 : 2149 : if (state->computePipelines.contains(key) || state->computePipelinesBuilding.contains(key)) return; 29 : 2150 : } 7 : 2151 : const auto layouts = Graphics::DescribeSetLayouts(context, shaders); 7 : 2152 : static_cast<void>(computePipeline(context, shader, layouts.layouts.main, layouts.mainKey, pushStages, programAddress)); 29 : 2153 : } Diff executable lines covered: 16 / 16 (100.0%) ``` Verified with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (`6/6 Passed`, zero `VUID-` errors). cc @MarcZX10
oneandonlydean commented 2026-10-21 06:28:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T06:28:50Z.


@hamb3r thanks for the length gating; both scan loops look right to us now. Before this goes further, a few things change behaviour in the default configuration and aren't in the description:

  1. APS5_GROUP_CAPTURE_ALL_QUEUES goes from opt-in to on by default (DispatchAhead.cpp), so group-ahead resolution now also runs on queue 0 for every title. On main queue 0 is deliberately opt-in, and docs/dev/ENVIRONMENT.md still describes the flag as a presence switch. Could you keep it opt-in here, or move the default change to its own PR that says why queue 0 is now safe and updates the reference?
  2. The description says the partialThreads = {1, 1, 1} compute variant is skipped "when the shader's header already specifies its threadgroup state", but PrepareRegistered now drops it for every compute shader. Dispatches with a partial last group then prepare their artifact at use, on the queue worker. Could the condition match the description, or could you say why those dispatches no longer need the prepared variant?
  3. The posted numbers use a dozen non-default APS5_* settings, including APS5_LAZY_SHADER_PREPARE=1. That is the only mode in which the new prewarm submits anything, because registration otherwise prepares the entries itself. Could you add main vs PR with the default environment? The new look-ahead now also runs on uncaptured dispatches and scans to the end of the submission each time, so its cost on long submissions matters too.
  4. DispatchAheadPrewarm submits the packets and waits, but asserts nothing about the result. Could it check what the change is for, for example that the lazily registered shader has a prepared entry for the dispatched offset after the submission and doesn't without the change?
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6309620316 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#issuecomment-6309620316). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T06:28:50Z. --- @hamb3r thanks for the length gating; both scan loops look right to us now. Before this goes further, a few things change behaviour in the default configuration and aren't in the description: 1. `APS5_GROUP_CAPTURE_ALL_QUEUES` goes from opt-in to on by default (`DispatchAhead.cpp`), so group-ahead resolution now also runs on queue 0 for every title. On `main` queue 0 is deliberately opt-in, and `docs/dev/ENVIRONMENT.md` still describes the flag as a presence switch. Could you keep it opt-in here, or move the default change to its own PR that says why queue 0 is now safe and updates the reference? 2. The description says the `partialThreads = {1, 1, 1}` compute variant is skipped "when the shader's header already specifies its threadgroup state", but `PrepareRegistered` now drops it for every compute shader. Dispatches with a partial last group then prepare their artifact at use, on the queue worker. Could the condition match the description, or could you say why those dispatches no longer need the prepared variant? 3. The posted numbers use a dozen non-default `APS5_*` settings, including `APS5_LAZY_SHADER_PREPARE=1`. That is the only mode in which the new prewarm submits anything, because registration otherwise prepares the entries itself. Could you add main vs PR with the default environment? The new look-ahead now also runs on uncaptured dispatches and scans to the end of the submission each time, so its cost on long submissions matters too. 4. `DispatchAheadPrewarm` submits the packets and waits, but asserts nothing about the result. Could it check what the change is for, for example that the lazily registered shader has a prepared entry for the dispatched offset after the submission and doesn't without the change?
hamb3r commented 2026-10-21 08:53:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-21T08:53:46Z.


@oneandonlydean Thanks for the thorough review! Addressed all four items in 320a4b6a19:

1. APS5_GROUP_CAPTURE_ALL_QUEUES opt-in on queue 0

Restored static const bool allQueues = std::getenv("APS5_GROUP_CAPTURE_ALL_QUEUES") != nullptr; in Driver::resolveGroupAhead (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp) so queue 0 remains opt-in by default, matching main and docs/dev/ENVIRONMENT.md.

2. partialThreads = {1, 1, 1} variant in PrepareRegistered

Restored the if (request.context.compute) { request.context.compute->partialThreads = {1, 1, 1}; append(); } else if (request.context.pixel) block in PrepareRegistered (core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp) so dispatches with a partial last workgroup continue to hit the registration-prepared artifact instead of compiling on the queue worker.

3. Look-ahead on uncaptured dispatches, bounded scan, and default-environment trace_digest.py

  • Reverted core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp to main so resolveGroupAhead only runs when gateOpened() is true (never on uncaptured dispatches).
  • Bounded the look-ahead preview loop in Driver::resolveGroupAhead (DispatchAhead.cpp) so it stops at the next wait/synchronization boundary (header == FlipPacketHeader || header == RenderingWaitPacketHeader || opcode == 0x22 || opcode == 0x3f || opcode == 0x3c || opcode == 0x93) instead of scanning to the end of the submission on every gate. Also removed the unused IndirectRegisterOpcode branch from the second (group-capture) loop so group-capture semantics match main.
  • Re-ran the main (ca74ef2177ee) vs PR (320a4b6a1946) comparison on Demon's Souls (PPSA01341 v01.007.000, frames 0:5) with the default environment ("env":{"APS5_TRACE_DIR":"logs","APS5_TRACE_FRAMES":"0:5"}):
    • Uncached compute pipelines (aps5-trace-ca74ef2177ee-32164.json.gz vs aps5-trace-320a4b6a1946-49392.json.gz):
      • Driver.Dispatch on queue workers decreased from 1736.797 to 1514.524 ms/frame (-222.273 ms/frame, -12.80%), with Vulkan.ComputePipeline (283.563 ms/frame) offloaded to the 8-thread RegistrationPreparePool::Prebuild() pool (VulkanDevice::PrebuildComputePipeline) and GpuMutex.wait.dispatch (336.444 ms/frame on main, 1211.4 ms longest wait) dropping out of the top phases.
    • Warm cache (aps5-trace-ca74ef2177ee-42280.json.gz vs aps5-trace-320a4b6a1946-33128.json.gz):
      • Driver.Packet decreased from 8075.118 to 7991.086 ms/frame (-1.04%), Driver.Packet.dispatch decreased from 1518.775 to 1445.265 ms/frame (-4.84%), Vulkan.Dispatch decreased from 429.674 to 385.267 ms/frame (-10.34%), Vulkan.Dispatch.shader_resources decreased from 419.597 to 373.257 ms/frame (-11.04%), and frame_ms.p90 / max decreased from 5066.419 to 5030.990 ms (-35.429 ms, -0.70%).
    • Updated the PR body with the default-environment tools/trace_digest.py outputs.

4. DispatchAheadPrewarm test assertions (PreparedShaders.cpp)

Updated DispatchAheadPrewarm in core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp so that:

  • The first DISPATCH_DIRECT in the submission targets an unregistered invalid shader (0xbf9f0000u), which causes both the group-capture loop in resolveGroupAhead and Driver::execute to stop at the first dispatch before reaching the second or third dispatch.
  • The second DISPATCH_DIRECT targets pendingHeader (with pending = true and demanded = false), and the third DISPATCH_DIRECT (via LOAD_SH_REG_INDEX 0x63) targets lazyHeader at lazyCode.data() + 64 (codeOffset == 64).
  • Only the look-ahead preview scan in resolveGroupAhead reaches the second and third dispatches, and the test asserts both post-conditions:
    • Require(pendingSnapshot->prepared->demanded.load(std::memory_order_acquire), "dispatch ahead did not prioritize the pending shader");
    • Require(lazySnapshot->prepared->entries.size() == 1 && lazySnapshot->prepared->entries.front().codeOffset == 64 && lazySnapshot->prepared->entries.front().handle != nullptr, "dispatch ahead did not prewarm the lazy shader for its dispatched offset");
  • Verified that disabling the look-ahead block in DispatchAhead.cpp causes agc_driver_prepared_shaders_registered_workgroup to fail immediately (exit code 8).

Verification & gcov Diff Coverage

  • Vulkan validation: Ran ctest --test-dir build-portable -R "^(agc_driver_gpu_indirect_arguments_written_ahead|agc_driver_gpu_indirect_arguments_misaligned_writer_ahead|agc_driver_indirect_arguments_written_ahead|agc_driver_write_data_written_ahead|agc_driver_prepared_shaders_registered_workgroup|agc_driver_pipelined_dispatch)$" -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation: 6/6 passed, 0 VUID- errors, and no missing layer warnings.
  • gcov diff coverage: 89 / 89 executable lines covered (100.0%) across Dispatch.cpp (4/4), DispatchAhead.cpp (68/68), ShaderRegistry.cpp (1/1), and VulkanDevice.cpp (16/16).
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312019450 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#issuecomment-6312019450). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-21T08:53:46Z. --- @oneandonlydean Thanks for the thorough review! Addressed all four items in `320a4b6a19`: ### 1. `APS5_GROUP_CAPTURE_ALL_QUEUES` opt-in on queue 0 Restored `static const bool allQueues = std::getenv("APS5_GROUP_CAPTURE_ALL_QUEUES") != nullptr;` in `Driver::resolveGroupAhead` (`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp`) so queue 0 remains opt-in by default, matching `main` and `docs/dev/ENVIRONMENT.md`. ### 2. `partialThreads = {1, 1, 1}` variant in `PrepareRegistered` Restored the `if (request.context.compute) { request.context.compute->partialThreads = {1, 1, 1}; append(); } else if (request.context.pixel)` block in `PrepareRegistered` (`core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp`) so dispatches with a partial last workgroup continue to hit the registration-prepared artifact instead of compiling on the queue worker. ### 3. Look-ahead on uncaptured dispatches, bounded scan, and default-environment `trace_digest.py` - Reverted `core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp` to `main` so `resolveGroupAhead` only runs when `gateOpened()` is `true` (never on uncaptured dispatches). - Bounded the look-ahead preview loop in `Driver::resolveGroupAhead` (`DispatchAhead.cpp`) so it stops at the next wait/synchronization boundary (`header == FlipPacketHeader || header == RenderingWaitPacketHeader || opcode == 0x22 || opcode == 0x3f || opcode == 0x3c || opcode == 0x93`) instead of scanning to the end of the submission on every gate. Also removed the unused `IndirectRegisterOpcode` branch from the second (group-capture) loop so group-capture semantics match `main`. - Re-ran the `main` (`ca74ef2177ee`) vs PR (`320a4b6a1946`) comparison on Demon's Souls (`PPSA01341` v01.007.000, `frames 0:5`) with the **default environment** (`"env":{"APS5_TRACE_DIR":"logs","APS5_TRACE_FRAMES":"0:5"}`): - **Uncached compute pipelines (`aps5-trace-ca74ef2177ee-32164.json.gz` vs `aps5-trace-320a4b6a1946-49392.json.gz`)**: - `Driver.Dispatch` on queue workers decreased from **`1736.797` to `1514.524` ms/frame (`-222.273` ms/frame, `-12.80%`)**, with `Vulkan.ComputePipeline` (`283.563` ms/frame) offloaded to the 8-thread `RegistrationPreparePool::Prebuild()` pool (`VulkanDevice::PrebuildComputePipeline`) and `GpuMutex.wait.dispatch` (`336.444` ms/frame on `main`, `1211.4` ms longest wait) dropping out of the top phases. - **Warm cache (`aps5-trace-ca74ef2177ee-42280.json.gz` vs `aps5-trace-320a4b6a1946-33128.json.gz`)**: - `Driver.Packet` decreased from `8075.118` to `7991.086` ms/frame (`-1.04%`), `Driver.Packet.dispatch` decreased from `1518.775` to `1445.265` ms/frame (`-4.84%`), `Vulkan.Dispatch` decreased from `429.674` to `385.267` ms/frame (`-10.34%`), `Vulkan.Dispatch.shader_resources` decreased from `419.597` to `373.257` ms/frame (`-11.04%`), and `frame_ms.p90` / `max` decreased from `5066.419` to `5030.990` ms (`-35.429` ms, `-0.70%`). - Updated the PR body with the default-environment `tools/trace_digest.py` outputs. ### 4. `DispatchAheadPrewarm` test assertions (`PreparedShaders.cpp`) Updated `DispatchAheadPrewarm` in `core/libs/prx/libSceAgcDriver/tests/execution/PreparedShaders.cpp` so that: - The first `DISPATCH_DIRECT` in the submission targets an unregistered invalid shader (`0xbf9f0000u`), which causes both the group-capture loop in `resolveGroupAhead` and `Driver::execute` to stop at the first dispatch before reaching the second or third dispatch. - The second `DISPATCH_DIRECT` targets `pendingHeader` (with `pending = true` and `demanded = false`), and the third `DISPATCH_DIRECT` (via `LOAD_SH_REG_INDEX` `0x63`) targets `lazyHeader` at `lazyCode.data() + 64` (`codeOffset == 64`). - Only the look-ahead preview scan in `resolveGroupAhead` reaches the second and third dispatches, and the test asserts both post-conditions: - `Require(pendingSnapshot->prepared->demanded.load(std::memory_order_acquire), "dispatch ahead did not prioritize the pending shader");` - `Require(lazySnapshot->prepared->entries.size() == 1 && lazySnapshot->prepared->entries.front().codeOffset == 64 && lazySnapshot->prepared->entries.front().handle != nullptr, "dispatch ahead did not prewarm the lazy shader for its dispatched offset");` - Verified that disabling the look-ahead block in `DispatchAhead.cpp` causes `agc_driver_prepared_shaders_registered_workgroup` to fail immediately (`exit code 8`). ### Verification & `gcov` Diff Coverage - **Vulkan validation**: Ran `ctest --test-dir build-portable -R "^(agc_driver_gpu_indirect_arguments_written_ahead|agc_driver_gpu_indirect_arguments_misaligned_writer_ahead|agc_driver_indirect_arguments_written_ahead|agc_driver_write_data_written_ahead|agc_driver_prepared_shaders_registered_workgroup|agc_driver_pipelined_dispatch)$" -V` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: **6/6 passed**, **0 `VUID-` errors**, and no missing layer warnings. - **`gcov` diff coverage**: **89 / 89 executable lines covered (`100.0%`)** across `Dispatch.cpp` (`4/4`), `DispatchAhead.cpp` (`68/68`), `ShaderRegistry.cpp` (`1/1`), and `VulkanDevice.cpp` (`16/16`).
oneandonlydean commented 2026-10-21 09:08:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T09:08:18Z.


@hamb3r thanks, 320a4b6a19 covers all four. Queue 0 is opt-in again, the {1, 1, 1} registration variant is back, PacketExecution.cpp matches main, the preview loop stops at the next wait or synchronization packet, and DispatchAheadPrewarm now fails without the look-ahead. The default-environment numbers are useful too.

One default change is still in: the Prebuild() pool in ShaderRegistry.cpp goes from 1 thread to max(2, hardware_concurrency / 2) when APS5_PREBUILD_THREADS is unset. That is 16 threads on a 32-thread host, competing with the title's threads, and the pool now also builds compute pipelines (PrebuildComputePipeline). docs/dev/ENVIRONMENT.md still documents the default as 1 ("the one-thread pool"). Could the default stay at 1 here, with your measured setting given in the description (APS5_PREBUILD_THREADS=8)? If you think the larger default is right, please update the ENVIRONMENT.md row and show that a default run doesn't slow the title's own threads.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312285634 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#issuecomment-6312285634). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-21T09:08:18Z. --- @hamb3r thanks, `320a4b6a19` covers all four. Queue 0 is opt-in again, the `{1, 1, 1}` registration variant is back, `PacketExecution.cpp` matches `main`, the preview loop stops at the next wait or synchronization packet, and `DispatchAheadPrewarm` now fails without the look-ahead. The default-environment numbers are useful too. One default change is still in: the `Prebuild()` pool in `ShaderRegistry.cpp` goes from 1 thread to `max(2, hardware_concurrency / 2)` when `APS5_PREBUILD_THREADS` is unset. That is 16 threads on a 32-thread host, competing with the title's threads, and the pool now also builds compute pipelines (`PrebuildComputePipeline`). `docs/dev/ENVIRONMENT.md` still documents the default as 1 ("the one-thread pool"). Could the default stay at 1 here, with your measured setting given in the description (`APS5_PREBUILD_THREADS=8`)? If you think the larger default is right, please update the `ENVIRONMENT.md` row and show that a default run doesn't slow the title's own threads.
hamb3r commented 2026-10-21 09:38:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hamb3r on 2026-10-21T09:38:21Z.


@oneandonlydean Restored the default RegistrationPreparePool::Prebuild() thread count to 1 in 0070aeafce (ShaderRegistry.cpp now has zero diff against main), and updated Driver::dispatch from if (compiledResult != nullptr) to if (!cached && compiledResult != nullptr) before calling SubmitLibraryPrebuild.

Why 8 -> 1 initially needed the !cached guard

When we first re-tested with the default 1-thread Prebuild() pool (839cabd6c7ba), cold-cache Driver.Dispatch was 1753.363 ms/frame (vs 1736.797 ms/frame on main):

  • Without !cached, every dispatch that hit the dispatch cache (cached == true) still re-submitted PrebuildComputePipeline to RegistrationPreparePool::Prebuild().
  • An 8-thread pool masked those redundant tasks, whereas on the 1-thread pool they queued behind already-cached shaders and contended with queue workers on computePipelinesMutex, starving genuinely new pipelines discovered ahead of time by resolveGroupAhead.

Guarding SubmitLibraryPrebuild with if (!cached && compiledResult != nullptr) ensures only dispatch-cache misses enqueue prebuild work, so the single default prebuild thread spends its time exclusively on new compute pipelines (Vulkan.ComputePipeline on the shader prepare prebuild thread increased from 28.3 to 35.9 ms/frame, +26.9%) and achieves nearly the same result as 8 threads without extra host threads:

Metric (frames 0:5, cold pipeline cache) main (ca74ef2177ee) 1 thread without !cached (839cabd6c7ba) 1 thread default + !cached (0070aeafce7d) APS5_PREBUILD_THREADS=8 (320a4b6a1946)
Driver.Dispatch (ms/frame) 1736.797 1753.363 (+0.95%) 1533.562 (-203.235 ms, -11.70%) 1514.524 (-222.273 ms, -12.80%)
Driver.Dispatch.materialize (ms/frame) 581.184 561.787 (-3.34%) 542.662 (-38.522 ms, -6.63%) 601.088 (+3.42%)
GpuMutex.wait.dispatch (ms/frame) 336.444 (max 1211.4 ms) 314.950 (max 1227.3 ms) out of top phases & top 10 waits out of top phases & top 10 waits

Updated the PR description with the full tools/trace_digest.py summaries for both the default 1-thread configuration (0070aeafce7d) and APS5_PREBUILD_THREADS=8 (320a4b6a1946).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6312836320 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#issuecomment-6312836320). Originally posted by [hamb3r](https://github.com/hamb3r) on 2026-10-21T09:38:21Z. --- @oneandonlydean Restored the default `RegistrationPreparePool::Prebuild()` thread count to `1` in `0070aeafce` (`ShaderRegistry.cpp` now has zero diff against `main`), and updated [`Driver::dispatch`](https://github.com/boykopovar/AnyPS5/blob/0070aeafce7d655ff0eb349811b3b4e0d8c7a8d9/core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cpp#L402) from `if (compiledResult != nullptr)` to `if (!cached && compiledResult != nullptr)` before calling `SubmitLibraryPrebuild`. ### Why `8 -> 1` initially needed the `!cached` guard When we first re-tested with the default 1-thread `Prebuild()` pool (`839cabd6c7ba`), cold-cache `Driver.Dispatch` was `1753.363` ms/frame (vs `1736.797` ms/frame on `main`): - Without `!cached`, every dispatch that hit the dispatch cache (`cached == true`) still re-submitted `PrebuildComputePipeline` to `RegistrationPreparePool::Prebuild()`. - An 8-thread pool masked those redundant tasks, whereas on the 1-thread pool they queued behind already-cached shaders and contended with queue workers on `computePipelinesMutex`, starving genuinely new pipelines discovered ahead of time by `resolveGroupAhead`. Guarding `SubmitLibraryPrebuild` with `if (!cached && compiledResult != nullptr)` ensures only dispatch-cache misses enqueue prebuild work, so the single default prebuild thread spends its time exclusively on new compute pipelines (`Vulkan.ComputePipeline` on the `shader prepare` prebuild thread increased from `28.3` to `35.9` ms/frame, `+26.9%`) and achieves nearly the same result as 8 threads without extra host threads: | Metric (`frames 0:5`, cold pipeline cache) | `main` (`ca74ef2177ee`) | 1 thread without `!cached` (`839cabd6c7ba`) | **1 thread default + `!cached` (`0070aeafce7d`)** | `APS5_PREBUILD_THREADS=8` (`320a4b6a1946`) | |---|---:|---:|---:|---:| | `Driver.Dispatch` (ms/frame) | `1736.797` | `1753.363` (`+0.95%`) | **`1533.562` (`-203.235` ms, `-11.70%`)** | `1514.524` (`-222.273` ms, `-12.80%`) | | `Driver.Dispatch.materialize` (ms/frame) | `581.184` | `561.787` (`-3.34%`) | **`542.662` (`-38.522` ms, `-6.63%`)** | `601.088` (`+3.42%`) | | `GpuMutex.wait.dispatch` (ms/frame) | `336.444` (max `1211.4` ms) | `314.950` (max `1227.3` ms) | **out of top phases & top 10 waits** | out of top phases & top 10 waits | Updated the PR description with the full `tools/trace_digest.py` summaries for both the default 1-thread configuration (`0070aeafce7d`) and `APS5_PREBUILD_THREADS=8` (`320a4b6a1946`).
adriadam10 commented 2026-10-23 18:42:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T18:42:56Z.

Review: CHANGES_REQUESTED


Thanks for the fixes to the earlier notes. Remaining points:

  • The default configuration doesn't show a gain in your own traces. With the default 1-thread pool (0070aeafce7d), warm cache vs main: Driver.Dispatch 1258 → 1574 ms/frame, Driver.Packet 8075 → 8941 ms/frame, frame_ms.p90 5066 → 5574 ms; cold: frame_ms.max 6360 → 6804 ms. The warm improvements in the description are from APS5_PREBUILD_THREADS=8, which is not the default. Please either show repeated runs (medians, same scene) where the default build is better, or scope the claim to what is measured. A single 5-frame window dominated by the first-frame stall (4.9 s memory_wait) is too noisy to separate a 10 % change.
  • DispatchAhead.cpp:150-194, :195-202 and Dispatch.cpp:419: new catch (...) {} blocks swallow every exception, including emulator invariants (main has none in DispatchAhead.cpp). Catch the specific exceptions the preview/prebuild can legitimately throw, or let the rest propagate.
  • docs/dev/ARCHITECTURE.md: the new compute prebuild on the library prebuild pool and the dispatch look-ahead that prioritizes/prepares registrations change the pipeline description; please add it next to the PrebuildStageLibrary paragraph.
  • tests/execution/PreparedShaders.cpp:1447-1448: DispatchAheadPrewarm() is hooked into the --registered-workgroup mode and device is reset there; please give it its own mode/test entry instead of piggybacking on an unrelated one.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5632977295 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#pullrequestreview-5632977295). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-23T18:42:56Z. **Review:** CHANGES_REQUESTED --- Thanks for the fixes to the earlier notes. Remaining points: - **The default configuration doesn't show a gain in your own traces.** With the default 1-thread pool (`0070aeafce7d`), warm cache vs `main`: `Driver.Dispatch` 1258 → 1574 ms/frame, `Driver.Packet` 8075 → 8941 ms/frame, `frame_ms.p90` 5066 → 5574 ms; cold: `frame_ms.max` 6360 → 6804 ms. The warm improvements in the description are from `APS5_PREBUILD_THREADS=8`, which is not the default. Please either show repeated runs (medians, same scene) where the default build is better, or scope the claim to what is measured. A single 5-frame window dominated by the first-frame stall (4.9 s `memory_wait`) is too noisy to separate a 10 % change. - `DispatchAhead.cpp:150-194`, `:195-202` and `Dispatch.cpp:419`: new `catch (...) {}` blocks swallow every exception, including emulator invariants (`main` has none in `DispatchAhead.cpp`). Catch the specific exceptions the preview/prebuild can legitimately throw, or let the rest propagate. - `docs/dev/ARCHITECTURE.md`: the new compute prebuild on the library prebuild pool and the dispatch look-ahead that prioritizes/prepares registrations change the pipeline description; please add it next to the `PrebuildStageLibrary` paragraph. - `tests/execution/PreparedShaders.cpp:1447-1448`: `DispatchAheadPrewarm()` is hooked into the `--registered-workgroup` mode and `device` is reset there; please give it its own mode/test entry instead of piggybacking on an unrelated one.
adriadam10 commented 2026-10-24 07:24:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T07:24:55Z.

Review: CHANGES_REQUESTED


Thanks for the scoping and the length gating; the correctness points from MarcZX10 and oneandonlydean are resolved on cb29f63d43, and the merge with current main is clean.

Requesting changes on the performance claim:

  • In the default configuration, your own warm-cache traces are worse than main: Driver.Dispatch 1258.0 → 1574.6 ms/frame, Driver.Packet 8075 → 8941 ms/frame, frame_ms.p90 5066.4 → 5574.6 ms (aps5-trace-ca74ef2177ee-42280.json.gz vs aps5-trace-0070aeafce7d-42312.json.gz).
  • The only improvement shown in the default configuration is one cold 5-frame run (Driver.Dispatch 1736.8 → 1533.6 ms/frame), with no repetitions.

Please provide at least 3 runs per side (main and this branch, same machine, same scene, default environment), with medians for cold and warm cache. If warm stays slower in the default configuration, either make the prebuild and group-ahead preview opt-in or drop the default-on claim from the description.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5637327418 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8735#pullrequestreview-5637327418). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-24T07:24:55Z. **Review:** CHANGES_REQUESTED --- Thanks for the scoping and the length gating; the correctness points from MarcZX10 and oneandonlydean are resolved on `cb29f63d43`, and the merge with current `main` is clean. Requesting changes on the performance claim: - In the default configuration, your own warm-cache traces are worse than `main`: `Driver.Dispatch` 1258.0 → 1574.6 ms/frame, `Driver.Packet` 8075 → 8941 ms/frame, `frame_ms.p90` 5066.4 → 5574.6 ms (`aps5-trace-ca74ef2177ee-42280.json.gz` vs `aps5-trace-0070aeafce7d-42312.json.gz`). - The only improvement shown in the default configuration is one cold 5-frame run (`Driver.Dispatch` 1736.8 → 1533.6 ms/frame), with no repetitions. Please provide at least 3 runs per side (main and this branch, same machine, same scene, default environment), with medians for cold and warm cache. If warm stays slower in the default configuration, either make the prebuild and group-ahead preview opt-in or drop the default-on claim from the description.
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!8735
No description provided.