fix(agc): save the guest bytes of units without a write generation when results land outside the write watch #5679

Merged
moong15 merged 1 commit from upstream-pr/5679 into main 2026-10-14 10:28:45 +00:00
moong15 commented 2026-10-14 06:06:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by moong15 on 2026-10-14T06:06:06Z.


What

Stellar Blade (PPSA13197 v01.141) stops on Windows main a few minutes after start with

[agc] driver failure, continuing: AGC graphics: storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented

followed by GameThread timed out waiting for RenderThread after 120.00 secs. #5657 does not cover it: every unit of the failing image has no write generation, which its debt entry lists as still throwing. The memory is likely outside the watch since #5596 (direct imports of singly mapped direct memory leave the watch, as #5657 describes); the title passed this point on main before #5596. I have not confirmed this by reverting #5596.

Sequence, traced on a 256x256x6 cube map (format=71, 11 block units) over memory outside the watch:

  1. Create uploads it while the range is not watched: layerOriginal true, layerGeneration 0.
  2. Results land and the units become pending.
  3. The title samples the cube; the pending results go through the host-import store, which ends in forgetStored(). Over unwatched memory settle leaves the generation at 0, so the units now have neither saved bytes nor a generation.
  4. Results land again (no re-upload in between) and the units become pending.
  5. The next store finds tracked == false and compared == false and throws (Texture.cpp, host-import store).
Log excerpt (temporary diagnostics, not part of this change)
[diag-cube] create 0000013fae1bb7e0 image 0x20dcee0000+0xb0000 units=11 gen0=0 orig0=1 watched=0
[diag-cube] pending 0000013fae1bb7e0 image 0x20dcee0000 units 0+11 gen=0 orig=1 wasPending=0 watched=0
[src/Texture.cpp:259 Texture] Texture address=0x20dcee0000 256x256 mips=9 layers=6 dim=3 tile=7 format=71 vk=97 element=8
[diag-cube] pending 0000013fae1bb7e0 image 0x20dcee0000 units 0+11 gen=0 orig=0 wasPending=0 watched=0
[diag-unwatch] image 0x20dcee0000+0xb0000 layer 0/11 at +0x20dcee0000+0x10000: original=0 generation=0 pending=1 keptAtUnwatch=0 watchedNow=0 tile=7 format=71 blockUnits=1
[diag-unwatch] throwing at the host-import store of image 0x20dcee0000
[agc] driver failure, continuing: AGC graphics: storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented

create and pending are logged after Create's upload and on entry to markLayersPending; the Texture line is the title sampling the cube between the two writes (steps 3 and 4).

markLayersPending now saves the guest bytes (captureGuestBytes) of units that become pending with no saved bytes and no generation while the image's range is not watched, as the clear and fill paths already do for memory outside the watch. The store then compares against those bytes and leaves the blocks the CPU changed since to the CPU.

The debt entry is narrowed: a unit without a generation whose range leaves the watch while its results are pending still throws, as do ranges that leave the watch through a failed collect.

Tested

Windows 11 Pro 26200, MinGW GCC 15.2, Release, BUILD_TESTING=ON, on main a94675fb1:

  • ctest -R "store|storage|write_watch|guest_memory|untracked": 38 of 38 pass.
  • tools/check_conventions.py --base origin/main passes.
  • Stellar Blade (PPSA13197 v01.141), on main plus #5631 and other local AGC changes the title needs that are not in main (they change GuestBufferMemory.cpp and libc's WindowsMappings.hpp, but not the write watch or Texture.cpp): without this change the error above appears in every run (6 runs, before and after #5657) at the same point of loading and the title stops. With this change it does not appear in 3 runs; the title reached the main menu.

No new test case: a second store through the StoreOverUntracked fixture re-uploads the image at its next dispatch (captureGuestBytes from the upload), so the units never reach step 4 there and the case passes with and without this change. The title takes the second results without a re-upload after sampling the image; I have not isolated which path does that.

