perf(agc): drop superseded pending units of a foreign image under APS5_TAKEOVER_DISCARD #18348

Closed
klosixgaming-arch wants to merge 1 commit from upstream-pr/18348 into main
klosixgaming-arch commented 2026-11-11 10:58:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-11-11T10:58:25Z.


What

Draft, and not safe to merge as it is. It drops GPU results without proof that they are dead. I'm posting it so the measurements are on record while I work on the sound version, described at the end. It is off by default.

Some titles reuse one guest address range as a transient pool: within a frame, images of different sizes and formats start at the same address, one pass after another. In Cyberpunk 2077 these are 3200x1800, 2560x1440, 2048x2048, 1848x1040 and 1600x900 images. Each new image is refreshed over memory where an earlier image of another shape still holds pending GPU results. The refresh writes those results back to guest memory and then uploads the memory into the new image. The old contents are usually dead, because the new pass overwrites them, but nothing in the driver can prove it.

With APS5_TAKEOVER_DISCARD:

  • Takeover. A storage image refresh over memory where only images of another shape hold pending results, and where no depth surface overlaps, drops those images' pending units inside its range (DiscardPendingInside) instead of writing them back.
  • Unit overlap. ScanPending and FindPending count a pending image as over a range only where one of its pending units lies. After a takeover, a larger earlier image keeps pending units only outside the smaller new one. The extent check still named it, so the fast revalidation path failed and fell back to a full walk.

Why it is unsafe. The fill HLE may drop pending units because the fill writes every byte of the range before anything else is recorded. Here the drop happens at the refresh, before the new image's write is recorded, and nothing proves that the write covers the range. If a later pass reads bytes the new image leaves unwritten (blending, partial coverage, padding, other mips or layers), it gets the older guest bytes instead of the dropped results. The frames I checked look right, but that is not a proof. The debt entry says the same.

The unit-overlap half is sound on its own: an image with no pending units in a range has nothing there that guest memory lacks. On main alone it gains nothing, because without the takeover the overlaps it ignores do not happen (in-run A/B on main 9bce44ce3b: +0.32 +- 0.21 presents per 10 s, n 11).

The series this was found on. I found the takeover while stacking open PRs for Cyberpunk 2077, and most of the numbers below come from those stacks:

  • my PRs: #17786 (shared collect walks), #18078 (reused untracked compares, on #17786), #18075 (import segment reuse), #18076 (refresh proof from an equal compare) and #18102 (walk reuse when storage results become pending);
  • #18293 (block arming), which adds on to #16372 by Nesyth, itself on #16371; the stack used an earlier version of my arming commit together with #16371;
  • other people's PRs: #10443 by Dripl1x (settling 64 KiB private imports, run with APS5_SETTLE_FLOOR_KIB=64) and #11485 by QRMOE (storage image uploads over several host imports).

Here is this PR measured on top of them:

