fix(agc): CB resolve into any tiled color target #1189
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1189"
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 MichonGoddijn231849 on 2026-10-07T17:01:57Z.
What
A multisample resolve writes into a resident 4 KiB or 64 KiB standard target, as well as into a 64 KiB render-target one. GTA V's fidelity mode resolves into a SW_64KB_S target.
Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB, MinGW-w64 GCC 15.2.0.
gta-v/testingbranch (Performance mode, the prologue).main0214069e3(2026-10-13; #419 is merged, so only this PR's two commits remain): the newagc_tiled_resolvectest resolves a CMASK-fast-cleared 4x source into SW_4KB_S, SW_64KB_S and SW_64KB_R_X targets and reads the color back from guest memory. CI runs it in theBuildworkflow'slinuxjob (ctest under lavapipe). It fails without this change ("CB resolve into a target without a resident image is not implemented"), and also with the resolve call removed (16384 texels keep their old value).agc_driver_graphicschecks that each tile mode decodes as a resolve destination. In the fullagc_ctest, the failures are the same as onmain. Not run here: the relinker's Python tests (my local Python does not find their helper modules) andguest_gameupdate.agc_*suite passes on Windows on the rebase (484 tests).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T10:31:04Z.
Review: DISMISSED
Thanks. The change itself (
Draw.cpp:2174,RenderTarget→!= Linearfor the resolve destination) looks reasonable: the resident surface goes throughCachedStorageSurface, which already handles the Standard4KB/Standard64KB modes.Standard4KBorStandard64KBtarget (a decode test like the one attests/Graphics.cpp:1188with those tile modes, plus an execution check that the resolved pixels land in the destination, would do). A test that passes withRenderTargetonly also passes without this commit.main(tests/Graphics.cpp,tests/execution/DepthFastClear*,docs/dev/TechnicalDebt.md). It can't land before them; please rebase once they are merged so that only this commit remains.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-11T12:15:00Z.
@adriadam10 thanks. I'll add a decode test for
Standard4KB/Standard64KBresolve destinations and an execution check that the resolved pixels land in the destination, then rebase once the bases are merged so only this commit remains, and fill in "Tested" with the CI job and the GTA V before/after.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-11T15:28:48Z.
@adriadam10 the tests are in (
1e2fc3951). The branch is now stacked on the rebased #419 (c120d9954) instead of #425/#454/#1186, so the last two commits are this PR.tests/Graphics.cppnow also decodes a SW_4KB_S, SW_64KB_S and SW_64KB_R_X destination, each keeping its tile mode.tiledResolveTestsintests/Recorder.cpp, registered as theagc_tiled_resolvectest, so theBuildworkflow'slinuxjob runs it under lavapipe. It fast-clears a 4x RGBA8 source through its CMASK to a different colour for each tile mode, resolves it into a 128x128 target of that mode whose memory starts as 0x55, and reads all 16384 texels back from guest memory. A linear destination still throws.RenderTargetrestored as the only accepted mode, the SW_4KB_S case throws "CB resolve into a target without a resident image is not implemented".The GTA V fidelity-mode before/after isn't rerun yet; I'll add it to "Tested" when it is. Once #419 merges, I'll rebase this so only these two commits remain.
Imported from boykopovar/AnyPS5. Originally posted by KingDarkHN on 2026-10-12T13:59:41Z.
Fallen Legion (PPSA07645) — CB resolve and multisampled-target guard findings
Repro:
Fallen Legion: Rise to Glory(PPSA07645) on main aborts before the firstframe with:
Root cause
The title issues a mode-3 CB resolve while
CB_AA_CONFIG(register0x2f8)reports a single sample.
DecodeColorMetadataPasstherefore does notrecognize the pass as a resolve, it falls through to
DrawRejection, and thedraw is rejected. Taking the sample count from the resolve source target
matches what this title does.
Local changes that made progress
Not proposed as a competing PR — just findings. Both are three-line/one-liner
style changes against the current code:
Take a CB resolve's sample count from its source target.
Decode a resolve whenever
CB_COLOR_CONTROLmode is3(instead of alsorequiring
CB_AA_CONFIGto report samples), and drop theRequire(source.samples == samples, ...)check, since the sample count nowcomes from the source.
Guard only a multisampled target's sample data, and let reads of a live
storage surface through.
guard()registeredtarget.bytes * samplesbytes.target.bytesalreadyincludes per-sample tile padding, so the guard extended ~2.2 MB past the
actual sample data (e.g.
0x227090000 + 0x21c0000instead of+ 0x1fa4000). This title places the resolve destination atbase + 0x2000000, which is past the sample data but inside that padding, sotexture and storage reads of the resolved backbuffer were rejected as
host-only memory. Guarding only
width * height * elementBytes * samples, and exempting an access whoseaddress has a live storage surface in the cache (the resolve already made
its texels available host-side), gets past this.
Where it stops now
With both changes the title renders many frames and then stops on reads whose
range genuinely overlaps the sample data of a multisampled target:
storage image access,texture read(sampled) whose 16 MB span straddles the target, andSET_CONTEXT_REG_INDIRECTof a buffer whose addressaliases the target (`a CPU read of 0x2270c5060+0x120 overlaps ... 0x227050000
The first two are the guest fetching texels/reading bytes over MSAA memory that
only exists host-side — the MultisampleTarget work in this PR. The CPU/indirect
case looks like transient-allocator aliasing: the register scratch buffer and the
render target share guest addresses, so the bytes are actually CPU-written and
only the guard rejects them.
Full log and test setup available on request.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-12T15:50:27Z.
@KingDarkHN thanks, both findings are in #419's code (merged), not in this PR, so they go into the #419 follow-up I promised there (retiring a multisampled target when its memory is written as something else):
CB_AA_CONFIGat one sample: decoding mode 3 as a resolve and taking the sample count from the source target matches what the hardware has to do, since the resolve reads the source's samples whatever the rasterizer state says. I'll take it with a decode test for that register combination.target.bytes * samplescame from the review (it covers the tile padding of the later sample planes, Amoenus' 65x65 4x case), so going back tow * h * elementBytes * sampleswould miss texels again. The right bound is the planes' real footprint, the fragment-aware size addrlib computes, so a resolve destination right after the sample data isn't covered. That and the retire-on-write rule should also clear the overlapping reads you hit next, where they are memory reuse.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-13T16:25:26Z.
Rebased onto current
main(0214069e3). #419 is merged, so only this PR's two commits remain: the change andagc_tiled_resolve. Theagc_*suite passes on Windows (484 tests).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T06:26:08Z.
Rebased onto main to resolve the test-list conflict in
core/libs/prx/libSceAgcDriver/CMakeLists.txt(kept both entries); no other change. The GTA V before/after from the earlier review is the one thing left.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T18:01:56Z.
GTA V (PPSA04263) before/after, on current
mainplus #448 (without #448 it stops atsample masks are unsupported): with and without this PR, Story Mode loads and reaches the prologue title card, then both stop at(#757). No CB resolve is issued before that point, so GTA can't show this change yet; the frames are identical. Build and
agc_tiled_resolvepass. The branch conflicts withmainagain in theset_tests_propertieslist ofcore/libs/prx/libSceAgcDriver/CMakeLists.txt(agc_metadata_passwas added there).Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T22:15:38Z.
Rebased onto main (test list conflict);
agc_tiled_resolveand theagc_tests pass.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T01:34:08Z.
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.
main)core/libs/prx/libSceAgcDriver/CMakeLists.txtL1125core/libs/prx/libSceAgcDriver/CMakeLists.txtL1125core/libs/prx/libSceAgcDriver/CMakeLists.txtL1125