fix(agc): keep buffer owners when a staged address space dissolves #10304

Merged
Ondra97 merged 3 commits from upstream-pr/10304 into main 2026-11-02 08:00:27 +00:00
Ondra97 commented 2026-10-23 16:55:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-23T16:55:42Z.


What

A writable descriptor can create a staging candidate inside a cached address space, then a later writable descriptor crosses that space's registered edge and dissolves it. resolveOverlays initialized the discard mask to true for every region when the address space was absent, so it erased the retained base and ordinary buffers along with the redundant overlay candidates. Looking up a descriptor then threw AGC graphics: guest buffer has no GPU owner.

Initialize the mask to false and mark only overlay members for removal after dissolution. Extend the existing staging regression with an in-space write, a crossing write and a separate ordinary read. It asserts dissolution, executes GPU storage writes, reads back the ordinary buffer, and checks that only the two requested byte ranges changed.

The PR also includes failedJoinDissolvedOverlayTests, contributed by Yunus Shaikh (EagleBearerYS) in f507598e81, cherry-picked with authorship preserved. It forces a joined host import to fail at vkAllocateMemory, restores the two separate imports, then creates a staged write followed by a write across their boundary. The mock-device test checks descriptor ownership and that the written word reaches guest memory; it runs without a physical Vulkan device.

Tested

Latest local validation (October 29, 2026): main 3a2b91981651569163768854a1fcdc7193b6667b, candidate 31f895cb59adf55532cd818ad491b7dcaef676f5. The baseline build used the same two regression sources as the candidate and GuestBufferMemory.cpp taken byte-for-byte from main (Git blob 64de3d8c8d7566fa7e1faf3cf362d476106ee748). The candidate includes main through a merge, without rewriting the original PR history.

Windows 11 Pro build 26300, Ryzen 9 7900X, 32 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 621.01; WinLibs MinGW-w64 GCC 15.2.0 r7, Release. Both runs used the same machine, GPU and test configuration, disabled shader caching and required Vulkan. Loader logs identify the RTX 4070 Ti SUPER and show the Khronos validation layer (manifest API 1.4.335) inserted at instance and device creation in all five real-GPU tests. Neither log contains a missing-layer warning, a VUID- diagnostic or a synchronization hazard.

Metric Before (base) After (fix)
agc_driver_graphics (includes the failed-join mock regression) fails: missing GPU owner passes
agc_bda_staging fails: missing GPU owner passes
Four neighboring GPU tests 4 pass 4 pass
Skipped tests 0 0
VUID diagnostics 0 0

One run of the six-test selection per build. The four neighboring tests are agc_read_written_staging, agc_driver_bda_reads_shadowed_results, agc_driver_bda_reads_shadowed_results_per_build and agc_unit_shadow_completion_store. The mock log records the intended vkAllocateMemory (-2) failure requested by a join. The candidate's real-GPU staging case also confirms dissolution, preserved owners and correct guest bytes.

The full Windows Release build and patched_libraries pass on the candidate. python tools/check_conventions.py --base origin/main and whitespace checks pass. The full CTest suite, current-head Linux build and title runs were not performed locally.

tools/pr_overlap.py inspected 1,380 other open PRs; 90 shared files or exports with this branch. I manually checked the relevant changes in the 37 PRs whose conflicts prevented an automatic comparison. None changes resolveOverlays or duplicates the failed-join overlay regression. #6185 and #6186 edit earlier copy-back assertions in bdaStagingTests, outside this PR's added dissolution case; no dependency is required.

Reproduction with the supported Windows toolchain and dependencies from BUILD.md:

cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
cmake --build build --target agc_driver_graphics_tests agc_driver_recorder_tests --parallel 8
$env:ANYPS5_REQUIRE_VULKAN='1'
$env:ANYPS5_NO_SHADER_CACHE='1'
$env:VK_INSTANCE_LAYERS='VK_LAYER_KHRONOS_validation'
$env:VK_LOADER_DEBUG='layer'
ctest --test-dir build -R '^(agc_driver_graphics|agc_bda_staging|agc_read_written_staging|agc_driver_bda_reads_shadowed_results|agc_driver_bda_reads_shadowed_results_per_build|agc_unit_shadow_completion_store)$' -V --parallel 1 --timeout 30
cmake --build build --parallel 8
ctest --test-dir build -R '^patched_libraries$' --output-on-failure --timeout 30
python tools/check_conventions.py --base origin/main
python tools/pr_overlap.py --branch codex/fix-agc-dissolved-staging-owners --repo boykopovar/AnyPS5

