feat(agc): encode the DCC clear codes of A2R10G10B10 color targets #764

Merged
Celegans12 merged 1 commit from upstream-pr/764 into main 2026-10-06 00:18:07 +00:00
Celegans12 commented 2026-10-05 22:00:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-05T22:00:12Z.


What

LayoutFor (DccMetadata.cpp) has no case for VK_FORMAT_A2R10G10B10_UNORM_PACK32, which DecodeColorFormat gives a COLOR_2_10_10_10 target with the alternate component swap, so FillDccClear cannot encode its 0001, 1110 and 1111 clear codes (0000 is filled before the layout lookup). Split out of #648 at the maintainer's request.

  • Change: the format takes the A2B10G10R10 layout (unorm 10/10/10/2 from the low bit). The codes set the three color channels alike and alpha sits on the 2-bit field, so both packings give the same words: 0001 0xc0000000, 1110 0x3fffffff, 1111 0xffffffff.
  • Draw into a copied target (no resident storage image): under these keys the target now starts from the clear value; before, it kept its stored texels and logged "its stored texels are used".
  • clearTexel (the CB metadata pass in eliminate and decompress modes, storeClearTexels): returns the texel instead of throwing "the target's format has no encoding of its DCC clear code".
  • Unchanged: DccAlphaOnMsb (it already defaulted to 4 channels; COLOR_2_10_10_10 accepts only swaps 0 and 1, so alpha stays on the high field); textures, which never resolve to A2R10G10B10; draws into resident targets, whose storage image reads the keys as guest format 50 (A2B10G10R10, through FindGuestColorTargetFormat); the register clear color, copied from CB_COLOR_CLEAR_WORD; every other format.
  • No new assumption: the format reuses the A2B10G10R10 encoding, so no TechnicalDebt line.
  • Once #648 is in, DisplayBufferClearPixel presents these codes on blue-low 10-bit display buffers too, since DisplayTexelFormat gives them A2R10G10B10.
  • #419 adds a resolve mode to the CB metadata pass and a test after metadataPassTests in tests/Graphics.cpp; the file merges cleanly.

Tested

  • Windows 11, MinGW-w64 GCC 15.2.0, based on main bc24783e: configure -DBUILD_TESTING=ON, full build, --target libs, ctest:
  • 318/318 tests pass (ctest --output-on-failure)
  • agc_driver_graphics (ctest), extended: a fast-clear eliminate pass over a DCC COLOR_2_10_10_10 target with the standard and the alternate swap writes 0x00000000, 0xc0000000, 0x3fffffff and 0xffffffff for 0000, 0001, 1110 and 1111 and sets every key to uncompressed, and FillDccClear, the call a draw into a copied target makes, gives the same words for the target; it fails on main at the alternate-swap 0001 row ("the target's format has no encoding of its DCC clear code").
  • Not tested: the GPU draw into a copied DCC target, PPSA21564 and Dreaming Sarah, Linux (CI), console behaviour.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4751265134 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/764). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-05T22:00:12Z. --- ### What `LayoutFor` (`DccMetadata.cpp`) has no case for `VK_FORMAT_A2R10G10B10_UNORM_PACK32`, which `DecodeColorFormat` gives a COLOR_2_10_10_10 target with the alternate component swap, so `FillDccClear` cannot encode its 0001, 1110 and 1111 clear codes (0000 is filled before the layout lookup). Split out of #648 at the maintainer's request. - **Change:** the format takes the A2B10G10R10 layout (unorm 10/10/10/2 from the low bit). The codes set the three color channels alike and alpha sits on the 2-bit field, so both packings give the same words: 0001 0xc0000000, 1110 0x3fffffff, 1111 0xffffffff. - **Draw into a copied target** (no resident storage image): under these keys the target now starts from the clear value; before, it kept its stored texels and logged "its stored texels are used". - **`clearTexel`** (the CB metadata pass in eliminate and decompress modes, `storeClearTexels`): returns the texel instead of throwing "the target's format has no encoding of its DCC clear code". - **Unchanged:** `DccAlphaOnMsb` (it already defaulted to 4 channels; COLOR_2_10_10_10 accepts only swaps 0 and 1, so alpha stays on the high field); textures, which never resolve to A2R10G10B10; draws into resident targets, whose storage image reads the keys as guest format 50 (A2B10G10R10, through `FindGuestColorTargetFormat`); the register clear color, copied from CB_COLOR_CLEAR_WORD; every other format. - No new assumption: the format reuses the A2B10G10R10 encoding, so no TechnicalDebt line. - Once #648 is in, `DisplayBufferClearPixel` presents these codes on blue-low 10-bit display buffers too, since `DisplayTexelFormat` gives them A2R10G10B10. - #419 adds a resolve mode to the CB metadata pass and a test after `metadataPassTests` in `tests/Graphics.cpp`; the file merges cleanly. ### Tested - Windows 11, MinGW-w64 GCC 15.2.0, based on `main` bc24783e: configure `-DBUILD_TESTING=ON`, full build, `--target libs`, `ctest`: - 318/318 tests pass (`ctest --output-on-failure`) - `agc_driver_graphics` (ctest), extended: a fast-clear eliminate pass over a DCC COLOR_2_10_10_10 target with the standard and the alternate swap writes 0x00000000, 0xc0000000, 0x3fffffff and 0xffffffff for 0000, 0001, 1110 and 1111 and sets every key to uncompressed, and `FillDccClear`, the call a draw into a copied target makes, gives the same words for the target; it fails on `main` at the alternate-swap 0001 row ("the target's format has no encoding of its DCC clear code"). - Not tested: the GPU draw into a copied DCC target, PPSA21564 and Dreaming Sarah, Linux (CI), console behaviour. ### Checklist - [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
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!764
No description provided.