shader: accept v_sub_co_u32, v_subrev_co_u32 and v_and_or_b32 in the mesh frontend (Part of #2413) #3659

Merged
SimSalabimse merged 8 commits from upstream-pr/3659 into main 2026-12-02 22:01:56 +00:00
SimSalabimse commented 2026-11-30 22:09:54 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-11-30T22:09:54Z.


Part of #2413.

The native mesh frontend already accepts v_sub_nc_u32 and v_subrev_nc_u32 since #3537. This adds the three integer ops next to them that it still refuses:

  • v_sub_co_u32 (VOP3)
  • v_subrev_co_u32 (VOP3)
  • v_and_or_b32 (VOP3)

All three go through the existing arithmetic() lowering, so the change in src/gfx1013_direct_mesh.inl is one whitelist line.

tests/mesh57_integer_alu_check.cpp (registered as mesh57_integer_alu) decodes synthetic gfx1013 words for the five ops with the repo decoder and checks the expected result of each form:

  • v_sub_nc_u32 / v_subrev_nc_u32: VOP2, VOP3, VOP3 with clamp, SDWA dword and DPP forms, including 0 - 1 == 0xFFFFFFFF wrap and the unsigned clamp to 0.
  • v_sub_co_u32 / v_subrev_co_u32: VOP3 result plus borrow bit.
  • v_and_or_b32: VOP3 (a & b) | c.
  • It also checks that all five names are on the mesh whitelist.

Left out:

  • The carry-in forms (v_sub_co_ci_u32, v_subrev_co_ci_u32).
  • Any modifier the carry/ALU lowering already refuses. Those still refuse the same way they do today.

Checks:

  • Linux, this branch: the new check builds with g++ and clang++ (-std=c++17 -Wall -Werror=narrowing) and passes.
  • Linux, the same change on the fork branch before it was moved onto current main: ctest mesh57_* 12/12.
  • Windows test PC: results are pending and will be posted here.

Why: on the Windows test PC, the derived slot 57 mesh walk (fork branch, see the draft linked from #3541) got through translation further than before and was refused in native compute translation at an unsupported v_sub_nc_u32. That branch was older than #3537. This PR keeps the subtract coverage in the test and adds the remaining siblings, so the next run does not stop one instruction later.

AI-assisted (Cursor)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5574674525 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-11-30T22:09:54Z. --- Part of #2413. The native mesh frontend already accepts `v_sub_nc_u32` and `v_subrev_nc_u32` since #3537. This adds the three integer ops next to them that it still refuses: - `v_sub_co_u32` (VOP3) - `v_subrev_co_u32` (VOP3) - `v_and_or_b32` (VOP3) All three go through the existing `arithmetic()` lowering, so the change in `src/gfx1013_direct_mesh.inl` is one whitelist line. `tests/mesh57_integer_alu_check.cpp` (registered as `mesh57_integer_alu`) decodes synthetic gfx1013 words for the five ops with the repo decoder and checks the expected result of each form: - `v_sub_nc_u32` / `v_subrev_nc_u32`: VOP2, VOP3, VOP3 with clamp, SDWA dword and DPP forms, including `0 - 1 == 0xFFFFFFFF` wrap and the unsigned clamp to 0. - `v_sub_co_u32` / `v_subrev_co_u32`: VOP3 result plus borrow bit. - `v_and_or_b32`: VOP3 `(a & b) | c`. - It also checks that all five names are on the mesh whitelist. Left out: - The carry-in forms (`v_sub_co_ci_u32`, `v_subrev_co_ci_u32`). - Any modifier the carry/ALU lowering already refuses. Those still refuse the same way they do today. Checks: - Linux, this branch: the new check builds with g++ and clang++ (`-std=c++17 -Wall -Werror=narrowing`) and passes. - Linux, the same change on the fork branch before it was moved onto current main: ctest `mesh57_*` 12/12. - Windows test PC: results are pending and will be posted here. Why: on the Windows test PC, the derived slot 57 mesh walk (fork branch, see the draft linked from #3541) got through translation further than before and was refused in native compute translation at an unsupported `v_sub_nc_u32`. That branch was older than #3537. This PR keeps the subtract coverage in the test and adds the remaining siblings, so the next run does not stop one instruction later. AI-assisted (Cursor)
SimSalabimse commented 2026-12-01 09:35:22 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T09:35:22Z.


Tested on the Windows test PC at head 3df4c9d8, dev preset, with ctest -R mesh (excluding the real-device audio tests): 202/202 passed, including native_direct_mesh (the DXC test), startup_mesh57_real_shape, and the new mesh57_integer_alu.

It merges cleanly with current main a061032f. Stock main with the same filter is also 207/207.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7306917994 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#issuecomment-7306917994). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-01T09:35:22Z. --- Tested on the Windows test PC at head 3df4c9d8, dev preset, with `ctest -R mesh` (excluding the real-device audio tests): 202/202 passed, including `native_direct_mesh` (the DXC test), `startup_mesh57_real_shape`, and the new `mesh57_integer_alu`. It merges cleanly with current main `a061032f`. Stock main with the same filter is also 207/207. AI-Assisted
lukaslw-lab commented 2026-12-01 19:04:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T19:04:24Z.

Review: COMMENTED


Reviewed 3df4c9d8 by reading the diff; not built or run.

Verdict: comment. The one-line allowlist change is right. The three ops reach lowerings that already exist: v_and_or_b32 is ({0} & {1}) | {2} (gfx1013_compute_alu.inl:8), and the two carry-out subtracts go through carry_destination (gfx1013_compute_native.cpp:577), whose lowering refuses clamp, neg, DPP and scale. But the PR's only test never runs that code, so nothing pins it. No MUST. I'd approve once a translator case is in.

  • SHOULD tests/mesh57_integer_alu_check.cpp decodes the words with the repo decoder. It then checks them against its own lower() (a C++ copy of the expected arithmetic) and against a text search of gfx1013_direct_mesh.inl for the names. It never calls lower_mesh, so the DXIL for the three new ops, and the borrow write to VCC or an SDST pair, are untested. mesh57_integer_alu is also not in the pr preset filter, so CI did not run it. A few cases in tests/native_direct_mesh_check.py would cover this, in the style of the other mesh allowlist PRs on #3703 (#3704, #3709). Each would follow the result to the exported X with assert_position_x: v_and_or_b32, v_sub_co_u32 with its borrow in VCC feeding a v_cndmask_b32, and v_subrev_co_u32 with operands swapped.
  • NIT The description starts with "Draft." but the PR is ready for review.
  • Checked, no finding:
    • VCC as the carry-out. carry_destination writes the lane bit to 106, and the mesh after_graphics_write(106) clears the numeric VCC words. So a later SALU or SAVEEXEC use of VCC refuses instead of reading a stale compare mask.
    • Explicit SDST pair. The numeric dwords are cleared and the bit goes to the per-pc pseudo register, as for v_add_co_ci_u32, which is already accepted.

Tests: mesh57_integer_alu proves the decoder names and widths for the five ops, and that the names appear in the mesh source. It does not reach the translator. CI is green, but it did not include this test.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6138062331 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6138062331). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T19:04:24Z. **Review:** COMMENTED --- Reviewed `3df4c9d8` by reading the diff; not built or run. **Verdict: comment.** The one-line allowlist change is right. The three ops reach lowerings that already exist: `v_and_or_b32` is `({0} & {1}) | {2}` (`gfx1013_compute_alu.inl:8`), and the two carry-out subtracts go through `carry_destination` (`gfx1013_compute_native.cpp:577`), whose lowering refuses clamp, neg, DPP and scale. But the PR's only test never runs that code, so nothing pins it. No MUST. I'd approve once a translator case is in. - **SHOULD** `tests/mesh57_integer_alu_check.cpp` decodes the words with the repo decoder. It then checks them against its own `lower()` (a C++ copy of the expected arithmetic) and against a text search of `gfx1013_direct_mesh.inl` for the names. It never calls `lower_mesh`, so the DXIL for the three new ops, and the borrow write to VCC or an SDST pair, are untested. `mesh57_integer_alu` is also not in the `pr` preset filter, so CI did not run it. A few cases in `tests/native_direct_mesh_check.py` would cover this, in the style of the other mesh allowlist PRs on #3703 (#3704, #3709). Each would follow the result to the exported X with `assert_position_x`: `v_and_or_b32`, `v_sub_co_u32` with its borrow in VCC feeding a `v_cndmask_b32`, and `v_subrev_co_u32` with operands swapped. - **NIT** The description starts with "Draft." but the PR is ready for review. - Checked, no finding: - **VCC as the carry-out.** `carry_destination` writes the lane bit to 106, and the mesh `after_graphics_write(106)` clears the numeric VCC words. So a later SALU or SAVEEXEC use of VCC refuses instead of reading a stale compare mask. - **Explicit SDST pair.** The numeric dwords are cleared and the bit goes to the per-pc pseudo register, as for `v_add_co_ci_u32`, which is already accepted. Tests: `mesh57_integer_alu` proves the decoder names and widths for the five ops, and that the names appear in the mesh source. It does not reach the translator. CI is green, but it did not include this test.
SimSalabimse commented 2026-12-02 12:13:18 +00:00 (Migrated from github.com)

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


Merged main and resolved the opcode allowlist conflict in src/gfx1013_direct_mesh.inl.

v_and_or_b32 was already covered by the upstream v-and-or-b32 case, so I left that one as is. I added a v_sub_co_u32 case that follows the VCC borrow into v_cndmask_b32, and a swapped v_subrev_co_u32 case. mesh57_integer_alu is now in the pr preset.

Windows test PC, head 1acfe7a1, dev/pr presets:

  • cmake --preset dev
  • cmake --build --preset pr --target mesh57_integer_alu_check compile_dxil (and startup_indirect_draw_indexed / offscreen_check for the nearby suite)
  • ctest --preset pr --no-tests=error -R '^(mesh57_integer_alu|native_direct_mesh)$' -V: mesh57_integer_alu passed. native_direct_mesh failed in the existing integer-row / float-row loop with native compute +0x34: unmapped graphics export. Current main 7c9f2639 fails the same way in that same loop, so this isn't from the merge. With that loop skipped locally (not committed), v-sub-co-u32-vcc-cndmask and v-subrev-co-u32-swapped both passed, and the rest of native_direct_mesh passed.
  • ctest --preset dev -R mesh57 -E 'startup_audio_(output|pacing|provider)': 48/64 passed after the first binaries were built. The other 16 were the startup_mesh57_*_{warp,hardware} tests, which needed offscreen_check. After building that target those 16 all passed.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7345015798 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#issuecomment-7345015798). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T12:13:18Z. --- Merged main and resolved the opcode allowlist conflict in `src/gfx1013_direct_mesh.inl`. `v_and_or_b32` was already covered by the upstream `v-and-or-b32` case, so I left that one as is. I added a `v_sub_co_u32` case that follows the VCC borrow into `v_cndmask_b32`, and a swapped `v_subrev_co_u32` case. `mesh57_integer_alu` is now in the `pr` preset. Windows test PC, head `1acfe7a1`, dev/pr presets: - `cmake --preset dev` - `cmake --build --preset pr --target mesh57_integer_alu_check compile_dxil` (and `startup_indirect_draw_indexed` / `offscreen_check` for the nearby suite) - `ctest --preset pr --no-tests=error -R '^(mesh57_integer_alu|native_direct_mesh)$' -V`: `mesh57_integer_alu` passed. `native_direct_mesh` failed in the existing `integer-row` / `float-row` loop with `native compute +0x34: unmapped graphics export`. Current main `7c9f2639` fails the same way in that same loop, so this isn't from the merge. With that loop skipped locally (not committed), `v-sub-co-u32-vcc-cndmask` and `v-subrev-co-u32-swapped` both passed, and the rest of `native_direct_mesh` passed. - `ctest --preset dev -R mesh57 -E 'startup_audio_(output|pacing|provider)'`: 48/64 passed after the first binaries were built. The other 16 were the `startup_mesh57_*_{warp,hardware}` tests, which needed `offscreen_check`. After building that target those 16 all passed. AI-Assisted
R0Y00 commented 2026-12-02 19:30:25 +00:00 (Migrated from github.com)

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

Review: COMMENTED


I reviewed 0860f882 and ran independent Windows/MSVC Debug ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(mesh57_integer_alu|native_direct_mesh)$' (2/2). The fixtures pin both carry-out subtract forms and the mesh frontend's acceptance. The trial merge into 23986134 still conflicts in CMakePresets.json only. Please retain mesh57_integer_alu together with the Mesh86 material coverage now on main, then rerun CI.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6157478782 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6157478782). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T19:30:25Z. **Review:** COMMENTED --- I reviewed 0860f882 and ran independent Windows/MSVC Debug `ctest --preset dev --no-tests=error --output-on-failure -j 1 -R '^(mesh57_integer_alu|native_direct_mesh)$'` (2/2). The fixtures pin both carry-out subtract forms and the mesh frontend's acceptance. The trial merge into `23986134` still conflicts in `CMakePresets.json` only. Please retain `mesh57_integer_alu` together with the Mesh86 material coverage now on main, then rerun CI.
SimSalabimse commented 2026-12-02 20:25:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T20:25:32Z.


