fix(agc): expand comp-to-single DCC keys in a DCC decompress pass #2939

Merged
CnRJay merged 2 commits from upstream-pr/2939 into main 2026-10-10 23:46:49 +00:00
CnRJay commented 2026-10-10 18:40:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-10T18:40:31Z.


What

PPSA28416 (STAR WARS: Galactic Racer, UE5) stops on main at its first presentation:

[videoout] presentation failed: AGC graphics: CB metadata pass over DCC keys that are mixed (per-block metadata is not modeled)

The keys are not actually mixed. Every key of the target is 0x10. The target is a 9x1 RGBA16F SW_64KB_R_X surface with pipe-aligned DCC (256 keys over its 64 KiB tile), and the pass is a CB DCC decompress (CB_COLOR_CONTROL.MODE 6). 0x10 is the comp-to-single code, GFX9_DCC_CLEAR_SINGLE in Mesa's src/amd/common/ac_descriptors.h. radv uses it for DCC fast clears that need no fast-clear eliminate (gfx8_get_fast_clear_parameters in radv_meta_clear.c). Its build_clear_dcc_comp_to_single_shader writes the clear color into one texel per DCC block, at the block's origin (coord = global_id * dcc_block_size), so a comp-to-single block's value is its top-left texel. ByteKeys did not know the code, so uniform 0x10 keys read as Mixed.

Changes:

  • DccKeys::ClearSingle (byte 0x10). It is not an IsDccClear code, because it has no fixed clear value, so every other key reader treats it as it treated these keys before (stored texels, refusal).
  • RunColorMetadataPass: a DCC decompress over uniform comp-to-single keys of a non-linear target flushes pending results, gives every texel of the target's extent the element at the start of its 256-byte block (ColorTargetLayout::Offset), stores uncompressed keys, and refreshes a resident image. A fast-clear eliminate over these keys throws, because whether it expands comp-to-single blocks is not modeled. Mixed keys still throw as before.
  • TechnicalDebt entry; not verified on hardware.

In every non-linear gfx10 swizzle a 256-byte micro-block is one DCC block, and its top-left texel has all in-block address bits zero, so it sits at the block's first byte. The test checks this through the layout instead of assuming it. It expects every texel to equal the original texel at (x & ~7, y & ~7) of the 8x8 block of a 4-byte SW_64KB_R_X target.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4080.

  • agc_driver_graphics: a 128x128 SW_64KB_R_X target with pipe-aligned and unaligned DCC, with 0x10 keys. A fast-clear eliminate throws and leaves the texels and keys unchanged. A DCC decompress gives every 8x8 block its first texel and stores uncompressed keys over the expected key count.
  • ctest -R "agc_driver|dcc|display_buffer": 257/257 pass. Full suite: 712/712 pass (5 VideoOut tests skipped, as on main).
  • PPSA28416: gets past the presentation above. The next stops are a VOP1 SDWA selector and a structurizer budget, in separate PRs.

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:4813561412 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2939). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-10T18:40:31Z. --- ### What PPSA28416 (STAR WARS: Galactic Racer, UE5) stops on `main` at its first presentation: ``` [videoout] presentation failed: AGC graphics: CB metadata pass over DCC keys that are mixed (per-block metadata is not modeled) ``` The keys are not actually mixed. Every key of the target is `0x10`. The target is a 9x1 RGBA16F SW_64KB_R_X surface with pipe-aligned DCC (256 keys over its 64 KiB tile), and the pass is a CB DCC decompress (`CB_COLOR_CONTROL.MODE` 6). `0x10` is the comp-to-single code, `GFX9_DCC_CLEAR_SINGLE` in Mesa's `src/amd/common/ac_descriptors.h`. radv uses it for DCC fast clears that need no fast-clear eliminate (`gfx8_get_fast_clear_parameters` in `radv_meta_clear.c`). Its `build_clear_dcc_comp_to_single_shader` writes the clear color into one texel per DCC block, at the block's origin (`coord = global_id * dcc_block_size`), so a comp-to-single block's value is its top-left texel. `ByteKeys` did not know the code, so uniform `0x10` keys read as `Mixed`. Changes: - `DccKeys::ClearSingle` (byte `0x10`). It is not an `IsDccClear` code, because it has no fixed clear value, so every other key reader treats it as it treated these keys before (stored texels, refusal). - `RunColorMetadataPass`: a DCC decompress over uniform comp-to-single keys of a non-linear target flushes pending results, gives every texel of the target's extent the element at the start of its 256-byte block (`ColorTargetLayout::Offset`), stores uncompressed keys, and refreshes a resident image. A fast-clear eliminate over these keys throws, because whether it expands comp-to-single blocks is not modeled. Mixed keys still throw as before. - TechnicalDebt entry; not verified on hardware. In every non-linear gfx10 swizzle a 256-byte micro-block is one DCC block, and its top-left texel has all in-block address bits zero, so it sits at the block's first byte. The test checks this through the layout instead of assuming it. It expects every texel to equal the original texel at `(x & ~7, y & ~7)` of the 8x8 block of a 4-byte SW_64KB_R_X target. ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, RTX 4080. - `agc_driver_graphics`: a 128x128 SW_64KB_R_X target with pipe-aligned and unaligned DCC, with `0x10` keys. A fast-clear eliminate throws and leaves the texels and keys unchanged. A DCC decompress gives every 8x8 block its first texel and stores uncompressed keys over the expected key count. - `ctest -R "agc_driver|dcc|display_buffer"`: 257/257 pass. Full suite: 712/712 pass (5 VideoOut tests skipped, as on `main`). - PPSA28416: gets past the presentation above. The next stops are a VOP1 SDWA selector and a structurizer budget, in separate PRs. ### 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
fma-rc commented 2026-10-10 22:00:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-10T22:00:27Z.


