fix(agc): stop treating a memory-backed multisampled copy as a host-only alias #25869
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25869"
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:27Z.
What
When a multisampled texture is read and no target owns its memory,
MultisampleTargetTexturebuilds a host copy from memory (createFilled). That copy is not host-only: memory holds its bytes. Two paths still treated it as if its samples existed only on the host.native multisample stencil plane aliases a multisampled colour target whose samples are only on the host, or its depth twinnative multisample depth or HTILE aliases a multisampled colour target whose samples are only on the host.Claiming the memory now retires such copies, since a later read rebuilds them from memory. The alias lookup used by the depth checks (
MultisampleColorTargetsOver) reports only targets whose samples are host-only. Host-only targets keep the existing claim handling, one-fragment FMASK guards are left alone, and a memory-backed copy over memory that changes is still retired at its next guarded access.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp:ClaimMultisampleTargetMemoryretires the claimed range's color targets that are not host-only;MultisampleColorTargetsOverskips them.core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp(inCheckClaimedTargets, testagc_driver_sample_multisample_target): zeroed memory read as a 2x R8 texture leaves a copy that is guarded but not reported as an alias. A native 2x D32S8 target bound with its stencil plane over that memory drops it, and the stencil plane then reads the zeros in memory.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'sMultisampleTarget.cppwith this branch's test),agc_driver_sample_multisample_targetfails witha memory-backed 2x copy was reported as a colour target whose samples are only on the host.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:
native multisample stencil plane 0x3f002d0000+0x1fe0000 aliases multisampled colour target 0x3f002d0000+0x1fe0000 (vk format 13, 4 samples), newest clear 0x00.native multisample depth 0x3ef8350000+0x7f80000 aliases multisampled colour target 0x3ef8350000+0x7f80000 (vk format 100, 4 samples), newest unknown. A diagnostic showed that copy built by a 4x R32 read (access=sampling written=0) after the depth target's last bind, during its whole-HTILE clear.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-claim-retires-memory-backed-msaa-copy(2,361 open PRs) found no overlap among mergeable PRs. Eleven PRs that conflict withmainwere searched by hand; none changes the claim code orhostOnly.Not tested: the stencil value mismatch itself in a unit test (the test shows the copy reported as an alias, which causes it), 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. 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-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:01:45Z.
Review: COMMENTED
Reviewed — no blocking findings
The change at head
89f7fea6bc570179ad26a3252b5b49e1b2514b3dappears consistent with its stated goal; I did not run tests or other checks, so a formal approval is not justified.What I ran
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-22T20:42:14Z.
Review: CHANGES_REQUESTED
The end-to-end stencil case passes on the RTX, but the checked-in fixture does not independently cover the new
ClaimMultisampleTargetMemoryretirement hunk.On exact head
89f7fea6bc570179ad26a3252b5b49e1b2514b3d,agc_driver_sample_multisample_targetreached the full new 2x-stencil success marker in 3/3 runs. With both production hunks reverted and the head fixture retained, it failed 3/3 at the expected host-only-alias precondition. However, with only the Claim retirement hunk reverted while retaining the alias filter, the unchanged test still reached the full success marker in 3/3 runs.The alternate path is visible in the source: after the claim, the alias-filtered depth/stencil setup reads the guest stencil memory. That guarded read can retire the memory-backed range through
RequireNoMultisampleColorTargetbefore the fixture recordskept;!hostOnlyis already sufficient in that read guard. The finalRequire(!kept)can therefore pass even when the eager Claim retirement hunk is absent.I confirmed this with a separate local probe, using one byte-identical augmented test executable against the frozen head and Claim-reverted PRXs. Immediately after
ClaimMultisampleTargetMemory(plane.Address(), plane.bytes), before any further guest read or depth/stencil bind:direct claim left the memory-backed 2x copy registeredAcross the original three-arm matrix and this direct probe, all 15 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. The augmented executable and fixture were byte-identical between its two arms; only the frozen PRX differed.If eager retirement in
ClaimMultisampleTargetMemoryis intentional, please add direct coverage before any guest read can retire the range, and use a fresh memory-backed copy for the existing end-to-end stencil-bind check. Otherwise, consider dropping that hunk. This keeps the current alias-filter coverage while checking the alias precondition and eager retirement separately.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-22T21:12:10Z.
Review: APPROVED
The requested direct coverage is resolved on exact head
4b26cc6f3e62557fa74232d73a2c0c3dd91bb4cc.I rebuilt the checked-in fixture and ran it against three production configurations on the RTX 4070 Laptop:
a direct claim left the memory-backed 2x copy registered.a memory-backed 2x copy was reported as a colour target whose samples are only on the host; the earlier direct-claim check passed before this later assertion.All arms used the byte-identical new test executable and fixture with distinct, hash-verified PRXs. All seven 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. Runtime hashes remained stable.This now checks the alias precondition and eager Claim retirement independently.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T21:23:20Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
4b26cc6f3e62557fa74232d73a2c0c3dd91bb4ccusingrepo_read.pyto inspect the prepared diff and the changed code with relevant callers. No tests were run in this review.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Tests, console behavior, other GPUs, and Linux were not verified in this review. The author reports focused test results and describes additional untested scenarios in
description.md.Files read:
description.md,commits.md,manifest.json,diff.patch, and all 15 added lines inMultisampleTarget.cppand 44 added lines inSampleMultisampleTarget.cpp; targeted surrounding code and callers inMultisampleTarget.cpp,DepthSurface.cpp,Draw.cpp, andSampleMultisampleTarget.cppwere also read. No changed files were excluded.To get this to a good state
Nothing is required.