fix(agc): wait briefly for a dispatch's background shader work instead of dropping it silently #25226

Merged
Ketz7 merged 1 commit from upstream-pr/25226 into main 2026-11-27 09:36:03 +00:00
Ketz7 commented 2026-11-21 19:39:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ketz7 on 2026-11-21T19:39:49Z.


What

  • With APS5_ASYNC_DRAW_COMPILE, a dispatch whose shader is still being prepared or specialized in the background now waits for that job up to APS5_ASYNC_DISPATCH_WAIT_MS (1000 by default) instead of being dropped.
    • Each job is waited on once, and the waiting is capped at twice the limit in any 10 s, so a long cold preparation still cannot hold a submission up to the guest's GPU timeout.
    • Draws keep skipping as before.
  • A dispatch that is still dropped is logged once per shader, then again with the count once its shader is ready, in the same form as the existing pipeline-skip lines. Before this it was dropped without any log line.
  • Why: a dropped compute dispatch loses data the guest keeps. vkQuake builds each model's BLAS once at level load, so a dropped encode pass left the structure without its header and root parent link. Every refit after that stored 128 MiB past its ready counts, giving about 5,000 BDA faults a minute for the rest of the session, even with every pipeline cached.
  • agc_driver_async_draw_compile now requires the dispatch to store on its first attempt when it may wait. agc_driver_async_draw_compile_no_wait (APS5_ASYNC_DISPATCH_WAIT_MS=0) keeps the old skip covered.
  • docs/dev/ENVIRONMENT.md documents APS5_ASYNC_DISPATCH_WAIT_MS.

Tested

  • PPSA99010 (vkQuake), Windows 11, RX 7900 XT. Each build ran 300 s to cache every pipeline, then 120 s warm with APS5_ASYNC_DRAW_COMPILE=1:
