shader: lower v_rcp_iflag_f32 in direct Compute and Pixel DXIL #3256

Manually merged
github merged 1 commit from github-bot/gh-3254 into gh-pr/3254/base 2026-11-28 04:22:17 +00:00 AGit
Owner

@⁠legacy-code-archaeologist on GitHub · 2026-11-28 01:59 UTC · original
legacy-code-archaeologist:shader/direct-rcp-iflag-f32 → main · +317 −2 · 7 files · 1 commits · merged 2026-11-28 04:14 UTC

Lower RDNA 2 v_rcp_iflag_f32 (VOP1 0x2b, VOP3 0x1ab, SDWA, DPP16) identically to v_rcp_f32 (1.0f / x) in the direct Compute and Pixel DXIL path (#2935).

Fixes #3254
Refs #2935

Summary

  • src/gfx1013_compute_alu.inl: Added v_rcp_iflag_f32 to alu_rules (1.0 / {0}), enabling both ALU rule checks and DPP lowering.
  • src/gfx1013_compute_opcodes.inl: Added case 0x2b: return "v_rcp_iflag_f32";.
  • src/gfx1013_compute_native.cpp: Added "v_rcp_iflag_f32" to the SDWA floats set.
  • src/gfx1013_direct_compute.inl: Lowered v_rcp_iflag_f32 alongside v_rcp_f32 (fdiv float 1.000000e+00, a) in DirectCompute::float_alu().
  • tests/native_rcp_iflag_check.py & tests/cmake/native_rcp_iflag.cmake: Added 16 Compute + 4 Pixel DXIL equivalence cases (VOP1 VGPR/SGPR/inline/literal, VOP3 abs/neg/clamp/omod, SDWA, DPP16) and 2 refusal controls (controls, compute_hardware, pixel_warp, pixel_hardware).
  • docs/experiments/native-rcp-iflag-f32.md: Documented verification, sensitivity mutants, and limits.

Verification

Host: Windows 10.0.26100, dev preset, DXC 10.0.26100.0.

  • cmake --build --preset dev --target compile_dxil native_store_replay offscreen_check native_compute_ir_dump: passed.
  • ctest --preset dev --no-tests=error -R '^native_rcp_iflag_' -V:
    • native_rcp_iflag_controls: Passed (16 Compute + 4 Pixel cases compiled identically to v_rcp_f32 DXIL; 2 refusals matched).
    • native_rcp_iflag_pixel_warp: Passed (Microsoft Basic Render Driver, 4 quad draws matched).
    • native_rcp_iflag_pixel_hardware: Passed (NVIDIA Quadro M1000M, 4 quad draws matched; debug layer unavailable).
    • native_rcp_iflag_compute_hardware: Skipped (77, Intel(R) HD Graphics 530 31.0.101.2111 requires SM 6.6 with wave32).
  • ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure: 68/68 passed (0 skips).
  • Sensitivity mutants drop_direct_iflag and drop_sdwa_iflag both failed native_rcp_iflag_controls (rc=8).
  • python -B tests/docs_links_check.py: passed (131 Markdown files, 631 links).

AI-assisted.

**@⁠legacy-code-archaeologist** on GitHub · 2026-11-28 01:59 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3254) `legacy-code-archaeologist:shader/direct-rcp-iflag-f32` → `main` · +317 −2 · 7 files · 1 commits · merged 2026-11-28 04:14 UTC Lower RDNA 2 `v_rcp_iflag_f32` (`VOP1 0x2b`, `VOP3 0x1ab`, SDWA, DPP16) identically to `v_rcp_f32` (`1.0f / x`) in the direct Compute and Pixel DXIL path (`#2935`). Fixes #3254 Refs #2935 ## Summary - **`src/gfx1013_compute_alu.inl`**: Added `v_rcp_iflag_f32` to `alu_rules` (`1.0 / {0}`), enabling both ALU rule checks and DPP lowering. - **`src/gfx1013_compute_opcodes.inl`**: Added `case 0x2b: return "v_rcp_iflag_f32";`. - **`src/gfx1013_compute_native.cpp`**: Added `"v_rcp_iflag_f32"` to the SDWA `floats` set. - **`src/gfx1013_direct_compute.inl`**: Lowered `v_rcp_iflag_f32` alongside `v_rcp_f32` (`fdiv float 1.000000e+00, a`) in `DirectCompute::float_alu()`. - **`tests/native_rcp_iflag_check.py` & `tests/cmake/native_rcp_iflag.cmake`**: Added `16` Compute + `4` Pixel DXIL equivalence cases (VOP1 VGPR/SGPR/inline/literal, VOP3 abs/neg/clamp/omod, SDWA, DPP16) and `2` refusal controls (`controls`, `compute_hardware`, `pixel_warp`, `pixel_hardware`). - **`docs/experiments/native-rcp-iflag-f32.md`**: Documented verification, sensitivity mutants, and limits. ## Verification Host: Windows 10.0.26100, `dev` preset, DXC `10.0.26100.0`. - `cmake --build --preset dev --target compile_dxil native_store_replay offscreen_check native_compute_ir_dump`: passed. - `ctest --preset dev --no-tests=error -R '^native_rcp_iflag_' -V`: - `native_rcp_iflag_controls`: **Passed** (`16` Compute + `4` Pixel cases compiled identically to `v_rcp_f32` DXIL; `2` refusals matched). - `native_rcp_iflag_pixel_warp`: **Passed** (`Microsoft Basic Render Driver`, `4` quad draws matched). - `native_rcp_iflag_pixel_hardware`: **Passed** (`NVIDIA Quadro M1000M`, `4` quad draws matched; debug layer unavailable). - `native_rcp_iflag_compute_hardware`: **Skipped** (`77`, `Intel(R) HD Graphics 530` `31.0.101.2111` requires SM 6.6 with wave32). - `ctest --preset dev --no-tests=error -R '^native_.*_(controls|ir)$' --output-on-failure`: **68/68 passed** (`0` skips). - Sensitivity mutants `drop_direct_iflag` and `drop_sdwa_iflag` both failed `native_rcp_iflag_controls` (`rc=8`). - `python -B tests/docs_links_check.py`: passed (`131` Markdown files, `631` links). AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 02:01:59 +00:00
github-bot changed target branch from main to gh-pr/3254/base 2026-11-28 04:22:15 +00:00
github manually merged commit f6be56c931 into gh-pr/3254/base 2026-11-28 04:22:17 +00:00
Author
Owner

