shader: lower v_rcp_iflag_f32 and v_ashrrev_i32 in the mesh frontend #3709

Merged
mumba17 merged 2 commits from upstream-pr/3709 into main 2026-12-02 02:13:18 +00:00
mumba17 commented 2026-12-01 08:06:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T08:06:45Z.


Refs #3641, #3703, #2413. Independent of #3708, but measured on top of it, since most of these programs only reach these instructions after #3708.

Problem

On a native Mesh86 capture with #3708 applied, v_rcp_iflag_f32 is the first refusal for 371 of the 1,569 distinct slot 86 programs, and v_ashrrev_i32 for 50. Both refuse with unsupported mesh instruction or EXEC state. The shared ALU already lowers both:

  • v_rcp_iflag_f32 takes the v_rcp_f32 path: fdiv float 1.0, a. The flag only changes IEEE exception reporting, which DXIL doesn't expose.
  • v_ashrrev_i32 is ashr src1, src0 & 31.

Change

Both join the mesh lane ALU list in src/gfx1013_direct_mesh.inl. The full_exec || exec_skip rule and the partial-write merge apply unchanged. Both have alu_rules entries, so, as for v_rcp_f32, a result whose sources are all uniform is recorded as uniform.

Census

Same capture as #3708 (main 1c634037, X2W_REFUSE_FIXED_MESH=1, X2W_NATIVE_MESH86=1, 600 s, 1,569 distinct .m86). Every request goes through compile_dxil … gfx1013-container-ms-texture-heap. Counts only.

First refusal #3708 #3708 + this PR
v_rcp_iflag_f32 371 0
v_ashrrev_i32 50 0
v_and_or_b32 — 144 (accepted by @SimSalabimse's #3659)
mesh heap slot lacks masked root constant provenance — 142
s_cmp_le_u32 — 85
raw buffer load needs offen with zero scalar offset and no modifiers 1 51
translate fully 389 389

So this PR moves 421 programs one wall further. None of them translates fully yet, and their next walls are listed above.

Tests

tests/native_direct_mesh_check.py:

  • v-ashrrev-i32 (v_ashrrev_i32 v1, 2, v0): an ashr of v0 by 2 & 31 reaches the exported X position.
  • v-rcp-iflag-f32 (v_rcp_iflag_f32 v1, v0): fdiv float 1.0, v0, whose bits reach the exported X.
  • Mutation. With the source change reverted, the check fails at v-ashrrev-i32 with unsupported mesh instruction or EXEC state: v_ashrrev_i32.
  • Regression. ctest -R "native_|mesh|gfx1013" -E "hardware|_warp": 786/788 pass. The same two local-only failures as in #3708: the SDK 10.0.26100 validator here only supports DXIL 1.7. They don't touch the mesh frontend.

Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100.

AI-assisted.

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5581611593 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3709). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T08:06:45Z. --- Refs #3641, #3703, #2413. Independent of #3708, but measured on top of it, since most of these programs only reach these instructions after #3708. ## Problem On a native Mesh86 capture with #3708 applied, `v_rcp_iflag_f32` is the first refusal for 371 of the 1,569 distinct slot 86 programs, and `v_ashrrev_i32` for 50. Both refuse with `unsupported mesh instruction or EXEC state`. The shared ALU already lowers both: - `v_rcp_iflag_f32` takes the `v_rcp_f32` path: `fdiv float 1.0, a`. The flag only changes IEEE exception reporting, which DXIL doesn't expose. - `v_ashrrev_i32` is `ashr src1, src0 & 31`. ## Change Both join the mesh lane ALU list in `src/gfx1013_direct_mesh.inl`. The `full_exec || exec_skip` rule and the partial-write merge apply unchanged. Both have `alu_rules` entries, so, as for `v_rcp_f32`, a result whose sources are all uniform is recorded as uniform. ## Census Same capture as #3708 (`main` `1c634037`, `X2W_REFUSE_FIXED_MESH=1`, `X2W_NATIVE_MESH86=1`, 600 s, 1,569 distinct `.m86`). Every request goes through `compile_dxil … gfx1013-container-ms-texture-heap`. Counts only. | First refusal | #3708 | #3708 + this PR | |---|---:|---:| | `v_rcp_iflag_f32` | 371 | 0 | | `v_ashrrev_i32` | 50 | 0 | | `v_and_or_b32` | — | 144 (accepted by @SimSalabimse's #3659) | | `mesh heap slot lacks masked root constant provenance` | — | 142 | | `s_cmp_le_u32` | — | 85 | | `raw buffer load needs offen with zero scalar offset and no modifiers` | 1 | 51 | | translate fully | 389 | 389 | So this PR moves 421 programs one wall further. None of them translates fully yet, and their next walls are listed above. ## Tests `tests/native_direct_mesh_check.py`: - **`v-ashrrev-i32`** (`v_ashrrev_i32 v1, 2, v0`): an `ashr` of v0 by `2 & 31` reaches the exported X position. - **`v-rcp-iflag-f32`** (`v_rcp_iflag_f32 v1, v0`): `fdiv float 1.0, v0`, whose bits reach the exported X. - **Mutation.** With the source change reverted, the check fails at `v-ashrrev-i32` with `unsupported mesh instruction or EXEC state: v_ashrrev_i32`. - **Regression.** `ctest -R "native_|mesh|gfx1013" -E "hardware|_warp"`: 786/788 pass. The same two local-only failures as in #3708: the SDK 10.0.26100 validator here only supports DXIL 1.7. They don't touch the mesh frontend. Environment: Windows 11 build 26300, RTX 3090, MSVC 14.44, DXC from SDK 10.0.26100. AI-assisted. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lukaslw-lab commented 2026-12-01 08:10:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T08:10:00Z.