base rule in-run A/B, presents per 10 s
an older stack, before #15569 drop whenever only other shapes are pending +2.2% +- 0.7 (n 3)
the same ... and no depth surface overlaps (this PR's rule) +5.9% (n 3)
main bc94a8e423 + #17786, #18078, #18075, #18076, #18102, #10443, #11485, #16371 this PR's rule +6.7% (+6.83 +- 0.91, n 3)
the same + my arming commit unit overlap, with the takeover already on +5.7% (+7.7 +- 1.5, n 8)

On the second stack the takeover halved storage-refresh write-backs (about 26 to 13.5 GB per 10 s) and cut the GPU wait from 8.2 to 3.8 ms per frame. Unit overlap cut full revalidation walks by 68% (about 8,600 to 2,700 per 10 s).

Tested

Cyberpunk 2077 (PPSA03974), the intro movie, 3200x1800, warm caches; Windows 11, RTX 5090 (driver 617.42), Ryzen 9 9950X3D. 2026-11-11.

Summary lines of main and of this PR. Separate runs, 5 minutes apart, with only the capture switches (APS5_TRACE_SECONDS=60:10, APS5_TRACE_SUMMARY_EVERY=10, APS5_TRACE_EVENTS=1048576), plus APS5_TAKEOVER_DISCARD=1 on this PR. Traces, all summary lines and the digests: https://github.com/klosixgaming-arch/AnyPS5/releases/tag/perf-captures-2026-11-11

main 14bff3fc4a:

{"commit":"14bff3fc4a2d","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":357,"ms":10111.608},"presents":44,"frame_ms":{"p50":230.429,"p90":252.972,"p99":278.371,"max":278.371},"gpu_busy_ms_per_present":43.375,"worker_busy_pct":{"queue worker 0x0":99.513,"queue worker 0x23":100.025},"top_phases_ms_per_frame":{"Driver.Packet":447.062,"Driver.Packet.dispatch":218.169,"Driver.Packet.memory_wait":200.897,"Driver.Dispatch":154.822,"Vulkan.Dispatch":102.223,"Vulkan.Dispatch.shader_resources":96.486,"Graphics.Draw":65.464,"Graphics.Draw.draw_and_resource_release":64.100},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-14bff3fc4a2d-59752.json.gz"}

this PR, 2b129e3a43, with APS5_TAKEOVER_DISCARD=1:

{"commit":"2b129e3a43c6","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TAKEOVER_DISCARD":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":358,"ms":10220.504},"presents":46,"frame_ms":{"p50":219.199,"p90":245.250,"p99":265.113,"max":265.113},"gpu_busy_ms_per_present":38.225,"worker_busy_pct":{"queue worker 0x0":99.448,"queue worker 0x23":99.823},"top_phases_ms_per_frame":{"Driver.Packet":430.191,"Driver.Packet.dispatch":209.628,"Driver.Packet.memory_wait":193.832,"Driver.Dispatch":141.592,"Vulkan.Dispatch":91.666,"Vulkan.Dispatch.shader_resources":86.383,"Graphics.Draw":63.839,"Graphics.Draw.draw_and_resource_release":62.471},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-2b129e3a43c6-56876.json.gz"}
main this PR, switch on
movie windows (presents per 10 s) 34, 45, 45, 44, 44, 44, 44 42, 46, 45, 44, 45, 44, 45
mean 42.9 44.4
GPU busy per present 43.4 ms 37.5 ms
trace window: frame p50 230.4 ms 219.2 ms
trace window: Vulkan.Dispatch per frame 102.2 ms 91.7 ms
trace window: Recorder.Sync slices per present 40.1 28.3

In-run A/B on this commit (APS5_AB=10:APS5_TAKEOVER_DISCARD from 80 s, 11 B phases inside the movie): +14.1%, 35.75 to 40.79 presents per 10 s, B vs neighbouring A +5.10 +- 0.72 (SD 2.40). An earlier A/B ran while a game was using the GPU, so I don't count it; it gave +8.8% (n 9).

These two disagree. The separate runs above show about +3.5% (+1.1% without the first window), and the A/B shows +14%. The A phases ran at 35.75, well below the 42.9 of main alone, so switching may cost the A phases, or that run was slower overall. Later in-run A/Bs of the sound version in #18369 gave +2.5% and +3.4%. That suggests this A/B's +14% carried a switching effect. The clear effects are the GPU time per present (-13%) and the GPU syncs per present (-30%). The frame is limited by queue worker 0x0 (87% busy in both traces), so those don't turn into frames one for one.

Pictures. With the switch on (every 150th frame), the logos, the legal text, six scenes of the intro movie and the title render correctly. takeover-frames.jpg is in the release.

Tests. None yet. The sound version below will come with tests that fail without it.

trace_digest.py, main 14bff3fc4a

seconds 60:10 from present 357: 44 presents, frame p50 230.4 / p90 253.0 / p99 278.4 / max 278.4 ms, GPU busy 43.4 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit 14bff3fc4a, dropped: no

{"commit":"14bff3fc4a2d","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":357,"ms":10111.608},"presents":44,"frame_ms":{"p50":230.429,"p90":252.972,"p99":278.371,"max":278.371},"gpu_busy_ms_per_present":43.375,"worker_busy_pct":{"queue worker 0x0":99.513,"queue worker 0x23":100.025},"top_phases_ms_per_frame":{"Driver.Packet":447.062,"Driver.Packet.dispatch":218.169,"Driver.Packet.memory_wait":200.897,"Driver.Dispatch":154.822,"Vulkan.Dispatch":102.223,"Vulkan.Dispatch.shader_resources":96.486,"Graphics.Draw":65.464,"Graphics.Draw.draw_and_resource_release":64.1},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-14bff3fc4a2d-59752.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 360: 278.4 ms at 684 ms: Driver.Packet (queue worker 0x23) 274.2, Driver.Packet (queue worker 0x0) 264.5, Driver.Packet.memory_wait (queue worker 0x23) 242.4, Driver.Packet.dispatch (queue worker 0x0) 233.3
  • present 367: 260.9 ms at 2310 ms: Driver.Packet (queue worker 0x23) 255.5, Driver.Packet (queue worker 0x0) 247.4, Driver.Packet.memory_wait (queue worker 0x23) 218.4, Driver.Packet.dispatch (queue worker 0x0) 213.6
  • present 361: 257.6 ms at 962 ms: Driver.Packet (queue worker 0x23) 256.0, Driver.Packet (queue worker 0x0) 244.4, Driver.Packet.memory_wait (queue worker 0x23) 221.5, Driver.Packet.dispatch (queue worker 0x0) 208.4
  • present 399: 254.9 ms at 9636 ms: Driver.Packet (queue worker 0x23) 249.1, Driver.Packet (queue worker 0x0) 241.5, Driver.Packet.memory_wait (queue worker 0x23) 211.0, Driver.Packet.dispatch (queue worker 0x0) 206.3
  • present 371: 253.0 ms at 3280 ms: Driver.Packet (queue worker 0x23) 248.4, Driver.Packet (queue worker 0x0) 237.7, Driver.Packet.memory_wait (queue worker 0x23) 208.4, Driver.Packet.dispatch (queue worker 0x0) 199.8

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 360: 278.4 ms at 684 ms, persistence 80.4 ms
  • present 367: 260.9 ms at 2310 ms, persistence 61.3 ms
  • present 399: 254.9 ms at 9636 ms, persistence 56.9 ms
  • present 385: 246.0 ms at 6415 ms, persistence 33.7 ms
  • present 371: 253.0 ms at 3280 ms, persistence 25.5 ms
  • present 357: 235.2 ms at 0 ms, persistence 19.7 ms
  • present 375: 222.3 ms at 4174 ms, persistence 10.2 ms
  • present 381: 243.9 ms at 5448 ms, persistence 9.2 ms
  • present 396: 251.4 ms at 8893 ms, persistence 8.9 ms
  • present 391: 221.3 ms at 7772 ms, persistence 8.3 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.0 (0 %) 0.0 (0 %) 229.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.0 (0 %) 0.1 (0 %) 229.7 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0
queue worker 0x0 199.9 (87 %) 25.2 (11 %) 4.7 12.7 Driver.Packet 217.9, Driver.EndSubmission 7.1
draw committer 71.3 (31 %) 12.5 (5 %) 145.9 1.5 Graphics.Draw 65.4, Vulkan.DrawFromRecipe 9.0
presenter 1.5 (1 %) 0.0 (0 %) 228.3 0.1 VideoOut.Flip 1.5
title 0.0 (0 %) 0.1 (0 %) 229.7 0.0 Recorder.Sync 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.8 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.7 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.1 (0 %) 229.7 0.0 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.7 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.8 0.0 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.8 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.4 (0 %) 229.4 0.0 Recorder.Sync 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.2 (0 %) 229.6 0.0 Recorder.Sync 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 229.7 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
queue worker 0x23 21.7 (9 %) 205.0 (89 %) 3.2 2.3 Driver.Packet 222.3, Driver.EndSubmission 4.3
gpu 43.4 (19 %) 0.0 (0 %) 186.4 0.0 batch 43.4

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 440.3, Driver.Packet.dispatch 218.0, Driver.Packet.memory_wait 198.2, Driver.Dispatch 154.4, Vulkan.Dispatch 101.9, Vulkan.Dispatch.shader_resources 96.0, Graphics.Draw 65.4, Graphics.Draw.draw_and_resource_release 64.1, batch 43.4, Recorder.Sync 37.6

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x23) 172.5 ms at 571 ms, present 359
  • Driver.Packet.memory_wait (queue worker 0x23) 147.8 ms at 852 ms, present 360
  • Driver.Packet.memory_wait (queue worker 0x23) 138.9 ms at 2191 ms, present 366
  • Driver.Packet.memory_wait (queue worker 0x23) 138.3 ms at 9016 ms, present 396
  • Driver.Packet.memory_wait (queue worker 0x23) 134.7 ms at 9762 ms, present 399
  • Driver.Packet.memory_wait (queue worker 0x23) 132.9 ms at 6289 ms, present 384
  • Driver.Packet.memory_wait (queue worker 0x23) 132.7 ms at 9513 ms, present 398
  • Driver.Packet.memory_wait (queue worker 0x23) 132.6 ms at 5327 ms, present 380
  • Driver.Packet.memory_wait (queue worker 0x23) 130.7 ms at 8305 ms, present 393
  • Driver.Packet.memory_wait (queue worker 0x23) 129.8 ms at 5808 ms, present 382

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

  • batch 27522: 11.5 ms at 6829 ms, present 386: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.4, Driver.Packet.dispatch (queue worker 0x0) 12.4, Driver.Dispatch (queue worker 0x0) 12.4, Vulkan.Dispatch (queue worker 0x0) 11.8
  • batch 26135: 10.1 ms at 4317 ms, present 375: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.2, Driver.Packet.dispatch (queue worker 0x0) 12.2, Driver.Dispatch (queue worker 0x0) 12.2, Vulkan.Dispatch (queue worker 0x0) 11.7
  • batch 28141: 10.0 ms at 7913 ms, present 391: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.2, Driver.Packet.dispatch (queue worker 0x0) 11.2, Driver.Dispatch (queue worker 0x0) 11.1, Vulkan.Dispatch (queue worker 0x0) 10.8
  • batch 27896: 9.9 ms at 7485 ms, present 389: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.7, Driver.Packet.dispatch (queue worker 0x0) 10.7, Driver.Dispatch (queue worker 0x0) 10.6, Vulkan.Dispatch (queue worker 0x0) 10.3
  • batch 26008: 9.9 ms at 4099 ms, present 374: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.5, Driver.Packet.dispatch (queue worker 0x0) 11.5, Driver.Dispatch (queue worker 0x0) 11.4, Vulkan.Dispatch (queue worker 0x0) 11.0
