Skip to content

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

Open
Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:take/3666
Open

Leyukaka wants to merge 3 commits into
R0Y00:mainfrom
Leyukaka:take/3666

Conversation

@Leyukaka

@Leyukaka Leyukaka commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

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

Kawiu and others added 2 commits December 2, 2026 19:35
…ontend

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 R0Y00#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 R0Y00#2413.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed 294efc0 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 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated head a67cf53 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 Dec 3, 2026

Copy link
Copy Markdown
Owner

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 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical approval for a67cf53. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants