fix(agc): allow independent MIN and MAX in dual-source blends #17187

Merged
PrivacyOnion merged 1 commit from upstream-pr/17187 into main 2026-11-12 11:52:05 +00:00
PrivacyOnion commented 2026-11-08 14:13:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-08T14:13:10Z.


What

A dual-source draw was rejected whenever either the RGB or alpha blend equation used MIN or MAX, including an independent equation with both factors set to ONE. Accept that equation while retaining dual-source blending in the other channels. MIN/MAX with other factors still throws; the existing target, export-layout and device-feature checks remain in force.

Sniper Ghost Warrior Contracts 2 (PPSA03131, 01.004.000) reaches this at entry to the tutorial: CB_BLEND0_CONTROL = 0x61411211, CB_COLOR0_INFO = 0x00040730, target mask 0xf, exports 0x44. RGB is SRC1_ALPHA + ONE_MINUS_SRC1_ALPHA; alpha is MIN with ONE/ONE. Main aborts with dual-source blending with a MIN or MAX operation is unsupported. With this change the tutorial renders and accepts movement, looking and firing input.

The translation uses Vulkan's independent color and alpha equations, where MIN/MAX ignore factors, only when both guest factors are ONE. AMD's PAL Gfx9 color blend setup explicitly sets those factors for unscaled MIN/MAX. Console behavior was not measured and is recorded in debt. There is no shader arithmetic change, title-specific branch or performance claim.

Tested

Windows 11 build 26200, WinLibs MinGW-w64 GCC 15.2.0, Release; NVIDIA GeForce RTX 5070, driver 616.64. Based on main 1086833f9a.

The same focused tests ran on main's graphics implementation and the change:

ANYPS5_REQUIRE_VULKAN=1
ANYPS5_NO_SHADER_CACHE=1
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation
VK_LOADER_LAYERS_DISABLE=~implicit~
ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R '^agc_driver_dual_source_blend' -V
  • Main: agc_driver_dual_source_blend passes; the new agc_driver_dual_source_blend_state fails on the previously rejected MIN/MAX equation. 1/2 pass, 1.47 s.
  • Change: both pass, 0.83 s. The state test covers MIN and MAX independently on RGB and alpha, preserves the second-source factor, and checks 32 unsupported factor combinations still throw. The GPU test checks all pixels inside and outside the scissor for 14 draws, including the four independent MIN/MAX combinations with both FP16_ABGR and 32_ABGR exports.
  • Both focused logs contain zero VUID- errors, zero missing-validation-layer messages and no skipped tests. Reference implementation: this PR's main base 1086833f9a, rebuilt after its shader changes. Final test registration and executable are identical in the two runs.
  • Owned title, relinked with --windows --no-patches, offline, dummy audio, validation enabled: a diagnostic-only error detail on main 522df1e176 confirms the registers above before abort at 246 s. That base plus the same State.cpp fix stays alive until stopped at 471 s; tutorial HUD and weapon are visible at 363 s, then controller input moves the view and a shot changes ammunition from 11 to 10. This title run preceded the final rebase; the focused tests above use the final base. A follow-up diagnostic run of final head f466758d19, with all staged runtime libraries refreshed, draw profiling and worker/committer sampling, also reaches the tutorial and keeps rendering until deliberately stopped at 463 s. This profiling run is not a performance measurement. No other open PR or local functional patch is applied to the staged AGC library. Both title logs have zero VUIDs or missing-layer messages; the candidate has no fatal or driver failure. Shader-output-not-consumed warnings remain.
  • GitHub Windows build/tests, conventions and library portability checks pass for head f466758d19. Linux and the unrelated relinker jobs were skipped by the workflow.
  • First-use shader/pipeline compilation still causes long stalls. This verifies entry to the tutorial and input, not a completed campaign, correct rendering throughout the title or a speed improvement. No Game bring-up discussion for PPSA03131 was found, so the Unblocks checklist field is none.
  • python tools/check_conventions.py --base HEAD^ passes. The required --base origin/main run reports 122 findings / 18 errors in existing upstream changes because the fork's origin/main is behind; none belongs to this commit.

