Skip to content

Tests: GPU and value tests for the 64-bit SALU data ops (s_bfe/s_bitset/s_brev/s_flbit 64) - #1495

Open
Vonsek wants to merge 7 commits into
ItsNotRexed:mainfrom
Vonsek:test/salu-b64-data
Open

Vonsek wants to merge 7 commits into
ItsNotRexed:mainfrom
Vonsek:test/salu-b64-data

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-SALU-B64-DATA, #1380 (comment)

What and why

The 64-bit scalar data ops s_bfe_u64, s_bfe_i64, s_bitset0_b64, s_bitset1_b64, s_brev_b64, s_flbit_i32_b64 and s_flbit_i32_i64 had CPU tests only (#723, #726, #729, #733); their docs/design.md row said "Not GPU-verified". This adds three pixel tests that run them on SGPR pairs written by s_mov_b32 (data, not lane masks) and export both 32-bit words of each result through v_mov_b32:

  • ps_salu64_bfe: s_bfe_u64 offset 4 / width 40 and s_bfe_i64 offset 20 / width 36 on 0xf0e1d2c3_89abcdef. Both fields cross bit 32; the i64 field has its top bit set, so the high word is the sign-extended 0xfffffffe.
  • ps_salu64_bitset: s_bitset0_b64 at 0x7d (bit 61) and s_bitset1_b64 at 98 in an SGPR (bit 34). Both bits are in the high word; indexing with & 31 would change the low word instead.
  • ps_salu64_brev_flbit: s_brev_b64 of 0x0000f00d_12345678 (words swapped and reversed), s_flbit_i32_b64 of 0x12345 (47) and s_flbit_i32_i64 of 0xffffffff_fff0abcd (44). Both counts run past the high word into the low word.

Expected words and their derivation from the RDNA2 ISA pseudocode are in each .asm header, worked out by hand. The same shaders are semantic fixtures, asserted in tests/semantic/test_value_semantics.py against hand constants and a plain-Python reference.

Lane masks: the translator treats all seven ops as 64-bit data. Each handler raises Unsupported when lane_masks.py marks the pair as a lane mask (#210), so none of them takes the per-lane mask path that #293 is about. These tests use data pairs only. No op gave a wrong result, so nothing in the translator changes. The design.md row now names the GPU tests. The width cut at bit 63 and the SCC of s_bfe are still CPU-only. s_cmp_eq_u64/s_cmp_lg_u64 already run on the GPU (cs_wavemask, cs_w64x_partial_scmp), so they are not in this PR.

Tested

Windows 11, scripts/run_gpu_tests.py --filter ps_salu64, VK_LOADER_LAYERS_DISABLE=~implicit~:

  • NVIDIA GeForce RTX 5080 (subgroup 32), driver 616.92: 3/3 translated and pass spirv-val, 3/3 PASS, 4096/4096 pixels exact each.
  • AMD Radeon(TM) Graphics, RDNA2 iGPU of a Ryzen 9 9950X3D (subgroup 32..64), driver 26.10.1: same, 3/3 PASS, 4096/4096 exact.

Negative control: changing the s_bitset*_b64 index mask in tools/rdna2spirv.py from & 63 to & 31 makes ps_salu64_bitset fail on both GPUs, with the words the header predicts for that mistake (got 0x56543210, 0xfedcba98, 0x76543214, 0xfedcba98). test_s_bitset0_bitset1_b64_index_the_high_word fails the same way. Reverted.

Also: python -m unittest discover -s tests/semantic OK, python tests/semantic/regen_fixtures.py --check clean, python -I tests/test_shader_checks.py OK.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No new rule; the existing row now names the GPU tests.)

AI-assisted.

s_bfe_u64, s_bfe_i64, s_bitset0_b64, s_bitset1_b64, s_brev_b64,
s_flbit_i32_b64 and s_flbit_i32_i64 had CPU tests only. Three pixel
tests run them on SGPR pairs written by s_mov_b32 (data, not lane
masks) and export both words of each result:

- ps_salu64_bfe: fields that cross bit 32, i64 sign extension
- ps_salu64_bitset: bit indices 61 and 34, in the high word
- ps_salu64_brev_flbit: brev word swap, flbit counts past the high word

Expected words are derived from the RDNA2 ISA pseudocode in each .asm
header. The same shaders are semantic fixtures asserted in
test_value_semantics.py against hand constants and a Python reference.
The docs/design.md row names the GPU tests now.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bvtterbroot

bvtterbroot commented Nov 22, 2026 •

Copy link
Copy Markdown

Tested 95f9c47 on AMD Radeon RX 7900 XTX (RDNA3, Navi 31), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: pass.

  • run_gpu_tests.py: 142/142 passed; the new ps_salu64_bfe, ps_salu64_bitset, ps_salu64_brev_flbit pass.
  • python -I -m unittest discover -s tests/semantic -p test_value_semantics.py: 30 tests OK.
  • tests/semantic/regen_fixtures.py --check: clean.

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 14.44.

@Rainmaker33

Copy link
Copy Markdown

Tested 95f9c47 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass. The new fixtures are exact on NVIDIA.

The PR's diff applied cleanly to main bb2e184. VS 2022, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8; harness programs from a CMake build of that main.

  • scripts/run_gpu_tests.py: 112/142 pass, 30 skipped (all wave64), no failures. main gives 109/139.
    • ps_salu64_bfe: 4096/4096 pixels exact.
    • ps_salu64_bitset: 4096/4096 pixels exact.
    • ps_salu64_brev_flbit: 4096/4096 pixels exact.

Conflicts: docs/design.md, runtime/test/shaders/check.py, scripts/run_gpu_tests.py, tests/semantic/regen_fixtures.py, tests/semantic/test_value_semantics.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged main as 48620ba (no rebase). Conflicts were in docs/design.md, runtime/test/shaders/check.py, scripts/run_gpu_tests.py, tests/semantic/regen_fixtures.py and tests/semantic/test_value_semantics.py: kept main's version (including its new quadmask/bitreplicate row and the updated 64-bit bitwise row) and re-applied only this PR's GPU-check text to the 64-bit scalar data ops row plus its registrations. CPU checks OK: regen_fixtures.py --check clean, unittest discover -s tests/semantic, test_shader_checks.py, test_run_gpu_tests.py. ps_salu64_bfe, ps_salu64_bitset and ps_salu64_brev_flbit pass (4096/4096 pixels exact) on an AMD Radeon RDNA2 iGPU (driver 26.10.1).

AI-assisted.

Conflicts: docs/design.md, tests/semantic/regen_fixtures.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Main moved again while this was being tested, so merged it once more as 34bf370. Conflicts: docs/design.md and tests/semantic/regen_fixtures.py. Main's 64-bit scalar data ops row now records the RX 7900 XTX hw_oracle check and cs_w32_salu64.asm; I kept that text and appended this PR's GPU-check sentence after it. CPU checks OK again (regen --check clean, unittest discover -s tests/semantic, test_shader_checks.py, test_run_gpu_tests.py), and ps_salu64_bfe, ps_salu64_bitset and ps_salu64_brev_flbit pass (4096/4096 pixels exact) on an AMD Radeon RDNA2 iGPU (driver 26.10.1) with the rebuilt runtime.

AI-assisted.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Overlap note for whoever merges: main now has cs_w32_salu64.asm, which GPU-checks s_bfe_u64, s_bfe_i64, s_bitset1_b64, s_brev_b64 and s_flbit_i32_b64/_i64 once each. What this PR adds on top:

  • s_bitset0_b64, which main doesn't test.
  • BFE fields that cross bit 32, with the i64 field sign-extended.
  • Bit indices in the high word, including an index taken mod 64 from an SGPR.
  • s_flbit_i32_i64 of a negative value.

If that's judged too close to main's test, I'm fine with trimming the PR to s_bitset0_b64 and the bit-32 crossing cases. AI-assisted.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 34bf370f4d295c334a8ae6bb4d8cecefce08d236 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent Vulkan pass on Linux 7.0.0-43-generic, GeForce RTX 5090, NVIDIA driver 595.99.02, LLVM 21.1.8, and SPIRV-Tools 2026.1.

I rebuilt the harnesses at this head and ran the three ps_salu64_* fixtures. Each matched all 4,096 pixels, including the BFE fields that cross bit 32 and the high-word bitset checks. The existing cs_w32_salu64 control matched all eight expected words on the same head. All four shaders passed SPIR-V validation. All 32 focused value-semantics tests and the fixture regeneration check passed.

AI-assisted verification.

@Impre-visible

Copy link
Copy Markdown

Tested 34bf370 on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass, no regression.

Native build of runtime/ from this head (Ninja, RelWithDebInfo, clang 23.1.5), llvm-mc 23.1.5, SPIRV-Tools v2026.4.

  • spirv-val on the modules the PR's semantic tests translate (test_value_semantics.py): distinct modules: 39, pass spirv-val: 39, rejected: 0
  • tests/semantic: 1453 OK
  • build.py: 181 shaders, 181 translated, 181 pass spirv-val; check.py: 119 of 153 pass, 34 skipped (wave64 without emulation, mesh fixtures)
  • run_gpu_tests.py: 174 shaders: 174 translated, 174 pass spirv-val; 130/169 passed, 39 skipped, 0 failed
  • LEONIDA_W64_EMULATE=1 run_gpu_tests.py: 161/169 passed, 8 skipped (fixtures run by the d3d12 tests), 0 failed
  • New fixtures ps_salu64_bfe, ps_salu64_bitset, ps_salu64_brev_flbit: each 4096/4096 pixels exact, natively and with LEONIDA_W64_EMULATE=1; check.py ok for all three

AI-assisted run (Claude). Synthetic programs only, no game files involved.

Conflicted files: docs/design.md, runtime/test/shaders/check.py, scripts/run_gpu_tests.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged main (0c0e4b6) again; CPU checks and the PR's GPU tests pass on Radeon RDNA2 iGPU. AI-assisted.

Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged main (ee9c3ed) again; CPU checks and the PR's GPU tests pass on Radeon RDNA2 iGPU. AI-assisted.

docs/design.md
tests/semantic/test_value_semantics.py

AI-assisted.
docs/design.md
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/README.md
tests/semantic/regen_fixtures.py
tests/semantic/test_value_semantics.py

AI-assisted.
@crastinator

Copy link
Copy Markdown
Contributor

Tested eccf7db merged into main aa2988cc (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • New tests pass natively: ps_salu64_bfe (4096/4096 pixels exact); ps_salu64_bitset (4096/4096 pixels exact); ps_salu64_brev_flbit (4096/4096 pixels exact).
  • Whole run_gpu_tests.py: 199/213 native, 199/213 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 47/47.
  • tests/semantic/test_value_semantics.py: 42 passed, 294 subtests passed.

No game files. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested eccf7db merged with main 2d3369a on Linux (Python 3.12.16) and Windows 11 (Python 3.13.1): pass.

  • -I -m unittest discover -s tests/semantic -p test_value_semantics.py: 42 OK on both (39 OK with the file from main, so the 3 new tests are counted). tests/test_shader_checks.py 83 and tests/test_run_gpu_tests.py 41 pass on both; tests/test_docs_*.py pass on both.
  • Negative control (test-only PR): in tools/rdna2spirv.py s_bitset0/1_b64 indexing with & 31 instead of & 63: 4 failures in test_value_semantics.py. Reverted afterwards.
  • Docs: the design.md row edit was checked by the docs tests only; GPU run of the three ps_salu64_* pixel tests not done.

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.

7 participants