fix(agc): run the queue-idle store for results a pipeline item leaves pending #22841

Open
slopezjur wants to merge 1 commit from upstream-pr/22841 into main
slopezjur commented 2026-11-18 12:15:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by slopezjur on 2026-11-18T12:15:32Z.


What

Queue 0 runs the idle store (StoreIdleResults) only when it finds storage results pending while every queue is idle. With dispatch miss items on (APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1), the dispatch that leaves those results pending is recorded by the draw committer after queue 0 has already gone idle. Queue 0 found nothing pending, waited for the next submission, and the results were never stored: the result stayed on the GPU until something flushed it directly, or until shutdown (storage image ... destroyed with GPU results pending).

The committer already takes the driver lock and notifies queue 0 when it completes a deferred submission (completeSubmission) and in the submission-end item (wakeQueueZeroForCompletions). Both now also advance the idle epoch when storage results are pending (Driver::noteResultsForIdleStore, skipped with APS5_NO_IDLE_STORE), so a dormant queue 0 checks again and stores them. Nothing changes with miss items off, the default.

New test variants run the two existing idle-store tests with miss items on: agc_driver_store_idle_results_dispatch_misses and agc_driver_idle_store_over_unmap_dispatch_misses. Both failed without this change ("the queue-idle store did not bring the result to guest memory without a direct flush or further submission", "the queue's idle store did not settle the results of the unmapped surface").

Found while measuring dispatch items on by default for Ghost of Yōtei; that default change is held back and is not part of this PR.

Tested

Windows 11, RTX 4080 SUPER (NVIDIA 621.24), Ryzen 7 7800X3D.

