perf(agc): continue render passes across draws without hazards #2670

Merged
oneandonlydean merged 2 commits from upstream-pr/2670 into main 2026-10-10 12:18:15 +00:00
oneandonlydean commented 2026-10-10 10:32:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T10:32:43Z.


What

A recorded draw continued the open render pass only when the previous draw wrote no memory. So every draw with a storage write ended the pass and paid two barriers.

  • New PassHazards (first commit, agc_pass_hazards unit tests). It keeps the guest ranges, images and attachments that the draws since the last barrier read and wrote, and answers whether a new draw has a RAW, WAW or WAR hazard against them.
    • Attachments of the current pass are ordered by rasterization. They conflict only with other passes, or with sampled and storage uses.
  • Continuing the pass (second commit).
    • A draw continues the open pass when it has no hazard.
    • A draw of other attachments with no hazard ends the pass without a barrier and begins its own without one.
    • A hazard break records the begin barrier alone, instead of the pass-end barrier plus the begin barrier.
    • A pass with a depth attachment or attachment proxies, or one with work after the pass, keeps both barriers.
    • APS5_FULL_BARRIERS (existing) keeps every barrier.
  • Address-based draws, draws through buffer device addresses and draws with copied writes count as reading and writing any guest memory. For them the rule is as strict as before.

Tested

Linux (CachyOS, GCC, RTX 4090), Release, on current main:

  • Full ctest passes, including the new agc_pass_hazards, except agc_driver_dcc_keys_first_write, which fails on main too.
  • agc_driver_recorder_tests passes when run by hand, with the groups that fail on main too skipped. Its sample-dump test now goes through the new pass start.
  • tools/check_conventions.py passes.

Astro Bot (PPSA21564), measured on our fork with the same tracker:

  • World map: 587 -> 104 render passes per present; draw-range GPU time 32.6 -> 17.6 ms; 16.8 -> 22.1 fps (+32%).
  • Title: 176 -> 45 passes per present.
  • Sky Garden: 2.44 -> 2.89 fps.
  • Gate runs passed and the frames were checked.

On the fork, draws through buffer device addresses were split further, using the shaders' store information. Here they keep the old rule, so draws that use them gain less.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4810546341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2670). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-10T10:32:43Z. --- ### What A recorded draw continued the open render pass only when the previous draw wrote no memory. So every draw with a storage write ended the pass and paid two barriers. - **New `PassHazards` (first commit, `agc_pass_hazards` unit tests).** It keeps the guest ranges, images and attachments that the draws since the last barrier read and wrote, and answers whether a new draw has a RAW, WAW or WAR hazard against them. - Attachments of the current pass are ordered by rasterization. They conflict only with other passes, or with sampled and storage uses. - **Continuing the pass (second commit).** - A draw continues the open pass when it has no hazard. - A draw of other attachments with no hazard ends the pass without a barrier and begins its own without one. - A hazard break records the begin barrier alone, instead of the pass-end barrier plus the begin barrier. - A pass with a depth attachment or attachment proxies, or one with work after the pass, keeps both barriers. - `APS5_FULL_BARRIERS` (existing) keeps every barrier. - Address-based draws, draws through buffer device addresses and draws with copied writes count as reading and writing any guest memory. For them the rule is as strict as before. ### Tested Linux (CachyOS, GCC, RTX 4090), Release, on current `main`: - Full `ctest` passes, including the new `agc_pass_hazards`, except `agc_driver_dcc_keys_first_write`, which fails on `main` too. - `agc_driver_recorder_tests` passes when run by hand, with the groups that fail on `main` too skipped. Its sample-dump test now goes through the new pass start. - `tools/check_conventions.py` passes. Astro Bot (PPSA21564), measured on our fork with the same tracker: - World map: 587 -> 104 render passes per present; draw-range GPU time 32.6 -> 17.6 ms; **16.8 -> 22.1 fps (+32%)**. - Title: 176 -> 45 passes per present. - Sky Garden: 2.44 -> 2.89 fps. - Gate runs passed and the frames were checked. On the fork, draws through buffer device addresses were split further, using the shaders' store information. Here they keep the old rule, so draws that use them gain less. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
Kikoarl commented 2026-10-10 11:12:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-10T11:12:55Z.


