Skip to content

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

Open
SimSalabimse wants to merge 1 commit into
R0Y00:mainfrom
SimSalabimse:mesh-integer-sub-ops
Open

SimSalabimse wants to merge 1 commit into
R0Y00:mainfrom
SimSalabimse:mesh-integer-sub-ops

Conversation

@SimSalabimse

Copy link
Copy Markdown
Contributor

Draft. 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)

…mesh frontend

The native mesh path already accepts v_sub_nc_u32 and v_subrev_nc_u32 (R0Y00#3537). This adds the carry-out subtract forms and v_and_or_b32 through the existing ALU lowering, plus a check that decodes synthetic words for all five ops and evaluates the lowered result.

AI-assisted (Cursor)
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Tested on the Windows test PC at head 3df4c9d, 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

@SimSalabimse
SimSalabimse marked this pull request as ready for review December 1, 2026 09:35

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

2 participants