Skip to content

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

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
emirduran707:recomp-per-lane-const-mask-operands
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
emirduran707:recomp-per-lane-const-mask-operands

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

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.

…ane form

In the per-lane direct DXIL backend (xcl-dev#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)
@frenziedcoder

frenziedcoder commented Nov 24, 2026 •

Copy link
Copy Markdown

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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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 gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #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.

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@raylitebull
raylitebull merged commit fc14fab into xcl-dev:main Nov 24, 2026
2 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
, xcl-dev#1869, xcl-dev#1898)

Brings main to full parity with upstream/main (8e87fc7):
- xcl-dev#1930: invalidate block-local DXIL CSE wave/quad cache across dx.op.discard (fixes xcl-dev#1891)
- xcl-dev#1864: allow inline-constant and NULL mask operands in the per-lane form
- xcl-dev#1869: avoid 2 - off underflow in s_setreg_b32 targeting HW_REG_MODE bit 3
- xcl-dev#1898: truncate s instead of returning native on special values in round_exact

Conflict in crates/xcl/src/gpu/dxil/core_tests.rs resolved by keeping both tests
(opt_folds_i64_bitcast_selects_and_commutative_cse and s_setreg_b32_mode_bit3_does_not_underflow).

Assisted-by: Antigravity (Gemini 4)
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 25, 2026
Pulls in xcl-dev#1836 (graphics and two-pass PSO disk cache + lazy MS/GS + shader build coalescing), xcl-dev#1930 (DXIL CSE across discard), xcl-dev#1900, xcl-dev#1005, xcl-dev#1053, xcl-dev#1864, xcl-dev#1866, xcl-dev#1869, xcl-dev#1876, and xcl-dev#1898 while keeping our RDNA4 MSAA clamp (xcl-dev#1908), wave64 graphics Direct DXIL guard (xcl-dev#1913), atomic writable-range tracking, static-sampler cache keys, and 4M-group indirect dispatch clamp.
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants