Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
ee6aba54:fix/agc-cmask-unknown-codes
Oct 13, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
ee6aba54:fix/agc-cmask-unknown-codes

Conversation

@ee6aba54

@ee6aba54 ee6aba54 commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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

@winstrex

Copy link
Copy Markdown
Contributor

Another title this fixes: The Pathless (PPSA01825, 02.000.000), Windows, RTX 5070 Ti. Tested on main 682ef0c + 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.

@ee6aba54
ee6aba54 force-pushed the fix/agc-cmask-unknown-codes branch from 22f5ea4 to afd5565 Compare October 12, 2026 21:15
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
A fast-clear materialization threw when a CMASK nibble held a code other
than 0 (cleared) or 15 (expanded). PPSA18391 (engine: Clickteam Fusion) fast
clears a target whose CMASK it never initialized, so some nibbles hold
leftover values such as 1 and 10, and presentation failed on the first
frame.

Such a tile now keeps its texels like an expanded tile, on the CPU path
and in the compute pass. A cleared tile of a DCC target still throws.
The graphics and CMASK fast-clear tests now check that an unknown code
leaves the tile unchanged instead of expecting the throw.
@ee6aba54
ee6aba54 force-pushed the fix/agc-cmask-unknown-codes branch from afd5565 to 51c043b Compare October 13, 2026 00:30
@github-actions

github-actions Bot commented Oct 13, 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
#4603 docs/dev/debt/libSceAgcDriver.md L70-71
#4790 docs/dev/debt/libSceAgcDriver.md L69-70
#4965 docs/dev/debt/libSceAgcDriver.md L70

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 13, 2026
@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 merged commit 96f3e9f into boykopovar:main Oct 13, 2026
8 of 9 checks passed
@Amoenus

Amoenus commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Additional Windows fixture coverage found an AMD GPL-off device loss, tracked in #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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants