fix(agc): take plane writes before a whole HTILE clear as superseded #25873

Merged
birdmarty merged 1 commit from upstream-pr/25873 into main 2026-11-23 09:43:19 +00:00
birdmarty commented 2026-11-22 19:38:39 +00:00 (Migrated from github.com)

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


What

A native multisampled depth target whose depth plane was written and then cleared by a fill of its whole HTILE refused the next sample. This happens, for example, when its memory served as a single-sample storage image before the clear.

  • With guest writes over native multisample depth are not implemented when the writes had landed.
  • With external GPU writes over native multisample depth are not implemented while they were still queued.

Every tile the clear proves cleared reads the clear value, so those plane bytes no longer matter. But the planes were compared against their import generation.

When the fill is noted, pending storage results and queued GPU writes over the cleared planes (the depth plane, and the stencil plane with the stencil in HTILE) are now landed first, and each plane's write generation is taken. When the clear is settled (every HTILE word must still prove it), those planes need only be unchanged since that generation; they are then re-collected and their publication rebased. A write after the fill still refuses.

Changes

  • core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp: NoteDepthMetadataFill lands the writes and takes the generations; the clear settle checks the cleared planes against them.
  • core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp, tests/cmake/agc_driver_native_multisample_depth_tests.cmake: agc_driver_native_depth_clear_supersedes_plane_writes. For 2, 4 and 8 samples, a queued and a landed write to the depth plane before a whole-HTILE fill are superseded, and a write after it still refuses.
  • docs/dev/debt/changes/fix-agc-htile-clear-supersedes-plane-writes.md: a new entry.

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, plus agc_driver_dispatch* and agc_driver_*fill*) 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, run on 7e7cf34a6e (this commit before its test entry was moved to another line):

main 66668ebb8b this change
Passed / failed 182 / 0 183 / 0 (adds agc_driver_native_depth_clear_supersedes_plane_writes)
Validation layer inserted 242 244
VUID- lines 0 0

On this commit, --clear-supersedes-plane-writes, --expand-gate and --publication passed again with the validation layer and 0 VUIDs. Without the fix (main's DepthSurface.cpp with this branch's test), the new test fails on its first case with AGC graphics: external GPU writes over native multisample depth are not implemented.

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

  • What the game does: it uses its native 4x depth plane's memory as a single-sample storage image, then clears the target with a whole-HTILE fill.
  • Without this change: the two refusals stopped many runs, depending on whether the storage writes had landed.
  • With this change and the other fixes for that game: 13 runs, none with either refusal.

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-htile-clear-supersedes-plane-writes (2,362 open PRs) found only a test-file position shared with #20186; the entry was moved and the branch now merges cleanly with it. Twenty-one PRs that conflict with main were searched by hand; #1368 and #7256 call NoteDepthMetadataFill from tests and #6808 reworks the plane checks, but none takes plane writes as superseded.

