Skip to content

fix(agc): leave a multisampled DCC target's CMASK unchecked without fast clears - #8283

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/msaa-dcc-cmask-fmask-only
Oct 23, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
milescoviello:fix/msaa-dcc-cmask-fmask-only

Conversation

@milescoviello

@milescoviello milescoviello commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What

The initial import of a native multisampled DCC target (MultisampledDccClear) requires its CMASK to be uniformly 0xcc or the fully expanded code for its sample count, and throws multisampled DCC CMASK compression or register clear is not implemented otherwise. That check now applies only when CB_COLOR_INFO enables FAST_CLEAR (ColorTarget::cmaskFastClear).

A multisampled target's CMASK is decoded when FAST_CLEAR (bit 13) or COMPRESSION (bit 14) is set. With COMPRESSION and without FAST_CLEAR, the CMASK holds only the FMASK compression state, which picks the fragment each sample reads; its color fast-clear codes are not in use. A uniform DCC clear key sets every fragment of the target to the clear color, so whatever fragment the FMASK picks, the sample reads that color, and the target imports as the DCC clear. Under FAST_CLEAR the CMASK can still be a register clear (code 0, the color in CB_COLOR_CLEAR_WORD), so that case keeps the existing check. For comparison, RADV's DCC fast clear of a multisampled image writes CMASK 0xc (radv_get_cmask_fast_clear_value), and the PS5 SDK's path in this title doesn't write the CMASK at all.

A new debt entry records the case: what the console reads where such an FMASK names no fragment, which stale CMASK bytes can select, is unverified.

Why

METAL GEAR SOLID 4 (PPSA18194): the Master Collection launcher (a Unity app) stops when its Master Book opens. Opening Master Book and confirming the spoiler prompt ends the run with the refusal above (EXIT-134). That happened on main 15da289 (1 run) and on diagnostic builds of main 7d876ad (4 runs, 44 s in each). The diagnostic build logged the target:

  • 1920x1080, 2 samples, R8G8B8A8_UNORM, CB_COLOR_INFO 0x1000c028: DCC_ENABLE and COMPRESSION, no FAST_CLEAR.
  • DCC 81,920 bytes, all 0x00 (the 0000 clear). CB_COLOR_CLEAR_WORD 0.
  • CMASK 24,576 bytes with 224 distinct byte values. Inside the extent, 20,866 of 32,400 tile nibbles are 0 and the rest spread over all 16 codes.
  • No buffer fill or DMA fill wrote that CMASK or DCC beforehand, and no recorded GPU write over either range was pending at the import. So the CMASK is stale memory, not a fill that hasn't landed.

With this PR the book opens and shows its cover at 60 FPS, and the run continues until I stop it (2 of 2 runs).

Tested

Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti, driver 595.99.02.

  • agc_driver_msaa_dcc_state gains a case for 2, 4 and 8 samples. It builds a 64x64 target with a uniform 0x00 DCC and a CMASK of varied bytes. Without cmaskFastClear it must import as 0000, and with cmaskFastClear it must still refuse. With main's check it fails 3 of 3 with the refusal above. With this PR it passes 3 of 3.

  • Khronos validation layer (LunarG SDK 1.4.363), NVIDIA RTX 4070 Ti (595.99.02), Ubuntu 24.04: VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -R '^agc_driver_(msaa|multisample|graphics$|alpha_to_coverage|dcc|sample_multisample|pixel_sample|cmask)' -V on main 661f8b7 and on this PR (ee6efa9). 23 of 23 pass on each, among them agc_driver_msaa_dcc_clear_2, _4 and _8. Neither log reports the layer missing. Both have the same two VUIDs, VUID-vkCmdDraw-multisampledRenderToSingleSampled-07285 ×2, and none is new.

  • tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py lists no conflicting lines. The new debt entry sits beside the multisampled CMASK entries rather than below line 61, which fix(agc): import multisampled DCC register clears #8123 edits.

  • Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, by @TheSovietWaffle on ee6efa9fc: agc_driver_msaa_dcc_state and agc_driver_graphics pass 3 of 3 on an NVIDIA RTX 3080 (617.42) and on an AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002).

Not tested: the console itself.

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: none
  • Fixes: none
  • Unblocks: PPSA18194 METAL GEAR SOLID 4: Guns of the Patriots - Master Collection Version (PPSA18194) #5518
  • GPUs tested: NVIDIA GeForce RTX 4070 Ti, driver 595.99.02, Ubuntu 24.04; NVIDIA RTX 3080 (617.42) and AMD Radeon RDNA 2 iGPU (32.0.21045.5002), Windows 10 (@TheSovietWaffle)
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

…ast clears