build 0xf60 faults other BDA faults pipeline skips
main 0e001115a9 8155 4 0
this PR 0 0 0
  • The priming runs had the same counts on both builds (about 67,000 at 0xf60), because they still skip dispatches while the 180k-word pipelines build. That loss is the one #21708 is about, and this PR doesn't change it.
  • Cold vkQuake with async compile on main and on this PR (win-perf-pr): both reached demo3 with the same pipeline-skip lines and closed at the 180 s harness limit.
  • agc_driver_async_draw_compile_{enabled,small_pipeline,no_wait,disabled} on Linux (llvmpipe):
    • small_pipeline stores on the first dispatch.
    • no_wait takes 2 and prints dropping the dispatches of compute shader ... and ... prepared after 1 dropped dispatches.
  • tools/check_conventions.py passes.

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: #25225
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (32.0.32015.7029), Windows 11 Pro 10.0.26300; llvmpipe (LLVM 20.1.2) on Linux for the tests
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5431692073 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25226). Originally posted by [Ketz7](https://github.com/Ketz7) on 2026-11-21T19:39:49Z. --- ### What - With `APS5_ASYNC_DRAW_COMPILE`, a dispatch whose shader is still being prepared or specialized in the background now waits for that job up to `APS5_ASYNC_DISPATCH_WAIT_MS` (1000 by default) instead of being dropped. - Each job is waited on once, and the waiting is capped at twice the limit in any 10 s, so a long cold preparation still cannot hold a submission up to the guest's GPU timeout. - Draws keep skipping as before. - A dispatch that is still dropped is logged once per shader, then again with the count once its shader is ready, in the same form as the existing pipeline-skip lines. Before this it was dropped without any log line. - Why: a dropped compute dispatch loses data the guest keeps. vkQuake builds each model's BLAS once at level load, so a dropped encode pass left the structure without its header and root parent link. Every refit after that stored 128 MiB past its ready counts, giving about 5,000 BDA faults a minute for the rest of the session, even with every pipeline cached. - `agc_driver_async_draw_compile` now requires the dispatch to store on its first attempt when it may wait. `agc_driver_async_draw_compile_no_wait` (`APS5_ASYNC_DISPATCH_WAIT_MS=0`) keeps the old skip covered. - `docs/dev/ENVIRONMENT.md` documents `APS5_ASYNC_DISPATCH_WAIT_MS`. ### Tested - PPSA99010 (vkQuake), Windows 11, RX 7900 XT. Each build ran 300 s to cache every pipeline, then 120 s warm with `APS5_ASYNC_DRAW_COMPILE=1`: | build | 0xf60 faults | other BDA faults | pipeline skips | |---|---|---|---| | main 0e001115a9 | 8155 | 4 | 0 | | this PR | 0 | 0 | 0 | - The priming runs had the same counts on both builds (about 67,000 at 0xf60), because they still skip dispatches while the 180k-word pipelines build. That loss is the one #21708 is about, and this PR doesn't change it. - Cold vkQuake with async compile on main and on this PR (`win-perf-pr`): both reached demo3 with the same pipeline-skip lines and closed at the 180 s harness limit. - `agc_driver_async_draw_compile_{enabled,small_pipeline,no_wait,disabled}` on Linux (llvmpipe): - `small_pipeline` stores on the first dispatch. - `no_wait` takes 2 and prints `dropping the dispatches of compute shader ...` and `... prepared after 1 dropped dispatches`. - `tools/check_conventions.py` passes. ### 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) and the licence notice of code adapted from upstream (see AGENTS.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: #25225 - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 7900 XT, AMD proprietary driver 26.10.1 (32.0.32015.7029), Windows 11 Pro 10.0.26300; llvmpipe (LLVM 20.1.2) on Linux for the tests - [x] AI-assisted: yes
MarcZX10 commented 2026-11-22 07:43:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T07:43:38Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this change; the point below is optional.

What I ran

Reviewed head 0eb495f0e1dbb1ecbf6f929d05941889a81f2c62 using repo_read.py reader tools. No build or tests were run. The prepared diff and manifest show eight changed files, all marked included.

Results

Check Result Note
Diff and targeted source review passed Eight changed files inspected
Tests and build not run No execution performed

Findings

Blocking

None.

Non-blocking

  • Diagnostics.cpp:151–152: concurrent dispatches can each receive the same remaining wait allowance because the budget is only charged after waiting. Their combined wait can exceed the stated twice-per-10-second cap. Reserve allowance while holding the budget mutex, then reconcile it after the wait.

Not verified

No build, automated tests, or hardware behavior were verified. Inspected changed-file content: Diagnostics.hpp, Diagnostics.cpp, Dispatch.cpp, DrawCapture.cpp, ShaderRegistry.cpp, agc_driver_async_draw_compile_tests.cmake, AsyncDrawCompile.cpp, and ENVIRONMENT.md. For source files, review was limited to the changed hunks and targeted context; full file contents were not read. No excluded changed files are listed in the manifest.

To get this to a good state

Nothing is required. Optionally reserve the wait budget atomically so simultaneous dispatches cannot exceed the documented cap.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6011093422 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25226#pullrequestreview-6011093422). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T07:43:38Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this change; the point below is optional. ## What I ran Reviewed head `0eb495f0e1dbb1ecbf6f929d05941889a81f2c62` using `repo_read.py` reader tools. No build or tests were run. The prepared diff and manifest show eight changed files, all marked included. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Eight changed files inspected | | Tests and build | not run | No execution performed | ## Findings ### Blocking None. ### Non-blocking - `Diagnostics.cpp:151`–`152`: concurrent dispatches can each receive the same remaining wait allowance because the budget is only charged after waiting. Their combined wait can exceed the stated twice-per-10-second cap. Reserve allowance while holding the budget mutex, then reconcile it after the wait. ## Not verified No build, automated tests, or hardware behavior were verified. Inspected changed-file content: `Diagnostics.hpp`, `Diagnostics.cpp`, `Dispatch.cpp`, `DrawCapture.cpp`, `ShaderRegistry.cpp`, `agc_driver_async_draw_compile_tests.cmake`, `AsyncDrawCompile.cpp`, and `ENVIRONMENT.md`. For source files, review was limited to the changed hunks and targeted context; full file contents were not read. No excluded changed files are listed in the manifest. ## To get this to a good state Nothing is required. Optionally reserve the wait budget atomically so simultaneous dispatches cannot exceed the documented cap.
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!25226
No description provided.