shader: lower v_cvt_f32_f16 and v_cmpx_eq_i32 in the mesh frontend #3888

Open
github-bot wants to merge 3 commits from github-bot/gh-3886 into main AGit
Owner

@⁠Leyukaka on GitHub · 2026-12-02 19:53 UTC · original
Leyukaka:take/3666 → main · +31 −2 · 2 files · 3 commits · open

Carries #3668 by @⁠Kawiu with their commits. Part of #2413.

#3668 is approved but conflicts with main. The author's commit is kept with its authorship and message (9032cea5e); one commit on top reduces it to what main still lacks. @⁠Kawiu, if you would rather rebase #3668 yourself, say so and I will close this PR.

Change

Since #3668 was opened, main lowers v_cvt_f16_f32 and every ordered f32 CMPX compare, v_cmpx_lt_f32 included, in lower_mesh. Two of the four forms are still missing, and this PR adds them in src/gfx1013_direct_mesh.inl:

  • v_cmpx_eq_i32 narrows the lane mask like v_cmpx_eq_u32: the new lane-active predicate is the parent mask AND the lane's own compare. EQ is the same bit test signed or unsigned. The existing refusals apply: no DPP, SDWA, abs, neg, omod or clamp.
  • v_cvt_f32_f16 joins the lane-ALU list and uses the shared lowering (legacyF16ToF32), so the partial-EXEC write merge applies unchanged.

Changed from #3668, in 294efc0c2:

  • v_cmpx_lt_f32 goes back to main's f32 CMPX branch, and the duplicate v_cvt_f16_f32 check is dropped.
  • v_cmpx_le_f32 is now lowered on main, so the refusal control uses v_cmpx_ne_i32 (VOPC 0x95).
  • lukaslw-lab's nit: the v_cmpx_lt_f32 check now requires the first fcmp olt operand to be the value built from the inline 0, so swapped operands fail it.

The diff against main is 2 files, +31 -2.

Validation

Windows, MSVC, dev preset, head 294efc0c2.

cmake --build --preset dev --target compile_dxil d3d12_xs.dll
ctest --preset dev --no-tests=error -R "^native_direct_mesh$" -V

Result: On the exact head of this branch, with MSVC: native_direct_mesh passes, including the new v_cmpx_eq_i32 and v_cvt_f32_f16 cases and the v_cmpx_ne_i32 control.

tests/native_direct_mesh_check.py adds, on the existing source-built triangle:

  • v_cvt_f32_f16 v1, v2: the exported X is the bitcast of dx.op.legacyF16ToF32(131, ...).
  • v_cmpx_eq_u32, v_cmpx_eq_i32 and v_cmpx_lt_f32 in a save / compare / s_cbranch_execz / restore sequence: the lane predicate is the br condition of the work block, the write is select i1 <predicate>, i32 2, i32 <old v1>, and the join phi takes the old value from the empty edge and feeds the exported X.
  • Control: v_cmpx_ne_i32 in the same sequence is refused with unsupported mesh instruction or EXEC state: v_cmpx_ne_i32.

Known limits

  • The checks are on DXIL text; no draw test exercises the two new forms.
  • Other integer CMPX forms stay refused by name.
  • The fixtures are hand-encoded gfx1013 words, as in #3668.
**@⁠Leyukaka** on GitHub · 2026-12-02 19:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3886) `Leyukaka:take/3666` → `main` · +31 −2 · 2 files · 3 commits · open Carries #3668 by @⁠Kawiu with their commits. Part of #2413. #3668 is approved but conflicts with `main`. The author's commit is kept with its authorship and message (`9032cea5e`); one commit on top reduces it to what `main` still lacks. @⁠Kawiu, if you would rather rebase #3668 yourself, say so and I will close this PR. ## Change Since #3668 was opened, `main` lowers `v_cvt_f16_f32` and every ordered f32 CMPX compare, `v_cmpx_lt_f32` included, in `lower_mesh`. Two of the four forms are still missing, and this PR adds them in `src/gfx1013_direct_mesh.inl`: - **`v_cmpx_eq_i32`** narrows the lane mask like `v_cmpx_eq_u32`: the new lane-active predicate is the parent mask AND the lane's own compare. EQ is the same bit test signed or unsigned. The existing refusals apply: no DPP, SDWA, abs, neg, omod or clamp. - **`v_cvt_f32_f16`** joins the lane-ALU list and uses the shared lowering (`legacyF16ToF32`), so the partial-EXEC write merge applies unchanged. Changed from #3668, in `294efc0c2`: - `v_cmpx_lt_f32` goes back to `main`'s f32 CMPX branch, and the duplicate `v_cvt_f16_f32` check is dropped. - `v_cmpx_le_f32` is now lowered on `main`, so the refusal control uses `v_cmpx_ne_i32` (VOPC `0x95`). - lukaslw-lab's nit: the `v_cmpx_lt_f32` check now requires the first `fcmp olt` operand to be the value built from the inline 0, so swapped operands fail it. The diff against `main` is 2 files, +31 -2. ## Validation Windows, MSVC, dev preset, head `294efc0c2`. ```powershell cmake --build --preset dev --target compile_dxil d3d12_xs.dll ctest --preset dev --no-tests=error -R "^native_direct_mesh$" -V ``` Result: On the exact head of this branch, with MSVC: `native_direct_mesh` passes, including the new `v_cmpx_eq_i32` and `v_cvt_f32_f16` cases and the `v_cmpx_ne_i32` control. `tests/native_direct_mesh_check.py` adds, on the existing source-built triangle: - `v_cvt_f32_f16 v1, v2`: the exported X is the bitcast of `dx.op.legacyF16ToF32(131, ...)`. - `v_cmpx_eq_u32`, `v_cmpx_eq_i32` and `v_cmpx_lt_f32` in a save / compare / `s_cbranch_execz` / restore sequence: the lane predicate is the `br` condition of the work block, the write is `select i1 <predicate>, i32 2, i32 <old v1>`, and the join `phi` takes the old value from the empty edge and feeds the exported X. - Control: `v_cmpx_ne_i32` in the same sequence is refused with `unsupported mesh instruction or EXEC state: v_cmpx_ne_i32`. ## Known limits - The checks are on DXIL text; no draw test exercises the two new forms. - Other integer CMPX forms stay refused by name. - The fixtures are hand-encoded gfx1013 words, as in #3668.
v_cvt_f16_f32 and v_cvt_f32_f16 reuse the shared ALU (RNE rounding into
the low word with the high word kept, and legacyF16ToF32). v_cmpx_eq_i32
and v_cmpx_lt_f32 narrow the lane mask like v_cmpx_eq_u32: EQ is the same
bit test signed or unsigned, and LT_F32 is ordered.

