feat(libSceAgcDriver): skip CMASK decode on single-sample views with viewMip > 0 #4965

Merged
pushkarreddyy merged 1 commit from upstream-pr/4965 into main 2026-10-14 01:46:20 +00:00
pushkarreddyy commented 2026-10-13 06:41:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T06:41:33Z.


What

On AMD GFX10/GFX11 hardware, CMASK metadata only covers base mip level 0 (or MSAA samples). When a title sets up a mipmapped color target, CB_COLOR_INFO may retain FAST_CLEAR (bit 13) while binding sub-resources (viewMip > 0), which drivers such as Mesa radeonsi explicitly mask off (if (cb_psurf->level > 0) cb_surf.cb_color_info &= C_028C70_FAST_CLEAR; in si_state.c). In AnyPS5, binding viewMip > 0 with FAST_CLEAR set caused DecodeColorBuffer to fail with Require(color.samples > 1 || (maxMip == 0 && !volume && slice == 0), "CMASK fast clears of a mipmapped, 3D or array color target are unsupported").

This change skips single-sample CMASK fast-clear decoding when viewMip > 0, leaving cmaskAddress = 0 and cmaskFastClear = false instead of rejecting the draw.

Tested

Added unit test in core/libs/prx/libSceAgcDriver/tests/Graphics.cpp verifying that a color buffer with FAST_CLEAR set and viewMip == 1 skips CMASK decoding with cmaskFastClear == false and cmaskAddress == 0, while viewMip == 0 on a mipmapped target continues to reject unsupported fast clear. Verified documentation in docs/dev/debt/libSceAgcDriver.md.