The initial import of a multisampled DCC target required its CMASK to be
uniformly 0xcc or the fully expanded code. When CB_COLOR_INFO enables
COMPRESSION but not FAST_CLEAR, the CMASK only holds FMASK compression,
which picks the fragment each sample reads, and a uniform DCC clear sets
every fragment to the clear color. The CMASK is then not checked, and the
target imports as the DCC clear.

METAL GEAR SOLID 4's launcher (PPSA18194) opens its Master Book on a
2-sample 1920x1080 target whose DCC reads as the 0000 clear and whose
CMASK holds stale bytes, with FAST_CLEAR off. It stopped there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 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 9077 docs/dev/debt/libSceAgcDriver.md L166

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 1395 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 2434 docs/dev/debt/libSceAgcDriver.md
PR 4040 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 4448 docs/dev/debt/libSceAgcDriver.md
PR 4449 docs/dev/debt/libSceAgcDriver.md
PR 5058 docs/dev/debt/libSceAgcDriver.md
PR 5441 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 5925 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6186 docs/dev/debt/libSceAgcDriver.md
PR 6194 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6223 docs/dev/debt/libSceAgcDriver.md
PR 6235 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6273 docs/dev/debt/libSceAgcDriver.md
PR 6280 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6300 docs/dev/debt/libSceAgcDriver.md
PR 6412 docs/dev/debt/libSceAgcDriver.md
PR 6481 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6498 docs/dev/debt/libSceAgcDriver.md
PR 6548 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6549 docs/dev/debt/libSceAgcDriver.md
PR 6628 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 6804 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6867 docs/dev/debt/libSceAgcDriver.md
PR 6868 docs/dev/debt/libSceAgcDriver.md
PR 6959 docs/dev/debt/libSceAgcDriver.md
PR 6970 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6977 docs/dev/debt/libSceAgcDriver.md
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7256 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7307 docs/dev/debt/libSceAgcDriver.md
PR 7410 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 7449 docs/dev/debt/libSceAgcDriver.md
PR 7604 docs/dev/debt/libSceAgcDriver.md
PR 7618 docs/dev/debt/libSceAgcDriver.md
PR 7642 docs/dev/debt/libSceAgcDriver.md
PR 7844 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7893 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 7910 docs/dev/debt/libSceAgcDriver.md
PR 7978 docs/dev/debt/libSceAgcDriver.md
PR 8014 docs/dev/debt/libSceAgcDriver.md
PR 8223 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8246 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8319 docs/dev/debt/libSceAgcDriver.md
PR 8564 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 8592 docs/dev/debt/libSceAgcDriver.md
PR 8658 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8740 docs/dev/debt/libSceAgcDriver.md
PR 8874 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 8998 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 9017 docs/dev/debt/libSceAgcDriver.md
PR 9020 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9068 docs/dev/debt/libSceAgcDriver.md
PR 9186 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9317 docs/dev/debt/libSceAgcDriver.md
PR 9335 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9356 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
PR 9387 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
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 9489 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
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 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9676 docs/dev/debt/libSceAgcDriver.md
PR 9700 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 9748 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
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 9897 core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
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 10049 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
docs/dev/debt/libSceAgcDriver.md
PR 10064 docs/dev/debt/libSceAgcDriver.md
PR 10179 docs/dev/debt/libSceAgcDriver.md
PR 10193 docs/dev/debt/libSceAgcDriver.md

@github-actions github-actions Bot added docs agc libSceAgc* labels Oct 20, 2026
@TheSovietWaffle

Copy link
Copy Markdown
Contributor

Windows data point: RTX 3080 (NVIDIA 617.42) and AMD Radeon RDNA 2 iGPU (1002:164e, 32.0.21045.5002), Windows 10 Pro 22H2, WinLibs GCC 15.2.0, Release, head ee6efa9fc: agc_driver_msaa_dcc_state and agc_driver_graphics pass 3 of 3 on both GPUs.

AI-assisted: yes (Claude Code).

@milescoviello

Copy link
Copy Markdown
Contributor Author

Thanks @TheSovietWaffle. That is the first AMD run of this change, and the first on Windows. I added both GPUs to the Tested section of the description.

AI-assisted: yes (Claude Code)

@adriadam10 adriadam10 self-assigned this Oct 23, 2026
@adriadam10
adriadam10 merged commit 4883171 into boykopovar:main Oct 23, 2026
13 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked that the CMASK uniformity check now applies only under FAST_CLEAR, that the new test (2/4/8 samples, varied CMASK) fails on main and still refuses with cmaskFastClear, the debt entry placement, and no conflict with #8123; Windows runs by @TheSovietWaffle on RTX 3080 and RDNA 2 noted; merged.

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.

3 participants