Skip to content

fix(agc): apply the pending CMASK clear in a fast-clear eliminate of a multisampled target - #24993

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-msaa-fast-clear-eliminate
Nov 21, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
birdmarty:fix/agc-msaa-fast-clear-eliminate

Conversation

@birdmarty

@birdmarty birdmarty commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Apply a pending CMASK fast clear to the host image when a CB fast-clear eliminate (CB_COLOR_CONTROL mode 2) targets a multisampled color target, instead of refusing the pass.

Previously, DecodeColorMetadataPass accepted only a CB resolve (mode 3) or an FMASK decompress (mode 5) over a multisampled color target and threw CB metadata pass over a multisampled color target, whose texels are on the host, is unsupported for 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 calling MaterializeMultisampleTargetClear. 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: allow ColorMetadataPass::Mode::EliminateFastClear over multisampled targets when target.cmaskAddress != 0; throw "fast-clear eliminate of a multisampled target without a CMASK address" when absent, and keep refusing DccDecompress over multisampled targets.
  • core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp: in RunColorMetadataPass, route multisampled targets (color.samples != 1u) to MaterializeMultisampleTargetClear(context, color) and continue, matching FmaskDecompress.
  • core/libs/prx/libSceAgcDriver/tests/Graphics.cpp: update the no-CMASK eliminate rejection test, add a decode test for a 4x multisampled SW_64KB_R_X target 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: generalize fmaskDecompressMsaaTests into msaaClearPassTests and run it for both FmaskDecompress and EliminateFastClear, 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: update Multisampled targets in CB passes to 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 so ClaimMultisampleTargetMemory runs only for single-sample targets (after the if (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, device 0x73bf, AMD proprietary driver 26.10.1 / Windows driver 32.0.21045.16010, Vulkan 1.4.315), based on origin/main e60b2f7.

Focused AGC tests on main e60b2f7 and on this branch (e2a5008), same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan SDK 1.4.363.0) and VK_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}_*):

Title test: Forza Horizon 5 (PPSA22327 v01.685.672, single run each on this machine):

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 e2a5008 (the State.cpp and Draw.cpp diff is unchanged from the tested commit).

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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: none
  • Fixes: none
  • Unblocks: PPSA22327 Forza Horizon 5 (PPSA22327) #25152
  • GPUs tested: AMD Radeon RX 6800 (vendor=0x1002, device=0x73bf), AMD proprietary driver 26.10.1 (Windows driver 32.0.21045.16010, Vulkan 1.4.315), Windows 11 Pro (build 26300); Khronos validation layer 1.4.363.0 on main and this change, 0 VUIDs
  • AI-assisted: yes

…a multisampled target

A CB fast-clear eliminate (CB_COLOR_CONTROL mode 2) over a multisampled
color target threw, because its texels are on the host and only a CB
resolve and an FMASK decompress were modeled. An eliminate writes the
fast-clear colour into the tiles its CMASK marks as cleared, so it now
applies the pending CMASK fast clear to the host image, as the FMASK
decompress already does. It requires a CMASK address; a DCC decompress
of a multisampled target still throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Doorriiaann

Copy link
Copy Markdown

NVIDIA run of the Tested selection: no regression.

Setup: RTX 3070 8 GB, NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13 (kernel 6.12.115), GCC 13.3.0 Release, validation layer 1.4.335. Base is the merge-base e60b2f7, head is e2a5008. ANYPS5_GPU=NVIDIA ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest -R '^(agc_driver_cached_image_multisample_guard|agc_driver_cmask_fast_clear|agc_driver_color_memo_.*|agc_driver_graphics|agc_driver_msaa_dcc_.*|agc_driver_multisample_.*|agc_driver_multisampled_pass_order|agc_driver_pipelined_metadata_pass|agc_driver_recorder)$' -V, 3 runs each: 79 tests.

base this PR
76 tests (agc_driver_graphics, agc_driver_recorder, agc_driver_cmask_fast_clear, agc_driver_pipelined_metadata_pass, agc_driver_multisampled_pass_order, agc_driver_cached_image_multisample_guard and the agc_driver_multisample_*, agc_driver_msaa_dcc_* and agc_driver_color_memo_* tests) 228/228 pass 228/228 pass
agc_driver_msaa_dcc_compared_import_{2,4,8} 9/9 skip 9/9 skip

The three skips are the device's: skipped, the device reports host imports that keep write protection, so the write-watch probe compares none of them. Every run selects the RTX 3070; every Vulkan test's log shows the layer inserted, none reports it missing, and no log has a VUID- line.

AI-assisted: yes

@github-actions github-actions Bot added docs agc libSceAgc* labels Nov 21, 2026
@rafaconvaitis

Copy link
Copy Markdown
Contributor

Windows data for an NVIDIA GPU and an AMD APU, with and without the Khronos validation layer. With this PR all 11 tests pass on both GPUs in every run. With only this PR's tests, both changed programs fail with the refusals from your description.

Setup

  • Windows 11 25H2 (26200), WinLibs GCC 15.2.0 r7, Release.
  • main ba870cbe18, and the same commit with this PR's diff applied (e2a5008fd0 against its base; it applies cleanly).
  • GPUs: NVIDIA GeForce RTX 3050 (driver 610.88) and AMD Radeon 760M (driver 32.0.32029.2010), selected with ANYPS5_GPU.
  • Environment: ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. Layer runs add VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (1.4.363.1) and VK_LOADER_DEBUG=layer; the loader inserted the layer in every one of them.

Tests: ctest -R "^(agc_driver_graphics|agc_multisample_guest_access|agc_multisample_use_collect|agc_multisample_use_collect_no_memo|agc_driver_recorder|agc_driver_cmask_fast_clear|agc_driver_pipelined_metadata_pass.*|agc_driver_multisampled_pass_order|agc_driver_cached_image_multisample_guard)$" -V, 11 tests. agc_multisample_guest_access is the --multisample-only run.

RTX 3050, no layer RTX 3050, layer Radeon 760M, no layer Radeon 760M, layer
main, 1 run 11 of 11 pass same same same
main with only this PR's hunks of tests/Graphics.cpp and tests/Recorder.cpp agc_driver_graphics fails: CB metadata pass over a multisampled color target, whose texels are on the host, is unsupported; agc_multisample_guest_access fails: fast-clear eliminate did not materialize the seeded clear to the host multisampled image same same same
this PR, 3 runs 11 of 11 pass same same same

Not run: a title.

AI-assisted: yes (runs scripted with an AI assistant, on the machine above).

@github-actions github-actions Bot added unblocks title Names a title ID on the Unblocks line review queue Next in the maintainer review queue: checks pass, no open change request, no conflict labels Nov 21, 2026
@oneandonlydean
oneandonlydean merged commit 158471a into boykopovar:main Nov 21, 2026
16 of 18 checks passed
@github-actions github-actions Bot removed the review queue Next in the maintainer review queue: checks pass, no open change request, no conflict label Nov 21, 2026
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