Skip to content

fix(agc): retire an undrawn filled multisampled color target that a guest access overlaps - #9186

Merged
adriadam10 merged 5 commits into
boykopovar:mainfrom
fma-rc:fix/agc-retire-undrawn-filled-msaa
Oct 25, 2026
Merged

adriadam10 merged 5 commits into
boykopovar:mainfrom
fma-rc:fix/agc-retire-undrawn-filled-msaa

Conversation

@fma-rc

@fma-rc fma-rc commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

A multisampled texture that a shader reads before any draw rendered to it becomes a multisampled target filled from its guest memory, and that memory is guarded like a drawn target's: the next guest access to it throws overlaps multisampled color target ... whose samples are only on the host: guest access to it is not implemented. Death Stranding 2 (PPSA02015) stops there on both GPUs, at a compute shader's storage image access over such a texture:

compute shader 0xc280079300: AGC graphics: a storage image access of 0xc2e9b40000+0x870000 overlaps multisampled color target 0xc2e9b40000+0x1fe0000 (4 samples), whose samples are only on the host: guest access to it is not implemented

The samples of such a target are still the memory's bytes, so nothing is lost by dropping it. Each target now carries a flag for whether its samples exist only on the host. A drawn target, a recreated one, one a dispatch's storage view writes and one that absorbs a color fill set it; a target filled for sampling starts without it. A guest access over a target without the flag retires it the way an unmap does and goes on; it is rebuilt from guest memory at its next use. A target with the flag throws as before. The debt entry for multisampled color targets records the rule.

#8223 also retires multisampled targets on guest access, when the CPU wrote over a target's memory since the last draw. That does not cover this case: the shader access comes from the GPU with no CPU write in between, and DS2 stops at the same line with #8223 applied. The two change the same function and conflict; I merged them for the DS2 run below (each target keeps both #8223's write stamp and this flag), and with both, the test's #8223 cases and the new ones pass together on the RTX 5080. Whichever lands second takes the merged version; this PR depends on #8223 and I rebase it onto main once #8223 is in.

Tested

