fix(agc): keep the texels of CMASK tiles with codes other than 0 and 15 #4041

Merged
ee6aba54 merged 1 commit from upstream-pr/4041 into main 2026-10-13 12:11:17 +00:00
ee6aba54 commented 2026-10-11 21:57:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ee6aba54 on 2026-10-11T21:57:54Z.


What

A fast-clear materialization threw when a CMASK nibble held a code other than 0 (cleared) or 0xF (expanded). PPSA18391 (engine: Clickteam Fusion) fast clears a color target whose CMASK it never initialized, so some nibbles hold leftover values (seen: 1 and 10), and presentation failed on the first frame with CMASK codes 1, 10 were recorded.

A tile with such a code now keeps its texels like an expanded tile, on the CPU path and in the compute pass (CmaskClear.comp). A cleared tile of a DCC target still throws, as do the other unsupported cases. The existing graphics and CMASK fast-clear tests expected the throw for an unknown code; they now check that such a tile keeps its contents and that a later full clear and eliminate still work.

Keeping the texels treats a tile that is not marked as cleared as not cleared, so the driver never overwrites bytes the title wrote with a clear value it did not ask for. Throwing stops the title, and clearing such a tile would guess a meaning for the code. What the console does with these codes on a single-sample target is unverified on hardware; the TechnicalDebt entry for CMASK fast clears says so.

