shader: admit s_max_u32 and v_mul_hi_u32 in the mesh frontend #3445

Merged
Leyukaka merged 1 commit from upstream-pr/3445 into main 2026-11-29 10:10:36 +00:00
Leyukaka commented 2026-11-29 09:16:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T09:16:22Z.


Part of #3416

Branch shader-mesh-udiv-ops, head 0f84c3ac, based on main 1a0120ba. One commit:

  • 0f84c3ac mesh: admit s_max_u32 and v_mul_hi_u32 in the native frontend

Files: src/gfx1013_direct_mesh.inl, tests/native_direct_mesh_check.py.

What changes

The shared compute translator already lowers both ops, and the native mesh frontend refused them as unsupported (line numbers at the branch head):

  • s_max_u32: select on unsigned strict S0 > S1, with SCC set to that compare (src/gfx1013_direct_compute.inl:4134-4146).
  • v_mul_hi_u32: 16-bit partial products, without the signed correction (:4160-4171).

In src/gfx1013_direct_mesh.inl:

  • :911 adds s_max_u32 to the scalar ALU list.
  • :1104 adds v_mul_hi_u32 to the VALU list, with that list's existing condition and partial-write handling.

Evidence

On this head (base 1a0120ba): configure, build compile_dxil, then

ctest -R '^native_direct_mesh$'

Result: native_direct_mesh Passed.

Tests: v-mul-hi-u32 and s-max-u32 are accepted fixtures whose result reaches POS0.x. assert_position_x follows the exported value back through uitofp to the op that produced it.

Mutation on this head, reverted afterwards:

Mutation Result
drop v_mul_hi_u32 from the mesh VALU list (:1104) fails: native compute +0x18: unsupported mesh instruction or EXEC state: v_mul_hi_u32

Mutations on previous revisions (same source change, same two fixtures), not repeated on this head:

Mutation Revision Result
drop s_max_u32 from the mesh scalar list ddd77faf on main d58a9f63 fails: native compute +0x24: unsupported mesh instruction or EXEC state: s_max_u32
signed predicate for s_max_u32 in gfx1013_direct_compute.inl c04dad83 on main 212d4b5f fails: assert 'icmp ugt i32' in text
v_mul_hi_u32 takes the signed correction in gfx1013_direct_compute.inl c04dad83 on main 212d4b5f fails: assert_position_x(text, r'add i32')

Not covered

  • The v_mul_hi_u32 check sees only the last op before POS0.x: add i32 for the unsigned path, sub i32 for the signed correction. The partial-product sequence and the numeric result are not checked. A signed lowering that still ended in add i32 would pass.
  • The s_max_u32 position regex accepts both signed and unsigned selects. The icmp ugt i32 substring is what separates them, and nothing ties that compare to the select.
  • SCC after s_max_u32 is not read by any case. A tie, where > and >= give different SCC values, is not tested.

CI

On main 1a0120ba the pr test preset filter in CMakePresets.json does not match native_direct_mesh, and the pr build preset does not list compile_dxil. Build and test on Windows does not exercise this change.

Interactions with our other open mesh branches

This branch touches the same two files as #3439 (f74eacc8) and the same test file as #3438 (0feac9c2). By git merge-tree --write-tree at these heads:

  • with #3439: content conflict in src/gfx1013_direct_mesh.inl, on the scalar ALU name list. This branch adds s_max_u32 on the line where #3439 adds s_sub_i32 || s_mul_hi_u32. The resolution is the union. tests/native_direct_mesh_check.py merges automatically.
  • with #3438: clean
  • with shader-mesh-exec-widen (958d341e): clean
  • with shader-mesh-exchange-nosave (08cf44c8): clean

The combinations were not built. Whichever of this branch and #3439 merges second needs a rebase.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5549331994 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3445). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-11-29T09:16:22Z. --- Part of #3416 Branch `shader-mesh-udiv-ops`, head 0f84c3ac, based on main 1a0120ba. One commit: - 0f84c3ac mesh: admit s_max_u32 and v_mul_hi_u32 in the native frontend Files: `src/gfx1013_direct_mesh.inl`, `tests/native_direct_mesh_check.py`. ## What changes The shared compute translator already lowers both ops, and the native mesh frontend refused them as unsupported (line numbers at the branch head): - `s_max_u32`: select on unsigned strict `S0 > S1`, with SCC set to that compare (`src/gfx1013_direct_compute.inl:4134-4146`). - `v_mul_hi_u32`: 16-bit partial products, without the signed correction (:4160-4171). In `src/gfx1013_direct_mesh.inl`: - :911 adds `s_max_u32` to the scalar ALU list. - :1104 adds `v_mul_hi_u32` to the VALU list, with that list's existing condition and partial-write handling. ## Evidence On this head (base 1a0120ba): configure, build `compile_dxil`, then ``` ctest -R '^native_direct_mesh$' ``` Result: `native_direct_mesh` Passed. Tests: `v-mul-hi-u32` and `s-max-u32` are accepted fixtures whose result reaches POS0.x. `assert_position_x` follows the exported value back through `uitofp` to the op that produced it. Mutation on this head, reverted afterwards: | Mutation | Result | |---|---| | drop `v_mul_hi_u32` from the mesh VALU list (:1104) | fails: `native compute +0x18: unsupported mesh instruction or EXEC state: v_mul_hi_u32` | Mutations on previous revisions (same source change, same two fixtures), not repeated on this head: | Mutation | Revision | Result | |---|---|---| | drop `s_max_u32` from the mesh scalar list | ddd77faf on main d58a9f63 | fails: `native compute +0x24: unsupported mesh instruction or EXEC state: s_max_u32` | | signed predicate for `s_max_u32` in `gfx1013_direct_compute.inl` | c04dad83 on main 212d4b5f | fails: `assert 'icmp ugt i32' in text` | | `v_mul_hi_u32` takes the signed correction in `gfx1013_direct_compute.inl` | c04dad83 on main 212d4b5f | fails: `assert_position_x(text, r'add i32')` | ## Not covered - The `v_mul_hi_u32` check sees only the last op before POS0.x: `add i32` for the unsigned path, `sub i32` for the signed correction. The partial-product sequence and the numeric result are not checked. A signed lowering that still ended in `add i32` would pass. - The `s_max_u32` position regex accepts both signed and unsigned selects. The `icmp ugt i32` substring is what separates them, and nothing ties that compare to the select. - SCC after `s_max_u32` is not read by any case. A tie, where `>` and `>=` give different SCC values, is not tested. ## CI On main 1a0120ba the `pr` test preset filter in `CMakePresets.json` does not match `native_direct_mesh`, and the `pr` build preset does not list `compile_dxil`. `Build and test on Windows` does not exercise this change. ## Interactions with our other open mesh branches This branch touches the same two files as #3439 (f74eacc8) and the same test file as #3438 (0feac9c2). By `git merge-tree --write-tree` at these heads: - with #3439: content conflict in `src/gfx1013_direct_mesh.inl`, on the scalar ALU name list. This branch adds `s_max_u32` on the line where #3439 adds `s_sub_i32 || s_mul_hi_u32`. The resolution is the union. `tests/native_direct_mesh_check.py` merges automatically. - with #3438: clean - with `shader-mesh-exec-widen` (958d341e): clean - with `shader-mesh-exchange-nosave` (08cf44c8): clean The combinations were not built. Whichever of this branch and #3439 merges second needs a rebase.
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!3445
No description provided.