fix(agc): apply the pending CMASK clear in a fast-clear eliminate of a multisampled target #24993
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24993"
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-21T14:24:11Z.
What
Apply a pending CMASK fast clear to the host image when a CB fast-clear eliminate (
CB_COLOR_CONTROLmode 2) targets a multisampled color target, instead of refusing the pass.Previously,
DecodeColorMetadataPassaccepted only a CB resolve (mode 3) or an FMASK decompress (mode 5) over a multisampled color target and threwCB metadata pass over a multisampled color target, whose texels are on the host, is unsupportedfor mode 2. On the console, a fast-clear eliminate writes the fast-clear colour into tiles whose CMASK marks them as fast-cleared; in AnyPS5, an FMASK decompress already handles this for multisampled targets by callingMaterializeMultisampleTargetClear. A fast-clear eliminate now takes the same path when the target has a CMASK address. A fast-clear eliminate without a CMASK address and a CB DCC decompress (mode 6) over a multisampled target still throw.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp: allowColorMetadataPass::Mode::EliminateFastClearover multisampled targets whentarget.cmaskAddress != 0; throw"fast-clear eliminate of a multisampled target without a CMASK address"when absent, and keep refusingDccDecompressover multisampled targets.core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: inRunColorMetadataPass, route multisampled targets (color.samples != 1u) toMaterializeMultisampleTargetClear(context, color)andcontinue, matchingFmaskDecompress.core/libs/prx/libSceAgcDriver/tests/Graphics.cpp: update the no-CMASK eliminate rejection test, add a decode test for a 4x multisampledSW_64KB_R_Xtarget with CMASK and DCC (CB_COLOR_CONTROL=0x00cc0020), and check that DCC decompress (0x00cc0060) over the same target still throws.core/libs/prx/libSceAgcDriver/tests/Recorder.cpp: generalizefmaskDecompressMsaaTestsintomsaaClearPassTestsand run it for bothFmaskDecompressandEliminateFastClear, verifying that a seeded CMASK fast clear materializes to the host 4x image, resolves to the clear colour, and does not re-clear on a second eliminate.docs/dev/debt/changes/fix-agc-msaa-fast-clear-eliminate.md: updateMultisampled targets in CB passesto document fast-clear eliminate alongside FMASK decompress, including that guest CMASK is left untouched (console rewrite to expanded is not modeled) and DCC decompress still throws.Note: this PR and #24994 both edit the same loop in
RunColorMetadataPass(Draw.cpp). Whichever merges second will need a rebase soClaimMultisampleTargetMemoryruns only for single-sample targets (after theif (color.samples != 1u)branch).Tested
Windows 11 Pro (build 26300), Intel Core i9-9900K, MinGW-w64 GCC 15.3.0, Release build with tests, AMD Radeon RX 6800 (vendor
0x1002, device0x73bf, AMD proprietary driver 26.10.1 / Windows driver 32.0.21045.16010, Vulkan 1.4.315), based onorigin/maine60b2f74ad.Focused AGC tests on
maine60b2f74adand on this branch (e2a5008fd0), same machine and GPU, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0) andVK_LOADER_DEBUG=layer. The set has 29 tests in 11 programs (agc_driver_graphics,agc_driver_recorder,agc_driver_cmask_fast_clear,agc_driver_pipelined_metadata_pass*,agc_driver_cached_image_multisample_guard,agc_driver_multisample_{retirement,srgb_twin,fill_host_only},agc_driver_multisampled_pass_order,agc_driver_msaa_dcc_*,agc_driver_color_memo_{msaa,metadata,untracked-cmask}_*):main(e60b2f74ad): 28 passed, 1 failed (agc_driver_recorder, pre-existing Windows address-reuse failure:AGC graphics: 64 KiB R_X 512x512, 3 mips, no DCC, an access to the first unit: an earlier case's image is still in the live registry over the reused memory, so this image would store whole).Insert instance layer "VK_LAYER_KHRONOS_validation"logged 31 times, 0 missing-layer errors, 0VUID-lines.e2a5008fd0): the same 28 passed, 1 failed (agc_driver_recorder, identical pre-existing failure).Insert instance layer "VK_LAYER_KHRONOS_validation"logged 31 times, 0 missing-layer errors, 0VUID-lines.agc_driver_recorder_tests --multisample-onlyunder the same validation layer env: passed (fast-clear eliminate MSAA clear and resolve tests passed,VK_LAYER_KHRONOS_validationinserted, 0VUID-lines).origin/maine60b2f74adState.cppandDraw.cppbuilt with this branch's tests):agc_driver_graphics_testsfails withAGC graphics: unexpected failure: AGC graphics: CB metadata pass over a multisampled color target, whose texels are on the host, is unsupported (only a CB resolve is modeled), andagc_driver_recorder_tests --multisample-onlyfails withAGC graphics: fast-clear eliminate did not materialize the seeded clear to the host multisampled image.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --check: both passed.py -3 tools/pr_overlap.py --branch fix/agc-msaa-fast-clear-eliminate(2,185 open PRs): 0 overlaps among mergeable PRs; 64 PRs that conflict withmaincould not be compared automatically and were checked manually (along with #6808, #6989/#6995/#7002, #13963, #13147, #23252, #24049, #24572, #24735); none implements this change (#13963 is a complementary text neighbour inDraw.cpp).Title test: Forza Horizon 5 (
PPSA22327v01.685.672, single run each on this machine):main291739adca+ #23688, runs 6–7): aborted on a fast-clear eliminate (CB_COLOR_CONTROL=0x00cc0020,CB_COLOR_INFO=0x18046718) over a 4x MSAA 3840x2160B10G11R11target with CMASK fast clear on, DCC and FMASK set.main089d2df72e+ #23688 + this fix'sState.cpp/Draw.cppchange, run 8): passed that eliminate cleanly and progressed to the next unrelated stop.Not tested: other GPUs, Linux/macOS host builds, console hardware measurement of guest CMASK after an eliminate, or a standalone re-run of the title on
e2a5008fd0(theState.cppandDraw.cppdiff is unchanged from the tested commit).Checklist
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