fix(agc): preserve registered array slices on CPU write-back #6367

Merged
Zenodeon merged 1 commit from upstream-pr/6367 into main 2026-10-19 00:41:15 +00:00
Zenodeon commented 2026-10-15 13:20:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Zenodeon on 2026-10-15T13:20:50Z.


What

Preserve GPU results during CPU write-back when the selected texture-array slice is registered but unused slices in the descriptor extend outside registered memory.

For example, only slice 0 of a four-slice array may be registered and have pending results. StorageTexture::writeBackLayers previously checked registration of the entire declared image and discarded slice 0's valid results because the unused slices were unregistered. It also refreshed unsaved guest bytes outside the ranges being stored.

Validate each retained write-back range instead, and intersect unsaved snapshot reads with those ranges. Keep the existing overhang handling and drop behavior when an actual destination has been unregistered. No public API or shader-semantic changes; no title-specific checks.

The regression registers only the first or last slice while keeping the complete backing allocation mapped. It checks the drawn pixels and untouched unused slices. A separate retirement case unregisters the active allocation before flushing and verifies that no stale results are written.

SuperTuxKart PPSA69421 supplied real two-slice descriptors whose active first slice fits its registered allocation while the entire descriptor does not. This PR does not claim a title unblock, a black-rendering correction, or a performance improvement.

Related work checked before publication: #6202 scopes refresh and adds independent coverage in the same test file; #6197 changes import selection, including within writeBackLayers; #6280 changes mip handling within that function; #6246 adds an allocation lease for idle stores. None implements this retained-range registration check or snapshot-read intersection. These are independent mechanisms; retain their changes and this regression when reconciling textual conflicts. No dependency on those PRs or the shader experiment tracked by #1413.

Tested

Based on upstream main 73e924acd4; PR commit 540c3a10c6.

Windows (10.0.26200), Intel Core i7-13700, 32 GiB RAM, NVIDIA RTX 4070 12 GiB, driver 591.86. GCC 15.2.0, Ninja, Release, BUILD_TESTING=ON, ANYPS5_ENABLE_SPIRV_TOOLS=ON; checked-out submodule revisions match the repository gitlinks. Rebuilt the complete libs target and focused test binaries; preserved a complete 126-library runtime snapshot with SHA-256 hashes locally.

  • Before: with the new regression and upstream's original production Texture.cpp, agc_driver_array_layer_target fails in 1.56 s:
    CPU write-back discarded the registered slice because an unused array slice was unregistered
    
  • After: 14/14 focused tests pass in 17.25 s total, each under 30 s, with ANYPS5_GPU=RTX 4070 and ANYPS5_REQUIRE_VULKAN=1:
    • agc_storage_kept_unit_settle, agc_storage_upload_lifetime, agc_storage_upload_failure, agc_storage_split_writeback, agc_host_import_retirement, agc_storage_cpu_snapshot;
    • agc_driver_graphics, agc_driver_array_layer_target, agc_driver_depth_fast_clear, agc_driver_depth_fast_clear_submit, agc_driver_depth_storage, agc_driver_depth_storage_reuse, agc_driver_storage_one_slice_alias, agc_driver_storage_write_back_overhang.
  • python tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass; tracked working tree clean.

Remaining validation: fresh standalone SuperTuxKart and vkQuake baseline/candidate comparisons, a completed race, controls/audio checks on this candidate, and a 15-minute stability run. Earlier successful interactive rendering/controls/audio used a separate experimental runtime and are not acceptance evidence for this PR. Linux, lavapipe and other GPU vendors have not been tested locally. No speed claim or performance acceptance result.

Checklist

  • Based on current main; no other open PR implements the same fix (related function/file overlap listed above)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt (no comments added)
  • Unimplemented paths retain strict failure behavior; no silent stubs added
  • No notes, investigation .md files, images, logs or game files added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none claimed; regression workload SuperTuxKart PPSA69421
  • GPUs tested: NVIDIA RTX 4070, driver 591.86, Windows 10.0.26200
  • AI-assisted: yes (OpenAI Codex)

Extended validation remains pending; this PR makes no title-unblock or performance claim.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4873941138 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6367). Originally posted by [Zenodeon](https://github.com/Zenodeon) on 2026-10-15T13:20:50Z. --- ### What Preserve GPU results during CPU write-back when the selected texture-array slice is registered but unused slices in the descriptor extend outside registered memory. For example, only slice 0 of a four-slice array may be registered and have pending results. `StorageTexture::writeBackLayers` previously checked registration of the entire declared image and discarded slice 0's valid results because the unused slices were unregistered. It also refreshed unsaved guest bytes outside the ranges being stored. Validate each retained write-back range instead, and intersect unsaved snapshot reads with those ranges. Keep the existing overhang handling and drop behavior when an actual destination has been unregistered. No public API or shader-semantic changes; no title-specific checks. The regression registers only the first or last slice while keeping the complete backing allocation mapped. It checks the drawn pixels and untouched unused slices. A separate retirement case unregisters the active allocation before flushing and verifies that no stale results are written. SuperTuxKart **PPSA69421** supplied real two-slice descriptors whose active first slice fits its registered allocation while the entire descriptor does not. This PR does not claim a title unblock, a black-rendering correction, or a performance improvement. Related work checked before publication: #6202 scopes refresh and adds independent coverage in the same test file; #6197 changes import selection, including within `writeBackLayers`; #6280 changes mip handling within that function; #6246 adds an allocation lease for idle stores. None implements this retained-range registration check or snapshot-read intersection. These are independent mechanisms; retain their changes and this regression when reconciling textual conflicts. No dependency on those PRs or the shader experiment tracked by #1413. ### Tested Based on upstream `main` **73e924acd4cba5396add13d1c15426f036298118**; PR commit **540c3a10c670bdb9d06723edf6f0a7b8d938e77a**. Windows (10.0.26200), Intel Core i7-13700, 32 GiB RAM, NVIDIA RTX 4070 12 GiB, driver 591.86. GCC 15.2.0, Ninja, Release, `BUILD_TESTING=ON`, `ANYPS5_ENABLE_SPIRV_TOOLS=ON`; checked-out submodule revisions match the repository gitlinks. Rebuilt the complete `libs` target and focused test binaries; preserved a complete 126-library runtime snapshot with SHA-256 hashes locally. - Before: with the new regression and upstream's original production `Texture.cpp`, `agc_driver_array_layer_target` fails in 1.56 s: ```text CPU write-back discarded the registered slice because an unused array slice was unregistered ``` - After: **14/14 focused tests pass in 17.25 s total**, each under 30 s, with `ANYPS5_GPU=RTX 4070` and `ANYPS5_REQUIRE_VULKAN=1`: - `agc_storage_kept_unit_settle`, `agc_storage_upload_lifetime`, `agc_storage_upload_failure`, `agc_storage_split_writeback`, `agc_host_import_retirement`, `agc_storage_cpu_snapshot`; - `agc_driver_graphics`, `agc_driver_array_layer_target`, `agc_driver_depth_fast_clear`, `agc_driver_depth_fast_clear_submit`, `agc_driver_depth_storage`, `agc_driver_depth_storage_reuse`, `agc_driver_storage_one_slice_alias`, `agc_driver_storage_write_back_overhang`. - `python tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` pass; tracked working tree clean. Remaining validation: fresh standalone SuperTuxKart and vkQuake baseline/candidate comparisons, a completed race, controls/audio checks on this candidate, and a 15-minute stability run. Earlier successful interactive rendering/controls/audio used a separate experimental runtime and are not acceptance evidence for this PR. Linux, lavapipe and other GPU vendors have not been tested locally. No speed claim or performance acceptance result. ### Checklist - [x] Based on current `main`; no other open PR implements the same fix (related function/file overlap listed above) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt (no comments added) - [x] Unimplemented paths retain strict failure behavior; no silent stubs added - [x] No notes, investigation `.md` files, images, logs or game files added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none claimed; regression workload SuperTuxKart PPSA69421 - [x] GPUs tested: NVIDIA RTX 4070, driver 591.86, Windows 10.0.26200 - [x] AI-assisted: yes (OpenAI Codex) Extended validation remains pending; this PR makes no title-unblock or performance claim.
github-actions[bot] commented 2026-10-15 13:26:42 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T13:26:42Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6202 core/libs/prx/libSceAgcDriver/tests/execution/ArrayLayerTarget.cpp L311
PR 6960 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp L5143-5145

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 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6454 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6457 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6479 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6615 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6683 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6730 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6946 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6947 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7154 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7254 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193190236 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6367#issuecomment-6193190236). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T13:26:42Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 6202](https://www.github.com/boykopovar/AnyPS5/pull/6202) | `core/libs/prx/libSceAgcDriver/tests/execution/ArrayLayerTarget.cpp` [L311](https://github.com/boykopovar/AnyPS5/blob/f4e60cfde6df7f965e7a68cc7ed27153a9a260f4/core/libs/prx/libSceAgcDriver/tests/execution/ArrayLayerTarget.cpp#L311) | | | | [PR 6960](https://www.github.com/boykopovar/AnyPS5/pull/6960) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` [L5143-5145](https://github.com/boykopovar/AnyPS5/blob/f4e60cfde6df7f965e7a68cc7ed27153a9a260f4/core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp#L5143-L5145) | | | 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 1368](https://www.github.com/boykopovar/AnyPS5/pull/1368) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 1395](https://www.github.com/boykopovar/AnyPS5/pull/1395) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 4448](https://www.github.com/boykopovar/AnyPS5/pull/4448) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 5609](https://www.github.com/boykopovar/AnyPS5/pull/5609) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6188](https://www.github.com/boykopovar/AnyPS5/pull/6188) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6192](https://www.github.com/boykopovar/AnyPS5/pull/6192) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6197](https://www.github.com/boykopovar/AnyPS5/pull/6197) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6454](https://www.github.com/boykopovar/AnyPS5/pull/6454) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6457](https://www.github.com/boykopovar/AnyPS5/pull/6457) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6479](https://www.github.com/boykopovar/AnyPS5/pull/6479) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6481](https://www.github.com/boykopovar/AnyPS5/pull/6481) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6539](https://www.github.com/boykopovar/AnyPS5/pull/6539) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6615](https://www.github.com/boykopovar/AnyPS5/pull/6615) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6683](https://www.github.com/boykopovar/AnyPS5/pull/6683) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6730](https://www.github.com/boykopovar/AnyPS5/pull/6730) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6946](https://www.github.com/boykopovar/AnyPS5/pull/6946) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6947](https://www.github.com/boykopovar/AnyPS5/pull/6947) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6971](https://www.github.com/boykopovar/AnyPS5/pull/6971) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 7154](https://www.github.com/boykopovar/AnyPS5/pull/7154) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 7254](https://www.github.com/boykopovar/AnyPS5/pull/7254) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 7256](https://www.github.com/boykopovar/AnyPS5/pull/7256) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 7604](https://www.github.com/boykopovar/AnyPS5/pull/7604) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` | | [PR 7642](https://www.github.com/boykopovar/AnyPS5/pull/7642) | `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp` |
romainveurrier commented 2026-10-16 21:41:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by romainveurrier on 2026-10-16T21:41:55Z.


Heads-up from #6960 : it also changes writeBackLayers' read of unsaved guest bytes on the CPU path. It moves the read before the keep decision, because the store now uses a compare-exchange against those bytes, and reading them after the decision lets a CPU store made in between pass as the expected value. Your PR can go first; I'll rebase and keep your registered-range restriction, applied to that earlier read.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6225241739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6367#issuecomment-6225241739). Originally posted by [romainveurrier](https://github.com/romainveurrier) on 2026-10-16T21:41:55Z. --- Heads-up from #6960 : it also changes `writeBackLayers`' read of unsaved guest bytes on the CPU path. It moves the read before the keep decision, because the store now uses a compare-exchange against those bytes, and reading them after the decision lets a CPU store made in between pass as the expected value. Your PR can go first; I'll rebase and keep your registered-range restriction, applied to that earlier read.
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!6367
No description provided.