Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-htile-clear-supersedes-plane-writes
Nov 23, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-htile-clear-supersedes-plane-writes

Conversation

@birdmarty

@birdmarty birdmarty commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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 66668eb.

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 66668eb 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 f220c22 (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 f220c22, 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.

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 Forza Horizon 5 (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

A native multisampled depth target whose depth plane was written (by
storage results or other GPU writes, as when its memory served as a
single-sample storage image) and then cleared by a fill of its whole
HTILE refused the next sample: with "guest writes over native multisample
depth are not implemented" when the writes had landed, or "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 bytes no longer matter.

When the fill is noted, pending storage results and queued GPU writes
over the cleared planes are now landed first and each plane's write
generation is taken; when the clear is settled the planes need only be
unchanged since then. A write after the fill still refuses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Doorriiaann

Copy link
Copy Markdown

NVIDIA run on Linux: the new agc_driver_native_depth_clear_supersedes_plane_writes passes and the multisample, native depth, HTILE, FMASK and CMASK tests do not regress. The three msaa_dcc_compared_import tests skip on both sides here (NVIDIA host imports keep write protection).

Setup: RTX 3070 8 GB, NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13 (kernel 6.12.115), GCC 13.3.0 Release, validation layer 1.4.335. Base is the merge-base f220c22, head is 67dac94. ANYPS5_GPU=NVIDIA ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '(multisample|native_depth|depth_surface|htile|fmask|msaa|cmask|cached_image_multisample_guard|depth_plane_sampling)' -V, 2 runs each.

base this PR
agc_driver_native_depth_clear_supersedes_plane_writes (new) 2/2 pass
agc_driver_msaa_dcc_compared_import_{2,4,8} 6 skipped 6 skipped
the other 90 matching tests 180/180 pass 180/180 pass

Every Vulkan test's log selects the RTX 3070 and shows the layer inserted, none reports it missing, and no log has a VUID- line.

AI-assisted: yes

@JJenkx

JJenkx commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Correction: this run is weaker evidence than it reads. My gate selected only agc_driver_native_multisample_depth, one of the 31 tests that agc_driver_native_multisample_depth_tests registers, so it does not include this PR's new agc_driver_native_depth_clear_supersedes_plane_writes. The pass below shows that test still passes with the change, not that the change itself works on AMD. I'm rerunning all 31 tests of that executable at the current head and will post the result here.


Windows AMD run of head 67dac94a74, merged onto main 6bedd8e28d (8a96db6333, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, AMD Radeon RX 6700 XT, driver 32.0.21045.29003. ANYPS5_REQUIRE_VULKAN=1 (no fallback to a software device), ANYPS5_NO_SHADER_CACHE=1.

  • agc_driver_native_multisample_depth: all 1 pass in each of 3 runs (3 of 3), none skipped.

AI-assisted: yes.

@JJenkx

JJenkx commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Full-executable rerun, replacing my earlier single-test run on this PR. This time every test that agc_driver_native_multisample_depth_tests registers, including this PR's new agc_driver_native_depth_clear_supersedes_plane_writes.

Windows AMD run of head 67dac94a74, merged onto main ac0d9a16f4 (41865d2b37, clean merge).

Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release, AMD Radeon RX 6700 XT, driver 32.0.21045.29003. ANYPS5_REQUIRE_VULKAN=1 (no fallback to a software device), ANYPS5_NO_SHADER_CACHE=1.

  • 32 tests: 31 pass in each of 3 runs, including agc_driver_native_depth_clear_supersedes_plane_writes.
  • agc_driver_native_depth_driver_queued_fill skips in each run, by design on Windows. CheckDriverPath returns VulkanTestSkipped under _WIN32 because host imports aren't write-watched there. This PR doesn't touch it.

AI-assisted: yes.

@4le22io

4le22io commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

A Windows + NVIDIA run of the current head 67dac94, next to the earlier NVIDIA Linux and AMD Windows runs. No regressions. The new test passes, and it fails against main's DepthSurface.cpp.

System: Windows 11 Pro 10.0.26200, NVIDIA GeForce RTX 4060 (10de:2882, Ada), driver 621.01, Intel Core i5-12400F, WinLibs GCC 15.2.0 r7 (UCRT), Release, BUILD_TESTING=ON.

Trees, each a full build:

  • main 0f0a11b;
  • main + 67dac94, merged with git merge --no-ff (clean merge, 4 files);
  • a control: this PR's tree with main's DepthSurface.cpp, so the new test runs against main's driver.

Run: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer (Vulkan SDK 1.4.363.1), ctest -R '^(agc_driver_native_multisample_depth|agc_driver_native_depth_.*)$' -V, so every test that agc_driver_native_multisample_depth_tests registers. 3 runs per tree:

tree tests result VUID Insert instance layer
main 32 31 pass, 1 skip, every run (the new test doesn't exist there) 0 66
this PR 33 32 pass, 1 skip, every run 0 68
control (main's DepthSurface.cpp + this PR's test) 33 31 pass, 1 skip, 1 fails, every run 0 68
  • The skip is agc_driver_native_depth_driver_queued_fill on every tree. It skips by design on Windows.
  • With this PR, agc_driver_native_depth_clear_supersedes_plane_writes passes (0.7 s). It covers 2, 4 and 8 samples, each with a queued and a landed write to the depth plane: a write before a full HTILE clear is superseded by the clear, and a write after it still refuses.
  • In the control, that test stops at AGC graphics: external GPU writes over native multisample depth are not implemented.

ctest -R '^agc' -j 8 with the layer: 2086 tests on main and 2087 with this PR. The same single failure on both: agc_driver_store_over_untracked (#22670, fix in #22764), already tracked on this GPU. The layer was inserted 1895 times on main and 1897 with this PR. There are 0 was not found but was requested lines and 0 VUID- lines.

Not tested: Linux, and a title.

AI-assisted: yes (Claude Code). It merged the PR, ran the three builds and the test sets, and drafted and posted this comment.

@Helldiverr

Copy link
Copy Markdown
Contributor

Head 67dac94a74 merged onto upstream/main f5b7e1d1ac: the six focused tests pass 3/3 on gfx1201 with the Khronos validation layer loaded, and they log no VUID-. I found no code defect.

Code.

  • When a whole-HTILE fill is noted, NoteDepthMetadataFill first lands pending storage results and queued GPU writes over the cleared planes. It then takes their write generations into clearPlaneGeneration (DepthSurface.cpp:4936-4947).
  • At settle, clearedPlane checks those planes against that generation instead of the import generation (:1107), then re-collects them and rebases their publication (:1126-1134).
  • A write after the fill still refuses, and the new test checks this. If a plane's generation is 0, the import generation is used, as before.
  • Stale generation. The HTILE mask-clear path (NoteHtileDepthClear, :4585) does not reset clearPlaneGeneration.
    • If an earlier fill never settled, its generation would be used for that clear. Since it is newer than the import generation, plane writes made before that earlier fill would be accepted.
    • The mask clear also covers the whole HTILE, so I found no wrong result from this, and no test reaches it.
  • The change adds no comment lines. The fragment fix-agc-htile-clear-supersedes-plane-writes.md adds an entry, and debt_fold.py --check and check_conventions.py pass.

Stacking.

Negative control. In one build, I combined the tests of #25867 and #25871-#25874 with main's unchanged DepthSurface.cpp and MultisampleTarget.cpp. agc_driver_native_depth_clear_supersedes_plane_writes fails in 0.26 s on its first case with external GPU writes over native multisample depth are not implemented.

GPU.

ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "^(agc_driver_native_depth_clear_supersedes_plane_writes|agc_driver_native_depth_clears|agc_driver_native_depth_clear_refusals|agc_driver_native_depth_buffer_clear|agc_driver_native_depth_stored_repeat_fill|agc_driver_native_depth_expand_gate)$" -V
run clear_supersedes_plane_writes clears clear_refusals buffer_clear stored_repeat_fill expand_gate
main not on main Passed 1.52 s Passed 0.44 s Passed 0.57 s Passed 0.37 s Passed 0.32 s
main + PR tests Failed 0.26 s
head 1 Passed 0.33 s Passed 1.45 s Passed 0.41 s Passed 0.53 s Passed 0.35 s Passed 0.30 s
head 2 Passed 0.28 s Passed 1.43 s Passed 0.39 s Passed 0.50 s Passed 0.33 s Passed 0.30 s
head 3 Passed 0.31 s Passed 1.44 s Passed 0.46 s Passed 0.50 s Passed 0.34 s Passed 0.33 s

The new test prints its queued and its landed case for 2, 4 and 8 samples. Every log shows the AMD Radeon AI PRO R9700 as the device.

What this adds. The other runs were on an RX 6800 (by the author) and an RX 6700 XT, both RDNA2, and on an RTX 3070 and an RTX 4060, the RTX 4060 run with a negative control. This is the first RDNA4 run, on a newer main that already contains the merged #25868-#25870.

Validation.

  • Insert instance layer "VK_LAYER_KHRONOS_validation" count: 12 on main (five tests) and 14 on each head run.
  • was not found but was requested by env var VK_INSTANCE_LAYERS appears in none of them.
  • VUID- lines: 0 in every log.

Host:

  • GPU: AMD Radeon AI PRO R9700 (gfx1201, 1002:7551), driver 32.0.31044.16, Vulkan 1.4.349
  • Validation layer: Khronos 1.4.363 (LunarG SDK)
  • CPU: Ryzen 9 9950X3D
  • OS: Windows 11 Pro 26300
  • Toolchain: WinLibs GCC 15.2, Release
  • Commits measured: main f5b7e1d1ac; head 44debd4ff5 (67dac94a74 merged onto f5b7e1d1ac)

AI-assisted: yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants