feat(agc): blend against an opaque destination for CB_COLOR_ATTRIB FORCE_DST_ALPHA_1 #1914

Merged
TheAggie merged 1 commit from upstream-pr/1914 into main 2026-10-10 04:42:27 +00:00
TheAggie commented 2026-10-08 23:33:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by TheAggie on 2026-10-08T23:33:51Z.


What

CB_COLOR_ATTRIB had to be zero, so any draw whose color target set FORCE_DST_ALPHA_1 (bit 17) was rejected. RADV on the PS5 (mihawk-99/PS5_Mesa) sets it for color formats without alpha, so blending reads the destination alpha as 1, as for an RGBX surface. In ccleste (PPSA59322) six draws per frame were skipped this way.

The bit is now accepted, and the target's blend factors are rewritten to what they become when the destination alpha is 1:

  • Color equation: DST_ALPHA becomes ONE, ONE_MINUS_DST_ALPHA becomes ZERO, and SRC_ALPHA_SATURATE (min(As, 1 - Ad)) becomes ZERO.
  • Alpha equation: DST_ALPHA and DST_COLOR become ONE, and ONE_MINUS_DST_ALPHA and ONE_MINUS_DST_COLOR become ZERO, since the destination color's alpha component is the destination alpha.

Other factors are unchanged. Every other CB_COLOR_ATTRIB bit is still rejected.

Test (agc_driver_graphics, OpaqueDestinationAlphaTests): without the bit, the destination-alpha and destination-color factors decode unchanged. With it they become ONE or ZERO as above, SRC_ALPHA_SATURATE becomes ZERO in the color equation and stays in the alpha equation, and another CB_COLOR_ATTRIB bit (18) is still rejected.

Related: #419 (multisampled targets) also relaxes the CB_COLOR_ATTRIB check, for the sample and fragment fields. The two edit the same line, so whichever merges second needs a small rebase; they don't conflict in behaviour.

