Skip to content

perf(agc): drain the draw pipeline at a dispatch gate only to resolve a group ahead - #21218

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
talha-devp:perf/dispatch-gate-drain
Nov 16, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
talha-devp:perf/dispatch-gate-drain

Conversation

@talha-devp

Copy link
Copy Markdown
Contributor

What

The first dispatch after a gate opened drained the queue-0 draw pipeline before Driver::resolveGroupAhead. A gate opens at a submission start, a passed wait, a label, or a fill or clear taken by HLE. But resolveGroupAhead returns at once on queue 0 unless APS5_GROUP_CAPTURE_ALL_QUEUES is set. Every queue-0 fill that followed another one therefore waited for the committer to finish all queued draws, for nothing:

  • the fill itself is queued in order behind those draws;
  • a dispatch that is no pipeline item drains on its own in Driver::dispatch.

The drain now sits in resolveGroupAhead, after the queue-0 return and before its other early returns. With APS5_GROUP_CAPTURE_ALL_QUEUES, a dispatch still drains exactly as before.

The gate code runs only while APS5_PIPELINE_DISPATCH is off (!pipelineDispatch() || queue != 0), so the change touches the default path and nothing with that switch on.

Tested

Windows 10 22H2 (19045), RTX 4060 (NVIDIA 621.14), Ryzen 5 5600, MSYS2 UCRT64 GCC 16.2.0, Release.

GPU tests. Run on main df18ede1f2 and on this change on it (852e21c511), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (layer 1.4.363). They cover the 15 tests of nine executables:

  • agc_driver_gated_dispatch_capture_tests
  • agc_driver_pipelined_dispatch_tests
  • agc_driver_pipelined_sample_dump_tests
  • agc_driver_draw_recapture_on_change_tests
  • agc_driver_copied_writer_label_order_tests
  • agc_driver_batch_cap_tests
  • agc_driver_dword_pattern_fill_tests
  • agc_driver_linear_target_completion_points_tests
  • agc_driver_write_data_written_ahead_tests

Both builds: 15 of 15 pass, the loader inserts the layer, and there are 0 VUID- lines.

Hades II (PPSA36082), how it was measured.

