fix(agc): take a whole native depth publication as an in-place expand #25872

Merged
birdmarty merged 1 commit from upstream-pr/25872 into main 2026-11-24 16:42:34 +00:00
birdmarty commented 2026-11-22 19:38:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-22T19:38:37Z.


What

A native multisampled depth target with HTILE accepted a descriptor without metadata only after an observed in-place expand draw. Any other such read threw native multisample depth sampled metadata or XOR mismatch. Publishing the target to guest memory (PublishToGuest) writes every HTILE word expanded (expandedHtileWord: ZMask 15, and SMem 3 with the stencil in HTILE) and the planes from the host samples, which is the state an in-place expand leaves.

When every plane was committed whole (no page kept from the guest, and each read back equal to what was published), the target is now taken as expanded, until the same HTILE clears and fills, plane fills and clear draws that end an expand.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp: PublishToGuest marks the target expanded after such a publication.
  • core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp (the reuse case of agc_driver_native_depth_publication): after a whole publication of a D32S8 owner with HTILE, a descriptor without metadata is sampled.
  • docs/dev/debt/changes/fix-agc-expanded-after-whole-depth-publication.md: a new entry, "Native multisampled depth publication as an in-place expand".

Tested

Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, main 66668ebb8b.

Focused set (as in #25871) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363) and VK_LOADER_DEBUG=layer:

main 66668ebb8b this change
Passed / failed 149 / 0 149 / 0
Validation layer inserted 189 189
VUID- lines 0 0

Without the fix (main's DepthSurface.cpp with this branch's test), agc_driver_native_depth_publication fails with AGC graphics: native multisample depth sampled metadata or XOR mismatch. --publication-without-htile and --bare-depth-publication pass with the fix.

Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:

  • What the game does: right before it reads the native 4x depth plane through a descriptor without metadata, AnyPS5 publishes the target. Every HTILE word is then 0xfffff3ff, but no expand draw was seen on the 4x target; the game's expand draws were on a single-sample surface at the same address.
  • Without this change: the refusal stopped 4 runs.
  • With this change and #25871: 18 runs, none with it; the same message came back in 5 of them for the stencil plane right after an HTILE fast clear, fixed by #25874.

py -3 tools/check_conventions.py --base origin/main and py -3 tools/debt_fold.py --check pass. py -3 tools/pr_overlap.py --branch fix/agc-expanded-after-whole-depth-publication (2,360 open PRs) found no overlap among mergeable PRs. Twenty-one PRs that conflict with main were searched by hand; #9950 changes which aspects expandedHtileWord expands for a stencil owner, and none marks the target expanded.

Not tested: a later draw that recompresses tiles is not observed (as for the expand draw), other GPUs, Linux, console behaviour.

Rebased onto main f220c22162 (394 commits, none touching the files this PR changes, no conflicts). On the rebased commit check_conventions and debt_fold --check pass. All eight PRs merged together on f220c22162, the focused tests of all eight with the same environment: main 182 passed / 0 failed, validation layer inserted 242 times, 0 VUID- lines; the eight together 188 passed / 0 failed (the six new tests added), inserted 250 times, 0 VUID- lines.

Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. The game hits these stops one after another, so these PRs were found and tested together on one stack: the other open PRs the game needs (#24960, #24994, #25151, #23688, #23545, #21479, #11825, #23778, #21155, #22306, #21199) plus the PRs below. Each one stands alone: it applies to main by itself, needs none of the others to build or pass its tests, and merges cleanly with every other one.

  • #25867 fix/agc-materialize-cold-native-fmask: cold native FMASK pages read as stored after a first touch
  • #25868 fix/agc-multisample-read-single-sample-depth: multisampled read over a single-sample depth surface
  • #25869 fix/agc-claim-retires-memory-backed-msaa-copy: memory-backed multisampled copy treated as a host-only alias
  • #25870 fix/agc-skip-no-op-htile-hiz-patch: HTILE Hi-Z patch dispatch that writes nothing
  • #25871 fix/agc-sample-htile-stencil-after-expand: stencil kept in HTILE read without metadata after an expand
  • #25873 fix/agc-htile-clear-supersedes-plane-writes: plane writes before a whole HTILE clear
  • #25874 fix/agc-read-unwritten-htile-stencil-from-memory: stencil plane read from memory for an unwritten native target

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 (with #25871)
  • 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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5442604570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25872). Originally posted by [birdmarty](https://github.com/birdmarty) on 2026-11-22T19:38:37Z. --- ### What A native multisampled depth target with HTILE accepted a descriptor without metadata only after an observed in-place expand draw. Any other such read threw `native multisample depth sampled metadata or XOR mismatch`. Publishing the target to guest memory (`PublishToGuest`) writes every HTILE word expanded (`expandedHtileWord`: ZMask 15, and SMem 3 with the stencil in HTILE) and the planes from the host samples, which is the state an in-place expand leaves. When every plane was committed whole (no page kept from the guest, and each read back equal to what was published), the target is now taken as expanded, until the same HTILE clears and fills, plane fills and clear draws that end an expand. #### Changes - `core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp`: `PublishToGuest` marks the target expanded after such a publication. - `core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp` (the reuse case of `agc_driver_native_depth_publication`): after a whole publication of a D32S8 owner with HTILE, a descriptor without metadata is sampled. - `docs/dev/debt/changes/fix-agc-expanded-after-whole-depth-publication.md`: a new entry, "Native multisampled depth publication as an in-place expand". ### Tested Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release, `main` 66668ebb8b. Focused set (as in #25871) with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (1.4.363) and `VK_LOADER_DEBUG=layer`: | | `main` 66668ebb8b | this change | |---|---|---| | Passed / failed | 149 / 0 | 149 / 0 | | Validation layer inserted | 189 | 189 | | `VUID-` lines | 0 | 0 | Without the fix (`main`'s `DepthSurface.cpp` with this branch's test), `agc_driver_native_depth_publication` fails with `AGC graphics: native multisample depth sampled metadata or XOR mismatch`. `--publication-without-htile` and `--bare-depth-publication` pass with the fix. Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs: - **What the game does:** right before it reads the native 4x depth plane through a descriptor without metadata, AnyPS5 publishes the target. Every HTILE word is then `0xfffff3ff`, but no expand draw was seen on the 4x target; the game's expand draws were on a single-sample surface at the same address. - **Without this change:** the refusal stopped 4 runs. - **With this change and #25871:** 18 runs, none with it; the same message came back in 5 of them for the stencil plane right after an HTILE fast clear, fixed by #25874. `py -3 tools/check_conventions.py --base origin/main` and `py -3 tools/debt_fold.py --check` pass. `py -3 tools/pr_overlap.py --branch fix/agc-expanded-after-whole-depth-publication` (2,360 open PRs) found no overlap among mergeable PRs. Twenty-one PRs that conflict with `main` were searched by hand; #9950 changes which aspects `expandedHtileWord` expands for a stencil owner, and none marks the target expanded. Not tested: a later draw that recompresses tiles is not observed (as for the expand draw), other GPUs, Linux, console behaviour. Rebased onto `main` f220c22162 (394 commits, none touching the files this PR changes, no conflicts). On the rebased commit `check_conventions` and `debt_fold --check` pass. All eight PRs merged together on f220c22162, the focused tests of all eight with the same environment: `main` 182 passed / 0 failed, validation layer inserted 242 times, 0 `VUID-` lines; the eight together 188 passed / 0 failed (the six new tests added), inserted 250 times, 0 `VUID-` lines. ### Related Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. The game hits these stops one after another, so these PRs were found and tested together on one stack: the other open PRs the game needs (#24960, #24994, #25151, #23688, #23545, #21479, #11825, #23778, #21155, #22306, #21199) plus the PRs below. Each one stands alone: it applies to `main` by itself, needs none of the others to build or pass its tests, and merges cleanly with every other one. - #25867 `fix/agc-materialize-cold-native-fmask`: cold native FMASK pages read as stored after a first touch - #25868 `fix/agc-multisample-read-single-sample-depth`: multisampled read over a single-sample depth surface - #25869 `fix/agc-claim-retires-memory-backed-msaa-copy`: memory-backed multisampled copy treated as a host-only alias - #25870 `fix/agc-skip-no-op-htile-hiz-patch`: HTILE Hi-Z patch dispatch that writes nothing - #25871 `fix/agc-sample-htile-stencil-after-expand`: stencil kept in HTILE read without metadata after an expand - #25873 `fix/agc-htile-clear-supersedes-plane-writes`: plane writes before a whole HTILE clear - #25874 `fix/agc-read-unwritten-htile-stencil-from-memory`: stencil plane read from memory for an unwritten native target ### 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 (with #25871) - [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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-11-22 19:56:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:56:32Z.

Review: APPROVED


Reviewed — looks good

The change was reviewed at head b3da3af97599ac0fd10d1f608930937318bb733c; the code supports marking a multisampled depth surface expanded after whole, unchanged publication, and I found no verified blocking defect.

What I ran

Read the prepared diff and the three changed files at the pinned head, plus the relevant DepthSurface.cpp state transitions. No commands or tests were run in this review.

Results

Check Result Note
Changed code review passed All changed files read
Tests not run No tests run in this review

Findings

Blocking

None.

Non-blocking

None.

Not verified

Tests and runtime behavior were not independently verified. The PR description reports test results and notes that later recompression, other GPUs, Linux, and console behavior were not tested.

Files read: DepthSurface.cpp, NativeMultisampleDepth.cpp, and fix-agc-expanded-after-whole-depth-publication.md. Files excluded: none; all three changed files were included in the review bundle and read. files.json was not present as a review document; the reader’s listing confirmed the changed-file set and inclusion status.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014165707 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25872#pullrequestreview-6014165707). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T19:56:32Z. **Review:** APPROVED --- # Reviewed — looks good The change was reviewed at head `b3da3af97599ac0fd10d1f608930937318bb733c`; the code supports marking a multisampled depth surface expanded after whole, unchanged publication, and I found no verified blocking defect. ## What I ran Read the prepared diff and the three changed files at the pinned head, plus the relevant `DepthSurface.cpp` state transitions. No commands or tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All changed files read | | Tests | not run | No tests run in this review | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Tests and runtime behavior were not independently verified. The PR description reports test results and notes that later recompression, other GPUs, Linux, and console behavior were not tested. Files read: `DepthSurface.cpp`, `NativeMultisampleDepth.cpp`, and `fix-agc-expanded-after-whole-depth-publication.md`. Files excluded: none; all three changed files were included in the review bundle and read. `files.json` was not present as a review document; the reader’s listing confirmed the changed-file set and inclusion status. ## 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!25872
No description provided.