For the baseline, use the candidate test sources with the main version of GuestBufferMemory.cpp; restore the candidate version before rebuilding for the fixed run. The validation layer must be discoverable; my runs supplied its existing installation through VK_LAYER_PATH. No title was rerun for this update.

Earlier validation of the original patch (e0d6e062a969d723a868d50741863a9aceadb6ae):

Windows 11 Pro (build 26300), Ryzen 9 7900X, 32 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.42; Release, GCC 15.2.0.

  • Base 4be3da2c6fb68f79953ff78978c83e06de6033b9 plus the same regression: agc_bda_staging fails with the missing-owner exception; four neighboring GPU tests pass.
  • Head e0d6e062a969d723a868d50741863a9aceadb6ae: all five pass, zero skips. Cases: agc_bda_staging, agc_read_written_staging, agc_driver_bda_reads_shadowed_results, agc_driver_bda_reads_shadowed_results_per_build, agc_unit_shadow_completion_store.
  • Both GPU runs require Vulkan, disable the shader cache and enable VK_LAYER_KHRONOS_validation. Loader logs confirm the validation layer at instance and device creation. Neither run reports a VUID.
  • Full Windows Release build and patched_libraries pass. tools/check_conventions.py --base origin/main and whitespace checks pass.
  • The original exception was captured in PRAGMATA (PPSA02530), compute shader 0x211204d400, on an earlier local diagnostic integration (main 2b3baacd plus #7446 and capture diagnostics). A fresh 20-minute game run of this isolated fix on 4be3da2c passed the intro into a black loading phase without the owner exception, then closed normally with exit code 0 after diagnostic collection. Bounded thread/lock profiling was used during that run. Progress beyond loading remains unconfirmed. That PRAGMATA run makes no gameplay or performance claim.

Independent validation reported by contributors (their runs, with setup and limits in the linked comments):

  • JJenkx, Arch Linux/RADV RX 6650 XT: the identical agc_bda_staging regression failed on pinned main and passed with this PR. agc_read_written_staging passed on both. Three other named tests skipped on both because this device reports watched host memory written during import/read; those paths remain untested on that GPU. Khronos validation was loaded in all ten logs, with no reported VUIDs. This is focused test evidence, without #8091 or a title run.

  • zaidhawk, Persona 3 Reload PPSA10872: on Windows/RTX 5090, four main runs that reached the end of the opening animation stopped with the missing-owner error; two runs with this PR reached the title screen and attract scene. Other runs stopped earlier on a separate pending storage-image error.

  • Lindamea1, Monster Hunter Wilds PPSA24191: on Linux/RTX 5090, the owner error occurred in two main runs and was absent in eight runs including this PR. Only two of those eight progressed past the earlier main failure point; six included additional stencil replay changes. Three of five GPU tests skipped on both main and the candidate on this device.

  • johnmaia, Epic Mickey: Rebrushed PPSA15657: on Linux/RADV RX 7600, two main runs with #8091 stopped on the missing-owner error before gameplay; two runs with #8091 and this PR reached the level without that abort. The #8091 dependency and different workloads prevent attributing a speed change to this PR.

  • QRMOE, Resident Evil Requiem PPSA31246 01.200.000: on Windows 11 Home 26200/Radeon RX 9070 XT, main 29ce6d87eb with #10935 stopped on the missing-owner error during first-boot loading. Seven later boots with this PR had no owner error and reached the intro, then stopped on other issues. First-boot and saved-settings paths differ, so this is not a same-path A/B; no validation layer was used. One run hit the native multisample-depth publication refusal; with #9950 too, runs stopped on VK_ERROR_DEVICE_LOST, whose cause remains unverified. Gameplay was not reached.

  • EagleBearerYS, Linux and Windows hosted runners: the contributed mock regression fails with the main implementation in both baseline repetitions on each runner and passes with the fix in five repetitions. The CI run uses main 319621ba2e578bd053b0baba2877fe70520e0737 plus the PR and test. Linux: 104 pass, 7 skip; Windows: 40 pass, 86 skip (no Vulkan device). These are contributor results. Resident Evil Village PPSA01556 encountered the same failure sequence in their modified-main runs, but they have not tested that title with this PR.

The full CTest suite was not run.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: latest local run: NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 621.01, Windows 11 Pro build 26300; earlier local run: the same GPU/OS, NVIDIA 617.42; contributor reports: AMD Radeon RX 6650 XT, Mesa 26.2.4, Arch Linux kernel 7.2.9; NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 11 Pro build 26200; NVIDIA GeForce RTX 5090, NVIDIA 595.99.02, Gentoo Linux kernel 7.2.8; AMD Radeon RX 7600, Linux, driver version not reported; AMD Radeon RX 9070 XT, Windows driver version not reported (Vulkan 1.4), Windows 11 Home build 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4986318524 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10304). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-23T16:55:42Z. --- ### What A writable descriptor can create a staging candidate inside a cached address space, then a later writable descriptor crosses that space's registered edge and dissolves it. `resolveOverlays` initialized the discard mask to true for every region when the address space was absent, so it erased the retained base and ordinary buffers along with the redundant overlay candidates. Looking up a descriptor then threw `AGC graphics: guest buffer has no GPU owner`. Initialize the mask to false and mark only overlay members for removal after dissolution. Extend the existing staging regression with an in-space write, a crossing write and a separate ordinary read. It asserts dissolution, executes GPU storage writes, reads back the ordinary buffer, and checks that only the two requested byte ranges changed. The PR also includes `failedJoinDissolvedOverlayTests`, contributed by Yunus Shaikh (`EagleBearerYS`) in [f507598e81](https://github.com/EagleBearerYS/AnyPS5/commit/f507598e8137de24f1de49c1dac3a647924feba5), cherry-picked with authorship preserved. It forces a joined host import to fail at `vkAllocateMemory`, restores the two separate imports, then creates a staged write followed by a write across their boundary. The mock-device test checks descriptor ownership and that the written word reaches guest memory; it runs without a physical Vulkan device. ### Tested Latest local validation (October 29, 2026): main `3a2b91981651569163768854a1fcdc7193b6667b`, candidate `31f895cb59adf55532cd818ad491b7dcaef676f5`. The baseline build used the same two regression sources as the candidate and `GuestBufferMemory.cpp` taken byte-for-byte from main (Git blob `64de3d8c8d7566fa7e1faf3cf362d476106ee748`). The candidate includes main through a merge, without rewriting the original PR history. Windows 11 Pro build 26300, Ryzen 9 7900X, 32 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, driver 621.01; WinLibs MinGW-w64 GCC 15.2.0 r7, Release. Both runs used the same machine, GPU and test configuration, disabled shader caching and required Vulkan. Loader logs identify the RTX 4070 Ti SUPER and show the Khronos validation layer (manifest API 1.4.335) inserted at instance and device creation in all five real-GPU tests. Neither log contains a missing-layer warning, a `VUID-` diagnostic or a synchronization hazard. | Metric | Before (base) | After (fix) | | --- | --- | --- | | `agc_driver_graphics` (includes the failed-join mock regression) | fails: missing GPU owner | passes | | `agc_bda_staging` | fails: missing GPU owner | passes | | Four neighboring GPU tests | 4 pass | 4 pass | | Skipped tests | 0 | 0 | | VUID diagnostics | 0 | 0 | One run of the six-test selection per build. The four neighboring tests are `agc_read_written_staging`, `agc_driver_bda_reads_shadowed_results`, `agc_driver_bda_reads_shadowed_results_per_build` and `agc_unit_shadow_completion_store`. The mock log records the intended `vkAllocateMemory (-2)` failure requested by a join. The candidate's real-GPU staging case also confirms dissolution, preserved owners and correct guest bytes. The full Windows Release build and `patched_libraries` pass on the candidate. `python tools/check_conventions.py --base origin/main` and whitespace checks pass. The full CTest suite, current-head Linux build and title runs were not performed locally. `tools/pr_overlap.py` inspected 1,380 other open PRs; 90 shared files or exports with this branch. I manually checked the relevant changes in the 37 PRs whose conflicts prevented an automatic comparison. None changes `resolveOverlays` or duplicates the failed-join overlay regression. #6185 and #6186 edit earlier copy-back assertions in `bdaStagingTests`, outside this PR's added dissolution case; no dependency is required. Reproduction with the supported Windows toolchain and dependencies from BUILD.md: ```powershell cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ cmake --build build --target agc_driver_graphics_tests agc_driver_recorder_tests --parallel 8 $env:ANYPS5_REQUIRE_VULKAN='1' $env:ANYPS5_NO_SHADER_CACHE='1' $env:VK_INSTANCE_LAYERS='VK_LAYER_KHRONOS_validation' $env:VK_LOADER_DEBUG='layer' ctest --test-dir build -R '^(agc_driver_graphics|agc_bda_staging|agc_read_written_staging|agc_driver_bda_reads_shadowed_results|agc_driver_bda_reads_shadowed_results_per_build|agc_unit_shadow_completion_store)$' -V --parallel 1 --timeout 30 cmake --build build --parallel 8 ctest --test-dir build -R '^patched_libraries$' --output-on-failure --timeout 30 python tools/check_conventions.py --base origin/main python tools/pr_overlap.py --branch codex/fix-agc-dissolved-staging-owners --repo boykopovar/AnyPS5 ``` For the baseline, use the candidate test sources with the main version of `GuestBufferMemory.cpp`; restore the candidate version before rebuilding for the fixed run. The validation layer must be discoverable; my runs supplied its existing installation through `VK_LAYER_PATH`. No title was rerun for this update. Earlier validation of the original patch (`e0d6e062a969d723a868d50741863a9aceadb6ae`): Windows 11 Pro (build 26300), Ryzen 9 7900X, 32 GiB RAM, NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 617.42; Release, GCC 15.2.0. - Base `4be3da2c6fb68f79953ff78978c83e06de6033b9` plus the same regression: `agc_bda_staging` fails with the missing-owner exception; four neighboring GPU tests pass. - Head `e0d6e062a969d723a868d50741863a9aceadb6ae`: all five pass, zero skips. Cases: `agc_bda_staging`, `agc_read_written_staging`, `agc_driver_bda_reads_shadowed_results`, `agc_driver_bda_reads_shadowed_results_per_build`, `agc_unit_shadow_completion_store`. - Both GPU runs require Vulkan, disable the shader cache and enable `VK_LAYER_KHRONOS_validation`. Loader logs confirm the validation layer at instance and device creation. Neither run reports a VUID. - Full Windows Release build and `patched_libraries` pass. `tools/check_conventions.py --base origin/main` and whitespace checks pass. - The original exception was captured in PRAGMATA (PPSA02530), compute shader `0x211204d400`, on an earlier local diagnostic integration (main `2b3baacd` plus #7446 and capture diagnostics). A fresh 20-minute game run of this isolated fix on `4be3da2c` passed the intro into a black loading phase without the owner exception, then closed normally with exit code 0 after diagnostic collection. Bounded thread/lock profiling was used during that run. Progress beyond loading remains unconfirmed. That PRAGMATA run makes no gameplay or performance claim. Independent validation reported by contributors (their runs, with setup and limits in the linked comments): - [JJenkx, Arch Linux/RADV RX 6650 XT](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6383920161): the identical agc_bda_staging regression failed on pinned main and passed with this PR. agc_read_written_staging passed on both. Three other named tests skipped on both because this device reports watched host memory written during import/read; those paths remain untested on that GPU. Khronos validation was loaded in all ten logs, with no reported VUIDs. This is focused test evidence, without #8091 or a title run. - [zaidhawk, Persona 3 Reload PPSA10872](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6375406593): on Windows/RTX 5090, four main runs that reached the end of the opening animation stopped with the missing-owner error; two runs with this PR reached the title screen and attract scene. Other runs stopped earlier on a separate pending storage-image error. - [Lindamea1, Monster Hunter Wilds PPSA24191](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6382454713): on Linux/RTX 5090, the owner error occurred in two main runs and was absent in eight runs including this PR. Only two of those eight progressed past the earlier main failure point; six included additional stencil replay changes. Three of five GPU tests skipped on both main and the candidate on this device. - [johnmaia, Epic Mickey: Rebrushed PPSA15657](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6382907050): on Linux/RADV RX 7600, two main runs with #8091 stopped on the missing-owner error before gameplay; two runs with #8091 and this PR reached the level without that abort. The #8091 dependency and different workloads prevent attributing a speed change to this PR. - [QRMOE, Resident Evil Requiem PPSA31246 01.200.000](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6399510237): on Windows 11 Home 26200/Radeon RX 9070 XT, main `29ce6d87eb` with #10935 stopped on the missing-owner error during first-boot loading. Seven later boots with this PR had no owner error and reached the intro, then stopped on other issues. First-boot and saved-settings paths differ, so this is not a same-path A/B; no validation layer was used. One run hit the native multisample-depth publication refusal; with #9950 too, runs stopped on `VK_ERROR_DEVICE_LOST`, whose cause remains unverified. Gameplay was not reached. - [EagleBearerYS, Linux and Windows hosted runners](https://github.com/boykopovar/AnyPS5/pull/10304#issuecomment-6481458502): the contributed mock regression fails with the main implementation in both baseline repetitions on each runner and passes with the fix in five repetitions. The [CI run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40763440361) uses main `319621ba2e578bd053b0baba2877fe70520e0737` plus the PR and test. Linux: 104 pass, 7 skip; Windows: 40 pass, 86 skip (no Vulkan device). These are contributor results. Resident Evil Village PPSA01556 encountered the same failure sequence in their modified-main runs, but they have not tested that title with this PR. The full CTest suite was not run. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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) - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> latest local run: NVIDIA GeForce RTX 4070 Ti SUPER, NVIDIA 621.01, Windows 11 Pro build 26300; earlier local run: the same GPU/OS, NVIDIA 617.42; contributor reports: AMD Radeon RX 6650 XT, Mesa 26.2.4, Arch Linux kernel 7.2.9; NVIDIA GeForce RTX 5090, NVIDIA 617.42, Windows 11 Pro build 26200; NVIDIA GeForce RTX 5090, NVIDIA 595.99.02, Gentoo Linux kernel 7.2.8; AMD Radeon RX 7600, Linux, driver version not reported; AMD Radeon RX 9070 XT, Windows driver version not reported (Vulkan 1.4), Windows 11 Home build 26200 - [x] AI-assisted: <!-- yes / no --> yes
MarcZX10 commented 2026-10-24 21:17:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T21:17:05Z.