Not tested: that the console's cleared tiles ignore the plane bytes (it follows the HTILE ZMask and SMem meanings; not measured), other GPUs, Linux.

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
  • #25872 fix/agc-expanded-after-whole-depth-publication: a whole native depth publication taken as an expand
  • #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
  • 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:5442604952 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25873). Originally posted by [birdmarty](https://github.com/birdmarty) on 2026-11-22T19:38:39Z. --- ### What A native multisampled depth target whose depth plane was written and then cleared by a fill of its whole HTILE refused the next sample. This happens, for example, when its memory served as a single-sample storage image before the clear. - **With `guest writes over native multisample depth are not implemented`** when the writes had landed. - **With `external GPU writes over native multisample depth are not implemented`** while they were still queued. Every tile the clear proves cleared reads the clear value, so those plane bytes no longer matter. But the planes were compared against their import generation. When the fill is noted, pending storage results and queued GPU writes over the cleared planes (the depth plane, and the stencil plane with the stencil in HTILE) are now landed first, and each plane's write generation is taken. When the clear is settled (every HTILE word must still prove it), those planes need only be unchanged since that generation; they are then re-collected and their publication rebased. A write after the fill still refuses. #### Changes - `core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp`: `NoteDepthMetadataFill` lands the writes and takes the generations; the clear settle checks the cleared planes against them. - `core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp`, `tests/cmake/agc_driver_native_multisample_depth_tests.cmake`: `agc_driver_native_depth_clear_supersedes_plane_writes`. For 2, 4 and 8 samples, a queued and a landed write to the depth plane before a whole-HTILE fill are superseded, and a write after it still refuses. - `docs/dev/debt/changes/fix-agc-htile-clear-supersedes-plane-writes.md`: a new entry. ### 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, plus `agc_driver_dispatch*` and `agc_driver_*fill*`) 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`, run on 7e7cf34a6e (this commit before its test entry was moved to another line): | | `main` 66668ebb8b | this change | |---|---|---| | Passed / failed | 182 / 0 | 183 / 0 (adds `agc_driver_native_depth_clear_supersedes_plane_writes`) | | Validation layer inserted | 242 | 244 | | `VUID-` lines | 0 | 0 | On this commit, `--clear-supersedes-plane-writes`, `--expand-gate` and `--publication` passed again with the validation layer and 0 VUIDs. Without the fix (`main`'s `DepthSurface.cpp` with this branch's test), the new test fails on its first case with `AGC graphics: external GPU writes over native multisample depth are not implemented`. Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs: - **What the game does:** it uses its native 4x depth plane's memory as a single-sample storage image, then clears the target with a whole-HTILE fill. - **Without this change:** the two refusals stopped many runs, depending on whether the storage writes had landed. - **With this change and the other fixes for that game:** 13 runs, none with either refusal. `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-htile-clear-supersedes-plane-writes` (2,362 open PRs) found only a test-file position shared with #20186; the entry was moved and the branch now merges cleanly with it. Twenty-one PRs that conflict with `main` were searched by hand; #1368 and #7256 call `NoteDepthMetadataFill` from tests and #6808 reworks the plane checks, but none takes plane writes as superseded. Not tested: that the console's cleared tiles ignore the plane bytes (it follows the HTILE ZMask and SMem meanings; not measured), other GPUs, Linux. 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 - #25872 `fix/agc-expanded-after-whole-depth-publication`: a whole native depth publication taken as an expand - #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 - [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:55:45 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — comments

The implementation and changed test paths were inspected at head 67dac94a74a7d930788eb54cc3228093c3bd83c3; the console behavior underlying the fix remains unverified.

What I ran

Read the prepared description, commits, manifest, diff, all changed files’ added lines, and targeted source callers through repo_read.py. No commands or tests were run. Author-reported test results were not independently verified.

Results

Check Result Note
Changed code review passed Logic and targeted callers inspected
Tests not run Results in the description are author-reported
Console behavior not run Cleared tiles ignoring plane bytes is unmeasured

Findings

Blocking

None.

Non-blocking

  • The added regression exercises depth-plane writes, but not the HTILE-stencil plane path. Consider adding a case for a queued and landed stencil-plane write before a whole HTILE fill, followed by a write that must still refuse. The stencil path is handled at DepthSurface.cpp:4888 and the new test covers only depth at NativeMultisampleDepth.cpp:3070.

Not verified

  • Whether the console’s cleared HTILE tiles ignore depth and HTILE-stencil plane bytes; the description explicitly says this was not measured.
  • Reported Windows/Vulkan test runs, other GPUs, and Linux were not independently verified.
  • The full text of unchanged repository files and excluded files was not read. All four changed files listed in the manifest were included, and their changed lines were read.

To get this to a good state

Nothing is required. Optional: add regression coverage for the HTILE-stencil plane case.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6014160170 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/25873#pullrequestreview-6014160170). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T19:55:45Z. **Review:** COMMENTED --- # Reviewed — comments The implementation and changed test paths were inspected at head `67dac94a74a7d930788eb54cc3228093c3bd83c3`; the console behavior underlying the fix remains unverified. ## What I ran Read the prepared description, commits, manifest, diff, all changed files’ added lines, and targeted source callers through `repo_read.py`. No commands or tests were run. Author-reported test results were not independently verified. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | Logic and targeted callers inspected | | Tests | not run | Results in the description are author-reported | | Console behavior | not run | Cleared tiles ignoring plane bytes is unmeasured | ## Findings ### Blocking None. ### Non-blocking - The added regression exercises depth-plane writes, but not the HTILE-stencil plane path. Consider adding a case for a queued and landed stencil-plane write before a whole HTILE fill, followed by a write that must still refuse. The stencil path is handled at [DepthSurface.cpp:4888](https://github.com/boykopovar/AnyPS5/blob/67dac94a74a7d930788eb54cc3228093c3bd83c3/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp#L4888) and the new test covers only depth at [NativeMultisampleDepth.cpp:3070](https://github.com/boykopovar/AnyPS5/blob/67dac94a74a7d930788eb54cc3228093c3/core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp#L3070). ## Not verified - Whether the console’s cleared HTILE tiles ignore depth and HTILE-stencil plane bytes; the description explicitly says this was not measured. - Reported Windows/Vulkan test runs, other GPUs, and Linux were not independently verified. - The full text of unchanged repository files and excluded files was not read. All four changed files listed in the manifest were included, and their changed lines were read. ## To get this to a good state Nothing is required. Optional: add regression coverage for the HTILE-stencil plane case.
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!25873
No description provided.