shader: lower v_bfm_b32 and v_bcnt_u32_b32 in the mesh frontend (Part of #2413) #3657

Manually merged
github merged 1 commit from github-bot/gh-3655 into gh-pr/3655/base 2026-12-01 00:12:54 +00:00 AGit
Owner

@⁠mumba17 on GitHub · 2026-11-30 21:59 UTC · original
mumba17:shader/mesh-bfm → main · +17 −2 · 2 files · 1 commits · merged 2026-12-01 00:12 UTC

Part of #2413.

The shared ALU already lowers both instructions for direct compute: v_bfm_b32 since #2986, and v_bcnt_u32_b32 through unaryBits (popcount) plus the second source. The mesh frontend's vector ALU list did not admit either one, so they were refused as unsupported mesh instruction or EXEC state. This PR adds both to that list as two-source operations, so the uniform-result proof checks both operands.

Census (454 cached slot 57 requests, #3418 layout, main plus #3637/#3645/#3646):

  • Before: v_bfm_b32 is the first refusal for 40 requests.
  • After: none of the 40 stops at v_bfm_b32 or v_bcnt_u32_b32. They now stop at later refusals: 19 unsupported mesh SAVEEXEC operands, and the rest at several smaller reasons (v_cvt_f16_f32, v_cmpx_*, other SAVEEXEC shapes).
  • On main alone, v_bfm_b32 is no longer a refusal reason.

Tests (tests/native_direct_mesh_check.py):

  • v-bfm-b32: v_bfm_b32 v1, v0, 2 feeds the position. The check pins shl 1, width, the - 1 and the & 31 offset of 2.
  • v-bcnt-u32-b32: v_bcnt_u32_b32 v1, v0, 5 feeds the position. The check pins unaryBits op 31 plus 5.

Each of these mutations fails native_direct_mesh:

  • v_bfm_b32 not admitted;
  • width and offset swapped in the shared lowering;
  • the - 1 dropped;
  • v_bcnt_u32_b32 not admitted;
  • the + src1 dropped.

ctest -R "mesh|compile_dxil|bfm": 215/215 with the v_bfm_b32 change; native_direct_mesh passes again with v_bcnt_u32_b32 added.

🤖 Generated with Claude Code

**@⁠mumba17** on GitHub · 2026-11-30 21:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3655) `mumba17:shader/mesh-bfm` → `main` · +17 −2 · 2 files · 1 commits · merged 2026-12-01 00:12 UTC Part of #2413. The shared ALU already lowers both instructions for direct compute: `v_bfm_b32` since #2986, and `v_bcnt_u32_b32` through `unaryBits` (popcount) plus the second source. The mesh frontend's vector ALU list did not admit either one, so they were refused as `unsupported mesh instruction or EXEC state`. This PR adds both to that list as two-source operations, so the uniform-result proof checks both operands. **Census** (454 cached slot 57 requests, #3418 layout, main plus #3637/#3645/#3646): - Before: `v_bfm_b32` is the first refusal for 40 requests. - After: none of the 40 stops at `v_bfm_b32` or `v_bcnt_u32_b32`. They now stop at later refusals: 19 `unsupported mesh SAVEEXEC operands`, and the rest at several smaller reasons (`v_cvt_f16_f32`, `v_cmpx_*`, other SAVEEXEC shapes). - On main alone, `v_bfm_b32` is no longer a refusal reason. **Tests** (`tests/native_direct_mesh_check.py`): - `v-bfm-b32`: `v_bfm_b32 v1, v0, 2` feeds the position. The check pins `shl 1, width`, the `- 1` and the `& 31` offset of 2. - `v-bcnt-u32-b32`: `v_bcnt_u32_b32 v1, v0, 5` feeds the position. The check pins `unaryBits` op 31 plus 5. Each of these mutations fails `native_direct_mesh`: - `v_bfm_b32` not admitted; - width and offset swapped in the shared lowering; - the `- 1` dropped; - `v_bcnt_u32_b32` not admitted; - the `+ src1` dropped. `ctest -R "mesh|compile_dxil|bfm"`: 215/215 with the `v_bfm_b32` change; `native_direct_mesh` passes again with `v_bcnt_u32_b32` added. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The shared ALU already lowers v_bfm_b32 for direct compute (#2986):
((1 << (S0 & 31)) - 1) << (S1 & 31). Admit it in the mesh frontend's
vector ALU list with two sources, so uniformity proofs see both.

The test builds v_bfm_b32 v1, v0, 2 into the position and pins the width,
the minus one and the offset operand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 22:04:36 +00:00
github-bot changed target branch from main to gh-pr/3655/base 2026-12-01 00:12:53 +00:00
github manually merged commit 7e260c1aac into gh-pr/3655/base 2026-12-01 00:12:54 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 00:10 UTC · original · approved these changes

Reviewed the mesh ALU admission for v_bfm_b32 and v_bcnt_u32_b32. Both reuse the shared lowering and declare both operands for the uniformity analysis. The tests tie the resulting mask/count to the exported position. ctest --test-dir <build> --no-tests=error -j1 -R '^native_direct_mesh$' --output-on-failure passed on the Windows Release integration.

**@⁠R0Y00** on GitHub · 2026-12-01 00:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3655#pullrequestreview-6122837314) · **approved these changes** Reviewed the mesh ALU admission for `v_bfm_b32` and `v_bcnt_u32_b32`. Both reuse the shared lowering and declare both operands for the uniformity analysis. The tests tie the resulting mask/count to the exported position. `ctest --test-dir <build> --no-tests=error -j1 -R '^native_direct_mesh$' --output-on-failure` passed on the Windows Release integration.
This discussion has been locked. Commenting is limited to contributors.
No description provided.