vk_harness exits 77, the code vk_compute_test and vk_store_test already use for a
device that cannot run a test, when VKH_GS is set and the device has no
geometryShader, or VKH_MESH is set and it has no VK_EXT_mesh_shader. Before, a
missing mesh extension exited 1 and a missing geometryShader failed in
vkCreateDevice with VK_ERROR_FEATURE_NOT_PRESENT (MoltenVK, #166).
run_gpu_tests.py (gs_tri, ms_tri, ms_w64x_ballot, ms_clip) and check.py
(ms_w64x_ballot) turn that exit code into SKIP, quoting the harness's reason.
LLVM_MC may be one executable or a command line such as the WSL llvm-mc documented for Windows. shader_disasm.py already split it, but the tests, runtime/test/shaders/build.py and scripts/run_gpu_tests.py treated it as a single executable, so the documented setup skipped translator tests, and build.py passed a Windows path to WSL. Share the splitter in tools/mc_command.py and feed assembly on stdin.
What was wrong
An RDNA2 SMEM load can carry a register offset and an immediate at once.
llvm-mc prints that form as "s_buffer_load_dword s12, s[24:27], s40 offset:0x4".
shader_ir.parse_line puts "offset:0x4" in mods, and Gen.scalar_load only read
the third operand, so the immediate was dropped without a diagnostic: the line
translated to the same SPIR-V with and without the modifier, and spirv-val
accepted both.
Evidence
Measured on an AMD Radeon RX 6800 (gfx1030) by running the instructions as a
raw compute kernel: for s_buffer_load_dword/x2/x4/x8 the address is
base + soffset + imm + 4*i, e.g. soffset 8 + imm 4 reads the dword at +12.
s_load_dword* with both offsets was not measured; it shares the SMEM encoding
(soffset_en + imm), so giving it the same rule is an inference.
Change
- scalar_load adds the immediate when the third operand is a register and mods
has offset:N. The no-modifier forms emit the same code as before.
- Forms llvm-mc does not accept (immediate operand plus offset:, two offset:
modifiers, a fourth operand, an unparseable offset) raise Unsupported.
- Not changed, and listed in docs/design.md as known differences: the hardware
truncates base, soffset and imm each to a multiple of 4 and s_buffer_load
returns 0 past NUM_RECORDS; the translator does neither. A negative s_load
immediate is still zero-extended from 32 bits, in both forms (not measured).
Tests
- tests/semantic/test_scalar_mem_smem.py: SmemSoffsetImmTranslatorTests runs
the code scalar_load emits against concrete SGPRs and memory and asserts the
addresses and values read (9 tests; 7 fail on main, where the loads read +8
instead of +12, and the imm-only / soffset-only regression cases pass).
- runtime/test/shaders/cs_smem_soffset_imm.asm, wired into check.py and
scripts/run_gpu_tests.py. Not run on a GPU in this change.
- unittest discover -s tests/semantic: 335 -> 344, all pass.
- pytest tests (--capture=sys, llvm-mc through WSL): 883 -> 893 passed, the
same 6 test_rtti_scan failures before and after (pefile not installed).
- The 27 hand-written GPU shaders: 27 translated, 27 pass spirv-val before and
after, output byte-identical.
AI-assisted.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
LLVM 21 prints the VOP3 form of v_lshlrev_b16, v_add_u16 etc. without _e64. All of them in the game's
shaders are 8-byte VOP3 encodings, so they were translated as VOP2 writes and lost the high half that
the hardware keeps (about 340 shaders). Found by #78's ps_ops5 on the GPU. Both runners now check
ps_ops5/ps_ops6, run_gpu_tests skips the interpreter-only ps_vcc_x2 (it lost the device), and
test_shader_checks derives its total from check.py.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check.py and run_gpu_tests.py both died with a FileNotFoundError traceback when vk_compute_test, vk_store_test
or vk_harness was not built, which on Linux happens whenever CMake does not find the Vulkan headers. They now
name the missing programs, how to build them, and the "Vulkan SDK not found" hint, and exit 1.
run_gpu_tests.py checks before translating; check.py checks in run(), which the unit tests mock.
Add --wave64-emulate to tools/rdna2spirv.py. A wave64 compute or mesh
shader then uses no subgroup operation: everything a lane needs from the
rest of its wave (votes for s_cbranch_*/SCC, whole-mask words for
s_bcnt1/s_ff1/v_mbcnt, v_readlane, v_readfirstlane, ds_bpermute,
ds_swizzle, v_permlane16/x16) goes through a Workgroup buffer. The
program runs in rounds that end at one OpControlBarrier in uniform
control flow; a cross-lane op cuts its basic block, and the rest runs one
round later, when all 64 lanes have written. s_barrier becomes a
scheduler state, and conflicting memory accesses in one segment are
ordered by a round. This answers #94 and #101 for compute and mesh
shaders: on 32-wide subgroups (NVIDIA) they are now exact, not
approximate.
Two fixes that apply without the flag:
- v_writelane_b32 in cs/ms selects the lane by the wave lane. On a
32-wide subgroup writes to lanes 32-63 were lost.
- ds_bpermute_b32 in wave64 runs as two wave32s (RDNA ISA 10.4.4): on a
64-wide subgroup lanes 32-63 read the low half, and an inactive source
lane now reads 0.
New hand-written GPU tests cs_w64x_* and ms_w64x_ballot pin down the
cross-half semantics. LEONIDA_W64_EMULATE=1 makes build.py,
run_gpu_tests.py and check.py use the flag. Other translator output is
byte-identical.
Tested on NVIDIA GeForce RTX 5070 Laptop (driver 617.42, subgroup 32) and
AMD Radeon 880M (driver 26.11.2 LLPC, subgroup 64):
run_gpu_tests.py 37/37 on both with the flag (RTX 5070 without it: 21/37;
880M without it: 37/37, was 36/37 before the bpermute fix).
AI-assisted (Claude Code).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cs_wavemask had no branch in run_gpu_tests.py, so it was silently left
out. Run it in wavemask mode with --require-wave64 and skip it where the
device has no 64-wide compute subgroup, as check.py and the wave64 dump
tests do since 4c75ce5.
Checked on RTX 5090 (subgroup 32..32): 19/25 passed, 6 skipped, exit 0.
Not checked on a 64-wide (AMD) GPU.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
vk_store_test exits 77 when the GPU lacks format-less storage image read/write (Intel Gen9), and check.py
reports it as SKIP. run_gpu_tests.py catches up with check.py: ps_flat (drawn with vs_ids), ps_legacy_mul,
and ps_bitmask_perm judged on lanes 0-31 only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Support '; mattr: ...' header directives in runtime/test/shaders/build.py,
scripts/run_gpu_tests.py, and tests/conftest.py.
- Restore runtime/test/shaders/cs_wave64_ballot.asm to wave64 v_cmp_*_e64
s[4:5] / s[6:7] / s[10:11] form using '; mattr: +wavefrontsize64,-wavefrontsize32'.
- Register cs_wave64_ballot and cs_wm_* in scripts/run_gpu_tests.py.