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

Open
Leyukaka wants to merge 3 commits from upstream-pr/3886 into main
Leyukaka commented 2026-12-02 19:53:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T19:53:53Z.


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

#3666 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 #3666 yourself, say so and I will close this PR.

Change

Since #3666 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 #3666, 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 #3666.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5613632700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3886). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-02T19:53:53Z. --- Carries #3666 by @Kawiu with their commits. Part of #2413. #3666 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 #3666 yourself, say so and I will close this PR. ## Change Since #3666 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 #3666, 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 #3666.
R0Y00 commented 2026-12-02 19:58:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:58:37Z.

Review: COMMENTED


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 #3666 or here so we land it once.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6157929673 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6157929673). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T19:58:37Z. **Review:** COMMENTED --- 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 #3666 or here so we land it once.
R0Y00 commented 2026-12-02 20:13:18 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T20:13:18Z.

Review: COMMENTED


The updated head a67cf533 includes #3885, 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158159097 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6158159097). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T20:13:18Z. **Review:** COMMENTED --- The updated head a67cf533 includes #3885, 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 commented 2026-12-03 06:34:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:34:59Z.


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 #3666.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7369997193 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3886#issuecomment-7369997193). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T06:34:59Z. --- 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 #3666.
R0Y00 commented 2026-12-03 08:38:42 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T08:38:42Z.

Review: APPROVED


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 #3666 and this carried branch still need a single landing choice.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6166249455 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3886#pullrequestreview-6166249455). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T08:38:42Z. **Review:** APPROVED --- 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 #3666 and this carried branch still need a single landing choice.
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/3886:upstream-pr/3886'
git switch 'upstream-pr/3886'

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