feat(agc): implement dual-source blending from the MRT1 export #1492

Merged
Celegans12 merged 1 commit from upstream-pr/1492 into main 2026-10-10 09:01:17 +00:00
Celegans12 commented 2026-10-08 09:08:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Celegans12 on 2026-10-08T09:08:46Z.


What

Blend factors 15–18 currently throw. This maps them to VK_BLEND_FACTOR_SRC1_*, using the pixel shader's MRT1 export as MRT0's second source. The factor encodings follow Mesa's gfx103 register definitions.

Accepted draws export slots 0 and 1, write only slot 0, use matching export formats and shader masks, identity component order, and ADD, SUBTRACT or REVERSE_SUBTRACT. Other layouts and MIN/MAX still throw; the remaining restrictions are recorded in TechnicalDebt.

Registered pixel shaders remain generic. Draw specialization places MRT1 at Location 0, Index 1; pipelines require dualSrcBlend, enabled when available. The flag participates in draw and materialization keys. Request version 15 follows main's packed-export version 14; older requests default the flag to false. Cache format 23 and runtime ABI 11 are unchanged.

An earlier PPSA26344 v1.008 capture uses ONE + SRC1_COLOR with FP16 MRT0/MRT1 exports into an RGBA16F target. This restack contains only dual-source changes now that #1485 has merged.

