fix(agc): keep aligned imports inside watched spans #8169

Closed
MarcZX10 wants to merge 2 commits from upstream-pr/8169 into main
MarcZX10 commented 2026-10-20 01:11:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T01:11:15Z.


What

The aligned host-import path can group adjacent registered ranges into a larger block even when another part of that block is no longer write watched. Importing that block then removes write watching from the whole span, including a watched DCC color source that the 4x refill test still needs.

When write watching is active, this change accepts a grouped import only when the complete candidate block is still watched. Otherwise it falls back to the requested range. It preserves the existing grouped-import behavior when write watching is unavailable and for single-range imports.

The regression test constructs the mixed-watch condition on Windows, checks that the target starts watched, imports it beside unwatched gaps, and asserts that the target remains watched. The test and fix are separate commits.

Tested

  • python3 tools/check_conventions.py --base upstream/main: passed.
  • git diff upstream/main...HEAD --check: passed.
  • Full CMake configuration and the AGC regression test: not run. The isolated worktree has unpopulated submodule checkouts, and configuration reports missing SDL/XRandR development support.
  • The Windows RTX 5080 reproduction and Vulkan validation: not run here. The issue report contains the reporter's hardware reproduction and bisect; those are not tests run by me.

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
  • New third-party code is a submodule built from source (none)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: #8103
  • Unblocks: none
  • GPUs tested: none; the Windows GPU reproduction and Vulkan validation were not run locally
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4929561212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8169). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-20T01:11:15Z. --- ### What The aligned host-import path can group adjacent registered ranges into a larger block even when another part of that block is no longer write watched. Importing that block then removes write watching from the whole span, including a watched DCC color source that the 4x refill test still needs. When write watching is active, this change accepts a grouped import only when the complete candidate block is still watched. Otherwise it falls back to the requested range. It preserves the existing grouped-import behavior when write watching is unavailable and for single-range imports. The regression test constructs the mixed-watch condition on Windows, checks that the target starts watched, imports it beside unwatched gaps, and asserts that the target remains watched. The test and fix are separate commits. ### Tested - `python3 tools/check_conventions.py --base upstream/main`: passed. - `git diff upstream/main...HEAD --check`: passed. - Full CMake configuration and the AGC regression test: not run. The isolated worktree has unpopulated submodule checkouts, and configuration reports missing SDL/XRandR development support. - The Windows RTX 5080 reproduction and Vulkan validation: not run here. The issue report contains the reporter's hardware reproduction and bisect; those are not tests run by me. ### 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 - [x] New third-party code is a submodule built from source (none) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: #8103 - [x] Unblocks: none - [x] GPUs tested: none; the Windows GPU reproduction and Vulkan validation were not run locally - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-20 01:19:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T01:19:54Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1191 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 1324 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 2434 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 4449 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6177 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6185 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6292 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6412 core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6636 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 6682 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6951 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7201 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7292 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7332 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp
PR 7446 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7473 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7618 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281071949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8169#issuecomment-6281071949). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T01:19:54Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 1191](https://www.github.com/boykopovar/AnyPS5/pull/1191) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 1324](https://www.github.com/boykopovar/AnyPS5/pull/1324) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 2434](https://www.github.com/boykopovar/AnyPS5/pull/2434) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 4449](https://www.github.com/boykopovar/AnyPS5/pull/4449) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 6146](https://www.github.com/boykopovar/AnyPS5/pull/6146) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6177](https://www.github.com/boykopovar/AnyPS5/pull/6177) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6185](https://www.github.com/boykopovar/AnyPS5/pull/6185) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6186](https://www.github.com/boykopovar/AnyPS5/pull/6186) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6197](https://www.github.com/boykopovar/AnyPS5/pull/6197) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 6292](https://www.github.com/boykopovar/AnyPS5/pull/6292) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6548](https://www.github.com/boykopovar/AnyPS5/pull/6548) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6636](https://www.github.com/boykopovar/AnyPS5/pull/6636) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 6682](https://www.github.com/boykopovar/AnyPS5/pull/6682) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 6951](https://www.github.com/boykopovar/AnyPS5/pull/6951) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 7292](https://www.github.com/boykopovar/AnyPS5/pull/7292) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp`<br>`core/libs/prx/libSceAgcDriver/tests/BdaResources.cpp` | | [PR 7446](https://www.github.com/boykopovar/AnyPS5/pull/7446) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7457](https://www.github.com/boykopovar/AnyPS5/pull/7457) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7473](https://www.github.com/boykopovar/AnyPS5/pull/7473) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7514](https://www.github.com/boykopovar/AnyPS5/pull/7514) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7618](https://www.github.com/boykopovar/AnyPS5/pull/7618) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp` |
wachi35676 commented 2026-10-20 02:24:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T02:24:54Z.


