Skip to content

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

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:feat/agc-dual-source-blending
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
Celegans12:feat/agc-dual-source-blending

Conversation

@Celegans12

@Celegans12 Celegans12 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed shader core/shader docs agc libSceAgc* labels Oct 8, 2026
@Celegans12
Celegans12 force-pushed the feat/agc-dual-source-blending branch from 7726354 to 66b1396 Compare October 8, 2026 12:01
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 8, 2026
@Celegans12
Celegans12 force-pushed the feat/agc-dual-source-blending branch from 66b1396 to 67d4c89 Compare October 8, 2026 13:55
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 8, 2026
@yahya308

yahya308 commented Oct 8, 2026

Copy link
Copy Markdown

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 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the build label Oct 10, 2026
@Celegans12
Celegans12 force-pushed the feat/agc-dual-source-blending branch from a6573b9 to f97c100 Compare October 10, 2026 06:47
@github-actions github-actions Bot added needs rebase Conflicts with main, rebase needed and removed needs rebase Conflicts with main, rebase needed labels Oct 10, 2026
CB_BLENDn_CONTROL factors 15-18 (BLEND_SRC1_COLOR, BLEND_INV_SRC1_COLOR,
BLEND_SRC1_ALPHA, BLEND_INV_SRC1_ALPHA) threw "unsupported blend
factor". They blend MRT0 with the pixel shader's MRT1 export as the
second source, as RADV and radeonsi program it.

DecodeState maps them to the VK_BLEND_FACTOR_SRC1_* factors and accepts
them only with pixel exports to slots 0 and 1, color writes to slot 0
alone, an MRT1 export with MRT0's export format and shader mask, an
ADD, SUBTRACT or REVERSE_SUBTRACT operation and an identity component
order. The blend is draw state, so the specialized module of the
registered pixel shader moves its MRT1 output to location 0 index 1,
which ValidateShaders requires; pipelines need dualSrcBlend, now enabled
when present. The request field dualSourceBlend is in the module key,
the result memo, the draw key and the serialized request (version 15).
@Celegans12
Celegans12 force-pushed the feat/agc-dual-source-blending branch from f97c100 to b8cc4ad Compare October 10, 2026 08:37
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 10, 2026

@adriadam10 adriadam10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* build docs shader core/shader

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants