Skip to content

perf(agc): release GPU mutex for early index waits - #723

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/21923
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/21923

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#21923, originally opened by Azaluz.

Source commit: 7abece5f4e062658e32e74e898fca4e09f1ce3dc. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Rebased onto bb89b8a4f5c4. The grouped indirect path from boykopovar#27686 keeps its individual-record fallback. With APS5_INDEX_IN_PLACE_BEHIND_WRITER=1, eligible draws use the in-place index path first, including fixed vertex attributes. When the queue-0 pipelined direct draw still needs the indices on the CPU, release GpuMutex only around the Vulkan timeline wait for an overlapping GPU write, at depth 1 and outside completion.

This runs before resolving host imports, choosing Vulkan input buffers, or recording draw input and attachment state. The queue committer releases its queue lock before dispatching the draw. No import or resource lock is held across the wait. When the mutex is reacquired, the normal proof invalidation runs before draw-state memoization, batch-owned keeps retain their references, and the unlock hook hands off already retired batches.

After relock, check recorder identity, liveness and driver device, then refresh writer evidence and drain intervening writes with the ordinary locked flush. Recorder loss traces draw-skipped and stops both normal and recipe paths before fallback or submit.

Tested

Windows build 26300, WinLibs GCC 15.2, Intel i5-14600KF, NVIDIA RTX 4080 SUPER, driver 621.01. Exact revisions A = bb89b8a4f5c4 and B = 7abece5f4e06.

All 18 common focused tests passed on both revisions with APS5_INDEX_IN_PLACE_BEHIND_WRITER unset and set to 1. The head-only agc_draw_index_flush passed in both modes. The Khronos layer loaded for every Vulkan test, with zero VUID- or SYNC-HAZARD diagnostics. The two CPU packet tests also passed on both revisions.

Vulkan runs used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation and VK_LOADER_DEBUG=layer. agc_driver_committed_read_mapping is registered on Windows.

ctest --test-dir build -R '^(agc_draw_inputs_in_place|agc_driver_committed_read_mapping|agc_driver_draw_offset_indices|agc_driver_draw_offset_indices_poisoned|agc_driver_draw_offset_indices_poisoned_in_place|agc_driver_index_behind_writer_vertex_attributes|agc_driver_pipelined_flush_read_order|agc_driver_pipelined_flush_read_order_draw_pipeline|agc_driver_recorded_kept_bytes|agc_driver_recorder|agc_driver_storage_write_back_no_window|agc_driver_storage_write_back_overhang|agc_driver_storage_write_back_overhang_draw_pipeline|agc_driver_storage_write_back_overhang_plan_verify|agc_driver_uniform_indirect_records_enabled|agc_driver_uniform_indirect_records_reference|agc_driver_write_back_guest_newer|agc_index_in_place_behind_writer)$' -V
ctest --test-dir build -R '^agc_draw_index_flush$' -V # PR head only
ctest --test-dir build -R '^(agc_driver_pm4|agc_prime_utcl2_tests)$' -V # CPU packet checks

GTA V (PPSA04263 v01.010.002). Three matched 60-second pairs in the Ludendorff bank at “Go to the guard”, standing still at 3840×2160 SDR. The in-place switch was unset. Each revision used its own relinked executable and frozen warm cache seed. All six captures confirmed the scene and recorded zero dropped events.

Pair order Presents A → B p50 ms A → B p99 ms A → B Total GpuMutex.wait.* ms/present A → B
AB 172 → 179 345.622 → 333.948 434.820 → 395.913 386.247 → 70.145
BA 177 → 168 341.118 → 354.589 374.259 → 411.614 367.590 → 75.718
AB 178 → 174 336.930 → 345.634 380.121 → 399.737 380.029 → 70.876

Mean aggregate GPU mutex wait across workers fell from 377.96 to 72.25 ms per present (−80.88%). Baseline wait varied by 18.66 ms per present. FPS, p50 and p99 changes were within the respective baseline ranges.