trace_digest.py, this PR 2b129e3a43 with APS5_TAKEOVER_DISCARD=1

seconds 60:10 from present 358: 46 presents, frame p50 219.2 / p90 245.2 / p99 265.1 / max 265.1 ms, GPU busy 38.2 ms per present
NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit 2b129e3a43, dropped: no

{"commit":"2b129e3a43c6","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TAKEOVER_DISCARD":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":358,"ms":10220.504},"presents":46,"frame_ms":{"p50":219.199,"p90":245.25,"p99":265.113,"max":265.113},"gpu_busy_ms_per_present":38.225,"worker_busy_pct":{"queue worker 0x0":99.448,"queue worker 0x23":99.823},"top_phases_ms_per_frame":{"Driver.Packet":430.191,"Driver.Packet.dispatch":209.628,"Driver.Packet.memory_wait":193.832,"Driver.Dispatch":141.592,"Vulkan.Dispatch":91.666,"Vulkan.Dispatch.shader_resources":86.383,"Graphics.Draw":63.839,"Graphics.Draw.draw_and_resource_release":62.471},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-2b129e3a43c6-56876.json.gz"}

Slowest frames (largest slices inside each, inclusive)

  • present 390: 265.1 ms at 7181 ms: Driver.Packet (queue worker 0x23) 257.2, Driver.Packet (queue worker 0x0) 249.2, Driver.Packet.memory_wait (queue worker 0x23) 221.7, Driver.Packet.dispatch (queue worker 0x0) 209.6
  • present 362: 253.2 ms at 930 ms: Driver.Packet (queue worker 0x23) 251.1, Driver.Packet (queue worker 0x0) 238.0, Driver.Packet.memory_wait (queue worker 0x23) 212.6, Driver.Packet.dispatch (queue worker 0x0) 195.1
  • present 359: 250.5 ms at 216 ms: Driver.Packet (queue worker 0x23) 242.9, Driver.Packet (queue worker 0x0) 236.8, Driver.Packet.memory_wait (queue worker 0x23) 211.0, Driver.Packet.dispatch (queue worker 0x0) 207.2
  • present 371: 245.4 ms at 2979 ms: Driver.Packet (queue worker 0x23) 238.0, Driver.Packet (queue worker 0x0) 234.2, Driver.Packet.memory_wait (queue worker 0x23) 207.2, Driver.Packet.dispatch (queue worker 0x0) 204.1
  • present 369: 245.3 ms at 2505 ms: Driver.Packet (queue worker 0x23) 239.5, Driver.Packet (queue worker 0x0) 233.7, Driver.Packet.memory_wait (queue worker 0x23) 206.9, Driver.Packet.dispatch (queue worker 0x0) 203.6

Persistent spikes (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame)

  • present 390: 265.1 ms at 7181 ms, persistence 67.7 ms
  • present 362: 253.2 ms at 930 ms, persistence 55.8 ms
  • present 371: 245.4 ms at 2979 ms, persistence 44.5 ms
  • present 359: 250.5 ms at 216 ms, persistence 26.8 ms
  • present 395: 226.9 ms at 8309 ms, persistence 18.0 ms
  • present 403: 223.9 ms at 9997 ms, persistence 17.4 ms
  • present 385: 231.1 ms at 6039 ms, persistence 17.3 ms
  • present 369: 245.3 ms at 2505 ms, persistence 16.8 ms
  • present 388: 242.4 ms at 6711 ms, persistence 15.4 ms
  • present 375: 222.7 ms at 3900 ms, persistence 7.3 ms

