shader: lower the exact SDWA cndmask select #3669

Closed
lambirou wants to merge 1 commit from upstream-pr/3669 into main
lambirou commented 2026-11-30 22:56:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T22:56:39Z.


Problem

v_cndmask_b32_sdwa is still unobserved for gfx1013 and gfx1030. Its VOP2 form has an implicit vcc/vcc_lo mask and no src2; the existing SDWA path only handled the non-SDWA select or refused the form.

The open #3605 also contains this form as part of a four-form binary16 patch. Its review requested changes because its lowering emitted condition ? src0 : src1, the reverse of VCC ? src1 : src0, and its reference repeated that inversion. This branch isolates the corrected select only.

Change

tools/pixel_aot.py lowers exactly v_cndmask_b32_sdwa vD, src0, src1, vcc[_lo] dst_sel:... dst_unused:... src0_sel:... src1_sel:... using the existing sdwa_source and sdwa_dest helpers. The selected src1 field is chosen when the tracked VCC bit is set and the selected src0 field otherwise; destination placement uses UNUSED_PAD or UNUSED_PRESERVE over a tracked old destination.

This slice refuses sext(), UNUSED_SEXT, SGPR/literal sources, non-vcc masks, untracked masks, clamp/float modifiers, missing or extra SDWA fields, out-of-range VGPRs, sample read/write overlaps and a non-entry EXEC mask. The scanner accepts the same exact shape.

The fixture draw-sdwa-cndmask has four programs and three runtime rows covering every dst_sel and src0_sel/src1_sel field, PAD/PRESERVE, a plain-v_cndmask_b32_e32 tie, signed/high-bit words and distinct high/low halves. Its eleven mutations each mismatch on both adapters; check_sdwa_cndmask_forms pins exactly ("SDWA", "v_cndmask_b32_sdwa").

Coordination

The cndmask portion of #3605 is the same source form. If #3605 is amended with this correction first, this PR is redundant and should be dropped; otherwise #3605 should remove its cndmask portion before merging both.

Verification

cmake --preset dev -DINTAKE_PYTHON=C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe
cmake --build --preset dev
ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_cndmask_(warp|hardware)$' -V
python -B tests/pixel_aot_check.py
python -B tests/form_coverage_check.py
python -B tests/rdna2_tools_check.py
python -B tests/docs_links_check.py
python -B tests/bidi_controls_check.py
  • Build dev: passed, 3,546/3,546 Ninja steps.
  • pixel_aot_sdwa_cndmask_hardware: passed, 18.41 s.
  • pixel_aot_sdwa_cndmask_warp: passed, 7.77 s.
  • No CTest skips. WARP: Microsoft Basic Render Driver 1414:008c, driver 10.0.26100.10068. Hardware: AMD Radeon RX 9060 XT 1002:7590, driver 32.0.32029.2010, Windows 11 build 26300, D3D12 debug layer unavailable, DXC 1.8.2502.11.
  • pixel_aot_check.py: passed; form_coverage_check.py: form coverage checks passed; rdna2_tools_check.py: 162 tests OK with 19 LLVM-dependent skips; docs and bidi checks passed.
  • Isolated record difference against the same fixture with the plain select: +1 form in gfx1013 and +1 in gfx1030. No full-table count is claimed.

Limits

