Skip to content

Translator: a wave32 FSSM header is only contradicted by markers wave32 code cannot contain - #2925

Open
Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:claude/w32-soft-markers
Open

Vonsek wants to merge 4 commits into
ItsNotRexed:mainfrom
Vonsek:claude/w32-soft-markers

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-W32-S64-MARKERS, #2716 (comment)

What and why

translate() takes the wave size from the FSSM header, but first checks the header against code markers and refuses a listing whose header says wave32 and whose code has any WAVE64_RE marker. Two of those markers are plain data ops that wave32 compiler output contains. With AMD clang (-mcpu=gfx1036 -mno-wavefrontsize64, OpenCL), a uniform 64-bit popcount, ctz and clz compile to s_bcnt1_i32_b64, s_ff1_i32_b64 and s_flbit_i32_b64 (the same code in wave64 mode is identical); a wave32 lane-id chain may also end in v_mbcnt_hi_u32_b32 (clang folds it away today, but the instruction is valid and the translator computes it correctly in wave32). A wave32 shader with a 64-bit scalar popcount was refused with "FSSM wave32 header contradicts wave64 code".

Now the contradiction check uses only the markers wave32 code cannot contain: exec_hi, *_saveexec_b64, *_wrexec_b64, s_wqm_b64, s_bfm_b64 (the translator models both as lane masks) and a _b64 op on EXEC or VCC. s_bcnt0/1_i32_b64, s_ff0/1_i32_b64 and v_mbcnt_hi_u32_b32 still count as wave64 evidence when there is no header (the fallback heuristic is unchanged), but a wave32 header now wins. WAVE64_RE itself is unchanged, so wave64_graphics_scan.py and the fallback behave as before.

New GPU test cs_w32_s64_data (wave32 compute, 8 words): s_bcnt1/0_i32_b64, s_ff1/0_i32_b64 on data pairs with only the high half set, and v_mbcnt_hi_u32_b32 after v_mbcnt_lo_u32_b32. compute_fixture.py gets a ; fssm-wave: 32|64 header comment that makes build.py write a real FSSM header (magic and the 0xd4 bit 5 flag) for that test; without it the synthetic zero-prefixed compute header has no magic, so the heuristic would decide. Semantic test test_w32_s64_data_fixture.py: hand constants and a plain-Python model, the shader in the interpreter under a wave32 header, the still-refused markers, the wave64 header, and the no-header fallback.