Review: APPROVED


Reviewed ecb4a19f by reading the diff; not built or run.

Verdict: approve. Both ops join the mesh lane ALU list and reach shared lowerings that already exist. v_rcp_iflag_f32 is the same 1.0 / x as v_rcp_f32 (gfx1013_compute_alu.inl:48-49, gfx1013_direct_compute.inl:3615). v_ashrrev_i32 is ashr src1, src0 & 31 (gfx1013_compute_alu.inl:10, :5779). No MUST.

  • NIT The PR body says neither op "counts as a uniform-proving source". Both have alu_rules entries (arity 2 and 1), so the mesh branch takes sources from them (gfx1013_direct_mesh.inl:1935). A result whose sources are all uniform is therefore recorded as uniform, exactly as for v_rcp_f32. That is correct; only the wording differs.
  • NIT v-rcp-iflag-f32 checks that the fdiv exists, not that it reaches the exported X, as v-ashrrev-i32 does with assert_position_x.
  • Checked, no finding:
    • 0x30020082 is VOP2 0x18 (v_ashrrev_i32 v1, 2, v0), and 0x7e025700 is VOP1 0x2b (v_rcp_iflag_f32 v1, v0).
    • The ashr pattern excludes an lshr.
    • For the iflag form, the only difference from v_rcp_f32 is exception reporting, which DXIL does not expose.
  • Note: this changes the same allowlist lines as #3704, so whichever of the two lands second needs a one-line rebase. I'll do it on #3704 if this one lands first.

