runtime: express CONSTANT_ALPHA on the alpha channel without the alpha blend factor feature #2523

Merged
Asimmimx merged 2 commits from upstream-pr/2531 into main 2026-11-25 20:24:21 +00:00
Asimmimx commented 2026-11-25 20:10:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-25T20:10:16Z.


Summary

When AlphaBlendFactorSupported is false, cb_blend.h now maps CONSTANT_ALPHA / ONE_MINUS_CONSTANT_ALPHA in the alpha factor fields to BLEND_FACTOR / INV_BLEND_FACTOR, which mean the same thing on the alpha channel. The new helper is detail::alpha_factor.

  • The colour fields still need ALPHA_FACTOR and are still refused without it.
  • With the feature on, the output is unchanged (ALPHA_FACTOR).

Fixes #2528

Tests

  • startup_cb_blend_decode now expects this mapping in both alpha slots for every factor value, and for raw word 0x74331291 without the feature. It adds raw 0x72911433, with CONSTANT_ALPHA in the colour fields, which must still be refused.
  • startup_state_block_blend gains a block with separate CONSTANT_ALPHA alpha factors.

Windows 11 26300, dev preset:

cmake --build --preset dev --target startup_cb_blend_check startup_state_block_blend_check
ctest --preset dev --no-tests=error -R '^(startup_cb_blend_decode|startup_cb_blend_decode_dest_alpha_control|startup_state_block_blend)$'

3 of 3 passed:

  • startup_cb_blend_decode: 527 cases.
  • startup_state_block_blend: passed.
  • startup_cb_blend_decode_dest_alpha_control (WILL_FAIL): still fails as intended, 26 of 527.

Fail-first

With the header reverted and the tests unchanged:

FAIL alpha source factor 19: refused: CONSTANT_ALPHA factor without alpha blend factor support
FAIL alpha source factor 20: refused: ...
FAIL alpha destination factor 19: refused: ...
FAIL alpha destination factor 20: refused: ...
FAIL raw 74331291: refused: CONSTANT_ALPHA factor without alpha blend factor support
startup_cb_blend_decode: 5 of 527 FAILED
FAIL constant alpha on the alpha channel: CONSTANT_ALPHA factor without alpha blend factor support
startup_state_block_blend: 1 FAILED

A WARP equivalence check (a source-built scratch program, not added here) read back 0.9000 for both alpha BLEND_FACTOR/INV_BLEND_FACTOR and ALPHA_FACTOR/INV_ALPHA_FACTOR, against 0.9 expected.

Not run / open

  • startup_cb_blend_warp / _hardware (they need offscreen_check). Those draws check only the colour source slot, whose behaviour is unchanged.
  • How often a title uses this form is not known.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6612805078 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2531). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-25T20:10:16Z. --- ## Summary When `AlphaBlendFactorSupported` is false, `cb_blend.h` now maps `CONSTANT_ALPHA` / `ONE_MINUS_CONSTANT_ALPHA` in the alpha factor fields to `BLEND_FACTOR` / `INV_BLEND_FACTOR`, which mean the same thing on the alpha channel. The new helper is `detail::alpha_factor`. - The colour fields still need `ALPHA_FACTOR` and are still refused without it. - With the feature on, the output is unchanged (`ALPHA_FACTOR`). Fixes #2528 ## Tests - `startup_cb_blend_decode` now expects this mapping in both alpha slots for every factor value, and for raw word `0x74331291` without the feature. It adds raw `0x72911433`, with `CONSTANT_ALPHA` in the colour fields, which must still be refused. - `startup_state_block_blend` gains a block with separate `CONSTANT_ALPHA` alpha factors. Windows 11 26300, dev preset: ``` cmake --build --preset dev --target startup_cb_blend_check startup_state_block_blend_check ctest --preset dev --no-tests=error -R '^(startup_cb_blend_decode|startup_cb_blend_decode_dest_alpha_control|startup_state_block_blend)$' ``` 3 of 3 passed: - `startup_cb_blend_decode`: 527 cases. - `startup_state_block_blend`: passed. - `startup_cb_blend_decode_dest_alpha_control` (WILL_FAIL): still fails as intended, 26 of 527. ## Fail-first With the header reverted and the tests unchanged: ``` FAIL alpha source factor 19: refused: CONSTANT_ALPHA factor without alpha blend factor support FAIL alpha source factor 20: refused: ... FAIL alpha destination factor 19: refused: ... FAIL alpha destination factor 20: refused: ... FAIL raw 74331291: refused: CONSTANT_ALPHA factor without alpha blend factor support startup_cb_blend_decode: 5 of 527 FAILED FAIL constant alpha on the alpha channel: CONSTANT_ALPHA factor without alpha blend factor support startup_state_block_blend: 1 FAILED ``` A WARP equivalence check (a source-built scratch program, not added here) read back 0.9000 for both alpha `BLEND_FACTOR`/`INV_BLEND_FACTOR` and `ALPHA_FACTOR`/`INV_ALPHA_FACTOR`, against 0.9 expected. ## Not run / open - `startup_cb_blend_warp` / `_hardware` (they need `offscreen_check`). Those draws check only the colour source slot, whose behaviour is unchanged. - How often a title uses this form is not known. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-25 21:01:18 +00:00
tedin7 commented 2026-11-25 21:01:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:18:32Z.

Review: COMMENTED


Review of head cfbc4234 (comment only, no approval).

