fix(agc): read a single-sample depth surface's memory through a multisampled descriptor #25868
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25868"
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:24Z.
What
A multisampled texture or storage descriptor over the memory of a resident single-sample depth surface threw
multisample reader overlaps a single-sample depth attachment. Only a native multisampled depth surface could serve a multisampled reader. The GPU reads the bytes in memory, so the reader now takes the guest-memory path, the same path it takes when no depth surface is there.That path built its copy from memory without storing depth planes that are newer on the host first. Texture imports already store them (
Texture.cpp).MultisampleTargetTexture,MultisampleTargetFirstSampleandMultisampleTargetStorageViewnow store them before they read memory or reuse a cached copy, so a read after the depth surface is drawn again sees the new depth.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:DepthSurfaceTexturereturns no texture for a multisampled reader over a single-sample depth surface instead of throwing.core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp: the multisampled sampling, first-sample and storage paths store stale depth planes under the descriptor first.core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp,tests/cmake/agc_driver_sample_multisample_target_tests.cmake:agc_driver_multisample_read_single_sample_depth. A single-sample 128x128 D32 surface is drawn at depth 0.25 and read through a 4-sample 16x16 R32 descriptor over the same 64 KiB: every sample reads 0.25. It is drawn again at 0.75 and read again: every sample reads 0.75.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_native_fmask_*,agc_driver_fmask_*,agc_driver_msaa_*,agc_driver_multisample*,agc_driver_native_multisample*,agc_driver_native_color*,agc_driver_native_msaa*,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:main66668ebb8bagc_driver_multisample_read_single_sample_depth)VUID-linesWithout the fix (
main'sDepthSurface.cppandMultisampleTarget.cppwith this branch's test), the new test fails withAGC graphics: multisample reader overlaps a single-sample depth attachment. With only theDepthSurface.cpppart, it reads the stale memory:...did not read the depth it published after the first draw: 0.000000.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs without this change:
py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-multisample-read-single-sample-depth(2,364 open PRs): #16880 changes the line next to this one inDepthSurfaceTexture, for the opposite case (a single-sample reader over native multisampled depth). Twenty-three PRs that conflict withmainwere searched by hand; none changes this path.Not tested: a first-sample read through a 2D image over a single-sample depth surface (it still refuses, now with "reading sample 0 of a multisampled depth surface whose depth plane is not at the descriptor's address is not implemented"), other GPUs, Linux, console behaviour.
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.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. This PR depends on #25869 on drivers whose host imports keep write protection (such as Linux NVIDIA): without #25869,
ClaimMultisampleTargetMemoryleaves the memory-backed multisampled copy registered when the single-sample depth surface is bound again, and the GPU-direct flush path does not trigger the CPU read guard that happened to retire it on Windows. The two PRs merge cleanly with no conflicts.fix/agc-materialize-cold-native-fmask: cold native FMASK pages read as stored after a first touchfix/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-sample-htile-stencil-after-expand: stencil kept in HTILE read without metadata after an expandfix/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-22T20:02:24Z.
Review: COMMENTED
Reviewed — comments
The changed paths and test are present in the prepared bundle, but I could not run the pinned repository reader or verify the flush helper’s behavior and callers, so a formal decision is not justified.
What I ran
repo_read.py; the available environment did not provide the instructed shell command interface. No tests were run.Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
Repository context at the pinned head was not independently read through
repo_read.py; in particular, callers and synchronization behavior ofFlushDepthPlanesandDepthPlanesStalewere not verified. Tests, build, and author-reported results were not independently verified. No files were excluded according to the manifest; all four changed files were read from the prepared bundle.To get this to a good state
Nothing is required. Optional: rerun the review with repository-reader access to verify the flush helper and its callers.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-22T20:54:44Z.
Review: APPROVED
Verified exact head
4e1d3c9480b6c928829e9eb253b080a802d39697with a three-arm RTX matrix.0.25f, the second after drawing again is0.75f, and the 2D and array paths agree.f220c221625695bcd12615476d385a8977532aa3: 0/3, with the expectedmultisample reader overlaps a single-sample depth attachmentrefusal.DepthSurface.cppwith onlyMultisampleTarget.cpprestored from the parent: 0/3 at the first value check, observing0.000000instead of the published depth.All three arms used the byte-identical head test executable and fixture. All nine invocations selected the RTX 4070 Laptop (
10de:2860, NVIDIA 621.01), reported pipeline libraries enabled and write watch retained, and inserted Khronos Validation 1.4.369. There were no skips, missing-layer messages, device losses, VUIDs, or synchronization diagnostics.This independently exercises the normal
LoadSamples/MultisampleTargetTexturepath. I did not separately exercise the addedMultisampleTargetFirstSampleorMultisampleTargetStorageViewcall sites.AI-assisted: yes.