Tests: v-ashrrev-i32 proves the signed shift reaches the export, and v-rcp-iflag-f32 proves the reciprocal path. The reverted-source mutation in the PR body hits the first. CI is still running at this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6127271459 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3709#pullrequestreview-6127271459). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T08:10:00Z. **Review:** APPROVED --- Reviewed `ecb4a19f` by reading the diff; not built or run. **Verdict: approve.** Both ops join the mesh lane ALU list and reach shared lowerings that already exist. `v_rcp_iflag_f32` is the same `1.0 / x` as `v_rcp_f32` (`gfx1013_compute_alu.inl:48-49`, `gfx1013_direct_compute.inl:3615`). `v_ashrrev_i32` is `ashr src1, src0 & 31` (`gfx1013_compute_alu.inl:10`, `:5779`). No MUST. - **NIT** The PR body says neither op "counts as a uniform-proving source". Both have `alu_rules` entries (arity 2 and 1), so the mesh branch takes `sources` from them (`gfx1013_direct_mesh.inl:1935`). A result whose sources are all uniform is therefore recorded as uniform, exactly as for `v_rcp_f32`. That is correct; only the wording differs. - **NIT** `v-rcp-iflag-f32` checks that the `fdiv` exists, not that it reaches the exported X, as `v-ashrrev-i32` does with `assert_position_x`. - Checked, no finding: - `0x30020082` is VOP2 0x18 (`v_ashrrev_i32 v1, 2, v0`), and `0x7e025700` is VOP1 0x2b (`v_rcp_iflag_f32 v1, v0`). - The `ashr` pattern excludes an `lshr`. - For the iflag form, the only difference from `v_rcp_f32` is exception reporting, which DXIL does not expose. - Note: this changes the same allowlist lines as #3704, so whichever of the two lands second needs a one-line rebase. I'll do it on #3704 if this one lands first. Tests: `v-ashrrev-i32` proves the signed shift reaches the export, and `v-rcp-iflag-f32` proves the reciprocal path. The reverted-source mutation in the PR body hits the first. CI is still running at this head.
mumba17 commented 2026-12-01 08:34:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by mumba17 on 2026-12-01T08:34:50Z.


Thanks @lukaslw-lab. Both NITs are fixed:

  • Wording. The description now says the two ops have alu_rules entries, so a result with all-uniform sources is recorded as uniform, the same as v_rcp_f32.
  • v-rcp-iflag-f32. It now follows the fdiv through the bitcast to the exported X with assert_position_x (745d65b5).

On the overlap with #3704: whichever of the two lands second needs a one-line rebase, so I'll take it if mine is second.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7305505241 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3709#issuecomment-7305505241). Originally posted by [mumba17](https://github.com/mumba17) on 2026-12-01T08:34:50Z. --- Thanks @lukaslw-lab. Both NITs are fixed: - **Wording.** The description now says the two ops have `alu_rules` entries, so a result with all-uniform sources is recorded as uniform, the same as `v_rcp_f32`. - **`v-rcp-iflag-f32`.** It now follows the `fdiv` through the bitcast to the exported X with `assert_position_x` (`745d65b5`). On the overlap with #3704: whichever of the two lands second needs a one-line rebase, so I'll take it if mine is second. AI-assisted.
lukaslw-lab commented 2026-12-01 18:08:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-01T18:08:47Z.

Review: APPROVED


Reviewed 95e4d369 by reading the diff; not built or run.

Verdict: approve. Both NITs from our earlier review are fixed, and nothing new came up. No MUST.

  • Encodings checked: 0x30020082 = v_ashrrev_i32 v1, 2, v0 (VOP2 op 0x18). 0x7e025700 = v_rcp_iflag_f32 v1, v0 (VOP1 op 0x2b).
  • The branch is based on 1c634037, but it merges cleanly with current main, including #3704's edits to the same allowlist lines. No rebase is needed.

Tests: v-ashrrev-i32 requires ashr by 2 & 31. v-rcp-iflag-f32 requires fdiv float 1.0. Both follow their result to the exported X through assert_position_x. native_direct_mesh is in the pr preset filter, and CI ran it green at this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6137157024 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3709#pullrequestreview-6137157024). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-01T18:08:47Z. **Review:** APPROVED --- Reviewed `95e4d369` by reading the diff; not built or run. **Verdict: approve.** Both NITs from our earlier review are fixed, and nothing new came up. No MUST. - Encodings checked: `0x30020082` = `v_ashrrev_i32 v1, 2, v0` (VOP2 op 0x18). `0x7e025700` = `v_rcp_iflag_f32 v1, v0` (VOP1 op 0x2b). - The branch is based on `1c634037`, but it merges cleanly with current `main`, including #3704's edits to the same allowlist lines. No rebase is needed. Tests: `v-ashrrev-i32` requires `ashr` by `2 & 31`. `v-rcp-iflag-f32` requires `fdiv float 1.0`. Both follow their result to the exported X through `assert_position_x`. `native_direct_mesh` is in the `pr` preset filter, and CI ran it green at 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!3709
No description provided.