@⁠pigalot on GitHub · 2026-11-28 04:13 UTC · original · approved these changes

I reviewed f6be56c9 merged over main ff524dff. The merge is clean (tree d5a1f554) and git diff --cached --check is clean.

What I traced. RDNA 2 VOP1 0x2b is v_rcp_iflag_f32, and VOP3 0x1ab is the same opcode plus 0x180. It differs from v_rcp_f32 only in which exception flag it raises, so lowering it the same way as v_rcp_f32 is right.

The direct paths:

  • the decoder already names it through vop1_names in gfx1013_isa_tables.inl;
  • float_alu now gives it the v_rcp_f32 fdiv float 1.0, a;
  • the SDWA floats set gives it float source modifiers;
  • the alu_rules entry is what admits DPP (gfx1013_direct_compute.inl:3761).

native_rcp_iflag_controls compiles each case as both 0x2b and 0x2a, and requires identical DXIL.

What I ran. I built compile_dxil native_store_replay offscreen_check native_compute_ir_dump native_global_srv_heap_replay native_compute_manifest_reasons in dev and release, then ran:

ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^native_' -E '_hardware'
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^native_(rcp|rsq|sqrt|f32|float|alu|sdwa|dpp)[a-z0-9_]*_hardware$'
  • Non-hardware: 131 tests per preset. 114 pass and 17 _warp tests skip with 77, the same WARP capability skips as on main, in both Debug and Release /O2. native_rcp_iflag_controls and native_rcp_iflag_pixel_warp pass.
  • Hardware: 9/9 pass in both presets, including both new tests. native_rcp_iflag_compute_hardware runs here (it skipped on your Intel adapter), as do the DPP, DPP8 and SDWA neighbours.

Mutants. Each was rebuilt in dev, then I ran the four native_rcp_iflag_* tests:

Mutant Result
float_alu no longer lowers v_rcp_iflag_f32 killed
dropped from the SDWA floats set killed
alu_rules entry removed killed
lowered as rsq (dx.op 25) killed
mnemonic() case 0x2b removed (gfx1013_compute_opcodes.inl) survives
alu_rules expression "2.0 / {0}" survives

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking: the legacy HLSL profile is enabled too, without a test. The two survivors only reach the legacy gfx1013-compute-wave32@ profile. For a non-direct request, the decoder names an opcode only through mnemonic(), and Emit writes HLSL from the rule's expression. On main, that profile has neither for 0x2b, so it refuses v_rcp_iflag_f32. This PR adds both.

