Skip to content

Tests: GPU tests for v_frexp_mant_f32, v_frexp_exp_i32_f32 and v_ldexp_f32 - #2165

Open
Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-frexp32
Open

Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-frexp32

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-GPU-FREXP32 (#1902 (comment))

What and why

An opcode inventory of tools/rdna2spirv.py against main (4eb6155) lists v_frexp_mant_f32, v_frexp_exp_i32_f32 and v_ldexp_f32 as checked on the CPU only. This adds two GPU tests for them. #1957 and #1986 add interpreter tests for the same ops and touch other files; this PR does not depend on them.

runtime/test/shaders/cs_w32_frexp_f32.asm (one word per case, derivation in the header):

word case expected
0, 1 frexp_mant(12.0), frexp_mant(-0.1) 0x3F400000 (0.75), 0xBF4CCCCD (-0.8)
2, 3 frexp_mant(-inf), frexp_mant(qNaN 0x7FC00123) the input unchanged
4, 5, 6 frexp_exp of 12.0, 0.1, FLT_MAX 4, -3, 128
7 frexp_exp(+inf) | frexp_exp(qNaN) | frexp_exp(-0.0), plus frexp_exp(1.0) 1

runtime/test/shaders/cs_w32_ldexp_f32.asm:

word case expected
0 ldexp(1.5, 3) 0x41400000
1 ldexp(-inf, -300) 0xFF800000
2, 3 ldexp(-1.5, 127), ldexp(1.0, 128) 0xFF400000, +inf
4, 5 ldexp(1.0, -126), ldexp(-1.0, -200) 0x00800000, -0
6, 7 ldexp(1.0, 0x7FFFFFFF), ldexp(-2.0, 0x80000000) (an unclamped 32-bit exponent sum would wrap) +inf, -0

Denormal inputs and results are left out on purpose: they depend on the f32 denormal mode, which the translator does not model for these ops (comment at the v_frexp_mant_f32 case).

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 both fixtures from regen_fixtures.py. test_value_semantics.py (FrexpLdexpF32) recomputes the words with math.frexp/math.ldexp on the binary32 values, checks that both runners expect them, and runs both fixtures through spirv_mini_interp.

No translator change: every word matches on both GPUs.

Tested

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

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

Negative controls, one line each, reverted after:

  • v_ldexp_f32: the S1 range check nb < 1025 made always true (no clamp). cs_w32_ldexp_f32 fails on both GPUs (word 6 0x0, want 0x7f800000) and test_translated_shaders fails.
  • v_frexp_exp_i32_f32: exponent bias 126 changed to 127. cs_w32_frexp_f32 fails on both GPUs (words 4..7 0x3 0xfffffffc 0x7f 0x0) and test_translated_shaders fails.

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

…p_f32

cs_w32_frexp_f32 and cs_w32_ldexp_f32 store one word per case: normal
values, +-0, +-inf, a quiet NaN, overflow/underflow and S1 = 0x7FFFFFFF /
0x80000000 for ldexp. Registered in check.py and run_gpu_tests.py, with
the fixtures and a value check in test_value_semantics.py. Passes on an
RDNA2 iGPU and an RTX 5080.

AI-assisted.
@emirduran707

Copy link
Copy Markdown
Contributor

Tested 3508cc8 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 exp_f32: 2/2 pass, every word as in the tables above.
    • cs_w32_frexp_f32: 0x3f400000 0xbf4ccccd 0xff800000 0x7fc00123 0x4 0xfffffffd 0x80 0x1
    • cs_w32_ldexp_f32: 0x41400000 0xff800000 0xff400000 0x7f800000 0x800000 0x80000000 0x7f800000 0x80000000
    • Same words with LEONIDA_W64_EMULATE=1.
  • Whole suite (native wave64): 187 shaders translated, 187 pass spirv-val; 169/182 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: 201 shaders translated, 201 pass spirv-val; 158 of 162 pass, 4 skipped (the 3 mesh fixtures and ps_w64x_readlane); both new tests 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.

This adds an RDNA4 card to the RDNA2 iGPU and NVIDIA runs in the description. I did not repeat the negative controls. No game files. AI-assisted (Claude Code).

@c4k3ss

c4k3ss commented Nov 22, 2026

Copy link
Copy Markdown

Tested 3508cc8e on NVIDIA GeForce RTX 5070 Ti (Blackwell, desktop, subgroup 32..32), driver 621.24 (Vulkan 1.4.357), Windows 11 Pro 10.0.26200: pass.

  • python -I scripts/run_gpu_tests.py --filter cs_w32_frexp: 1/1 passed, cs_w32_frexp_f32 words 0x3f400000 0xbf4ccccd 0xff800000 0x7fc00123 0x4 0xfffffffd 0x80 0x1
  • python -I scripts/run_gpu_tests.py --filter cs_w32_ldexp: 1/1 passed, cs_w32_ldexp_f32 words 0x41400000 0xff800000 0xff400000 0x7f800000 0x800000 0x80000000 0x7f800000 0x80000000
  • Both again with LEONIDA_W64_EMULATE=1: 1/1 and 1/1, identical words.
  • python -I -m unittest discover -s tests/semantic -p test_value_semantics.py: 33 tests OK.

Test programs built from main 4eb6155 (the PR changes no C++). llvm-mc 23.1.6 (conda-forge), Vulkan SDK 1.4.363.0, Python 3.13.14. No game files. AI-assisted.

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 3508cc8e7855749ea5ab6eeb07a5e5e226400495 on AMD Custom GPU 0405 (Van Gogh, RDNA2 APU — Steam Deck LCD / Jupiter), RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5: pass.

Ran python3 -I scripts/run_gpu_tests.py --build runtime/build --filter frexp and the same with --filter ldexp:

  • cs_w32_frexp_f32 — 1/1 passed, 8/8 words exact
  • cs_w32_ldexp_f32 — 1/1 passed, 8/8 words exact

The full suite from this branch also passes: 169/182 passed, 13 skipped (same set: 12 D3D12-run fixtures plus ps_w64x_readlane), 0 failed.

@dandasma

Copy link
Copy Markdown
Contributor

Tested 3508cc8 on AMD Radeon RX 9070 (RDNA4, subgroup 32..64), AMD 26.10.1 (LLPC), Vulkan 1.4.359, Windows 11 26300: pass. Python 3.12.10, llvm-mc 21.1.8, Vulkan SDK 1.4.363.0; harness programs built from main 4eb6155 (this PR's base; it changes no C++), with LEONIDA_VK_DEVICE=9070 so no other GPU could take the run.

  • build.py: 201 shaders translated, 201 pass spirv-val (main: 199).
  • check.py: 158 of 162 pass, 4 skipped (main: 156 of 160); cs_w32_frexp_f32 and cs_w32_ldexp_f32 are ok, same skips as main.
  • run_gpu_tests.py --filter cs_w32_frexp_f32: 1/1 passed in three runs, 0x3f400000 0xbf4ccccd 0xff800000 0x7fc00123 0x4 0xfffffffd 0x80 0x1 each time.
  • run_gpu_tests.py --filter cs_w32_ldexp_f32: 1/1 passed in three runs, 0x41400000 0xff800000 0xff400000 0x7f800000 0x800000 0x80000000 0x7f800000 0x80000000 each time.
  • Full run_gpu_tests.py: 187 shaders, 187 pass spirv-val; 169/182 passed, 13 skipped, 0 failed (main 4eb6155: 167/180, 13 skipped). The difference is the two new tests; the skips are the same 13 (12 d3d12_*-run fixtures and ps_w64x_readlane).
    AI-assisted (Claude Code).

Conflicts:
	tests/semantic/regen_fixtures.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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

runtime/test/shaders/check.py
scripts/run_gpu_tests.py

AI-assisted.
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 8d2e867f (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: 166/212 passed, 46 skipped, 0 failed. Both new tests pass: cs_w32_frexp_f32 (0x3f400000 0xbf4ccccd 0xff800000 0x7fc00123 0x4 0xfffffffd 0x80 0x1) and cs_w32_ldexp_f32 (0x41400000 0xff800000 0xff400000 0x7f800000 0x800000 0x80000000 0x7f800000 0x80000000).
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_value_semantics.py: 42 passed, 288 subtests passed.

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

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 8d2e867f (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: 166/212 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_frexp_f32 PASS (0x3f400000 0xbf4ccccd 0xff800000 0x7fc00123 0x4 0xfffffffd 0x80 0x1).
  • New: cs_w32_ldexp_f32 PASS (0x41400000 0xff800000 0xff400000 0x7f800000 0x800000 0x80000000 0x7f800000 0x80000000).

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

AI-assisted (Claude Code).

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