I ran #8169 and #8172 on the same Windows base so both fixes for #8103 can be compared. @MarcZX10 mentioned they could not build #8169 or run the Windows repro, so here are those results. Disclosure: #8172 is my PR, so I've kept this to measurements.

Setup

  • Base main 7e12b3da8.
  • #8169 head 629ee88e8, merged onto that base.
  • #8172 head 58f0e89ca, applied onto the same base.
  • Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, Ninja, BUILD_TESTING=ON.
  • GPUs: RTX 5070 Ti and the Radeon iGPU (ANYPS5_GPU=AMD).
  • Environment: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 APS5_NO_PIPELINE_JOURNAL=1. No validation layer is installed.

1. The #8103 repro

Each test ran 3 times on each GPU.

test main #8169 #8172
agc_driver_msaa_dcc_clear_4 fails (requires watched guest memory) 3/3 pass, both GPUs 3/3 pass, both GPUs
agc_driver_msaa_dcc_clear_2, _8, agc_driver_msaa_dcc_state, agc_write_tracking pass 3/3 pass, both GPUs 3/3 pass, both GPUs
agc_driver_graphics pass 3/3 fail, both GPUs 3/3 pass, both GPUs

So both PRs fix agc_driver_msaa_dcc_clear_4 on this machine.

With #8169, agc_driver_graphics stops at its first failure:

AGC graphics: adjacent registered ranges with the same access were not imported as one span

2. agc|guest_memory|import|watch subset

831 tests, -j6, NVIDIA.

failures
main agc_driver_msaa_dcc_clear_4, agc_driver_pass_input_hazard, agc_pipeline_journal
#8169 agc_driver_graphics, agc_storage_writeback_blocks, agc_host_import_retirement, agc_host_import_retire, agc_driver_pass_input_hazard, agc_pipeline_journal
#8172 agc_driver_pass_input_hazard, agc_pipeline_journal

agc_driver_pass_input_hazard and agc_pipeline_journal fail on main too. agc_pipeline_journal fails because APS5_NO_PIPELINE_JOURNAL=1 is set.

The four tests that fail only with #8169 also failed 2 of 2 when run alone on NVIDIA, and once each on the iGPU:

  • agc_storage_writeback_blocks: a 4 MiB image over 64 KiB pieces of which every other one is not GPU mapped: 0 imports made (0 by write-back segments), CPU write-back, 1048576 of 1048576 texels stored
  • agc_host_import_retirement: unlocked mapping retired an import instead of requesting the GPU lock
  • agc_host_import_retire: FAIL: the grown run was not imported as one import replacing the first
  • agc_driver_graphics: see above

agc_driver_graphics stops at the first failure, so I made a local diagnostic build (not part of either PR). It runs each of the 58 sub-tests of RunBdaResourceTests in its own process.

  • On main, all 58 pass except #8169's new test, enabled as described in section 3.
  • With #8169, 17 fail, all with grouping messages:
    • importCrossingTests, importSpanTests, failedImportRemapTests, spaceImportRunTests, importWindowTests, spaceReadAcrossImportsTests
    • importBlockMapTests (both variants), importBlockBuildTests, importBlockHoleTests, importBlockUnalignedTests, importBlockFlagTests, importBlockRemapTests, importBlockFailureTests, importBlockBudgetTests
    • evictingRefusalWindowTests, evictingRefusalBlockRangesTests, evictingRefusalStepDownTests
    • Example: 64 adjacent 64 KiB pieces mapped one by one were not imported as one 4 MiB block: 64 imports

Of these fixtures, I checked two. importCrossingTests allocates with ::operator new, and HostImportRetireHold.cpp uses VirtualAlloc. Neither is in the guest arena. On Windows GuestMemory::WriteWatched() is true, so the new GuestMemory::Watched(...) condition in importRun returns the single range for these blocks. The only code change in #8169 is that condition, and every one of these sub-tests passes on main.

