fix(agc-driver): delay storage writeback until queue activity settles #4410

Merged
MarcZX10 merged 2 commits from upstream-pr/4410 into main 2026-10-13 01:48:01 +00:00
MarcZX10 commented 2026-10-12 09:48:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T09:48:16Z.


What

Fixes #4398 by waiting for 50 ms of queue quiet before calling StoreIdleResults, and only when storage results are pending and no queue work or completions remain. If queue activity changes the idle epoch during the wait, queue 0 rechecks its state instead of exiting. The existing direct-poll fallback remains available for guest code that reads memory without a read hook.

Tested

Linux Release, Ninja, current main e7c70a2df:

  • Built agc_driver_store_idle_results_tests.
  • ctest -R '^agc_driver_store_idle_results$': passed (1/1) on llvmpipe/lavapipe.
  • agc_driver_store_idle_results_tests --idle-epoch-wake: passed on llvmpipe/lavapipe.
  • tools/check_conventions.py --base upstream/main and git diff --check: passed.

Scramblrrrr's Windows/RTX 5070 Ti cross-test reproduced the interrupted-wait failure on the original code and reported that the regression mode and six related tests pass with the corrected path. Their separate one-run-per-variant game comparison used an older sparse stack and did not demonstrate a meaningful performance gain; it does not establish the reported #4398 performance delta.

Checklist

  • Based on current main; no other open PR implements the same fix
  • 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 (not applicable)
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4827690088 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T09:48:16Z. --- ### What Fixes #4398 by waiting for 50 ms of queue quiet before calling `StoreIdleResults`, and only when storage results are pending and no queue work or completions remain. If queue activity changes the idle epoch during the wait, queue 0 rechecks its state instead of exiting. The existing direct-poll fallback remains available for guest code that reads memory without a read hook. ### Tested Linux Release, Ninja, current `main` `e7c70a2df`: - Built `agc_driver_store_idle_results_tests`. - `ctest -R '^agc_driver_store_idle_results$'`: passed (1/1) on llvmpipe/lavapipe. - `agc_driver_store_idle_results_tests --idle-epoch-wake`: passed on llvmpipe/lavapipe. - `tools/check_conventions.py --base upstream/main` and `git diff --check`: passed. Scramblrrrr's Windows/RTX 5070 Ti cross-test reproduced the interrupted-wait failure on the original code and reported that the regression mode and six related tests pass with the corrected path. Their separate one-run-per-variant game comparison used an older sparse stack and did not demonstrate a meaningful performance gain; it does not establish the reported #4398 performance delta. ### Checklist - [x] Based on current `main`; no other open PR implements the same fix - [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) (not applicable) - [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] AI-assisted: yes
Scramblrrrr commented 2026-10-12 09:51:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T09:51:01Z.


Preparing a Windows/RTX 5070 Ti 007 cross-test of your existing #4410 fix, preserving author/cherry-pick attribution: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-idle-storage-cross-test head e1a2c7f3c (from ddc0d2a65). Applied cleanly to our older public-perf/cache-preserving sparse stack cc495f66d; not a uniform current-main build. Source only so far, native checks/game result pending. Current campaign control is still running, so I am deferring compilation until it ends to keep FPS samples uncontaminated. Will report results here and on #2523. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121841483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6121841483). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T09:51:01Z. --- Preparing a Windows/RTX 5070 Ti 007 cross-test of your existing #4410 fix, preserving author/cherry-pick attribution: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-idle-storage-cross-test head e1a2c7f3c (from ddc0d2a65). Applied cleanly to our older public-perf/cache-preserving sparse stack cc495f66d; not a uniform current-main build. Source only so far, native checks/game result pending. Current campaign control is still running, so I am deferring compilation until it ends to keep FPS samples uncontaminated. Will report results here and on #2523. AI-assisted: Codex.
MarcZX10 commented 2026-10-12 09:51:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T09:51:31Z.


Thanks for preparing the cross-test and for preserving the original commit attribution. The Windows/RTX result on that older stack will be useful context alongside the Linux/lavapipe regression test; please report it whenever your current campaign is finished. No urgency from my side.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121849104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6121849104). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T09:51:31Z. --- Thanks for preparing the cross-test and for preserving the original commit attribution. The Windows/RTX result on that older stack will be useful context alongside the Linux/lavapipe regression test; please report it whenever your current campaign is finished. No urgency from my side.
Scramblrrrr commented 2026-10-12 09:53:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T09:53:51Z.


