fix(agc): skip the first-visit library prebuild for a pipeline the async build defers #26196

Merged
oneandonlydean merged 2 commits from upstream-pr/26196 into main 2026-11-29 01:59:04 +00:00
oneandonlydean commented 2026-11-23 12:47:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-23T12:47:28Z.


What

Since #25434, commitDraw calls PrebuildGraphicsLibrariesOnFirstVisit
before the draw reaches the APS5_ASYNC_PIPELINE_WORDS check, so a large
first-visit pipeline is compiled on the draw-commit thread again and the
deferral no longer helps. The prebuild now returns early when
DefersPipelineBuild says the deferred-build thread will build it. The
default path (APS5_ASYNC_PIPELINE_WORDS unset) is unchanged.

Fixes #26186.

Tested

On #26186, Jazeupoi (PPSA47770, RTX 2060, Windows 11) exits 4 of 4 runs on main and runs 3 of 3 with #25434 reverted. The change is one early return in VulkanDevice::PrebuildGraphicsLibrariesOnFirstVisit: it returns early when Graphics::DefersPipelineBuild(shaders) is true, the same predicate Graphics/src/Draw.cpp uses to defer. The default path (APS5_ASYNC_PIPELINE_WORDS unset) is unchanged. Not compiled locally; CI builds it.

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: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5453399901 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26196). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-23T12:47:28Z. --- ### What Since #25434, commitDraw calls PrebuildGraphicsLibrariesOnFirstVisit before the draw reaches the APS5_ASYNC_PIPELINE_WORDS check, so a large first-visit pipeline is compiled on the draw-commit thread again and the deferral no longer helps. The prebuild now returns early when DefersPipelineBuild says the deferred-build thread will build it. The default path (APS5_ASYNC_PIPELINE_WORDS unset) is unchanged. Fixes #26186. ### Tested On #26186, Jazeupoi (PPSA47770, RTX 2060, Windows 11) exits 4 of 4 runs on main and runs 3 of 3 with #25434 reverted. The change is one early return in `VulkanDevice::PrebuildGraphicsLibrariesOnFirstVisit`: it returns early when `Graphics::DefersPipelineBuild(shaders)` is true, the same predicate `Graphics/src/Draw.cpp` uses to defer. The default path (`APS5_ASYNC_PIPELINE_WORDS` unset) is unchanged. Not compiled locally; CI builds it. ### 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 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 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
mihiii1337 commented 2026-11-23 12:59:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T12:59:20Z.

Review: CHANGES_REQUESTED


The threshold gate restores the normal cached async route. The documented cache-off combination below still needs the off-lock first visit.

I checked the exact base and head routing and deferred queue in a native Windows CPU fixture using mock pipeline/library creation. For the cache-enabled async path, eight stress runs per arm kept one outstanding build across 64 repeat attempts per run, retained the copied program/view data, waited for the worker at device drain, and handed a worker failure back to the synchronous path. The head skipped the early prebuild. The fixture creates no Vulkan device. The existing Afterglow request in #26186 is the separate title/GPU check.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6022101734 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26196#pullrequestreview-6022101734). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T12:59:20Z. **Review:** CHANGES_REQUESTED --- The threshold gate restores the normal cached async route. The documented cache-off combination below still needs the off-lock first visit. I checked the exact base and head routing and deferred queue in a native Windows CPU fixture using mock pipeline/library creation. For the cache-enabled async path, eight stress runs per arm kept one outstanding build across 64 repeat attempts per run, retained the copied program/view data, waited for the worker at device drain, and handed a worker failure back to the synchronous path. The head skipped the early prebuild. The fixture creates no Vulkan device. The existing Afterglow request in #26186 is the separate title/GPU check. AI-assisted: yes
Jazeupoi commented 2026-11-23 14:17:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-23T14:17:11Z.

Review: COMMENTED


@oneandonlydean the Afterglow check you asked for in #26186, on exactly 8f9a9cae20: it defers the build and keeps presenting, 2 of 2 runs.

Setup: same machine as #26186. Windows 11 Pro (build 26300), AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24, Vulkan 1.4.357), WinLibs GCC 15.2.0 r7, Release. The tree was checked out at 8f9a9cae20 with no other change, and libs and relinker were built from it. Afterglow (PPSA47770), catalog 01.000.006, APS5_ASYNC_PIPELINE_WORDS=100000 and APS5_PROFILE_DRAW=1. Before each run the NVIDIA shader cache (%LOCALAPPDATA%\NVIDIA\DXCache and GLCache) was moved aside as before, and it was restored after each run.

run [pipecache] deferred build presents per 10 s over 95 s submission retirement failed
1 deferred build 0x11fccc541fe21fb6 queued, its draws are skipped until it is resident 547, 598, 567, 600, 600, 600, 600, 600 no
2 same line 497, 585, 599, 580, 587, 590, 494, 504 no

