Commit Graph

19 Commits

Author SHA1 Message Date
4e390e0871 run_gpu_tests: --filter ps_flat also builds vs_ids, which ps_flat is drawn with (fixes #192)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:19:54 -05:00
f238f66a97 Merge pull request #186 from imnotdiesel
# Conflicts:
#	runtime/test/shaders/build.py
#	scripts/run_gpu_tests.py
2026-11-21 16:08:57 -05:00
f3da088e56 Merge pull request #171 from shelbykb2
# Conflicts:
#	runtime/test/shaders/check.py
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-21 16:08:48 -05:00
ce2cf75785 Merge main and share compute fixture header overrides 2026-11-21 22:04:18 +01:00
5b3bbad6e6 Test compute workgroup Y/Z registers on a 3D Vulkan dispatch 2026-11-21 22:00:38 +01:00
66a410edf0 Accept LLVM_MC as a whole command in the tests and GPU tools
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.
2026-11-21 21:00:03 +00:00
16d285e7bc Merge pull request #152 from AlxcBTW
# Conflicts:
#	scripts/run_gpu_tests.py
#	tests/test_shader_checks.py
2026-11-21 15:47:57 -05:00
89ca8c85e5 Merge pull request #149 from eIBart0 2026-11-21 15:47:57 -05:00
0f85eec343 Merge pull request #154 from crastinator 2026-11-21 15:47:56 -05:00
49dd92d41d translator: SMEM loads with soffset and imm add both (the imm was dropped)
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>
2026-11-21 13:28:03 -07:00
dcf5f44879 Translator: decide VOP3 for 16-bit integer ops from the encoding size, not the _e64 suffix
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>
2026-11-21 15:27:02 -05:00
725052d731 GPU tests: say which test programs are missing instead of a traceback
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.
2026-11-21 22:19:13 +02:00
ab35e9a64f Translator: exact wave64 compute and mesh shaders on any subgroup size
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>
2026-11-21 21:18:05 +01:00
50efbdb3b5 run_gpu_tests.py: run cs_wavemask like check.py
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>
2026-11-21 20:57:59 +01:00
12ddbc68f3 tests: add ms_clip GPU test and enable shaderClipDistance/shaderCullDistance in vk_harness 2026-11-21 16:57:03 -03:00
4c75ce537a run_gpu_tests: skip the wave64 mask dumps on devices without 64-wide compute subgroups, as check.py does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:51:37 -05:00
d51bddc84e GPU tests: skip what the device can't run instead of failing (fixes #88 points 2-3)
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>
2026-11-21 14:16:04 -05:00
1a7ca71f97 Tests: add per-file mattr directive, restore wave64 cs_wave64_ballot, register in run_gpu_tests.py
- 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.
2026-11-21 18:11:52 +00:00
e72e13ecfe Vulkan tests: fix AMD vk_store_test bindings, add subgroupSizeControl, add GPU test runner 2026-11-21 10:55:05 -03:00