Tested

  • Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on 1c5e62878. agc_driver_graphics: a code-3 tile is left unchanged while its cleared neighbour gets the clear value. agc_driver_cmask_fast_clear: a code-3 tile stays as it was, and a later full clear and eliminate work. Both fail without the change. ctest: 995 tests pass.
  • PPSA18391: presents its frames and reaches the title menu; checked by hand on an earlier base.
  • Windows not built or tested.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4822676464 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4041). Originally posted by [ee6aba54](https://github.com/ee6aba54) on 2026-10-11T21:57:54Z. --- ### What A fast-clear materialization threw when a CMASK nibble held a code other than 0 (cleared) or 0xF (expanded). PPSA18391 (engine: Clickteam Fusion) fast clears a color target whose CMASK it never initialized, so some nibbles hold leftover values (seen: 1 and 10), and presentation failed on the first frame with `CMASK codes 1, 10 were recorded`. A tile with such a code now keeps its texels like an expanded tile, on the CPU path and in the compute pass (`CmaskClear.comp`). A cleared tile of a DCC target still throws, as do the other unsupported cases. The existing graphics and CMASK fast-clear tests expected the throw for an unknown code; they now check that such a tile keeps its contents and that a later full clear and eliminate still work. Keeping the texels treats a tile that is not marked as cleared as not cleared, so the driver never overwrites bytes the title wrote with a clear value it did not ask for. Throwing stops the title, and clearing such a tile would guess a meaning for the code. What the console does with these codes on a single-sample target is unverified on hardware; the TechnicalDebt entry for CMASK fast clears says so. ### Tested - Ubuntu 24.04, Linux 7.0, GCC 13.3, Release, based on `1c5e62878`. `agc_driver_graphics`: a code-3 tile is left unchanged while its cleared neighbour gets the clear value. `agc_driver_cmask_fast_clear`: a code-3 tile stays as it was, and a later full clear and eliminate work. Both fail without the change. `ctest`: 995 tests pass. - PPSA18391: presents its frames and reaches the title menu; checked by hand on an earlier base. - Windows not built or tested. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
winstrex commented 2026-10-12 20:58:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by winstrex on 2026-10-12T20:58:24Z.


Another title this fixes: The Pathless (PPSA01825, 02.000.000), Windows, RTX 5070 Ti. Tested on main 682ef0c17 + this PR + #4491 (PlayGo; without it the title stops earlier).

  • On main the first present aborts with CMASK codes 1, 2, ..., 14 were recorded. Its two 3840x2160 single-sample display buffers set FAST_CLEAR (CB_COLOR_INFO 0xa828, no DCC, clear words 0), but their CB_COLOR0_CMASK points into memory the title uses as a CPU heap. At the first draw it holds PNG data, with every nibble value 0 to 15, and nothing on the GPU side clears it first.
  • With this PR the abort is gone. The Annapurna Interactive and Giant Squid logos render; I compared frame dumps (APS5_DUMP_FRAMES) across three runs. It then stops on unrelated errors (storage image access to depth/stencil surface ... is not implemented, or a Wwise access violation).
  • The PNG nibbles that happen to be 0 (29041 and 34672 tiles in the two buffers) are cleared to black before the first draw. The title then draws over the whole frame, so nothing of that shows.
  • One side effect: the materialization stores the CMASK as expanded, so 0xFF goes over those 81920 bytes of the title's heap on each buffer. No crash traced to it so far: the same two later stops also happen when the CMASK is not touched at all.
  • LEGO Horizon Adventures (PPSA14632, 01.004.000), which zero-fills its display-buffer CMASK every frame: same loading screen as on main, compared frame by frame.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132494877 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4041#issuecomment-6132494877). Originally posted by [winstrex](https://github.com/winstrex) on 2026-10-12T20:58:24Z. --- Another title this fixes: The Pathless (PPSA01825, 02.000.000), Windows, RTX 5070 Ti. Tested on `main` 682ef0c17 + this PR + #4491 (PlayGo; without it the title stops earlier). - On `main` the first present aborts with `CMASK codes 1, 2, ..., 14 were recorded`. Its two 3840x2160 single-sample display buffers set `FAST_CLEAR` (`CB_COLOR_INFO 0xa828`, no DCC, clear words 0), but their `CB_COLOR0_CMASK` points into memory the title uses as a CPU heap. At the first draw it holds PNG data, with every nibble value 0 to 15, and nothing on the GPU side clears it first. - With this PR the abort is gone. The Annapurna Interactive and Giant Squid logos render; I compared frame dumps (`APS5_DUMP_FRAMES`) across three runs. It then stops on unrelated errors (`storage image access to depth/stencil surface ... is not implemented`, or a Wwise access violation). - The PNG nibbles that happen to be 0 (29041 and 34672 tiles in the two buffers) are cleared to black before the first draw. The title then draws over the whole frame, so nothing of that shows. - One side effect: the materialization stores the CMASK as expanded, so 0xFF goes over those 81920 bytes of the title's heap on each buffer. No crash traced to it so far: the same two later stops also happen when the CMASK is not touched at all. - LEGO Horizon Adventures (PPSA14632, 01.004.000), which zero-fills its display-buffer CMASK every frame: same loading screen as on `main`, compared frame by frame.
github-actions[bot] commented 2026-10-13 00:36:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T00:36:01Z.


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
#4603 docs/dev/debt/libSceAgcDriver.md L70-71
#4790 docs/dev/debt/libSceAgcDriver.md L69-70
#4965 docs/dev/debt/libSceAgcDriver.md L70
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6135368137 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4041#issuecomment-6135368137). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T00:36:01Z. --- <!-- 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 | |---|---|---|---| | #4603 | `docs/dev/debt/libSceAgcDriver.md` [L70-71](https://github.com/boykopovar/AnyPS5/blob/14036cb0e8aeddb686a6c745193610528bd8a9f0/docs/dev/debt/libSceAgcDriver.md#L70-L71) | | | | #4790 | `docs/dev/debt/libSceAgcDriver.md` [L69-70](https://github.com/boykopovar/AnyPS5/blob/14036cb0e8aeddb686a6c745193610528bd8a9f0/docs/dev/debt/libSceAgcDriver.md#L69-L70) | | | | #4965 | `docs/dev/debt/libSceAgcDriver.md` [L70](https://github.com/boykopovar/AnyPS5/blob/14036cb0e8aeddb686a6c745193610528bd8a9f0/docs/dev/debt/libSceAgcDriver.md#L70) | | |
adriadam10 commented 2026-10-13 10:47:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T10:47:17Z.


Checked the diff, the two updated tests (agc_driver_graphics, agc_driver_cmask_fast_clear: both pass with the change and fail without it) and the scoped libSceAgcDriver ctest; the CPU path and CmaskClear.comp agree (a code other than 0 keeps its texels, a cleared tile of a DCC target still throws), and the TechnicalDebt entry is updated. Also confirmed by @winstrex on The Pathless (PPSA01825, Windows, RTX 5070 Ti). Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6143849660 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4041#issuecomment-6143849660). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T10:47:17Z. --- Checked the diff, the two updated tests (`agc_driver_graphics`, `agc_driver_cmask_fast_clear`: both pass with the change and fail without it) and the scoped libSceAgcDriver ctest; the CPU path and `CmaskClear.comp` agree (a code other than 0 keeps its texels, a cleared tile of a DCC target still throws), and the TechnicalDebt entry is updated. Also confirmed by @winstrex on The Pathless (PPSA01825, Windows, RTX 5070 Ti). Merging once the full Build is green.
Amoenus commented 2026-10-13 13:00:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T13:00:02Z.


Additional Windows fixture coverage found an AMD GPL-off device loss, tracked in https://github.com/boykopovar/AnyPS5/issues/5150. agc_driver_cmask_fast_clear fails on exact unmodified main 0f2683cb7 with AGC graphics: vkQueueSubmit recorder: Vulkan result -4, and the same failure returns after byte-exact candidate restoration/full rebuild. NVIDIA on/off and AMD on each pass 5/5 on the two recorded candidate/base pins.

This is a distinct synthetic-fixture finding, not an attribution to #4041 or a title result. Full reproduction and controls are in the issue. AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6146112778 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4041#issuecomment-6146112778). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-13T13:00:02Z. --- Additional Windows fixture coverage found an AMD GPL-off device loss, tracked in https://github.com/boykopovar/AnyPS5/issues/5150. `agc_driver_cmask_fast_clear` fails on exact unmodified main `0f2683cb7` with `AGC graphics: vkQueueSubmit recorder: Vulkan result -4`, and the same failure returns after byte-exact candidate restoration/full rebuild. NVIDIA on/off and AMD on each pass 5/5 on the two recorded candidate/base pins. This is a distinct synthetic-fixture finding, not an attribution to #4041 or a title result. Full reproduction and controls are in the issue. AI-assisted: yes.
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!4041
No description provided.