fix(agc): store pending storage-image results when a queue has no more work #3334

Closed
Tamalero wants to merge 1 commit from upstream-pr/3334 into main
Tamalero commented 2026-10-11 08:06:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-11T08:06:08Z.


What

Fixes #3272.

Cause: storage-image results stay on the GPU until a driver-side read of guest memory (FlushGpuWrites) or, with APS5_STORE_AT_FLIP=1, a flip stores them. A title that polls a result with plain CPU loads gets neither. Ratchet & Clank: Rift Apart writes a 384x216 R32F image from compute and spins on its last float until it is no longer -1.0, before its next flip, so it waits forever.

Fix: when a queue worker runs out of work, either about to sleep or after its second completion poll, it calls VulkanDevice::StoreIdleResults. Under the GPU mutex, that stores every pending result as for a memory access (FlushAllPending) and submits the recorded stores. The submit is essential: the stores go into the open batch, and from an idle worker nothing else would submit it. Nothing is stored while work keeps arriving, and the cost is one lock when nothing is pending.

Tested

CachyOS (Linux 7.2), RTX 4090, NVIDIA 615.78, GCC Release.

  • New agc_driver_store_at_idle: it stores through a storage image, checks the result has not reached guest memory, calls StoreIdleResults, then polls guest memory for 2 s with no wait and no further submission. It passes, and it fails when the SubmitRecorded call is removed.
  • ctest -R '^agc' 359/360 (agc_driver_dcc_keys_first_write, #2188); the rest of the suite 409/410 (pr_overlap_encoding needs a newer Python here).
  • tools/check_conventions.py passes.
  • Ratchet & Clank: Rift Apart: without APS5_EAGER_WRITEBACK it passes the frame-450 wait (3 of 3 runs, the last with exactly this change) and stops later at #3274. Its intro logos also run faster than with eager write-back.

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 (Claude Code)

Tested and written by Claude (AI assistant) on a contributor's machine.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4817609567 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3334). Originally posted by [Tamalero](https://github.com/Tamalero) on 2026-10-11T08:06:08Z. --- ### What Fixes #3272. **Cause:** storage-image results stay on the GPU until a driver-side read of guest memory (`FlushGpuWrites`) or, with `APS5_STORE_AT_FLIP=1`, a flip stores them. A title that polls a result with plain CPU loads gets neither. Ratchet & Clank: Rift Apart writes a 384x216 R32F image from compute and spins on its last float until it is no longer -1.0, before its next flip, so it waits forever. **Fix:** when a queue worker runs out of work, either about to sleep or after its second completion poll, it calls `VulkanDevice::StoreIdleResults`. Under the GPU mutex, that stores every pending result as for a memory access (`FlushAllPending`) and **submits** the recorded stores. The submit is essential: the stores go into the open batch, and from an idle worker nothing else would submit it. Nothing is stored while work keeps arriving, and the cost is one lock when nothing is pending. ### Tested CachyOS (Linux 7.2), RTX 4090, NVIDIA 615.78, GCC Release. - New `agc_driver_store_at_idle`: it stores through a storage image, checks the result has not reached guest memory, calls `StoreIdleResults`, then polls guest memory for 2 s with no wait and no further submission. It passes, and it fails when the `SubmitRecorded` call is removed. - `ctest -R '^agc'` 359/360 (`agc_driver_dcc_keys_first_write`, #2188); the rest of the suite 409/410 (`pr_overlap_encoding` needs a newer Python here). - `tools/check_conventions.py` passes. - Ratchet & Clank: Rift Apart: without `APS5_EAGER_WRITEBACK` it passes the frame-450 wait (3 of 3 runs, the last with exactly this change) and stops later at #3274. Its intro logos also run faster than with eager write-back. ### 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 (Claude Code) *Tested and written by Claude (AI assistant) on a contributor's machine.* 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-11 08:06:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T08:06:19Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106965692 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3334#issuecomment-6106965692). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T08:06:19Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

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