Skip to content

Recompiler: lower S_FF0_I32 and S_FLBIT_I32 on mask registers in the per-lane form - #1865

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
emirduran707:recomp-per-lane-mask-ff0-flbit
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
emirduran707:recomp-per-lane-mask-ff0-flbit

Conversation

@emirduran707

@emirduran707 emirduran707 commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

wave_salu in the per-lane direct DXIL backend (#1745) lowered S_BCNT1, S_BCNT0, and S_FF1 on mask registers, but S_FF0_I32_B32, S_FF0_I32_B64, S_FLBIT_I32_B32, and S_FLBIT_I32_B64 fell through to bridge() and failed with "a mask read as a number". Part of #1269.

wave_salu now lowers S_FF0_I32_B32/B64 via first_set on the inverted mask words and S_FLBIT_I32_B32/B64 via leading-zero count (returning 0xFFFFFFFF when the input is 0, matching emit.rs and the RDNA2 ISA).

What is in it

  • crates/xcl/src/gpu/recomp/lower/wave.rs: add clz32 helper and handle S_FF0_I32_B32/B64 and S_FLBIT_I32_B32/B64 in wave_salu.
  • crates/xcl/src/gpu/recomp/lower_dxil.rs: GPU parity test mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (wave32 and wave64 across partial, all-ones, and all-zeros masks, plus B32 on EXEC).

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 build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4 on 2c1102d (rebased onto main de36462): 1003 passed, 2 failed, 45 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)
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) fail identically on unmodified main de36462 on this GPU (seeds 722 and 1599).
  • mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu before the change failed (wave32: unsupported S_FF0_I32_B32 (s106: a mask read as a number)); passes on both wave32 and native wave64 after

Regression run

main:

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

this PR:

xcl-smoke v1
commit: 2c1102d6e76b4abec0d111a6b4e1e01a29bb4adb
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1488 (PresentX 1488)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16622 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.
  • Claude Code with Claude Opus 5.5: rebased the change onto main de36462 (a conflict in the tests of crates/xcl/src/gpu/recomp/lower_dxil.rs; both tests kept) and reran the suite and smoke runs above.

@frenziedcoder

frenziedcoder commented Nov 24, 2026 •

Copy link
Copy Markdown

NVIDIA test report for dfddc79: full suite green, its own GPU test skipped here (no wave64), and a clean smoke pair on the retail title (1654 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 dfddc79a5a69fd3d7a3dc5a352c75d1764f39281, no local changes.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 (debug): 960 passed, 0 failed, 43 ignored; the PR's own test mask_ff0_and_flbit_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::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::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (mask_ff0_flbit, 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 mask_ff0_and_flbit_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: dfddc79a5a69fd3d7a3dc5a352c75d1764f39281
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: 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, dfddc79 merged onto main 689f2db.

  • mask_ff0_and_flbit_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.

…per-lane form

`wave_salu` in the per-lane direct DXIL backend (xcl-dev#1745) handled `S_BCNT1`,
`S_BCNT0`, and `S_FF1` on mask registers, but `S_FF0_I32_B32/B64` and
`S_FLBIT_I32_B32/B64` fell through to `bridge()` and failed with
`"a mask read as a number"`.

`wave_salu` now lowers `S_FF0_I32_B32/B64` via `first_set` on the inverted
mask words and `S_FLBIT_I32_B32/B64` via leading-zero count (returning
`0xFFFFFFFF` when the input is 0, matching `emit.rs` and the RDNA2 ISA).

Assisted-by: Antigravity (Gemini 4 Neon)
@raylitebull

Copy link
Copy Markdown
Member

Both AMD and NVIDIA verification look good on dfddc79. This is currently DIRTY with merge conflicts against main — please rebase onto main and let Build and test (Windows, no GPU) run cleanly so we can merge.

@emirduran707
emirduran707 force-pushed the recomp-per-lane-mask-ff0-flbit branch from dfddc79 to 2c1102d Compare November 25, 2026 01:27
@raylitebull
raylitebull merged commit 393cbdd into xcl-dev:main Nov 25, 2026
3 checks passed
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

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