test(agc): settle the padding block's import before the write-back route checks #23751

Merged
Luis-0508 merged 1 commit from upstream-pr/23751 into main 2026-11-27 09:28:45 +00:00
Luis-0508 commented 2026-11-19 15:48:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Luis-0508 on 2026-11-19T15:48:23Z.


What

agc_storage_write_back_host_retile fails on Windows with NVIDIA Turing with (watched) linear 200x150: the linear write-back went through its scratch instead of retiling into the import or the same line for linear 240x135, 2 mips (#23708). The test is wrong, not the write-back.

On Windows a private writable host import smaller than settleFloorBytes (1 MiB) is not settled at creation: importWatching leaves it unwatched and it is registered for a deferred settle (GuestBufferMemory.cpp, importWatching, ImportWatched(..., false)), which rewatchSettledImports completes later from a HostImportFor poll once the settle batch's fence has signalled. The two small linear cases allocate 0x40000 bytes, so their import starts unwatched; the larger linear cases are over 1 MiB and are settled synchronously.

StorageTexture::WriteBack decides on the watch state at the time it runs: a stored range that is not watched gets saveUnits (prepareStoredSave), and the direct import retile requires saveUnits.empty(), so it saves through its scratch. That is intended: without the watch the next store needs the saved bytes. The test evaluated GuestMemory::Watched(address, surfaceBytes) only after Submit, WaitQueue and Sync, when the deferred settle had usually completed, and expected the direct retile from that later state. Whether the settle completed before the write-back's own poll is a matter of fence timing, so which of the two small cases failed varied between runs.

The test now settles the block's import with WatchedAfterSettle (under the GPU mutex, as the settle tests do) before the image is created, and the slab, padding-seed and import-retile expectations use that state. The small linear cases then reach the write-back watched and the direct-retile check runs for all four linear cases instead of depending on timing. On Linux and macOS importWatching decides the watch once at import creation and WatchedAfterSettle only returns GuestMemory::Watched, so the expectations there are unchanged.

No driver change.

Tested

Windows 11 Pro 26200, NVIDIA GeForce RTX 2080 (Turing), driver 621.14 (32.0.16.2114), Vulkan 1.4.357, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh), Release, BUILD_TESTING=ON, Ryzen 5 7500F.

agc_storage_write_back_host_retile run alone, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1:

Build No layer With VK_LAYER_KHRONOS_validation
main b40a0d6dc7 0 of 20 passed 10 of 10 passed
this PR 20 of 20 passed (another 30 of 30 earlier) 10 of 10 passed

After rebasing onto main 0b1e9644e9: this PR 20 of 20 passed, agc_storage_write_back passed.

Under the validation layer main passes, which fits the timing explanation: the slower submissions let the deferred settle finish before the write-back polls.

A temporary print (not committed) of the per-case state confirmed that with the change all four watched linear cases have the import watched before the write-back, expect the direct retile and take it (LinearImportRetiles +1), in each of 3 runs. Before the change the small cases read unwatched before WriteBack and watched after Sync.

All 144 tests that run agc_driver_recorder_tests (from tests/cmake/agc_driver_recorder_tests.cmake), on main and on this PR, ctest -j6 -V with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, VK_LOADER_DEBUG=layer, Khronos validation layer 1.4.368 (Vulkan-ValidationLayers nightly 2026-11-19, loaded with VK_ADD_LAYER_PATH):

  • main: 144 of 144 passed; this PR: 144 of 144 passed.
  • Both logs show Insert instance layer "VK_LAYER_KHRONOS_validation" (141 times each) and neither contains was not found but was requested by env var VK_INSTANCE_LAYERS.
  • Neither log contains a VUID- line.

python tools/check_conventions.py --base upstream/main: passed. tools/pr_overlap.py --branch: no shared lines with comparable pull requests; of those it could not compare (conflicting with main), none changes the lines touched here.