One control-flow concern while reviewing ddc0d2a65 before staging: in the new quiet wait, if (idleEpoch != idleEpochAtWait) { if (idleResultsPending()) continue; break; } can break the while (!ready()) with queue 0 still having no pending packet. Below that loop, pending.empty() breaks the outer worker loop, so this seems able to permanently stop queue 0 when another queue changes the idle epoch and the storage-idle predicate becomes false (for example outstanding completions or pending work on another queue). ready() was checked false just above.

Would continue to re-evaluate/poll instead of that inner break be appropriate? This is a source-level concern, not a reproduced Windows failure yet; existing StoreIdleResults fixture only submits queue 0 once and may not cover this wake-up. I have not staged the change or claimed a game result.
AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6121883774 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6121883774). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T09:53:51Z. --- One control-flow concern while reviewing ddc0d2a65 before staging: in the new quiet wait, `if (idleEpoch != idleEpochAtWait) { if (idleResultsPending()) continue; break; }` can break the `while (!ready())` with queue 0 still having no pending packet. Below that loop, `pending.empty()` breaks the outer worker loop, so this seems able to permanently stop queue 0 when another queue changes the idle epoch and the storage-idle predicate becomes false (for example outstanding completions or pending work on another queue). `ready()` was checked false just above. Would `continue` to re-evaluate/poll instead of that inner `break` be appropriate? This is a source-level concern, not a reproduced Windows failure yet; existing StoreIdleResults fixture only submits queue 0 once and may not cover this wake-up. I have not staged the change or claimed a game result. AI-assisted: Codex.
Scramblrrrr commented 2026-10-12 10:05:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T10:05:51Z.


Reproduced the wake-up concern on Windows/RTX 5070 Ti. Added a behavioral fixture mode agc_driver_store_idle_results_tests.exe --idle-epoch-wake: observe pending storage, allow queue 0 to enter the quiet wait, explicitly flush under GpuMutex, then submit a NOP on queue 0x30 to move the idle epoch; a subsequent queue-0 dispatch writes a different, initially untouched surface. No old surface contents can satisfy the second check.

Test-only commit 0792abc93 on your original ddc0d2a65 port fails with the original assertion (exit 1): "the queue-idle store did not bring the result to guest memory without a direct flush or further submission". With f7be67521 (replace the epoch-changed block with unconditional continue), the wake mode exits 0 and the existing CTest mode passes 1/1 in 0.48 s. Both targets were rebuilt against matching source/headers/DLLs. The fixture includes teardown before its backing vectors die on failure.

Public cross-test branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-idle-storage-cross-test. Please feel free to cherry-pick 0792abc93 and f7be67521 into #4410; no competing upstream PR. Your original fix remains credited as e1a2c7f3c. Related queue/draw fixtures are building next; corrected game result still pending. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122074733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6122074733). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T10:05:51Z. --- Reproduced the wake-up concern on Windows/RTX 5070 Ti. Added a behavioral fixture mode `agc_driver_store_idle_results_tests.exe --idle-epoch-wake`: observe pending storage, allow queue 0 to enter the quiet wait, explicitly flush under GpuMutex, then submit a NOP on queue 0x30 to move the idle epoch; a subsequent queue-0 dispatch writes a different, initially untouched surface. No old surface contents can satisfy the second check. Test-only commit 0792abc93 on your original ddc0d2a65 port fails with the original assertion (exit 1): "the queue-idle store did not bring the result to guest memory without a direct flush or further submission". With f7be67521 (replace the epoch-changed block with unconditional `continue`), the wake mode exits 0 and the existing CTest mode passes 1/1 in 0.48 s. Both targets were rebuilt against matching source/headers/DLLs. The fixture includes teardown before its backing vectors die on failure. Public cross-test branch: https://github.com/Scramblrrrr/AnyPS5/tree/codex/first-light-idle-storage-cross-test. Please feel free to cherry-pick 0792abc93 and f7be67521 into #4410; no competing upstream PR. Your original fix remains credited as e1a2c7f3c. Related queue/draw fixtures are building next; corrected game result still pending. AI-assisted: Codex.
Scramblrrrr commented 2026-10-12 10:13:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T10:13:49Z.


Corrected idle-writeback stack f7be67521 reached the fully rendered title at frame 848, ~1.61 FPS, ~20.17 decimal GB private. Preceding cc495 control title was frame851 ~1.57 FPS/~20.3 GB. One run/sample each, camera/timing differ, so there is no demonstrated meaningful 007 speed gain from #4410 here. No queue shutdown/new fatal observed during this startup. Stopped intentionally at title for next native cross-test, not a campaign/playability claim.