Threads (ms per frame)

thread busy wait untraced in slices < 20 us largest
title 0.1 (0 %) 0.1 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
queue worker 0x0 193.5 (87 %) 23.8 (11 %) 4.9 13.3 Driver.Packet 209.6, Driver.EndSubmission 7.7
title 0.1 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
draw committer 72.9 (33 %) 12.9 (6 %) 136.3 1.6 Graphics.Draw 63.8, Vulkan.DrawFromRecipe 13.2
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
presenter 2.0 (1 %) 0.0 (0 %) 220.2 0.1 VideoOut.Flip 2.0
title 0.1 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.1 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0
title 0.0 (0 %) 0.1 (0 %) 222.0 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0
title 0.1 (0 %) 0.1 (0 %) 222.0 0.0 Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0
title 0.0 (0 %) 0.0 (0 %) 222.1 0.0 Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0
queue worker 0x23 19.3 (9 %) 199.5 (90 %) 3.4 2.4 Driver.Packet 214.0, Driver.EndSubmission 4.8
gpu 37.5 (17 %) 0.0 (0 %) 184.7 0.0 batch 37.5

Largest slices (ms per frame, inclusive, all threads): Driver.Packet 423.6, Driver.Packet.dispatch 209.5, Driver.Packet.memory_wait 191.4, Driver.Dispatch 141.1, Vulkan.Dispatch 91.3, Vulkan.Dispatch.shader_resources 85.9, Graphics.Draw 63.8, Graphics.Draw.draw_and_resource_release 62.4, batch 37.5, Recorder.Sync 27.8

Longest waits

  • Driver.Packet.memory_wait (queue worker 0x23) 146.9 ms at 328 ms, present 359
  • Driver.Packet.memory_wait (queue worker 0x23) 145.4 ms at 7308 ms, present 390
  • Driver.Packet.memory_wait (queue worker 0x23) 142.4 ms at 1051 ms, present 362
  • Driver.Packet.memory_wait (queue worker 0x23) 139.4 ms at 2621 ms, present 369
  • Driver.Packet.memory_wait (queue worker 0x23) 139.0 ms at 3094 ms, present 371
  • Driver.Packet.memory_wait (queue worker 0x23) 134.8 ms at 1299 ms, present 363
  • Driver.Packet.memory_wait (queue worker 0x23) 129.7 ms at 810 ms, present 361
  • Driver.Packet.memory_wait (queue worker 0x23) 129.4 ms at 6832 ms, present 388
  • Driver.Packet.memory_wait (queue worker 0x23) 127.6 ms at 6154 ms, present 385
  • Driver.Packet.memory_wait (queue worker 0x23) 126.1 ms at 2393 ms, present 368

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

  • batch 28422: 11.9 ms at 7343 ms, present 390: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 9.6, Driver.Packet.dispatch (queue worker 0x0) 9.6, Driver.Dispatch (queue worker 0x0) 9.5, Vulkan.Dispatch (queue worker 0x0) 9.0
  • batch 25027: 11.8 ms at 1091 ms, present 362: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.5, Driver.Packet.dispatch (queue worker 0x0) 11.5, Driver.Dispatch (queue worker 0x0) 11.3, Vulkan.Dispatch (queue worker 0x0) 10.7
  • batch 25876: 11.5 ms at 2658 ms, present 369: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.0, Driver.Packet.dispatch (queue worker 0x0) 11.0, Driver.Dispatch (queue worker 0x0) 10.9, Vulkan.Dispatch (queue worker 0x0) 10.4
  • batch 26115: 11.2 ms at 3128 ms, present 371: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 8.7, Driver.Packet.dispatch (queue worker 0x0) 8.7, Driver.Dispatch (queue worker 0x0) 8.6, Vulkan.Dispatch (queue worker 0x0) 8.1
  • batch 27094: 10.9 ms at 4918 ms, present 379: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 8.4, Driver.Packet.dispatch (queue worker 0x0) 8.4, Driver.Dispatch (queue worker 0x0) 8.4, Vulkan.Dispatch (queue worker 0x0) 8.0

The sound version

#18369 does this with a proof instead of a guess. The recompiler proves that a compute shader stores every texel of a storage image's level and never reads it, and the driver checks the grid, the user data and the other bindings per dispatch before it drops anything. Its in-run A/B on main is +3.4% (n 8).

A census on main of the takeovers this draft makes, counted without dropping anything (832,522 units of 64 KiB in 12 reports):

  • 60.5% are under a storage element the compute shader writes, in a dispatch with at least one thread per texel;
  • about 16% are under color targets;
  • sampled reads take none.