I did not measure whether guest-arena ranges in a real title, for example read-only ones, are all watched. So I can't say how often titles would hit this.

3. #8169's regression test (importBlockMixedWatchTests)

Under ctest on this machine, the test prints write watching unavailable: mixed import block not tested and returns, on main and on #8169 alike. A local print showed the values of its guard:

  • GuestArenaAvailable = 1
  • GuestArenaWriteWatched = 1
  • GuestMemory::WriteWatched() = 1
  • context.hostImportAlignment = 0

The context that RunBdaResourceTests receives is mockContext(), whose alignment is 0. The PieceWindow the test builds sets its own importing.hostImportAlignment to 64 KiB.

I removed only the context.hostImportAlignment == 0 condition, locally:

  • On main, it fails with an aligned import through unwatched neighboring spans dropped the target from the write watch.
  • With #8169, run alone, it passes.

So the test detects the bug once the guard reads the alignment from window.importing (or the condition is dropped). As committed, it does not run here.

4. #8172's tests on the #8169 build

I applied only #8172's two test files on top of #8169.

test #8169 + #8172 tests message
agc_write_tracking, CheckImportWindowOverUnwatchedBlock fails, 6/6 runs (both GPUs) took the watched blocks out of the write watch
agc_driver_msaa_dcc_clear_{2,4,8}, DccImportWindowTests fails, 6/6 runs (both GPUs) writes to a resident multisampled DCC target or its metadata are not implemented (DCC range 0x200100000+0x1000, 4 samples) (likewise for 2 and 8)

Both tests call GuestMemory::ImportWatched directly, which #8169 does not change. They test ImportWatched and the DCC metadata generations, not importRun. Failing them does not mean #8169 fails to fix the issue's test.

With #8169, the stock dcc_clear_4 never builds the 4 MiB block (see section 5), so it does not reach the metadata refusal that DccImportWindowTests checks.

5. Import churn (APS5_TRACE_HOST_IMPORT=1)

What the counts mean

  • "ok" counts host import of ... ok lines.
  • "retired" counts host import of ... retired: the range was mapped again.
    • refreshImports prints that line when sameRange(entry) is false while the range is still leased.
    • That is the retire path the importRun concern is about.
  • Each test ran once, on NVIDIA.
test main ok / retired #8169 ok / retired #8172 ok / retired
agc_storage_writeback_blocks 3 / 0 128 / 0 (fails) 3 / 0
agc_host_import_retirement 6 / 2 6 / 0 (fails) 6 / 2
agc_host_import_retire 6 / 2 6 / 0 (fails) 6 / 2
agc_driver_msaa_dcc_clear_4 27 / 8 (fails) 31 / 0 31 / 8
agc_driver_host_import_lifetime 19 / 0 19 / 0 19 / 0
agc_driver_host_import_at_map 8 / 0 8 / 0 8 / 0
_unmap, _second_mapping, _mutation_race, _sparse, _teardown, _windows, storage_write_back_overhang same counts on all three, 0 retired

In dcc_clear_4:

  • #8169 makes 28 imports of 256 KiB and 3 of 64 KiB. It makes no 4 MiB block and retires nothing.
  • #8172 makes 27 of 256 KiB, 3 of 64 KiB and the 4 MiB block, and retires eight 256 KiB imports, as on main.

So none of these tests showed a retire/re-import loop with #8169. For #8169, the "retired" count is 0 everywhere.

The concern raised in the #8103 bisect comment comes from this code path, which no test above covers. It is from reading the code; I did not measure it:

  • sameRange(const HostImport&) re-runs importRun(lease, entry.base, ...) at every allocation-generation refresh. With #8169, that result depends on GuestMemory::Watched over the candidate block.
  • On Windows, an import is made with staysWatched == false when watchedHostPointer is false: unwatchImports is set and the import is not settled (read-only, or below settleFloorBytes).
    • ImportWatched then unwatches the whole run.
    • refreshImports calls GuestMemory::Unwatch on it again at each refresh (if (it->second.unwatched)).
  • If #8169 formed such a grouped import while its block was watched, then at the next refresh importRun would return the single range. sameRun would fail and the import would be retired. A later import would take the single range, because the block stays unwatched.
  • By this reading, that is one retire per such grouped import, not a repeating cycle, unless something later rewatches the whole block. rewatchSettledImports only covers settled imports.
  • I did not construct a fixture that produces this case, so I can't confirm or rule it out with a measurement.