The concrete contribution is the reproduced multi-queue wake-up failure and its fix already offered on #4410 (0792abc93 / f7be67521). Six related native tests and separate wake mode passed. Host-window #290 preparation 4e4083057 remains source-only and is next; import budget will be explicitly 6144 MiB. AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122199020 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6122199020). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T10:13:49Z. --- Corrected idle-writeback stack f7be67521 reached the fully rendered title at frame 848, ~1.61 FPS, ~20.17 decimal GB private. Preceding cc495 control title was frame851 ~1.57 FPS/~20.3 GB. One run/sample each, camera/timing differ, so there is no demonstrated meaningful 007 speed gain from #4410 here. No queue shutdown/new fatal observed during this startup. Stopped intentionally at title for next native cross-test, not a campaign/playability claim. The concrete contribution is the reproduced multi-queue wake-up failure and its fix already offered on #4410 (0792abc93 / f7be67521). Six related native tests and separate wake mode passed. Host-window #290 preparation 4e4083057 remains source-only and is next; import budget will be explicitly 6144 MiB. AI-assisted: Codex.
MarcZX10 commented 2026-10-12 10:33:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T10:33:36Z.


Good catch. The epoch wake can arrive while the predicate is temporarily false (for example, completion state changes), and breaking there could let queue 0 exit with no queued submission. I changed that path to continue and re-evaluate ready() and the idle/completion predicates. The storage idle regression test passes on Linux/lavapipe after the change, and conventions pass on current main. I also rebased onto current main and corrected the commit subject; the commit remains authored and committed by MarcZX100 with no coauthor trailer.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122508637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6122508637). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T10:33:36Z. --- Good catch. The epoch wake can arrive while the predicate is temporarily false (for example, completion state changes), and breaking there could let queue 0 exit with no queued submission. I changed that path to continue and re-evaluate `ready()` and the idle/completion predicates. The storage idle regression test passes on Linux/lavapipe after the change, and conventions pass on current main. I also rebased onto current main and corrected the commit subject; the commit remains authored and committed by MarcZX100 with no coauthor trailer.
MarcZX10 commented 2026-10-12 10:37:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T10:37:02Z.


I cherry-picked the wake-up regression fixture as a separate commit authored by you, preserving its original author and adding no coauthor trailer. Both the regular CTest case and --idle-epoch-wake now pass here on llvmpipe/lavapipe. The PR title/body now match the repository template; the refreshed conventions workflow is queued.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122571398 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6122571398). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T10:37:02Z. --- I cherry-picked the wake-up regression fixture as a separate commit authored by you, preserving its original author and adding no coauthor trailer. Both the regular CTest case and `--idle-epoch-wake` now pass here on llvmpipe/lavapipe. The PR title/body now match the repository template; the refreshed conventions workflow is queued.
Scramblrrrr commented 2026-10-12 10:37:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T10:37:33Z.


Thanks. I checked 746a6ad73cebb82406bdf36f79ecdf5faf01ae98; its epoch-change path now matches the continue/recheck behavior we independently tested on Windows. My earlier six-test pass and wake-mode pass were on the older port f7be67521, not a build of this newly rebased full head, so I won't conflate those.

The reusable two-surface/multi-queue regression remains separately available as 0792abc93 if you want it in the PR's tests. The 007 quiet title result was 1.61 FPS versus the preceding1.57 control, so no meaningful speedup established for this title. Current run is the separate #290 stack. Thanks for resolving the failure before it got carried further.
AI-assisted: Codex.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6122581361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6122581361). Originally posted by [Scramblrrrr](https://github.com/Scramblrrrr) on 2026-10-12T10:37:33Z. --- Thanks. I checked 746a6ad73cebb82406bdf36f79ecdf5faf01ae98; its epoch-change path now matches the continue/recheck behavior we independently tested on Windows. My earlier six-test pass and wake-mode pass were on the older port f7be67521, not a build of this newly rebased full head, so I won't conflate those. The reusable two-surface/multi-queue regression remains separately available as 0792abc93 if you want it in the PR's tests. The 007 quiet title result was ~1.61 FPS versus the preceding~1.57 control, so no meaningful speedup established for this title. Current run is the separate #290 stack. Thanks for resolving the failure before it got carried further. AI-assisted: Codex.
LeandroLP23 commented 2026-10-12 13:16:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-12T13:16:25Z.


Ran this on AMD hardware, since the GPU tests in CI only use lavapipe: Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, BUILD_TESTING=ON. Head 746a6ad73 merged onto main f8dee0595, together with #4445: on this GPU, main crashes 47 agc_ tests inside amdvlk64.dll without it (#4435), which would hide anything else.

  • ctest -R '^agc_' -j 1: 435/435.
  • ctest -E '^agc_' -j 4: 530/530.
  • agc_driver_store_idle_results: 3/3.
  • agc_driver_store_idle_results_tests --idle-epoch-wake: exit 0, 3/3.
  • With main's QueueWorker.cpp restored, --idle-epoch-wake exits 1, 3/3, with AGC graphics: idle wake fixture did not observe pending storage results. That is the fixture's setup check, not its write-back assertion. The plain ctest case still passes on main's QueueWorker.cpp, so --idle-epoch-wake is the only part that fails without the change.

I can't run Dreaming Sarah here, so this says nothing about the FPS figure in #4398.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6125045929 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6125045929). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-12T13:16:25Z. --- Ran this on AMD hardware, since the GPU tests in CI only use lavapipe: Windows 11 (26300), AMD Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, `BUILD_TESTING=ON`. Head `746a6ad73` merged onto `main` `f8dee0595`, together with #4445: on this GPU, `main` crashes 47 `agc_` tests inside `amdvlk64.dll` without it (#4435), which would hide anything else. - `ctest -R '^agc_' -j 1`: 435/435. - `ctest -E '^agc_' -j 4`: 530/530. - `agc_driver_store_idle_results`: 3/3. - `agc_driver_store_idle_results_tests --idle-epoch-wake`: exit 0, 3/3. - With `main`'s `QueueWorker.cpp` restored, `--idle-epoch-wake` exits 1, 3/3, with `AGC graphics: idle wake fixture did not observe pending storage results`. That is the fixture's setup check, not its write-back assertion. The plain `ctest` case still passes on `main`'s `QueueWorker.cpp`, so `--idle-epoch-wake` is the only part that fails without the change. I can't run Dreaming Sarah here, so this says nothing about the FPS figure in #4398. AI-assisted: yes (Claude Code)
EagleBearerYS commented 2026-10-12 19:11:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-12T19:11:21Z.


Planet of Lana (PPSA19450) is a title where the per-present store costs a lot. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop. The build is a local test stack on main d146ec1b6, with #4267 so the game boots, plus #494, #2863 and #290, which I was measuring for other reasons.

Without a quiet period (main's #3777 behaviour), with Lana standing in the first village:

  • Queue 0 stores the pending results once per present, about 76 stores per 10 s.
  • Each store writes back ten 3840x2160 images, 376 MiB in all: four RGBA16F targets, five other render targets and one display buffer.
  • Each store takes ~6.4 ms of the queue-0 worker, and the GPU spends ~60 ms per present on the copies.
  • All queues are idle for only 5-10 ms between frames, so a quiet period longer than that skips every one of these stores.

With a 16 ms quiet period (my own draft, before I found this PR), the same scene went from 75.1 to 92.3 presents per 10 s. GPU busy time went from 95 to 34 ms per present, read from the driver profile. These are single runs.

That build also needed #2904, now merged: with the store postponed, a compute shader reached reused depth memory as a storage image, and the game stopped with storage image access to depth/stencil surface ... is not implemented until #2904 was added. On current main this is covered. That build also had #4320, now merged too, for frame dumps.

With this PR's queue logic in place of the draft (its QueueWorker.cpp change, the same as at 3824282e5), a later area ran at 177.8 presents per 10 s for 300 s with no errors. That matches the draft's 176.7-181.4 in the same area.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6130876155 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6130876155). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-12T19:11:21Z. --- Planet of Lana (PPSA19450) is a title where the per-present store costs a lot. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop. The build is a local test stack on `main` d146ec1b6, with #4267 so the game boots, plus #494, #2863 and #290, which I was measuring for other reasons. **Without a quiet period** (`main`'s #3777 behaviour), with Lana standing in the first village: - Queue 0 stores the pending results once per present, about 76 stores per 10 s. - Each store writes back ten 3840x2160 images, 376 MiB in all: four RGBA16F targets, five other render targets and one display buffer. - Each store takes ~6.4 ms of the queue-0 worker, and the GPU spends ~60 ms per present on the copies. - All queues are idle for only 5-10 ms between frames, so a quiet period longer than that skips every one of these stores. **With a 16 ms quiet period** (my own draft, before I found this PR), the same scene went from 75.1 to 92.3 presents per 10 s. GPU busy time went from 95 to 34 ms per present, read from the driver profile. These are single runs. That build also needed #2904, now merged: with the store postponed, a compute shader reached reused depth memory as a storage image, and the game stopped with `storage image access to depth/stencil surface ... is not implemented` until #2904 was added. On current `main` this is covered. That build also had #4320, now merged too, for frame dumps. **With this PR's queue logic** in place of the draft (its `QueueWorker.cpp` change, the same as at 3824282e5), a later area ran at 177.8 presents per 10 s for 300 s with no errors. That matches the draft's 176.7-181.4 in the same area.
MarcZX10 commented 2026-10-12 21:39:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-12T21:39:32Z.


Thanks for adding the Planet of Lana measurements and describing the dependency stack. The 300-second run suggests this queue logic avoids per-present writebacks in that later area without errors, and the single-run 16 ms draft comparison is useful context; I will not attribute the frame-rate change to this PR alone. Noted that the reported build also included #4267 and other local stack changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6133102297 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6133102297). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-12T21:39:32Z. --- Thanks for adding the Planet of Lana measurements and describing the dependency stack. The 300-second run suggests this queue logic avoids per-present writebacks in that later area without errors, and the single-run 16 ms draft comparison is useful context; I will not attribute the frame-rate change to this PR alone. Noted that the reported build also included #4267 and other local stack changes.
xXPBSXx commented 2026-10-12 23:24:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T23:24:53Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main 44ab0c39e (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it:

  • tests/execution/StoreIdleResults.cpp (agc_driver_store_idle_results): 3 of 3 runs passed. The QueueWorker.cpp change itself was only exercised through that test; no title was run.

Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6134544699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6134544699). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T23:24:53Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built in a batch with five other open GPU PRs cherry-picked onto main `44ab0c39e` (not current main, which needs a submodule that isn't checked out here), so only the tests that belong to this PR say anything about it: - `tests/execution/StoreIdleResults.cpp` (`agc_driver_store_idle_results`): 3 of 3 runs passed. The `QueueWorker.cpp` change itself was only exercised through that test; no title was run. Not tested: no game run; the batch was not rebuilt per PR, so a failure would have needed a bisect (there was none besides the flake). AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 00:20:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:05Z.


Why 50 ms? EagleBearerYS's PPSA19450 runs cover the gain, but with a 16 ms wait: the queues there are idle for 5-10 ms between frames, so 16 ms already skips every store. A title that polls guest memory with no read hook, the case #3777 went in for, gets each result later by the whole wait, so it should be no longer than it has to be.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135173787 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6135173787). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T00:20:05Z. --- Why 50 ms? EagleBearerYS's PPSA19450 runs cover the gain, but with a 16 ms wait: the queues there are idle for 5-10 ms between frames, so 16 ms already skips every store. A title that polls guest memory with no read hook, the case #3777 went in for, gets each result later by the whole wait, so it should be no longer than it has to be.
EagleBearerYS commented 2026-10-13 00:31:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T00:31:39Z.


A second title shows the same effect: Animal Well (PPSA22520), a 2D game on its own engine. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop. The build is main 43e3a70f8 plus #4859, so the game boots, and #4693, measured with and without this PR at 3824282e5. Same scene each run (new game, first room, standing), APS5_PROFILE_DRAW=1, runs interleaved A, B, A, windows after 80 s:

presents per 10 s GPU busy per present idle write-backs per 10 s flips from the resident image / through guest memory
without this PR 313.5 17.0 ms ~13,750 MiB 2 / 6,821
with this PR 407.8 7.6 ms 0 (one 31.9 MiB store in one window) 9,107 / 4
without, again 336.6 16.4 ms ~14,770 MiB 0 / 7,394

Without the quiet period, the idle store writes back ~41 MiB of storage results every frame, and the flip then reads the 3840x2160 display buffer back from guest memory instead of presenting the resident image. With this PR both go away, and the game goes from ~33 to ~42 fps, beyond this PC's ~15% run-to-run noise. Four more runs with this PR and other settings (mailbox present mode, high thread priority, a smaller batch cap, a usleep trace) stayed at 391-428 presents per 10 s.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135310536 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6135310536). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T00:31:39Z. --- A second title shows the same effect: Animal Well (PPSA22520), a 2D game on its own engine. Setup: Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, RTX 3070 Laptop. The build is `main` 43e3a70f8 plus #4859, so the game boots, and #4693, measured with and without this PR at 3824282e5. Same scene each run (new game, first room, standing), `APS5_PROFILE_DRAW=1`, runs interleaved A, B, A, windows after 80 s: | | presents per 10 s | GPU busy per present | idle write-backs per 10 s | flips from the resident image / through guest memory | |---|---|---|---|---| | without this PR | 313.5 | 17.0 ms | ~13,750 MiB | 2 / 6,821 | | with this PR | 407.8 | 7.6 ms | 0 (one 31.9 MiB store in one window) | 9,107 / 4 | | without, again | 336.6 | 16.4 ms | ~14,770 MiB | 0 / 7,394 | Without the quiet period, the idle store writes back ~41 MiB of storage results every frame, and the flip then reads the 3840x2160 display buffer back from guest memory instead of presenting the resident image. With this PR both go away, and the game goes from ~33 to ~42 fps, beyond this PC's ~15% run-to-run noise. Four more runs with this PR and other settings (mailbox present mode, high thread priority, a smaller batch cap, a usleep trace) stayed at 391-428 presents per 10 s.
EagleBearerYS commented 2026-10-13 01:22:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T01:22:46Z.


On the 16 ms question: I measured both waits on Animal Well (PPSA22520), with the same setup as my comment above. The build is main 43e3a70f8 plus #4859 and #4693, with this PR at 3824282e5; the 16 ms runs change only IdleResultsQuietPeriod. Same scene (new game, first room, standing), APS5_PROFILE_DRAW=1, 10 s windows after 80 s, runs interleaved 50, 16, 50, 16:

wait presents per 10 s GPU busy per present idle write-backs per 10 s flips from the resident image / through guest memory, over the 13 windows
50 ms 402.3 7.8 ms 0 5,230 / 0
16 ms 395.0 7.8 ms 7.2 (18.4 MiB), in 2 of 13 windows 5,131 / 4
50 ms 375.8 8.0 ms 0 4,885 / 0
16 ms 380.5 7.9 ms 11.0 (32.5 MiB), in 4 of 13 windows 4,897 / 51
without this PR 336.6 16.4 ms 7,742 (14,769 MiB) 0 / 4,376

16 ms keeps the gain on this title too. The frame rate matches 50 ms within this PC's ~15% noise (means 388 and 389), and over 99.7% of the write-back volume is gone. It doesn't skip every store, though, because Animal Well's queues stay idle longer between frames than Lana's. An instrumented 50 ms run timed each quiet wait until new activity ended it. In the first room, per 10 s window:

  • median 13.5-15.1 ms, p90 14.7-17.4 ms, p99 15.9-22.7 ms, max 17.4-28.2 ms;
  • 3-82 of the 330-400 waits ran past 16 ms, and none reached 50 ms.

On the logos and menus, the median is 7.5-8.1 ms, and one wait in five windows reached 50 ms. So in these runs, a wait just above 28 ms would have skipped every store in gameplay. A 16 ms wait sits around this title's p90, which is why a few windows still store and the flip then reads the display buffer through guest memory.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6136022043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6136022043). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T01:22:46Z. --- On the 16 ms question: I measured both waits on Animal Well (PPSA22520), with the same setup as my comment above. The build is `main` 43e3a70f8 plus #4859 and #4693, with this PR at 3824282e5; the 16 ms runs change only `IdleResultsQuietPeriod`. Same scene (new game, first room, standing), `APS5_PROFILE_DRAW=1`, 10 s windows after 80 s, runs interleaved 50, 16, 50, 16: | wait | presents per 10 s | GPU busy per present | idle write-backs per 10 s | flips from the resident image / through guest memory, over the 13 windows | |---|---|---|---|---| | 50 ms | 402.3 | 7.8 ms | 0 | 5,230 / 0 | | 16 ms | 395.0 | 7.8 ms | 7.2 (18.4 MiB), in 2 of 13 windows | 5,131 / 4 | | 50 ms | 375.8 | 8.0 ms | 0 | 4,885 / 0 | | 16 ms | 380.5 | 7.9 ms | 11.0 (32.5 MiB), in 4 of 13 windows | 4,897 / 51 | | without this PR | 336.6 | 16.4 ms | 7,742 (14,769 MiB) | 0 / 4,376 | 16 ms keeps the gain on this title too. The frame rate matches 50 ms within this PC's ~15% noise (means 388 and 389), and over 99.7% of the write-back volume is gone. It doesn't skip every store, though, because Animal Well's queues stay idle longer between frames than Lana's. An instrumented 50 ms run timed each quiet wait until new activity ended it. In the first room, per 10 s window: - median 13.5-15.1 ms, p90 14.7-17.4 ms, p99 15.9-22.7 ms, max 17.4-28.2 ms; - 3-82 of the 330-400 waits ran past 16 ms, and none reached 50 ms. On the logos and menus, the median is 7.5-8.1 ms, and one wait in five windows reached 50 ms. So in these runs, a wait just above 28 ms would have skipped every store in gameplay. A 16 ms wait sits around this title's p90, which is why a few windows still store and the flip then reads the display buffer through guest memory.
tibzejoker commented 2026-10-13 04:56:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T04:56:19Z.


A regression from this PR in GTA V (PPSA04264). Windows 11, RTX 4090, GCC 15.2.0 UCRT, Release, write watch on.

Setup. Base: main at 37dd48308 plus the open PRs GTA needs to reach Story (#757, #423, #290, #637, #4082, #4114, #4163, #4500, #448 ported, a few cherry-picks) and our local hacks. Branch tibzejoker/AnyPS5 gtav-next6. The only difference between the two builds is the revert of 048206e18.

Result. Same scripted path each time: menu, Story, prologue.

Story
with #4410 dies about 30 s in (2 of 2 runs, one on each side of a bisect)
#4410 reverted runs 120-180 s in the prologue (3 runs)

With #4410, libSceJobManager kernels on queue 0x20 start reading V#s that are all 0xFF:

compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff

Our local GTAV_SKIP_DISPATCH_ERRORS hack skipped 37 of those. Then another JobManager kernel aborts the run:

compute shader 0x7ff73adc7400: AGC graphics: buffer descriptor has reserved bits set

With the revert, none of these appear. main up to e55b881f0, the merge before this one, is fine. Reverting #4468 or #4500 instead didn't help.

What I think happens (not traced): these kernels take their V#s from a block that earlier GPU work on the same submission fills in (see #3055 for how this title uses that pool). If that write reaches guest memory through the idle storage results path, the 50 ms quiet period means the next dispatch's capture reads the block before the store, so it sees the pool's 0xFF fill. That's the "guest reads memory without a read hook" case @oneandonlydean raised above, here with the reader being a later dispatch's capture rather than CPU code.

I can test a fix or a shorter wait on this title.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138549230 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6138549230). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-13T04:56:19Z. --- A regression from this PR in GTA V (PPSA04264). Windows 11, RTX 4090, GCC 15.2.0 UCRT, Release, write watch on. **Setup.** Base: `main` at 37dd48308 plus the open PRs GTA needs to reach Story (#757, #423, #290, #637, #4082, #4114, #4163, #4500, #448 ported, a few cherry-picks) and our local hacks. Branch `tibzejoker/AnyPS5` `gtav-next6`. The only difference between the two builds is the revert of 048206e18. **Result.** Same scripted path each time: menu, Story, prologue. | | Story | |---|---| | with #4410 | dies about 30 s in (2 of 2 runs, one on each side of a bisect) | | #4410 reverted | runs 120-180 s in the prologue (3 runs) | With #4410, `libSceJobManager` kernels on queue 0x20 start reading V#s that are all `0xFF`: ``` compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff ``` Our local `GTAV_SKIP_DISPATCH_ERRORS` hack skipped 37 of those. Then another JobManager kernel aborts the run: ``` compute shader 0x7ff73adc7400: AGC graphics: buffer descriptor has reserved bits set ``` With the revert, none of these appear. `main` up to e55b881f0, the merge before this one, is fine. Reverting #4468 or #4500 instead didn't help. **What I think happens** (not traced): these kernels take their V#s from a block that earlier GPU work on the same submission fills in (see #3055 for how this title uses that pool). If that write reaches guest memory through the idle storage results path, the 50 ms quiet period means the next dispatch's capture reads the block before the store, so it sees the pool's `0xFF` fill. That's the "guest reads memory without a read hook" case @oneandonlydean raised above, here with the reader being a later dispatch's capture rather than CPU code. I can test a fix or a shorter wait on this title. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 05:30:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T05:30:52Z.


Thanks for the bisect. A dispatch's capture reads through the flush hook, so a pending store over that block should land before the V#s are read, and the #3055 notes say this block is filled by WRITE_DATA, which flushes pending images first. To find which read misses it, could you run the #4410 build three ways: with APS5_TRACE_FLUSH=1, with APS5_BDA_FLUSH=1, and without GTAV_SKIP_DISPATCH_ERRORS? The first failing line of each would do.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6138956833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6138956833). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T05:30:52Z. --- Thanks for the bisect. A dispatch's capture reads through the flush hook, so a pending store over that block should land before the V#s are read, and the #3055 notes say this block is filled by `WRITE_DATA`, which flushes pending images first. To find which read misses it, could you run the #4410 build three ways: with `APS5_TRACE_FLUSH=1`, with `APS5_BDA_FLUSH=1`, and without `GTAV_SKIP_DISPATCH_ERRORS`? The first failing line of each would do.
tibzejoker commented 2026-10-13 05:44:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by tibzejoker on 2026-10-13T05:44:26Z.


@oneandonlydean the three runs, same #4410 build as above (gtav-next6 with the revert dropped), same scripted path:

run Story
APS5_TRACE_FLUSH=1 dies about 30 s in, same as before
APS5_BDA_FLUSH=1 runs 90 s, no 0xFF V#s. The only skipped dispatch is 0x25b45a200, the known #757 one, same as with the revert
without GTAV_SKIP_DISPATCH_ERRORS aborts on the first one: compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff

The trace shows a storage image whose range covers the JobManager block. It is still pending well into Story, and the first failure comes right after it is flushed by a CPU access:

[flush] image 0x2a63e0000+0x870000 for memory access 0x2a63ee000+0x1000
[gpu] ahead capture failed serial=7151 @16345 queue=0x20: compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff
[flush] image 0x2a63e0000+0x870000 for memory access 0x2a63f2000+0x1000
[gpu] in-order dispatch skipped (GTAV_SKIP_DISPATCH_ERRORS) serial=7151 @16369 queue=0x20: compute shader 0x7ff73adc1200: ...
[flush] image 0x2a63e0000+0x870000 for memory access 0x2a6408000+0x1000
...

The same image is flushed again for accesses at 0x2a6408000, 0x2a649d000, 0x2a64b5000, 0x2a64c4000, 0x2a64d1000 and 0x2a6533000, with the failing dispatches in between. The failing blocks are around 0x2a63e4500, inside it.

Before this run, the only flushes were the eight for idle 0x0+0xffffffffffffffff ones at startup.

So the capture doesn't miss a store. It looks like the opposite: an old storage-image result over 0x2a63e0000 is still pending when the title reuses that memory as the JobManager pool. The CP and CPU write the pool, a CPU access then flushes the stale image result over it, and the kernels read the image's bytes (0xFF) where their V#s should be. Without the 50 ms wait, that result was stored at idle long before the pool was reused. With APS5_BDA_FLUSH=1 it is stored at an earlier read, also before the reuse.

That's my reading of the log, not traced further. Logs are available if you want them: about 3 MB, 0.5 MB gzipped.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6139118881 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6139118881). Originally posted by [tibzejoker](https://github.com/tibzejoker) on 2026-10-13T05:44:26Z. --- @oneandonlydean the three runs, same #4410 build as above (gtav-next6 with the revert dropped), same scripted path: | run | Story | |---|---| | `APS5_TRACE_FLUSH=1` | dies about 30 s in, same as before | | `APS5_BDA_FLUSH=1` | **runs 90 s, no 0xFF V#s.** The only skipped dispatch is `0x25b45a200`, the known #757 one, same as with the revert | | without `GTAV_SKIP_DISPATCH_ERRORS` | aborts on the first one: `compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff` | The trace shows a storage image whose range covers the JobManager block. It is still pending well into Story, and the first failure comes right after it is flushed by a CPU access: ``` [flush] image 0x2a63e0000+0x870000 for memory access 0x2a63ee000+0x1000 [gpu] ahead capture failed serial=7151 @16345 queue=0x20: compute shader 0x7ff73adc1200: buffer descriptor 1 uses an unsupported type: ffffffff ffffffff ffffffff ffffffff [flush] image 0x2a63e0000+0x870000 for memory access 0x2a63f2000+0x1000 [gpu] in-order dispatch skipped (GTAV_SKIP_DISPATCH_ERRORS) serial=7151 @16369 queue=0x20: compute shader 0x7ff73adc1200: ... [flush] image 0x2a63e0000+0x870000 for memory access 0x2a6408000+0x1000 ... ``` The same image is flushed again for accesses at 0x2a6408000, 0x2a649d000, 0x2a64b5000, 0x2a64c4000, 0x2a64d1000 and 0x2a6533000, with the failing dispatches in between. The failing blocks are around 0x2a63e4500, inside it. Before this run, the only flushes were the eight `for idle 0x0+0xffffffffffffffff` ones at startup. So the capture doesn't miss a store. It looks like the opposite: an old storage-image result over 0x2a63e0000 is still pending when the title reuses that memory as the JobManager pool. The CP and CPU write the pool, a CPU access then flushes the stale image result over it, and the kernels read the image's bytes (0xFF) where their V#s should be. Without the 50 ms wait, that result was stored at idle long before the pool was reused. With `APS5_BDA_FLUSH=1` it is stored at an earlier read, also before the reuse. That's my reading of the log, not traced further. Logs are available if you want them: about 3 MB, 0.5 MB gzipped. AI-assisted (Claude Code).
oneandonlydean commented 2026-10-13 06:51:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T06:51:56Z.


Reproduced on main with a test, thanks for the trace. It's older than this PR: on memory that isn't write-tracked (imports on Windows), a partial store drops the saved original, and the next store of the same image writes the layer whole over newer CPU data. This PR only keeps results pending long enough to hit it; with it reverted the same test still fails. A fix for the store is coming as its own PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6140022600 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4410#issuecomment-6140022600). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T06:51:56Z. --- Reproduced on main with a test, thanks for the trace. It's older than this PR: on memory that isn't write-tracked (imports on Windows), a partial store drops the saved original, and the next store of the same image writes the layer whole over newer CPU data. This PR only keeps results pending long enough to hit it; with it reverted the same test still fails. A fix for the store is coming as its own PR.
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!4410
No description provided.