IR dumps of the top programs show copy-rectangle, clear, A16 swizzled and plain global-id stores, which the proof covers. They also show a read-modify-write of the same image at the same texel, about 6% of the units. This draft can drop results that shader then reads, so it can change what that shader computes. The frames I checked still looked right.

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 5090, driver 617.42, Windows 11 (10.0.26200); the game only, no GPU tests
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5258208345 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18348). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-11-11T10:58:25Z. --- ### What **Draft, and not safe to merge as it is.** It drops GPU results without proof that they are dead. I'm posting it so the measurements are on record while I work on the sound version, described at the end. It is off by default. Some titles reuse one guest address range as a transient pool: within a frame, images of different sizes and formats start at the same address, one pass after another. In Cyberpunk 2077 these are 3200x1800, 2560x1440, 2048x2048, 1848x1040 and 1600x900 images. Each new image is refreshed over memory where an earlier image of another shape still holds pending GPU results. The refresh writes those results back to guest memory and then uploads the memory into the new image. The old contents are usually dead, because the new pass overwrites them, but nothing in the driver can prove it. With `APS5_TAKEOVER_DISCARD`: - **Takeover.** A storage image refresh over memory where only images of another shape hold pending results, and where no depth surface overlaps, drops those images' pending units inside its range (`DiscardPendingInside`) instead of writing them back. - **Unit overlap.** `ScanPending` and `FindPending` count a pending image as over a range only where one of its pending units lies. After a takeover, a larger earlier image keeps pending units only outside the smaller new one. The extent check still named it, so the fast revalidation path failed and fell back to a full walk. **Why it is unsafe.** The fill HLE may drop pending units because the fill writes every byte of the range before anything else is recorded. Here the drop happens at the refresh, before the new image's write is recorded, and nothing proves that the write covers the range. If a later pass reads bytes the new image leaves unwritten (blending, partial coverage, padding, other mips or layers), it gets the older guest bytes instead of the dropped results. The frames I checked look right, but that is not a proof. The debt entry says the same. The unit-overlap half is sound on its own: an image with no pending units in a range has nothing there that guest memory lacks. On `main` alone it gains nothing, because without the takeover the overlaps it ignores do not happen (in-run A/B on `main` `9bce44ce3b`: +0.32 +- 0.21 presents per 10 s, n 11). **The series this was found on.** I found the takeover while stacking open PRs for Cyberpunk 2077, and most of the numbers below come from those stacks: - my PRs: #17786 (shared collect walks), #18078 (reused untracked compares, on #17786), #18075 (import segment reuse), #18076 (refresh proof from an equal compare) and #18102 (walk reuse when storage results become pending); - #18293 (block arming), which adds on to #16372 by Nesyth, itself on #16371; the stack used an earlier version of my arming commit together with #16371; - other people's PRs: #10443 by Dripl1x (settling 64 KiB private imports, run with `APS5_SETTLE_FLOOR_KIB=64`) and #11485 by QRMOE (storage image uploads over several host imports). Here is this PR measured on top of them: | base | rule | in-run A/B, presents per 10 s | |---|---|---| | an older stack, before #15569 | drop whenever only other shapes are pending | +2.2% +- 0.7 (n 3) | | the same | ... and no depth surface overlaps (this PR's rule) | +5.9% (n 3) | | `main` `bc94a8e423` + #17786, #18078, #18075, #18076, #18102, #10443, #11485, #16371 | this PR's rule | +6.7% (+6.83 +- 0.91, n 3) | | the same + my arming commit | unit overlap, with the takeover already on | +5.7% (+7.7 +- 1.5, n 8) | On the second stack the takeover halved storage-refresh write-backs (about 26 to 13.5 GB per 10 s) and cut the GPU wait from 8.2 to 3.8 ms per frame. Unit overlap cut full revalidation walks by 68% (about 8,600 to 2,700 per 10 s). ### Tested Cyberpunk 2077 (PPSA03974), the intro movie, 3200x1800, warm caches; Windows 11, RTX 5090 (driver 617.42), Ryzen 9 9950X3D. 2026-11-11. **Summary lines of `main` and of this PR.** Separate runs, 5 minutes apart, with only the capture switches (`APS5_TRACE_SECONDS=60:10`, `APS5_TRACE_SUMMARY_EVERY=10`, `APS5_TRACE_EVENTS=1048576`), plus `APS5_TAKEOVER_DISCARD=1` on this PR. Traces, all summary lines and the digests: https://github.com/klosixgaming-arch/AnyPS5/releases/tag/perf-captures-2026-11-11 `main` `14bff3fc4a`: ```json {"commit":"14bff3fc4a2d","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":357,"ms":10111.608},"presents":44,"frame_ms":{"p50":230.429,"p90":252.972,"p99":278.371,"max":278.371},"gpu_busy_ms_per_present":43.375,"worker_busy_pct":{"queue worker 0x0":99.513,"queue worker 0x23":100.025},"top_phases_ms_per_frame":{"Driver.Packet":447.062,"Driver.Packet.dispatch":218.169,"Driver.Packet.memory_wait":200.897,"Driver.Dispatch":154.822,"Vulkan.Dispatch":102.223,"Vulkan.Dispatch.shader_resources":96.486,"Graphics.Draw":65.464,"Graphics.Draw.draw_and_resource_release":64.100},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-14bff3fc4a2d-59752.json.gz"} ``` this PR, `2b129e3a43`, with `APS5_TAKEOVER_DISCARD=1`: ```json {"commit":"2b129e3a43c6","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TAKEOVER_DISCARD":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":358,"ms":10220.504},"presents":46,"frame_ms":{"p50":219.199,"p90":245.250,"p99":265.113,"max":265.113},"gpu_busy_ms_per_present":38.225,"worker_busy_pct":{"queue worker 0x0":99.448,"queue worker 0x23":99.823},"top_phases_ms_per_frame":{"Driver.Packet":430.191,"Driver.Packet.dispatch":209.628,"Driver.Packet.memory_wait":193.832,"Driver.Dispatch":141.592,"Vulkan.Dispatch":91.666,"Vulkan.Dispatch.shader_resources":86.383,"Graphics.Draw":63.839,"Graphics.Draw.draw_and_resource_release":62.471},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-2b129e3a43c6-56876.json.gz"} ``` | | `main` | this PR, switch on | |---|---|---| | movie windows (presents per 10 s) | 34, 45, 45, 44, 44, 44, 44 | 42, 46, 45, 44, 45, 44, 45 | | mean | 42.9 | 44.4 | | GPU busy per present | 43.4 ms | 37.5 ms | | trace window: frame p50 | 230.4 ms | 219.2 ms | | trace window: `Vulkan.Dispatch` per frame | 102.2 ms | 91.7 ms | | trace window: `Recorder.Sync` slices per present | 40.1 | 28.3 | **In-run A/B on this commit** (`APS5_AB=10:APS5_TAKEOVER_DISCARD` from 80 s, 11 B phases inside the movie): +14.1%, 35.75 to 40.79 presents per 10 s, B vs neighbouring A +5.10 +- 0.72 (SD 2.40). An earlier A/B ran while a game was using the GPU, so I don't count it; it gave +8.8% (n 9). **These two disagree.** The separate runs above show about +3.5% (+1.1% without the first window), and the A/B shows +14%. The A phases ran at 35.75, well below the 42.9 of `main` alone, so switching may cost the A phases, or that run was slower overall. Later in-run A/Bs of the sound version in #18369 gave +2.5% and +3.4%. That suggests this A/B's +14% carried a switching effect. The clear effects are the GPU time per present (-13%) and the GPU syncs per present (-30%). The frame is limited by queue worker 0x0 (87% busy in both traces), so those don't turn into frames one for one. **Pictures.** With the switch on (every 150th frame), the logos, the legal text, six scenes of the intro movie and the title render correctly. `takeover-frames.jpg` is in the release. **Tests.** None yet. The sound version below will come with tests that fail without it. <details><summary>trace_digest.py, main 14bff3fc4a</summary> **seconds 60:10** from present 357: 44 presents, frame p50 230.4 / p90 253.0 / p99 278.4 / max 278.4 ms, GPU busy 43.4 ms per present NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit 14bff3fc4a2d, dropped: no ```json {"commit":"14bff3fc4a2d","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":357,"ms":10111.608},"presents":44,"frame_ms":{"p50":230.429,"p90":252.972,"p99":278.371,"max":278.371},"gpu_busy_ms_per_present":43.375,"worker_busy_pct":{"queue worker 0x0":99.513,"queue worker 0x23":100.025},"top_phases_ms_per_frame":{"Driver.Packet":447.062,"Driver.Packet.dispatch":218.169,"Driver.Packet.memory_wait":200.897,"Driver.Dispatch":154.822,"Vulkan.Dispatch":102.223,"Vulkan.Dispatch.shader_resources":96.486,"Graphics.Draw":65.464,"Graphics.Draw.draw_and_resource_release":64.1},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-14bff3fc4a2d-59752.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 360: 278.4 ms at 684 ms: Driver.Packet (queue worker 0x23) 274.2, Driver.Packet (queue worker 0x0) 264.5, Driver.Packet.memory_wait (queue worker 0x23) 242.4, Driver.Packet.dispatch (queue worker 0x0) 233.3 - present 367: 260.9 ms at 2310 ms: Driver.Packet (queue worker 0x23) 255.5, Driver.Packet (queue worker 0x0) 247.4, Driver.Packet.memory_wait (queue worker 0x23) 218.4, Driver.Packet.dispatch (queue worker 0x0) 213.6 - present 361: 257.6 ms at 962 ms: Driver.Packet (queue worker 0x23) 256.0, Driver.Packet (queue worker 0x0) 244.4, Driver.Packet.memory_wait (queue worker 0x23) 221.5, Driver.Packet.dispatch (queue worker 0x0) 208.4 - present 399: 254.9 ms at 9636 ms: Driver.Packet (queue worker 0x23) 249.1, Driver.Packet (queue worker 0x0) 241.5, Driver.Packet.memory_wait (queue worker 0x23) 211.0, Driver.Packet.dispatch (queue worker 0x0) 206.3 - present 371: 253.0 ms at 3280 ms: Driver.Packet (queue worker 0x23) 248.4, Driver.Packet (queue worker 0x0) 237.7, Driver.Packet.memory_wait (queue worker 0x23) 208.4, Driver.Packet.dispatch (queue worker 0x0) 199.8 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 360: 278.4 ms at 684 ms, persistence 80.4 ms - present 367: 260.9 ms at 2310 ms, persistence 61.3 ms - present 399: 254.9 ms at 9636 ms, persistence 56.9 ms - present 385: 246.0 ms at 6415 ms, persistence 33.7 ms - present 371: 253.0 ms at 3280 ms, persistence 25.5 ms - present 357: 235.2 ms at 0 ms, persistence 19.7 ms - present 375: 222.3 ms at 4174 ms, persistence 10.2 ms - present 381: 243.9 ms at 5448 ms, persistence 9.2 ms - present 396: 251.4 ms at 8893 ms, persistence 8.9 ms - present 391: 221.3 ms at 7772 ms, persistence 8.3 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | title | 0.0 (0 %) | 0.0 (0 %) | 229.8 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.0 (0 %) | 0.1 (0 %) | 229.7 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | queue worker 0x0 | 199.9 (87 %) | 25.2 (11 %) | 4.7 | 12.7 | Driver.Packet 217.9, Driver.EndSubmission 7.1 | | draw committer | 71.3 (31 %) | 12.5 (5 %) | 145.9 | 1.5 | Graphics.Draw 65.4, Vulkan.DrawFromRecipe 9.0 | | presenter | 1.5 (1 %) | 0.0 (0 %) | 228.3 | 0.1 | VideoOut.Flip 1.5 | | title | 0.0 (0 %) | 0.1 (0 %) | 229.7 | 0.0 | Recorder.Sync 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.8 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.8 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.7 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.1 (0 %) | 229.7 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.7 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.8 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.8 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.4 (0 %) | 229.4 | 0.0 | Recorder.Sync 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.2 (0 %) | 229.6 | 0.0 | Recorder.Sync 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 229.7 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | queue worker 0x23 | 21.7 (9 %) | 205.0 (89 %) | 3.2 | 2.3 | Driver.Packet 222.3, Driver.EndSubmission 4.3 | | gpu | 43.4 (19 %) | 0.0 (0 %) | 186.4 | 0.0 | batch 43.4 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 440.3, Driver.Packet.dispatch 218.0, Driver.Packet.memory_wait 198.2, Driver.Dispatch 154.4, Vulkan.Dispatch 101.9, Vulkan.Dispatch.shader_resources 96.0, Graphics.Draw 65.4, Graphics.Draw.draw_and_resource_release 64.1, batch 43.4, Recorder.Sync 37.6 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x23) 172.5 ms at 571 ms, present 359 - Driver.Packet.memory_wait (queue worker 0x23) 147.8 ms at 852 ms, present 360 - Driver.Packet.memory_wait (queue worker 0x23) 138.9 ms at 2191 ms, present 366 - Driver.Packet.memory_wait (queue worker 0x23) 138.3 ms at 9016 ms, present 396 - Driver.Packet.memory_wait (queue worker 0x23) 134.7 ms at 9762 ms, present 399 - Driver.Packet.memory_wait (queue worker 0x23) 132.9 ms at 6289 ms, present 384 - Driver.Packet.memory_wait (queue worker 0x23) 132.7 ms at 9513 ms, present 398 - Driver.Packet.memory_wait (queue worker 0x23) 132.6 ms at 5327 ms, present 380 - Driver.Packet.memory_wait (queue worker 0x23) 130.7 ms at 8305 ms, present 393 - Driver.Packet.memory_wait (queue worker 0x23) 129.8 ms at 5808 ms, present 382 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 27522: 11.5 ms at 6829 ms, present 386: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.4, Driver.Packet.dispatch (queue worker 0x0) 12.4, Driver.Dispatch (queue worker 0x0) 12.4, Vulkan.Dispatch (queue worker 0x0) 11.8 - batch 26135: 10.1 ms at 4317 ms, present 375: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 12.2, Driver.Packet.dispatch (queue worker 0x0) 12.2, Driver.Dispatch (queue worker 0x0) 12.2, Vulkan.Dispatch (queue worker 0x0) 11.7 - batch 28141: 10.0 ms at 7913 ms, present 391: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.2, Driver.Packet.dispatch (queue worker 0x0) 11.2, Driver.Dispatch (queue worker 0x0) 11.1, Vulkan.Dispatch (queue worker 0x0) 10.8 - batch 27896: 9.9 ms at 7485 ms, present 389: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 10.7, Driver.Packet.dispatch (queue worker 0x0) 10.7, Driver.Dispatch (queue worker 0x0) 10.6, Vulkan.Dispatch (queue worker 0x0) 10.3 - batch 26008: 9.9 ms at 4099 ms, present 374: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.5, Driver.Packet.dispatch (queue worker 0x0) 11.5, Driver.Dispatch (queue worker 0x0) 11.4, Vulkan.Dispatch (queue worker 0x0) 11.0 </details> <details><summary>trace_digest.py, this PR 2b129e3a43 with APS5_TAKEOVER_DISCARD=1</summary> **seconds 60:10** from present 358: 46 presents, frame p50 219.2 / p90 245.2 / p99 265.1 / max 265.1 ms, GPU busy 38.2 ms per present NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 10.0.26200, 3200x1800, commit 2b129e3a43c6, dropped: no ```json {"commit":"2b129e3a43c6","dirty":false,"env":{"APS5_LOG_TIMESTAMPS":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TAKEOVER_DISCARD":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"1048576","APS5_TRACE_SECONDS":"60:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 5090","driver":"NVIDIA 617.42","os":"Windows 10.0.26200","cpu":"AMD Ryzen 9 9950X3D 16-Core Processor","cpu_threads":32,"memory_mib":194197,"title_id":"PPSA03974","title":"Cyberpunk 2077","content_version":"02.120.000","resolution":"3200x1800","window":{"spec":"seconds 60:10","first_present":358,"ms":10220.504},"presents":46,"frame_ms":{"p50":219.199,"p90":245.25,"p99":265.113,"max":265.113},"gpu_busy_ms_per_present":38.225,"worker_busy_pct":{"queue worker 0x0":99.448,"queue worker 0x23":99.823},"top_phases_ms_per_frame":{"Driver.Packet":430.191,"Driver.Packet.dispatch":209.628,"Driver.Packet.memory_wait":193.832,"Driver.Dispatch":141.592,"Vulkan.Dispatch":91.666,"Vulkan.Dispatch.shader_resources":86.383,"Graphics.Draw":63.839,"Graphics.Draw.draw_and_resource_release":62.471},"owned_draw_counts":{},"trace_dropped":false,"trace":"aps5-trace-2b129e3a43c6-56876.json.gz"} ``` **Slowest frames** (largest slices inside each, inclusive) - present 390: 265.1 ms at 7181 ms: Driver.Packet (queue worker 0x23) 257.2, Driver.Packet (queue worker 0x0) 249.2, Driver.Packet.memory_wait (queue worker 0x23) 221.7, Driver.Packet.dispatch (queue worker 0x0) 209.6 - present 362: 253.2 ms at 930 ms: Driver.Packet (queue worker 0x23) 251.1, Driver.Packet (queue worker 0x0) 238.0, Driver.Packet.memory_wait (queue worker 0x23) 212.6, Driver.Packet.dispatch (queue worker 0x0) 195.1 - present 359: 250.5 ms at 216 ms: Driver.Packet (queue worker 0x23) 242.9, Driver.Packet (queue worker 0x0) 236.8, Driver.Packet.memory_wait (queue worker 0x23) 211.0, Driver.Packet.dispatch (queue worker 0x0) 207.2 - present 371: 245.4 ms at 2979 ms: Driver.Packet (queue worker 0x23) 238.0, Driver.Packet (queue worker 0x0) 234.2, Driver.Packet.memory_wait (queue worker 0x23) 207.2, Driver.Packet.dispatch (queue worker 0x0) 204.1 - present 369: 245.3 ms at 2505 ms: Driver.Packet (queue worker 0x23) 239.5, Driver.Packet (queue worker 0x0) 233.7, Driver.Packet.memory_wait (queue worker 0x23) 206.9, Driver.Packet.dispatch (queue worker 0x0) 203.6 **Persistent spikes** (frame time above the fastest frame that separates it from a longer frame; one entry per stall, not per frame) - present 390: 265.1 ms at 7181 ms, persistence 67.7 ms - present 362: 253.2 ms at 930 ms, persistence 55.8 ms - present 371: 245.4 ms at 2979 ms, persistence 44.5 ms - present 359: 250.5 ms at 216 ms, persistence 26.8 ms - present 395: 226.9 ms at 8309 ms, persistence 18.0 ms - present 403: 223.9 ms at 9997 ms, persistence 17.4 ms - present 385: 231.1 ms at 6039 ms, persistence 17.3 ms - present 369: 245.3 ms at 2505 ms, persistence 16.8 ms - present 388: 242.4 ms at 6711 ms, persistence 15.4 ms - present 375: 222.7 ms at 3900 ms, persistence 7.3 ms **Threads** (ms per frame) | thread | busy | wait | untraced | in slices < 20 us | largest | |---|---|---|---|---|---| | title | 0.1 (0 %) | 0.1 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | queue worker 0x0 | 193.5 (87 %) | 23.8 (11 %) | 4.9 | 13.3 | Driver.Packet 209.6, Driver.EndSubmission 7.7 | | title | 0.1 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | draw committer | 72.9 (33 %) | 12.9 (6 %) | 136.3 | 1.6 | Graphics.Draw 63.8, Vulkan.DrawFromRecipe 13.2 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | presenter | 2.0 (1 %) | 0.0 (0 %) | 220.2 | 0.1 | VideoOut.Flip 2.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.1 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsStagesAbi 0.0 | | title | 0.0 (0 %) | 0.1 (0 %) | 222.0 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveAbi 0.0 | | title | 0.1 (0 %) | 0.1 (0 %) | 222.0 | 0.0 | Shader.ResolveAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | title | 0.0 (0 %) | 0.0 (0 %) | 222.1 | 0.0 | Shader.ResolveGraphicsStagesAbi 0.0, Shader.ResolveGraphicsAbi 0.0 | | queue worker 0x23 | 19.3 (9 %) | 199.5 (90 %) | 3.4 | 2.4 | Driver.Packet 214.0, Driver.EndSubmission 4.8 | | gpu | 37.5 (17 %) | 0.0 (0 %) | 184.7 | 0.0 | batch 37.5 | **Largest slices** (ms per frame, inclusive, all threads): Driver.Packet 423.6, Driver.Packet.dispatch 209.5, Driver.Packet.memory_wait 191.4, Driver.Dispatch 141.1, Vulkan.Dispatch 91.3, Vulkan.Dispatch.shader_resources 85.9, Graphics.Draw 63.8, Graphics.Draw.draw_and_resource_release 62.4, batch 37.5, Recorder.Sync 27.8 **Longest waits** - Driver.Packet.memory_wait (queue worker 0x23) 146.9 ms at 328 ms, present 359 - Driver.Packet.memory_wait (queue worker 0x23) 145.4 ms at 7308 ms, present 390 - Driver.Packet.memory_wait (queue worker 0x23) 142.4 ms at 1051 ms, present 362 - Driver.Packet.memory_wait (queue worker 0x23) 139.4 ms at 2621 ms, present 369 - Driver.Packet.memory_wait (queue worker 0x23) 139.0 ms at 3094 ms, present 371 - Driver.Packet.memory_wait (queue worker 0x23) 134.8 ms at 1299 ms, present 363 - Driver.Packet.memory_wait (queue worker 0x23) 129.7 ms at 810 ms, present 361 - Driver.Packet.memory_wait (queue worker 0x23) 129.4 ms at 6832 ms, present 388 - Driver.Packet.memory_wait (queue worker 0x23) 127.6 ms at 6154 ms, present 385 - Driver.Packet.memory_wait (queue worker 0x23) 126.1 ms at 2393 ms, present 368 **Largest GPU batches** (GPU ranges inside, and the CPU slices that recorded each, inclusive) - batch 28422: 11.9 ms at 7343 ms, present 390: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 9.6, Driver.Packet.dispatch (queue worker 0x0) 9.6, Driver.Dispatch (queue worker 0x0) 9.5, Vulkan.Dispatch (queue worker 0x0) 9.0 - batch 25027: 11.8 ms at 1091 ms, present 362: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.5, Driver.Packet.dispatch (queue worker 0x0) 11.5, Driver.Dispatch (queue worker 0x0) 11.3, Vulkan.Dispatch (queue worker 0x0) 10.7 - batch 25876: 11.5 ms at 2658 ms, present 369: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 11.0, Driver.Packet.dispatch (queue worker 0x0) 11.0, Driver.Dispatch (queue worker 0x0) 10.9, Vulkan.Dispatch (queue worker 0x0) 10.4 - batch 26115: 11.2 ms at 3128 ms, present 371: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 8.7, Driver.Packet.dispatch (queue worker 0x0) 8.7, Driver.Dispatch (queue worker 0x0) 8.6, Vulkan.Dispatch (queue worker 0x0) 8.1 - batch 27094: 10.9 ms at 4918 ms, present 379: GPU no ranges; recorded by Driver.Packet (queue worker 0x0) 8.4, Driver.Packet.dispatch (queue worker 0x0) 8.4, Driver.Dispatch (queue worker 0x0) 8.4, Vulkan.Dispatch (queue worker 0x0) 8.0 </details> ### The sound version #18369 does this with a proof instead of a guess. The recompiler proves that a compute shader stores every texel of a storage image's level and never reads it, and the driver checks the grid, the user data and the other bindings per dispatch before it drops anything. Its in-run A/B on `main` is +3.4% (n 8). A census on `main` of the takeovers this draft makes, counted without dropping anything (832,522 units of 64 KiB in 12 reports): - 60.5% are under a storage element the compute shader writes, in a dispatch with at least one thread per texel; - about 16% are under color targets; - sampled reads take none. IR dumps of the top programs show copy-rectangle, clear, A16 swizzled and plain global-id stores, which the proof covers. They also show a read-modify-write of the same image at the same texel, about 6% of the units. This draft can drop results that shader then reads, so it can change what that shader computes. The frames I checked still looked right. ### 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: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 (10.0.26200); the game only, no GPU tests - [x] AI-assisted: yes

Pull request closed

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!18348
No description provided.