Both runs were still alive when stopped at about 95 s and draw the title's "Flashing lights" notice. On main f5b7e1d1ac the same check exited in 4 of 4 runs (#26186).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6023222290 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26196#pullrequestreview-6023222290). Originally posted by [Jazeupoi](https://github.com/Jazeupoi) on 2026-11-23T14:17:11Z. **Review:** COMMENTED --- @oneandonlydean the Afterglow check you asked for in #26186, on exactly `8f9a9cae20`: it defers the build and keeps presenting, 2 of 2 runs. **Setup:** same machine as #26186. Windows 11 Pro (build 26300), AMD Ryzen 5 3400G, NVIDIA GeForce RTX 2060 (driver 621.24, Vulkan 1.4.357), WinLibs GCC 15.2.0 r7, Release. The tree was checked out at `8f9a9cae20` with no other change, and `libs` and `relinker` were built from it. Afterglow (PPSA47770), catalog 01.000.006, `APS5_ASYNC_PIPELINE_WORDS=100000` and `APS5_PROFILE_DRAW=1`. Before each run the NVIDIA shader cache (`%LOCALAPPDATA%\NVIDIA\DXCache` and `GLCache`) was moved aside as before, and it was restored after each run. | run | `[pipecache] deferred build` | presents per 10 s over 95 s | `submission retirement failed` | | --- | --- | --- | --- | | 1 | `deferred build 0x11fccc541fe21fb6 queued, its draws are skipped until it is resident` | 547, 598, 567, 600, 600, 600, 600, 600 | no | | 2 | same line | 497, 585, 599, 580, 587, 590, 494, 504 | no | Both runs were still alive when stopped at about 95 s and draw the title's "Flashing lights" notice. On `main` `f5b7e1d1ac` the same check exited in 4 of 4 runs (#26186). AI-assisted: yes (Claude Code)
mihiii1337 commented 2026-11-23 15:03:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T15:03:38Z.

Review: APPROVED


Re-reviewed exact head 8f9a9cae20d7c67537df81e64ba09e9ce214f9b9. This resolves my cache-off first-visit blocker.

In an exact production-slice A/B, the previous head performed 0 prebuilds and reached 64 simulated lock-held first visits with the pipeline cache disabled. This head performed all 64 builds off-lock with 0 lock-held misses; eight strict repeats passed. The default path still prebuilt all 64, while the async path used its two workers, copied inputs safely, preserved failure fallback, and drained. Null/empty shader identities no longer enter deferred state, while a valid SPIR-V identity remains deferable.

I also read the complete exact-head Hosted Windows log. It compiles and links agc_driver_graphics_tests.exe, starts agc_pipeline_deferred_build_cache_off as test #2694, and passes it in 0.03 s; the normal deferred-build test #2693 also passes in 0.03 s. The job reports zero failures across 5,579 tests, and every applicable check is successful.

No physical GPU or Afterglow title run was performed or inferred here; the open title report remains separate. This approval is limited to the exact commit above.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6023956816 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26196#pullrequestreview-6023956816). Originally posted by [mihiii1337](https://github.com/mihiii1337) on 2026-11-23T15:03:38Z. **Review:** APPROVED --- Re-reviewed exact head `8f9a9cae20d7c67537df81e64ba09e9ce214f9b9`. This resolves my cache-off first-visit blocker. In an exact production-slice A/B, the previous head performed 0 prebuilds and reached 64 simulated lock-held first visits with the pipeline cache disabled. This head performed all 64 builds off-lock with 0 lock-held misses; eight strict repeats passed. The default path still prebuilt all 64, while the async path used its two workers, copied inputs safely, preserved failure fallback, and drained. Null/empty shader identities no longer enter deferred state, while a valid SPIR-V identity remains deferable. I also read the complete exact-head Hosted Windows log. It compiles and links `agc_driver_graphics_tests.exe`, starts `agc_pipeline_deferred_build_cache_off` as test #2694, and passes it in 0.03 s; the normal deferred-build test #2693 also passes in 0.03 s. The job reports zero failures across 5,579 tests, and every applicable check is successful. No physical GPU or Afterglow title run was performed or inferred here; the open title report remains separate. This approval is limited to the exact commit above. AI-assisted: yes
MarcZX10 commented 2026-11-25 08:24:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:24:27Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected logic and added regression coverage support the stated fix.

What I ran

Reviewed head 8f9a9cae20d7c67537df81e64ba09e9ce214f9b9 and the prepared diff. No build or tests were run.

Results

Check Result Note
Diff and targeted code review passed Deferral conditions align
Build and tests not run Not available in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Did not run CI, compile the change, or run the added tests. Read the changed sections of VulkanDevice.cpp, Pipeline.cpp, Graphics.cpp, and agc_driver_graphics_tests.cmake, plus the draw call sites in Draw.cpp. The remainder of Graphics.cpp and VulkanDevice.cpp was not read; no claims are made about those sections. The author reports CI builds the change and describes hardware runs in the PR description; these were not independently verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6054084348 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/26196#pullrequestreview-6054084348). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-25T08:24:27Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected logic and added regression coverage support the stated fix. ## What I ran Reviewed head `8f9a9cae20d7c67537df81e64ba09e9ce214f9b9` and the prepared diff. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted code review | passed | Deferral conditions align | | Build and tests | not run | Not available in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Did not run CI, compile the change, or run the added tests. Read the changed sections of `VulkanDevice.cpp`, `Pipeline.cpp`, `Graphics.cpp`, and `agc_driver_graphics_tests.cmake`, plus the draw call sites in `Draw.cpp`. The remainder of `Graphics.cpp` and `VulkanDevice.cpp` was not read; no claims are made about those sections. The author reports CI builds the change and describes hardware runs in the PR description; these were not independently verified. ## To get this to a good state Nothing is required.
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!26196
No description provided.