Unrelated, seen later in the same title and not addressed here: vertex fetch exceeds descriptor record count after the main menu.

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 (related: #5657, which this extends; Stellar Blade also needs #5631 to reach this point)
  • Unblocks: PPSA13197 (no Game bring-up discussion yet)
  • GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.32015.2008, Windows 11 Pro 26200
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4853702593 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5679). Originally posted by [moong15](https://github.com/moong15) on 2026-10-14T06:06:06Z. --- ### What Stellar Blade (PPSA13197 v01.141) stops on Windows `main` a few minutes after start with ``` [agc] driver failure, continuing: AGC graphics: storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented ``` followed by `GameThread timed out waiting for RenderThread after 120.00 secs`. #5657 does not cover it: every unit of the failing image has no write generation, which its debt entry lists as still throwing. The memory is likely outside the watch since #5596 (direct imports of singly mapped direct memory leave the watch, as #5657 describes); the title passed this point on `main` before #5596. I have not confirmed this by reverting #5596. Sequence, traced on a 256x256x6 cube map (`format=71`, 11 block units) over memory outside the watch: 1. `Create` uploads it while the range is not watched: `layerOriginal` true, `layerGeneration` 0. 2. Results land and the units become pending. 3. The title samples the cube; the pending results go through the host-import store, which ends in `forgetStored()`. Over unwatched memory `settle` leaves the generation at 0, so the units now have neither saved bytes nor a generation. 4. Results land again (no re-upload in between) and the units become pending. 5. The next store finds `tracked == false` and `compared == false` and throws (`Texture.cpp`, host-import store). <details><summary>Log excerpt (temporary diagnostics, not part of this change)</summary> ``` [diag-cube] create 0000013fae1bb7e0 image 0x20dcee0000+0xb0000 units=11 gen0=0 orig0=1 watched=0 [diag-cube] pending 0000013fae1bb7e0 image 0x20dcee0000 units 0+11 gen=0 orig=1 wasPending=0 watched=0 [src/Texture.cpp:259 Texture] Texture address=0x20dcee0000 256x256 mips=9 layers=6 dim=3 tile=7 format=71 vk=97 element=8 [diag-cube] pending 0000013fae1bb7e0 image 0x20dcee0000 units 0+11 gen=0 orig=0 wasPending=0 watched=0 [diag-unwatch] image 0x20dcee0000+0xb0000 layer 0/11 at +0x20dcee0000+0x10000: original=0 generation=0 pending=1 keptAtUnwatch=0 watchedNow=0 tile=7 format=71 blockUnits=1 [diag-unwatch] throwing at the host-import store of image 0x20dcee0000 [agc] driver failure, continuing: AGC graphics: storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented ``` `create` and `pending` are logged after `Create`'s upload and on entry to `markLayersPending`; the `Texture` line is the title sampling the cube between the two writes (steps 3 and 4). </details> `markLayersPending` now saves the guest bytes (`captureGuestBytes`) of units that become pending with no saved bytes and no generation while the image's range is not watched, as the clear and fill paths already do for memory outside the watch. The store then compares against those bytes and leaves the blocks the CPU changed since to the CPU. The debt entry is narrowed: a unit without a generation whose range leaves the watch while its results are pending still throws, as do ranges that leave the watch through a failed collect. ### Tested Windows 11 Pro 26200, MinGW GCC 15.2, Release, `BUILD_TESTING=ON`, on `main` a94675fb1: - `ctest -R "store|storage|write_watch|guest_memory|untracked"`: 38 of 38 pass. - `tools/check_conventions.py --base origin/main` passes. - Stellar Blade (PPSA13197 v01.141), on `main` plus #5631 and other local AGC changes the title needs that are not in `main` (they change `GuestBufferMemory.cpp` and libc's `WindowsMappings.hpp`, but not the write watch or `Texture.cpp`): without this change the error above appears in every run (6 runs, before and after #5657) at the same point of loading and the title stops. With this change it does not appear in 3 runs; the title reached the main menu. No new test case: a second store through the `StoreOverUntracked` fixture re-uploads the image at its next dispatch (`captureGuestBytes` from the upload), so the units never reach step 4 there and the case passes with and without this change. The title takes the second results without a re-upload after sampling the image; I have not isolated which path does that. Unrelated, seen later in the same title and not addressed here: `vertex fetch exceeds descriptor record count` after the main menu. ### 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 (related: #5657, which this extends; Stellar Blade also needs #5631 to reach this point) - [x] Unblocks: PPSA13197 (no Game bring-up discussion yet) - [x] GPUs tested: AMD Radeon RX 9070 XT, driver 32.0.32015.2008, Windows 11 Pro 26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-14 06:32:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T06:32:16Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4794 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L3033
#5760 docs/dev/debt/libSceAgcDriver.md L54
#5761 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L3033
docs/dev/debt/libSceAgcDriver.md L54
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6162404095 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5679#issuecomment-6162404095). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T06:32:16Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4794 | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L3033](https://github.com/boykopovar/AnyPS5/blob/2a99157640d6721383de941d7c2450eb53c6639c/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L3033) | | | | #5760 | `docs/dev/debt/libSceAgcDriver.md` [L54](https://github.com/boykopovar/AnyPS5/blob/2a99157640d6721383de941d7c2450eb53c6639c/docs/dev/debt/libSceAgcDriver.md#L54) | | | | #5761 | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L3033](https://github.com/boykopovar/AnyPS5/blob/2a99157640d6721383de941d7c2450eb53c6639c/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L3033)<br>`docs/dev/debt/libSceAgcDriver.md` [L54](https://github.com/boykopovar/AnyPS5/blob/2a99157640d6721383de941d7c2450eb53c6639c/docs/dev/debt/libSceAgcDriver.md#L54) | | |
simonbronk commented 2026-10-14 08:59:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simonbronk on 2026-10-14T08:59:27Z.


AMD and NVIDIA runs for this PR at head f05086278. Windows 11 Pro 26200, WinLibs GCC 15.2.0 (MinGW-w64), Release, one machine with two GPUs, each picked with ANYPS5_GPU:

  • NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742)
  • AMD Radeon(TM) Graphics, Ryzen integrated, gfx1036 (1002:13c0, RDNA 2), driver 32.0.21036.18

