fix(agc): separate pipeline drain and device lock timings #8034

Merged
JJenkx merged 1 commit from upstream-pr/8034 into main 2026-10-23 16:38:06 +00:00
JJenkx commented 2026-10-19 18:17:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-19T18:17:44Z.


What

Driver.Packet.device_lock starts at packet entry, before the draw-pipeline drains. Waiting for queued draws is therefore attributed to the device mutex. Add pipeline_prepare and pipeline_drain checkpoints so the existing device_lock stage measures the subsequent shared-lock section. Packet ordering, lock conditions and drain decisions are unchanged.

This is a profiling attribution fix; it makes no speed claim.

Tested

On current main 8c9161eaca00 and the rebased change (also checked on earlier main f52509acc7d6): trace_digest, agc_performance_trace, agc_driver_graphics, agc_driver_draw_pipeline_trace, and agc_driver_draw_pipeline_trace_disabled: 5/5 passed per revision, no skips. Graphics tests used ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; neither log contains a missing-layer warning or VUID- error. libs builds and conventions pass.

Before the final rebase onto #7119 (allocation diagnostics), native revision 9c59f9fc36de on main f52509acc7d6: Record of Lodoss War (PPSA05347), stationary initial forest: 250-second run exited zero, scripted inputs, screenshots at 190/240 seconds visually checked, normal close, PID gone, kernel setting restored. Official 200:30 trace has no dropped events. The new pipeline_drain phase is 12.982 ms/present in its summary; retained spans include 15,771 pipeline drains and only one device-lock span (22.744 us). Short spans are folded, so retained sums do not measure total mutex time. Reused prior main shader/Mesa caches; no main/change performance comparison is claimed. Four existing storage-image-results-pending warnings were emitted at shutdown, and host-import allocation failures fell back to copies during startup/transition.

Native trace, screenshots and original focused-test evidence. Repeated focused tests on current main and rebased change.

The overlap tool could not compare 11 stale/conflicting shared-file PRs. Manual review of their cached patches found no duplicate timing split; no dependency is needed.

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: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1, Arch Linux (7.2.9-arch1-1).
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4925395583 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8034). Originally posted by [JJenkx](https://github.com/JJenkx) on 2026-10-19T18:17:44Z. --- ### What `Driver.Packet.device_lock` starts at packet entry, before the draw-pipeline drains. Waiting for queued draws is therefore attributed to the device mutex. Add `pipeline_prepare` and `pipeline_drain` checkpoints so the existing `device_lock` stage measures the subsequent shared-lock section. Packet ordering, lock conditions and drain decisions are unchanged. This is a profiling attribution fix; it makes no speed claim. ### Tested On current main `8c9161eaca00` and the rebased change (also checked on earlier main `f52509acc7d6`): `trace_digest`, `agc_performance_trace`, `agc_driver_graphics`, `agc_driver_draw_pipeline_trace`, and `agc_driver_draw_pipeline_trace_disabled`: 5/5 passed per revision, no skips. Graphics tests used `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`; neither log contains a missing-layer warning or `VUID-` error. `libs` builds and conventions pass. Before the final rebase onto #7119 (allocation diagnostics), native revision `9c59f9fc36de` on main `f52509acc7d6`: Record of Lodoss War (PPSA05347), stationary initial forest: 250-second run exited zero, scripted inputs, screenshots at 190/240 seconds visually checked, normal close, PID gone, kernel setting restored. Official 200:30 trace has no dropped events. The new `pipeline_drain` phase is 12.982 ms/present in its summary; retained spans include 15,771 pipeline drains and only one device-lock span (22.744 us). Short spans are folded, so retained sums do not measure total mutex time. Reused prior main shader/Mesa caches; no main/change performance comparison is claimed. Four existing storage-image-results-pending warnings were emitted at shutdown, and host-import allocation failures fell back to copies during startup/transition. [Native trace, screenshots and original focused-test evidence](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/sync161-packet-timing-evidence.tar.gz). [Repeated focused tests on current main and rebased change](https://github.com/JJenkx/AnyPS5/releases/download/game-library-checks-20261016/sync161-current-main-tests.tar.gz). The overlap tool could not compare 11 stale/conflicting shared-file PRs. Manual review of their cached patches found no duplicate timing split; no dependency is needed. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: AMD Radeon RX 6650 XT, RADV Mesa 26.2.4-arch1.1, Arch Linux (7.2.9-arch1-1). <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
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!8034
No description provided.