test(agc): run the second-store case on a surface that was never watched #22764

Merged
DerKarussellbremser merged 1 commit from upstream-pr/22764 into main 2026-11-27 09:28:15 +00:00
DerKarussellbremser commented 2026-11-18 07:49:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DerKarussellbremser on 2026-11-18T07:49:44Z.


What

agc_driver_store_over_untracked fails intermittently on Windows in its "a second store over a surface outside the write watch" case with the store left no saved guest bytes (#22670). The cause is the test's fixture, not a lost store.

RunSecondStore allocated its surface in the guest write-watch arena, took it out of the watch with GuestMemory::Unwatch and then required the first store to leave saved guest bytes. On Windows the host import that the store makes over the surface is settled, and rewatchSettledImports puts the range back under the write watch. When that happens before the first store's write-back, the write-back sees watched memory and keeps no saved bytes (GuestMemory::Watched(firstStored, ...) ? {} : prepareStoredSave(...) in writeBackLayers), and the case reported Outcome::Lost.

The case now uses a surface that is never in the write-watch arena (Surface surface;, the fixture's existing unwatched constructor), requires it to be outside the watch at the start and again after the first store, and keeps every check after that: the saved bytes, the CPU's page surviving the second store, and the second result reaching the block the CPU left alone. The driver is unchanged.

This fixture is the one @thalesdot1dot1 posted in #22670; the commit carries them as co-author. It replaces my first version of this PR, which let a surface that was watched again skip the saved-bytes check. As @u-instinct11 measured on Intel, that version skipped it in 98 of 300 runs, and on this machine in 21 of 40, so it no longer tested the unwatched second store it is named for.

Tested

Windows 11 Home 10.0.26200, Intel i7-10750H, NVIDIA GeForce RTX 2060 (driver 610.91), WinLibs GCC 15.2.0 r7, Release, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, ctest -R ^agc_driver_store_over_untracked$, built from main d50640e264:

failed runs
main 9 of 20, all with the store left no saved guest bytes
this change 0 of 30

With this change none of the 30 runs printed a line for the second-store case, so each ran it to the end with saved bytes and lost 0.

Earlier measurements on this machine (local trace lines, not part of this PR): in all 9 failing traced runs on main rewatchSettledImports covered the surface between the test's Unwatch and the first write-back.

Not tested, and limits:

  • Linux and macOS; I rely on CI for those.
  • AMD and Intel GPUs on my side. @thalesdot1dot1 reports 50 of 50 on an RTX 5060 and @u-instinct11 300 of 300 on Intel Graphics 0x7d67 with this fixture.
  • The four cases that print not run, the surface is not write-watched on Windows (second part of #22670) are not touched.
  • The full suite was not run; the change is one test file.

python tools/check_conventions.py --base origin/main 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: Fixes #22670
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2060, driver 610.91, Windows 11 Home 10.0.26200
  • AI-assisted: yes

🤖 Generated with Claude Code

https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5372045304 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22764). Originally posted by [DerKarussellbremser](https://github.com/DerKarussellbremser) on 2026-11-18T07:49:44Z. --- ### What `agc_driver_store_over_untracked` fails intermittently on Windows in its "a second store over a surface outside the write watch" case with `the store left no saved guest bytes` (#22670). The cause is the test's fixture, not a lost store. `RunSecondStore` allocated its surface in the guest write-watch arena, took it out of the watch with `GuestMemory::Unwatch` and then required the first store to leave saved guest bytes. On Windows the host import that the store makes over the surface is settled, and `rewatchSettledImports` puts the range back under the write watch. When that happens before the first store's write-back, the write-back sees watched memory and keeps no saved bytes (`GuestMemory::Watched(firstStored, ...) ? {} : prepareStoredSave(...)` in `writeBackLayers`), and the case reported `Outcome::Lost`. The case now uses a surface that is never in the write-watch arena (`Surface surface;`, the fixture's existing unwatched constructor), requires it to be outside the watch at the start and again after the first store, and keeps every check after that: the saved bytes, the CPU's page surviving the second store, and the second result reaching the block the CPU left alone. The driver is unchanged. This fixture is the one @thalesdot1dot1 posted in #22670; the commit carries them as co-author. It replaces my first version of this PR, which let a surface that was watched again skip the saved-bytes check. As @u-instinct11 measured on Intel, that version skipped it in 98 of 300 runs, and on this machine in 21 of 40, so it no longer tested the unwatched second store it is named for. ### Tested Windows 11 Home 10.0.26200, Intel i7-10750H, NVIDIA GeForce RTX 2060 (driver 610.91), WinLibs GCC 15.2.0 r7, Release, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`, `ctest -R ^agc_driver_store_over_untracked$`, built from `main` `d50640e264`: | | failed runs | |---|---| | `main` | 9 of 20, all with `the store left no saved guest bytes` | | this change | 0 of 30 | With this change none of the 30 runs printed a line for the second-store case, so each ran it to the end with saved bytes and `lost 0`. Earlier measurements on this machine (local trace lines, not part of this PR): in all 9 failing traced runs on `main` `rewatchSettledImports` covered the surface between the test's `Unwatch` and the first write-back. Not tested, and limits: - Linux and macOS; I rely on CI for those. - AMD and Intel GPUs on my side. @thalesdot1dot1 reports 50 of 50 on an RTX 5060 and @u-instinct11 300 of 300 on Intel Graphics 0x7d67 with this fixture. - The four cases that print `not run, the surface is not write-watched` on Windows (second part of #22670) are not touched. - The full suite was not run; the change is one test file. `python tools/check_conventions.py --base origin/main` passes. ### 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: Fixes #22670 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2060, driver 610.91, Windows 11 Home 10.0.26200 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011TXsSW8zeAgKgHLCFsYwM3
Ethan-Hainline commented 2026-11-19 00:11:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ethan-Hainline on 2026-11-19T00:11:44Z.

Review: COMMENTED


Reviewed and verified on Windows 11, Ryzen 5 7530U (Radeon Vega 8 iGPU), MinGW-w64 GCC 16.2.0 UCRT, Release, Vulkan available:

A/B on current main 168921678f

  • Without the patch: agc_driver_store_over_untracked_tests failed 1 of 3 runs with exactly a second store over a surface outside the write watch: the store left no saved guest bytes, so #22670 reproduces here.
  • With d1aaf844dd applied: 10 of 10 runs passed.

Other checks

  • The target compiles cleanly with the change.
  • AgcDriver::GuestMemory::Watched(address, SurfaceBytes) exists with that signature; reading it inside the same GpuMutex critical section as GuestSnapshotValid() matches how settleUnwatchedImports and rewatchSettledImports use it, so the decision is coherent.
  • The new branch fired on every run here (5 of 5), not occasionally. On this machine the rewatch happens before the check each time, so on Windows the case now always takes the "watched again" path and no longer exercises the saved-bytes assertion at all. The CPU-page and second-result checks still run, and the message makes the path visible in the log, so I don't think this blocks the fix — but if the rewatch is now the normal Windows behaviour rather than a race, the case name "outside the write watch" is doing less than it says. Worth a sentence in the body or a follow-up that re-unwatches and retries if the intent is to keep covering the unwatched path on Windows.

Not a blocker from me; the patch fixes the reproduced failure without weakening the assertions that still apply.

AI-assisted.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967280768 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22764#pullrequestreview-5967280768). Originally posted by [Ethan-Hainline](https://github.com/Ethan-Hainline) on 2026-11-19T00:11:44Z. **Review:** COMMENTED --- Reviewed and verified on Windows 11, Ryzen 5 7530U (Radeon Vega 8 iGPU), MinGW-w64 GCC 16.2.0 UCRT, Release, Vulkan available: **A/B on current `main` `168921678f`** - Without the patch: `agc_driver_store_over_untracked_tests` failed 1 of 3 runs with exactly `a second store over a surface outside the write watch: the store left no saved guest bytes`, so #22670 reproduces here. - With `d1aaf844dd` applied: 10 of 10 runs passed. **Other checks** - The target compiles cleanly with the change. - `AgcDriver::GuestMemory::Watched(address, SurfaceBytes)` exists with that signature; reading it inside the same `GpuMutex` critical section as `GuestSnapshotValid()` matches how `settleUnwatchedImports` and `rewatchSettledImports` use it, so the decision is coherent. - The new branch fired on every run here (5 of 5), not occasionally. On this machine the rewatch happens before the check each time, so on Windows the case now always takes the "watched again" path and no longer exercises the saved-bytes assertion at all. The CPU-page and second-result checks still run, and the message makes the path visible in the log, so I don't think this blocks the fix — but if the rewatch is now the normal Windows behaviour rather than a race, the case name "outside the write watch" is doing less than it says. Worth a sentence in the body or a follow-up that re-unwatches and retries if the intent is to keep covering the unwatched path on Windows. Not a blocker from me; the patch fixes the reproduced failure without weakening the assertions that still apply. AI-assisted.
MarcZX10 commented 2026-11-19 00:51:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T00:51:54Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the optional points below are informational.

What I ran

Reviewed head d1aaf844dd53b545b6d07c922bf5b311944c6cc9. No commands or tests were run; I inspected the prepared diff and pinned source through the repository reader.

Results

Check Result Note
Changed-code review passed One test fixture change
Tests not run No local execution

Findings

Blocking

None.

Non-blocking

  • RunSecondStore now accepts a rewatched surface and carries on to its second-store assertions. That addresses the reported timing-dependent early failure while retaining the saved-bytes requirement when the surface remains unwatched. The PR description also clarifies that the second store’s result and CPU-written page are checked in the rewatched path.

Not verified

  • Test execution and CI results were not verified independently; reported runs in the PR description are author supplied.
  • I did not read the full changed file; the review was limited to the changed hunk and nearby RunSecondStore logic, the related GuestMemory::Watched implementation, and the adjacent fixture function.
  • review/description.md, review/commits.md, review/manifest.json, review/diff.patch, and core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp ranges 270–390 were read. No files were excluded by the manifest.

To get this to a good state

Nothing is required. The optional point above is informational.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5967632224 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22764#pullrequestreview-5967632224). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T00:51:54Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the optional points below are informational. ## What I ran Reviewed head `d1aaf844dd53b545b6d07c922bf5b311944c6cc9`. No commands or tests were run; I inspected the prepared diff and pinned source through the repository reader. ## Results | Check | Result | Note | |---|---|---| | Changed-code review | passed | One test fixture change | | Tests | not run | No local execution | ## Findings ### Blocking None. ### Non-blocking - `RunSecondStore` now accepts a rewatched surface and carries on to its second-store assertions. That addresses the reported timing-dependent early failure while retaining the saved-bytes requirement when the surface remains unwatched. The PR description also clarifies that the second store’s result and CPU-written page are checked in the rewatched path. ## Not verified - Test execution and CI results were not verified independently; reported runs in the PR description are author supplied. - I did not read the full changed file; the review was limited to the changed hunk and nearby `RunSecondStore` logic, the related `GuestMemory::Watched` implementation, and the adjacent fixture function. - `review/description.md`, `review/commits.md`, `review/manifest.json`, `review/diff.patch`, and `core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp` ranges 270–390 were read. No files were excluded by the manifest. ## To get this to a good state Nothing is required. The optional point above is informational.
MarcZX10 commented 2026-11-20 03:53:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T03:53:39Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the test now allocates an unwatched surface and checks that the write watch remains absent after the first store, while retaining its saved-byte and second-store assertions.

What I ran

Reviewed head 5503a0cbff3d3cf44f63b62c8c3c9ea69bde66b2 using repo_read.py to read the supplied review materials and the changed source. No commands or tests were run.

Files read: description.md, commits.md, manifest.json, diff.patch, and core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp (lines 1–25 and 260–355). The manifest lists one reviewed file, and its full text was available. No files were excluded by the manifest.

Results

Check Result Note
Diff and changed source review passed One changed test file
Tests not run Author-reported results were not rerun

Findings

Blocking

None.

Non-blocking

None.

Not verified

No tests or conventions checks were run. The author reports Windows runs and a conventions check in the description; these results were not independently verified. Linux, macOS, and full-suite behavior were not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5987251483 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22764#pullrequestreview-5987251483). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T03:53:39Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the test now allocates an unwatched surface and checks that the write watch remains absent after the first store, while retaining its saved-byte and second-store assertions. ## What I ran Reviewed head `5503a0cbff3d3cf44f63b62c8c3c9ea69bde66b2` using `repo_read.py` to read the supplied review materials and the changed source. No commands or tests were run. Files read: `description.md`, `commits.md`, `manifest.json`, `diff.patch`, and `core/libs/prx/libSceAgcDriver/tests/execution/StoreOverUntracked.cpp` (lines 1–25 and 260–355). The manifest lists one reviewed file, and its full text was available. No files were excluded by the manifest. ## Results | Check | Result | Note | |---|---|---| | Diff and changed source review | passed | One changed test file | | Tests | not run | Author-reported results were not rerun | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No tests or conventions checks were run. The author reports Windows runs and a conventions check in the description; these results were not independently verified. Linux, macOS, and full-suite behavior were not verified. ## To get this to a good state Nothing is required.
throny commented 2026-11-22 01:04:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T01:04:48Z.

Review: APPROVED


Approving per the review above.

AI-assisted review (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6009292361 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22764#pullrequestreview-6009292361). Originally posted by [throny](https://github.com/throny) on 2026-11-22T01:04:48Z. **Review:** APPROVED --- Approving per the [review above](https://github.com/boykopovar/AnyPS5/pull/22764#issuecomment-7071895173). <sub>AI-assisted review (Claude Code)</sub>
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!22764
No description provided.