Reply to https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6157478782:

Merged current main into this branch. The only conflict was CMakePresets.json: I kept the mesh57_integer_alu build target and test selection alongside main's Mesh86 entries. I resolved only that file; the rest merged cleanly.

Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time): mesh57_integer_alu, native_direct_mesh, startup_mesh57_* and native_mesh_*: 37 of 37 pass. The previous merge of main had passed the full -R mesh selection (233 of 233).

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7357716197 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#issuecomment-7357716197). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T20:25:32Z. --- Reply to https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6157478782: Merged current `main` into this branch. The only conflict was `CMakePresets.json`: I kept the `mesh57_integer_alu` build target and test selection alongside main's Mesh86 entries. I resolved only that file; the rest merged cleanly. Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time): `mesh57_integer_alu`, `native_direct_mesh`, `startup_mesh57_*` and `native_mesh_*`: 37 of 37 pass. The previous merge of main had passed the full `-R mesh` selection (233 of 233). AI-Assisted
R0Y00 commented 2026-12-02 22:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T22:01:40Z.

Review: APPROVED


Reviewed the updated lowering and fixtures. The added translator cases exercise the borrow bit through VCC into v_cndmask and cover the reversed operand order. On Windows I verified a clean trial merge with main at c3a85433, built mesh57_integer_alu_check and compile_dxil from 4818a90b, and ran ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(mesh57_integer_alu|native_direct_mesh)$' (2 passed). I also checked that the PR CI selection retains the integer ALU and Mesh86 fixtures. Windows, Linux Python, and gfx1013 fixture CI are green on this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6159804784 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3659#pullrequestreview-6159804784). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T22:01:40Z. **Review:** APPROVED --- Reviewed the updated lowering and fixtures. The added translator cases exercise the borrow bit through VCC into `v_cndmask` and cover the reversed operand order. On Windows I verified a clean trial merge with `main` at `c3a85433`, built `mesh57_integer_alu_check` and `compile_dxil` from `4818a90b`, and ran `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(mesh57_integer_alu|native_direct_mesh)$'` (2 passed). I also checked that the PR CI selection retains the integer ALU and Mesh86 fixtures. Windows, Linux Python, and gfx1013 fixture CI are green on this head.
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!3659
No description provided.