Summary of measured facts

  • Both PRs make agc_driver_msaa_dcc_clear_4 pass on the RTX 5070 Ti and the Radeon iGPU here, 3 of 3 runs each.
  • #8169 makes four tests fail that pass on main, on both GPUs: agc_driver_graphics (17 BDA sub-tests), agc_storage_writeback_blocks, agc_host_import_retirement and agc_host_import_retire. Their messages are about adjacent ranges no longer being grouped. #8172 adds no failures to the subset.
  • #8169's new test is skipped under ctest here because the mock context's hostImportAlignment is 0. With that condition removed, it fails on main and passes with #8169.
  • #8172's tests fail on #8169. They exercise ImportWatched and the DCC generations, which #8169 does not change.
  • No retire churn appeared in the traced tests for either PR. The retire path described above for #8169 was not exercised.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281876251 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8169#issuecomment-6281876251). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-20T02:24:54Z. --- I ran #8169 and #8172 on the same Windows base so both fixes for #8103 can be compared. @MarcZX10 mentioned they could not build #8169 or run the Windows repro, so here are those results. Disclosure: #8172 is my PR, so I've kept this to measurements. **Setup** - Base `main` 7e12b3da8. - #8169 head 629ee88e8, merged onto that base. - #8172 head 58f0e89ca, applied onto the same base. - Windows 11 Home 26300, Ryzen 5 9600X, WinLibs GCC 15.2.0, Release, Ninja, `BUILD_TESTING=ON`. - GPUs: RTX 5070 Ti and the Radeon iGPU (`ANYPS5_GPU=AMD`). - Environment: `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 APS5_NO_PIPELINE_JOURNAL=1`. No validation layer is installed. ### 1. The #8103 repro Each test ran 3 times on each GPU. | test | main | #8169 | #8172 | |---|---|---|---| | `agc_driver_msaa_dcc_clear_4` | fails (`requires watched guest memory`) | 3/3 pass, both GPUs | 3/3 pass, both GPUs | | `agc_driver_msaa_dcc_clear_2`, `_8`, `agc_driver_msaa_dcc_state`, `agc_write_tracking` | pass | 3/3 pass, both GPUs | 3/3 pass, both GPUs | | `agc_driver_graphics` | pass | 3/3 fail, both GPUs | 3/3 pass, both GPUs | So both PRs fix `agc_driver_msaa_dcc_clear_4` on this machine. With #8169, `agc_driver_graphics` stops at its first failure: ```text AGC graphics: adjacent registered ranges with the same access were not imported as one span ``` ### 2. `agc|guest_memory|import|watch` subset 831 tests, `-j6`, NVIDIA. | | failures | |---|---| | main | `agc_driver_msaa_dcc_clear_4`, `agc_driver_pass_input_hazard`, `agc_pipeline_journal` | | #8169 | `agc_driver_graphics`, `agc_storage_writeback_blocks`, `agc_host_import_retirement`, `agc_host_import_retire`, `agc_driver_pass_input_hazard`, `agc_pipeline_journal` | | #8172 | `agc_driver_pass_input_hazard`, `agc_pipeline_journal` | `agc_driver_pass_input_hazard` and `agc_pipeline_journal` fail on main too. `agc_pipeline_journal` fails because `APS5_NO_PIPELINE_JOURNAL=1` is set. The four tests that fail only with #8169 also failed 2 of 2 when run alone on NVIDIA, and once each on the iGPU: - `agc_storage_writeback_blocks`: `a 4 MiB image over 64 KiB pieces of which every other one is not GPU mapped: 0 imports made (0 by write-back segments), CPU write-back, 1048576 of 1048576 texels stored` - `agc_host_import_retirement`: `unlocked mapping retired an import instead of requesting the GPU lock` - `agc_host_import_retire`: `FAIL: the grown run was not imported as one import replacing the first` - `agc_driver_graphics`: see above `agc_driver_graphics` stops at the first failure, so I made a local diagnostic build (not part of either PR). It runs each of the 58 sub-tests of `RunBdaResourceTests` in its own process. - On main, all 58 pass except #8169's new test, enabled as described in section 3. - With #8169, 17 fail, all with grouping messages: - `importCrossingTests`, `importSpanTests`, `failedImportRemapTests`, `spaceImportRunTests`, `importWindowTests`, `spaceReadAcrossImportsTests` - `importBlockMapTests` (both variants), `importBlockBuildTests`, `importBlockHoleTests`, `importBlockUnalignedTests`, `importBlockFlagTests`, `importBlockRemapTests`, `importBlockFailureTests`, `importBlockBudgetTests` - `evictingRefusalWindowTests`, `evictingRefusalBlockRangesTests`, `evictingRefusalStepDownTests` - Example: `64 adjacent 64 KiB pieces mapped one by one were not imported as one 4 MiB block: 64 imports` Of these fixtures, I checked two. `importCrossingTests` allocates with `::operator new`, and `HostImportRetireHold.cpp` uses `VirtualAlloc`. Neither is in the guest arena. On Windows `GuestMemory::WriteWatched()` is true, so the new `GuestMemory::Watched(...)` condition in `importRun` returns the single range for these blocks. The only code change in #8169 is that condition, and every one of these sub-tests passes on main. I did not measure whether guest-arena ranges in a real title, for example read-only ones, are all watched. So I can't say how often titles would hit this. ### 3. #8169's regression test (`importBlockMixedWatchTests`) Under ctest on this machine, the test prints `write watching unavailable: mixed import block not tested` and returns, on main and on #8169 alike. A local print showed the values of its guard: - `GuestArenaAvailable` = 1 - `GuestArenaWriteWatched` = 1 - `GuestMemory::WriteWatched()` = 1 - `context.hostImportAlignment` = 0 The context that `RunBdaResourceTests` receives is `mockContext()`, whose alignment is 0. The `PieceWindow` the test builds sets its own `importing.hostImportAlignment` to 64 KiB. I removed only the `context.hostImportAlignment == 0` condition, locally: - On main, it fails with `an aligned import through unwatched neighboring spans dropped the target from the write watch`. - With #8169, run alone, it passes. So the test detects the bug once the guard reads the alignment from `window.importing` (or the condition is dropped). As committed, it does not run here. ### 4. #8172's tests on the #8169 build I applied only #8172's two test files on top of #8169. | test | #8169 + #8172 tests | message | |---|---|---| | `agc_write_tracking`, `CheckImportWindowOverUnwatchedBlock` | fails, 6/6 runs (both GPUs) | `took the watched blocks out of the write watch` | | `agc_driver_msaa_dcc_clear_{2,4,8}`, `DccImportWindowTests` | fails, 6/6 runs (both GPUs) | `writes to a resident multisampled DCC target or its metadata are not implemented (DCC range 0x200100000+0x1000, 4 samples)` (likewise for 2 and 8) | Both tests call `GuestMemory::ImportWatched` directly, which #8169 does not change. They test `ImportWatched` and the DCC metadata generations, not `importRun`. Failing them does not mean #8169 fails to fix the issue's test. With #8169, the stock `dcc_clear_4` never builds the 4 MiB block (see section 5), so it does not reach the metadata refusal that `DccImportWindowTests` checks. ### 5. Import churn (`APS5_TRACE_HOST_IMPORT=1`) **What the counts mean** - "ok" counts `host import of ... ok` lines. - "retired" counts `host import of ... retired: the range was mapped again`. - `refreshImports` prints that line when `sameRange(entry)` is false while the range is still leased. - That is the retire path the importRun concern is about. - Each test ran once, on NVIDIA. | test | main ok / retired | #8169 ok / retired | #8172 ok / retired | |---|---|---|---| | `agc_storage_writeback_blocks` | 3 / 0 | 128 / 0 (fails) | 3 / 0 | | `agc_host_import_retirement` | 6 / 2 | 6 / 0 (fails) | 6 / 2 | | `agc_host_import_retire` | 6 / 2 | 6 / 0 (fails) | 6 / 2 | | `agc_driver_msaa_dcc_clear_4` | 27 / 8 (fails) | 31 / 0 | 31 / 8 | | `agc_driver_host_import_lifetime` | 19 / 0 | 19 / 0 | 19 / 0 | | `agc_driver_host_import_at_map` | 8 / 0 | 8 / 0 | 8 / 0 | | `_unmap`, `_second_mapping`, `_mutation_race`, `_sparse`, `_teardown`, `_windows`, `storage_write_back_overhang` | same counts on all three, 0 retired | In `dcc_clear_4`: - #8169 makes 28 imports of 256 KiB and 3 of 64 KiB. It makes no 4 MiB block and retires nothing. - #8172 makes 27 of 256 KiB, 3 of 64 KiB and the 4 MiB block, and retires eight 256 KiB imports, as on main. So none of these tests showed a retire/re-import loop with #8169. For #8169, the "retired" count is 0 everywhere. The concern raised in the #8103 bisect comment comes from this code path, which no test above covers. It is from reading the code; I did not measure it: - `sameRange(const HostImport&)` re-runs `importRun(lease, entry.base, ...)` at every allocation-generation refresh. With #8169, that result depends on `GuestMemory::Watched` over the candidate block. - On Windows, an import is made with `staysWatched == false` when `watchedHostPointer` is false: `unwatchImports` is set and the import is not settled (read-only, or below `settleFloorBytes`). - `ImportWatched` then unwatches the whole run. - `refreshImports` calls `GuestMemory::Unwatch` on it again at each refresh (`if (it->second.unwatched)`). - If #8169 formed such a grouped import while its block was watched, then at the next refresh `importRun` would return the single range. `sameRun` would fail and the import would be retired. A later import would take the single range, because the block stays unwatched. - By this reading, that is one retire per such grouped import, not a repeating cycle, unless something later rewatches the whole block. `rewatchSettledImports` only covers settled imports. - I did not construct a fixture that produces this case, so I can't confirm or rule it out with a measurement. ### Summary of measured facts - Both PRs make `agc_driver_msaa_dcc_clear_4` pass on the RTX 5070 Ti and the Radeon iGPU here, 3 of 3 runs each. - #8169 makes four tests fail that pass on main, on both GPUs: `agc_driver_graphics` (17 BDA sub-tests), `agc_storage_writeback_blocks`, `agc_host_import_retirement` and `agc_host_import_retire`. Their messages are about adjacent ranges no longer being grouped. #8172 adds no failures to the subset. - #8169's new test is skipped under ctest here because the mock context's `hostImportAlignment` is 0. With that condition removed, it fails on main and passes with #8169. - #8172's tests fail on #8169. They exercise `ImportWatched` and the DCC generations, which #8169 does not change. - No retire churn appeared in the traced tests for either PR. The retire path described above for #8169 was not exercised. AI-assisted: yes (Claude Code); results above were run on this machine.