Not run on Linux, macOS or another GPU vendor. Not run on a PS5.

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 #23708
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 2080, driver 621.14 (32.0.16.2114), Windows 11 Pro 26200
  • AI-assisted: yes (Claude Code; root-cause analysis cross-checked with Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5398152723 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23751). Originally posted by [Luis-0508](https://github.com/Luis-0508) on 2026-11-19T15:48:23Z. --- ### What `agc_storage_write_back_host_retile` fails on Windows with NVIDIA Turing with `(watched) linear 200x150: the linear write-back went through its scratch instead of retiling into the import` or the same line for `linear 240x135, 2 mips` (#23708). The test is wrong, not the write-back. On Windows a private writable host import smaller than `settleFloorBytes` (1 MiB) is not settled at creation: `importWatching` leaves it unwatched and it is registered for a deferred settle (`GuestBufferMemory.cpp`, `importWatching`, `ImportWatched(..., false)`), which `rewatchSettledImports` completes later from a `HostImportFor` poll once the settle batch's fence has signalled. The two small linear cases allocate 0x40000 bytes, so their import starts unwatched; the larger linear cases are over 1 MiB and are settled synchronously. `StorageTexture::WriteBack` decides on the watch state at the time it runs: a stored range that is not watched gets `saveUnits` (`prepareStoredSave`), and the direct import retile requires `saveUnits.empty()`, so it saves through its scratch. That is intended: without the watch the next store needs the saved bytes. The test evaluated `GuestMemory::Watched(address, surfaceBytes)` only after `Submit`, `WaitQueue` and `Sync`, when the deferred settle had usually completed, and expected the direct retile from that later state. Whether the settle completed before the write-back's own poll is a matter of fence timing, so which of the two small cases failed varied between runs. The test now settles the block's import with `WatchedAfterSettle` (under the GPU mutex, as the settle tests do) before the image is created, and the slab, padding-seed and import-retile expectations use that state. The small linear cases then reach the write-back watched and the direct-retile check runs for all four linear cases instead of depending on timing. On Linux and macOS `importWatching` decides the watch once at import creation and `WatchedAfterSettle` only returns `GuestMemory::Watched`, so the expectations there are unchanged. No driver change. ### Tested Windows 11 Pro 26200, NVIDIA GeForce RTX 2080 (Turing), driver 621.14 (32.0.16.2114), Vulkan 1.4.357, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh), Release, `BUILD_TESTING=ON`, Ryzen 5 7500F. `agc_storage_write_back_host_retile` run alone, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1`: | Build | No layer | With `VK_LAYER_KHRONOS_validation` | |---|---|---| | main `b40a0d6dc7` | 0 of 20 passed | 10 of 10 passed | | this PR | 20 of 20 passed (another 30 of 30 earlier) | 10 of 10 passed | After rebasing onto main `0b1e9644e9`: this PR 20 of 20 passed, `agc_storage_write_back` passed. Under the validation layer main passes, which fits the timing explanation: the slower submissions let the deferred settle finish before the write-back polls. A temporary print (not committed) of the per-case state confirmed that with the change all four watched linear cases have the import watched before the write-back, expect the direct retile and take it (`LinearImportRetiles` +1), in each of 3 runs. Before the change the small cases read unwatched before `WriteBack` and watched after `Sync`. All 144 tests that run `agc_driver_recorder_tests` (from `tests/cmake/agc_driver_recorder_tests.cmake`), on main and on this PR, `ctest -j6 -V` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, `VK_LOADER_DEBUG=layer`, Khronos validation layer 1.4.368 (Vulkan-ValidationLayers nightly 2026-11-19, loaded with `VK_ADD_LAYER_PATH`): - main: 144 of 144 passed; this PR: 144 of 144 passed. - Both logs show `Insert instance layer "VK_LAYER_KHRONOS_validation"` (141 times each) and neither contains `was not found but was requested by env var VK_INSTANCE_LAYERS`. - Neither log contains a `VUID-` line. `python tools/check_conventions.py --base upstream/main`: passed. `tools/pr_overlap.py --branch`: no shared lines with comparable pull requests; of those it could not compare (conflicting with main), none changes the lines touched here. Not run on Linux, macOS or another GPU vendor. Not run on a PS5. ### 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 #23708 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 2080, driver 621.14 (32.0.16.2114), Windows 11 Pro 26200 - [x] AI-assisted: yes (Claude Code; root-cause analysis cross-checked with Codex)
MarcZX10 commented 2026-11-19 17:00:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T17:00:39Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the targeted code supports settling the import before checking write-back routing, and I found no verified defect.

What I ran

Reviewed head c6e40657a0a358a1244b8856516289a554488bae. Read the prepared description, commit summary, manifest and diff, then read the changed function and the WatchedAfterSettle implementation and an existing test using it. No tests or builds were run.

Results

Check Result Note
Changed code review passed One changed file read at head
Tests and builds not run Relied on author-reported runs only

Findings

Blocking

None.

Non-blocking

None.

Not verified

The only changed file, core/libs/prx/libSceAgcDriver/tests/Recorder.cpp, was not included in the prepared full-text bundle, so I read its relevant ranges through repo_read.py; the full file was not read. No test execution was performed. Linux, macOS, other GPU vendors, and PS5 behavior were not verified. The reported test results and environment in the PR description are author-reported, not independently confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5979605383 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23751#pullrequestreview-5979605383). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-19T17:00:39Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the targeted code supports settling the import before checking write-back routing, and I found no verified defect. ## What I ran Reviewed head `c6e40657a0a358a1244b8856516289a554488bae`. Read the prepared description, commit summary, manifest and diff, then read the changed function and the `WatchedAfterSettle` implementation and an existing test using it. No tests or builds were run. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | One changed file read at head | | Tests and builds | not run | Relied on author-reported runs only | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The only changed file, `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp`, was not included in the prepared full-text bundle, so I read its relevant ranges through `repo_read.py`; the full file was not read. No test execution was performed. Linux, macOS, other GPU vendors, and PS5 behavior were not verified. The reported test results and environment in the PR description are author-reported, not independently confirmed. ## To get this to a good state Nothing is required.
throny commented 2026-11-22 02:52:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by throny on 2026-11-22T02:52:07Z.

Review: APPROVED


Approving on the RTX 4080 run above (0 of 30 failed with this change, 4 of 30 on main).

AI-assisted review (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6009873274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/23751#pullrequestreview-6009873274). Originally posted by [throny](https://github.com/throny) on 2026-11-22T02:52:07Z. **Review:** APPROVED --- Approving on the RTX 4080 run above (0 of 30 failed with this change, 4 of 30 on `main`). <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!23751
No description provided.