Part of #2413.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Main already lowers v_cvt_f16_f32 and every ordered f32 CMPX (float_cmpx),
so v_cmpx_lt_f32 goes back to that branch and the duplicate v_cvt_f16_f32
check is dropped. v_cmpx_le_f32 is now lowered, so the refusal control
uses v_cmpx_ne_i32. The v_cmpx_lt_f32 check pins the inline 0 as the
first fcmp operand (review note).

Part of #2413.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 19:56:43 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 19:58 UTC · original · reviewed

I reviewed 294efc0c and independently ran Windows/MSVC Debug cmake --build --preset dev --target compile_dxil and ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_direct_mesh$' (1/1). The two remaining forms use the existing partial-EXEC rules, and the fixture retains the unsupported compare refusal. Please coordinate with @⁠Kawiu on whether to carry this reduced change in #3668 or here so we land it once.

**@⁠R0Y00** on GitHub · 2026-12-02 19:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6157929673) · **reviewed** I reviewed 294efc0c and independently ran Windows/MSVC Debug `cmake --build --preset dev --target compile_dxil` and `ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_direct_mesh$'` (1/1). The two remaining forms use the existing partial-EXEC rules, and the fixture retains the unsupported compare refusal. Please coordinate with @⁠Kawiu on whether to carry this reduced change in #3668 or here so we land it once.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 20:13 UTC · original · reviewed

The updated head a67cf533 includes #3887, which fixes the old Linux 84 != 83 error. I ran python -B tests/standin_exports_check.py (476 checks, six mutations) and Windows/MSVC Debug ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_direct_mesh$' (1/1), both passed. The choice of landing PR with @⁠Kawiu is still open.

**@⁠R0Y00** on GitHub · 2026-12-02 20:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6158159097) · **reviewed** The updated head a67cf533 includes #3887, which fixes the old Linux `84 != 83` error. I ran `python -B tests/standin_exports_check.py` (476 checks, six mutations) and Windows/MSVC Debug `ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^native_direct_mesh$'` (1/1), both passed. The choice of landing PR with @⁠Kawiu is still open.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 06:34 UTC · original

Independent MSVC Debug check at a67cf533: built compile_dxil and d3d12_xs.dll, then ctest --preset dev --no-tests=error -j 1 -V -R '^native_direct_mesh$' passed (1/1). I checked the signed compare’s parent-mask intersection and the half-to-float conversion using the existing partial-EXEC write merge. The fixture checks emitted DXIL and the unsupported CMPX refusal; these two opcodes still have no GPU draw here. I’ll keep the two PRs coordinated while Kawiu has the chance to update #3668.

**@⁠R0Y00** on GitHub · 2026-12-03 06:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3886#issuecomment-7369997193) Independent MSVC Debug check at `a67cf533`: built `compile_dxil` and `d3d12_xs.dll`, then `ctest --preset dev --no-tests=error -j 1 -V -R '^native_direct_mesh$'` passed (1/1). I checked the signed compare’s parent-mask intersection and the half-to-float conversion using the existing partial-EXEC write merge. The fixture checks emitted DXIL and the unsupported CMPX refusal; these two opcodes still have no GPU draw here. I’ll keep the two PRs coordinated while Kawiu has the chance to update #3668.
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 08:38 UTC · original · approved these changes

Technical approval for a67cf533. I independently rebuilt compile_dxil and d3d12_xs.dll with MSVC Debug and ran native_direct_mesh (1/1), including the emitted signed equality path, half-to-float conversion and unsupported signed CMPX refusal. Current main merges cleanly and required CI passed. This fixture checks emitted DXIL. The original submission #3668 and this carried branch still need a single landing choice.

**@⁠R0Y00** on GitHub · 2026-12-03 08:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6166249455) · **approved these changes** Technical approval for a67cf533. I independently rebuilt compile_dxil and d3d12_xs.dll with MSVC Debug and ran native_direct_mesh (1/1), including the emitted signed equality path, half-to-float conversion and unsupported signed CMPX refusal. Current main merges cleanly and required CI passed. This fixture checks emitted DXIL. The original submission #3668 and this carried branch still need a single landing choice.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3888/head:github-bot/gh-3886'
git switch 'github-bot/gh-3886'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3886'
git switch 'github-bot/gh-3886'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3886'
git switch 'github-bot/gh-3886'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3886'
git switch 'main'
git merge --squash 'github-bot/gh-3886'
git switch 'main'
git merge --ff-only 'github-bot/gh-3886'
git switch 'main'
git merge 'github-bot/gh-3886'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.