feat(agc): run CB fast-clear eliminate and DCC decompress passes within the DCC model #132

Merged
oneandonlydean merged 1 commit from upstream-pr/132 into main 2026-10-01 08:29:22 +00:00
oneandonlydean commented 2026-09-29 00:33:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-29T00:33:15Z.


What

Draws with CB_COLOR_CONTROL MODE ELIMINATE_FAST_CLEAR (2) or DCC_DECOMPRESS (6) were rejected as "only normal color rendering with copy ROP". On hardware these are full-target blits: they write the fast-clear value into the fast-cleared pixels, or store the pixels uncompressed, and the shader's output never lands. In the driver's DCC model (surfaces stored uncompressed, uniform fast-clear keys make every read return the clear value), that works out as follows:

  • Keys that are a clear code: the target's texels become that value and its keys read uncompressed. Reads return the same values before and after.
  • Uncompressed keys, or no DCC on the target: nothing changes.
  • Throws: mixed keys (per-block metadata isn't modeled), a mipmapped DCC target (its keys aren't decoded), a register clear of a texel over 64 bits, and indirect passes.

The texels go into the target's resident image, since its refresh already cleared it to a code's value and the register code is cleared on the GPU with FillClear. From there they reach memory through the image's write-back. Without a resident image they are written to guest memory on the CPU. A resident image made under other DCC keys is remade under the target's keys by the storage cache (#177) before the pass reads it. DecodeColorMetadataPass requires the draw to be only that pass: copy ROP, no depth or stencil work, no multisampling, and a viewport and scissor covering each target. The CB_COLOR decode moves into DecodeColorBuffer, which also reads CB_COLOR_CLEAR_WORD0/1.

The register clear code (DCC key 0x20) had no value before: it was read as the stored texels. A target under register keys now reads as its CB_COLOR_CLEAR_WORD texel. A resident target is cleared to that value before a draw renders into it, and its keys then read uncompressed. A non-resident target's copy starts from the value.

Every decision that materializes a clear reads the keys through CurrentDccKeys. It first waits for the batches up to the newest recorded writer of the key range, because the title's fast-clear fill of the metadata can still be pending on the GPU. Reading the stale bytes made a later draw clear a target over earlier draws' results; in PPSA21564 this hit the 1080p G-buffer every frame.

The other CB modes (resolve, decompress, FMASK decompress) are still rejected, and the message now names the mode.

Not included: accepting CB_COLOR_INFO.FAST_CLEAR (CMASK) targets. Rendering them uncompressed would leave pixels in CMASK-cleared tiles stale after an eliminate pass, because CMASK clears aren't modeled. Those targets still throw.

Rebased on current main. Since #177 remakes a storage image whose DCC keys moved, the earlier refusal of a resident image that doesn't follow the target's keys can no longer trigger, so it is dropped, and the recorder test now checks that such an image is remade under the target's keys and the pass completes.

Tested

  • Linux (CachyOS, RADV). agc_driver_graphics_tests gets metadataPassTests: pass decoding (modes, ROP, depth/stencil work, partial viewport or scissor, disabled targets, mipmapped DCC) and the CPU path (register and code clears written into the texels with keys marked uncompressed, uncompressed keys untouched, mixed keys refused, no DCC).
  • agc_driver_recorder_tests gets metadataPassTests for the resident path:
    • Register and 1111 clears land in the resident image, the keys read uncompressed, and the write-back stores the value.
    • A key fill recorded on the GPU but not yet run is waited for.
    • Uncompressed keys leave the texels alone.
    • An image made under other keys is remade under the target's keys, and the pass stores the clear value.
  • Both suites pass on current main (after #163 and the other recent merges). ctest: 85/85 pass.
  • The source commits were exercised in PPSA21564 on our integration branch: the G-buffer register fast clear and its eliminate passes.

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
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4670963541 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/132). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-29T00:33:15Z. --- ### What Draws with CB_COLOR_CONTROL MODE ELIMINATE_FAST_CLEAR (2) or DCC_DECOMPRESS (6) were rejected as "only normal color rendering with copy ROP". On hardware these are full-target blits: they write the fast-clear value into the fast-cleared pixels, or store the pixels uncompressed, and the shader's output never lands. In the driver's DCC model (surfaces stored uncompressed, uniform fast-clear keys make every read return the clear value), that works out as follows: - **Keys that are a clear code:** the target's texels become that value and its keys read uncompressed. Reads return the same values before and after. - **Uncompressed keys, or no DCC on the target:** nothing changes. - **Throws:** mixed keys (per-block metadata isn't modeled), a mipmapped DCC target (its keys aren't decoded), a register clear of a texel over 64 bits, and indirect passes. The texels go into the target's resident image, since its refresh already cleared it to a code's value and the register code is cleared on the GPU with `FillClear`. From there they reach memory through the image's write-back. Without a resident image they are written to guest memory on the CPU. A resident image made under other DCC keys is remade under the target's keys by the storage cache (#177) before the pass reads it. `DecodeColorMetadataPass` requires the draw to be only that pass: copy ROP, no depth or stencil work, no multisampling, and a viewport and scissor covering each target. The CB_COLOR decode moves into `DecodeColorBuffer`, which also reads CB_COLOR_CLEAR_WORD0/1. The register clear code (DCC key 0x20) had no value before: it was read as the stored texels. A target under register keys now reads as its CB_COLOR_CLEAR_WORD texel. A resident target is cleared to that value before a draw renders into it, and its keys then read uncompressed. A non-resident target's copy starts from the value. Every decision that materializes a clear reads the keys through `CurrentDccKeys`. It first waits for the batches up to the newest recorded writer of the key range, because the title's fast-clear fill of the metadata can still be pending on the GPU. Reading the stale bytes made a later draw clear a target over earlier draws' results; in PPSA21564 this hit the 1080p G-buffer every frame. The other CB modes (resolve, decompress, FMASK decompress) are still rejected, and the message now names the mode. Not included: accepting CB_COLOR_INFO.FAST_CLEAR (CMASK) targets. Rendering them uncompressed would leave pixels in CMASK-cleared tiles stale after an eliminate pass, because CMASK clears aren't modeled. Those targets still throw. Rebased on current `main`. Since #177 remakes a storage image whose DCC keys moved, the earlier refusal of a resident image that doesn't follow the target's keys can no longer trigger, so it is dropped, and the recorder test now checks that such an image is remade under the target's keys and the pass completes. ### Tested - Linux (CachyOS, RADV). `agc_driver_graphics_tests` gets `metadataPassTests`: pass decoding (modes, ROP, depth/stencil work, partial viewport or scissor, disabled targets, mipmapped DCC) and the CPU path (register and code clears written into the texels with keys marked uncompressed, uncompressed keys untouched, mixed keys refused, no DCC). - `agc_driver_recorder_tests` gets `metadataPassTests` for the resident path: - Register and 1111 clears land in the resident image, the keys read uncompressed, and the write-back stores the value. - A key fill recorded on the GPU but not yet run is waited for. - Uncompressed keys leave the texels alone. - An image made under other keys is remade under the target's keys, and the pass stores the clear value. - Both suites pass on current `main` (after #163 and the other recent merges). `ctest`: 85/85 pass. - The source commits were exercised in PPSA21564 on our integration branch: the G-buffer register fast clear and its eliminate passes. ### 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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
oneandonlydean commented 2026-09-30 21:01:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-30T21:01:09Z.


On the overlap note: #167 and this PR touch the same color target loop in DecodeState (State.cpp) but do different things. #167 allows gaps between written MRT slots; this PR decodes the fast-clear and DCC metadata words of each target. Nothing is implemented twice, it is only a textual conflict. If #167 merges first, I'll rebase this PR onto it straight away.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5919650504 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/132#issuecomment-5919650504). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-30T21:01:09Z. --- On the overlap note: #167 and this PR touch the same color target loop in `DecodeState` (`State.cpp`) but do different things. #167 allows gaps between written MRT slots; this PR decodes the fast-clear and DCC metadata words of each target. Nothing is implemented twice, it is only a textual conflict. If #167 merges first, I'll rebase this PR onto it straight away.
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!132
No description provided.