Recompiler: allow inline-constant and NULL mask operands in the per-lane form #1864

Manually merged
github merged 1 commit from gh-pr/1864/head into gh-pr/1864/base 2026-11-26 05:07:39 +00:00
Owner

@⁠emirduran707 on GitHub · 2026-11-24 22:06 UTC · original
emirduran707:recomp-per-lane-const-mask-operands → main · +109 −29 · 2 files · 1 commits · merged 2026-11-24 23:54 UTC

In the per-lane direct DXIL backend (#1745):

  • bridge() rejected V_CNDMASK_B32, V_ADD_CO_CI_U32, V_SUB_CO_CI_U32, and V_SUBREV_CO_CI_U32 whenever the mask operand was not an SGPR (m > 127, such as inline carry-in 0 = 128 or -1 = 193, or NULL = 125), even though dxil::Lw::read64 already decodes non-SGPR mask operands without reading any SGPR.
  • src_bit() accepted only SGPRs, 128 (0), and 193 (-1), refusing NULL (125), inline integer masks (129..=192, 194..=208), and 32-bit literals (255).
  • src() and src64() missed 125 (NULL).

Part of #1269. bridge() now skips SGPR injection when m > 127 || m == 125, src_bit() extracts the lane's bit from NULL, inline integers (sign-extended to 64 bits for negative values), and 32-bit literals, and src() / src64() handle 125.

What is in it

  • crates/xcl/src/gpu/recomp/lower.rs: handle 125 (NULL) in src() / src64(), extend src_bit() for 125, 129..=192, 194..=208, and 255, and skip SGPR injection in bridge() when m > 127 || m == 125.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: GPU parity test const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (wave32 and wave64, V_ADD_CO_CI_U32 with 128/193/125, V_CNDMASK_B32 with inline positive/negative/NULL masks, and mask SALU with inline mask).

Tested

  • AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release
  • cargo test --workspace -- --test-threads=4 on 15fff3b: 960 passed, 0 failed, 43 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record)
  • const_and_null_mask_operands_agree_with_hlsl_on_the_gpu before the change failed (wave32: unsupported V_ADD_CO_CI_U32 (V_ADD_CO_CI_U32: mask operand 128)); passes on both wave32 and native wave64 after

Regression run

main:

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1539 (PresentX 1539)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14791 MB

this PR:

xcl-smoke v1
commit: 15fff3b4fb528add77a5d81e583aa626130c15f7
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1567)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14787 MB

Not tested

  • Split wave64 (WaveSize(32)) GPUs (NVIDIA / Intel / wave32-only).
  • The smoke title's run is a regression check only.

AI use

  • Antigravity with Gemini 4 Neon: found the gap, wrote the change, GPU parity test and this description, and ran the test suite and smoke runs above.