Checklist

  • Depends on: none
  • AI-assisted: yes
  • Unblocks: PPSA15246 #3701
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4839422547 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-13T06:41:33Z. --- ### What On AMD GFX10/GFX11 hardware, CMASK metadata only covers base mip level 0 (or MSAA samples). When a title sets up a mipmapped color target, CB_COLOR_INFO may retain `FAST_CLEAR` (bit 13) while binding sub-resources (`viewMip > 0`), which drivers such as Mesa `radeonsi` explicitly mask off (`if (cb_psurf->level > 0) cb_surf.cb_color_info &= C_028C70_FAST_CLEAR;` in `si_state.c`). In AnyPS5, binding `viewMip > 0` with `FAST_CLEAR` set caused `DecodeColorBuffer` to fail with `Require(color.samples > 1 || (maxMip == 0 && !volume && slice == 0), "CMASK fast clears of a mipmapped, 3D or array color target are unsupported")`. This change skips single-sample CMASK fast-clear decoding when `viewMip > 0`, leaving `cmaskAddress = 0` and `cmaskFastClear = false` instead of rejecting the draw. ### Tested Added unit test in `core/libs/prx/libSceAgcDriver/tests/Graphics.cpp` verifying that a color buffer with `FAST_CLEAR` set and `viewMip == 1` skips CMASK decoding with `cmaskFastClear == false` and `cmaskAddress == 0`, while `viewMip == 0` on a mipmapped target continues to reject unsupported fast clear. Verified documentation in `docs/dev/debt/libSceAgcDriver.md`. ### Checklist - [x] Depends on: none - [x] AI-assisted: yes - [x] Unblocks: PPSA15246 #3701
xXPBSXx commented 2026-10-13 08:40:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:40:09Z.


Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main 534451426 together with six other open GPU PRs (their own commits applied, no merge conflicts), so only the tests that belong to this PR say something about it:

  • tests/Graphics.cpp (target agc_driver_graphics_tests), run as agc_driver_graphics (10 of 10 passed; this test is known to fail sometimes on address layout, see #4660), and in the same target agc_sparse_buffer_holes, agc_descriptor_pool_reset_failure, agc_compute_descriptor_layout_flags: 3 of 3 passed each.

Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6141703285 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6141703285). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T08:40:09Z. --- Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main `534451426` together with six other open GPU PRs (their own commits applied, no merge conflicts), so only the tests that belong to this PR say something about it: - `tests/Graphics.cpp` (target `agc_driver_graphics_tests`), run as `agc_driver_graphics` (10 of 10 passed; this test is known to fail sometimes on address layout, see #4660), and in the same target `agc_sparse_buffer_holes`, `agc_descriptor_pool_reset_failure`, `agc_compute_descriptor_layout_flags`: 3 of 3 passed each. Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed. AI-assisted (Claude Code).
pushkarreddyy commented 2026-10-13 12:22:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T12:22:40Z.


Rebased cleanly onto latest origin/main resolving the libSceAgcDriver.md merge conflict with newly merged #4041. Conventions checks pass locally with 0 findings and 0 errors, and Windows unit tests verified 10/10 clean by @xXPBSXx.

This unblocks Teardown (PPSA08182 / Issue #3701). Register state confirmed on hardware: single-sample view with iewMip = 1 where CMASK metadata only exists on base mip 0 (FAST_CLEAR skipped).

@adriadam10 @oneandonlydean @MarcZX100 Clean, mergeable, and ready for review/merge when convenient.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6145443211 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6145443211). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-13T12:22:40Z. --- Rebased cleanly onto latest origin/main resolving the libSceAgcDriver.md merge conflict with newly merged #4041. Conventions checks pass locally with 0 findings and 0 errors, and Windows unit tests verified 10/10 clean by @xXPBSXx. This unblocks *Teardown* (PPSA08182 / Issue #3701). Register state confirmed on hardware: single-sample view with iewMip = 1 where CMASK metadata only exists on base mip 0 (FAST_CLEAR skipped). @adriadam10 @oneandonlydean @MarcZX100 Clean, mergeable, and ready for review/merge when convenient.
xXPBSXx commented 2026-10-13 14:00:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T14:00:52Z.


Evidence for the error this fixes: in three of my saved runs of PPSA15246 (2026-10-11, before this change) the title stops with AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported, the message quoted in the description. The same title also logs runtime image descriptor is invalid in nine other saved runs, which may be a separate problem. I have not run PPSA15246 with this PR applied, so whether this change alone lets it continue is not tested.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6147294134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6147294134). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T14:00:52Z. --- Evidence for the error this fixes: in three of my saved runs of PPSA15246 (2026-10-11, before this change) the title stops with `AGC graphics: CMASK fast clears of a mipmapped, 3D or array color target are unsupported`, the message quoted in the description. The same title also logs `runtime image descriptor is invalid` in nine other saved runs, which may be a separate problem. I have not run PPSA15246 with this PR applied, so whether this change alone lets it continue is not tested. AI-assisted (Claude Code).
pushkarreddyy commented 2026-10-13 14:44:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T14:44:08Z.


@xXPBSXx Thanks for confirming the saved run evidence on PPSA15246! That matches the exact CMASK fast clear assertion this PR resolves.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6148181323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6148181323). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-10-13T14:44:08Z. --- @xXPBSXx Thanks for confirming the saved run evidence on PPSA15246! That matches the exact CMASK fast clear assertion this PR resolves.
oneandonlydean commented 2026-10-14 01:20:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T01:20:19Z.


Rebased onto main to resolve the conflict in docs/dev/debt/libSceAgcDriver.md after #4603 and #4517; no other change.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158737029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6158737029). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T01:20:19Z. --- Rebased onto main to resolve the conflict in `docs/dev/debt/libSceAgcDriver.md` after #4603 and #4517; no other change.
github-actions[bot] commented 2026-10-14 01:29:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T01:29:44Z.


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
#4790 docs/dev/debt/libSceAgcDriver.md L76-77
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6158847289 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4965#issuecomment-6158847289). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T01:29:44Z. --- <!-- pr-overlap --> 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 | |---|---|---|---| | #4790 | `docs/dev/debt/libSceAgcDriver.md` [L76-77](https://github.com/boykopovar/AnyPS5/blob/5a81f6085b0c18efed2125d857836c73acd129c6/docs/dev/debt/libSceAgcDriver.md#L76-L77) | | |
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!4965
No description provided.