Skip to content

GPU tests for v_mad_legacy_f32, v_mac_legacy_f32, v_mad_f32 and v_mac_f32 (legacy zero rule, denormal flush) - #2002

Open
evilclanker9000 wants to merge 8 commits into
ItsNotRexed:mainfrom
evilclanker9000:claude/mad-legacy-gpu
Open

evilclanker9000 wants to merge 8 commits into
ItsNotRexed:mainfrom
evilclanker9000:claude/mad-legacy-gpu

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-COV-W64EXEC (#1902 (comment))

What and why

An opcode inventory of tools/rdna2spirv.py against main 6a6704d (every opcode the translator handles, checked against runtime/test/shaders/*.asm, tests/** and the fuzzers' tables) finds eight wave64 EXEC ops that no test runs at all: the translator handles them through Gen.EXEC_LOGIC, but only the and/or/andn2 kinds have tests. This adds a GPU test and the matching tests/semantic checks for

s_xor_saveexec_b64, s_andn1_saveexec_b64, s_orn1_saveexec_b64, s_orn2_saveexec_b64, s_nand_saveexec_b64, s_nor_saveexec_b64, s_xnor_saveexec_b64, s_andn1_wrexec_b64.

It is the wave64 counterpart of #1771, which covers the b32 forms; no file overlaps with it.

  • runtime/test/shaders/cs_w64x_saveexec_ext.asm: one 64-lane wave, one case per op. S0 comes from a v_cmp into VCC or an SGPR pair, the old EXEC is set per half. The new EXEC is measured per lane (a VGPR written under it, then read back with all lanes on), D with s_bcnt1/s_ff1, SCC with s_cselect. Each word is code(new EXEC) << 16 | SCC << 15 | code(D) with code = bcnt << 8 | ff1. S0 and EXEC differ between the halves in every case, so a half swap moves the lowest lane; the wrexec case's result is in the high half only, so an SCC taken from the low word would be 0. The derivation from the ISA pseudocode is in the header. Registered in W64X_DUMPS (check.py) and in run_gpu_tests.py.
  • tests/semantic/test_saveexec_ext_b64.py: the same program shape and S0/EXEC table as test_saveexec_b64.py (plus six pairs so every kind has a result in the low half only, the high half only, both and neither), checked lane by lane against the ISA lines as integers, plus the GPU fixture and a check that rebuilds the header's eight words from that model.

No translator change: all eight match the ISA on both GPUs.

Tested

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

GPU driver mode result
AMD Radeon (RDNA2 iGPU, Ryzen 9 9950X3D) 26.10.1 native wave64 (subgroup 64) PASS, 8/8 words
AMD Radeon (same) 26.10.1 LEONIDA_W64_EMULATE=1 PASS
NVIDIA GeForce RTX 5080 616.92 LEONIDA_W64_EMULATE=1 (subgroup 32) PASS

out[0..7] = 671133712 604809224 536905768 537964544 536914948 605325368 537960448 405313576 on all three; the existing cs_w64x_saveexec_b64 still passes.

Negative control: EXEC_LOGIC["andn1"] changed to complement EXEC instead of S0 (one line). cs_w64x_saveexec_ext then fails on both GPUs (out[1] = 134260744, out[7] = 402692096), and test_saveexec_ext_b64.py fails 33 subtests (every andn1 saveexec and wrexec case plus the fixture). Reverted.

python -m unittest discover -s tests/semantic OK, 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.)

Two pixel tests for ops that had CPU checks only. ps_mad_legacy: the
legacy zero rule (0 * inf, NaN * -0 give +0) and the denormal flush of
a product and of a v_mac_legacy_f32 operand. ps_mad_flush: the SHADER-118
flush of a v_mad_f32 operand, a v_mac_f32 product, a denormal sum, and
FLT_MIN div:2 (flush after omod). Expected words derived by hand in the
.asm headers; registered in check.py and run_gpu_tests.py and added as
semantic fixtures with hand constants and a Python reference. The
design.md rows name the tests.

AI-assisted.
@Rainmaker33

Copy link
Copy Markdown

Tested 8b00d4e 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: 138/182 pass, 44 skipped (wave64), no failures (main: 136/180). ps_mad_legacy and ps_mad_flush: 4096/4096 pixels exact.
  • tests/semantic/test_value_semantics.py: OK.

@nonverifiedperson

Copy link
Copy Markdown
Contributor

Tested 8b00d4e on RDNA2: AMD Radeon integrated graphics of a Ryzen 7 9800X3D (gfx1036, subgroup 32..64), AMD driver 32.0.13036.4, Windows 10, Vulkan SDK 1.4.363.0.

  • scripts/build_runtime.ps1: builds clean (352/352).
  • scripts/run_gpu_tests.py with LEONIDA_VK_DEVICE=radeon: 169/182 passed, 13 skipped, 0 failed.
    • ps_mad_legacy: PASS, 4096/4096 pixels exact
    • ps_mad_flush: PASS, 4096/4096 pixels exact
    • The skips are the usual ones on this device (ps_w64x_readlane can't require a 64-wide fragment subgroup; vs_m*/ps_m* run by their own d3d12 tests).
  • python -m unittest discover -s tests/semantic: 1673 tests OK (2 skipped).
  • tests/semantic/regen_fixtures.py --check: clean.

So the legacy zero rule (0·inf and NaN·−0 → +0), the denormal-product flush and the v_mac_legacy_f32 −denormal → −0 case all match the hardware on RDNA2 too.

One thing: the PR description talks about EGEN-COV-W64EXEC / cs_w64x_saveexec_ext, but the commit (08ba945) adds the v_mad_legacy_f32 / v_mac_legacy_f32 / v_mad_f32 / v_mac_f32 GPU tests from the title. Probably the body from another PR was pasted in. Worth fixing before review.

AI-assisted (Claude Code).

@fernquill

Copy link
Copy Markdown

Tested 8b00d4e merged into main 4eb6155 (clean merge) on AMD Radeon RX 9070 XT (RDNA4, gfx1201), RADV Mesa 26.3.1, Arch Linux, kernel 7.3.5; llvm-mc 23.1.5, SPIRV-Tools 2026.4; runtime built from main 4eb6155: pass.

  • The whole semantic suite: 1673 OK.
  • scripts/run_gpu_tests.py: 169/182 passed, 13 skipped, 187/187 translated and valid. ps_mad_flush and ps_mad_legacy PASS.
  • check.py: 157/162, 4 skipped (the one failure is cs_fma_fused, as on main, GPU tests: wire cs_fma_fused in run_gpu_tests and accept GLSL Fma split on RADV #1518). ps_mad_flush and ps_mad_legacy ok.
  • Test by test against main 4eb6155 on the same machine: the only changes are the two new tests (absent → PASS in both runners), so no regression.

AI-assisted (Claude Code).

@esteban-dcp

Copy link
Copy Markdown

Tested 8b00d4ef (the PR head as is, built from its own runtime/), Linux 7.3.5, scripts/run_gpu_tests.py, 0 failures in all three runs:

GPU Driver Result
NVIDIA GeForce RTX 4050 Laptop (Ada, subgroup 32) 620.73.04 138/182 passed, 44 skipped
same GPU, LEONIDA_W64_EMULATE=1 620.73.04 169/182 passed, 13 skipped
AMD Radeon 740M (RDNA3, RADV, subgroup 32..64) Mesa 26.3.1 169/182 passed, 13 skipped

The new ps_mad_legacy and ps_mad_flush both report 4096/4096 pixels exact in all three runs. 187 shaders translate and pass spirv-val; tests/semantic 1673 OK.

No game files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

@crastinator

Copy link
Copy Markdown
Contributor

Tested 8b00d4e merged into main 4eb6155d (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_mad_flush (4096/4096 pixels exact); ps_mad_legacy (4096/4096 pixels exact).
  • Whole run_gpu_tests.py: 169/182 native, 169/182 with LEONIDA_W64_EMULATE=1. The skips are the D3D12-only fixtures and ps_w64x_readlane (RADV can't require a 64-wide fragment subgroup), the same as on main.
  • ctest: 36/36.
  • tests/semantic/test_value_semantics.py: 32 passed, 113 subtests passed.

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

@Impre-visible

Copy link
Copy Markdown

Tested 8b00d4e 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. A Turing datapoint next to the Ampere and AMD runs above.

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: 1673 OK
  • build.py: 201 shaders, 201 translated, 201 pass spirv-val; check.py: 127 of 162 pass, 35 skipped (wave64 without emulation, mesh fixtures)
  • run_gpu_tests.py: 187 shaders: 187 translated, 187 pass spirv-val; 138/182 passed, 44 skipped, 0 failed
  • LEONIDA_W64_EMULATE=1 run_gpu_tests.py: 169/182 passed, 13 skipped (12 fixtures run by the d3d12 tests, 1 needs a 64-wide fragment subgroup), 0 failed
  • New fixtures ps_mad_flush and ps_mad_legacy: each 4096/4096 pixels exact, natively and with LEONIDA_W64_EMULATE=1; check.py ok for both. This driver reports shaderDenormFlushToZeroFloat32 false and shaderDenormPreserveFloat32 false, so the flush ps_mad_flush checks comes from the translated code, not from a driver mode.

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

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested 8b00d4ef80fb90d334473fa951e40fe3486f9a6b 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 ps_mad:

  • ps_mad_flush — 4096/4096 pixels exact
  • ps_mad_legacy — 4096/4096 pixels exact

2/2 passed. 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.

This is the native RDNA2 measurement that SHADER-340 asks for: the denormal flush in v_mad_f32/v_mac_f32 and the legacy zero rule in v_mad_legacy_f32/v_mac_legacy_f32 match the translator on this part.

@zneel

zneel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 8b00d4ef on AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), AMD 26.11.2, Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D CPU (64 GB RAM), Python 3.12.10: pass.

Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows llvm-mc 21.1.8, Vulkan SDK 1.4.363.0. No game files.

run result
run_gpu_tests.py (whole suite, native wave64) 169/182, 0 failed (main 4eb6155d: 167/180); ps_mad_flush and ps_mad_legacy both PASS, 4096/4096 pixels exact
same with LEONIDA_W64_EMULATE=1 169/182, 0 failed; both PASS, 4096/4096 exact
unittest discover -s tests/semantic -p test_value_semantics.py 32 OK
tests/semantic/regen_fixtures.py --check clean
tests/test_shader_checks.py 60 OK

One thing for the author: the PR description is the one from #2015. It's about EGEN-COV-W64EXEC and cs_w64x_saveexec_ext, but this PR's files are ps_mad_legacy/ps_mad_flush, and it links #2015's claim. The title and commits are right, so it probably just needs the matching description and claim link.

AI-assisted (Claude Code); I checked the results.

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

AI-assisted.
@evilclanker9000

Copy link
Copy Markdown
Contributor Author

Merged main (1ed9c01) 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
tests/semantic/test_value_semantics.py

AI-assisted.
docs/design.md
tests/semantic/regen_fixtures.py
tests/semantic/test_value_semantics.py

AI-assisted.
docs/design.md
tests/semantic/regen_fixtures.py

AI-assisted.
@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 006f0f9 on Windows 11 with AMD Radeon(TM) Graphics (32.0.21043.5001) and NVIDIA GeForce RTX 4090 (32.0.16.2101): pass. I set LEONIDA_VK_DEVICE to AMD and then NVIDIA. I ran py -3.14 -I scripts/run_gpu_tests.py --build E:/Leonida-review-work-build/RelWithDebInfo --filter ps_mad_ --require-pass for each adapter. Both shaders passed spirv-val. Both ps_mad_flush and ps_mad_legacy matched all 4,096 pixels on each run. I used the existing Windows runtime harness. AI-assisted.

@BetterJdue

Copy link
Copy Markdown
Contributor

Tested 006f0f91 (this PR merged with main 561b65a8) on a discrete RDNA2 under the AMD Windows driver: AMD Radeon RX 6700 (gfx1031, subgroup 32..64), driver 26.11.2 (32.0.21045.29003), Windows 11 Pro 26300: pass.

I ran python -I scripts/run_gpu_tests.py --filter ps_mad at this head. The test programs are a main 03b09a08 build (MSVC 19.44, Ninja, RelWithDebInfo); this PR changes no runtime C++.

  • Native: 2/2. ps_mad_flush 4096/4096 pixels exact, ps_mad_legacy 4096/4096 pixels exact.
  • LEONIDA_W64_EMULATE=1: 2/2, the same counts.
  • The pre-merge head 751e9d5b gave the same counts.

Not run: the semantic suite, and the other GPU fixtures.

AI-assisted verification using synthetic inputs.

@MKS2508

MKS2508 commented Nov 23, 2026

Copy link
Copy Markdown

Tested 006f0f915 on AMD RX 5700 (RADV NAVI10), Mesa 26.2.3, Vulkan 1.4.357, NixOS (LLVM 21.1.8): pass

Built the full fixture corpus with build.py and ran check.py against runtime/build/linux: 194/205 pass, 9 skipped. Both of this PR's shaders pass: ps_mad_legacy and ps_mad_flush. Skips are environmental (mesh fixtures and VK_KHR_fragment_shader_barycentric, which RADV doesn't expose on RDNA1).

RDNA1/RADV check claimed as SHADER-837 in #7049.

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.