Tested

Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti.

  • The full suite (488 tests) passes on current main with this PR and my RADV raster-defaults PR merged together. It was run from the generated CTestTestfile.cmake commands because antivirus blocks ctest.exe on this machine.
  • tools/check_conventions.py --base origin/main passes on this branch alone.
  • ccleste (PPSA59322) renders with this change on a local branch that also carries my other open RADV PRs (#1732, #1733-#1736, #1819, #1825 and others).

Not tested on AMD, Intel, Linux or macOS.

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:4794043783 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1914). Originally posted by [TheAggie](https://github.com/TheAggie) on 2026-10-08T23:33:51Z. --- ### What `CB_COLOR_ATTRIB` had to be zero, so any draw whose color target set `FORCE_DST_ALPHA_1` (bit 17) was rejected. RADV on the PS5 ([mihawk-99/PS5_Mesa](https://github.com/mihawk-99/PS5_Mesa)) sets it for color formats without alpha, so blending reads the destination alpha as 1, as for an RGBX surface. In ccleste (PPSA59322) six draws per frame were skipped this way. The bit is now accepted, and the target's blend factors are rewritten to what they become when the destination alpha is 1: - Color equation: `DST_ALPHA` becomes `ONE`, `ONE_MINUS_DST_ALPHA` becomes `ZERO`, and `SRC_ALPHA_SATURATE` (`min(As, 1 - Ad)`) becomes `ZERO`. - Alpha equation: `DST_ALPHA` and `DST_COLOR` become `ONE`, and `ONE_MINUS_DST_ALPHA` and `ONE_MINUS_DST_COLOR` become `ZERO`, since the destination color's alpha component is the destination alpha. Other factors are unchanged. Every other `CB_COLOR_ATTRIB` bit is still rejected. Test (`agc_driver_graphics`, `OpaqueDestinationAlphaTests`): without the bit, the destination-alpha and destination-color factors decode unchanged. With it they become `ONE` or `ZERO` as above, `SRC_ALPHA_SATURATE` becomes `ZERO` in the color equation and stays in the alpha equation, and another `CB_COLOR_ATTRIB` bit (18) is still rejected. Related: #419 (multisampled targets) also relaxes the `CB_COLOR_ATTRIB` check, for the sample and fragment fields. The two edit the same line, so whichever merges second needs a small rebase; they don't conflict in behaviour. ### Tested Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, NVIDIA GeForce RTX 5070 Ti. - The full suite (488 tests) passes on current `main` with this PR and my RADV raster-defaults PR merged together. It was run from the generated `CTestTestfile.cmake` commands because antivirus blocks `ctest.exe` on this machine. - `tools/check_conventions.py --base origin/main` passes on this branch alone. - ccleste (PPSA59322) renders with this change on a local branch that also carries my other open RADV PRs (#1732, #1733-#1736, #1819, #1825 and others). Not tested on AMD, Intel, Linux or macOS. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
klosixgaming-arch commented 2026-10-09 00:47:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:47:20Z.

Review: APPROVED


The blend-factor rewrite is correct and I can approve it.

  • When FORCE_DST_ALPHA_1 sets the destination alpha to 1, the mappings are right: DST_ALPHA → ONE, ONE_MINUS_DST_ALPHA → ZERO, SRC_ALPHA_SATURATE → ZERO (since min(As, 1−1) = 0). For the alpha equation, treating the destination color's alpha component as the destination alpha (DST_ALPHA/DST_COLOR → ONE, ONE_MINUS_* → ZERO) is consistent.
  • DecodeColorBuffer's zero(cx, 0x31d + stride, ~0x20000u, ...) now carves out bit 17 while rejecting every other CB_COLOR_ATTRIB bit — good, you didn't just zero the whole word.
  • The test (OpaqueDestinationAlphaTests) checks each factor both with and without the bit, and confirms another bit (18) is still rejected. Solid coverage of the exact boundary.

Non-blocking notes:

  1. Rebase collision with #419. You note both this PR and #419 edit the same zero(...) line in DecodeColorBuffer. Whichever merges second needs a manual rebase and the two should be compatible (bit 17 vs sample/fragment fields), but please verify there's no behavioural interaction — specifically that #419's sample/fragment relaxation doesn't also touch 0x31d's other bits in a way that changes what "other bits still rejected" means once both are in.
  2. The mapping assumes the destination is truly opaque (alpha forced to 1) for all pixels in the draw. If FORCE_DST_ALPHA_1 were ever combined with a per-pixel alpha source, "destination alpha = 1" still holds because it's a destination override — so this is safe, but it's worth one sentence in the debt entry stating that the factor rewrite is unconditional once the bit is set.

Written with AI assistance.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5464521754 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1914#pullrequestreview-5464521754). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-09T00:47:20Z. **Review:** APPROVED --- The blend-factor rewrite is correct and I can approve it. - When `FORCE_DST_ALPHA_1` sets the destination alpha to 1, the mappings are right: `DST_ALPHA → ONE`, `ONE_MINUS_DST_ALPHA → ZERO`, `SRC_ALPHA_SATURATE → ZERO` (since `min(As, 1−1) = 0`). For the alpha equation, treating the destination color's alpha component as the destination alpha (`DST_ALPHA`/`DST_COLOR → ONE`, `ONE_MINUS_* → ZERO`) is consistent. - `DecodeColorBuffer`'s `zero(cx, 0x31d + stride, ~0x20000u, ...)` now carves out bit 17 while rejecting every other `CB_COLOR_ATTRIB` bit — good, you didn't just zero the whole word. - The test (`OpaqueDestinationAlphaTests`) checks each factor both with and without the bit, and confirms another bit (18) is still rejected. Solid coverage of the exact boundary. Non-blocking notes: 1. **Rebase collision with #419.** You note both this PR and #419 edit the same `zero(...)` line in `DecodeColorBuffer`. Whichever merges second needs a manual rebase and the two *should* be compatible (bit 17 vs sample/fragment fields), but please verify there's no behavioural interaction — specifically that #419's sample/fragment relaxation doesn't also touch `0x31d`'s other bits in a way that changes what "other bits still rejected" means once both are in. 2. The mapping assumes the destination is truly opaque (alpha forced to 1) for *all* pixels in the draw. If `FORCE_DST_ALPHA_1` were ever combined with a per-pixel alpha source, "destination alpha = 1" still holds because it's a destination override — so this is safe, but it's worth one sentence in the debt entry stating that the factor rewrite is unconditional once the bit is set. Written with AI assistance.
johnmaia commented 2026-10-09 01:01:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T01:01:36Z.


Linux run on AMD, since the description lists it as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head 1e20b4ec, merged onto main f1451396. Full ctest: 494/494 pass, the same as main on this machine, with the GPU tests running on the RX 7600 (none skipped). That includes agc_driver_graphics with this PR's new cases.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6072105808 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1914#issuecomment-6072105808). Originally posted by [johnmaia](https://github.com/johnmaia) on 2026-10-09T01:01:36Z. --- Linux run on AMD, since the description lists it as not tested: Ubuntu 24.04.5 (kernel 6.8), GCC 13.3, Release, AMD Radeon RX 7600 (RADV NAVI33, Mesa 25.2.8). This PR's head `1e20b4ec`, merged onto `main` `f1451396`. Full ctest: 494/494 pass, the same as `main` on this machine, with the GPU tests running on the RX 7600 (none skipped). That includes `agc_driver_graphics` with this PR's new cases.
github-actions[bot] commented 2026-10-10 01:48:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T01:48:24Z.


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
#2169 core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp L741
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6092354603 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1914#issuecomment-6092354603). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T01:48:24Z. --- <!-- 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 | |---|---|---|---| | #2169 | `core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp` [L741](https://github.com/boykopovar/AnyPS5/blob/80d539abcbd0f90a7b6e64f7ab4868556671f241/core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp#L741) | | |
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!1914
No description provided.