No console measurement or title run. Only VGPR sources are modeled; sext() and UNUSED_SEXT are deliberately refused. The fixture measures translated HLSL on WARP and one physical RDNA 4 adapter, not native RDNA 2 behavior.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5575288819 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3669). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-30T22:56:39Z. --- ## Problem `v_cndmask_b32_sdwa` is still `unobserved` for gfx1013 and gfx1030. Its VOP2 form has an implicit `vcc`/`vcc_lo` mask and no `src2`; the existing SDWA path only handled the non-SDWA select or refused the form. The open [#3605](https://github.com/R0Y00/Xbox2Windows/pull/3605) also contains this form as part of a four-form binary16 patch. Its review requested changes because its lowering emitted `condition ? src0 : src1`, the reverse of `VCC ? src1 : src0`, and its reference repeated that inversion. This branch isolates the corrected select only. ## Change `tools/pixel_aot.py` lowers exactly `v_cndmask_b32_sdwa vD, src0, src1, vcc[_lo] dst_sel:... dst_unused:... src0_sel:... src1_sel:...` using the existing `sdwa_source` and `sdwa_dest` helpers. The selected src1 field is chosen when the tracked VCC bit is set and the selected src0 field otherwise; destination placement uses `UNUSED_PAD` or `UNUSED_PRESERVE` over a tracked old destination. This slice refuses `sext()`, `UNUSED_SEXT`, SGPR/literal sources, non-`vcc` masks, untracked masks, `clamp`/float modifiers, missing or extra SDWA fields, out-of-range VGPRs, sample read/write overlaps and a non-entry EXEC mask. The scanner accepts the same exact shape. The fixture `draw-sdwa-cndmask` has four programs and three runtime rows covering every `dst_sel` and `src0_sel`/`src1_sel` field, PAD/PRESERVE, a plain-`v_cndmask_b32_e32` tie, signed/high-bit words and distinct high/low halves. Its eleven mutations each mismatch on both adapters; `check_sdwa_cndmask_forms` pins exactly `("SDWA", "v_cndmask_b32_sdwa")`. ## Coordination The cndmask portion of #3605 is the same source form. If #3605 is amended with this correction first, this PR is redundant and should be dropped; otherwise #3605 should remove its cndmask portion before merging both. ## Verification ```text cmake --preset dev -DINTAKE_PYTHON=C:/Users/rolandedi/dev/labs/xbox-recomp/Xbox2Windows/out/pe-env/Scripts/python.exe cmake --build --preset dev ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_cndmask_(warp|hardware)$' -V python -B tests/pixel_aot_check.py python -B tests/form_coverage_check.py python -B tests/rdna2_tools_check.py python -B tests/docs_links_check.py python -B tests/bidi_controls_check.py ``` - Build `dev`: passed, 3,546/3,546 Ninja steps. - `pixel_aot_sdwa_cndmask_hardware`: passed, 18.41 s. - `pixel_aot_sdwa_cndmask_warp`: passed, 7.77 s. - No CTest skips. WARP: Microsoft Basic Render Driver `1414:008c`, driver `10.0.26100.10068`. Hardware: AMD Radeon RX 9060 XT `1002:7590`, driver `32.0.32029.2010`, Windows 11 build `26300`, D3D12 debug layer unavailable, DXC `1.8.2502.11`. - `pixel_aot_check.py`: passed; `form_coverage_check.py`: `form coverage checks passed`; `rdna2_tools_check.py`: 162 tests OK with 19 LLVM-dependent skips; docs and bidi checks passed. - Isolated record difference against the same fixture with the plain select: **+1 form** in gfx1013 and **+1** in gfx1030. No full-table count is claimed. ## Limits No console measurement or title run. Only VGPR sources are modeled; `sext()` and `UNUSED_SEXT` are deliberately refused. The fixture measures translated HLSL on WARP and one physical RDNA 4 adapter, not native RDNA 2 behavior. AI-assisted.
lambirou commented 2026-11-30 23:10:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lambirou on 2026-11-30T23:10:17Z.


The corrected cndmask lowering is folded into #3605 at b7c0c70f: VCC selects src1 and otherwise src0, the reference and plain-e32 tie are fixed, and the VGPR-only/refusals and fixtures are in #3605. #3605 is green on run 46533421137. Closing this standalone duplicate without merging.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7294796393 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3669#issuecomment-7294796393). Originally posted by [lambirou](https://github.com/lambirou) on 2026-11-30T23:10:17Z. --- The corrected cndmask lowering is folded into #3605 at b7c0c70f: VCC selects src1 and otherwise src0, the reference and plain-e32 tie are fixed, and the VGPR-only/refusals and fixtures are in #3605. #3605 is green on run 46533421137. Closing this standalone duplicate without merging.

Pull request closed

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!3669
No description provided.