fix: refuse dual-source blend factors on render targets other than 0 #1504
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1511"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T13:24:15Z.
Change
Refs #1216.
state_block_blenddecoded all eightCB_BLENDn_CONTROLwords and accepted aSRC1_*(dual-source) factor on any target, as well as blending on targets 1-7 alongside a dual-source target 0. Dual-source blending reads the pixel shader's second output, which exists for render target 0 only, and D3D12 forbids blending on targets 1-7 when target 0 uses dual-source factors (OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0). Both invalid cases are now refused ("dual-source factor on a target other than 0" / "dual-source blend on target 0 with another blending target"), each offending target is set inrefused_targets, and the output is left alone (the caller keeps its previous path, as for any refused word). Target 0 with targets 1-7 disabled (ENABLEclear) is accepted, and a target withENABLEclear uses no factor and is not refused.Audit result for the other points of the blend headers (no change needed): a 40-million-word sweep of
cb_blend::decode(every field value including undefined factors 21-31 and combine functions 5-7, words with all bits set, with and without alpha-factor support) never produced an out-of-rangeD3D12_BLEND/D3D12_BLEND_OP, a colour-only factor in an alpha slot,BlendEnabletogether withLogicOpEnable, a write mask above 0xF, or a refusal without a reason.Verification
x86_64-w64-mingw32-g++ -std=c++17 -Wall -Wextra -Werror -static -Isrc -o sbb.exe tests/startup_state_block_blend_check.cpp && wine sbb.exe->startup_state_block_blend: PASS (4 measured words, enable clear, 5 controls, dual source)state_block_blend.hfromorigin/main: fails ondual source on target > 0anddual source on target 0 with blending target > 0, exit 1.git diff --check origin/main...HEAD,tests/docs_links_check.py,tests/bidi_controls_check.py: clean.--preset dev) and Release/O2(--preset release):ctest --preset <preset> -R '^startup_state_block_blend' --no-tests=error --output-on-failure-> 1/1 passed (details in PR comment).Evidence and follow-up
Synthetic state blocks built in the test; no captured data. Assumption: the dual-source rules (target 0 only, and no other blending target alongside dual-source target 0) follow the D3D12/Vulkan blend rules and the hardware's single second export. Not changed, candidates for separate work: the stream and derived-patch blend descriptors are copied without range checks;
find_blendaccepts factors up to 19 only (missesALPHA_FACTOR/INV_ALPHA_FACTOR); blending on integer render target formats is not checked inpipeline_for.Checklist
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:09:17Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
ae2fe983aa3e7fb670bfc3ec0456de0d7dbd79f9:--preset dev):cmake --build --preset dev --target startup_state_block_blend_check -- -j 6):4.00s(configure1.81s)ctest --preset dev -R '^startup_state_block_blend' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (0.08s:startup_state_block_blend0.01s)/O2(--preset release):cmake --build --preset release --target startup_state_block_blend_check -- -j 6):1.50s(configure1.82s)ctest --preset release -R '^startup_state_block_blend' --parallel 4 --no-tests=error --output-on-failure): 1/1 passed (0.08s:startup_state_block_blend0.01s)sccache: 0/2 hits; wall14.9sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T14:09:29Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
ae2fe98ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T14:50:16Z.
Both halves of the dual-source rule are covered
Independent reviewer, not the author. Reviewed
ae2fe983; nothing pushed to the branch. Mutations were made locally insrc/startup_stubs/state_block_blend.h, rebuilt, reverted; working tree is clean.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100.
startup_state_block_blend: PASS (4 measured words, enable clear, 5 controls, dual source)as submitted.The rule under test
Mutation 1 — only refuse a dual factor on a non-zero target
So the "target 0 is dual-source and another target also blends" half is genuinely exercised, not just described.
Mutation 2 — refuse but do not report which target
refused_targetsis asserted per bit, so the caller can tell which target was rejected rather than only that somethingwas.
Worth knowing
The two failures report
32 FAILEDand62 FAILEDwith no per-case name in the summary line, so from ctest output aloneit is not obvious which control broke. The count is enough to see a regression landed, and the test prints per-case
detail under
-V; I mention it only because a one-line "first failing control: …" would make a future bisect faster.Not a request.
Verdict
Reviewed
ae2fe983. Builds clean, the fixture passes, and both halves of the rule plus the per-target reporting are eachcaught when removed. No objection from me.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:55:55Z.
Thanks for the independent review and local mutation verification on Windows 11 26300, @ChazY11.