fix(agc): claim multisampled memory in a CB metadata pass over a single-sample target #24994

Merged
birdmarty merged 1 commit from upstream-pr/24994 into main 2026-11-25 04:33:21 +00:00
birdmarty commented 2026-11-21 14:24:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-21T14:24:14Z.


What

Claim overlapping multisampled color target memory when a CB metadata pass (EliminateFastClear or DccDecompress) runs over a single-sample color target, matching what binding that single-sample target as a color attachment already does.

Previously, RunColorMetadataPass looked up the single-sample target's resident image through metadataPassResident (which calls CachedStorageSurface) without claiming the target's address range first. If a host-only multisampled color target still guarded those bytes from an earlier use of the same memory, the guard treated metadataPassResident's lookup as a guest storage-image read of live host-only samples and threw a storage image access of ... overlaps multisampled color target ... (4 samples), whose samples are only on the host: guest access to it is not implemented. Because the draw path already calls ClaimMultisampleTargetMemory when binding a color target over that memory, the CB metadata pass—which writes the same target's bytes—should claim them the same way before touching the target so the multisampled guard retires cleanly.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: call ClaimMultisampleTargetMemory(color.MemoryAddress(), color.bytes) for each single-sample target in the pass.targets loop of RunColorMetadataPass (after the multisampled-target branch that #24993 added).
  • core/libs/prx/libSceAgcDriver/tests/Recorder.cpp: add metadataPassOverMultisampleMemoryTests (run in both --multisample-only and the full agc_driver_recorder suite), creating a host-only 4x multisampled color target via FmaskDecompress, verifying MultisampleColorTargetOverlaps, then running an EliminateFastClear pass over a single-sample SW_64KB_R_X target at the same address and verifying that it succeeds and clears the multisampled guard.
  • docs/dev/debt/changes/fix-agc-metadata-pass-claims-msaa-memory.md: update Multisampled color targets to list a CB fast-clear eliminate or DCC decompress over an overlapping single-sample color target as a memory-reuse claim.

Tested

Windows 11 Pro (build 26300), Intel Core i9-9900K, MinGW-w64 GCC 15.3.0, Release build with tests, AMD Radeon RX 6800 (vendor 0x1002, device 0x73bf, AMD proprietary driver 26.10.1 / Windows driver 32.0.21045.16010, Vulkan 1.4.315), based on origin/main 729981cb5a (rebased after #24993 merged).

Focused AGC tests on main 729981cb5a and on this branch (06a886cfe2), same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0) and VK_LOADER_DEBUG=layer. The set has 29 tests in 11 programs (agc_driver_graphics, agc_driver_recorder, agc_driver_cmask_fast_clear, agc_driver_pipelined_metadata_pass*, agc_driver_cached_image_multisample_guard, agc_driver_multisample_{retirement,srgb_twin,fill_host_only}, agc_driver_multisampled_pass_order, agc_driver_msaa_dcc_*, agc_driver_color_memo_{msaa,metadata,untracked-cmask}_*):

  • main (729981cb5a): 28 passed, 1 failed (agc_driver_recorder, pre-existing Windows address-reuse failure: AGC graphics: 64 KiB R_X 512x512, 3 mips, no DCC, an access to the first unit: an earlier case's image is still in the live registry over the reused memory, so this image would store whole). Insert instance layer "VK_LAYER_KHRONOS_validation" logged 31 times, 0 missing-layer errors, 0 VUID- lines.
  • This change (06a886cfe2): the same 28 passed, 1 failed (agc_driver_recorder, identical pre-existing failure). Insert instance layer "VK_LAYER_KHRONOS_validation" logged 31 times, 0 missing-layer errors, 0 VUID- lines.
  • agc_driver_recorder_tests --multisample-only under the same validation layer env: passed (CB metadata pass over a multisampled target's memory tests passed, VK_LAYER_KHRONOS_validation inserted 1 time, 0 VUID- lines).
  • Without the fix (origin/main 729981cb5a Draw.cpp built with this branch's test): agc_driver_recorder_tests --multisample-only passes #24993's two MSAA clear and resolve tests, then fails with AGC graphics: a storage image access of 0x13c0c540000+0x10000 overlaps multisampled color target 0x13c0c540000+0x40000 (4 samples), whose samples are only on the host: guest access to it is not implemented.
  • py -3 tools/check_conventions.py --base origin/main: passed. py -3 tools/debt_fold.py --check: this PR's fragment passes; the check reports two libkernel_sys fragments (docs-libkernel-pro-measured-1360.md, fix-kernel-sys-title-workaround-bit-limit.md) that fail the same way on main 729981cb5a and are not touched here.
  • py -3 tools/pr_overlap.py --branch fix/agc-metadata-pass-claims-msaa-memory on 06a886cfe2 (2,339 open PRs): 0 overlaps among mergeable PRs; 59 other PRs that conflict with main could not be compared automatically, and none of their diffs changes RunColorMetadataPass, metadataPassResident or ClaimMultisampleTargetMemory (before the rebase #6808, #6989/#6995/#7002, #13963, #13147, #24572 and #24735 were also read by hand); none implements this change.

Title test: Forza Horizon 5 (PPSA22327 v01.685.672, local stack on main 089d2df72e + #23688 + fix/agc-msaa-fast-clear-eliminate (#24993) + this fix; the stack resolved the shared loop exactly as this rebase does, multisampled targets through #24993's branch and single-sample targets claimed first):

  • Without this change (run 8, traced in runs 9–15 to metadataPassResident): aborted with a storage image access of 0x3eefb00000+0x480000 overlaps multisampled color target 0x3eefb00000+0x7f80000 (4 samples), whose samples are only on the host: guest access to it is not implemented.
  • With this change (run 18, confirmed by diagnostic print that the fast-clear eliminate over the 960x540 RGBA16F single-sample target at 0x3eefb00000+0x480000 claimed the 4x memory): retired the guard cleanly and ran ~70 s to the next unrelated stop. The refusal did not come back in any of the 120 runs with this change since.

Not tested: other GPUs, Linux/macOS host builds, console hardware, or a standalone re-run of the title on 06a886cfe2 (its RunColorMetadataPass loop is identical to the tested stack's).

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: none
  • Unblocks: PPSA22327 #25152
  • GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on main and this change, 0 VUIDs
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5428843637 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24994). Originally posted by [birdmarty](https://github.com/birdmarty) on 2026-11-21T14:24:14Z. --- ### What Claim overlapping multisampled color target memory when a CB metadata pass (`EliminateFastClear` or `DccDecompress`) runs over a single-sample color target, matching what binding that single-sample target as a color attachment already does. Previously, `RunColorMetadataPass` looked up the single-sample target's resident image through `metadataPassResident` (which calls `CachedStorageSurface`) without claiming the target's address range first. If a host-only multisampled color target still guarded those bytes from an earlier use of the same memory, the guard treated `metadataPassResident`'s lookup as a guest storage-image read of live host-only samples and threw `a storage image access of ... overlaps multisampled color target ... (4 samples), whose samples are only on the host: guest access to it is not implemented`. Because the draw path already calls `ClaimMultisampleTargetMemory` when binding a color target over that memory, the CB metadata pass—which writes the same target's bytes—should claim them the same way before touching the target so the multisampled guard retires cleanly. #### Changes - `core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp`: call `ClaimMultisampleTargetMemory(color.MemoryAddress(), color.bytes)` for each single-sample target in the `pass.targets` loop of `RunColorMetadataPass` (after the multisampled-target branch that #24993 added). - `core/libs/prx/libSceAgcDriver/tests/Recorder.cpp`: add `metadataPassOverMultisampleMemoryTests` (run in both `--multisample-only` and the full `agc_driver_recorder` suite), creating a host-only 4x multisampled color target via `FmaskDecompress`, verifying `MultisampleColorTargetOverlaps`, then running an `EliminateFastClear` pass over a single-sample `SW_64KB_R_X` target at the same address and verifying that it succeeds and clears the multisampled guard. - `docs/dev/debt/changes/fix-agc-metadata-pass-claims-msaa-memory.md`: update `Multisampled color targets` to list a CB fast-clear eliminate or DCC decompress over an overlapping single-sample color target as a memory-reuse claim. ### Tested Windows 11 Pro (build 26300), Intel Core i9-9900K, MinGW-w64 GCC 15.3.0, Release build with tests, AMD Radeon RX 6800 (vendor `0x1002`, device `0x73bf`, AMD proprietary driver 26.10.1 / Windows driver 32.0.21045.16010, Vulkan 1.4.315), based on `origin/main` 729981cb5a (rebased after #24993 merged). Focused AGC tests on `main` 729981cb5a and on this branch (06a886cfe2), same machine and GPU, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (Vulkan SDK 1.4.363.0) and `VK_LOADER_DEBUG=layer`. The set has 29 tests in 11 programs (`agc_driver_graphics`, `agc_driver_recorder`, `agc_driver_cmask_fast_clear`, `agc_driver_pipelined_metadata_pass*`, `agc_driver_cached_image_multisample_guard`, `agc_driver_multisample_{retirement,srgb_twin,fill_host_only}`, `agc_driver_multisampled_pass_order`, `agc_driver_msaa_dcc_*`, `agc_driver_color_memo_{msaa,metadata,untracked-cmask}_*`): - `main` (729981cb5a): 28 passed, 1 failed (`agc_driver_recorder`, pre-existing Windows address-reuse failure: `AGC graphics: 64 KiB R_X 512x512, 3 mips, no DCC, an access to the first unit: an earlier case's image is still in the live registry over the reused memory, so this image would store whole`). `Insert instance layer "VK_LAYER_KHRONOS_validation"` logged 31 times, 0 missing-layer errors, 0 `VUID-` lines. - This change (06a886cfe2): the same 28 passed, 1 failed (`agc_driver_recorder`, identical pre-existing failure). `Insert instance layer "VK_LAYER_KHRONOS_validation"` logged 31 times, 0 missing-layer errors, 0 `VUID-` lines. - `agc_driver_recorder_tests --multisample-only` under the same validation layer env: passed (`CB metadata pass over a multisampled target's memory tests passed`, `VK_LAYER_KHRONOS_validation` inserted 1 time, 0 `VUID-` lines). - Without the fix (`origin/main` 729981cb5a `Draw.cpp` built with this branch's test): `agc_driver_recorder_tests --multisample-only` passes #24993's two `MSAA clear and resolve` tests, then fails with `AGC graphics: a storage image access of 0x13c0c540000+0x10000 overlaps multisampled color target 0x13c0c540000+0x40000 (4 samples), whose samples are only on the host: guest access to it is not implemented`. - `py -3 tools/check_conventions.py --base origin/main`: passed. `py -3 tools/debt_fold.py --check`: this PR's fragment passes; the check reports two `libkernel_sys` fragments (`docs-libkernel-pro-measured-1360.md`, `fix-kernel-sys-title-workaround-bit-limit.md`) that fail the same way on `main` 729981cb5a and are not touched here. - `py -3 tools/pr_overlap.py --branch fix/agc-metadata-pass-claims-msaa-memory` on 06a886cfe2 (2,339 open PRs): 0 overlaps among mergeable PRs; 59 other PRs that conflict with `main` could not be compared automatically, and none of their diffs changes `RunColorMetadataPass`, `metadataPassResident` or `ClaimMultisampleTargetMemory` (before the rebase #6808, #6989/#6995/#7002, #13963, #13147, #24572 and #24735 were also read by hand); none implements this change. Title test: Forza Horizon 5 (`PPSA22327` v01.685.672, local stack on `main` 089d2df72e + #23688 + `fix/agc-msaa-fast-clear-eliminate` (#24993) + this fix; the stack resolved the shared loop exactly as this rebase does, multisampled targets through #24993's branch and single-sample targets claimed first): - Without this change (run 8, traced in runs 9–15 to `metadataPassResident`): aborted with `a storage image access of 0x3eefb00000+0x480000 overlaps multisampled color target 0x3eefb00000+0x7f80000 (4 samples), whose samples are only on the host: guest access to it is not implemented`. - With this change (run 18, confirmed by diagnostic print that the fast-clear eliminate over the 960x540 RGBA16F single-sample target at `0x3eefb00000+0x480000` claimed the 4x memory): retired the guard cleanly and ran ~70 s to the next unrelated stop. The refusal did not come back in any of the 120 runs with this change since. Not tested: other GPUs, Linux/macOS host builds, console hardware, or a standalone re-run of the title on 06a886cfe2 (its `RunColorMetadataPass` loop is identical to the tested stack's). ### 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: none - [x] Unblocks: PPSA22327 #25152 - [x] GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on `main` and this change, 0 VUIDs - [x] AI-assisted: yes
MarcZX10 commented 2026-11-22 05:25:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T05:25:14Z.

Review: APPROVED


Reviewed — looks good

Nothing blocks this change; the inspected implementation and test support merging.

What I ran

Reviewed head 06a886cfe233cba7d9112f2261a74574b7b15565. No commands or tests were run in this review. The author reports focused Windows/Vulkan tests, including a passing --multisample-only run; those results were not independently verified.

Results

Check Result Note
Diff and changed lines passed All three changed files inspected
Tests in this review not run Author-reported results only
Targeted implementation context passed Claim helper and call sites inspected

Findings

Blocking

None.

Non-blocking

None.

Not verified

The full Recorder.cpp file was excluded as too large, but all 91 added lines and both changed call sites were read. Tests, builds, hardware behavior, and the author-reported test output were not independently verified. No other changed files were excluded.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6010537706 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24994#pullrequestreview-6010537706). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T05:25:14Z. **Review:** APPROVED --- # Reviewed — looks good Nothing blocks this change; the inspected implementation and test support merging. ## What I ran Reviewed head `06a886cfe233cba7d9112f2261a74574b7b15565`. No commands or tests were run in this review. The author reports focused Windows/Vulkan tests, including a passing `--multisample-only` run; those results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Diff and changed lines | passed | All three changed files inspected | | Tests in this review | not run | Author-reported results only | | Targeted implementation context | passed | Claim helper and call sites inspected | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified The full `Recorder.cpp` file was excluded as too large, but all 91 added lines and both changed call sites were read. Tests, builds, hardware behavior, and the author-reported test output were not independently verified. No other changed files were excluded. ## To get this to a good state Nothing is required.
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!24994
No description provided.