feat(agc-driver): blend into COLOR_8_8 SWAP_ALT targets with a separate alpha equation #3194

Merged
XairRrR merged 2 commits from upstream-pr/3194 into main 2026-10-11 07:17:35 +00:00
XairRrR commented 2026-10-11 00:52:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-11T00:52:10Z.


What

#2916 added COLOR_8_8 targets with CB_COLOR_INFO.COMP_SWAP 1 (SWAP_ALT), but blending into them still throws. PPSA05684 stops in its first level on such a draw: its color blend SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ADD differs from its alpha blend ONE, ONE_MINUS_SRC_ALPHA, ADD.

SWAP_ALT on a two-channel format keeps the x export in the first channel and the alpha export in the second (Mesa si_translate_colorswap, "X__Y"; radeonsi uses it for the luminance-alpha formats, whose second channel is alpha). The color block blends that second channel with the alpha equation.

Changes:

  • Same equation for color and alpha: the draw blends as before, in one pass.

  • Separate alpha equation: the pipeline draws twice.

    • The first pass writes the first channel with the color equation.
    • The second pass writes the second channel, with the alpha factors and operation moved into its color equation. The moved factors keep their meaning, since the second channel of the source holds w.
  • The split throws for:

    • draws that write depth or stencil, or use per-face depth bias;
    • draws whose pixel shader writes memory (written guest buffers or storage images, GDS, address-based access).

    Those draws would run twice.

  • Factors of the destination alpha throw (DST_ALPHA, ONE_MINUS_DST_ALPHA, SRC_ALPHA_SATURATE), since the target keeps that alpha in its second channel.

  • Split pipelines don't use pipeline libraries.

Tests:

  • tests/execution/SwapAltBlend.cpp draws into an 8_8 SWAP_ALT target over known destinations and checks every pixel: three separate-alpha cases (including a reverse-subtract alpha) and one shared equation. Without the second pass the second channel reads 63 where 127.5 is expected.
  • tests/Graphics.cpp (ReversedComponentOrderTests) checks the decode and the split decision.

Tested

  • Arch Linux (kernel 7.2.6), GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.71.09), Release with BUILD_TESTING=ON.
  • Branch built alone; full ctest on main f1ae427b: 751/752; the one failure, agc_driver_dcc_keys_first_write, fails the same way on plain main. Conventions check passed.
  • Title: Uncharted: Legacy of Thieves Collection (PPSA05684), on its own bring-up branch: the draw that stopped the level now blends in two passes and the level continues.

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:4815590797 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3194). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-11T00:52:10Z. --- ### What #2916 added `COLOR_8_8` targets with `CB_COLOR_INFO.COMP_SWAP` 1 (SWAP_ALT), but blending into them still throws. PPSA05684 stops in its first level on such a draw: its color blend `SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ADD` differs from its alpha blend `ONE, ONE_MINUS_SRC_ALPHA, ADD`. SWAP_ALT on a two-channel format keeps the x export in the first channel and the alpha export in the second (Mesa `si_translate_colorswap`, "X__Y"; radeonsi uses it for the luminance-alpha formats, whose second channel is alpha). The color block blends that second channel with the alpha equation. Changes: - **Same equation for color and alpha:** the draw blends as before, in one pass. - **Separate alpha equation:** the pipeline draws twice. - The first pass writes the first channel with the color equation. - The second pass writes the second channel, with the alpha factors and operation moved into its color equation. The moved factors keep their meaning, since the second channel of the source holds w. - **The split throws** for: - draws that write depth or stencil, or use per-face depth bias; - draws whose pixel shader writes memory (written guest buffers or storage images, GDS, address-based access). Those draws would run twice. - **Factors of the destination alpha throw** (`DST_ALPHA`, `ONE_MINUS_DST_ALPHA`, `SRC_ALPHA_SATURATE`), since the target keeps that alpha in its second channel. - Split pipelines don't use pipeline libraries. Tests: - `tests/execution/SwapAltBlend.cpp` draws into an 8_8 SWAP_ALT target over known destinations and checks every pixel: three separate-alpha cases (including a reverse-subtract alpha) and one shared equation. Without the second pass the second channel reads 63 where 127.5 is expected. - `tests/Graphics.cpp` (`ReversedComponentOrderTests`) checks the decode and the split decision. ### Tested - Arch Linux (kernel 7.2.6), GCC 16.2.1, NVIDIA RTX 4070 Ti SUPER (driver 615.71.09), Release with `BUILD_TESTING=ON`. - Branch built alone; full ctest on main f1ae427b: 751/752; the one failure, `agc_driver_dcc_keys_first_write`, fails the same way on plain main. Conventions check passed. - Title: Uncharted: Legacy of Thieves Collection (PPSA05684), on its own bring-up branch: the draw that stopped the level now blends in two passes and the level continues. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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
Silverash-i8 commented 2026-10-11 01:35:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:35:10Z.


Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto main d31b57a4 in one build with #3039, #3134, #3175 and #3194, on an RTX 5060 Laptop and the Arrow Lake iGPU (ANYPS5_GPU=Intel).

  • agc_driver_swap_alt_blend and agc_driver_graphics pass on both GPUs.