Built dfe2967c on main 262c0316 on Linux (GCC 16.2.1, RTX 5080); agc_driver_graphics and the full suite pass apart from agc_driver_dcc_keys_first_write, which also fails on main here.

One case that I think should throw and doesn't: in the new test I set only the first 256 key bytes to 0x10 and the remaining 3840 to 0xff (and in a second run to 0x00), then ran the DCC decompress on the pipe-aligned target. It doesn't throw, the texels are rewritten and all 4096 keys come back as 0xff. So a surface whose keys are mixed past the first 256 is expanded as if it were all comp-to-single.

The test only uses a 4-byte format. I did not try an 8-byte one.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6102629280 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2939#issuecomment-6102629280). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-10T22:00:27Z. --- Built dfe2967c on main 262c0316 on Linux (GCC 16.2.1, RTX 5080); `agc_driver_graphics` and the full suite pass apart from `agc_driver_dcc_keys_first_write`, which also fails on main here. One case that I think should throw and doesn't: in the new test I set only the first 256 key bytes to 0x10 and the remaining 3840 to 0xff (and in a second run to 0x00), then ran the DCC decompress on the pipe-aligned target. It doesn't throw, the texels are rewritten and all 4096 keys come back as 0xff. So a surface whose keys are mixed past the first 256 is expanded as if it were all comp-to-single. The test only uses a 4-byte format. I did not try an 8-byte one.
adriadam10 commented 2026-10-10 23:41:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:41:29Z.


Checked on Linux (RADV): build + agc_driver_graphics / agc_driver_prepared_graphics pass on the PR rebased onto main, and the new cases fail without the change. Confirmed by @fma-rc on Linux RTX 5080.

Added one commit of ours:

  • docs/dev/TechnicalDebt.md: the comp-to-single entry now says "uniform" is judged over the key bytes the driver reads (one per 256 surface bytes, see "DCC key stores"), so keys that differ past that range, as @fma-rc found, are expanded like the other clear codes.

Not verified: the block value on real hardware (taken from radv's build_clear_dcc_comp_to_single_shader), 8-byte elements (the test covers 4-byte) and the title itself. Merging on green CI.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6103411623 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2939#issuecomment-6103411623). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T23:41:29Z. --- Checked on Linux (RADV): build + `agc_driver_graphics` / `agc_driver_prepared_graphics` pass on the PR rebased onto main, and the new cases fail without the change. Confirmed by @fma-rc on Linux RTX 5080. Added one commit of ours: - `docs/dev/TechnicalDebt.md`: the comp-to-single entry now says "uniform" is judged over the key bytes the driver reads (one per 256 surface bytes, see "DCC key stores"), so keys that differ past that range, as @fma-rc found, are expanded like the other clear codes. Not verified: the block value on real hardware (taken from radv's `build_clear_dcc_comp_to_single_shader`), 8-byte elements (the test covers 4-byte) and the title itself. Merging on green CI.
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!2939
No description provided.