perf(agc): leave a capture's branch over a pending GPU write unpruned instead of waiting #12616

Merged
Raghav314 merged 2 commits from upstream-pr/12616 into main 2026-11-02 13:39:00 +00:00
Raghav314 commented 2026-10-28 23:02:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Raghav314 on 2026-10-28T23:02:41Z.


What

A dispatch's resource capture prunes the untaken side of a scalar branch by evaluating the branch condition on the CPU. When the condition word has a pending GPU write (typically a flag in a constant buffer that the previous compute dispatch wrote), ShaderMemory waits for that GPU work before it can read the word.

Changes:

  • Recompiler: SrtEvaluatingBranch() is a thread-local flag. SrtBranchScope sets it around the branch-condition evaluation in both SRT walkers (SrtDescriptorEvaluation.cpp and SrtTape.cpp), and only there.
  • Capture: inside that scope, ShaderMemory::read does not wait for a word-wise word whose pending write needs a sync; it reports the read as unavailable instead. The walkers already treat an unreadable condition as not cleanly evaluable and keep both successors, so the capture becomes a superset: it includes the resources of both sides, and the GPU shader still evaluates the real branch.
    • Only words read solely for a branch are affected. A flag that is also a flat slot (a scalar SRT load the recompiled shader receives as data) is read right after the walk and still waits, because the GPU needs its value.
  • Redo on failure: the superset can reach a descriptor that the pruned walk would never have read. For example, an invalid T# behind a branch whose flag says "no texture" throws runtime image descriptor is invalid. When a capture that refused a branch read throws, ShaderMemory::Capture redoes it once with waiting on, which is exactly main's behaviour.
  • Kill switch: APS5_WAIT_PENDING_BRANCHES restores waiting, with a row in docs/dev/ENVIRONMENT.md.
  • Counters: the [capture] line (APS5_PROFILE_DRAW) counts refused branch reads and redone captures.
  • Disk-cache review list: SrtEvaluatingBranch is added to the shader disk cache's reviewed names. It does not change compiled output.

Why

In the APS5_PROFILE_DRAW diagnostic runs, main's capture waited word by word for 4,927 words, 8.77 s per 90 s. Every one of those waits was a branch-condition read; a diagnostic build classified each waited word by consumer, and only branch was non-zero. With the change, those waits are 0, and about 8,700 branch-condition reads per 90 s leave their branch unpruned instead. Capture time fell from 12.5 s to 4.2 s.

Tested

Performance

Minecraft Dungeons II (PPSA16064, gameplay, same spot), RTX 4090, 3840x2160, warm caches. The runs alternated main, change, main, change, main, change in one session. APS5_TRACE_SECONDS=50:8 was the only switch.

Run Commit Presents (8 s) p50 ms p90 ms p99 ms GPU busy ms/present Driver.Packet.dispatch ms/frame Driver.Packet.memory_wait ms/frame
main (CM1) 319621ba2e 142 55.6 58.3 87.2 38.6 41.8 34.6
change (CC1) 5c4323035f 145 54.6 57.2 84.4 38.6 35.2 30.3
main (CM2) 319621ba2e 134 59.0 62.0 88.2 39.7 41.6 34.6
change (CC2) 5c4323035f 146 54.4 57.6 84.7 38.2 35.3 30.0
main (CM3) 319621ba2e 142 55.5 58.4 86.7 38.4 41.7 35.0
change (CF1) 7a13a20b84 143 55.5 58.1 87.2 39.4 36.1 30.9
  • Dispatch time: the compute worker's Driver.Packet.dispatch falls by about 6 ms per frame in every pair (41.6–41.8 → 35.2–36.1), and Driver.Dispatch.capture_resources (11.8 ms per frame on main) leaves the top slices.
  • GPU time: unchanged.
  • Frame time:
    • main varies between runs, at 55.5, 55.6 and 59.0 ms p50, depending on how long its capture waits for the GPU.
    • the change holds 54.4–55.5 ms.
    • Mean p50 goes from 56.7 to 54.8 ms (−3.3 %), and p99 improves in 2 of 3 pairs.
    • In the last pair the freed compute-worker time did not reach the frame: queue 0 is now the critical path, and its Driver.Packet.pipeline_drain grows.

Notes:

  • Main currently aborts the title at boot in sceHttp2SetResolveRetry ("not implemented", the new nghttp2 libSceHttp2). Both arms used the same older libSceHttp2.prx so they could reach gameplay; that library is not on the graphics path.
  • The log went to a file in both arms because the runs were headless.

Traces (release assets on the fork):