Arch Linux, rebased on main b7a451d.

  • agc_driver_sample_multisample_target has new cases: a 4x texture sampled before any draw is retired by a guest access, and a later load reads the memory's new value; a guest access over a drawn target is still refused; one over an undrawn texture a dispatch wrote, or one that absorbed a fill, is still refused, and the absorbed fill's value is kept. With main's MultisampleTarget.cpp the test fails on the RTX 5080, the Radeon 610M and lavapipe at the first new case (a storage image access ... overlaps multisampled color target ...); with the change it passes on all three.
  • Death Stranding 2, hidden, on main with PR 5426, PR 7978, PR 6565, PR 6182, fix(agc): retire a multisampled color target the title wrote over #8223 and fix(shader): gather a 3D image's image_gather4_lz from one slice as measured #9183 (needed to reach this shader): without this change the RTX 5080 stops at the line above at 132 s and the 680M at 184 s; with it both run on to the next stop, color targets with fewer fragments than samples (EQAA) are unsupported (RTX 5080 at 93 s, frame 117; 680M at 157 s, frame 86, picture visible).
  • With VK_LAYER_KHRONOS_validation enabled, agc_driver_sample_multisample_target passes on the RTX 5080 with no validation messages, on the merge base and with the change.
  • In a Windows 11 VM (WinLibs GCC 15.2, no GPU) the PR builds and passes all 1928 tests.
  • tools/check_conventions.py --base origin/main passes.

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
  • 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: fix(agc): retire a multisampled color target the title wrote over #8223
  • Fixes: none
  • Unblocks: PPSA02015 Death Stranding 2: On the Beach (PPSA02015) #5424
  • GPUs tested: NVIDIA RTX 5080 (driver 615.78.08, Linux), AMD Radeon 610M and 680M (RADV, Mesa 26.1.4 / 26.2.4, Linux), lavapipe
  • AI-assisted: yes

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6498 docs/dev/debt/libSceAgcDriver.md L89
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L788-789
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L788-789, L881-882
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L788-789, L881-882
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L788-789, L881-882
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L788-789, L881-882
docs/dev/debt/libSceAgcDriver.md L89
PR 9533 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L738-748
PR 9742 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L738-748
PR 10233 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L752-754
PR 10906 docs/dev/debt/libSceAgcDriver.md L88-89

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 2434 docs/dev/debt/libSceAgcDriver.md
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5372 docs/dev/debt/libSceAgcDriver.md
PR 5925 docs/dev/debt/libSceAgcDriver.md
PR 6194 docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 docs/dev/debt/libSceAgcDriver.md
PR 6548 docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6743 docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6959 docs/dev/debt/libSceAgcDriver.md
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 7256 docs/dev/debt/libSceAgcDriver.md
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7505 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 7844 docs/dev/debt/libSceAgcDriver.md
PR 7910 docs/dev/debt/libSceAgcDriver.md
PR 8014 docs/dev/debt/libSceAgcDriver.md
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8520 docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 8874 docs/dev/debt/libSceAgcDriver.md
PR 8930 docs/dev/debt/libSceAgcDriver.md
PR 8998 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 9020 docs/dev/debt/libSceAgcDriver.md
PR 9335 docs/dev/debt/libSceAgcDriver.md
PR 9356 docs/dev/debt/libSceAgcDriver.md
PR 9387 docs/dev/debt/libSceAgcDriver.md
PR 9393 docs/dev/debt/libSceAgcDriver.md
PR 9431 docs/dev/debt/libSceAgcDriver.md
PR 9432 docs/dev/debt/libSceAgcDriver.md
PR 9508 docs/dev/debt/libSceAgcDriver.md
PR 9592 docs/dev/debt/libSceAgcDriver.md
PR 9672 docs/dev/debt/libSceAgcDriver.md
PR 9673 docs/dev/debt/libSceAgcDriver.md
PR 9674 docs/dev/debt/libSceAgcDriver.md
PR 9675 docs/dev/debt/libSceAgcDriver.md
PR 9676 docs/dev/debt/libSceAgcDriver.md
PR 9700 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9717 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9748 docs/dev/debt/libSceAgcDriver.md
PR 9842 docs/dev/debt/libSceAgcDriver.md
PR 9891 docs/dev/debt/libSceAgcDriver.md
PR 9892 docs/dev/debt/libSceAgcDriver.md
PR 9893 docs/dev/debt/libSceAgcDriver.md
PR 9895 docs/dev/debt/libSceAgcDriver.md
PR 9898 docs/dev/debt/libSceAgcDriver.md
PR 9904 docs/dev/debt/libSceAgcDriver.md
PR 9905 docs/dev/debt/libSceAgcDriver.md
PR 9906 docs/dev/debt/libSceAgcDriver.md
PR 9950 docs/dev/debt/libSceAgcDriver.md
PR 10026 docs/dev/debt/libSceAgcDriver.md
PR 10049 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10064 docs/dev/debt/libSceAgcDriver.md
PR 10193 docs/dev/debt/libSceAgcDriver.md
PR 10351 docs/dev/debt/libSceAgcDriver.md
PR 10435 docs/dev/debt/libSceAgcDriver.md
PR 10469 docs/dev/debt/libSceAgcDriver.md
PR 10492 core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10497 core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10800 docs/dev/debt/libSceAgcDriver.md

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

The regression target and the change are scoped to the undrawn, guest-backed multisampled texture case, and the PR description contains useful A/B evidence. Its validation-layer report names the same 23 tests on main and the change, required environment variables, selected GPU, and states that neither run had a missing-layer warning or a VUID line. I could not independently reproduce GPU tests here: this environment has no /dev/dri device or Vulkan tools, and the hosted product jobs are skipped. Treat the detailed GPU results as author-reported evidence.