Independent Linux verification on Intel Gen12 graphics (Mesa ANV) and lavapipe:

  • OS / Kernel: Linux 6.x x86_64
  • Hardware: Intel(R) Graphics (RPL-S, 0xa780), Mesa 26.3.0-devel (ANV), Vulkan 1.4.363
  • CPU / Reference: lavapipe (LLVM 23.1.1), Vulkan 1.3.1.1
  • Toolchain: GCC 16.2.1, Ninja, Release (-DBUILD_TESTING=ON)
  • Target: ecc14b0f

Results:

  • tools/check_conventions.py: passed.
  • tools/check_test_registration.py: 557 test executables registered, 0 unregistered.
  • agc_pass_hazards: passed (both on Intel ANV and lavapipe).
  • Full ctest: 689/696 passed (the 7 non-passing tests fail identically on current main here due to the device lacking shaderFloat64 capability).
  • agc_pipeline_library (GPL on & off): 2/2 passed.
  • agc_driver_sampled_cache_budget: passed.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096894583 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2670#issuecomment-6096894583). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-10T11:12:55Z. --- Independent Linux verification on Intel Gen12 graphics (Mesa ANV) and lavapipe: - **OS / Kernel:** Linux 6.x x86_64 - **Hardware:** Intel(R) Graphics (RPL-S, `0xa780`), Mesa 26.3.0-devel (ANV), Vulkan 1.4.363 - **CPU / Reference:** lavapipe (LLVM 23.1.1), Vulkan 1.3.1.1 - **Toolchain:** GCC 16.2.1, Ninja, Release (`-DBUILD_TESTING=ON`) - **Target:** `ecc14b0f` ### Results: - `tools/check_conventions.py`: passed. - `tools/check_test_registration.py`: 557 test executables registered, 0 unregistered. - `agc_pass_hazards`: passed (both on Intel ANV and lavapipe). - Full `ctest`: **689/696 passed** (the 7 non-passing tests fail identically on current `main` here due to the device lacking `shaderFloat64` capability). - `agc_pipeline_library` (GPL on & off): 2/2 passed. - `agc_driver_sampled_cache_budget`: passed. AI-assisted: yes
ArjenS-LA commented 2026-10-10 11:14:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ArjenS-LA on 2026-10-10T11:14:09Z.


Adding a Windows CPU-side check alongside the Linux results above, at head ecc14b0f66e7b4f8d2ad92ca86f7075a977d28bc.

Compiled the unmodified tests/PassHazards.cpp and Graphics/src/PassHazards.cpp together as a standalone executable, using the PR's PassHazards.hpp and the local checkout's bundled Vulkan headers:

  • Windows x64; MinGW-w64 GCC 15.2.0.
  • Flags: -std=c++20 -O2 -DNDEBUG -Wall -Wextra -pedantic-errors.
  • Compilation completed without diagnostics.
  • Execution printed pass hazard tests passed and exited with code 0.

The supplied checks cover range boundaries/coalescing, RAW/WAW/WAR classification, unknown accesses, image conflicts, and attachment tracking across passes. This test uses synthetic image handles and makes no Vulkan calls, so this result covers the standalone CPU tracker only. I have not run the full PR build, recorder integration tests, GPU execution, or the Astro Bot benchmark.

AI-assisted: Codex inspected the code and performed this compilation/test run on my Windows machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6096903830 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2670#issuecomment-6096903830). Originally posted by [ArjenS-LA](https://github.com/ArjenS-LA) on 2026-10-10T11:14:09Z. --- Adding a Windows CPU-side check alongside the Linux results above, at head `ecc14b0f66e7b4f8d2ad92ca86f7075a977d28bc`. Compiled the unmodified `tests/PassHazards.cpp` and `Graphics/src/PassHazards.cpp` together as a standalone executable, using the PR's `PassHazards.hpp` and the local checkout's bundled Vulkan headers: - Windows x64; MinGW-w64 GCC 15.2.0. - Flags: `-std=c++20 -O2 -DNDEBUG -Wall -Wextra -pedantic-errors`. - Compilation completed without diagnostics. - Execution printed `pass hazard tests passed` and exited with code 0. The supplied checks cover range boundaries/coalescing, RAW/WAW/WAR classification, unknown accesses, image conflicts, and attachment tracking across passes. This test uses synthetic image handles and makes no Vulkan calls, so this result covers the standalone CPU tracker only. I have not run the full PR build, recorder integration tests, GPU execution, or the Astro Bot benchmark. AI-assisted: Codex inspected the code and performed this compilation/test run on my Windows machine.
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!2670
No description provided.