Summary lines
{"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1843,"ms":8018.023},"presents":142,"frame_ms":{"p50":55.565,"p90":58.326,"p99":87.249,"max":91.517},"gpu_busy_ms_per_present":38.553,"worker_busy_pct":{"queue worker 0x0":99.235,"queue worker 0x20":99.412},"top_phases_ms_per_frame":{"Driver.Packet":112.104,"Driver.Packet.dispatch":42.377,"Driver.Dispatch":41.278,"Driver.Packet.memory_wait":34.675,"Vulkan.Dispatch":15.632,"Vulkan.Dispatch.shader_resources":13.856,"Driver.Packet.pipeline_drain":13.792,"Driver.Dispatch.capture_resources":13.087},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-347497.json.gz"}
{"commit":"5c4323035f7e","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1846,"ms":8027.163},"presents":145,"frame_ms":{"p50":54.601,"p90":57.177,"p99":84.355,"max":85.158},"gpu_busy_ms_per_present":38.598,"worker_busy_pct":{"queue worker 0x0":99.196,"queue worker 0x20":99.398},"top_phases_ms_per_frame":{"Driver.Packet":109.875,"Driver.Packet.dispatch":35.824,"Driver.Dispatch":35.206,"Driver.Packet.memory_wait":30.382,"Driver.Packet.pipeline_drain":17.476,"Vulkan.Dispatch":12.384,"Driver.Packet.draw":12.082,"Driver.Draw":12.015},"trace_dropped":false,"trace":"aps5-trace-5c4323035f7e-349192.json.gz"}
{"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1819,"ms":8019.215},"presents":134,"frame_ms":{"p50":59.041,"p90":61.983,"p99":88.236,"max":89.663},"gpu_busy_ms_per_present":39.678,"worker_busy_pct":{"queue worker 0x0":99.255,"queue worker 0x20":99.721},"top_phases_ms_per_frame":{"Driver.Packet":119.013,"Driver.Packet.dispatch":42.138,"Driver.Dispatch":39.408,"Driver.Packet.memory_wait":34.681,"Driver.Packet.draw":16.870,"Driver.Draw":16.804,"Graphics.Draw":15.811,"Vulkan.Dispatch":14.636},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-350783.json.gz"}
{"commit":"5c4323035f7e","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1842,"ms":8041.677},"presents":146,"frame_ms":{"p50":54.412,"p90":57.569,"p99":84.731,"max":86.556},"gpu_busy_ms_per_present":38.209,"worker_busy_pct":{"queue worker 0x0":99.214,"queue worker 0x20":99.558},"top_phases_ms_per_frame":{"Driver.Packet":109.416,"Driver.Packet.dispatch":35.843,"Driver.Dispatch":35.214,"Driver.Packet.memory_wait":30.047,"Driver.Packet.pipeline_drain":17.350,"Vulkan.Dispatch":12.624,"Driver.Packet.draw":11.949,"Driver.Draw":11.886},"trace_dropped":false,"trace":"aps5-trace-5c4323035f7e-352238.json.gz"}
{"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1847,"ms":8004.597},"presents":142,"frame_ms":{"p50":55.472,"p90":58.434,"p99":86.672,"max":87.648},"gpu_busy_ms_per_present":38.397,"worker_busy_pct":{"queue worker 0x0":99.227,"queue worker 0x20":99.264},"top_phases_ms_per_frame":{"Driver.Packet":111.827,"Driver.Packet.dispatch":42.321,"Driver.Dispatch":41.249,"Driver.Packet.memory_wait":35.028,"Vulkan.Dispatch":15.566,"Vulkan.Dispatch.shader_resources":13.789,"Driver.Packet.pipeline_drain":13.423,"Driver.Dispatch.capture_resources":13.293},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-372833.json.gz"}
{"commit":"7a13a20b844f","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1850,"ms":8055.855},"presents":143,"frame_ms":{"p50":55.474,"p90":58.058,"p99":87.241,"max":91.610},"gpu_busy_ms_per_present":39.408,"worker_busy_pct":{"queue worker 0x0":99.222,"queue worker 0x20":99.704},"top_phases_ms_per_frame":{"Driver.Packet":112.002,"Driver.Packet.dispatch":36.687,"Driver.Dispatch":36.092,"Driver.Packet.memory_wait":30.933,"Driver.Packet.pipeline_drain":18.307,"Vulkan.Dispatch":12.861,"Driver.Packet.draw":12.141,"Driver.Draw":12.072},"trace_dropped":false,"trace":"aps5-trace-7a13a20b844f-374000.json.gz"}
trace_digest: main (CM3)

seconds 50:8 from present 1847: 142 presents, frame p50 55.5 / p90 58.4 / p99 86.7 / max 87.6 ms, GPU busy 38.4 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit 319621ba2e, dropped: no

{"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1847,"ms":8004.597},"presents":142,"frame_ms":{"p50":55.472,"p90":58.434,"p99":86.672,"max":87.648},"gpu_busy_ms_per_present":38.397,"worker_busy_pct":{"queue worker 0x0":99.227,"queue worker 0x20":99.264},"top_phases_ms_per_frame":{"Driver.Packet":111.827,"Driver.Packet.dispatch":42.321,"Driver.Dispatch":41.249,"Driver.Packet.memory_wait":35.028,"Vulkan.Dispatch":15.566,"Vulkan.Dispatch.shader_resources":13.789,"Driver.Packet.pipeline_drain":13.423,"Driver.Dispatch.capture_resources":13.293},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-372833.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1936: 87.6 ms at 5005 ms: Driver.Packet (queue worker 0x20) 86.2, Driver.Packet (queue worker 0x0) 82.6, Driver.Packet.memory_wait (queue worker 0x20) 53.9, Driver.Packet.draw (queue worker 0x0) 43.7
  • present 1890: 86.7 ms at 2422 ms: Driver.Packet (queue worker 0x20) 85.2, Driver.Packet (queue worker 0x0) 80.9, Driver.Packet.memory_wait (queue worker 0x20) 52.1, Driver.Packet.draw (queue worker 0x0) 40.8
  • present 1982: 86.1 ms at 7583 ms: Driver.Packet (queue worker 0x20) 84.8, Driver.Packet (queue worker 0x0) 81.1, Driver.Packet.dispatch (queue worker 0x20) 58.9, Driver.Dispatch (queue worker 0x20) 58.1
  • present 1882: 59.8 ms at 1974 ms: Driver.Packet (queue worker 0x20) 58.4, Driver.Packet (queue worker 0x0) 54.3, batch (gpu) 41.5, Driver.Packet.dispatch (queue worker 0x20) 28.0
  • present 1900: 59.8 ms at 3017 ms: Driver.Packet (queue worker 0x20) 58.3, Driver.Packet (queue worker 0x0) 54.3, batch (gpu) 38.7, Driver.Packet.dispatch (queue worker 0x20) 25.0

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 36.2 (64 %) 14.4 (26 %) 5.7 30.9 Driver.Packet 50.7, Driver.EndSubmission 0.0
draw committer 10.1 (18 %) 2.2 (4 %) 44.0 5.4 Graphics.Draw 6.7, Recorder.Sync 3.2
queue worker 0x20 21.5 (38 %) 33.4 (59 %) 1.5 7.3 Driver.Packet 54.6, Driver.EndSubmission 0.0
presenter 0.3 (0 %) 0.0 (0 %) 56.1 0.1 VideoOut.Flip 0.3, Driver.Present 0.0
gpu 38.4 (68 %) 0.0 (0 %) 18.0 0.0 batch 38.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 105.3, Driver.Packet.dispatch 41.7, Driver.Dispatch 40.1, batch 38.4, Driver.Packet.memory_wait 35.0, Vulkan.Dispatch 14.6, Vulkan.Dispatch.shader_resources 12.8, Driver.Packet.pipeline_drain 12.2, Driver.Dispatch.capture_resources 11.8, Driver.Packet.draw 10.4

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x20) 43.6 ms at 2466 ms, present 1890
  • Driver.Packet.memory_wait (queue worker 0x20) 35.0 ms at 5005 ms, present 1936
  • Driver.Packet.memory_wait (queue worker 0x0) 16.5 ms at 3985 ms, present 1917
  • Driver.Packet.memory_wait (queue worker 0x0) 16.5 ms at 4864 ms, present 1933
  • Driver.Packet.memory_wait (queue worker 0x0) 16.4 ms at 1386 ms, present 1871
  • Driver.Packet.memory_wait (queue worker 0x0) 16.2 ms at 6180 ms, present 1956
  • Driver.Packet.memory_wait (queue worker 0x0) 16.0 ms at 4976 ms, present 1935
  • Driver.Packet.memory_wait (queue worker 0x0) 16.0 ms at 1773 ms, present 1878
  • Driver.Packet.memory_wait (queue worker 0x0) 15.9 ms at 4810 ms, present 1932
  • Driver.Packet.memory_wait (queue worker 0x0) 15.9 ms at 5288 ms, present 1940

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

  • batch 4048: 6.8 ms at 3583 ms, present 1910: GPU no ranges; recorded by Driver.Packet (queue worker 0x20) 1.9, Driver.Packet.dispatch (queue worker 0x20) 1.8, Driver.Dispatch (queue worker 0x20) 0.7, Vulkan.Dispatch (queue worker 0x20) 0.3
  • batch 676: 6.4 ms at 584 ms, present 1857: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.3, GpuMutex.wait.draw (draw committer) 0.2, GpuMutex.wait.label (draw committer) 0.1
  • batch 4829: 6.1 ms at 4303 ms, present 1923: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 6.0, Driver.Packet (queue worker 0x0) 1.6, Driver.Packet.draw (queue worker 0x0) 1.4, Driver.Draw (queue worker 0x0) 1.4
  • batch 1957: 5.3 ms at 1718 ms, present 1877: GPU no ranges; recorded by GpuMutex.wait.draw (draw committer) 6.2, Graphics.Draw (draw committer) 0.9, Graphics.Draw.draw_and_resource_release (draw committer) 0.7, Resources.Complete (draw committer) 0.1
  • batch 994: 5.2 ms at 874 ms, present 1862: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 6.5, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, GpuMutex.wait.draw (draw committer) 0.2
trace_digest: change (CF1)

seconds 50:8 from present 1850: 143 presents, frame p50 55.5 / p90 58.1 / p99 87.2 / max 91.6 ms, GPU busy 39.4 ms per present
NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit 7a13a20b84, dropped: no

{"commit":"7a13a20b844f","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1850,"ms":8055.855},"presents":143,"frame_ms":{"p50":55.474,"p90":58.058,"p99":87.241,"max":91.61},"gpu_busy_ms_per_present":39.408,"worker_busy_pct":{"queue worker 0x0":99.222,"queue worker 0x20":99.704},"top_phases_ms_per_frame":{"Driver.Packet":112.002,"Driver.Packet.dispatch":36.687,"Driver.Dispatch":36.092,"Driver.Packet.memory_wait":30.933,"Driver.Packet.pipeline_drain":18.307,"Vulkan.Dispatch":12.861,"Driver.Packet.draw":12.141,"Driver.Draw":12.072},"trace_dropped":false,"trace":"aps5-trace-7a13a20b844f-374000.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 1978: 91.6 ms at 7167 ms: Driver.Packet (queue worker 0x20) 90.2, Driver.Packet (queue worker 0x0) 86.2, Driver.Packet.memory_wait (queue worker 0x20) 54.8, Driver.Packet.dispatch (queue worker 0x0) 45.2
  • present 1932: 87.2 ms at 4545 ms: Driver.Packet (queue worker 0x20) 85.9, Driver.Packet (queue worker 0x0) 81.3, Driver.Packet.memory_wait (queue worker 0x20) 53.2, Driver.Packet.draw (queue worker 0x0) 42.9
  • present 1887: 86.3 ms at 2037 ms: Driver.Packet (queue worker 0x20) 84.9, Driver.Packet (queue worker 0x0) 81.1, Driver.Packet.dispatch (queue worker 0x20) 57.0, Driver.Dispatch (queue worker 0x20) 56.2
  • present 1992: 61.4 ms at 7994 ms: Driver.Packet (queue worker 0x0) 55.6, Driver.Packet (queue worker 0x20) 47.4, batch (gpu) 41.4, Driver.Packet.pipeline_drain (queue worker 0x0) 31.3
  • present 1896: 60.9 ms at 2563 ms: Driver.Packet (queue worker 0x20) 59.6, Driver.Packet (queue worker 0x0) 54.8, batch (gpu) 38.7, Driver.Packet.memory_wait (queue worker 0x20) 26.0

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
queue worker 0x0 39.1 (69 %) 11.5 (20 %) 5.7 31.1 Driver.Packet 50.6, Driver.EndSubmission 0.0
draw committer 9.8 (17 %) 6.7 (12 %) 39.8 5.4 Graphics.Draw 7.3, Recorder.Sync 2.3
queue worker 0x20 16.8 (30 %) 38.2 (68 %) 1.4 7.1 Driver.Packet 54.9, Driver.EndSubmission 0.0
presenter 0.3 (0 %) 0.0 (0 %) 56.0 0.1 VideoOut.Flip 0.3, Driver.Present 0.0
gpu 39.4 (70 %) 0.0 (0 %) 16.9 0.0 batch 39.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 105.5, batch 39.4, Driver.Packet.dispatch 36.1, Driver.Dispatch 35.0, Driver.Packet.memory_wait 30.9, Driver.Packet.pipeline_drain 17.1, Vulkan.Dispatch 11.9, Driver.Packet.draw 10.6, Driver.Draw 10.5, Vulkan.Dispatch.shader_resources 10.0

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x20) 46.4 ms at 7213 ms, present 1978
  • Driver.Packet.memory_wait (queue worker 0x20) 44.0 ms at 4588 ms, present 1932
  • Driver.Packet.memory_wait (queue worker 0x0) 14.6 ms at 916 ms, present 1866
  • Driver.Packet.memory_wait (queue worker 0x20) 14.0 ms at 6593 ms, present 1967
  • Driver.Packet.memory_wait (queue worker 0x0) 13.9 ms at 7402 ms, present 1981
  • Driver.Packet.memory_wait (queue worker 0x0) 13.9 ms at 6802 ms, present 1971
  • Driver.Packet.memory_wait (queue worker 0x20) 13.8 ms at 3429 ms, present 1911
  • Driver.Packet.memory_wait (queue worker 0x20) 13.7 ms at 7039 ms, present 1975
  • Driver.Packet.memory_wait (queue worker 0x0) 13.7 ms at 1027 ms, present 1868
  • Driver.Packet.memory_wait (queue worker 0x0) 13.7 ms at 6692 ms, present 1969

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

  • batch 6030: 7.3 ms at 6016 ms, present 1957: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 8.8, Driver.Packet (queue worker 0x20) 1.5, Driver.Packet.dispatch (queue worker 0x20) 1.2, Driver.Dispatch (queue worker 0x20) 1.1
  • batch 7997: 7.3 ms at 8030 ms, present 1992: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 8.5, Driver.Packet (queue worker 0x20) 1.2, Driver.Packet.dispatch (queue worker 0x20) 1.0, Driver.Dispatch (queue worker 0x20) 0.9
  • batch 196: 6.5 ms at 197 ms, present 1853: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 7.8, Driver.Packet (queue worker 0x20) 1.3, Driver.Packet.dispatch (queue worker 0x20) 0.8, Driver.Dispatch (queue worker 0x20) 0.8
  • batch 6532: 6.5 ms at 6521 ms, present 1966: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 6.5, Driver.Packet (queue worker 0x20) 1.5, Driver.Packet.dispatch (queue worker 0x20) 1.5, Driver.Dispatch (queue worker 0x20) 1.4
  • batch 884: 6.4 ms at 865 ms, present 1865: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 7.7, Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.4, Resources.Complete (draw committer) 0.1

Tests

  • New verifyPendingBranchLeftUnpruned (recompiler walkers): a condition read inside the branch scope that cannot be read keeps both successors, the tape walk and the tree walk agree, and the scope is closed afterwards.

  • New verifyPendingBranchCapture (ShaderMemory): the flag is loaded with s_buffer_load from a constant buffer that has a pending Sync write. The test checks three cases:

    1. no wait, and both successors are kept;
    2. an invalid T# behind the skipped successor makes the capture redo, which waits and prunes;
    3. an invalid T# behind the taken successor still fails, as on main.

    It fails with APS5_WAIT_PENDING_BRANCHES=1 and fails with the redo removed.

  • Focused ctest (agc_shader_memory|srt|capture|agc_driver_dispatch|agc_driver_pipelined|agc_driver_storage|agc_driver_copied|wait|recompiler_plan) passed 117/117 on main and on the change, in both default and APS5_GPU_HEAP=1 modes. The runs used ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation and logged no VUID- lines.

  • tools/check_conventions.py --base origin/main and tools/env_reference.py --check both pass.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4090, driver 615.78.08, Linux 7.3.0-3-cachyos
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5059073181 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12616). Originally posted by [Raghav314](https://github.com/Raghav314) on 2026-10-28T23:02:41Z. --- ### What A dispatch's resource capture prunes the untaken side of a scalar branch by evaluating the branch condition on the CPU. When the condition word has a pending GPU write (typically a flag in a constant buffer that the previous compute dispatch wrote), `ShaderMemory` waits for that GPU work before it can read the word. **Changes:** - **Recompiler:** `SrtEvaluatingBranch()` is a thread-local flag. `SrtBranchScope` sets it around the branch-condition evaluation in both SRT walkers (`SrtDescriptorEvaluation.cpp` and `SrtTape.cpp`), and only there. - **Capture:** inside that scope, `ShaderMemory::read` does not wait for a word-wise word whose pending write needs a sync; it reports the read as unavailable instead. The walkers already treat an unreadable condition as not cleanly evaluable and keep both successors, so the capture becomes a superset: it includes the resources of both sides, and the GPU shader still evaluates the real branch. - Only words read solely for a branch are affected. A flag that is also a flat slot (a scalar SRT load the recompiled shader receives as data) is read right after the walk and still waits, because the GPU needs its value. - **Redo on failure:** the superset can reach a descriptor that the pruned walk would never have read. For example, an invalid T# behind a branch whose flag says "no texture" throws `runtime image descriptor is invalid`. When a capture that refused a branch read throws, `ShaderMemory::Capture` redoes it once with waiting on, which is exactly main's behaviour. - **Kill switch:** `APS5_WAIT_PENDING_BRANCHES` restores waiting, with a row in `docs/dev/ENVIRONMENT.md`. - **Counters:** the `[capture]` line (`APS5_PROFILE_DRAW`) counts refused branch reads and redone captures. - **Disk-cache review list:** `SrtEvaluatingBranch` is added to the shader disk cache's reviewed names. It does not change compiled output. #### Why In the `APS5_PROFILE_DRAW` diagnostic runs, main's capture waited word by word for 4,927 words, 8.77 s per 90 s. Every one of those waits was a branch-condition read; a diagnostic build classified each waited word by consumer, and only branch was non-zero. With the change, those waits are 0, and about 8,700 branch-condition reads per 90 s leave their branch unpruned instead. Capture time fell from 12.5 s to 4.2 s. ### Tested #### Performance Minecraft Dungeons II (PPSA16064, gameplay, same spot), RTX 4090, 3840x2160, warm caches. The runs alternated main, change, main, change, main, change in one session. `APS5_TRACE_SECONDS=50:8` was the only switch. | Run | Commit | Presents (8 s) | p50 ms | p90 ms | p99 ms | GPU busy ms/present | `Driver.Packet.dispatch` ms/frame | `Driver.Packet.memory_wait` ms/frame | |---|---|---|---|---|---|---|---|---| | main (CM1) | `319621ba2e` | 142 | 55.6 | 58.3 | 87.2 | 38.6 | 41.8 | 34.6 | | change (CC1) | `5c4323035f` | 145 | 54.6 | 57.2 | 84.4 | 38.6 | 35.2 | 30.3 | | main (CM2) | `319621ba2e` | 134 | 59.0 | 62.0 | 88.2 | 39.7 | 41.6 | 34.6 | | change (CC2) | `5c4323035f` | 146 | 54.4 | 57.6 | 84.7 | 38.2 | 35.3 | 30.0 | | main (CM3) | `319621ba2e` | 142 | 55.5 | 58.4 | 86.7 | 38.4 | 41.7 | 35.0 | | change (CF1) | `7a13a20b84` | 143 | 55.5 | 58.1 | 87.2 | 39.4 | 36.1 | 30.9 | - **Dispatch time:** the compute worker's `Driver.Packet.dispatch` falls by about 6 ms per frame in every pair (41.6–41.8 → 35.2–36.1), and `Driver.Dispatch.capture_resources` (11.8 ms per frame on main) leaves the top slices. - **GPU time:** unchanged. - **Frame time:** - main varies between runs, at 55.5, 55.6 and 59.0 ms p50, depending on how long its capture waits for the GPU. - the change holds 54.4–55.5 ms. - Mean p50 goes from 56.7 to 54.8 ms (−3.3 %), and p99 improves in 2 of 3 pairs. - In the last pair the freed compute-worker time did not reach the frame: queue 0 is now the critical path, and its `Driver.Packet.pipeline_drain` grows. Notes: - Main currently aborts the title at boot in `sceHttp2SetResolveRetry` ("not implemented", the new nghttp2 libSceHttp2). Both arms used the same older `libSceHttp2.prx` so they could reach gameplay; that library is not on the graphics path. - The log went to a file in both arms because the runs were headless. **Traces** (release assets on the fork): - CM1: [CM1-main-aps5-trace-319621ba2e57-347497.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CM1-main-aps5-trace-319621ba2e57-347497.json.gz) - CC1: [CC1-change-aps5-trace-5c4323035f7e-349192.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CC1-change-aps5-trace-5c4323035f7e-349192.json.gz) - CM2: [CM2-main-aps5-trace-319621ba2e57-350783.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CM2-main-aps5-trace-319621ba2e57-350783.json.gz) - CC2: [CC2-change-aps5-trace-5c4323035f7e-352238.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CC2-change-aps5-trace-5c4323035f7e-352238.json.gz) - CM3: [CM3-main-aps5-trace-319621ba2e57-372833.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CM3-main-aps5-trace-319621ba2e57-372833.json.gz) - CF1: [CF1-change-aps5-trace-7a13a20b844f-374000.json.gz](https://github.com/Raghav314/AnyPS5/releases/download/perf-traces-capture-pending-branches/CF1-change-aps5-trace-7a13a20b844f-374000.json.gz) <details><summary>Summary lines</summary> ```json {"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1843,"ms":8018.023},"presents":142,"frame_ms":{"p50":55.565,"p90":58.326,"p99":87.249,"max":91.517},"gpu_busy_ms_per_present":38.553,"worker_busy_pct":{"queue worker 0x0":99.235,"queue worker 0x20":99.412},"top_phases_ms_per_frame":{"Driver.Packet":112.104,"Driver.Packet.dispatch":42.377,"Driver.Dispatch":41.278,"Driver.Packet.memory_wait":34.675,"Vulkan.Dispatch":15.632,"Vulkan.Dispatch.shader_resources":13.856,"Driver.Packet.pipeline_drain":13.792,"Driver.Dispatch.capture_resources":13.087},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-347497.json.gz"} {"commit":"5c4323035f7e","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1846,"ms":8027.163},"presents":145,"frame_ms":{"p50":54.601,"p90":57.177,"p99":84.355,"max":85.158},"gpu_busy_ms_per_present":38.598,"worker_busy_pct":{"queue worker 0x0":99.196,"queue worker 0x20":99.398},"top_phases_ms_per_frame":{"Driver.Packet":109.875,"Driver.Packet.dispatch":35.824,"Driver.Dispatch":35.206,"Driver.Packet.memory_wait":30.382,"Driver.Packet.pipeline_drain":17.476,"Vulkan.Dispatch":12.384,"Driver.Packet.draw":12.082,"Driver.Draw":12.015},"trace_dropped":false,"trace":"aps5-trace-5c4323035f7e-349192.json.gz"} {"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1819,"ms":8019.215},"presents":134,"frame_ms":{"p50":59.041,"p90":61.983,"p99":88.236,"max":89.663},"gpu_busy_ms_per_present":39.678,"worker_busy_pct":{"queue worker 0x0":99.255,"queue worker 0x20":99.721},"top_phases_ms_per_frame":{"Driver.Packet":119.013,"Driver.Packet.dispatch":42.138,"Driver.Dispatch":39.408,"Driver.Packet.memory_wait":34.681,"Driver.Packet.draw":16.870,"Driver.Draw":16.804,"Graphics.Draw":15.811,"Vulkan.Dispatch":14.636},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-350783.json.gz"} {"commit":"5c4323035f7e","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1842,"ms":8041.677},"presents":146,"frame_ms":{"p50":54.412,"p90":57.569,"p99":84.731,"max":86.556},"gpu_busy_ms_per_present":38.209,"worker_busy_pct":{"queue worker 0x0":99.214,"queue worker 0x20":99.558},"top_phases_ms_per_frame":{"Driver.Packet":109.416,"Driver.Packet.dispatch":35.843,"Driver.Dispatch":35.214,"Driver.Packet.memory_wait":30.047,"Driver.Packet.pipeline_drain":17.350,"Vulkan.Dispatch":12.624,"Driver.Packet.draw":11.949,"Driver.Draw":11.886},"trace_dropped":false,"trace":"aps5-trace-5c4323035f7e-352238.json.gz"} {"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1847,"ms":8004.597},"presents":142,"frame_ms":{"p50":55.472,"p90":58.434,"p99":86.672,"max":87.648},"gpu_busy_ms_per_present":38.397,"worker_busy_pct":{"queue worker 0x0":99.227,"queue worker 0x20":99.264},"top_phases_ms_per_frame":{"Driver.Packet":111.827,"Driver.Packet.dispatch":42.321,"Driver.Dispatch":41.249,"Driver.Packet.memory_wait":35.028,"Vulkan.Dispatch":15.566,"Vulkan.Dispatch.shader_resources":13.789,"Driver.Packet.pipeline_drain":13.423,"Driver.Dispatch.capture_resources":13.293},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-372833.json.gz"} {"commit":"7a13a20b844f","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1850,"ms":8055.855},"presents":143,"frame_ms":{"p50":55.474,"p90":58.058,"p99":87.241,"max":91.610},"gpu_busy_ms_per_present":39.408,"worker_busy_pct":{"queue worker 0x0":99.222,"queue worker 0x20":99.704},"top_phases_ms_per_frame":{"Driver.Packet":112.002,"Driver.Packet.dispatch":36.687,"Driver.Dispatch":36.092,"Driver.Packet.memory_wait":30.933,"Driver.Packet.pipeline_drain":18.307,"Vulkan.Dispatch":12.861,"Driver.Packet.draw":12.141,"Driver.Draw":12.072},"trace_dropped":false,"trace":"aps5-trace-7a13a20b844f-374000.json.gz"} ``` </details> <details><summary>trace_digest: main (CM3)</summary> **seconds 50:8** from present 1847: 142 presents, frame p50 55.5 / p90 58.4 / p99 86.7 / max 87.6 ms, GPU busy 38.4 ms per present NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit 319621ba2e57, dropped: no ```json {"commit":"319621ba2e57","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1847,"ms":8004.597},"presents":142,"frame_ms":{"p50":55.472,"p90":58.434,"p99":86.672,"max":87.648},"gpu_busy_ms_per_present":38.397,"worker_busy_pct":{"queue worker 0x0":99.227,"queue worker 0x20":99.264},"top_phases_ms_per_frame":{"Driver.Packet":111.827,"Driver.Packet.dispatch":42.321,"Driver.Dispatch":41.249,"Driver.Packet.memory_wait":35.028,"Vulkan.Dispatch":15.566,"Vulkan.Dispatch.shader_resources":13.789,"Driver.Packet.pipeline_drain":13.423,"Driver.Dispatch.capture_resources":13.293},"trace_dropped":false,"trace":"aps5-trace-319621ba2e57-372833.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1936: 87.6 ms at 5005 ms: Driver.Packet (queue worker 0x20) 86.2, Driver.Packet (queue worker 0x0) 82.6, Driver.Packet.memory_wait (queue worker 0x20) 53.9, Driver.Packet.draw (queue worker 0x0) 43.7 - present 1890: 86.7 ms at 2422 ms: Driver.Packet (queue worker 0x20) 85.2, Driver.Packet (queue worker 0x0) 80.9, Driver.Packet.memory_wait (queue worker 0x20) 52.1, Driver.Packet.draw (queue worker 0x0) 40.8 - present 1982: 86.1 ms at 7583 ms: Driver.Packet (queue worker 0x20) 84.8, Driver.Packet (queue worker 0x0) 81.1, Driver.Packet.dispatch (queue worker 0x20) 58.9, Driver.Dispatch (queue worker 0x20) 58.1 - present 1882: 59.8 ms at 1974 ms: Driver.Packet (queue worker 0x20) 58.4, Driver.Packet (queue worker 0x0) 54.3, batch (gpu) 41.5, Driver.Packet.dispatch (queue worker 0x20) 28.0 - present 1900: 59.8 ms at 3017 ms: Driver.Packet (queue worker 0x20) 58.3, Driver.Packet (queue worker 0x0) 54.3, batch (gpu) 38.7, Driver.Packet.dispatch (queue worker 0x20) 25.0 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 36.2 (64 %) | 14.4 (26 %) | 5.7 | 30.9 | Driver.Packet 50.7, Driver.EndSubmission 0.0 | | draw committer | 10.1 (18 %) | 2.2 (4 %) | 44.0 | 5.4 | Graphics.Draw 6.7, Recorder.Sync 3.2 | | queue worker 0x20 | 21.5 (38 %) | 33.4 (59 %) | 1.5 | 7.3 | Driver.Packet 54.6, Driver.EndSubmission 0.0 | | presenter | 0.3 (0 %) | 0.0 (0 %) | 56.1 | 0.1 | VideoOut.Flip 0.3, Driver.Present 0.0 | | gpu | 38.4 (68 %) | 0.0 (0 %) | 18.0 | 0.0 | batch 38.4 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 105.3, Driver.Packet.dispatch 41.7, Driver.Dispatch 40.1, batch 38.4, Driver.Packet.memory_wait 35.0, Vulkan.Dispatch 14.6, Vulkan.Dispatch.shader_resources 12.8, Driver.Packet.pipeline_drain 12.2, Driver.Dispatch.capture_resources 11.8, Driver.Packet.draw 10.4 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x20) 43.6 ms at 2466 ms, present 1890 - Driver.Packet.memory_wait (queue worker 0x20) 35.0 ms at 5005 ms, present 1936 - Driver.Packet.memory_wait (queue worker 0x0) 16.5 ms at 3985 ms, present 1917 - Driver.Packet.memory_wait (queue worker 0x0) 16.5 ms at 4864 ms, present 1933 - Driver.Packet.memory_wait (queue worker 0x0) 16.4 ms at 1386 ms, present 1871 - Driver.Packet.memory_wait (queue worker 0x0) 16.2 ms at 6180 ms, present 1956 - Driver.Packet.memory_wait (queue worker 0x0) 16.0 ms at 4976 ms, present 1935 - Driver.Packet.memory_wait (queue worker 0x0) 16.0 ms at 1773 ms, present 1878 - Driver.Packet.memory_wait (queue worker 0x0) 15.9 ms at 4810 ms, present 1932 - Driver.Packet.memory_wait (queue worker 0x0) 15.9 ms at 5288 ms, present 1940 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 4048: 6.8 ms at 3583 ms, present 1910: GPU no ranges; recorded by Driver.Packet (queue worker 0x20) 1.9, Driver.Packet.dispatch (queue worker 0x20) 1.8, Driver.Dispatch (queue worker 0x20) 0.7, Vulkan.Dispatch (queue worker 0x20) 0.3 - batch 676: 6.4 ms at 584 ms, present 1857: GPU no ranges; recorded by Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.3, GpuMutex.wait.draw (draw committer) 0.2, GpuMutex.wait.label (draw committer) 0.1 - batch 4829: 6.1 ms at 4303 ms, present 1923: GPU no ranges; recorded by Recorder.Sync (queue worker 0x0) 6.0, Driver.Packet (queue worker 0x0) 1.6, Driver.Packet.draw (queue worker 0x0) 1.4, Driver.Draw (queue worker 0x0) 1.4 - batch 1957: 5.3 ms at 1718 ms, present 1877: GPU no ranges; recorded by GpuMutex.wait.draw (draw committer) 6.2, Graphics.Draw (draw committer) 0.9, Graphics.Draw.draw_and_resource_release (draw committer) 0.7, Resources.Complete (draw committer) 0.1 - batch 994: 5.2 ms at 874 ms, present 1862: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 6.5, Graphics.Draw (draw committer) 1.1, Graphics.Draw.draw_and_resource_release (draw committer) 1.0, GpuMutex.wait.draw (draw committer) 0.2 </details> <details><summary>trace_digest: change (CF1)</summary> **seconds 50:8** from present 1850: 143 presents, frame p50 55.5 / p90 58.1 / p99 87.2 / max 91.6 ms, GPU busy 39.4 ms per present NVIDIA GeForce RTX 4090, NVIDIA 615.78.08, Linux 7.3.0-3-cachyos, 3840x2160, commit 7a13a20b844f, dropped: no ```json {"commit":"7a13a20b844f","dirty":false,"env":{"APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"50:8"},"gpu":"NVIDIA GeForce RTX 4090","driver":"NVIDIA 615.78.08","os":"Linux 7.3.0-3-cachyos","cpu":"AMD Ryzen 7 7800X3D 8-Core Processor","cpu_threads":16,"memory_mib":31742,"title_id":"PPSA16064","title":"Minecraft Dungeons II","content_version":"01.100.100","resolution":"3840x2160","window":{"spec":"seconds 50:8","first_present":1850,"ms":8055.855},"presents":143,"frame_ms":{"p50":55.474,"p90":58.058,"p99":87.241,"max":91.61},"gpu_busy_ms_per_present":39.408,"worker_busy_pct":{"queue worker 0x0":99.222,"queue worker 0x20":99.704},"top_phases_ms_per_frame":{"Driver.Packet":112.002,"Driver.Packet.dispatch":36.687,"Driver.Dispatch":36.092,"Driver.Packet.memory_wait":30.933,"Driver.Packet.pipeline_drain":18.307,"Vulkan.Dispatch":12.861,"Driver.Packet.draw":12.141,"Driver.Draw":12.072},"trace_dropped":false,"trace":"aps5-trace-7a13a20b844f-374000.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 1978: 91.6 ms at 7167 ms: Driver.Packet (queue worker 0x20) 90.2, Driver.Packet (queue worker 0x0) 86.2, Driver.Packet.memory_wait (queue worker 0x20) 54.8, Driver.Packet.dispatch (queue worker 0x0) 45.2 - present 1932: 87.2 ms at 4545 ms: Driver.Packet (queue worker 0x20) 85.9, Driver.Packet (queue worker 0x0) 81.3, Driver.Packet.memory_wait (queue worker 0x20) 53.2, Driver.Packet.draw (queue worker 0x0) 42.9 - present 1887: 86.3 ms at 2037 ms: Driver.Packet (queue worker 0x20) 84.9, Driver.Packet (queue worker 0x0) 81.1, Driver.Packet.dispatch (queue worker 0x20) 57.0, Driver.Dispatch (queue worker 0x20) 56.2 - present 1992: 61.4 ms at 7994 ms: Driver.Packet (queue worker 0x0) 55.6, Driver.Packet (queue worker 0x20) 47.4, batch (gpu) 41.4, Driver.Packet.pipeline_drain (queue worker 0x0) 31.3 - present 1896: 60.9 ms at 2563 ms: Driver.Packet (queue worker 0x20) 59.6, Driver.Packet (queue worker 0x0) 54.8, batch (gpu) 38.7, Driver.Packet.memory_wait (queue worker 0x20) 26.0 **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | queue worker 0x0 | 39.1 (69 %) | 11.5 (20 %) | 5.7 | 31.1 | Driver.Packet 50.6, Driver.EndSubmission 0.0 | | draw committer | 9.8 (17 %) | 6.7 (12 %) | 39.8 | 5.4 | Graphics.Draw 7.3, Recorder.Sync 2.3 | | queue worker 0x20 | 16.8 (30 %) | 38.2 (68 %) | 1.4 | 7.1 | Driver.Packet 54.9, Driver.EndSubmission 0.0 | | presenter | 0.3 (0 %) | 0.0 (0 %) | 56.0 | 0.1 | VideoOut.Flip 0.3, Driver.Present 0.0 | | gpu | 39.4 (70 %) | 0.0 (0 %) | 16.9 | 0.0 | batch 39.4 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 105.5, batch 39.4, Driver.Packet.dispatch 36.1, Driver.Dispatch 35.0, Driver.Packet.memory_wait 30.9, Driver.Packet.pipeline_drain 17.1, Vulkan.Dispatch 11.9, Driver.Packet.draw 10.6, Driver.Draw 10.5, Vulkan.Dispatch.shader_resources 10.0 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x20) 46.4 ms at 7213 ms, present 1978 - Driver.Packet.memory_wait (queue worker 0x20) 44.0 ms at 4588 ms, present 1932 - Driver.Packet.memory_wait (queue worker 0x0) 14.6 ms at 916 ms, present 1866 - Driver.Packet.memory_wait (queue worker 0x20) 14.0 ms at 6593 ms, present 1967 - Driver.Packet.memory_wait (queue worker 0x0) 13.9 ms at 7402 ms, present 1981 - Driver.Packet.memory_wait (queue worker 0x0) 13.9 ms at 6802 ms, present 1971 - Driver.Packet.memory_wait (queue worker 0x20) 13.8 ms at 3429 ms, present 1911 - Driver.Packet.memory_wait (queue worker 0x20) 13.7 ms at 7039 ms, present 1975 - Driver.Packet.memory_wait (queue worker 0x0) 13.7 ms at 1027 ms, present 1868 - Driver.Packet.memory_wait (queue worker 0x0) 13.7 ms at 6692 ms, present 1969 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 6030: 7.3 ms at 6016 ms, present 1957: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 8.8, Driver.Packet (queue worker 0x20) 1.5, Driver.Packet.dispatch (queue worker 0x20) 1.2, Driver.Dispatch (queue worker 0x20) 1.1 - batch 7997: 7.3 ms at 8030 ms, present 1992: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 8.5, Driver.Packet (queue worker 0x20) 1.2, Driver.Packet.dispatch (queue worker 0x20) 1.0, Driver.Dispatch (queue worker 0x20) 0.9 - batch 196: 6.5 ms at 197 ms, present 1853: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 7.8, Driver.Packet (queue worker 0x20) 1.3, Driver.Packet.dispatch (queue worker 0x20) 0.8, Driver.Dispatch (queue worker 0x20) 0.8 - batch 6532: 6.5 ms at 6521 ms, present 1966: GPU no ranges; recorded by Recorder.Sync (queue worker 0x20) 6.5, Driver.Packet (queue worker 0x20) 1.5, Driver.Packet.dispatch (queue worker 0x20) 1.5, Driver.Dispatch (queue worker 0x20) 1.4 - batch 884: 6.4 ms at 865 ms, present 1865: GPU no ranges; recorded by GpuMutex.wait.label (draw committer) 7.7, Graphics.Draw (draw committer) 0.4, Graphics.Draw.draw_and_resource_release (draw committer) 0.4, Resources.Complete (draw committer) 0.1 </details> #### Tests - New `verifyPendingBranchLeftUnpruned` (recompiler walkers): a condition read inside the branch scope that cannot be read keeps both successors, the tape walk and the tree walk agree, and the scope is closed afterwards. - New `verifyPendingBranchCapture` (`ShaderMemory`): the flag is loaded with `s_buffer_load` from a constant buffer that has a pending Sync write. The test checks three cases: 1. no wait, and both successors are kept; 2. an invalid T# behind the skipped successor makes the capture redo, which waits and prunes; 3. an invalid T# behind the taken successor still fails, as on main. It fails with `APS5_WAIT_PENDING_BRANCHES=1` and fails with the redo removed. - Focused ctest (`agc_shader_memory|srt|capture|agc_driver_dispatch|agc_driver_pipelined|agc_driver_storage|agc_driver_copied|wait|recompiler_plan`) passed 117/117 on main and on the change, in both default and `APS5_GPU_HEAP=1` modes. The runs used `ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` and logged no `VUID-` lines. - `tools/check_conventions.py --base origin/main` and `tools/env_reference.py --check` both pass. ### Checklist - [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: NVIDIA GeForce RTX 4090, driver 615.78.08, Linux 7.3.0-3-cachyos - [x] AI-assisted: yes
CnRJay commented 2026-11-01 19:49:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:45Z.

Review: COMMENTED


The Minecraft Dungeons II table is the right kind of evidence, and the idea of not stalling the capture on a word that is only a branch condition is reasonable. Some points on what the unpruned superset costs, which the table does not show.

  1. Superset capture changes what is compiled. With the refused read, both successors of the branch stay in the capture, so the ResourceCapture for a given shader can now contain descriptors the pruned walk would have dropped. Does that feed the pipeline or shader key? If it does, the same shader can produce a different key depending on whether the flag word happened to have a pending GPU write at capture time, so the same draw can compile twice and the disk cache grows with both variants. Please state whether the key is built from the pruned or the unpruned capture, and show the shader compile count and shader cache size on main versus the change for the same scene.

  2. captureWaitingOnFailure retries on any std::exception. The retry is guarded only by branchReadsRefused != 0, not by the kind of failure. A failure that has nothing to do with the dropped pruning (for example a genuinely unreadable page) now runs the whole capture twice before it surfaces, and the first failure is discarded without a log line. Either narrow the catch to the descriptor-validity failures the description names, or log the first error. The branchCapturesRedone counter only exists under APS5_PROFILE_DRAW, so a title that redoes every capture would not be visible in a normal trace.

  3. The superset can reach memory the real branch never reads. The description covers an invalid T# that throws. It does not cover a descriptor that is valid-looking but stale, or one that points at memory that is only mapped on the taken side. Those are captured, bound and barriered for nothing. Is there a bound on how many extra resources a capture can pick up, and has anyone counted them on the title used for the measurement?

  4. Evidence beyond one title. The performance rows come from one title on one GPU. The capture time figure (12.5 s to 4.2 s) comes from APS5_PROFILE_DRAW diagnostics, which are not accepted as the speed claim on their own. The tools/trace_digest.py summaries of main and the change from the same session are what carry it; please attach those summaries explicitly rather than the table alone. The comment from Tamalero shows no change on Marvel's Guardians of the Galaxy; that is a useful negative result and should be in the description with the claim scoped to titles that have flags written by the previous dispatch.

  5. Negative control for the new test. verifyPendingBranchLeftUnpruned shows the branch is left unpruned with the refusal. Is there a case in the same test that fails if the SrtBranchScope is also active around a non-branch read (the flat-slot case in the description that must still wait)? That is the case that would turn this into a wrong-data bug, and it is the one I would want pinned.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729923232 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12616#pullrequestreview-5729923232). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:45Z. **Review:** COMMENTED --- The Minecraft Dungeons II table is the right kind of evidence, and the idea of not stalling the capture on a word that is only a branch condition is reasonable. Some points on what the unpruned superset costs, which the table does not show. 1. **Superset capture changes what is compiled.** With the refused read, both successors of the branch stay in the capture, so the `ResourceCapture` for a given shader can now contain descriptors the pruned walk would have dropped. Does that feed the pipeline or shader key? If it does, the same shader can produce a different key depending on whether the flag word happened to have a pending GPU write at capture time, so the same draw can compile twice and the disk cache grows with both variants. Please state whether the key is built from the pruned or the unpruned capture, and show the shader compile count and shader cache size on main versus the change for the same scene. 2. **`captureWaitingOnFailure` retries on any `std::exception`.** The retry is guarded only by `branchReadsRefused != 0`, not by the kind of failure. A failure that has nothing to do with the dropped pruning (for example a genuinely unreadable page) now runs the whole capture twice before it surfaces, and the first failure is discarded without a log line. Either narrow the catch to the descriptor-validity failures the description names, or log the first error. The `branchCapturesRedone` counter only exists under `APS5_PROFILE_DRAW`, so a title that redoes every capture would not be visible in a normal trace. 3. **The superset can reach memory the real branch never reads.** The description covers an invalid T# that throws. It does not cover a descriptor that is valid-looking but stale, or one that points at memory that is only mapped on the taken side. Those are captured, bound and barriered for nothing. Is there a bound on how many extra resources a capture can pick up, and has anyone counted them on the title used for the measurement? 4. **Evidence beyond one title.** The performance rows come from one title on one GPU. The capture time figure (12.5 s to 4.2 s) comes from `APS5_PROFILE_DRAW` diagnostics, which are not accepted as the speed claim on their own. The `tools/trace_digest.py` summaries of main and the change from the same session are what carry it; please attach those summaries explicitly rather than the table alone. The comment from Tamalero shows no change on Marvel's Guardians of the Galaxy; that is a useful negative result and should be in the description with the claim scoped to titles that have flags written by the previous dispatch. 5. **Negative control for the new test.** `verifyPendingBranchLeftUnpruned` shows the branch is left unpruned with the refusal. Is there a case in the same test that fails if the `SrtBranchScope` is also active around a non-branch read (the flat-slot case in the description that must still wait)? That is the case that would turn this into a wrong-data bug, and it is the one I would want pinned.
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!12616
No description provided.