Across all agc_* tests in that build, the only new failure on either GPU is agc_driver_flat_store, which comes from #3175 alone (reported there). The Intel failures besides it are the known ones from #2114 and #3207.

AI-assisted (Claude Code); I ran this on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6104244237 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3194#issuecomment-6104244237). Originally posted by [Silverash-i8](https://github.com/Silverash-i8) on 2026-10-11T01:35:10Z. --- Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto `main` d31b57a4 in one build with #3039, #3134, #3175 and #3194, on an RTX 5060 Laptop and the Arrow Lake iGPU (`ANYPS5_GPU=Intel`). - `agc_driver_swap_alt_blend` and `agc_driver_graphics` pass on both GPUs. Across all `agc_*` tests in that build, the only new failure on either GPU is `agc_driver_flat_store`, which comes from #3175 alone (reported there). The Intel failures besides it are the known ones from #2114 and #3207. AI-assisted (Claude Code); I ran this on my machine.
oneandonlydean commented 2026-10-11 05:05:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T05:05:43Z.


Two things before this is tested:

  • CONSTANT_COLOR and ONE_MINUS_CONSTANT_COLOR need a throw next to the destination-alpha factors (State.cpp:751). The second channel holds the guest's alpha, but Vulkan applies blend constant G to it instead of A. That affects the shared-equation pass and the alpha factors moved into the color equation (Pipeline.cpp:391-392).
  • fragmentWritesMemory (Pipeline.cpp:131) only checks the pixel stage, but the second pass runs the earlier stages again too. A vertex or geometry stage that writes memory needs the same throw.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6105682543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3194#issuecomment-6105682543). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-11T05:05:43Z. --- Two things before this is tested: - `CONSTANT_COLOR` and `ONE_MINUS_CONSTANT_COLOR` need a throw next to the destination-alpha factors (`State.cpp:751`). The second channel holds the guest's alpha, but Vulkan applies blend constant G to it instead of A. That affects the shared-equation pass and the alpha factors moved into the color equation (`Pipeline.cpp:391-392`). - `fragmentWritesMemory` (`Pipeline.cpp:131`) only checks the pixel stage, but the second pass runs the earlier stages again too. A vertex or geometry stage that writes memory needs the same throw.
adriadam10 commented 2026-10-11 07:13:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:13:47Z.


Checked on RADV: agc_driver_swap_alt_blend and agc_driver_graphics pass on the PR merged onto main (full AgcDriver ctest scope green after the rebase), the new tests don't build without the change, and the Windows run by @Silverash-i8 covers NVIDIA and Intel.

Added as a commit on your branch:

  • docs/dev/TechnicalDebt.md ("Functional", next to per-face depth bias): the second pass runs the vertex stages again and occlusion counts include both passes; the second-channel/alpha-equation mapping comes from Mesa, not measured on hardware.
  • docs/dev/ARCHITECTURE.md: split pipelines are created whole, without pipeline libraries.

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6106568202 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3194#issuecomment-6106568202). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T07:13:47Z. --- Checked on RADV: `agc_driver_swap_alt_blend` and `agc_driver_graphics` pass on the PR merged onto main (full AgcDriver ctest scope green after the rebase), the new tests don't build without the change, and the Windows run by @Silverash-i8 covers NVIDIA and Intel. Added as a commit on your branch: - `docs/dev/TechnicalDebt.md` ("Functional", next to per-face depth bias): the second pass runs the vertex stages again and occlusion counts include both passes; the second-channel/alpha-equation mapping comes from Mesa, not measured on hardware. - `docs/dev/ARCHITECTURE.md`: split pipelines are created whole, without pipeline libraries. Merging once CI is green.
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!3194
No description provided.