Tested

  • Rebased on main f6af6d11. Current head b8cc4adb resolves only the TechnicalDebt conflict; all 599 added/removed topic lines are unchanged. Source reviews, conventions and whitespace checks pass. This head has not been rebuilt or retested.
  • Existing execution evidence: f97c1009, tested as merge 0f3c7b5c with frozen main 092e133e, on Windows 11, MinGW-w64 GCC 15.2.0, RTX 3080 Laptop, -DBUILD_TESTING=ON: configure, five-target build, registration and 5/5 CTests pass; zero skips, 14.42 s.
  • Those tests cover three SRC1 blends, Float32/FP16 exports, four destination colors and untouched scissors (agc_driver_dual_source_blend), DualSourceBlendTests in agc_driver_graphics, request compatibility in agc_shader_memory, packed-UNORM color targets and UINT16 exports.
  • Historical full suites on main f1451396: Windows 490/490, Linux/llvmpipe 499/499. Not tested for this rebase: a fresh full suite, Linux, game execution or console behavior.

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:4784458107 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1492). Originally posted by [Celegans12](https://github.com/Celegans12) on 2026-10-08T09:08:46Z. --- ### What Blend factors 15–18 currently throw. This maps them to `VK_BLEND_FACTOR_SRC1_*`, using the pixel shader's MRT1 export as MRT0's second source. The factor encodings follow Mesa's [gfx103 register definitions](https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/src/amd/registers/gfx103.json). Accepted draws export slots 0 and 1, write only slot 0, use matching export formats and shader masks, identity component order, and ADD, SUBTRACT or REVERSE_SUBTRACT. Other layouts and MIN/MAX still throw; the remaining restrictions are recorded in TechnicalDebt. Registered pixel shaders remain generic. Draw specialization places MRT1 at `Location 0, Index 1`; pipelines require `dualSrcBlend`, enabled when available. The flag participates in draw and materialization keys. Request version 15 follows main's packed-export version 14; older requests default the flag to false. Cache format 23 and runtime ABI 11 are unchanged. An earlier PPSA26344 v1.008 capture uses `ONE + SRC1_COLOR` with FP16 MRT0/MRT1 exports into an RGBA16F target. This restack contains only dual-source changes now that #1485 has merged. ### Tested - Rebased on `main` f6af6d11. Current head `b8cc4adb` resolves only the TechnicalDebt conflict; all 599 added/removed topic lines are unchanged. Source reviews, conventions and whitespace checks pass. This head has not been rebuilt or retested. - Existing execution evidence: `f97c1009`, tested as merge `0f3c7b5c` with frozen main `092e133e`, on Windows 11, MinGW-w64 GCC 15.2.0, RTX 3080 Laptop, `-DBUILD_TESTING=ON`: configure, five-target build, registration and 5/5 CTests pass; zero skips, 14.42 s. - Those tests cover three SRC1 blends, Float32/FP16 exports, four destination colors and untouched scissors (`agc_driver_dual_source_blend`), `DualSourceBlendTests` in `agc_driver_graphics`, request compatibility in `agc_shader_memory`, packed-UNORM color targets and UINT16 exports. - Historical full suites on main `f1451396`: Windows 490/490, Linux/llvmpipe 499/499. Not tested for this rebase: a fresh full suite, Linux, game execution or console behavior. ### 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
yahya308 commented 2026-10-08 15:28:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by yahya308 on 2026-10-08T15:28:54Z.


Tested on top of main 9e2ffe0d, Windows 11, MinGW-w64 GCC 16.2.0, full ctest with ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3, NVIDIA RTX 4070 Laptop (32.0.16.1074) and AMD Radeon 780M (32.0.31041.1004). vopc_compare_table fails on the 780M on main too (#825, #1473).

Head 67d4c898, with #1485 underneath: NVIDIA 459/459, 780M 458/459. The new dual_source_blend and packed_unorm_color_target tests ran and passed on both.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6063310143 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1492#issuecomment-6063310143). Originally posted by [yahya308](https://github.com/yahya308) on 2026-10-08T15:28:54Z. --- Tested on top of main `9e2ffe0d`, Windows 11, MinGW-w64 GCC 16.2.0, full ctest with `ANYPS5_REQUIRE_VULKAN=1 --repeat until-fail:3`, NVIDIA RTX 4070 Laptop (32.0.16.1074) and AMD Radeon 780M (32.0.31041.1004). `vopc_compare_table` fails on the 780M on main too (#825, #1473). Head `67d4c898`, with #1485 underneath: NVIDIA 459/459, 780M 458/459. The new `dual_source_blend` and `packed_unorm_color_target` tests ran and passed on both. AI-assisted: yes (Claude Code).
adriadam10 commented 2026-10-10 00:02:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T00:02:28Z.

Review: CHANGES_REQUESTED


Thanks. This is stacked on #1485, which isn't merged yet, so this branch still carries its commit (d41f24f29) and can't land as is. It also conflicts with main in core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp (the color-export validation changed with #1073/#1074).

  • Please wait for #1485 to land (or drop the dependency), then rebase so the branch contains only the dual-source commit, and resolve the ShaderValidation.cpp conflict.
  • After the rebase, rerun the PR's tests (agc_driver_dual_source_blend, DualSourceBlendTests, agc_shader_memory) and update the request-version number if main or a merged PR took it meanwhile.

I haven't reviewed the code itself yet; it'll be reviewed once the diff is just this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5476488118 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1492#pullrequestreview-5476488118). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T00:02:28Z. **Review:** CHANGES_REQUESTED --- Thanks. This is stacked on #1485, which isn't merged yet, so this branch still carries its commit (`d41f24f29`) and can't land as is. It also conflicts with `main` in `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderValidation.cpp` (the color-export validation changed with #1073/#1074). - Please wait for #1485 to land (or drop the dependency), then rebase so the branch contains only the dual-source commit, and resolve the `ShaderValidation.cpp` conflict. - After the rebase, rerun the PR's tests (`agc_driver_dual_source_blend`, `DualSourceBlendTests`, `agc_shader_memory`) and update the request-version number if `main` or a merged PR took it meanwhile. I haven't reviewed the code itself yet; it'll be reviewed once the diff is just this change.
adriadam10 commented 2026-10-10 09:01:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T09:01:13Z.

Review: APPROVED


Checked on current main: build + ctest of libSceAgcDriver/libSceAgc green, agc_driver_dual_source_blend runs on RADV and on CI's lavapipe, the new tests don't compile without the change, blend factors 15-18 match Mesa's gfx103 encodings, unmodelled layouts and MIN/MAX still throw and the assumption is in TechnicalDebt. Windows runs by @yahya308 on NVIDIA and AMD also pass. Merging once the full Linux/Windows build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5478398150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1492#pullrequestreview-5478398150). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T09:01:13Z. **Review:** APPROVED --- Checked on current `main`: build + ctest of libSceAgcDriver/libSceAgc green, `agc_driver_dual_source_blend` runs on RADV and on CI's lavapipe, the new tests don't compile without the change, blend factors 15-18 match Mesa's gfx103 encodings, unmodelled layouts and MIN/MAX still throw and the assumption is in TechnicalDebt. Windows runs by @yahya308 on NVIDIA and AMD also pass. Merging once the full Linux/Windows build 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!1492
No description provided.