Skip to content

GPU fixtures for computed writes to exec_lo / exec_hi (SHADER-1264) - #8995

Open
zsigisti wants to merge 2 commits into
ItsNotRexed:mainfrom
zsigisti:test/shader-1264-exec-computed-fixture
Open

zsigisti wants to merge 2 commits into
ItsNotRexed:mainfrom
zsigisti:test/shader-1264-exec-computed-fixture

Conversation

@zsigisti

Copy link
Copy Markdown

Claimed in the coordination issue as: GPU fixture for SHADER-1264 (claim)

Depends on: #8353 or #8424. Either one is enough: they fix the same bug, and this PR's new tests fail on main until one of them lands.

What and why

SHADER-1264 has two open fixes, #8353 and #8424. Both check themselves only with CPU tests. Neither adds a GPU test to the suite, so nothing on real hardware would catch the rule breaking again after a merge. This PR adds GPU tests the maintainer can run against both:

  • runtime/test/shaders/cs_w32_exec_computed.asm: one 32-thread wave32.
  • runtime/test/shaders/cs_w64_exec_computed.asm: one 64-thread wave64, with exec_hi and both halves.

Each case writes a computed value into exec_lo / exec_hi, then marks the lanes that run a VALU write. Lane 0 stores lane count << 8 | lowest lane for each case. The base value comes from v_readfirstlane_b32, so the translator can't fold a write into a constant and take the constant path, which was already right (cs_exec_const). The cases:

wave32 wave64
s_lshl_b32 into EXEC lane 3 exec_hi: lane 35
s_add_u32 into EXEC lanes 4..7 exec_lo, exec_hi = 0
s_bfm_b32 into EXEC lanes 16..27 exec_hi, exec_lo = -1
both halves computed – lanes 3, 32, 39
s_not_b32 / s_mov_b32 of a number right on main already right on main already
lane mask (VCC) s_and_b32 a number right on main already right on main already

The last two rows were already right before the fix; they check that a fix keeps them right. #8353 treats s_mov_b32 from a lane-mask SGPR differently from #8424, which always takes the per-lane bit.

Changes:

  • The two fixtures, with their expected words in scripts/run_gpu_tests.py and runtime/test/shaders/check.py. The wave32 one is registered like cs_w32_andn2_exec, the wave64 one like cs_w64_mask_imm: it needs a 64-wide subgroup or LEONIDA_W64_EMULATE=1.
  • tests/semantic/test_exec_computed.py: runs both fixtures through the translator and spirv_mini_interp on every lane, so CI checks the words without a GPU. A plain-Python reference recomputes each word from the case's EXEC.
  • Generated tests/semantic/fixtures/disasm/*.s (regen_fixtures.py --check is clean), and a line in tests/semantic/README.md.

There's no new translator rule here, so no docs/design.md contract row. #8353 or #8424 brings the rule; its row can name these tests as its GPU check.

Tested

NVIDIA GeForce RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 615.78.08, Vulkan 1.4.351, Arch Linux, llvm-mc 23.1.4, Python 3.14.8. Test programs built from main 867d922f0 (-DLEONIDA_VULKAN_HEADERS_FETCH=ON).

tree cs_w32_exec_computed cs_w64_exec_computed (LEONIDA_W64_EMULATE=1) test_exec_computed.py
this PR on main FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3 FAIL, the same words
+ #8353 (cb7c5b322) PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3 OK
+ #8424 (1d93673c5) PASS PASS OK

The CPU interpreter and the GPU agree word for word, both before and after the fix. Without emulation, cs_w64_exec_computed skips on this device ("no 64-wide compute subgroup"), as the other wave64 dumps do. A native wave64 run on AMD would be the first hardware check of the expected words, which are worked out by hand from the ISA in each .asm header.

AI-assisted: yes (Claude)

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 here: see above.)

@matheusfermiano-source

Copy link
Copy Markdown

Native wave64 hardware check on Linux with the Radeon 660M (RADV Mesa 26.3.1), fixture head b643ebd3. For the direct wave64 runs, I passed --require-wave64 to vk_compute_test, confirmed compute subgroup size: 64, and compared the binary readback to the fixture's expected words.

Translator applied to the fixture branch Native wave64 output
No fix 8224 8192 16384 16384 8192 4132 0 3 (4/8 match)
#8353 at cb7c5b32 291 1028 11264 771 8192 4132 0 3 (8/8 match)
#8424 at 1d93673c 291 1028 11264 771 8192 4132 0 3 (8/8 match)

Both fixes applied independently to the fixture branch. The real run_gpu_tests.py --filter exec_computed --require-pass invocation passed 2/2 for each fix on this GPU (wave32 and native wave64). The modules passed spirv-val. I also reproduced the existing CPU difference on this host. test_active_cache.py passed 9/9 with #8353 and 8/9 with #8424, where test_divergent_loop_loads_active_once_per_block failed.

Synthetic shaders only. AI-assisted (Codex).

@Grimkeh Grimkeh left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent Linux CPU review

What changed: GPU fixtures for computed writes to exec_lo / exec_hi (SHADER-1264), plus a semantic test that expects per-lane EXEC bits.

Checked: tests/semantic/test_exec_computed.py — test_words_follow_from_the_masks OK, but test_words fails on this tip: interpreter still returns the OLD_PREFIX whole-half masks ([8192, 8192, 8192, …]). This PR adds fixtures/tests only — no rdna2spirv change — so the semantic expectation is ahead of the translator.

Needs the SHADER-1264 translator fix (or the test gated) before merge. No game files.

@nonverifiedperson

Copy link
Copy Markdown
Contributor

AMD Windows and NVIDIA Windows run of the new fixtures at b643ebd, merged with current main (clean merge). Each fix's tools/rdna2spirv.py diff was applied on top in turn, with scripts/run_gpu_tests.py --filter exec_computed:

translator cs_w32_exec_computed, Radeon cs_w64_exec_computed, Radeon (subgroup 64) cs_w32_exec_computed, RTX 5070 Ti
main FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3 FAIL (same words as the Radeon)
+ #8424 PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3 PASS
+ #8353 PASS (same words) PASS (same words) PASS

The wave64 fixture skips on the RTX 5070 Ti, because the card has no 64-wide subgroup. Both fixes give identical words on both drivers. The fixtures catch the bug on main, and the cases that were already right (the s_not_b32/s_mov_b32 number and the VCC mask cases) give the same words on main and with either fix. python -m unittest discover -s tests/semantic -p test_exec_computed.py fails 2 on the merge without a fix, as the description says.

The words agree with my silicon check of the same rule on #8424 (gfx1036 hw_oracle, wave64).

Windows 10 22H2, AMD Radeon iGPU gfx1036 (driver 32.0.13036.4), NVIDIA RTX 5070 Ti (driver 621.35), Vulkan SDK 1.4.363. Synthetic values only, no game files. AI-assisted (Claude Code).

@Diskuss

Diskuss commented Nov 23, 2026

Copy link
Copy Markdown

Tested b643ebd37 against both fixes on AMD Radeon RX 9070 XT (RDNA4, gfx1201), Adrenalin 26.10.1 (Windows driver 32.0.32015.7029), Windows 11 Pro 26200, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8. This is the AMD Windows (LLPC) side next to the RADV run above. The fixtures catch the bug, and both fixes pass them.

Each configuration starts from main 867d922f0, and every merge was clean. The fix heads were #8353 cb7c5b322 and #8424 1d93673c5. No C++ changed, so the runner retranslated the fixtures with each branch's rdna2spirv.py. Native wave64 is confirmed: vk_subgroup_info.py reports native64_compute true, subgroup 32..64. Each cell below ran 2x with identical words.

cs_w32_exec_computed cs_w64_exec_computed native cs_w64_exec_computed LEONIDA_W64_EMULATE=1
main + this PR FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3 FAIL, same words
+ #8353 PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3 PASS
+ #8424 PASS, same words PASS, same words PASS
  • Only the computed-EXEC cases fail on main. In wave32 that is words 0–2 (s_lshl_b32, s_add_u32, s_bfm_b32), in wave64 words 0–3. These are the same words the description reports. The cases marked "right on main already" pass on main here as well.
  • Native and emulated wave64 give identical words in every configuration.
  • Semantic test. test_exec_computed.py fails on main + this PR (2/2) and is OK with either fix. regen_fixtures.py --check is clean in all three configurations.
    • py -I tests/semantic/test_exec_computed.py can't import support, so I ran it the way run_semantic_tests.py does, as python -m unittest from tests/semantic.
  • Full run_gpu_tests.py, with either fix: 227/243 passed, 16 skipped, 0 failed. That is main's 225/241 plus the two new fixtures.

One gap, for whoever picks between #8353 and #8424: the description says the two fixes treat s_mov_b32 from a lane-mask SGPR differently. No word in these fixtures tells them apart: #8353 and #8424 produce identical results in every case, native and emulated. If that difference should be pinned on hardware, it needs its own case, an s_mov_b32 exec_lo, <SGPR written by a v_cmp>. As the fixtures stand, they confirm that both fixes are right on what they test, not that the two are equivalent.

Not covered:

  • No separate negative control. The main configuration fails with the predicted words, which serves as one.
  • Linux/RADV, already covered above.
  • RDNA2/3 on the Windows driver.

No game files. AI-assisted.

@dragoso

dragoso commented Nov 23, 2026

Copy link
Copy Markdown

Tested b643ebd3 on Windows 11 with two GPUs: AMD Radeon Graphics (Ryzen 7 7700X iGPU, RDNA2, AMD 32.0.21042.62, subgroup 32..64, native wave64) and NVIDIA RTX 5060 Ti (Blackwell, NVIDIA 617.42, subgroup 32). Local merges on main 867d922f; test programs built from that main (this PR doesn't touch them). llvm-mc 21.1.8, Vulkan SDK 1.4.363.0, MSVC 14.51.

python -I scripts/run_gpu_tests.py --build runtime\build --filter exec_computed, GPU picked with LEONIDA_VK_DEVICE:

Translator AMD iGPU (wave64 native) RTX 5060 Ti RTX 5060 Ti, LEONIDA_W64_EMULATE=1
this PR alone 0/2: w32 8192 8192 8192 7682 512 4100 0 3, w64 8224 8192 16384 16384 8192 4132 0 3 0/2 (w32 fails as on AMD; w64 skipped, no 64-wide subgroup) 0/2, same words as AMD
+ #8353 at cb7c5b32 2/2 1/1 (w64 skipped) 2/2
+ #8424 at 1d93673c 2/2 1/1 (w64 skipped) 2/2

With either fix the words are 259 1028 3088 7682 512 4100 0 3 (w32) and 291 1028 11264 771 8192 4132 0 3 (w64), matching the expected values in check.py / run_gpu_tests.py. Without a fix the w64 words are the same as the Radeon 660M check above on RADV, so the AMD Windows driver and NVIDIA (emulated wave64) agree with it. The new fixtures catch the bug on all three paths and pass with both fixes.

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

@LewisCodesWebsites

Copy link
Copy Markdown

Tested b643ebd on AMD Radeon 660M (Ryzen 5 7535HS iGPU, RDNA2, subgroup 32..64, native wave64, no LEONIDA_W64_EMULATE), Adrenalin 32.0.21045.1000 (Vulkan driver 2.0.353), Windows 11 build 26200, MSVC 2026. Run with run_gpu_tests.py --disasm-dir tests/semantic/fixtures/disasm --filter exec_computed (no llvm-mc on this machine, so the PR's generated .s fixtures were used rather than assembling the .asm).

tree cs_w32_exec_computed cs_w64_exec_computed
this PR alone FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3
+ #8353 (cb7c5b3) PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3
+ #8424 (1d93673) PASS PASS

Words match the RTX 5070 results in the description; wave64 here is native hardware rather than emulation. AI-assisted.

@towade

towade commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Intel data point for b643ebd3 (on main 867d922f0): Intel UHD Graphics 770 (Xe-LP, driver 32.0.101.7092, subgroup 8..32, so cs_w64_exec_computed runs with LEONIDA_W64_EMULATE=1), Windows 11 26300, MSVC 19.44, python -I scripts/run_gpu_tests.py --filter exec_computed --disasm-dir tests/semantic/fixtures/disasm, each fix's tools/rdna2spirv.py diff applied in turn: pass.

translator cs_w32_exec_computed cs_w64_exec_computed (emulated)
main FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3
+ #8353 cb7c5b32 PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3
+ #8424 1d93673c PASS (same words) PASS (same words)

The same words as the AMD and NVIDIA runs above, so the emulated wave64 path agrees with native wave64 here. The same run on an RX 9070 XT with the newer driver 32.0.32029.2010 also gives these words, as in Diskuss's run on 32.0.32015.7029.

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

@junaydirfan

Copy link
Copy Markdown

First Intel and Linux runs, with each fix. I tested b643ebd3 merged onto main 867d922f on an Intel Raptor Lake-S iGPU (Xe-LP) with Mesa ANV 26.3.1 and on an RTX 4080 Laptop with NVIDIA 620.73.04 (CachyOS). The command was run_gpu_tests.py --filter exec_computed with LEONIDA_W64_EMULATE=1, since neither GPU runs a 64-wide compute subgroup.

translator cs_w32_exec_computed cs_w64_exec_computed test_exec_computed.py
main FAIL 8192 8192 8192 7682 512 4100 0 3 FAIL 8224 8192 16384 16384 8192 4132 0 3 fails
+ #8353 cb7c5b32 PASS 259 1028 3088 7682 512 4100 0 3 PASS 291 1028 11264 771 8192 4132 0 3 OK
+ #8424 0e24e3bf PASS, same words PASS, same words OK

The results are the same on both GPUs. Both fixes give identical words on every case, so these fixtures don't separate them. The s_mov_b32-from-a-lane-mask-SGPR difference you describe isn't covered by a case that fails one of them. The full run_gpu_tests.py with this PR alone shows no change on either GPU apart from the two new fixtures.

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