fix(agc): track imported draw inputs in render-pass hazards #4887

Closed
Dripl1x wants to merge 1 commit from upstream-pr/4887 into main
Dripl1x commented 2026-10-13 01:54:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dripl1x on 2026-10-13T01:54:12Z.


What

Imported vertex and index buffers are listed in DrawInputs::inPlaceReads, but recordDraw omits them from PassAccess. A draw that reads only these inputs can therefore look memory-free to the render-pass hazard tracker. Overlapping GPU writes can be classified as independent, allowing a pass to continue when it needs an ordering barrier.

Pass these input reads as a separate borrowed span and include them in read-after-write, write-after-read and unknown-write checks. PassHazards::Add retains the ranges, rather than the span. Existing callers default to an empty span. Disjoint and empty ranges retain their current behavior, and this avoids constructing another combined read vector for each draw.

Related to #4649, which changes how pending GPU writes are ordered before imported vertex inputs. This PR contains only the hazard-tracking fix and applies independently to main; it does not include that PR's optimization.

Tested

Windows, NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42; WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON. Based on 0c3dc9ca2b0572cf4239a3c16de3a8a3ba6f8304.

  • Full root CMake build passed (cmake --build build-gpu --parallel 12).

  • Focused CTest run: 4/4 passed, 11.85 s total, with the normal 30 s timeout:

    agc_draw_inputs_in_place   Passed   0.52 s
    agc_pass_hazards           Passed   0.06 s
    agc_driver_graphics        Passed   9.15 s
    agc_driver_bda_device      Passed   1.09 s
    
  • Negative control: compiling the new agc_pass_hazards tests against the original main implementation fails five checks; the fixed implementation passes. New cases cover overlapping reads/writes, input-only draws, unknown writes, retained shader-resource reads, disjoint and empty ranges, and unrelated images.

  • Local Conventions checker, including the commit subject and PR description, and git diff --check passed.

The hazard regression is a CPU test. The imported-input and BDA tests use the NVIDIA Vulkan device; graphics tests also exercise mocked command recording. Windows host imports are compared rather than watched, so the imported-input test skips its kept-highest-index cache subsection. No PS5 title, rendered-frame comparison or game FPS measurement was performed, and no FPS improvement is claimed. Linux and the full CTest suite were not run locally. Independent Windows runs are reported in the comments: the full suite, 1023 of 1023, on an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU, and agc_pass_hazards on an RTX 4080 SUPER.

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; no stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source; none added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42, Windows 11
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4837243183 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4887). Originally posted by [Dripl1x](https://github.com/Dripl1x) on 2026-10-13T01:54:12Z. --- ### What Imported vertex and index buffers are listed in `DrawInputs::inPlaceReads`, but `recordDraw` omits them from `PassAccess`. A draw that reads only these inputs can therefore look memory-free to the render-pass hazard tracker. Overlapping GPU writes can be classified as independent, allowing a pass to continue when it needs an ordering barrier. Pass these input reads as a separate borrowed span and include them in read-after-write, write-after-read and unknown-write checks. `PassHazards::Add` retains the ranges, rather than the span. Existing callers default to an empty span. Disjoint and empty ranges retain their current behavior, and this avoids constructing another combined read vector for each draw. Related to #4649, which changes how pending GPU writes are ordered before imported vertex inputs. This PR contains only the hazard-tracking fix and applies independently to `main`; it does not include that PR's optimization. ### Tested Windows, NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42; WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`. Based on `0c3dc9ca2b0572cf4239a3c16de3a8a3ba6f8304`. - Full root CMake build passed (`cmake --build build-gpu --parallel 12`). - Focused CTest run: **4/4 passed**, 11.85 s total, with the normal 30 s timeout: ```text agc_draw_inputs_in_place Passed 0.52 s agc_pass_hazards Passed 0.06 s agc_driver_graphics Passed 9.15 s agc_driver_bda_device Passed 1.09 s ``` - Negative control: compiling the new `agc_pass_hazards` tests against the original `main` implementation fails five checks; the fixed implementation passes. New cases cover overlapping reads/writes, input-only draws, unknown writes, retained shader-resource reads, disjoint and empty ranges, and unrelated images. - Local Conventions checker, including the commit subject and PR description, and `git diff --check` passed. The hazard regression is a CPU test. The imported-input and BDA tests use the NVIDIA Vulkan device; graphics tests also exercise mocked command recording. Windows host imports are compared rather than watched, so the imported-input test skips its kept-highest-index cache subsection. No PS5 title, rendered-frame comparison or game FPS measurement was performed, and no FPS improvement is claimed. Linux and the full CTest suite were not run locally. Independent Windows runs are reported in the comments: [the full suite, 1023 of 1023, on an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU](https://github.com/boykopovar/AnyPS5/pull/4887#issuecomment-6138449650), and [`agc_pass_hazards` on an RTX 4080 SUPER](https://github.com/boykopovar/AnyPS5/pull/4887#issuecomment-6138357262). ### 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 - [x] Unimplemented paths throw; no stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source; none added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 3070 Laptop GPU, driver 617.42, Windows 11 - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 04:39:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T04:39:06Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main 3779597 together with four other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:

  • tests/PassHazards.cpp (agc_pass_hazards): 3 of 3 runs passed.

Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138357262 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4887#issuecomment-6138357262). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T04:39:06Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on current main `3779597` together with four other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it: - `tests/PassHazards.cpp` (`agc_pass_hazards`): 3 of 3 runs passed. Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed. AI-assisted (Claude Code).
kr4y4 commented 2026-10-13 04:47:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-13T04:47:29Z.


The full suite, which the description lists as not run, on NVIDIA and Intel.

Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 03ea80c17 merged into main 495bf91a0, which passes 1023 of 1023 on both GPUs.

  • agc_pass_hazards passes on both GPUs with --repeat until-fail:3.
  • Full suite (ctest --timeout 120 --parallel 4): 1023 of 1023 on both GPUs, agc_draw_inputs_in_place, agc_driver_graphics and agc_driver_bda_device included.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138449650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4887#issuecomment-6138449650). Originally posted by [kr4y4](https://github.com/kr4y4) on 2026-10-13T04:47:29Z. --- The full suite, which the description lists as not run, on NVIDIA and Intel. Setup: Windows 11 (26200), WinLibs GCC 15.2.0 r7, Release, CI configure flags, an RTX 4070 Laptop GPU and an Intel Raptor Lake-S iGPU. The head 03ea80c17 merged into `main` 495bf91a0, which passes 1023 of 1023 on both GPUs. - `agc_pass_hazards` passes on both GPUs with `--repeat until-fail:3`. - Full suite (`ctest --timeout 120 --parallel 4`): 1023 of 1023 on both GPUs, `agc_draw_inputs_in_place`, `agc_driver_graphics` and `agc_driver_bda_device` included. Written with AI assistance.
oneandonlydean commented 2026-10-14 02:32:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:32:51Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159586718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4887#issuecomment-6159586718). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:32:51Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

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