oneandonlydean commented 2026-10-20 07:21:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T07:21:54Z.


Thanks for jumping on #8103 so quickly. We're closing this in favour of #8172, which fixes the same regression at its cause: ImportWatched keeps the watched blocks under a partly unwatched import. It also fixes a second DCC metadata-generation failure. A Windows hardware run on a 5070 Ti and a Radeon shows both parts are needed for msaa_dcc_clear_4.

For reference, this head also fails CI (run 39352989674, Windows). agc_host_import_retire fails 3 checks, and agc_driver_graphics fails at BdaResources.cpp:192 because adjacent ranges are no longer imported as one span. The new !Watched guard in importRun stops grouping unwatched runs that the existing fixtures depend on, and the same check fails on Linux too.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6285638907 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8169#issuecomment-6285638907). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-20T07:21:54Z. --- Thanks for jumping on #8103 so quickly. We're closing this in favour of #8172, which fixes the same regression at its cause: ImportWatched keeps the watched blocks under a partly unwatched import. It also fixes a second DCC metadata-generation failure. A Windows hardware run on a 5070 Ti and a Radeon shows both parts are needed for `msaa_dcc_clear_4`. For reference, this head also fails CI (run 39352989674, Windows). `agc_host_import_retire` fails 3 checks, and `agc_driver_graphics` fails at BdaResources.cpp:192 because adjacent ranges are no longer imported as one span. The new `!Watched` guard in `importRun` stops grouping unwatched runs that the existing fixtures depend on, and the same check fails on Linux too.

Pull request closed

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!8169
No description provided.