Tested

  • Red on main: the semantic test errors (FSSM wave32 header contradicts wave64 code); run_gpu_tests.py --filter cs_w32_s64_data reports "missing .spv (translation failed)". Green with this change.
  • AMD Radeon iGPU (driver 26.10.1): PASS, 8/8 words exact. RTX 5080 (driver 616.92): PASS, 8/8 words exact.
  • Negative control (fails, then reverted): the s_ff0_i32_b64 high-word offset 32 changed to 33 fails on the Radeon (word 3 expected 32, got 33).
  • python -m unittest discover -s tests/semantic, regen_fixtures.py --check, tests/test_shader_checks.py, tests/test_fssm_wave_size.py, tests/test_wave64_graphics_scan.py: all pass (discover 4143 tests OK, 3 skipped; regen --check clean; shader_checks, fssm_wave_size and wave64_graphics_scan 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 (the "Wave64 handling" row).

AI-assisted.

…32 code cannot contain

s_bcnt0/1_i32_b64 and s_ff0/1_i32_b64 on a 64-bit SGPR pair, and
v_mbcnt_hi_u32_b32, are data ops that wave32 compiler output has (clang
-mno-wavefrontsize64 emits s_bcnt1_i32_b64 and s_ff1_i32_b64 for a 64-bit
popcount and ctz). With a wave32 FSSM header they raised "FSSM wave32 header
contradicts wave64 code". Only exec_hi, saveexec/wrexec_b64, s_wqm_b64,
s_bfm_b64 and _b64 ops on EXEC/VCC contradict it now; without a header the
markers still imply wave64. GPU test cs_w32_s64_data (build.py writes a real
wave32 FSSM header for a "; fssm-wave: 32" comment), semantic test, contract
row.

AI-assisted.
@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of f74da3cb (I didn't run it). Splitting the markers is right. exec_hi, *_saveexec_b64/*_wrexec_b64, s_wqm_b64/s_bfm_b64 and _b64 ops on EXEC/VCC can't appear in wave32 code, while s_bcnt*/s_ff*_b64 on plain SGPR pairs and v_mbcnt_hi are ordinary data ops LLVM emits in wave32 too. So only the first group should contradict a wave32 header, and the broader set still decides when there's no header. I worked the fixture's expected words out from the bit patterns and they all check: 2 and 31 for 0x00000100_80000000; 16, 32 and 48 for 0xffff0000_ffffffff; −1 for all ones; and 5 and 12 for the two mbcnt lanes (bits 0–3, 8–11 and 16–19 of 0x0f0f0f0f are below lane 20, and the hi half adds nothing in wave32).

AI-assisted review (Claude Code).

@Rainmaker33

Copy link
Copy Markdown

Tested f74da3c 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 77444fa. VS 2022, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8; harness programs from a CMake build of main; overlay layers off.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested f74da3cb on CachyOS Linux, RTX 5070 Ti, NVIDIA 620.73.04. The synthetic cs_w32_s64_data fixture translated, passed spirv-val and returned all eight exact expected words on Vulkan: 2, 31, 16, 32, 48, 0xffffffff, 5, 12. All 13 FSSM wave-size and fixture semantic tests passed. AI-assisted.

@emirduran707

Copy link
Copy Markdown
Contributor

Tested f74da3c 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. The checks above have no AMD run from outside the author; this adds an AMD card with native 64-wide subgroups.

  • python -I scripts/run_gpu_tests.py --build <build> --filter <fixture>, one run per new fixture:
    • cs_w32_s64_data: PASS, 2 31 16 32 48 4294967295 5 12; same with LEONIDA_W64_EMULATE=1
  • Whole suite (native wave64): 195 shaders translated, 195 pass spirv-val; 176/190 passed, 14 skipped, 0 failed. The skips are the 14 fixtures the d3d12_* tests run.
  • build.py + check.py: 215 shaders: 215 translated, 215 pass spirv-val; 165 of 168 pass, 3 skipped; ok for cs_w32_s64_data.
  • CPU: python -I -m unittest discover -s tests/semantic -p test_w32_s64_data_fixture.py 6 OK, tests/test_shader_checks.py 69 OK, tests/test_run_gpu_tests.py 34 OK, tests/semantic/regen_fixtures.py --check clean. I did not run the whole tests/semantic suite.

Test programs: an MSVC 14.44 build of main ec8ec4c; this PR's runtime C++ and CMake are identical to that commit, and the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0. No negative control run here. No game files. AI-assisted (Claude Code).

@crastinator

Copy link
Copy Markdown
Contributor

Tested f74da3c merged into main 16282101 (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 test passes natively: cs_w32_s64_data (2 31 16 32 48 4294967295 5 12).
  • Whole run_gpu_tests.py: 176/190 native, 176/190 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • tests/semantic/test_w32_s64_data_fixture.py: 6 passed, 20 subtests passed.

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

@bvtterbroot

Copy link
Copy Markdown

Tested f74da3c on AMD Radeon RX 7900 XTX (RDNA3, Navi 31; native wave32 and wave64), AMD driver 26.11.2, Vulkan 1.4.359, Windows 11: pass.

  • run_gpu_tests.py: 176/190 passed, 14 skipped; the new cs_w32_s64_data passes.
  • python -I -m unittest discover -s tests/semantic -p test_w32_s64_data_fixture.py: 6 tests OK.
  • python -I tests/semantic/regen_fixtures.py --check: clean.

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

@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51):

No problems found. ctest on the RTX 4080 SUPER: 129/129 passed. Intel UHD 770 ctest: only the two known base failures, d3d12_descriptor (fixed by #2948) and d3d12_subgroup (fixed by #2934).
Fixture cs_w32_s64_data: PASS on both RTX 4080 SUPER and Intel UHD 770 (identical output).

docs/design.md
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested 0d4c3b7 (a re-test at the new head) on AMD Radeon RX 9070 XT (RADV GFX1201, wave32/64) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

No game files. AI-assisted.

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.

9 participants