**@⁠emirduran707** on GitHub · 2026-11-24 22:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1864) `emirduran707:recomp-per-lane-const-mask-operands` → `main` · +109 −29 · 2 files · 1 commits · merged 2026-11-24 23:54 UTC In the per-lane direct DXIL backend (#1745): - `bridge()` rejected `V_CNDMASK_B32`, `V_ADD_CO_CI_U32`, `V_SUB_CO_CI_U32`, and `V_SUBREV_CO_CI_U32` whenever the mask operand was not an SGPR (`m > 127`, such as inline carry-in `0` = `128` or `-1` = `193`, or `NULL` = `125`), even though `dxil::Lw::read64` already decodes non-SGPR mask operands without reading any SGPR. - `src_bit()` accepted only SGPRs, `128` (0), and `193` (-1), refusing `NULL` (`125`), inline integer masks (`129..=192`, `194..=208`), and 32-bit literals (`255`). - `src()` and `src64()` missed `125` (`NULL`). Part of #1269. `bridge()` now skips SGPR injection when `m > 127 || m == 125`, `src_bit()` extracts the lane's bit from `NULL`, inline integers (sign-extended to 64 bits for negative values), and 32-bit literals, and `src()` / `src64()` handle `125`. **What is in it** - `crates/xcl/src/gpu/recomp/lower.rs`: handle `125` (`NULL`) in `src()` / `src64()`, extend `src_bit()` for `125`, `129..=192`, `194..=208`, and `255`, and skip SGPR injection in `bridge()` when `m > 127 || m == 125`. - `crates/xcl/src/gpu/recomp/lower_dxil.rs`: GPU parity test `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` (wave32 and wave64, `V_ADD_CO_CI_U32` with `128`/`193`/`125`, `V_CNDMASK_B32` with inline positive/negative/NULL masks, and mask SALU with inline mask). **Tested** - AMD Radeon RX 9060 XT (driver 32.0.31044.16), Ryzen 5 5600, Windows 11 Pro 26300, Rust 1.100.0; tests debug, smoke release - `cargo test --workspace -- --test-threads=4` on 15fff3b: 960 passed, 0 failed, 43 ignored; 8 SKIPPED (6 in `lower_dxil::tests::{f16,f32}_programs_on_the_gpu`; `heap_window_out_of_memory_falls_back_to_the_switch_form`; `pso_measurement_compiles_an_exact_synthetic_record`) - `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` before the change failed (`wave32: unsupported V_ADD_CO_CI_U32 (V_ADD_CO_CI_U32: mask operand 128)`); passes on both wave32 and native wave64 after **Regression run** main: ``` xcl-smoke v1 commit: c4d37bec1bb4286eb373aea963404a23f13401fa gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1539 (PresentX 1539) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14791 MB ``` this PR: ``` xcl-smoke v1 commit: 15fff3b4fb528add77a5d81e583aa626130c15f7 gpu: AMD Radeon RX 9060 XT title: 21222967 seconds: 60 exit: 0x0 frames shown: 1567 (PresentX 1567) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 14787 MB ``` **Not tested** - Split wave64 (`WaveSize(32)`) GPUs (NVIDIA / Intel / wave32-only). - The smoke title's run is a regression check only. **AI use** - Antigravity with Gemini 4 Neon: found the gap, wrote the change, GPU parity test and this description, and ran the test suite and smoke runs above.
In the per-lane direct DXIL backend (#1745):
- `bridge()` rejected `V_CNDMASK_B32` / `V_ADD_CO_CI_U32` / `V_SUB_CO_CI_U32`
  / `V_SUBREV_CO_CI_U32` whenever the mask operand was not an SGPR (`m > 127`,
  such as inline carry-in `0` = 128 or `-1` = 193, or `NULL` = 125), even
  though `dxil::Lw::read64` already decodes non-SGPR mask operands without
  touching any SGPR.
- `src_bit()` accepted only SGPRs, `128` (0), and `193` (-1), refusing `NULL`
  (125), inline integer masks (`129..=192`, `194..=208`), and 32-bit literals
  (`255`).
- `src()` and `src64()` missed `125` (`NULL`).

`bridge()` now skips SGPR injection when `m > 127 || m == 125`, `src_bit()`
extracts the lane's bit from `NULL`, inline integers (sign-extended to 64 bits
for negative values), and 32-bit literals, and `src()`/`src64()` handle `125`.

Assisted-by: Antigravity (Gemini 4 Neon)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:07:37 +00:00
github manually merged commit 15fff3b4fb into gh-pr/1864/base 2026-11-26 05:07:39 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 22:20 UTC · original

NVIDIA counterpart to the RX 9060 XT run: RTX 3070 8 GB (32-lane waves, no native wave64), driver 616.56, Windows 11, debug, 15fff3b merged onto main 689f2db.

  • const_and_null_mask_operands_agree_with_hlsl_on_the_gpu: the wave32 form passes, 2 of 2 runs. The wave64 form skips ("no wave64"), so your AMD run is the wave64 coverage.
  • gpu::recomp::lower (lower, lower_dxil, lower::wave): 47 passed, 0 failed.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-24 22:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/1864#issuecomment-7146117727) NVIDIA counterpart to the RX 9060 XT run: RTX 3070 8 GB (32-lane waves, no native wave64), driver 616.56, Windows 11, debug, `15fff3b` merged onto `main` `689f2db`. - `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu`: the wave32 form passes, 2 of 2 runs. The wave64 form skips ("no wave64"), so your AMD run is the wave64 coverage. - `gpu::recomp::lower` (lower, lower_dxil, lower::wave): 47 passed, 0 failed. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠frenziedcoder on GitHub · 2026-11-24 22:13 UTC · original · edited 2026-11-24 22:26 UTC

NVIDIA test report for 15fff3b: full suite green, its own GPU test skipped here (no wave64), and a clean smoke pair on the retail title (1656 vs 1654 frames).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head 15fff3b4fb528add77a5d81e583aa626130c15f7, no local changes.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 (debug): 960 passed, 0 failed, 43 ignored; the PR's own test const_and_null_mask_operands_agree_with_hlsl_on_the_gpu SKIPPED here. SKIPPED: gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (const_mask, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 compares, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 rounding, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 three-source, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 transcendentals, wave64: no wave64), gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu (f64, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer carries, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • This PR's own GPU test const_and_null_mask_operands_agree_with_hlsl_on_the_gpu SKIPPED on this card (no wave64: NVIDIA runs 32-lane waves only), so the change itself is not exercised by its test here; this report covers the rest of the suite and the smoke pair.
  • test_title_draws_with_a_root_signature_under_the_debug_layer reports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (1d027e5, this PR's merge base with main):

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14598 MB

this PR:

xcl-smoke v1
commit: 15fff3b4fb528add77a5d81e583aa626130c15f7
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1656 (PresentX 1656)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14603 MB

Not tested: this code in the title: it is on the opt-in direct-DXIL path (XCL_PER_LANE=1 with XCL_DIRECT_DXIL), which the smoke runs leave unset (default HLSL backend), so they show only that nothing else regressed; the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.

**@⁠frenziedcoder** on GitHub · 2026-11-24 22:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1864#issuecomment-7145959202) · edited 2026-11-24 22:26 UTC **NVIDIA test report for `15fff3b`: full suite green, its own GPU test skipped here (no wave64), and a clean smoke pair on the retail title (1656 vs 1654 frames).** **Tested** - NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 `stable-x86_64-pc-windows-msvc`, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head `15fff3b4fb528add77a5d81e583aa626130c15f7`, no local changes. - `cargo build --workspace && cargo test --workspace -- --test-threads=4` (debug): **960 passed, 0 failed, 43 ignored**; the PR's own test `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` SKIPPED here. SKIPPED: `gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu` (no wave64), `gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` (const_mask, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 packed, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 compares, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 conversions, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 rounding, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 three-source, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 transcendentals, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu` (f64, wave64: no wave64), `gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu` (integer arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu` (integer carries, wave64: no wave64), `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - This PR's own GPU test `const_and_null_mask_operands_agree_with_hlsl_on_the_gpu` SKIPPED on this card (no wave64: NVIDIA runs 32-lane waves only), so the change itself is not exercised by its test here; this report covers the rest of the suite and the smoke pair. - `test_title_draws_with_a_root_signature_under_the_debug_layer` reports ok, but this machine has no D3D12 debug layer (`debug layer requested but unavailable … (0x887A002D)`), so it ran without the layer and is no evidence either way. **Regression run** (`scripts/smoke.ps1 -Seconds 60`, release, the retail title of #505 at its start screen; `XCL_PSO_PRELOAD=0` for both builds, because this machine's preload list holds the program of #1307) base (`1d027e5`, this PR's merge base with `main`): ``` xcl-smoke v1 commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331 gpu: NVIDIA GeForce RTX 5080 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1654 (PresentX 1654) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14598 MB ``` this PR: ``` xcl-smoke v1 commit: 15fff3b4fb528add77a5d81e583aa626130c15f7 gpu: NVIDIA GeForce RTX 5080 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1656 (PresentX 1656) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14603 MB ``` **Not tested:** this code in the title: it is on the opt-in direct-DXIL path (`XCL_PER_LANE=1` with `XCL_DIRECT_DXIL`), which the smoke runs leave unset (default HLSL backend), so they show only that nothing else regressed; the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD. *AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.*
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 01:38 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 01:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1864#issuecomment-7149784822) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.