I need the branch coordination and base updated before this is merge-ready:

  • The PR discussion records agreement with #8223's author that #8223 lands first and this PR rebases onto it. The current checklist still says Depends on: none, and the overlap report confirms both PRs change MultisampleTarget.cpp and its retirement path. Please set Depends on: #8223 and rebase this combined change onto the agreed #8223 head after it lands (or coordinate a different order with that author and update both PRs). Keep the CPU-write/claim behavior and this PR's host-only behavior together, as in the combined test report.
  • This head is 1,198 commits behind current upstream main (3 commits ahead); the merge-tree is clean, but CONTRIBUTING requires branches to stay current. Please update it to current main, then refresh the overlap report and rerun conventions plus the focused validation-layer A/B suite on the rebased head.

The current hosted checks show conventions, eligibility, intake, labels and report passing; Linux, Windows and product-test jobs are skipped. My local current-main diff check and convention check pass, and the merge-tree is clean. I am requesting changes for the agreed dependency/base update, not for a failure in the reported GPU test results.

@akkadbakkad89

Copy link
Copy Markdown
Contributor

Validation datapoint on a second title — negative for this case, but it narrows the map.

Assassin's Creed Shadows (PPSA20397), RTX 3070 driver 617.42, Windows 11, VK_LAYER_KHRONOS_validation 1.4.363. Stacked this PR on a local tree carrying the stencil-replay chain (#9317 + #9393/#9904/#9905/#9906), #8615, and a local MSAA stencil-replay relaxation. At +486 s the title reaches its stencil-export draw (0x407325e400, stage 5), replays all 256 references, passes the push-constant and depth-surface checks — and then still stops here:

[gpu] color target 0x41b1940000 stays non-resident: a storage image access of 0x41b1880000+0x1 overlaps multisampled color target 0x41b1800000+0x870000 (4 samples), whose samples are only on the host
[gpu] driver failure: a CPU read of 0x41b1940000+0x200000 overlaps multisampled color target 0x41b1800000+0x870000 (4 samples), whose samples are only on the host: guest access to it is not implemented

The guard's hostOnly flag is set for this target — it was rendered to before the guest access, so retiring is correctly refused (its samples can't be rebuilt from guest memory). Worth noting the sequence: the title first touches the same range as a storage image (0x41b1880000+0x1, the non-resident warning above), then the CPU read throws.

So this title's failure is the other half of the space your flag splits: it needs actual guest access to host-resident samples (the #9892 direction), not undrawn-target retirement. DS2's undrawn-fill case and ACS's drawn-target case are now distinguished — the flag works exactly as designed, ACS just lands on the still-thrown side.