The required overlap scan inspected 1,804 other open PRs against main 1086833f9a; 159 share files or exports. There are no confirmed intersecting hunks, duplicate exports or new-file collisions. It exits 2 because 57 existing branches conflict with main, rather than reporting a clean check. I compared all 57 branch heads against their merge bases across the five shared files: 51 retain the dual-source guard unchanged, and six predate it. The only related additions are #9748 refusing dual-source factors in packed 10_11_11 target merges and #17056 changing typed storage-image access for merges that still refuse dual-source blending. Neither implements this translation. The reported heads, patches and guard comparisons were retained locally; these old branches can still need their own rebases. Depends on none.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070, 616.64, Windows 11 build 26200
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5212020327 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17187). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-08T14:13:10Z. --- ### What A dual-source draw was rejected whenever either the RGB or alpha blend equation used MIN or MAX, including an independent equation with both factors set to ONE. Accept that equation while retaining dual-source blending in the other channels. MIN/MAX with other factors still throws; the existing target, export-layout and device-feature checks remain in force. Sniper Ghost Warrior Contracts 2 (PPSA03131, 01.004.000) reaches this at entry to the tutorial: `CB_BLEND0_CONTROL = 0x61411211`, `CB_COLOR0_INFO = 0x00040730`, target mask `0xf`, exports `0x44`. RGB is `SRC1_ALPHA + ONE_MINUS_SRC1_ALPHA`; alpha is MIN with ONE/ONE. Main aborts with `dual-source blending with a MIN or MAX operation is unsupported`. With this change the tutorial renders and accepts movement, looking and firing input. The translation uses Vulkan's [independent color and alpha equations](https://docs.vulkan.org/spec/latest/chapters/framebuffer.html#framebuffer-blending), where MIN/MAX ignore factors, only when both guest factors are ONE. AMD's [PAL Gfx9 color blend setup](https://github.com/GPUOpen-Drivers/pal/blob/c5e800072a32f68b6ccc4422936d96167c6e0728/src/core/hw/gfxip/gfx9/gfx9ColorBlendState.cpp#L323-L336) explicitly sets those factors for unscaled MIN/MAX. Console behavior was not measured and is recorded in debt. There is no shader arithmetic change, title-specific branch or performance claim. ### Tested Windows 11 build 26200, WinLibs MinGW-w64 GCC 15.2.0, Release; NVIDIA GeForce RTX 5070, driver 616.64. Based on main `1086833f9a`. The same focused tests ran on main's graphics implementation and the change: ``` ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_LAYERS_DISABLE=~implicit~ ctest --test-dir C:/Users/playl/AppData/Local/Temp/ap5p15 -R '^agc_driver_dual_source_blend' -V ``` - Main: `agc_driver_dual_source_blend` passes; the new `agc_driver_dual_source_blend_state` fails on the previously rejected MIN/MAX equation. 1/2 pass, 1.47 s. - Change: both pass, 0.83 s. The state test covers MIN and MAX independently on RGB and alpha, preserves the second-source factor, and checks 32 unsupported factor combinations still throw. The GPU test checks all pixels inside and outside the scissor for 14 draws, including the four independent MIN/MAX combinations with both FP16_ABGR and 32_ABGR exports. - Both focused logs contain zero `VUID-` errors, zero missing-validation-layer messages and no skipped tests. Reference implementation: this PR's main base `1086833f9a`, rebuilt after its shader changes. Final test registration and executable are identical in the two runs. - Owned title, relinked with `--windows --no-patches`, offline, dummy audio, validation enabled: a diagnostic-only error detail on main `522df1e176` confirms the registers above before abort at 246 s. That base plus the same State.cpp fix stays alive until stopped at 471 s; tutorial HUD and weapon are visible at 363 s, then controller input moves the view and a shot changes ammunition from 11 to 10. This title run preceded the final rebase; the focused tests above use the final base. A follow-up diagnostic run of final head `f466758d19`, with all staged runtime libraries refreshed, draw profiling and worker/committer sampling, also reaches the tutorial and keeps rendering until deliberately stopped at 463 s. This profiling run is not a performance measurement. No other open PR or local functional patch is applied to the staged AGC library. Both title logs have zero VUIDs or missing-layer messages; the candidate has no fatal or driver failure. Shader-output-not-consumed warnings remain. - GitHub Windows build/tests, conventions and library portability checks pass for head `f466758d19`. Linux and the unrelated relinker jobs were skipped by the workflow. - First-use shader/pipeline compilation still causes long stalls. This verifies entry to the tutorial and input, not a completed campaign, correct rendering throughout the title or a speed improvement. No Game bring-up discussion for PPSA03131 was found, so the Unblocks checklist field is none. - `python tools/check_conventions.py --base HEAD^` passes. The required `--base origin/main` run reports 122 findings / 18 errors in existing upstream changes because the fork's origin/main is behind; none belongs to this commit. The required overlap scan inspected 1,804 other open PRs against main `1086833f9a`; 159 share files or exports. There are no confirmed intersecting hunks, duplicate exports or new-file collisions. It exits 2 because 57 existing branches conflict with main, rather than reporting a clean check. I compared all 57 branch heads against their merge bases across the five shared files: 51 retain the dual-source guard unchanged, and six predate it. The only related additions are #9748 refusing dual-source factors in packed 10_11_11 target merges and #17056 changing typed storage-image access for merges that still refuse dual-source blending. Neither implements this translation. The reported heads, patches and guard comparisons were retained locally; these old branches can still need their own rebases. Depends on none. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: NVIDIA GeForce RTX 5070, 616.64, Windows 11 build 26200 <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
THEMANnt commented 2026-11-08 20:48:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-11-08T20:48:04Z.

Review: APPROVED


The decoder now checks color and alpha independently. That lets a MIN/MAX equation with ONE factors coexist with an ADD equation that uses the second source, while preserving the refusal for non-ONE factors in the MIN/MAX equation. The state test covers both operations in both channels and checks that the second-source factor survives in the other channel. I verified that agc_driver_dual_source_blend_state ran and passed on this head in hosted Windows. The hosted GPU execution test skipped. The PR reports the pixel-output tests and baseline control on an RTX 5070. I did not independently rerun that hardware test.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5819605992 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/17187#pullrequestreview-5819605992). Originally posted by [THEMANnt](https://github.com/THEMANnt) on 2026-11-08T20:48:04Z. **Review:** APPROVED --- The decoder now checks color and alpha independently. That lets a MIN/MAX equation with ONE factors coexist with an ADD equation that uses the second source, while preserving the refusal for non-ONE factors in the MIN/MAX equation. The state test covers both operations in both channels and checks that the second-source factor survives in the other channel. I verified that `agc_driver_dual_source_blend_state` ran and passed on this head in [hosted Windows](https://github.com/boykopovar/AnyPS5/actions/runs/42488728383/job/128756219155). The hosted GPU execution test skipped. The PR reports the pixel-output tests and baseline control on an RTX 5070. I did not independently rerun that hardware test.
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!17187
No description provided.