Skip to content

Tests: GPU test for v_fma_mix_f32, v_fma_mixlo_f16 and v_fma_mixhi_f16 - #2211

Open
evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:test/gpu-fmamix
Open

evilclanker9000 wants to merge 3 commits into
ItsNotRexed:mainfrom
evilclanker9000:test/gpu-fmamix

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-GPU-FMAMIX (#1902 (comment))

What and why

An opcode inventory of tools/rdna2spirv.py against main (4eb6155) lists v_fma_mix_f32, v_fma_mixlo_f16 and v_fma_mixhi_f16 as checked on the CPU only. Their translation depends on the driver fusing Fma and on the round-to-odd step in Gen.fma_mix_odd, so this adds a GPU test for them.

runtime/test/shaders/cs_w32_fma_mix.asm (one word per case, derivation in the header; every mixlo/mixhi destination starts as 0xABCD1234):

word case expected
0 mix_f32, op_sel:[1,0,0] op_sel_hi:[1,1,0]: 2.0 (hi) * 3.0 (lo) + 0.5f 0x40D00000
1 mix_f32, all f32: (1 + 2^-12)^2 - 1, one rounding 0x3A000400 (rounding the product first gives 0x3A000000)
2 mixlo, op_sel:[0,1,0] op_sel_hi:[1,1,1]: 1.0 * 4.0 + 0.25 0xABCD4440
3 mixhi, op_sel:[1,0,1] op_sel_hi:[1,1,1]: 2.0 * 3.0 + 0.5 0x46801234
4 mixlo, all f32: (1 + 2^-11) + 2^-40, just above an f16 tie 0xABCD3C01 (rounding through f32 gives 0x3C00)
5 mixhi, neg src0: -(1 + 2^-11) - 2^-40 0xBC011234
6 mixlo clamp, neg src0: -1.0 * 3.0 + 0.25 0xABCD0000
7 mixlo, all f32: 300.0 * 300.0 0xABCD7C00 (+inf)

Registered like cs_w32_new_ops (WAVE32_DUMPS/CS_DUMPS in check.py, the dump list and wave32 exclusion in run_gpu_tests.py), plus the fixture from regen_fixtures.py. test_value_semantics.py (FmaMix) recomputes the words with exact Fraction arithmetic and one round to nearest even, checks that words 1 and 4 differ when rounded through f32 first, checks that both runners expect the words, and runs the fixture through spirv_mini_interp.

No translator change: every word matches on both GPUs, including the two single-rounding cases.

Tested

Windows 11, python -I scripts/run_gpu_tests.py --filter fma_mix:

GPU driver result
AMD Radeon (RDNA2 iGPU, Ryzen 9 9950X3D) 26.10.1 PASS, 8/8 words exact
NVIDIA GeForce RTX 5080 616.92 PASS, 8/8 words exact

Negative control: Gen.fma_mix_srcs reads every f16 source from the low half (self.f16_in(src, 0) for sb[i], one line). cs_w32_fma_mix fails on both GPUs (words 0, 2, 3: 0x40600000 0xabcd4280 0x42801234) and test_translated_shader fails. Reverted.

python -m unittest discover -s tests/semantic: 1674 tests OK (2 skipped). python tests/semantic/regen_fixtures.py --check clean, python -I tests/test_shader_checks.py and python -I tests/test_run_gpu_tests.py OK.

AI-assisted.

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.)

cs_w32_fma_mix covers op_sel/op_sel_hi source selection, neg, clamp, f16
overflow, the kept destination half, and two inputs where one rounding
differs from rounding through f32 first. Registered in check.py and
run_gpu_tests.py, with the fixture and a value check in
test_value_semantics.py. Passes on an RDNA2 iGPU and an RTX 5080.

AI-assisted.
@Krashgamer

Copy link
Copy Markdown
Contributor

Tested 5874685 (contains main 4eb6155) on NVIDIA GeForce RTX 3080 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 25H2, MSVC 14.51.36231, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8: pass. An older NVIDIA generation and driver branch than the RTX 5080 / 616.92 in the description.

  • run_gpu_tests.py --filter cs_w32_fma_mix: PASS, 8/8 words exact (0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00). Words 1 and 4, the single-rounding cases, come out right here too.
  • Same with LEONIDA_FMA=khr (OpFmaKHR): PASS, same 8 words.
  • Your negative control (f16_in(src, 0) in Gen.fma_mix_srcs) fails here with the words you reported: 0x40600000 0x3a000400 0xabcd4280 0x42801234 .... Reverted.
  • Full run_gpu_tests.py: 137/181 passed, 44 skipped, 0 failed (main 4eb6155: 136/180, same skips).
  • FmaMix (3/3), regen_fixtures.py --check clean, tests/test_shader_checks.py (60 OK), tests/test_run_gpu_tests.py (30 OK).

AI-assisted (Claude Code); no game files.

@emirduran707

Copy link
Copy Markdown
Contributor

Tested 5874685 on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass.

  • python -I scripts/run_gpu_tests.py --build <build> --filter cs_w32_fma_mix: 1/1 pass, words 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00. Same with LEONIDA_W64_EMULATE=1.
  • Whole suite (native wave64): 186 shaders translated, 186 pass spirv-val; 168/181 passed, 13 skipped, 0 failed. The skips are the 12 fixtures the d3d12_* tests run, and ps_w64x_readlane (skipped on main too, see check.py: judge ps_w64x_readlane where vk_harness required 64 (its line has no "required") #2085; not from this PR).
  • build.py + check.py: 200 shaders translated, 200 pass spirv-val; 157 of 161 pass, 4 skipped (the 3 mesh fixtures and ps_w64x_readlane); cs_w32_fma_mix ok.
  • CPU: python -I -m unittest discover -s tests/semantic -p test_value_semantics.py 33 OK, tests/test_shader_checks.py 60 OK, tests/test_run_gpu_tests.py 30 OK, tests/semantic/regen_fixtures.py --check clean.

Test programs: an MSVC 14.44 build of 4eb6155, this PR's base. The PR changes no C++ or CMake, so they are what its head builds; the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0.

The check above is NVIDIA (32-wide); this one is an AMD card with native 64-wide subgroups, RDNA4. No negative control run here. No game files. AI-assisted (Claude Code).

@Rainmaker33

Copy link
Copy Markdown

Tested 5874685 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass.

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

  • scripts/run_gpu_tests.py: 137/181 pass, 44 skipped (wave64), no failures (main: 136/180). cs_w32_fma_mix: 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00.
  • tests/semantic/test_value_semantics.py: OK.

@AmazingMoaaz

AmazingMoaaz commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested 5874685 on NVIDIA RTX 3050 Laptop GPU (driver 617.42) and Intel UHD Graphics (Xe-LP, Tiger Lake-H iGPU, driver 101.7088), Windows 11 Pro build 26300, scripts\build_runtime.ps1 (MSVC 19.51), llvm-mc 23.1.6, Vulkan SDK 1.4.363.

  • RTX 3050: pass, all 8 words: 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00.
  • Intel UHD: fail on word 1 only: 0x3a000000, want 0x3A000400, the "rounding the product first" value from the header. The other 7 words match, including the f16 single-rounding cases (words 4 and 5).

I think the test is right and this is the Intel driver splitting GLSL Fma into two roundings, which the spec allows. On main 4eb6155, check.py on the same device gives cs_fma_fused = 00000000 a8800000 3a000000 00000000 33800000 00000000 28800000 00007351. That's the split value in words 0, 2, 3 and 5 (v_fma_f32, v_fmaak_f32, v_fmac_f32) and fused in 1, 4, 6 and 7. check.py reports that as its one failure on this device (116 of 160 pass, 43 skipped); run_gpu_tests.py doesn't run cs_fma_fused at all, so its summary doesn't show it. This device has no VK_KHR_shader_fma (vulkaninfo), so LEONIDA_FMA=khr can't run here.

Apart from that, the full run_gpu_tests.py on the Intel UHD is 124/181 passed, 56 skipped, cs_w32_fma_mix the only failure (main: 124/180, 56 skipped). python -m unittest discover -s tests/semantic: 1674 tests OK (2 skipped).

Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
@evilclanker9000

Copy link
Copy Markdown
Contributor Author

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

@evilclanker9000

Copy link
Copy Markdown
Contributor Author

Merged current main into the branch (conflicts in check.py, run_gpu_tests.py, regen_fixtures.py and test_value_semantics.py, resolved by keeping both sides' entries). cs_w32_fma_mix still passes on an RTX 5080 (616.92) and on the Radeon gfx1036 (26.10.1); regen_fixtures.py --check and test_value_semantics.py (42 tests) are OK. AI-assisted.

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 3f3633a7 (the rebased head) on NVIDIA GeForce RTX 3060 Ti (subgroup 32..32), driver 580.173.02, Linux (kernel 6.18), Python 3.14: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. cs_w32_fma_mix prints 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00 and passes.
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_value_semantics.py: 42 passed, 284 subtests passed.

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

@radv-tinker

Copy link
Copy Markdown
Contributor

Tested 3f3633a7 on AMD Radeon RX 9070 XT (RDNA4), RADV GFX1201, Linux (Fedora 43), subgroup 32..64: pass. This is the first RADV/Mesa check; the earlier ones were Windows drivers.

python3 -I scripts/run_gpu_tests.py --filter cs_w32_fma_mix (Mesa shader cache off):

Driver Compiler Result
Mesa 25.3.6 (Fedora package) ACO PASS
Mesa 25.3.6 (Fedora package) LLVM (RADV_DEBUG=llvm) PASS
Mesa 26.3.1 (built from source) ACO PASS

All three give the expected words 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00. The shader translates and passes spirv-val. The PR's CPU tests also pass: test_value_semantics.py, 42 tests OK.

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 3f3633a7 (merge base aa2988cc) on an NVIDIA GeForce RTX 5070 Ti (Blackwell, subgroup 32..32), driver 616.56, Windows 11 10.0.26300. Translator and fixtures from this head; runtime test programs built from main aa2988cc (MSVC 19.44, Vulkan-Headers fetched by CMake, loader from the NVIDIA driver); spirv-as/spirv-val and llvm-mc 21 from WSL Ubuntu: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped (wave64 programs on a 32-wide GPU), 0 failed.
  • Diffed test by test against main aa2988cc (164/210, 46 skipped): every main result is the same here.
  • New: cs_w32_fma_mix PASS (0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00).

Not run: LEONIDA_W64_EMULATE=1, other vendors, Linux. No game files.

AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Tested 3f3633a (merge base aa2988c) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass

Tested the PR head merged with current main 7b7d73f8 (clean merge, not pushed). Runtime harnesses built from main 7b7d73f8, llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 7b7d73f8 this PR
run_gpu_tests.py native 170/217 passed, 47 skipped 171/218 passed, 47 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 201/217 passed, 16 skipped 202/218 passed, 16 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/semantic/test_value_semantics.py tests/test_shader_checks.py tests/test_run_gpu_tests.py tests/test_cf_diff.py 162 passed, 315 subtests passed (3 shared files) 204 passed, 600 subtests passed in 5.76s

Line-by-line against my main run (results that differ from main):

  • native:
    • cs_w32_fma_mix main: - pr: PASS 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00
  • emulated:
    • cs_w32_fma_mix main: - pr: PASS 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00

Not run: the full unittest discover -s tests/semantic (about 6 minutes, and main alone has failures there); only the test files this PR touches plus the shared checker tests ran. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

@amarovndres

Copy link
Copy Markdown

Tested 3f3633a7 on AMD Radeon RX 9060 XT (RDNA4, discrete, subgroup 32..64), AMD 26.10.1 (32.0.32015.7029, LLPC, Vulkan 1.4.359), Windows 11 Pro (build 26200): pass.

  • scripts/run_gpu_tests.py (full suite; test programs built from this head with llvm-mingw, llvm-mc 23.1.6): 197/211 passed, 14 skipped, 0 failed. main d0835dd9 on the same machine: 196/210 passed, 14 skipped.
    • PASS cs_w32_fma_mix 0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00
  • tests/semantic/test_value_semantics.py: 42 tests, OK

AI-assisted (Claude Code). Synthetic shaders only, no game files.

@dcastell1

Copy link
Copy Markdown
Contributor

Tested 3f3633a on RTX 5090, 621.24, Windows 11: pass. Programs rebuilt from this tree, LEONIDA_W64_EMULATE=1: 196/211 passed, 15 skipped, 0 failed, and the new case is exact:

PASS  cs_w32_fma_mix   0x40d00000 0x3a000400 0xabcd4440 0x46801234 0xabcd3c01 0xbc011234 0xabcd0000 0xabcd7c00

That is the eight-word derivation from the header, on hardware, for v_fma_mix_f32 and the two f16 forms.

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.