@adriadam10 adriadam10 self-assigned this Oct 23, 2026
@adriadam10
adriadam10 force-pushed the fix/agc-retire-undrawn-filled-msaa branch from c61789c to 820fd96 Compare October 23, 2026 20:35
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 23, 2026
@adriadam10
adriadam10 force-pushed the fix/agc-retire-undrawn-filled-msaa branch from 820fd96 to 1c73656 Compare October 24, 2026 00:29
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 24, 2026
@adriadam10
adriadam10 force-pushed the fix/agc-retire-undrawn-filled-msaa branch from 1c73656 to b966180 Compare October 24, 2026 04:41
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@MarcZX10 both points of your review are addressed on the current head:

  • The body now says Depends on: #8223.
  • The branch is rebased onto current main (Linux build and ctest passed on the rebase, 971/971; MultisampleTargetStorageView from main is combined with this PR's host-only check).

Remaining: this PR rebases onto #8223 once that lands (it is still open and conflicting with main), keeping its CPU-write stamp together with the host-only flag. @MarcZX10, could you re-review so the merge queue stops refusing it on the old request? Nothing else is pending on the author's side.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@fma-rc
fma-rc force-pushed the fix/agc-retire-undrawn-filled-msaa branch from b966180 to b6bfc78 Compare October 24, 2026 21:46
@fma-rc

fma-rc commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main c8d34aa as b6bfc78. The conflict was with #9450's one-fragment FMASK guard in MultisampleTarget.cpp: GuardedRange keeps both fields, and the FMASK range it adds is always host-only, so a guest access to it still throws as on main. agc_driver_sample_multisample_target passes on NVIDIA, RADV and lavapipe, and the Windows build and ctest show no failure that main lacks.

@MarcZX10 the requested changes are in, could you take another look?

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@akkadbakkad89

Copy link
Copy Markdown
Contributor

Context datapoint from a title run (PPSA20397 / Assassin's Creed Shadows, RTX 3070).

We hit the same guard this PR relaxes — CPU read 0x41b1940000+0x200000 overlaps multisampled color target 0x41b1800000+0x870000 (4 samples) — so we tested the retire-on-guest-access semantics in-title. Result: insufficient for this case. The overlapping target here is hostOnly in the guard's terms (it was actually rendered into, not an undrawn fill), and the "guest access" is not a read of its samples at all — the guest does its own resolve dispatch writing a new render target at 0x41b1940000, which lands inside the first target's VA footprint (deliberate VA reuse), then presents that range. On hardware that's just memory.

What unblocked it for us: treating a draw's color-target binding over a guarded MSAA range as a destructive alias and retiring the overlapped target at bind time — same semantics as the existing RetireDepthSurfaces call at that site — while keeping the throw for true guest reads of live host-only samples. Posting in case that's useful when this lands; the guest-access path alone won't cover titles that repurpose MSAA footprints this way.

@adriadam10
adriadam10 dismissed MarcZX10’s stale review October 25, 2026 10:31

Dismissing a stale review: the requested changes were addressed after it (new head) and the merge queue blocks on it. Please request changes again if anything is still open.

@adriadam10
adriadam10 merged commit 0658bc8 into boykopovar:main Oct 25, 2026
10 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked on b6bfc78: the rebase over #9450 only changes GuardOneFragmentFmask, whose range now carries its own always-host-only flag, so a guest access to a one-fragment FMASK still throws as on main. The rest is the previously reviewed logic: drawn, recreated, dispatch-written and fill-absorbing targets keep refusing guest access; only a target filled for sampling is retired. The new test cases pin the memory's new value after reuse and the refusals. Depends on: #8223 is set and the branch is on current main, which covers both points of the earlier request; the combined version is taken by whichever of this and #8223 lands second. Assassin's Creed Shadows (drawn target, reused VA) stays out of scope, as reported above; merged.

savvaniss added a commit to savvaniss/AnyPS5 that referenced this pull request Oct 25, 2026
boykopovar#9186 and the one-fragment FMASK guard changed the guard bookkeeping
that this branch moved into TargetUse. TargetUse now holds boykopovar#9186's
hostOnly next to the write stamp and the claim mark, and every guarded
range points to it, the 8-sample FMASK range included. The one-fragment
FMASK range keeps its fmask flag and gets a TargetUse of its own, but
claims skip it, so it still refuses every guest access as on main.
guard() returns void again; the color footprint is guardedColorBytes(),
which the draw stamp also uses.

A guarded access retires every overlapping range when each can retire:
its samples are not host-only, another target was bound over it since
its last use, or the CPU wrote the accessed bytes since then. Otherwise
it refuses and retires nothing, as boykopovar#9186 does. holdHostOnly also stamps
a use, since a dispatch's storage view or an absorbed fill uses the
target like a draw. CheckOverwrittenTarget and CheckClaimedTargets run
after main's sampling test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oneandonlydean pushed a commit that referenced this pull request Nov 2, 2026
Main's #9186 adds a host-only flag to guard(), whose byte count this
branch moved into guardedColorBytes; the merge keeps both.
oneandonlydean pushed a commit that referenced this pull request Nov 2, 2026
Takes #9533's two merges of main since this branch last took it: #10375's
CheckDepthAttachmentAlias and #9186's host-only flag for guard(). No
conflict here.
oneandonlydean pushed a commit that referenced this pull request Nov 2, 2026
Main's #9186 extends the multisampled color target debt entry right after
the type-0 and type-1 descriptor entry this branch rewrites. The merge
keeps both entries.
SA-SUJON pushed a commit to SA-SUJON/AnyPS5 that referenced this pull request Nov 4, 2026
Takes boykopovar#9533's merge of main, which brings in boykopovar#9186's host-only flag for
guard(). No conflict here.
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.

4 participants