GPU tests: ctest -R "^(agc_|shader_)" -V on main 9b262cc4ee and on this branch, same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (Vulkan SDK 1.4.363 layer). main 2002 tests, this branch 2004 (the two new variants, both passing); the layer was inserted 1805 and 1809 times, no was not found but was requested line, 0 VUID- lines in either. Both fail the same 3 and do not build the same 1: agc_driver_stencil_plane_memory, agc_driver_store_over_untracked, agc_driver_msaa_dcc_unwatch; agc_driver_upload_cache_read_only_flush does not compile on Windows. Without the fix, the two idle-store tests failed every time with miss items on (3 of 3 repeats each) and passed with APS5_PIPELINE_DISPATCH=0 or with miss items off.

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: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4080 SUPER, driver 621.24, Windows 11
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5375753633 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22841). Originally posted by [slopezjur](https://github.com/slopezjur) on 2026-11-18T12:15:32Z. --- ### What Queue 0 runs the idle store (`StoreIdleResults`) only when it finds storage results pending while every queue is idle. With dispatch miss items on (`APS5_PIPELINE_DISPATCH=1 APS5_PIPELINE_DISPATCH_MISSES=1`), the dispatch that leaves those results pending is recorded by the draw committer after queue 0 has already gone idle. Queue 0 found nothing pending, waited for the next submission, and the results were never stored: the result stayed on the GPU until something flushed it directly, or until shutdown (`storage image ... destroyed with GPU results pending`). The committer already takes the driver lock and notifies queue 0 when it completes a deferred submission (`completeSubmission`) and in the submission-end item (`wakeQueueZeroForCompletions`). Both now also advance the idle epoch when storage results are pending (`Driver::noteResultsForIdleStore`, skipped with `APS5_NO_IDLE_STORE`), so a dormant queue 0 checks again and stores them. Nothing changes with miss items off, the default. New test variants run the two existing idle-store tests with miss items on: `agc_driver_store_idle_results_dispatch_misses` and `agc_driver_idle_store_over_unmap_dispatch_misses`. Both failed without this change ("the queue-idle store did not bring the result to guest memory without a direct flush or further submission", "the queue's idle store did not settle the results of the unmapped surface"). Found while measuring dispatch items on by default for Ghost of Yōtei; that default change is held back and is not part of this PR. ### Tested Windows 11, RTX 4080 SUPER (NVIDIA 621.24), Ryzen 7 7800X3D. GPU tests: `ctest -R "^(agc_|shader_)" -V` on `main` 9b262cc4ee and on this branch, same machine and GPU, with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer` (Vulkan SDK 1.4.363 layer). `main` 2002 tests, this branch 2004 (the two new variants, both passing); the layer was inserted 1805 and 1809 times, no `was not found but was requested` line, 0 `VUID-` lines in either. Both fail the same 3 and do not build the same 1: `agc_driver_stencil_plane_memory`, `agc_driver_store_over_untracked`, `agc_driver_msaa_dcc_unwatch`; `agc_driver_upload_cache_read_only_flush` does not compile on Windows. Without the fix, the two idle-store tests failed every time with miss items on (3 of 3 repeats each) and passed with `APS5_PIPELINE_DISPATCH=0` or with miss items off. ### 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) 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: none - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4080 SUPER, driver 621.24, Windows 11 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-23 01:30:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T01:30:50Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the author-reported GPU test run supports the described queue-idle wakeup fix, though I did not run checks myself.

What I ran

Reviewed head 8b41f50eb4ee7e2dd3fc4148833962dab3b5268f. No commands or tests were run. I read description.md, commits.md, manifest.json, diff.patch, and the full text of all four changed files listed in the manifest: Driver.hpp, QueueWorker.cpp, agc_driver_idle_store_over_unmap_tests.cmake, and agc_driver_store_idle_results_tests.cmake. The review folder’s files.json was not available through the reader, so excluded files could not be confirmed.

Results

Check Result Note
Changed code review passed All manifest-listed changed files read
Build and tests not run Test results are author-reported
Excluded-file inventory not run files.json was unavailable

Findings

Blocking

None.

Non-blocking

None.

Not verified

I did not run the tests or independently verify the author-reported Windows 11 and RTX 4080 SUPER results. files.json was not readable through the supplied reader, so I could not determine whether any changed files were excluded by rule. The inspected diff changes only the four files listed in manifest.json.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6015640279 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22841#pullrequestreview-6015640279). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-23T01:30:50Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the author-reported GPU test run supports the described queue-idle wakeup fix, though I did not run checks myself. ## What I ran Reviewed head `8b41f50eb4ee7e2dd3fc4148833962dab3b5268f`. No commands or tests were run. I read `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and the full text of all four changed files listed in the manifest: `Driver.hpp`, `QueueWorker.cpp`, `agc_driver_idle_store_over_unmap_tests.cmake`, and `agc_driver_store_idle_results_tests.cmake`. The review folder’s `files.json` was not available through the reader, so excluded files could not be confirmed. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All manifest-listed changed files read | | Build and tests | not run | Test results are author-reported | | Excluded-file inventory | not run | `files.json` was unavailable | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified I did not run the tests or independently verify the author-reported Windows 11 and RTX 4080 SUPER results. `files.json` was not readable through the supplied reader, so I could not determine whether any changed files were excluded by rule. The inspected diff changes only the four files listed in `manifest.json`. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 15:52:34 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T15:52:34Z.

Review: APPROVED


I read the diff at 8b41f50eb4. Windows 11, GCC 15.2, merged into main at c1593e4e1dd together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • the agc_driver_store_idle_results and agc_driver_idle_store tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (the same tree with only this PR's source change taken out): agc_driver_store_idle_results_dispatch_misses fails with "the queue-idle store did not bring the result to guest memory without a direct flush or further submission".

Both agc_driver_idle_store_over_unmap tests skip themselves on this PC.

Not checked: a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6173285884 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22841#pullrequestreview-6173285884). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T15:52:34Z. **Review:** APPROVED --- I read the diff at `8b41f50eb4`. Windows 11, GCC 15.2, merged into `main` at `c1593e4e1dd` together with other open PRs (so not an isolated build), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2). - the `agc_driver_store_idle_results` and `agc_driver_idle_store` tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a `VUID-` or `SYNC-HAZARD` line. - Control (the same tree with only this PR's source change taken out): `agc_driver_store_idle_results_dispatch_misses` fails with "the queue-idle store did not bring the result to guest memory without a direct flush or further submission". Both `agc_driver_idle_store_over_unmap` tests skip themselves on this PC. Not checked: a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 17:18:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:18:17Z.

Review: COMMENTED


I tested 8b41f50eb4 against main at 9d362fb088 on Linux with Mesa lavapipe. The scalar execution test, idle store over unmap, and the default, wake, and disabled idle-store cases passed on both revisions. Both new dispatch-miss cases passed on the change. Every run required Vulkan and disabled the shader cache. The loader inserted VK_LAYER_KHRONOS_validation 1.4.369, with no missing-layer warnings or VUID- messages. This comparison used software Vulkan.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6174788271 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22841#pullrequestreview-6174788271). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T17:18:17Z. **Review:** COMMENTED --- I tested `8b41f50eb4` against `main` at `9d362fb088` on Linux with Mesa lavapipe. The scalar execution test, idle store over unmap, and the default, wake, and disabled idle-store cases passed on both revisions. Both new dispatch-miss cases passed on the change. Every run required Vulkan and disabled the shader cache. The loader inserted `VK_LAYER_KHRONOS_validation` 1.4.369, with no missing-layer warnings or `VUID-` messages. This comparison used software Vulkan. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/22841:upstream-pr/22841'
git switch 'upstream-pr/22841'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/22841'
git switch 'upstream-pr/22841'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/22841'
git switch 'upstream-pr/22841'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/22841'
git switch 'main'
git merge --squash 'upstream-pr/22841'
git switch 'main'
git merge --ff-only 'upstream-pr/22841'
git switch 'main'
git merge 'upstream-pr/22841'
git push origin 'main'
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!22841
No description provided.