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

Merged
milescoviello merged 1 commit from upstream-pr/8283 into main 2026-10-23 17:16:32 +00:00
milescoviello commented 2026-10-20 08:34:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T08:34:25Z.


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 15da28937e (1 run) and on diagnostic builds of main 7d876ad3ba (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 661f8b7171 and on this PR (ee6efa9fce). 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 #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 #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

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4933175555 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8283). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T08:34:25Z. --- ### 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`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/amd/vulkan/meta/radv_meta_clear.c)), 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` 15da28937e (1 run) and on diagnostic builds of `main` 7d876ad3ba (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` 661f8b7171 and on this PR (ee6efa9fce). 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 #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 <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA18194 #5518 - [x] 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) - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TheSovietWaffle commented 2026-10-20 11:09:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheSovietWaffle on 2026-10-20T11:09:29Z.


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

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289508572 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8283#issuecomment-6289508572). Originally posted by [TheSovietWaffle](https://github.com/TheSovietWaffle) on 2026-10-20T11:09:29Z. --- 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 commented 2026-10-20 11:13:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-20T11:13:06Z.


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)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6289575008 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8283#issuecomment-6289575008). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-20T11:13:06Z. --- 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)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!8283
No description provided.