1. On main (p0 = df18ede1f2 + #16053 reverted + #20310, pA = p0 + this change).

  • The fill drains drop by about 95 %, measured in one profiled replay each, per 10 s of combat:
    • drains at opcode 0x15: 5,315 to 6,124 → 227 to 283;
    • total packet drain time: 1,410 to 1,470 ms → 613 to 743 ms.
  • FPS does not change, because on main Hades' draw committer is already saturated (its queue sits about 23 of 32 deep). The worker now waits for queue room instead of at the gate.
    • ABBA, dense combat: p0 26.8 FPS (29.2 / 24.5), pA 26.0 FPS (27.5 / 24.5).

2. With a faster committer, it shows.

FPS (rounds) worker µs/draw committer µs/draw draws/frame
z6r-noA 37.4 (37.3 / 37.5) 27.6 22.5 944
z6r (this change) 41.5 (43.3 / 39.8) 25.4 21.8 923

That is +11 %. Both rounds with the change beat both without it, and the worker saves the ~2 µs per draw that the gate drains cost.

Summary lines. tools/trace_digest.py of the 55-65 s window, in this order:

  1. p0
  2. pA
  3. z6r-noA
  4. z6r

Paths are replaced by <path>; APS5_DIAG_PAD_REPLAY is set by my local wrapper and read by nothing in these builds. The traces are kept locally and I can attach them.

Summary lines
{"commit":"f21cf8434576","dirty":false,"env":{"APS5_DIAG_PAD_REPLAY":"<path>","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_NO_PAD_INPUT":"1","APS5_PAD_REPLAY":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"55:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 55:10","first_present":4123,"ms":10000.393},"presents":328,"frame_ms":{"p50":30.67,"p90":37.639,"p99":50.835,"max":175.838},"gpu_busy_ms_per_present":3.706,"worker_busy_pct":{"queue worker 0x0":93.919},"phase_totals_ms":{"Driver.Completion":2.779,"Driver.Dispatch":107.374,"Driver.Dispatch.decode_key_device_setup":1.451,"Driver.Dispatch.lookup_cache":1.031,"Driver.Draw":6800.449,"Driver.Draw.device_setup":365.903,"Driver.Draw.draw_enqueued":1332.0,"Driver.Draw.post_compile_prepare":54.53,"Driver.Draw.prepare":622.217,"Driver.Draw.shader_compile_and_link":3955.608,"Driver.EndSubmission":14.423,"Driver.Packet":9374.966,"Driver.Packet.device_lock":72.362,"Driver.Packet.dispatch":1443.199,"Driver.Packet.draw":6877.374,"Driver.Packet.execute":270.805,"Driver.Packet.flip_flush":25.591,"Driver.Packet.flush_between_packets":194.567,"Driver.Packet.memory_wait":0.027,"Driver.Packet.pipeline_drain":97.525,"Driver.Packet.pipeline_prepare":109.777,"Driver.Packet.prepare_memory":112.714,"Driver.Packet.rendering_wait":0.613,"Driver.Present":531.301,"Driver.Present.acquire_image":5.579,"Driver.Present.device_setup":0.207,"Driver.Present.gpu_mutex_wait":45.497,"Driver.Present.inflight_wait":0.941,"Driver.Present.present_display_buffer":323.774,"Driver.Present.queue_present":141.403,"Driver.Present.release_and_callback":0.483,"Driver.Present.render_fence_wait":12.408,"Driver.Present.resize":0.61,"Driver.Present.validate":0.113,"Driver.Suspend":0.062,"GpuMutex.wait.draw":74.863,"GpuMutex.wait.end":0.968,"GpuMutex.wait.fill":21.233,"GpuMutex.wait.flush":0.074,"GpuMutex.wait.hook":138.208,"GpuMutex.wait.label":0.656,"GpuMutex.wait.present":44.797,"GpuMutex.wait.wait":286.048,"Graphics.Draw":7378.243,"Graphics.Draw.draw_and_resource_release":4148.713,"Graphics.Draw.index_upload":986.39,"Graphics.Draw.validate":404.152,"Graphics.Draw.vertex_upload":1761.199,"Graphics.DrawWithRecipe":129.98,"Graphics.DrawWithRecipe.draw_and_resource_release":68.167,"Graphics.DrawWithRecipe.index_upload":17.688,"Graphics.DrawWithRecipe.validate":4.56,"Graphics.DrawWithRecipe.vertex_upload":38.22,"Graphics.Submit":0.801,"Graphics.Submit.command_end":0.046,"Graphics.Submit.queue_submit":0.752,"Graphics.Wait":51.64,"Graphics.Wait.fence_wait":51.624,"Recorder.Reap":87.714,"Recorder.Submit":275.11,"Recorder.Sync":0.011,"Recorder.WaitSerial":63.316,"Resources.Complete":50.554,"Resources.Prepare":17.807,"Shader.DrawStage":2789.374,"Shader.DrawStage.capture_resources":1755.93,"Shader.DrawStage.materialize":461.487,"Shader.DrawStage.prepared_invocation":536.75,"Shader.PrepareArtifact":16.762,"Shader.ResolveAbi":6.526,"Shader.ResolveGraphicsAbi":3.664,"Shader.ResolveGraphicsStagesAbi":14.081,"VideoOut.Flip":583.999,"VideoOut.Flip.completion_mutex_wait":0.685,"VideoOut.Flip.config_mutex_wait":0.035,"VideoOut.Flip.frame_limit":0.27,"VideoOut.Flip.notify_game":19.474,"VideoOut.Flip.present":532.968,"VideoOut.Flip.validate":0.467,"VideoOut.Flip.vblank_wait":0.299,"VideoOut.Flip.window_prepare":0.587,"VideoOut.Flip.window_title":28.699,"VideoOut.Readiness":1.071,"VideoOut.Readiness.locks_validate":0.478,"Vulkan.Acquire":5.108,"Vulkan.Acquire.acquire_fence_wait":0.818,"Vulkan.Acquire.acquire_image":3.098,"Vulkan.Acquire.fence_reset":0.822,"Vulkan.Acquire.retired_swapchains":0.235,"Vulkan.DispatchRecipe":14.625,"Vulkan.DispatchRecipe.command_record":14.472,"Vulkan.DrawFromRecipe":131.732,"Vulkan.GraphicsPipeline":69.453,"Vulkan.GraphicsPipeline.create":30.789,"Vulkan.GraphicsPipeline.modules_and_state":0.55,"Vulkan.GraphicsPipelineLibrary":68.836,"Vulkan.GraphicsPipelineLink":0.021,"Vulkan.GraphicsPipelinePrebuild":38.347,"Vulkan.Present":68.891,"Vulkan.Present.command_record_scale":16.152,"Vulkan.Present.pixel_upload":36.811,"Vulkan.Present.queue_submit":15.575,"Vulkan.QueuePresent":139.227,"Vulkan.QueuePresent.queue_present":138.529,"Vulkan.Retire":12.353,"Vulkan.Retire.dump":0.46,"Vulkan.Retire.wait":9.572},"top_phases_ms_per_frame":{"Driver.Packet":28.582,"Graphics.Draw":22.495,"Driver.Packet.draw":20.968,"Driver.Draw":20.733,"Graphics.Draw.draw_and_resource_release":12.649,"Driver.Draw.shader_compile_and_link":12.06,"Shader.DrawStage":8.504,"Graphics.Draw.vertex_upload":5.37},"owned_draw_counts":{"OwnedDraw.evicted_other":186397},"graphics_track":{"Graphics.Barrier.dispatch-trail":328,"Graphics.Barrier.draw":42033,"Graphics.Barrier.fill":1597,"Graphics.Barrier.fill-clear":10782,"Graphics.Barrier.input-mirror":1487,"Graphics.Barrier.label-run":15307,"Graphics.Barrier.present-blit":1312,"Graphics.Barrier.shadow-publish":7,"Graphics.Barrier.staging-in":984,"Graphics.Barrier.staging-out":328,"Graphics.Barrier.storage-upload":1797,"Graphics.Barrier.storage-writeback":1922,"Graphics.BarrierMerged.dispatch-lead":328,"Graphics.BarrierMerged.fill":279,"Graphics.BarrierMerged.label-run":4027,"Graphics.BarrierMerged.shadow-publish":3,"Graphics.BarrierMerged.staging-out":328,"Graphics.BarrierMerged.storage-writeback":310,"Graphics.Copy":2190,"Graphics.Copy.bytes":798320376,"Graphics.RenderPass":17294,"Graphics.RenderPass.Close.command":7514,"Graphics.RenderPass.Close.image":1448,"Graphics.RenderPass.Close.key":336,"Graphics.RenderPass.Close.label":4027,"Graphics.RenderPass.Close.new-batch":3969,"Graphics.RenderPass.Continued":247595},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.954,"events_lost":187421,"totals_full":false}},"trace":"aps5-trace-f21cf8434576-9428.json.gz"}
{"commit":"1c42355f4736","dirty":false,"env":{"APS5_DIAG_PAD_REPLAY":"<path>","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_NO_PAD_INPUT":"1","APS5_PAD_REPLAY":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"55:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 55:10","first_present":3987,"ms":10001.034},"presents":307,"frame_ms":{"p50":33.45,"p90":38.67,"p99":48.475,"max":171.841},"gpu_busy_ms_per_present":3.866,"worker_busy_pct":{"queue worker 0x0":94.079},"phase_totals_ms":{"Driver.Completion":2.199,"Driver.Dispatch":190.877,"Driver.Dispatch.decode_key_device_setup":104.812,"Driver.Dispatch.lookup_cache":1.016,"Driver.Draw":7884.818,"Driver.Draw.device_setup":412.309,"Driver.Draw.draw_enqueued":1788.659,"Driver.Draw.post_compile_prepare":55.43,"Driver.Draw.prepare":650.999,"Driver.Draw.shader_compile_and_link":4166.42,"Driver.EndSubmission":15.03,"Driver.Packet":9391.566,"Driver.Packet.device_lock":68.334,"Driver.Packet.dispatch":196.111,"Driver.Packet.draw":7966.507,"Driver.Packet.execute":334.588,"Driver.Packet.flip_flush":28.272,"Driver.Packet.flush_between_packets":198.644,"Driver.Packet.memory_wait":0.023,"Driver.Packet.pipeline_drain":100.557,"Driver.Packet.pipeline_prepare":108.547,"Driver.Packet.prepare_memory":112.552,"Driver.Packet.rendering_wait":0.668,"Driver.Present":485.27,"Driver.Present.acquire_image":5.143,"Driver.Present.device_setup":0.21,"Driver.Present.gpu_mutex_wait":44.008,"Driver.Present.inflight_wait":0.982,"Driver.Present.present_display_buffer":302.002,"Driver.Present.queue_present":120.682,"Driver.Present.release_and_callback":0.518,"Driver.Present.render_fence_wait":10.809,"Driver.Present.resize":0.587,"Driver.Present.validate":0.097,"Driver.Suspend":0.061,"GpuMutex.wait.draw":76.487,"GpuMutex.wait.end":2.373,"GpuMutex.wait.fill":18.144,"GpuMutex.wait.flush":0.423,"GpuMutex.wait.hook":124.052,"GpuMutex.wait.label":1.783,"GpuMutex.wait.present":43.159,"GpuMutex.wait.wait":297.099,"Graphics.Draw":7550.1,"Graphics.Draw.draw_and_resource_release":4320.81,"Graphics.Draw.index_upload":994.949,"Graphics.Draw.validate":407.93,"Graphics.Draw.vertex_upload":1748.178,"Graphics.DrawWithRecipe":154.626,"Graphics.DrawWithRecipe.draw_and_resource_release":81.558,"Graphics.DrawWithRecipe.index_upload":22.082,"Graphics.DrawWithRecipe.validate":5.519,"Graphics.DrawWithRecipe.vertex_upload":43.843,"Graphics.Submit":0.634,"Graphics.Submit.command_end":0.049,"Graphics.Submit.queue_submit":0.582,"Graphics.Wait":45.941,"Graphics.Wait.fence_wait":45.928,"Recorder.Reap":101.234,"Recorder.Submit":306.494,"Recorder.Sync":0.012,"Recorder.WaitSerial":59.934,"Resources.Complete":53.99,"Resources.Prepare":18.68,"Shader.DrawStage":2901.231,"Shader.DrawStage.capture_resources":1832.634,"Shader.DrawStage.materialize":482.881,"Shader.DrawStage.prepared_invocation":549.938,"Shader.PrepareArtifact":6.075,"Shader.ResolveAbi":6.483,"Shader.ResolveGraphicsAbi":3.28,"Shader.ResolveGraphicsStagesAbi":14.806,"VideoOut.Flip":554.552,"VideoOut.Flip.completion_mutex_wait":0.633,"VideoOut.Flip.config_mutex_wait":0.038,"VideoOut.Flip.frame_limit":0.474,"VideoOut.Flip.notify_game":37.123,"VideoOut.Flip.present":486.868,"VideoOut.Flip.validate":0.49,"VideoOut.Flip.vblank_wait":0.242,"VideoOut.Flip.window_prepare":0.548,"VideoOut.Flip.window_title":27.698,"VideoOut.Readiness":0.954,"VideoOut.Readiness.locks_validate":0.379,"Vulkan.Acquire":4.721,"Vulkan.Acquire.acquire_fence_wait":0.696,"Vulkan.Acquire.acquire_image":3.032,"Vulkan.Acquire.fence_reset":0.669,"Vulkan.Acquire.retired_swapchains":0.196,"Vulkan.DispatchRecipe":15.292,"Vulkan.DispatchRecipe.command_record":15.144,"Vulkan.DrawFromRecipe":156.875,"Vulkan.GraphicsPipeline":74.769,"Vulkan.GraphicsPipeline.create":33.734,"Vulkan.GraphicsPipeline.modules_and_state":0.598,"Vulkan.GraphicsPipelineLibrary":74.098,"Vulkan.GraphicsPipelineLink":0.024,"Vulkan.GraphicsPipelinePrebuild":40.645,"Vulkan.Present":66.318,"Vulkan.Present.command_record_scale":15.502,"Vulkan.Present.pixel_upload":33.395,"Vulkan.Present.queue_submit":17.066,"Vulkan.QueuePresent":118.7,"Vulkan.QueuePresent.queue_present":118.097,"Vulkan.Retire":10.768,"Vulkan.Retire.dump":0.46,"Vulkan.Retire.wait":7.994},"top_phases_ms_per_frame":{"Driver.Packet":30.591,"Driver.Packet.draw":25.95,"Driver.Draw":25.683,"Graphics.Draw":24.593,"Graphics.Draw.draw_and_resource_release":14.074,"Driver.Draw.shader_compile_and_link":13.571,"Shader.DrawStage":9.45,"Shader.DrawStage.capture_resources":5.969},"owned_draw_counts":{"OwnedDraw.evicted_other":170792},"graphics_track":{"Graphics.Barrier.dispatch-trail":307,"Graphics.Barrier.draw":39684,"Graphics.Barrier.fill":1508,"Graphics.Barrier.fill-clear":10108,"Graphics.Barrier.input-mirror":1395,"Graphics.Barrier.label-run":14508,"Graphics.Barrier.present-blit":1228,"Graphics.Barrier.shadow-publish":5,"Graphics.Barrier.staging-in":921,"Graphics.Barrier.staging-out":307,"Graphics.Barrier.storage-upload":1710,"Graphics.Barrier.storage-writeback":1804,"Graphics.BarrierMerged.dispatch-lead":307,"Graphics.BarrierMerged.fill":276,"Graphics.BarrierMerged.label-run":3824,"Graphics.BarrierMerged.shadow-publish":1,"Graphics.BarrierMerged.staging-out":307,"Graphics.BarrierMerged.storage-writeback":286,"Graphics.Copy":2050,"Graphics.Copy.bytes":729106272,"Graphics.RenderPass":16345,"Graphics.RenderPass.Close.command":7084,"Graphics.RenderPass.Close.image":1343,"Graphics.RenderPass.Close.key":318,"Graphics.RenderPass.Close.label":3824,"Graphics.RenderPass.Close.new-batch":3776,"Graphics.RenderPass.Continued":228722},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.407,"events_lost":256547,"totals_full":false}},"trace":"aps5-trace-1c42355f4736-9440.json.gz"}
{"commit":"ce86b05d7897","dirty":false,"env":{"APS5_DIAG_PAD_REPLAY":"<path>","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_NO_PAD_INPUT":"1","APS5_PAD_REPLAY":"<path>","APS5_PIPELINE_STATS":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"55:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 55:10","first_present":4300,"ms":10014.62},"presents":423,"frame_ms":{"p50":23.387,"p90":27.489,"p99":35.779,"max":131.57},"gpu_busy_ms_per_present":3.672,"worker_busy_pct":{"queue worker 0x0":93.682},"phase_totals_ms":{"Driver.Completion":7.621,"Driver.Dispatch":79.055,"Driver.Dispatch.decode_key_device_setup":1.855,"Driver.Dispatch.lookup_cache":1.158,"Driver.Draw":7241.544,"Driver.Draw.device_setup":457.481,"Driver.Draw.draw_enqueued":1158.776,"Driver.Draw.post_compile_prepare":70.409,"Driver.Draw.prepare":833.649,"Driver.Draw.shader_compile_and_link":4117.187,"Driver.EndSubmission":5.641,"Driver.Packet":9368.457,"Driver.Packet.device_lock":93.526,"Driver.Packet.dispatch":814.871,"Driver.Packet.draw":7323.196,"Driver.Packet.execute":333.9,"Driver.Packet.flip_flush":17.774,"Driver.Packet.flush_between_packets":237.36,"Driver.Packet.memory_wait":0.029,"Driver.Packet.pipeline_drain":125.909,"Driver.Packet.pipeline_prepare":131.947,"Driver.Packet.prepare_memory":137.044,"Driver.Packet.rendering_wait":1.074,"Driver.Present":396.804,"Driver.Present.acquire_image":7.447,"Driver.Present.device_setup":0.271,"Driver.Present.gpu_mutex_wait":21.188,"Driver.Present.inflight_wait":1.195,"Driver.Present.present_display_buffer":213.146,"Driver.Present.queue_present":139.587,"Driver.Present.release_and_callback":0.675,"Driver.Present.render_fence_wait":11.915,"Driver.Present.resize":0.854,"Driver.Present.validate":0.132,"Driver.Suspend":0.139,"GpuMutex.wait.draw":59.805,"GpuMutex.wait.end":0.684,"GpuMutex.wait.fill":16.179,"GpuMutex.wait.flush":0.136,"GpuMutex.wait.hook":20.129,"GpuMutex.wait.label":0.36,"GpuMutex.wait.present":20.318,"GpuMutex.wait.wait":111.162,"Graphics.Draw":6246.423,"Graphics.Draw.draw_and_resource_release":4765.229,"Graphics.Draw.index_upload":257.84,"Graphics.Draw.validate":426.52,"Graphics.Draw.vertex_upload":707.055,"Graphics.DrawWithRecipe":149.545,"Graphics.DrawWithRecipe.draw_and_resource_release":110.621,"Graphics.DrawWithRecipe.index_upload":7.71,"Graphics.DrawWithRecipe.validate":8.171,"Graphics.DrawWithRecipe.vertex_upload":20.769,"Graphics.Submit":0.41,"Graphics.Submit.command_end":0.028,"Graphics.Submit.queue_submit":0.38,"Graphics.Wait":31.48,"Graphics.Wait.fence_wait":31.47,"Recorder.Reap":109.984,"Recorder.Submit":237.581,"Recorder.WaitSerial":72.651,"Resources.Complete":58.371,"Resources.Prepare":20.019,"Shader.DrawStage":1338.093,"Shader.DrawStage.capture_resources":796.626,"Shader.DrawStage.materialize":252.113,"Shader.DrawStage.prepared_invocation":272.244,"Shader.PrepareArtifact":5.922,"Shader.ResolveAbi":9.191,"Shader.ResolveGraphicsAbi":4.385,"Shader.ResolveGraphicsStagesAbi":20.505,"VideoOut.Flip":483.06,"VideoOut.Flip.completion_mutex_wait":0.821,"VideoOut.Flip.config_mutex_wait":0.041,"VideoOut.Flip.frame_limit":0.511,"VideoOut.Flip.notify_game":44.5,"VideoOut.Flip.present":398.826,"VideoOut.Flip.validate":0.634,"VideoOut.Flip.vblank_wait":0.501,"VideoOut.Flip.window_prepare":0.779,"VideoOut.Flip.window_title":35.712,"VideoOut.Readiness":1.227,"VideoOut.Readiness.locks_validate":0.522,"Vulkan.Acquire":6.845,"Vulkan.Acquire.acquire_fence_wait":1.077,"Vulkan.Acquire.acquire_image":4.283,"Vulkan.Acquire.fence_reset":0.945,"Vulkan.Acquire.retired_swapchains":0.358,"Vulkan.DispatchRecipe":18.321,"Vulkan.DispatchRecipe.command_record":18.137,"Vulkan.DrawFromRecipe":152.498,"Vulkan.GraphicsPipeline":67.291,"Vulkan.GraphicsPipeline.create":66.412,"Vulkan.GraphicsPipeline.modules_and_state":0.616,"Vulkan.GraphicsPipelinePrebuild":0.226,"Vulkan.Present":43.785,"Vulkan.Present.command_record_scale":14.119,"Vulkan.Present.pixel_upload":16.314,"Vulkan.Present.queue_submit":12.776,"Vulkan.QueuePresent":136.845,"Vulkan.QueuePresent.queue_present":136.02,"Vulkan.Retire":11.727,"Vulkan.Retire.dump":0.575,"Vulkan.Retire.wait":8.172},"top_phases_ms_per_frame":{"Driver.Packet":22.148,"Driver.Packet.draw":17.313,"Driver.Draw":17.119,"Graphics.Draw":14.767,"Graphics.Draw.draw_and_resource_release":11.265,"Driver.Draw.shader_compile_and_link":9.733,"Shader.DrawStage":3.163,"Driver.Draw.draw_enqueued":2.739},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.dispatch-trail":423,"Graphics.Barrier.draw":55421,"Graphics.Barrier.fill":2093,"Graphics.Barrier.fill-clear":14054,"Graphics.Barrier.input-mirror":1285,"Graphics.Barrier.label-run":18864,"Graphics.Barrier.present-blit":1692,"Graphics.Barrier.shadow-publish":5,"Graphics.Barrier.staging-in":846,"Graphics.Barrier.staging-out":423,"Graphics.Barrier.storage-upload":2394,"Graphics.Barrier.storage-writeback":2500,"Graphics.BarrierMerged.dispatch-lead":423,"Graphics.BarrierMerged.fill":359,"Graphics.BarrierMerged.label-run":5548,"Graphics.BarrierMerged.shadow-publish":1,"Graphics.BarrierMerged.staging-out":423,"Graphics.BarrierMerged.storage-writeback":389,"Graphics.Copy":1743,"Graphics.Copy.bytes":729961120,"Graphics.RenderPass":22876,"Graphics.RenderPass.Close.command":9925,"Graphics.RenderPass.Close.image":1890,"Graphics.RenderPass.Close.key":779,"Graphics.RenderPass.Close.label":5548,"Graphics.RenderPass.Close.new-batch":4734,"Graphics.RenderPass.Continued":324960},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.382,"events_lost":250621,"totals_full":false}},"trace":"aps5-trace-ce86b05d7897-1316.json.gz"}
{"commit":"bf72beff0fb5","dirty":false,"env":{"APS5_DIAG_PAD_REPLAY":"<path>","APS5_DUMP_FRAMES":"100000","APS5_DUMP_FRAMES_EVERY":"30","APS5_DUMP_SCALE":"8","APS5_NO_PAD_INPUT":"1","APS5_PAD_REPLAY":"<path>","APS5_PIPELINE_STATS":"1","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"55:10","APS5_TRACE_SUMMARY_EVERY":"10"},"gpu":"NVIDIA GeForce RTX 4060","driver":"NVIDIA 621.14","os":"Windows 10.0.19045","cpu":"AMD Ryzen 5 5600 6-Core Processor","cpu_threads":12,"memory_mib":32678,"title_id":"PPSA36082","title":"Hades II","content_version":"01.006.000","resolution":"1920x1080","window":{"spec":"seconds 55:10","first_present":4388,"ms":10014.178},"presents":460,"frame_ms":{"p50":21.531,"p90":24.76,"p99":29.832,"max":169.177},"gpu_busy_ms_per_present":3.601,"worker_busy_pct":{"queue worker 0x0":93.587},"phase_totals_ms":{"Driver.Completion":5.881,"Driver.Dispatch":136.827,"Driver.Dispatch.decode_key_device_setup":73.833,"Driver.Dispatch.lookup_cache":1.313,"Driver.Draw":7827.731,"Driver.Draw.device_setup":470.577,"Driver.Draw.draw_enqueued":1299.953,"Driver.Draw.post_compile_prepare":68.698,"Driver.Draw.prepare":857.142,"Driver.Draw.shader_compile_and_link":4248.781,"Driver.EndSubmission":9.166,"Driver.Packet":9356.729,"Driver.Packet.device_lock":99.037,"Driver.Packet.dispatch":142.603,"Driver.Packet.draw":7915.912,"Driver.Packet.execute":340.169,"Driver.Packet.flip_flush":19.065,"Driver.Packet.flush_between_packets":255.19,"Driver.Packet.memory_wait":0.056,"Driver.Packet.pipeline_drain":135.367,"Driver.Packet.pipeline_prepare":146.088,"Driver.Packet.prepare_memory":139.558,"Driver.Packet.rendering_wait":0.643,"Driver.Present":471.442,"Driver.Present.acquire_image":7.728,"Driver.Present.device_setup":0.366,"Driver.Present.gpu_mutex_wait":35.403,"Driver.Present.inflight_wait":1.607,"Driver.Present.present_display_buffer":249.846,"Driver.Present.queue_present":159.4,"Driver.Present.release_and_callback":0.804,"Driver.Present.render_fence_wait":14.834,"Driver.Present.resize":0.858,"Driver.Present.validate":0.154,"Driver.Suspend":0.187,"GpuMutex.wait.draw":80.243,"GpuMutex.wait.end":0.486,"GpuMutex.wait.fill":10.663,"GpuMutex.wait.flush":0.208,"GpuMutex.wait.hook":33.862,"GpuMutex.wait.label":0.472,"GpuMutex.wait.present":34.446,"GpuMutex.wait.wait":135.458,"Graphics.Draw":6615.361,"Graphics.Draw.draw_and_resource_release":5044.116,"Graphics.Draw.index_upload":288.115,"Graphics.Draw.validate":438.006,"Graphics.Draw.vertex_upload":751.295,"Graphics.DrawWithRecipe":199.009,"Graphics.DrawWithRecipe.draw_and_resource_release":145.964,"Graphics.DrawWithRecipe.index_upload":10.649,"Graphics.DrawWithRecipe.validate":10.676,"Graphics.DrawWithRecipe.vertex_upload":28.659,"Graphics.Submit":0.444,"Graphics.Submit.command_end":0.029,"Graphics.Submit.queue_submit":0.412,"Graphics.Wait":45.817,"Graphics.Wait.fence_wait":45.803,"Recorder.Reap":117.38,"Recorder.Submit":236.542,"Recorder.WaitSerial":95.256,"Resources.Complete":55.587,"Resources.Prepare":17.456,"Shader.DrawStage":1360.518,"Shader.DrawStage.capture_resources":814.432,"Shader.DrawStage.materialize":249.199,"Shader.DrawStage.prepared_invocation":280.893,"Shader.PrepareArtifact":15.059,"Shader.ResolveAbi":9.027,"Shader.ResolveGraphicsAbi":4.662,"Shader.ResolveGraphicsStagesAbi":21.049,"VideoOut.Flip":535.324,"VideoOut.Flip.completion_mutex_wait":1.043,"VideoOut.Flip.config_mutex_wait":0.041,"VideoOut.Flip.frame_limit":0.396,"VideoOut.Flip.notify_game":18.544,"VideoOut.Flip.present":473.766,"VideoOut.Flip.validate":0.69,"VideoOut.Flip.vblank_wait":0.34,"VideoOut.Flip.window_prepare":0.826,"VideoOut.Flip.window_title":39.068,"VideoOut.Readiness":1.332,"VideoOut.Readiness.locks_validate":0.636,"Vulkan.Acquire":7.145,"Vulkan.Acquire.acquire_fence_wait":0.963,"Vulkan.Acquire.acquire_image":4.585,"Vulkan.Acquire.fence_reset":1.131,"Vulkan.Acquire.retired_swapchains":0.279,"Vulkan.DispatchRecipe":19.435,"Vulkan.DispatchRecipe.command_record":19.217,"Vulkan.DrawFromRecipe":202.854,"Vulkan.GraphicsPipeline":68.408,"Vulkan.GraphicsPipeline.create":67.74,"Vulkan.GraphicsPipeline.modules_and_state":0.511,"Vulkan.GraphicsPipelinePrebuild":0.174,"Vulkan.Present":49.287,"Vulkan.Present.command_record_scale":15.964,"Vulkan.Present.pixel_upload":19.594,"Vulkan.Present.queue_submit":13.207,"Vulkan.QueuePresent":156.366,"Vulkan.QueuePresent.queue_present":155.475,"Vulkan.Retire":14.673,"Vulkan.Retire.dump":0.671,"Vulkan.Retire.wait":10.972},"top_phases_ms_per_frame":{"Driver.Packet":20.341,"Driver.Packet.draw":17.209,"Driver.Draw":17.017,"Graphics.Draw":14.381,"Graphics.Draw.draw_and_resource_release":10.965,"Driver.Draw.shader_compile_and_link":9.236,"Shader.DrawStage":2.958,"Driver.Draw.draw_enqueued":2.826},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.dispatch-trail":460,"Graphics.Barrier.draw":58496,"Graphics.Barrier.fill":2305,"Graphics.Barrier.fill-clear":14984,"Graphics.Barrier.input-mirror":1583,"Graphics.Barrier.label-run":19467,"Graphics.Barrier.present-blit":1840,"Graphics.Barrier.shadow-publish":5,"Graphics.Barrier.staging-in":920,"Graphics.Barrier.staging-out":460,"Graphics.Barrier.storage-upload":2560,"Graphics.Barrier.storage-writeback":2728,"Graphics.BarrierMerged.dispatch-lead":460,"Graphics.BarrierMerged.fill":401,"Graphics.BarrierMerged.label-run":5591,"Graphics.BarrierMerged.shadow-publish":1,"Graphics.BarrierMerged.staging-out":460,"Graphics.BarrierMerged.storage-writeback":444,"Graphics.Copy":2079,"Graphics.Copy.bytes":740468416,"Graphics.RenderPass":23998,"Graphics.RenderPass.Close.command":10765,"Graphics.RenderPass.Close.image":1997,"Graphics.RenderPass.Close.key":847,"Graphics.RenderPass.Close.label":5591,"Graphics.RenderPass.Close.new-batch":4798,"Graphics.RenderPass.Continued":351541},"trace_dropped":true,"trace_dropped_threads":{"queue worker 0x0":{"events_full_after_s":5.467,"events_lost":231964,"totals_full":false}},"trace":"aps5-trace-bf72beff0fb5-4672.json.gz"}

Other checks.

  • tools/check_conventions.py --base origin/main passes.
  • tools/pr_overlap.py --branch fails closed: 8 open pull requests that conflict with main share these files, and I checked their diffs.
  • Only perf(agc): build the pipelines of a submission ahead on a compile pool #5925 touches the same lines. It removes resolveGroupAhead's queue-0 return to build pipelines ahead. Whichever merges second should keep this drain on the group-capture path only, not before the pipeline build.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 4060, driver 621.14, Windows 10 22H2
  • AI-assisted: yes

… a group ahead

The first dispatch after a gate opened (a submission start, a passed wait, a label or a fill or
clear taken by HLE) drained the queue-0 draw pipeline before Driver::resolveGroupAhead, which
returns at once on queue 0 unless APS5_GROUP_CAPTURE_ALL_QUEUES is set. Every queue-0 fill that
followed another one therefore waited for the committer to finish all queued draws, for nothing:
the fill itself is queued in order behind them, and a dispatch that is no pipeline item drains on
its own in Driver::dispatch.

The drain now sits in resolveGroupAhead, after the queue-0 return and before its other early
returns, so with APS5_GROUP_CAPTURE_ALL_QUEUES a dispatch still drains exactly as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added perf Performance change agc libSceAgc* labels Nov 16, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good

Nothing blocks this change; the inspected code supports the stated queue-0 drain relocation, and the reported checks are author-supplied.

What I ran

Reviewed head ad967b726e41fd426f82e4c870ebb75df8ae2809 using the pinned repo_read.py reader. No commands or tests were run. Read description.md, commits.md, manifest.json, diff.patch, and the full text of both changed files, plus targeted caller and gate logic in Dispatch.cpp.

Results

Check Result Note
Changed code review passed Both changed files read
Automated tests not run Test results in description are author-reported
Performance measurements not run Traces were not available for inspection

Findings

Blocking

None.

Non-blocking

None.

Not verified

The author-reported Windows GPU test results, performance comparisons, and convention check were not independently run. The files.json document was not available in the review folder listing; manifest.json lists two changed files and both were read. No other repository files were read in full.

To get this to a good state

Nothing is required.

@NathanFahey23

NathanFahey23 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Windows NVIDIA check of head ad967b726e, merged onto main 3251ad6944 (9689a10684, clean merge). This adds an RTX 4080 and the whole GPU set to the RTX 4060 run in the description.

Setup: Windows 11 Home 10.0.26300, i9-13900K, WinLibs GCC 15.2.0, Release, RTX 4080 (10de:2704, driver 32.0.16.2101), ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, Khronos validation layer loaded. GPU set: ctest -R '^(agc_\|shader\|video_out\|guest_video)' --parallel 4, one run per side.

main 3251ad6944 merge 9689a10684
GPU set 1955 pass, 20 skipped, 0 failed 1955 pass, 20 skipped, 0 failed
VUID- lines 0 0
the 26 tests of the nine executables listed in the PR's Tested section 26 Passed 26 Passed
homebrew, 30 s each (tools/title_run.py, cold shader cache) Jelly5 rendering 116.9, VLC rendering 119.4, DriftCheck rendering 54.2, PS5SX2 rendering 59.6, DOOM rendering 36.4 Jelly5 rendering 85.1, VLC rendering 119.5, DriftCheck rendering 59.0, PS5SX2 rendering 59.7, DOOM rendering 36.4

The one test not run on both sides is agc_driver_upload_cache_read_only_flush: its executable does not build on Windows on this main (setenv, fixed by #19899). The homebrew titles are Jelly5, VLC, DriftCheck, PS5SX2 and DOOM; fps is one run each, for whether they still render, not a performance comparison. Jelly5 dropped from about 116 to about 86 fps on every merge I ran after 15:00 local today, including PRs with unrelated changes, so that drop comes from this machine, not from this PR.

Not checked: AMD, Linux, macOS, any commercial title.

AI-assisted: yes

@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Tested on Cyberpunk 2077 (PPSA03974) 02.120.000, the intro movie at 3200x1800, Windows 11 (10.0.26200), RTX 5090 (NVIDIA 617.42), Ryzen 9 9950X3D, WinLibs GCC 15.2 Release. Base: current main e04bd77e7f + #19071 (736364e8d5), which this title needs to run the intro at full speed. This PR's head ad967b726e is merged on top (ba1b4b3908, clean merge). One boot each, presents per 10 s from the 10 s summary windows; the median is over the windows after the first two (loading).

build windows median
base, run 1 113 114 114 112 112 111 110 108 118 113 116 113
base, run 2 96 98 114 106 117 114 110 112 113 121 112.5
this PR 120 120 90 107 94 121 125 133 138 127 132 121

Separate boots of one build on this PC differ by up to about 8%, so +7% over the base is a hint, not a result. No errors or aborts in the run. I'll repeat it with more boots.

@klosixgaming-arch

Copy link
Copy Markdown
Contributor

Follow-up to my comment above, as promised: I repeated this PR with two more boots and ran the base in between, because the PC drifted faster during the session.

Same setup and base (main e04bd77e7f + #19071), intro medians in presents per 10 s:

  • this PR, 3 boots: 121, 116, 120 (mean 119.0)
  • base, 7 boots spread over the session: 113, 112.5, 125, 127, 130, 119, 118 (mean 120.6, SD 6.8)

Difference: -1.4% +- 2.5%. So the first +7% was the PC's drift, and on this scene I can't see a change; with this spread a change of about 7% or more would have shown up. That says nothing about scenes where this path is hotter.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 4448 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 5925 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp
core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 15136 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 16200 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Packets/PacketExecution.cpp
PR 16753 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp
PR 18914 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp
PR 18956 core/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/DispatchAhead.cpp

@oneandonlydean
oneandonlydean merged commit 3619e2a into boykopovar:main Nov 16, 2026
14 checks passed
@cristibctr

cristibctr commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

A neutral data point from a draw-heavy title. GTA V (PPSA04263 01.010.002), open world in Graphics Mode: Performance. Windows 11, RTX 4070 Ti (NVIDIA 621.14), WinLibs GCC 15.2 Release.Method. This PR's head was merged locally onto \main\ \7c444b77ad\ (with #20845, #14561 and #19899) and compared with the same tree without it. Each run was one ^Ggc_frame_replay\ pass of a 30-frame capture, in alternating order, with the trace window \APS5_TRACE_FRAMES=15:12.| draw finisher | build | worker 0 \Driver.Packet\ | \Driver.Packet.pipeline_drain\ | committer \Graphics.Draw\ ||---|---|---|---|---|| on | base (3 runs) | 95.6–96.8 | 2.0–2.1 | 76.9–77.7 || on | this PR (2 runs) | 95.0–95.2 | 1.9–2.0 | 77.2–77.5 || off | base | 119.8 | 1.7 | 96.9 || off | this PR | 120.8 | 2.0 | 97.2 |All values are ms per frame. The first run of this PR (114 ms) is left out: it was the first on a new driver build, and its shader disk cache started empty (0 hits and 8,948 misses, against 8,952 hits and 0 misses in the other runs). In this scene the drain at the dispatch gate costs only about 2 ms per frame, so there is little for this change to remove. This says nothing against it for titles with more queue-0 fills.AI-assisted: yes (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants