Skip to content

Tests: check bit-scan, reverse, bitfield and byte-permute ops on the GPU - #1226

Open
plentilha wants to merge 1 commit into
xcl-dev:mainfrom
plentilha:tests/bitwise-bitfield-gpu
Open

plentilha wants to merge 1 commit into
xcl-dev:mainfrom
plentilha:tests/bitwise-bitfield-gpu

Conversation

@plentilha

Copy link
Copy Markdown

Adds GPU execution tests for nine translated bitwise and bitfield VALU instructions that had no existing GPU test coverage: v_not_b32, v_xnor_b32, v_bfrev_b32, v_ffbh_u32, v_ffbh_i32, v_ffbl_b32, v_bfm_b32, v_bfi_b32 and v_perm_b32. Test-only change.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_bitwise_and_bitfield_ops exercising zero, all-ones, sign-bit, bitmask wrap, and all v_perm_b32 selector classes (byte picks, half/word sign extensions, 0x00 and 0xFF fills) through gpu_waves().

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3070 (driver 32.0.16.2124, wave32 only), Intel Core i7-9700K, Windows 11 x64, rustc 1.100.0, DXC 1.9.2602.17 (Windows SDK 10.0.26100.0), debug
  • ./scripts/test.ps1: 742 passed, 0 failed, 41 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64))
  • cargo test -p xcl --lib -- gpu_bitwise_and_bitfield_ops --nocapture: 1 passed, 0 failed (wave32 pass on this adapter)

Regression run

  • Not needed: test-only change.

Not tested

  • Native wave64 pass (AMD/Intel GPUs), retail game runs (XCL_SAMPLE_* unset), Wine, release build.

AI use

  • Antigravity (Gemini 4 Hydrogen): checked emit.rs coverage, wrote the test and PR description, and ran the test suite locally.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib recomp: 190 passed, 0 failed, 18 ignored (new GPU checks included).

Thanks!

@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

I checked the expected values against the RDNA2 definitions (read from the ISA, not run on AMD hardware). All 9 match:

  • v_perm_b32: over {S0, S1} with S1 the low dword, a selector of 0–3 picks an S1 byte and 4–7 an S0 byte. 8, 9, 10 and 11 give the sign of bit 15 and bit 31 of S1, then of S0. 12 gives 0x00; 13 and above give 0xFF.
  • v_ffbh_i32: the position, counted from the MSB, of the first bit that differs from the sign bit, and -1 for 0 and -1.
  • v_bfm_b32: 0 at width 0.

perm_ref and ffbh_i_ref encode exactly these. No changes needed from my side.

AI-assisted (Claude Code).

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@Luislariosss

Copy link
Copy Markdown

Compatibility note, in case it saves a conflict later: I have a local change to Shader::bfrev (crates/xcl/src/gpu/dxil/ops.rs) that reverses a dynamic Bfrev.i32 with shifts instead of dx.op unary 30, because amdxc64 returns x | bfrev(x) when the operand descends from a 64-bit op (#2115, fuzz seed 1599's dynamic form). It is posted as a patch in #2115 (comment) and is not a PR yet (it needs a retail smoke run I cannot do).

I merged this PR on top of it and ran cargo test -p xcl --lib gpu::recomp::tests on an RX 9060 XT (driver 32.0.32029.2010): 168 passed, 0 failed, 17 ignored. So the v_bfrev_b32 coverage here still passes when the direct path stops using the native Bfrev.i32 for dynamic operands - the tests exercise the translated output, not the dx.op.

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean f09c1d44ac0185521ac98be091d7914902d7514c, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. cargo test -j 2 -p xcl --lib --locked --no-run then exact gpu::recomp::tests::gpu_bitwise_and_bitfield_ops, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, and gpu::recomp::dxc::version_tests::the_loaded_dxc_is_identified with --nocapture --test-threads=1. One GPU fixture passed all nine VOP3 operations across 32 lanes, and the DXC identity test passed. The native-wave64 fixture emitted SKIPPED … no wave64 and counted as a pass in libtest. No failures or ignores.

Not tested: Native wave64, direct DXIL, full workspace suite and retail smoke.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the checks and wrote this report.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA verification of PR #1226 at head f09c1d44ac0185521ac98be091d7914902d7514c (1 commit; exact parent & merge-base: 47efa2ecea0a12934719ae69b81930cf02a4b1c3, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted GPU tests & build (f09c1d44)

Command Result
cargo test --release -p xcl --lib gpu_bitwise_and_bitfield_ops -- --nocapture (3 consecutive runs) 1 passed; 0 failed; 0 ignored; 719 filtered out × 3 (0.28s, 0.23s, 0.22s, 0 skipped; live RTX 4060 execution compiled with DXC 1.9.2609.5)
cargo build --release -p xcl Clean build (1m 20s test compile + 0.06s incremental --release build, exit 0, 0 new warnings)

Paired quiet 60 s retail smoke (title: 29640639)

(Note: scripts/smoke.ps1 at 47efa2ec predates 9683e7a6 and printed the local folder basename on title:; replaced below with the standard 9683e7a6 title hash 29640639, with all measured fields verbatim.)

Exact parent & merge-base (47efa2ecea0a12934719ae69b81930cf02a4b1c3):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1527 (PresentX 1527)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14723 MB

PR #1226 (f09c1d44ac0185521ac98be091d7914902d7514c):

xcl-smoke v1
commit: f09c1d44ac0185521ac98be091d7914902d7514c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1596 (PresentX 1596)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14713 MB

Limits of coverage

  • This PR is test-only (crates/xcl/src/gpu/recomp/tests.rs, 0 production-code changes); gpu_bitwise_and_bitfield_ops compiled and executed 3/3 on desktop RTX 4060 (Wave32-only Ada; native Wave64 paths are not exercised).
  • The 60 s retail smoke confirms non-regression of the unchanged runtime binary at this commit (single-run frame/commit delta vs. parent reflects normal startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head f09c1d4

Overlaps the open GPU test PRs of #1607 group D171 for some ops: v_bfi_b32, v_bfm_b32 and v_perm_b32 are also tested by #445 and #1576, v_perm_b32 by #1057, and v_ffbh_u32/v_ffbh_i32/v_ffbl_b32 by #1576. v_not_b32, v_xnor_b32 and v_bfrev_b32 are tested by none of them and none of these ops is tested on main. Unlike #1576 (wave64 only), this test also runs wave32 through gpu_waves().
The reference functions (byte selectors 8-12 in perm_ref, all-same-bits = -1 in ffbh_i_ref, width & 31 in bfm) match the RDNA2 definitions.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants