test(agc): keep the saved-baseline fixtures outside the write watch on Windows #22166

Merged
oneandonlydean merged 5 commits from upstream-pr/22166 into main 2026-11-17 08:32:26 +00:00
oneandonlydean commented 2026-11-17 07:28:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-11-17T07:28:41Z.


What

agc_driver_color_memo_baseline_enabled / _disabled (added by #17738) fail on Windows in about half the runs with "the baseline fixture has no saved bytes". This is a race in the fixture, not in the driver.

The baseline and held-baseline fixtures unwatch their target, draw, flush, and then require that the store saved the stored bytes. The store saves them only while the range is outside the write watch (Texture.cpp: the save units are empty when GuestMemory::Watched holds). On Windows a host import of unwatched memory is settled on the settle queue and then returned to the write watch (rewatchSettledImports in GuestBufferMemory.cpp, polled every 100 us). When that settle completes before the fixture's flush, the range is watched again, the store saves nothing, and the precondition fails. Both states are valid for the driver; the fixture just needs the unwatched one.

Both fixtures now turn deferred settles off for their duration with SetHostImportDeferredSettles(false), the hook the deferred settle tests in tests/Recorder.cpp already use, so the range stays outside the watch until the fixture's own Rewatch. Test file only, no driver change. The call does nothing on Linux.

Tested

Linux, built on c8c044b0d8: the test target builds. Linux cannot show the race (deferred settles exist only on Windows).

Windows: on main the test failed in 7 of 13 CI runs today across two machines (one of the two variants each time). A repeat run of both fixtures on this head on Windows is the proof; I will add its result here.

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
  • Unimplemented paths throw; silent stubs are listed under Silent stubs in their library's technical debt
  • No notes, investigation .md files or images added to the repository
  • 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 4090, driver 610.57.04, Linux (build only so far)
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5352690853 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22166). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-11-17T07:28:41Z. --- ### What `agc_driver_color_memo_baseline_enabled` / `_disabled` (added by #17738) fail on Windows in about half the runs with "the baseline fixture has no saved bytes". This is a race in the fixture, not in the driver. The `baseline` and `held-baseline` fixtures unwatch their target, draw, flush, and then require that the store saved the stored bytes. The store saves them only while the range is outside the write watch (`Texture.cpp`: the save units are empty when `GuestMemory::Watched` holds). On Windows a host import of unwatched memory is settled on the settle queue and then returned to the write watch (`rewatchSettledImports` in `GuestBufferMemory.cpp`, polled every 100 us). When that settle completes before the fixture's flush, the range is watched again, the store saves nothing, and the precondition fails. Both states are valid for the driver; the fixture just needs the unwatched one. Both fixtures now turn deferred settles off for their duration with `SetHostImportDeferredSettles(false)`, the hook the deferred settle tests in `tests/Recorder.cpp` already use, so the range stays outside the watch until the fixture's own `Rewatch`. Test file only, no driver change. The call does nothing on Linux. ### Tested Linux, built on `c8c044b0d8`: the test target builds. Linux cannot show the race (deferred settles exist only on Windows). Windows: on main the test failed in 7 of 13 CI runs today across two machines (one of the two variants each time). A repeat run of both fixtures on this head on Windows is the proof; I will add its result here. ### 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 and the licence notice of code adapted from upstream - [x] Unimplemented paths throw; silent stubs are listed under Silent stubs in their library's technical debt - [x] No notes, investigation `.md` files or images added to the repository - [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 4090, driver 610.57.04, Linux (build only so far) - [x] AI-assisted: yes
MarcZX10 commented 2026-11-17 07:53:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T07:53:47Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing blocks this; the points below are optional. The Windows proof the description promises is not in yet, so I am not approving.

What I ran

  • Head: 62aaa6fb8aef427b9ff0acbdc5f5d856d1c79329, base main.
  • Read the diff, the description and the commit list, then the changed hunks in core/libs/prx/libSceAgcDriver/tests/TargetStateMemo.cpp and the hook they call, SetHostImportDeferredSettles.
  • No build and no test run on my side. The Linux build result is the author's, on c8c044b0d8.

Results

Check Result Note
Diff scope (one test file) passed Two fixtures touched
Hook is a no-op off Windows passed Read in GuestBufferMemory.cpp
Same guard pattern used elsewhere passed Recorder, BdaResources, DccKeysFirstWrite
Linux build not run Author-reported only
Windows repeat run not run Author says it will be added

Findings

Blocking

None.

Non-blocking

None verified.

Not verified

  • The race itself. Linux cannot show it, and the deferred settle path exists only on Windows, so the fix is unproven until the Windows run is posted.
  • The Windows repeat run of both fixtures on this head. The description leaves it as "I will add its result here".
  • heldBaselineUnits after its own Rewatch. I read only the start of that fixture, so I did not confirm that its rewatch happens while the guard still holds.
  • The second commit in the list, fix(agc): rename the settle guard that shadowed the held byte. The diff does not show a rename, so I could not match it to a change.

To get this to a good state

  • Post the Windows repeat run of validRefreshBaselines and heldBaselineUnits on this head, with the output.
  • Then a formal review can be made on that result.

Files read: core/libs/prx/libSceAgcDriver/tests/TargetStateMemo.cpp (changed regions, lines 1225–1274 at head), plus the hook in core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp. Files reviewed: 1 of 1 listed in files.json.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5934789896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/22166#pullrequestreview-5934789896). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T07:53:47Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing blocks this; the points below are optional. The Windows proof the description promises is not in yet, so I am not approving. ## What I ran - Head: `62aaa6fb8aef427b9ff0acbdc5f5d856d1c79329`, base `main`. - Read the diff, the description and the commit list, then the changed hunks in `core/libs/prx/libSceAgcDriver/tests/TargetStateMemo.cpp` and the hook they call, `SetHostImportDeferredSettles`. - No build and no test run on my side. The Linux build result is the author's, on `c8c044b0d8`. ## Results | Check | Result | Note | |---|---|---| | Diff scope (one test file) | passed | Two fixtures touched | | Hook is a no-op off Windows | passed | Read in `GuestBufferMemory.cpp` | | Same guard pattern used elsewhere | passed | Recorder, BdaResources, DccKeysFirstWrite | | Linux build | not run | Author-reported only | | Windows repeat run | not run | Author says it will be added | ## Findings **Blocking** None. **Non-blocking** None verified. ## Not verified - The race itself. Linux cannot show it, and the deferred settle path exists only on Windows, so the fix is unproven until the Windows run is posted. - The Windows repeat run of both fixtures on this head. The description leaves it as "I will add its result here". - `heldBaselineUnits` after its own `Rewatch`. I read only the start of that fixture, so I did not confirm that its rewatch happens while the guard still holds. - The second commit in the list, `fix(agc): rename the settle guard that shadowed the held byte`. The diff does not show a rename, so I could not match it to a change. ## To get this to a good state - Post the Windows repeat run of `validRefreshBaselines` and `heldBaselineUnits` on this head, with the output. - Then a formal review can be made on that result. Files read: `core/libs/prx/libSceAgcDriver/tests/TargetStateMemo.cpp` (changed regions, lines 1225–1274 at head), plus the hook in `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`. Files reviewed: 1 of 1 listed in `files.json`.
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!22166
No description provided.