ctest -R "agc|shader|video_out" -j 8 (517 tests, including the ones this PR adds or changes):

  • RTX 5070: all 517 pass.
  • AMD gfx1036: all pass except agc_driver_lds_mixed_width_atomics, agc_driver_pixel_interlock and agc_driver_layered_volume_vertex_no_gpl. These three fail the same way on current main (872f52320) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR.

No title run. AI-assisted: yes (Claude Code ran the builds and tests).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6164726399 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5679#issuecomment-6164726399). Originally posted by [simonbronk](https://github.com/simonbronk) on 2026-10-14T08:59:27Z. --- AMD and NVIDIA runs for this PR at head `f05086278`. Windows 11 Pro 26200, WinLibs GCC 15.2.0 (MinGW-w64), Release, one machine with two GPUs, each picked with `ANYPS5_GPU`: - NVIDIA GeForce RTX 5070, driver 617.42 (32.0.16.1742) - AMD Radeon(TM) Graphics, Ryzen integrated, gfx1036 (`1002:13c0`, RDNA 2), driver 32.0.21036.18 `ctest -R "agc|shader|video_out" -j 8` (517 tests, including the ones this PR adds or changes): - RTX 5070: all 517 pass. - AMD gfx1036: all pass except `agc_driver_lds_mixed_width_atomics`, `agc_driver_pixel_interlock` and `agc_driver_layered_volume_vertex_no_gpl`. These three fail the same way on current `main` (`872f52320`) on this GPU and pass there on the RTX 5070; they are the three of #5271, so not caused by this PR. No title run. AI-assisted: yes (Claude Code ran the builds and tests).
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!5679
No description provided.