shader: accept the SDWA form of mesh v_cmpx_lt_u32 (Part of #3703) #3947

Open
mumba17 wants to merge 1 commit from upstream-pr/3947 into main
mumba17 commented 2026-12-03 16:45:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-03T16:45:27Z.


Part of #3703 (X1, the SDWA slice: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7384615850).

Problem

The mesh frontend lowers v_cmpx_lt_u32 only in its plain VOPC and VOP3 forms (plain_cmpx_lt requires !i.subword). The SDWA form, a compare of one 16-bit half (src0_sel:WORD_0) with an s_cbranch_execz after it, was refused with unsupported mesh instruction or EXEC state: v_cmpx_lt_u32. #3922 and the CMPX paths in #3886/#3666 keep SDWA refused as well.

Change

plain_cmpx_lt accepts SDWA. Nothing else was needed for the compare itself:

  • The decoder already refuses an SDWA CMPX with an explicit SGPR destination (invalid SDWA compare destination) and integer abs/neg.
  • The shared comparison applies each source's WORD/BYTE select and sign extension.

So the SDWA form narrows EXEC exactly like the plain one, and VCC stays unwritten. The one place that reads the whole operand as a lane-linear thread index, the export-count bound, now requires a non-SDWA compare: a bound taken from half a thread index would be wrong.

Tests (native_direct_mesh)

  • v-cmpx-lt-sdwa-word0: v_cmpx_lt_u32_sdwa v0, v2 src0_sel:WORD_0 narrows EXEC with icmp ult on and v0, 65535, with no VCC ballot.
  • v-cmpx-lt-sdwa-word1: src0_sel:WORD_1 compares (v0 >> 16) & 65535.
  • v-cmpx-lt-sdwa-sgpr-destination: SD set (explicit SGPR destination) is still refused.
  • Mutation check: with the source change reverted, v-cmpx-lt-sdwa-word0 fails with the v_cmpx_lt_u32 refusal.

Census

Our native Mesh86 capture (RTX 3090, 600 s): 6,685 distinct .m86 programs, each run once through compile_dxil … gfx1013-container-ms-texture-heap.

  • main c6a0b036 (with #3922): 2,163 translate. 178 stop at v_cmpx_lt_u32, and in this capture all 178 are this SDWA form.
  • With this change: 2,163 translate, 0 lost. All 178 move on, all to a later v_readfirstlane_b32. No other program's first refusal changes.
  • With #3946 as well (now merged): still 2,163, 0 lost. The 99 that #3946 moves to v_cmpx_lt_u32 get past it too, and all 277 then stop at a later v_readfirstlane_b32. These programs have several walls in a row.

Counts only; request bytes stay local.

Checks

Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. ctest --preset pr on this commit (rebased on main 4324d81f, which has #3945 and #3946): 349/351 pass, native_direct_mesh included. The two local failures, native_compute_implicit_lod_controls and native_wave_virtual_derivative_controls, are the local SDK validator 1.7 vs DXIL 1.8 and fail on main too. The census was measured before the rebase (c6a0b036, and c6a0b036 + #3946) and not rerun on 4324d81f.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5630868406 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3947). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-03T16:45:27Z. --- Part of #3703 (X1, the SDWA slice: https://github.com/R0Y00/Xbox2Windows/issues/3703#issuecomment-7384615850). ## Problem The mesh frontend lowers `v_cmpx_lt_u32` only in its plain VOPC and VOP3 forms (`plain_cmpx_lt` requires `!i.subword`). The SDWA form, a compare of one 16-bit half (`src0_sel:WORD_0`) with an `s_cbranch_execz` after it, was refused with `unsupported mesh instruction or EXEC state: v_cmpx_lt_u32`. #3922 and the CMPX paths in #3886/#3666 keep SDWA refused as well. ## Change `plain_cmpx_lt` accepts SDWA. Nothing else was needed for the compare itself: - The decoder already refuses an SDWA CMPX with an explicit SGPR destination (`invalid SDWA compare destination`) and integer abs/neg. - The shared `comparison` applies each source's WORD/BYTE select and sign extension. So the SDWA form narrows EXEC exactly like the plain one, and VCC stays unwritten. The one place that reads the whole operand as a lane-linear thread index, the export-count bound, now requires a non-SDWA compare: a bound taken from half a thread index would be wrong. ## Tests (`native_direct_mesh`) - `v-cmpx-lt-sdwa-word0`: `v_cmpx_lt_u32_sdwa v0, v2 src0_sel:WORD_0` narrows EXEC with `icmp ult` on `and v0, 65535`, with no VCC ballot. - `v-cmpx-lt-sdwa-word1`: `src0_sel:WORD_1` compares `(v0 >> 16) & 65535`. - `v-cmpx-lt-sdwa-sgpr-destination`: SD set (explicit SGPR destination) is still refused. - Mutation check: with the source change reverted, `v-cmpx-lt-sdwa-word0` fails with the `v_cmpx_lt_u32` refusal. ## Census Our native Mesh86 capture (RTX 3090, 600 s): 6,685 distinct `.m86` programs, each run once through `compile_dxil … gfx1013-container-ms-texture-heap`. - `main` `c6a0b036` (with #3922): 2,163 translate. 178 stop at `v_cmpx_lt_u32`, and in this capture all 178 are this SDWA form. - With this change: 2,163 translate, 0 lost. All 178 move on, all to a later `v_readfirstlane_b32`. No other program's first refusal changes. - With #3946 as well (now merged): still 2,163, 0 lost. The 99 that #3946 moves to `v_cmpx_lt_u32` get past it too, and all 277 then stop at a later `v_readfirstlane_b32`. These programs have several walls in a row. Counts only; request bytes stay local. ## Checks Windows 11 build 26300, MSVC (VS Build Tools 14.44), SDK/DXC 10.0.26100. `ctest --preset pr` on this commit (rebased on `main` `4324d81f`, which has #3945 and #3946): 349/351 pass, `native_direct_mesh` included. The two local failures, `native_compute_implicit_lod_controls` and `native_wave_virtual_derivative_controls`, are the local SDK validator 1.7 vs DXIL 1.8 and fail on `main` too. The census was measured before the rebase (`c6a0b036`, and `c6a0b036` + #3946) and not rerun on `4324d81f`. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
R0Y00 commented 2026-12-03 17:21:16 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T17:21:16Z.

Review: COMMENTED


Independently rebuilt compile_dxil on efdaf580 with MSVC Debug; native_direct_mesh passed 1/1, including both SDWA half selectors and the explicit destination refusal. The hosted Windows run's only failure was startup_stage_package: stage_package.ps1 exceeded the fixture's 30 s subprocess deadline. The shader case did not fail there. I reran the failed job on this same head to keep the required Windows gate intact.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6174841101 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3947#pullrequestreview-6174841101). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T17:21:16Z. **Review:** COMMENTED --- Independently rebuilt compile_dxil on efdaf580 with MSVC Debug; native_direct_mesh passed 1/1, including both SDWA half selectors and the explicit destination refusal. The hosted Windows run's only failure was startup_stage_package: stage_package.ps1 exceeded the fixture's 30 s subprocess deadline. The shader case did not fail there. I reran the failed job on this same head to keep the required Windows gate intact.
R0Y00 commented 2026-12-03 17:25:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T17:25:09Z.

Review: APPROVED


Re-reviewed efdaf580. The SDWA path still narrows EXEC only, and the lane-linear export count proof remains limited to the full-width operand. The source-built native_direct_mesh suite passed 1/1 in MSVC Debug. Restoring only the old !i.subword guard caused the WORD_0 control to fail at +0x24 with the former v_cmpx_lt_u32 EXEC refusal. WORD_1 and explicit SGPR destination controls also ran in the unmodified suite. The initial required Windows job failed only its package staging subprocess timeout; I requested the exact-head retry.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6174921309 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3947#pullrequestreview-6174921309). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T17:25:09Z. **Review:** APPROVED --- Re-reviewed efdaf580. The SDWA path still narrows EXEC only, and the lane-linear export count proof remains limited to the full-width operand. The source-built native_direct_mesh suite passed 1/1 in MSVC Debug. Restoring only the old !i.subword guard caused the WORD_0 control to fail at +0x24 with the former v_cmpx_lt_u32 EXEC refusal. WORD_1 and explicit SGPR destination controls also ran in the unmodified suite. The initial required Windows job failed only its package staging subprocess timeout; I requested the exact-head retry.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3947:upstream-pr/3947'
git switch 'upstream-pr/3947'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3947'
git switch 'upstream-pr/3947'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3947'
git switch 'upstream-pr/3947'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3947'
git switch 'main'
git merge --squash 'upstream-pr/3947'
git switch 'main'
git merge --ff-only 'upstream-pr/3947'
git switch 'main'
git merge 'upstream-pr/3947'
git push origin 'main'
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!3947
No description provided.