Code: detail::alpha_factor in cb_blend.h maps CONSTANT_ALPHA / ONE_MINUS_CONSTANT_ALPHA to BLEND_FACTOR / INV_BLEND_FACTOR in the two alpha slots only when AlphaBlendFactorSupported is false. On the alpha channel those read the constant's alpha, so the meaning is the same. alpha_form() leaves them unchanged, and the colour slots still use factor() and are still refused without the feature. With the feature on, the output is the same as before. The only blend constant the stubs set is OMSetBlendFactor (slot 21), so there is no separate alpha constant to keep in sync.

Checked locally:

  • Diff is limited to cb_blend.h and the two existing blend check files. They extend the existing suites: startup_cb_blend_decode covers every factor value in both alpha slots plus raw words, and startup_state_block_blend gets one new block.
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py, git diff --check origin/main...HEAD: clean.
  • No other open or merged PR covers this slice (CONSTANT_ALPHA search).
  • The check includes D3D12 headers, so I could not build or mutate it on Linux. The fail-first in the PR body shows the new cases fail without the header change. The Win2025 receipt comes after this review.

Notes:

  • This is a decode-table change with fixture tests. It makes no claim about game startup, and I am not claiming any game result.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064360075 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2531#pullrequestreview-6064360075). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:18:32Z. **Review:** COMMENTED --- Review of head cfbc4234 (comment only, no approval). Code: `detail::alpha_factor` in `cb_blend.h` maps CONSTANT_ALPHA / ONE_MINUS_CONSTANT_ALPHA to BLEND_FACTOR / INV_BLEND_FACTOR in the two alpha slots only when AlphaBlendFactorSupported is false. On the alpha channel those read the constant's alpha, so the meaning is the same. `alpha_form()` leaves them unchanged, and the colour slots still use `factor()` and are still refused without the feature. With the feature on, the output is the same as before. The only blend constant the stubs set is `OMSetBlendFactor` (slot 21), so there is no separate alpha constant to keep in sync. Checked locally: - Diff is limited to `cb_blend.h` and the two existing blend check files. They extend the existing suites: `startup_cb_blend_decode` covers every factor value in both alpha slots plus raw words, and `startup_state_block_blend` gets one new block. - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py`, `git diff --check origin/main...HEAD`: clean. - No other open or merged PR covers this slice (`CONSTANT_ALPHA` search). - The check includes D3D12 headers, so I could not build or mutate it on Linux. The fail-first in the PR body shows the new cases fail without the header change. The Win2025 receipt comes after this review. Notes: - This is a decode-table change with fixture tests. It makes no claim about game startup, and I am not claiming any game result. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 21:01:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:23:52Z.


Win2025 WARP receipt for head 1cb88bd3 after updating with main.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 1cb88bd3622ff8ab5efa00ca52306e40b3bd2f2d:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_cb_blend_check startup_state_block_blend_check -- -j 2): 32.89s (configure 2.48s)
    • Test (ctest --preset dev -R '^(startup_cb_blend|startup_state_block_blend)' --parallel 6 --no-tests=error --output-on-failure): 7/7 passed (0.33s: startup_cb_blend_decode 0.03s, startup_state_block_blend 0.02s, startup_cb_blend_decode_dest_alpha_control 0.02s, startup_cb_blend_swapped_warp 0.14s, startup_cb_blend_warp 0.13s, startup_cb_blend_hardware 0.12s, startup_cb_blend_swapped_hardware 0.12s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_cb_blend_check startup_state_block_blend_check -- -j 2): 63.51s (configure 2.52s)
    • Test (ctest --preset release -R '^(startup_cb_blend|startup_state_block_blend)' --parallel 6 --no-tests=error --output-on-failure): 7/7 passed (0.23s: startup_cb_blend_decode 0.03s, startup_state_block_blend 0.02s, startup_cb_blend_decode_dest_alpha_control 0.01s, startup_cb_blend_swapped_warp 0.09s, startup_cb_blend_warp 0.10s, startup_cb_blend_hardware 0.09s, startup_cb_blend_swapped_hardware 0.09s)
  • sccache: 0/10 hits; wall 108.9s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173610270 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2531#issuecomment-7173610270). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T20:23:52Z. --- Win2025 WARP receipt for head 1cb88bd3 after updating with main. Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `1cb88bd3622ff8ab5efa00ca52306e40b3bd2f2d`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_cb_blend_check startup_state_block_blend_check -- -j 2`): `32.89s` (configure `2.48s`) - Test (`ctest --preset dev -R '^(startup_cb_blend|startup_state_block_blend)' --parallel 6 --no-tests=error --output-on-failure`): **7/7 passed** (`0.33s`: `startup_cb_blend_decode` `0.03s`, `startup_state_block_blend` `0.02s`, `startup_cb_blend_decode_dest_alpha_control` `0.02s`, `startup_cb_blend_swapped_warp` `0.14s`, `startup_cb_blend_warp` `0.13s`, `startup_cb_blend_hardware` `0.12s`, `startup_cb_blend_swapped_hardware` `0.12s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_cb_blend_check startup_state_block_blend_check -- -j 2`): `63.51s` (configure `2.52s`) - Test (`ctest --preset release -R '^(startup_cb_blend|startup_state_block_blend)' --parallel 6 --no-tests=error --output-on-failure`): **7/7 passed** (`0.23s`: `startup_cb_blend_decode` `0.03s`, `startup_state_block_blend` `0.02s`, `startup_cb_blend_decode_dest_alpha_control` `0.01s`, `startup_cb_blend_swapped_warp` `0.09s`, `startup_cb_blend_warp` `0.10s`, `startup_cb_blend_hardware` `0.09s`, `startup_cb_blend_swapped_hardware` `0.09s`) - `sccache`: 0/10 hits; wall `108.9s` AI-assisted; commands listed were executed locally.
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
R0Y00/Xbox2Windows!2523
No description provided.