Skip to content

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

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-expanded-after-whole-depth-publication
Nov 24, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-expanded-after-whole-depth-publication

Conversation

@birdmarty

@birdmarty birdmarty commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

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

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

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 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 (with fix(agc): sample a stencil kept in HTILE without metadata after an in-place expand #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

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 writes every HTILE
word expanded and the planes from the host samples, which is the state
an in-place expand leaves. When every plane was committed whole and
unchanged by the guest, the target is now taken as expanded, until the
same clears and fills that end an expand.

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 — 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.

@Doorriiaann

Copy link
Copy Markdown

NVIDIA run on Linux: no regression in the multisample, native depth, HTILE, FMASK and CMASK tests, including agc_driver_native_depth_publication. 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 b3da3af. 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_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 the cases this PR changes may be registered under other test names that weren't selected. 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 b3da3af975, merged onto main dc937dfd42 (12f4957e0c, 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.

Windows AMD run of head b3da3af975, merged onto main 1ec0df1aee (3fac5bb3ff, 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.

  • 31 tests: 30 pass in each of 3 runs.
  • 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 b3da3af, next to the earlier NVIDIA Linux and AMD Windows runs. No regressions. The extended publication case 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 d795f93;
  • main + b3da3af, merged with git merge --no-ff (clean merge, 3 files);
  • a control: this PR's tree with main's DepthSurface.cpp, so the extended 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. That covers 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 0 66
this PR 32 31 pass, 1 skip, every run 0 66
control (main's DepthSurface.cpp + this PR's test) 32 30 pass, 1 skip, 1 fails, every run 0 66
  • 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_publication passes (1.3 s), including the new check that a D32S8 owner published whole with expanded HTILE is sampled without metadata.
  • In the control, that test stops at AGC graphics: native multisample depth sampled metadata or XOR mismatch.

ctest -R '^agc' -j 8 with the layer: 2089 tests on both trees.

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 b3da3af975 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.

  • PublishToGuest (DepthSurface.cpp:3288-3302) marks the target expanded only when two things hold:
    • the target has HTILE;
    • every plane was committed whole: no page was kept from the guest, and each plane read back equal to what was published.
  • For a target with HTILE, publication requires all three ranges (publishable, :3178), so the flag cannot be set with nothing published.
  • The published HTILE words are expanded for both aspects (expandedHtileWord(..., DEPTH | STENCIL), :3234), which is consistent with taking the target as expanded.
  • A later draw that recompresses tiles is not observed. The fragment says so, as the existing entry does for the expand draw.
  • The change adds no comment lines. The fragment fix-agc-expanded-after-whole-depth-publication.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_publication fails in 0.62 s with native multisample depth sampled metadata or XOR mismatch.

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_publication|agc_driver_native_depth_publication_without_htile|agc_driver_native_depth_bare_publication|agc_driver_native_depth_expand_gate|agc_driver_native_multisample_depth|agc_driver_native_depth_clears)$" -V
run publication publication_without_htile bare_publication expand_gate native_multisample_depth clears
main Passed 1.11 s Passed 0.36 s Passed 0.42 s Passed 0.35 s Passed 0.91 s Passed 1.53 s
main + PR tests Failed 0.62 s
head 1 Passed 1.05 s Passed 0.34 s Passed 0.37 s Passed 0.29 s Passed 0.91 s Passed 1.39 s
head 2 Passed 1.16 s Passed 0.37 s Passed 0.37 s Passed 0.30 s Passed 0.95 s Passed 1.43 s
head 3 Passed 1.06 s Passed 0.32 s Passed 0.36 s Passed 0.31 s Passed 0.95 s Passed 1.40 s

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: 16 on main and 16 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 f7d1c14ffc (b3da3af975 merged onto f5b7e1d1ac)

AI-assisted: yes

@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1368 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 9950 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 16880 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 18185 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 19557 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20041 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 20315 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 22062 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 22306 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp
PR 22531 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 22647 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 22778 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 24083 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 24327 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp
PR 25610 core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp

@oneandonlydean
oneandonlydean merged commit e9b74b1 into boykopovar:main Nov 24, 2026
14 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* 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