Review: CHANGES_REQUESTED


The production fix is narrowly scoped: when the cached address space has already dissolved, only overlay members are now dropped; retained base regions remain available. The added regression checks the in-space write, the crossing write, a separate ordinary read, and untouched bytes. The reported Windows and RADV validation runs, with their skip limits stated, are useful evidence.

The integration runs are based on 4be3da2, 7,557 commits behind current main. Since then, both GuestBufferMemory.cpp and the AGC recorder tests have changed on main (including host-import settling/joining and staging-test updates). The hosted product tests are skipped, so please refresh onto current main and rerun agc_bda_staging plus the neighboring staging/readback cases on the Windows/NVIDIA setup where the original failure reproduced. Require Vulkan and validation, and report any skips explicitly. A local rerun is not available here because this environment has no Vulkan device.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640066272 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10304#pullrequestreview-5640066272). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T21:17:05Z. **Review:** CHANGES_REQUESTED --- The production fix is narrowly scoped: when the cached address space has already dissolved, only overlay members are now dropped; retained base regions remain available. The added regression checks the in-space write, the crossing write, a separate ordinary read, and untouched bytes. The reported Windows and RADV validation runs, with their skip limits stated, are useful evidence. The integration runs are based on `4be3da2`, 7,557 commits behind current `main`. Since then, both `GuestBufferMemory.cpp` and the AGC recorder tests have changed on main (including host-import settling/joining and staging-test updates). The hosted product tests are skipped, so please refresh onto current `main` and rerun `agc_bda_staging` plus the neighboring staging/readback cases on the Windows/NVIDIA setup where the original failure reproduced. Require Vulkan and validation, and report any skips explicitly. A local rerun is not available here because this environment has no Vulkan device.
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!10304
No description provided.