Metric Mean A → B Baseline run-to-run range
FPS 2.9183 → 2.8873 0.0967
Frame p50 (ms) 341.223 → 344.724 8.692
Frame p99 (ms) 396.400 → 402.421 60.561

Main traces and digests · PR traces and digests

Native Linux validation for 7abece5f4e06 is pending. domx4q's previous native Linux run on 241a0a22aeb8

Native trace summary lines from pair 2
{"commit":"bb89b8a4f5c4","dirty":false,"env":{"APS5_DUMP_FRAMES":"4096","APS5_DUMP_FRAMES_EVERY":"60","APS5_DUMP_SCALE":"4","APS5_FORCE_SDR":"1","APS5_HEAP_CACHE_MIB":"1024","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"3145728","APS5_TRACE_SECONDS":"0:60","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 621.01","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600KF","cpu_threads":20,"memory_mib":32537,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.010.002","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":1981,"ms":60199.404},"presents":177,"frame_ms":{"p50":341.118,"p90":358.048,"p99":374.259,"max":379.255},"gpu_busy_ms_per_present":219.410,"worker_busy_pct":{"queue worker 0x0":99.577,"queue worker 0x30":51.209,"queue worker 0x20":61.273,"queue worker 0x38":44.489,"queue worker 0x28":60.460},"phase_totals_ms":{"DrawPipeline.Drain.packet.dispatch":2.369,"DrawPipeline.Drain.packet.flip":40.762,"DrawPipeline.Drain.packet.label_not_queued":64.263,"DrawPipeline.Drain.packet.metadata_pass":117.379,"DrawPipeline.Drain.packet.not_candidate":7310.161,"DrawPipeline.Drain.packet.rendering":12.610,"Driver.Completion":3.278,"Driver.Dispatch":58120.993,"Driver.Dispatch.capture_resources":16141.397,"Driver.Dispatch.decode_key_device_setup":7408.086,"Driver.Dispatch.lookup_cache":12605.054,"Driver.Dispatch.materialize":3819.811,"Driver.Dispatch.prepared_invocation":30.467,"Driver.Draw":36761.936,"Driver.Draw.device_setup":172.906,"Driver.Draw.draw_enqueued":29618.965,"Driver.Draw.post_compile_prepare":79.797,"Driver.Draw.prepare":645.366,"Driver.Draw.shader_compile_and_link":6007.489,"Driver.EndSubmission":1330.278,"Driver.FinisherDrain":2.259,"Driver.LandingWait.blocked.memory":33.113,"Driver.LandingWait.blocked.settled":120.538,"Driver.MemoryWait.blocked.recorder.queue_0x0":77096.427,"Driver.MemoryWait.blocked.recorder.queue_0x20":751.979,"Driver.MemoryWait.blocked.recorder.queue_0x28":510.188,"Driver.MemoryWait.blocked.recorder.queue_0x30":384.234,"Driver.MemoryWait.blocked.recorder.queue_0x38":118.542,"Driver.MemoryWait.blocked.store.queue_0x0":12953.811,"Driver.MemoryWait.entry.memory":4.948,"Driver.MemoryWait.entry.store.queue_0x0":1.344,"Driver.Packet":188976.348,"Driver.Packet.device_lock":63.159,"Driver.Packet.dispatch":58270.764,"Driver.Packet.draw":36811.857,"Driver.Packet.execute":682.617,"Driver.Packet.flip_flush":6.115,"Driver.Packet.flush_between_packets":303.691,"Driver.Packet.memory_wait":91824.348,"Driver.Packet.pipeline_drain":201.044,"Driver.Packet.pipeline_prepare":83.554,"Driver.Packet.prepare_memory":217.670,"Driver.Packet.rendering_wait":0.173,"Driver.Present":100.659,"Driver.Present.acquire_image":2.383,"Driver.Present.device_setup":0.084,"Driver.Present.gpu_mutex_wait":0.971,"Driver.Present.inflight_wait":0.404,"Driver.Present.present_display_buffer":18.468,"Driver.Present.queue_present":71.711,"Driver.Present.release_and_callback":0.198,"Driver.Present.render_fence_wait":5.927,"Driver.Present.resize":0.359,"Driver.Present.validate":0.052,"Driver.Rewind":524.495,"Driver.Suspend":0.059,"GpuMutex.wait.dispatch":1323.654,"GpuMutex.wait.draw":6767.158,"GpuMutex.wait.end":1123.136,"GpuMutex.wait.fill":7.986,"GpuMutex.wait.flush":62.016,"GpuMutex.wait.hook":54368.827,"GpuMutex.wait.indirect":1139.739,"GpuMutex.wait.label":270.130,"GpuMutex.wait.other":0.084,"GpuMutex.wait.present":0.697,"Graphics.Draw":32394.572,"Graphics.Draw.draw_and_resource_release":8107.288,"Graphics.Draw.index_upload":23279.399,"Graphics.Draw.validate":339.759,"Graphics.Draw.vertex_upload":626.667,"Graphics.DrawWithRecipe":3973.007,"Graphics.DrawWithRecipe.draw_and_resource_release":1290.549,"Graphics.DrawWithRecipe.index_upload":2552.741,"Graphics.DrawWithRecipe.validate":23.867,"Graphics.DrawWithRecipe.vertex_upload":99.833,"Recorder.Reap":127.773,"Recorder.Submit":713.233,"Recorder.Sync":21915.701,"Recorder.WaitSerial":3213.630,"Resources.Complete":8835.280,"Resources.Prepare":626.338,"Shader.DrawStage":2849.878,"Shader.DrawStage.capture_resources":1727.017,"Shader.DrawStage.materialize":788.466,"Shader.DrawStage.prepared_invocation":308.308,"Shader.ResolveGraphicsStagesAbi":3.253,"VideoOut.Flip":127.368,"VideoOut.Flip.completion_mutex_wait":0.133,"VideoOut.Flip.config_mutex_wait":0.016,"VideoOut.Flip.frame_limit":0.103,"VideoOut.Flip.notify_game":22.077,"VideoOut.Flip.present":100.514,"VideoOut.Flip.validate":0.206,"VideoOut.Flip.vblank_wait":0.091,"VideoOut.Flip.window_prepare":0.281,"VideoOut.Flip.window_title":3.716,"VideoOut.Readiness":0.443,"VideoOut.Readiness.locks_validate":0.161,"Vulkan.Acquire":2.209,"Vulkan.Acquire.acquire_fence_wait":0.332,"Vulkan.Acquire.acquire_image":1.462,"Vulkan.Acquire.fence_reset":0.300,"Vulkan.Acquire.retired_swapchains":0.075,"Vulkan.Dispatch":10866.757,"Vulkan.Dispatch.command_record":934.645,"Vulkan.Dispatch.shader_resources":9924.487,"Vulkan.DispatchRecipe":169.179,"Vulkan.DispatchRecipe.command_record":168.264,"Vulkan.DrawFromRecipe":3986.633,"Vulkan.Present":9.276,"Vulkan.Present.command_record_scale":3.873,"Vulkan.Present.pixel_upload":0.471,"Vulkan.Present.queue_submit":4.796,"Vulkan.QueuePresent":71.498,"Vulkan.QueuePresent.queue_present":71.234,"Vulkan.Retire":5.839,"Vulkan.Retire.dump":0.657,"Vulkan.Retire.wait":1.622},"top_phases_ms_per_frame":{"Driver.Packet":1067.663,"Driver.Packet.memory_wait":518.782,"Driver.MemoryWait.blocked.recorder.queue_0x0":435.573,"Driver.Packet.dispatch":329.213,"Driver.Dispatch":328.367,"GpuMutex.wait.hook":307.169,"Driver.Packet.draw":207.977,"Driver.Draw":207.695},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":10488,"Graphics.Barrier.dcc-clear":7434,"Graphics.Barrier.dcc-keys":3978,"Graphics.Barrier.dispatch-lead":81205,"Graphics.Barrier.dispatch-trail":43543,"Graphics.Barrier.draw":114598,"Graphics.Barrier.fill":8737,"Graphics.Barrier.fill-clear":4602,"Graphics.Barrier.indirect-args":24747,"Graphics.Barrier.input-mirror":3415,"Graphics.Barrier.label-run":70390,"Graphics.Barrier.present-blit":708,"Graphics.Barrier.shadow-publish":2124,"Graphics.Barrier.staging-in":45357,"Graphics.Barrier.staging-out":20983,"Graphics.Barrier.storage-upload":19678,"Graphics.Barrier.storage-writeback":28487,"Graphics.BarrierMerged.dispatch-lead":11900,"Graphics.BarrierMerged.fill":4833,"Graphics.BarrierMerged.label-run":124,"Graphics.BarrierMerged.shadow-publish":1770,"Graphics.BarrierMerged.staging-in":19631,"Graphics.BarrierMerged.staging-out":20983,"Graphics.BarrierMerged.storage-writeback":7259,"Graphics.Copy":74532,"Graphics.Copy.bytes":47252371588,"Graphics.RenderPass":50466,"Graphics.RenderPass.Close.command":30594,"Graphics.RenderPass.Close.image":10513,"Graphics.RenderPass.Close.key":3605,"Graphics.RenderPass.Close.label":124,"Graphics.RenderPass.Close.new-batch":5630,"Graphics.RenderPass.Continued":194310},"trace_dropped":false,"trace":"aps5-trace-bb89b8a4f5c4-21744.json.gz"}
{"commit":"7abece5f4e06","dirty":false,"env":{"APS5_DUMP_FRAMES":"4096","APS5_DUMP_FRAMES_EVERY":"60","APS5_DUMP_SCALE":"4","APS5_FORCE_SDR":"1","APS5_HEAP_CACHE_MIB":"1024","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"<path>","APS5_TRACE_DIR":"<path>","APS5_TRACE_EVENTS":"3145728","APS5_TRACE_SECONDS":"0:60","APS5_TRACE_TRIGGER_FILE":"<path>"},"gpu":"NVIDIA GeForce RTX 4080 SUPER","driver":"NVIDIA 621.01","os":"Windows 10.0.26300","cpu":"Intel(R) Core(TM) i5-14600KF","cpu_threads":20,"memory_mib":32537,"title_id":"PPSA04263","title":"Grand Theft Auto V","content_version":"01.010.002","resolution":"3840x2160","window":{"spec":"seconds 0:60","first_present":1921,"ms":60088.522},"presents":168,"frame_ms":{"p50":354.589,"p90":382.810,"p99":411.614,"max":413.052},"gpu_busy_ms_per_present":227.468,"worker_busy_pct":{"queue worker 0x0":99.589,"queue worker 0x20":69.253,"queue worker 0x28":58.867,"queue worker 0x30":46.993,"queue worker 0x38":45.144},"phase_totals_ms":{"DrawPipeline.Drain.packet.dispatch":3.389,"DrawPipeline.Drain.packet.flip":57.768,"DrawPipeline.Drain.packet.label_not_queued":71.231,"DrawPipeline.Drain.packet.metadata_pass":141.409,"DrawPipeline.Drain.packet.not_candidate":7803.185,"DrawPipeline.Drain.packet.rendering":10.312,"Driver.Completion":2.342,"Driver.Dispatch":58604.841,"Driver.Dispatch.capture_resources":15950.700,"Driver.Dispatch.decode_key_device_setup":7911.637,"Driver.Dispatch.lookup_cache":11652.176,"Driver.Dispatch.materialize":3851.085,"Driver.Dispatch.prepared_invocation":34.786,"Driver.Draw":35979.817,"Driver.Draw.device_setup":174.923,"Driver.Draw.draw_enqueued":29453.093,"Driver.Draw.post_compile_prepare":77.188,"Driver.Draw.prepare":653.529,"Driver.Draw.shader_compile_and_link":5357.692,"Driver.EndSubmission":142.208,"Driver.FinisherDrain":2.218,"Driver.LandingWait.blocked.memory":59.747,"Driver.LandingWait.blocked.settled":104.000,"Driver.MemoryWait.blocked.recorder.queue_0x0":77124.206,"Driver.MemoryWait.blocked.recorder.queue_0x20":1029.381,"Driver.MemoryWait.blocked.recorder.queue_0x28":589.552,"Driver.MemoryWait.blocked.recorder.queue_0x30":204.535,"Driver.MemoryWait.blocked.recorder.queue_0x38":97.439,"Driver.MemoryWait.blocked.store.queue_0x0":15789.273,"Driver.MemoryWait.entry.memory":4.963,"Driver.MemoryWait.entry.store.queue_0x0":1.350,"Driver.Packet":191582.708,"Driver.Packet.device_lock":61.590,"Driver.Packet.dispatch":58766.119,"Driver.Packet.draw":36029.884,"Driver.Packet.execute":377.469,"Driver.Packet.flip_flush":5.437,"Driver.Packet.flush_between_packets":293.564,"Driver.Packet.memory_wait":94844.109,"Driver.Packet.pipeline_drain":220.843,"Driver.Packet.pipeline_prepare":83.463,"Driver.Packet.prepare_memory":157.503,"Driver.Packet.rendering_wait":0.411,"Driver.Present":96.565,"Driver.Present.acquire_image":2.316,"Driver.Present.device_setup":0.096,"Driver.Present.gpu_mutex_wait":0.951,"Driver.Present.inflight_wait":0.402,"Driver.Present.present_display_buffer":18.111,"Driver.Present.queue_present":69.182,"Driver.Present.release_and_callback":0.194,"Driver.Present.render_fence_wait":4.806,"Driver.Present.resize":0.306,"Driver.Present.validate":0.103,"Driver.Rewind":461.193,"Driver.Suspend":0.048,"GpuMutex.wait.dispatch":1733.024,"GpuMutex.wait.draw":6798.505,"GpuMutex.wait.end":54.981,"GpuMutex.wait.fill":7.170,"GpuMutex.wait.flush":53.960,"GpuMutex.wait.hook":2299.195,"GpuMutex.wait.indirect":1523.376,"GpuMutex.wait.label":249.787,"GpuMutex.wait.other":0.024,"GpuMutex.wait.present":0.656,"Graphics.Draw":31208.502,"Graphics.Draw.draw_and_resource_release":8094.298,"Graphics.Draw.index_upload":22083.838,"Graphics.Draw.index_wait":25000.301,"Graphics.Draw.validate":353.217,"Graphics.Draw.vertex_upload":636.067,"Graphics.DrawWithRecipe":4798.676,"Graphics.DrawWithRecipe.draw_and_resource_release":1419.831,"Graphics.DrawWithRecipe.index_upload":3241.407,"Graphics.DrawWithRecipe.validate":25.644,"Graphics.DrawWithRecipe.vertex_upload":105.499,"Recorder.Reap":131.615,"Recorder.Submit":744.900,"Recorder.Sync":33.013,"Recorder.WaitSerial":3223.186,"Resources.Complete":8888.554,"Resources.Prepare":622.572,"Shader.DrawStage":2638.849,"Shader.DrawStage.capture_resources":1545.975,"Shader.DrawStage.materialize":757.702,"Shader.DrawStage.prepared_invocation":309.855,"Shader.ResolveGraphicsStagesAbi":3.151,"VideoOut.Flip":119.786,"VideoOut.Flip.completion_mutex_wait":0.157,"VideoOut.Flip.config_mutex_wait":0.018,"VideoOut.Flip.frame_limit":0.098,"VideoOut.Flip.notify_game":18.388,"VideoOut.Flip.present":96.914,"VideoOut.Flip.validate":0.279,"VideoOut.Flip.vblank_wait":0.097,"VideoOut.Flip.window_prepare":0.262,"VideoOut.Flip.window_title":3.097,"VideoOut.Readiness":0.359,"VideoOut.Readiness.locks_validate":0.150,"Vulkan.Acquire":2.166,"Vulkan.Acquire.acquire_fence_wait":0.318,"Vulkan.Acquire.acquire_image":1.429,"Vulkan.Acquire.fence_reset":0.304,"Vulkan.Acquire.retired_swapchains":0.066,"Vulkan.Dispatch":10948.421,"Vulkan.Dispatch.command_record":963.590,"Vulkan.Dispatch.shader_resources":9975.732,"Vulkan.DispatchRecipe":183.278,"Vulkan.DispatchRecipe.command_record":181.823,"Vulkan.DrawFromRecipe":4812.493,"Vulkan.Present":8.938,"Vulkan.Present.command_record_scale":4.006,"Vulkan.Present.pixel_upload":0.562,"Vulkan.Present.queue_submit":4.245,"Vulkan.QueuePresent":68.971,"Vulkan.QueuePresent.queue_present":68.697,"Vulkan.Retire":4.770,"Vulkan.Retire.dump":0.683,"Vulkan.Retire.wait":1.056},"top_phases_ms_per_frame":{"Driver.Packet":1140.373,"Driver.Packet.memory_wait":564.548,"Driver.MemoryWait.blocked.recorder.queue_0x0":459.073,"Driver.Packet.dispatch":349.798,"Driver.Dispatch":348.838,"Driver.Packet.draw":214.464,"Driver.Draw":214.166,"Graphics.Draw":185.765},"owned_draw_counts":{},"graphics_track":{"Graphics.Barrier.copy":9921,"Graphics.Barrier.dcc-clear":7056,"Graphics.Barrier.dcc-keys":3818,"Graphics.Barrier.dispatch-lead":77176,"Graphics.Barrier.dispatch-trail":41298,"Graphics.Barrier.draw":108269,"Graphics.Barrier.fill":8330,"Graphics.Barrier.fill-clear":4368,"Graphics.Barrier.indirect-args":23490,"Graphics.Barrier.input-mirror":4109,"Graphics.Barrier.label-run":66836,"Graphics.Barrier.present-blit":672,"Graphics.Barrier.shadow-publish":2016,"Graphics.Barrier.staging-in":43257,"Graphics.Barrier.staging-out":19944,"Graphics.Barrier.storage-upload":18350,"Graphics.Barrier.storage-writeback":27055,"Graphics.BarrierMerged.dispatch-lead":11168,"Graphics.BarrierMerged.fill":4586,"Graphics.BarrierMerged.label-run":119,"Graphics.BarrierMerged.shadow-publish":1680,"Graphics.BarrierMerged.staging-in":18486,"Graphics.BarrierMerged.staging-out":19944,"Graphics.BarrierMerged.storage-writeback":6868,"Graphics.Copy":71641,"Graphics.Copy.bytes":44526510794,"Graphics.RenderPass":47627,"Graphics.RenderPass.Close.command":28782,"Graphics.RenderPass.Close.image":10052,"Graphics.RenderPass.Close.key":3431,"Graphics.RenderPass.Close.label":119,"Graphics.RenderPass.Close.new-batch":5242,"Graphics.RenderPass.Continued":184659},"trace_dropped":false,"trace":"aps5-trace-7abece5f4e06-16748.json.gz"}

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 4080 SUPER (Windows build 26300, NVIDIA 621.01)
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability for indexed rendering when GPU synchronization is needed, helping prevent stale draw work from being recorded if the active rendering device changes.
  • Tests
    • Added coverage for indexed-draw synchronization, including overlapping writes and device changes during waits.

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Indexed draw flush and recorder loss

Layer / File(s) Summary
Recorder-aware index flushing
core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp, core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp, core/libs/prx/libSceAgcDriver/tests/Recorder.cpp, core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake
The recorder adds a context-aware flush path for pending writes. The test suite checks overlapping and nonoverlapping ranges, mutex ownership, and recorder or device changes during timeline waits.
Draw preparation and outcome propagation
core/libs/prx/libSceAgcDriver/Execution/include/Recipe.hpp, core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp, core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp, core/libs/prx/libSceAgcDriver/Graphics/include/Draw.hpp, core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
Draw APIs accept a device-current callback. Indexed draw preparation calls the recorder flush and returns a recorder-lost outcome when it fails. VulkanDevice forwards the callback and propagates recipe outcomes.
Driver commit and recorder-loss handling
core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp, core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
The queued draw commit enables index waits and prepares graphics libraries before acquiring the GPU mutex. The driver passes a device-current callback and skips the draw when recording reports recorder loss.

Suggested reviewers: kteal, wallisskill, eaglebearerys

Change: Refactor

Merge Risk: Minimal · up to 7abec

This change releases the GPU mutex during early index waits and skips a draw if the recorder or device is lost during the wait. No concrete defect was found. The previously raised concerns about stale index reads, submission after a skipped draw, and failed waits were checked and not supported. Native Linux validation for this exact revision is still pending.

Security architecture risk: Minimal · up to 7abec

Eligible indexed draws can let other driver work proceed while waiting for the GPU. If the recorder or device changes during that wait, the driver skips the draw rather than recording it or submitting work through the stale device. The reviewed change did not establish a new security exposure or a failure-containment regression.

Security review details

Security Blast Radius

  • inferred — The changed authority is local to the driver process: eligible queue-0 direct indexed draws can release the shared GPU mutex while waiting, allowing other users of the same mutex to make progress. The inspected path does not grant guest commands a new host operation or access to another device.

Trust Boundaries and Controls

  • observed — The unlocked wait requires a depth-one mutex hold, the expected flush hook, the active recorder, and an overlapping pending write, and it is excluded during completion. On relock, a signaled timeline is not enough: the recorder ID and active identity must still match, the driver must confirm the device is current, and the ordinary flush must recheck intervening writes.

Resilience and Maintainability Implications

  • observed — The timeline waiter registers before unlock and unregisters before trying to reacquire GpuMutex, so recorder teardown can wait for the semaphore user to leave without waiting for that user's relock. After relock, batch completion uses the current in-flight queue rather than a batch pointer retained across the wait.

Rollout and rollback

  • observed — The driver, not the guest draw packet, authorizes the early wait and stops the draw if the device is no longer current. No migration is required for this path. An operator who needs to keep waits locked can set APS5_HOOK_LOCKED_WAIT=1 before launching the process; this existing switch also affects ordinary flush-hook waits.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Cppcheck (2.22.0)

Cppcheck (2.22.0) exceeded its 180-second time budget. Findings from completed work are retained; remaining checks are incomplete.

core/libs/prx/libSceAgcDriver/tests/Recorder.cpp

Cppcheck interrupted; analysis of this file is incomplete

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 11
  • Waived: $2.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 04862785-74e2-43c1-bea1-ac8b7e2b507e
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and 7abece5.

Files selected for processing: 11

  • core/libs/prx/libSceAgcDriver/Execution/include/Driver/Driver.hpp
  • core/libs/prx/libSceAgcDriver/Execution/include/Recipe.hpp
  • core/libs/prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp
  • core/libs/prx/libSceAgcDriver/Execution/src/Driver/Draw/Draw.cpp
  • core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp
  • core/libs/prx/libSceAgcDriver/Graphics/include/Draw.hpp
  • core/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hpp
  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp
  • core/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cpp
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp
  • core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_recorder_tests.cmake

Limit details: You’ve used all 10 included reviews currently available.

@github-actions github-actions Bot added perf Performance change needs rebase Conflicts with main, rebase needed labels Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with main, rebase needed perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants