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

Merged
mumba17 merged 1 commit from upstream-pr/3655 into main 2026-12-01 00:12:17 +00:00
mumba17 commented 2026-11-30 21:59:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-11-30T21:59:06Z.


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, #3416 layout, main plus #3635/#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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5574518560 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3655). Originally posted by [mumba17](https://github.com/mumba17) on 2026-11-30T21:59:06Z. --- 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, #3416 layout, main plus #3635/#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)
R0Y00 commented 2026-12-01 00:10:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T00:10:13Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6122837314 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3655#pullrequestreview-6122837314). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T00:10:13Z. **Review:** APPROVED --- 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.
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!3655
No description provided.