I ran the controls' VOP1/VOP3 cases on gfx1013-compute-wave32@0. SDWA and DPP are refused there, as for any opcode. The 0x2b and 0x2a DXIL are identical, so the behaviour is right. But with the expression mutated to "2.0 / {0}", 12 lines of that DXIL change and no registered test fails. The controls' 'fdiv float 1.000000e+00,' check would not carry over as-is: on that profile, DXC folds the constant inputs, and no fdiv is left.

Two ways to cover it:

  • a legacy-profile equality case in controls;
  • or leave 0x2b out of mnemonic() (the direct paths don't need it), so the legacy profile stays refused, and say so in the description.

Verdict: approve on f6be56c9.

Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32; I did not check the debug-layer status.
CI: Build and test on Windows passes on f6be56c9.

This reply was AI-assisted.

**@⁠pigalot** on GitHub · 2026-11-28 04:13 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3254#pullrequestreview-6095722649) · **approved these changes** I reviewed `f6be56c9` merged over `main` `ff524dff`. The merge is clean (tree `d5a1f554`) and `git diff --cached --check` is clean. **What I traced.** RDNA 2 VOP1 `0x2b` is `v_rcp_iflag_f32`, and VOP3 `0x1ab` is the same opcode plus `0x180`. It differs from `v_rcp_f32` only in which exception flag it raises, so lowering it the same way as `v_rcp_f32` is right. The direct paths: - the decoder already names it through `vop1_names` in `gfx1013_isa_tables.inl`; - `float_alu` now gives it the `v_rcp_f32` `fdiv float 1.0, a`; - the SDWA `floats` set gives it float source modifiers; - the `alu_rules` entry is what admits DPP (`gfx1013_direct_compute.inl:3761`). `native_rcp_iflag_controls` compiles each case as both `0x2b` and `0x2a`, and requires identical DXIL. **What I ran.** I built `compile_dxil native_store_replay offscreen_check native_compute_ir_dump native_global_srv_heap_replay native_compute_manifest_reasons` in `dev` and `release`, then ran: ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^native_' -E '_hardware' python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^native_(rcp|rsq|sqrt|f32|float|alu|sdwa|dpp)[a-z0-9_]*_hardware$' ``` - **Non-hardware:** 131 tests per preset. 114 pass and 17 `_warp` tests skip with 77, the same WARP capability skips as on `main`, in both Debug and Release `/O2`. `native_rcp_iflag_controls` and `native_rcp_iflag_pixel_warp` pass. - **Hardware:** 9/9 pass in both presets, including both new tests. `native_rcp_iflag_compute_hardware` runs here (it skipped on your Intel adapter), as do the DPP, DPP8 and SDWA neighbours. **Mutants.** Each was rebuilt in `dev`, then I ran the four `native_rcp_iflag_*` tests: | Mutant | Result | |---|---| | `float_alu` no longer lowers `v_rcp_iflag_f32` | killed | | dropped from the SDWA `floats` set | killed | | `alu_rules` entry removed | killed | | lowered as `rsq` (dx.op 25) | killed | | `mnemonic()` `case 0x2b` removed (`gfx1013_compute_opcodes.inl`) | survives | | `alu_rules` expression `"2.0 / {0}"` | survives | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking: the legacy HLSL profile is enabled too, without a test.** The two survivors only reach the legacy `gfx1013-compute-wave32@` profile. For a non-direct request, the decoder names an opcode only through `mnemonic()`, and `Emit` writes HLSL from the rule's expression. On `main`, that profile has neither for `0x2b`, so it refuses `v_rcp_iflag_f32`. This PR adds both. I ran the controls' VOP1/VOP3 cases on `gfx1013-compute-wave32@0`. SDWA and DPP are refused there, as for any opcode. The `0x2b` and `0x2a` DXIL are identical, so the behaviour is right. But with the expression mutated to `"2.0 / {0}"`, 12 lines of that DXIL change and no registered test fails. The controls' `'fdiv float 1.000000e+00,'` check would not carry over as-is: on that profile, DXC folds the constant inputs, and no `fdiv` is left. Two ways to cover it: - a legacy-profile equality case in `controls`; - or leave `0x2b` out of `mnemonic()` (the direct paths don't need it), so the legacy profile stays refused, and say so in the description. **Verdict:** approve on `f6be56c9`. Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32; I did not check the debug-layer status. CI: `Build and test on Windows` passes on `f6be56c9`. This reply was AI-assisted.
This discussion has been locked. Commenting is limited to contributors.
No description provided.