fix(agc): sample a stencil kept in HTILE without metadata after an in-place expand #25871
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25871"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by birdmarty on 2026-11-22T19:38:33Z.
What
The stencil plane of a native multisampled D32S8 target was sampled through a descriptor without metadata only when its HTILE held depth alone. With the stencil in HTILE, every such read threw
native multisample depth sampled metadata or XOR mismatch. With the stencil in HTILE the plane in memory is compressed until an in-place expand, which is why the read was refused.Depth reads without metadata are already accepted after an observed in-place expand of depth and, with a stencil plane, stencil (
DB_RENDER_CONTROL.DEPTH_COMPRESS_DISABLEandSTENCIL_COMPRESS_DISABLE). The stencil read now follows the same rule, until the HTILE clears and fills, plane fills and clear draws that end it. A target the host has never written is a separate case, covered by #25874: its plane in memory is still what was published or imported.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp: the stencil branch ofCheckResourcealso accepts a target that is expanded.core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp(run byagc_driver_native_depth_expand_gatefor 2, 4 and 8 samples): a target with the stencil in HTILE that the host has written refuses a stencil read without metadata before any expand and after a depth-only expand, accepts it after an expand of depth and stencil, and refuses it again after an HTILE fill.docs/dev/debt/changes/fix-agc-sample-htile-stencil-after-expand.md: the "Native multisample stencil plane sampling" 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,
main66668ebb8b.Focused set (
agc_driver_graphics,agc_shader_memory,agc_driver_sample_multisample_target,agc_driver_recorder,agc_driver_cached_image_multisample_guard,agc_driver_cmask_fast_clear,agc_driver_pipelined_metadata_pass*,agc_driver_native_*,agc_driver_fmask_*,agc_driver_msaa_*,agc_driver_multisample*,agc_driver_sampled_cache*,image_msaa*,agc_driver_depth*,agc_driver_htile*,agc_driver_stencil*) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363) andVK_LOADER_DEBUG=layer:main66668ebb8bVUID-linesWithout the fix (
main'sDepthSurface.cppwith this branch's test),agc_driver_native_depth_expand_gatefails withAGC graphics: native multisample depth sampled metadata or XOR mismatchat the read after the expand of depth and stencil.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:
py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-sample-htile-stencil-after-expand(2,360 open PRs): #16880 renames the call on the same line (Requireto a localrequire), a textual conflict only. Twenty PRs that conflict withmainwere searched by hand; #6808 adds an import refusal for this flag combination, and none changes this read.Not tested: whether the console's reads of the plane through such a descriptor match the host stencil (not measured, as the debt entry says), other GPUs, Linux.
Rebased onto
mainf220c22162(394 commits, none touching the files this PR changes, no conflicts). On the rebased commitcheck_conventionsanddebt_fold --checkpass. All eight PRs merged together onf220c22162, the focused tests of all eight with the same environment:main182 passed / 0 failed, validation layer inserted 242 times, 0VUID-lines; the eight together 188 passed / 0 failed (the six new tests added), inserted 250 times, 0VUID-lines. That combined run first failed this PR's test case: its target had been imported but never drawn, and #25874 reads such a target's stencil plane from memory, by design. The case now writes the target from the host first, which is the case this PR is about. On the amended commit,agc_driver_native_depth_expand_gate,_stencil,_stencil_view,_publicationand_publication_without_htilepass with the validation layer (0VUID-lines), and the test still fails without the fix.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
mainby itself, needs none of the others to build or pass its tests, and merges cleanly with every other one.fix/agc-materialize-cold-native-fmask: cold native FMASK pages read as stored after a first touchfix/agc-multisample-read-single-sample-depth: multisampled read over a single-sample depth surfacefix/agc-claim-retires-memory-backed-msaa-copy: memory-backed multisampled copy treated as a host-only aliasfix/agc-skip-no-op-htile-hiz-patch: HTILE Hi-Z patch dispatch that writes nothingfix/agc-expanded-after-whole-depth-publication: a whole native depth publication taken as an expandfix/agc-htile-clear-supersedes-plane-writes: plane writes before a whole HTILE clearfix/agc-read-unwritten-htile-stencil-from-memory: stencil plane read from memory for an unwritten native targetChecklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)mainand this change, 0 VUIDs🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T19:57:22Z.
Review: APPROVED
Reviewed — looks good
The change is consistent with the existing expand-state tracking and adds a focused regression case; I found no verified blocking defect.
What I ran
Reviewed head
e87f7644a7c8447d0f1cfae726a6f8ff1c63da84. I read the prepared description, commits, manifest, diff, and all three changed files. I did not run tests or builds;repo_read.pywas unavailable as a shell command in this review environment.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently verify the author-reported test results, console behavior, other GPUs, or Linux. The review manifest lists three changed files, all included and read;
files.jsonwas not available as a review document.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-22T21:08:03Z.
Review: APPROVED
Verified exact head
e87f7644a7c8447d0f1cfae726a6f8ff1c63da84against its direct parent production code on the RTX 4070 Laptop.The head passed 3/3. Every run reached the new
Native stencil in HTILE expand gatemarker for 2x, 4x, and 8x, after checking refusal before expansion, continued refusal after depth-only expansion, successful routing after combined depth/stencil expansion, cache identity, and refusal again after the HTILE fill.With only
DepthSurface.cpprestored from direct parentf220c221625695bcd12615476d385a8977532aa3, the byte-identical test executable failed 3/3 with the expectednative multisample depth sampled metadata or XOR mismatchbefore any new stencil marker.All six invocations selected the RTX 4070 Laptop (
10de:2860, NVIDIA 621.01), reported pipeline libraries enabled, and inserted Khronos Validation 1.4.369. There were no skips, missing-layer messages, device losses, VUIDs, or synchronization diagnostics. Runtime artifact hashes were unchanged.This verifies the routing and cache behavior for the exercised D32S8 expand gate. It does not read stencil texel values or establish console expand equivalence.
AI-assisted: yes.