fix(agc): publish small tiled writes before labels #11694

Merged
droid2299 merged 2 commits from upstream-pr/11694 into main 2026-10-29 13:52:04 +00:00
droid2299 commented 2026-10-27 03:30:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by droid2299 on 2026-10-27T03:30:55Z.


What

Publish small tiled storage-image write-backs directly to the host import instead of a unit shadow. This keeps their results visible to CPU reads after a label, while large tiled images retain unit-shadow write-backs.

Adds a focused regression test covering CPU visibility after a label, GPU-reader ordering, and the large-image shadow path.

Tested

Windows 10 Home 25H2 (build 26200.9711), NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA driver 616.92 (32.0.16.1692), Release.

  • cmake --build build-main-regression --target agc_driver_recorder_tests --parallel
  • ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build-main-regression -R '^agc_small_tiled_shadow_label$' -V
  • The focused test fails with the previous write-back behavior and passes with this change.
  • The validation layer was available; the passing log contains no VUID- errors.

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: Fixes #11481
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA driver 616.92 (32.0.16.1692), Windows 10 Home 25H2 build 26200.9711
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5028139205 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11694). Originally posted by [droid2299](https://github.com/droid2299) on 2026-10-27T03:30:55Z. --- ### What Publish small tiled storage-image write-backs directly to the host import instead of a unit shadow. This keeps their results visible to CPU reads after a label, while large tiled images retain unit-shadow write-backs. Adds a focused regression test covering CPU visibility after a label, GPU-reader ordering, and the large-image shadow path. ### Tested Windows 10 Home 25H2 (build 26200.9711), NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA driver 616.92 (32.0.16.1692), Release. - `cmake --build build-main-regression --target agc_driver_recorder_tests --parallel` - `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest --test-dir build-main-regression -R '^agc_small_tiled_shadow_label$' -V` - The focused test fails with the previous write-back behavior and passes with this change. - The validation layer was available; the passing log contains no `VUID-` errors. ### 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 (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 #11481 - [x] Unblocks: none - [x] GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, NVIDIA driver 616.92 (32.0.16.1692), Windows 10 Home 25H2 build 26200.9711 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-27 05:23:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T05:23:30Z.

Review: CHANGES_REQUESTED


Reviewed exact head ce2c64a2b68957ba9f9a8b75cb999de5bddcd937.

[P1] Preserve neighboring unit-shadow data when small write-backs bypass the shadow. In StorageTexture::writeBackWindows, this change forces ShadowDestinationFor to return no destination for every write at or below SmallStoreBytes, so those pieces are copied directly into the host import. Shadow freshness is tracked per 64 KiB unit. A small 4 KiB-swizzled image can share that unit with a different image whose newer bytes are still in a shadow slab; the direct import write/MarkWritten path can invalidate the unit and discard the neighbor's unpublished bytes. I do not see a PublishShadow of the affected unit before the direct copy.

The current regression uses a 64 KiB-aligned image with no shadowed neighbor, so it cannot catch this case. Please add the requested shared-unit regression (4 KiB-swizzled small image plus a shadowed neighbor), verify the small image remains CPU-visible after the label and the neighbor's contents survive publication, and preserve the large-image shadow control. Publishing the affected partial units before a direct write, or keeping the existing shadow path and publishing the small image at readback time, are possible approaches; the test should establish the correct behavior.

Hosted eligibility, intake, conventions, label and report checks pass; product jobs are skipped by path policy. The PR reports a focused Windows/Vulkan validation-layer run, which I have not independently reproduced on this host.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5662584833 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11694#pullrequestreview-5662584833). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T05:23:30Z. **Review:** CHANGES_REQUESTED --- Reviewed exact head `ce2c64a2b68957ba9f9a8b75cb999de5bddcd937`. **[P1] Preserve neighboring unit-shadow data when small write-backs bypass the shadow.** In `StorageTexture::writeBackWindows`, this change forces `ShadowDestinationFor` to return no destination for every write at or below `SmallStoreBytes`, so those pieces are copied directly into the host import. Shadow freshness is tracked per 64 KiB unit. A small 4 KiB-swizzled image can share that unit with a different image whose newer bytes are still in a shadow slab; the direct import write/`MarkWritten` path can invalidate the unit and discard the neighbor's unpublished bytes. I do not see a `PublishShadow` of the affected unit before the direct copy. The current regression uses a 64 KiB-aligned image with no shadowed neighbor, so it cannot catch this case. Please add the requested shared-unit regression (4 KiB-swizzled small image plus a shadowed neighbor), verify the small image remains CPU-visible after the label and the neighbor's contents survive publication, and preserve the large-image shadow control. Publishing the affected partial units before a direct write, or keeping the existing shadow path and publishing the small image at readback time, are possible approaches; the test should establish the correct behavior. Hosted eligibility, intake, conventions, label and report checks pass; product jobs are skipped by path policy. The PR reports a focused Windows/Vulkan validation-layer run, which I have not independently reproduced on this host.
MarcZX10 commented 2026-10-27 09:42:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-27T09:42:12Z.

Review: DISMISSED


Follow-up against current upstream main 801d5b9bc1: this PR remains based on 09f9a63f6b, and Texture.cpp, the driver CMake file and Recorder.cpp all changed on main since then. The current Texture.cpp also changed storage-view format handling and the StorageView interface, so the earlier review cannot establish behavior or build/test coverage for the current merge. Please rebase and rerun the paired small-image/neighbor shadow regression, large-image shadow control, and the required Vulkan validation-layer test on the merged tree. The previous shared-64-KiB-unit concern remains unresolved; the stale-base integration request is an additional reason not to approve.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5665026540 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11694#pullrequestreview-5665026540). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-27T09:42:12Z. **Review:** DISMISSED --- Follow-up against current upstream `main` `801d5b9bc1`: this PR remains based on `09f9a63f6b`, and `Texture.cpp`, the driver CMake file and `Recorder.cpp` all changed on main since then. The current `Texture.cpp` also changed storage-view format handling and the `StorageView` interface, so the earlier review cannot establish behavior or build/test coverage for the current merge. Please rebase and rerun the paired small-image/neighbor shadow regression, large-image shadow control, and the required Vulkan validation-layer test on the merged tree. The previous shared-64-KiB-unit concern remains unresolved; the stale-base integration request is an additional reason not to approve.
adriadam10 commented 2026-10-27 11:35:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T11:35:09Z.

Review: CHANGES_REQUESTED


Thanks for the fix; the label case in #11481 is real. Points to address:

  • core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:3418: forcing no shadow destination for every write at or below SmallStoreBytes sends those pieces straight to the host import. Shadow freshness is tracked per 64 KiB unit, so a small image with a 256 B / 4 KiB swizzle that shares a unit with another image's still-shadowed results discards that neighbour's unpublished bytes on the direct write plus MarkWritten. Either publish the affected units (PublishShadow(range, PublishScope::PartialUnits, ...), as storeDrawnRect and the whole-layer path do) before the direct copy, or keep write-back unchanged and have StoreReadbackBeforeLabel publish shadowed units over the small ranges.
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp:5888: the test uses a 64 KiB-aligned image with no neighbour, so it cannot catch the case above. Please add a 4 KiB-swizzled small image sharing a unit with a shadowed neighbour, checking that the small image is CPU-visible after the label and the neighbour's contents survive. Keep the large-image shadow control.
  • The branch is based on an older main; Texture.cpp, the driver CMake file and Recorder.cpp have changed since. Please rebase and rerun the focused tests with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and the validation layer on the merged tree.

Happy to look again once these are addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5666413030 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11694#pullrequestreview-5666413030). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T11:35:09Z. **Review:** CHANGES_REQUESTED --- Thanks for the fix; the label case in #11481 is real. Points to address: - `core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:3418`: forcing no shadow destination for every write at or below `SmallStoreBytes` sends those pieces straight to the host import. Shadow freshness is tracked per 64 KiB unit, so a small image with a 256 B / 4 KiB swizzle that shares a unit with another image's still-shadowed results discards that neighbour's unpublished bytes on the direct write plus `MarkWritten`. Either publish the affected units (`PublishShadow(range, PublishScope::PartialUnits, ...)`, as `storeDrawnRect` and the whole-layer path do) before the direct copy, or keep write-back unchanged and have `StoreReadbackBeforeLabel` publish shadowed units over the small ranges. - `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp:5888`: the test uses a 64 KiB-aligned image with no neighbour, so it cannot catch the case above. Please add a 4 KiB-swizzled small image sharing a unit with a shadowed neighbour, checking that the small image is CPU-visible after the label and the neighbour's contents survive. Keep the large-image shadow control. - The branch is based on an older `main`; `Texture.cpp`, the driver CMake file and `Recorder.cpp` have changed since. Please rebase and rerun the focused tests with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and the validation layer on the merged tree. Happy to look again once these are addressed.
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!11694
No description provided.