Commit Graph

594 Commits

Author SHA1 Message Date
cc1f4d3597 Merge pull request #230 from Jan Trencansky
# Conflicts:
#	docs/d3d12_vulkan.md
2026-11-21 17:09:46 -05:00
01e23b6175 Merge pull request #208 from dcastell1 2026-11-21 17:07:41 -05:00
fdaf5e402e Merge pull request #246 from LuanFreitas 2026-11-21 17:07:40 -05:00
2765bbfc22 run_gpu_tests: honor LEONIDA_W64_EMULATE via a w64_emulated() helper (cmd.exe leaves a trailing space in 'set VAR=1 &', so the raw == '1' parse drops the flag and mis-sorts the wave64 emulated results on a 32-wide GPU) 2026-11-21 23:01:48 +01:00
d9c0ab5b48 vk_harness: VKH_HEAP on a device without buffer addresses is a SKIP; stricter VKH_SGPRS/VKH_HEAP parsing
A device without bufferDeviceAddress or shaderInt64 now gets "unsupported: ..." and exit 77, which check.py and
run_gpu_tests.py report as SKIP (the same handling as #203), so ps_vcc_x2 doesn't turn into a FAIL there. Words
are decimal or 0x hex only (no octal, sign or spaces), a trailing comma is rejected, and an empty VKH_HEAP is unset.
2026-11-21 23:57:11 +02:00
34f63c6c62 Translator: detect wave64 from 64-bit lane-mask SOP ops (#210)
Shaders that only use s_bcnt1_i32_b64 (and related mask ops) on ordinary
SGPR pairs were translated as wave32. Treat those ops as wave64 markers
and add a GPU test that expects a count of 48.
2026-11-21 18:57:04 -03:00
69ff8e5c72 Runtime: bindless set 0 (M2)
Set 0 as the translator declares it (docs/design.md, docs/d3d12_vulkan.md
section 5), in runtime/src/vulkan_bindless.h: the twenty bindings with the
array sizes vk_pipeline_check uses, and DescriptorTable (descriptor_table.h)
behind binding 2.

- An image has one index in its dimension (2D, 2D array, 3D, 1D), the same
  in every binding of that dimension. The storage arrays hold 256, so an
  image with a storage view gets an index below 256 and a read-only one
  goes above while there is room.
- Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest
  clamping sampler), because a miss in the table is index 0.
- Changes are queued and written by flush(), one write a slot: a view
  removed before the next flush is never written, so it may be destroyed
  at once.
- insert_key / erase_key change the table; flush() copies it to the buffer,
  into a new and larger one when it has grown. Erasing compacts a probe
  cluster, which moves other keys' entries, and a new buffer rewrites
  binding 2: flush_needs_idle() says when a flush would do either, so the
  owner can make sure no command buffer that uses the set is still running.
- With update after bind the set may be flushed between submissions; with
  partially bound only index 0 is written at creation.

Test: vk_bindless_test, run by runtime/test/shaders/check.py and
scripts/run_gpu_tests.py. ps_tex.asm, a hand-written RDNA2 pixel shader
built by build.py, loads a T# and an S# from a descriptor table and
samples: the translator's own lookup against the table and the set. It
draws the gradient with the T# at the fourth slot probed, the fallback
after the key is erased, the gradient after the table has grown into a new
buffer, another view at the same index and the fallback after removal,
with and without the descriptor-indexing flags; and it adds, removes and
destroys a view before its first flush, which the validation layer reports
if the write is still made.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 16:56:56 -05:00
36ace7135e Merge pull request #222 from simonbronk
# Conflicts:
#	docs/design.md
#	tests/semantic/test_alu_perm_alignbit.py
#	tools/rdna2spirv.py
2026-11-21 16:56:10 -05:00
047d4d9b60 Wave64 emulation: guard the chained voted branch, more tests, bench reference
Raise Unsupported when a voted branch's segment was not started by the vote's
own round. New tests cs_w64x_mask_reuse2 (EXEC reuse, read after a store,
half of a mask pair rewritten, chained successor starting with a conflicting
load) and cs_w64x_chain_barrier (chained successor starting with s_barrier),
plus a translation test counting mask exchanges. bench_wave64.py reports a
missing bench line readably and compares against the native AMD output.
design.md: how the rules were confirmed, current GPU counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:35 +01:00
cdaef79a7d Wave64 emulation: fewer rounds (reuse mask exchanges, chain voted branches), benchmark
A whole-mask read of a register value already exchanged in the block reuses
the exchange; a block ending in a voted branch runs its successor in the
round that reads the vote. Adds scripts/bench_wave64.py, cs_bench_mix,
VKC_BENCH timing in vk_compute_test and the cs_w64x_mask_reuse test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:35 +01:00
042f665da6 run_gpu_tests: comment names cs_bpermute32 as the other non-wave64 dump
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:52:03 +01:00
87700c04cf Zero disabled source lanes in wave32 ds_bpermute_b32
RDNA ISA 10.4.4: EXEC is honoured for reading the source, so a source lane
that is off reads 0. The wave64 paths did this already; the wave32 path
shuffled the raw value. New GPU test cs_bpermute32 (wave32), wired into
check.py, run_gpu_tests.py and tests/test_shader_checks.py; LDS row of
docs/design.md updated. ds_permute_b32 stays Unsupported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:51:44 +01:00
3fae38a7a1 GPU tests: ms_v5_workgroup expects #209's v5 (group * NumThreads + lane); run_gpu_tests runs #167's ps_texture_sample
#219's checker was written for the older workgroup-index model; on an RTX 4060 Ti lanes 0/1/31 of every
group read 32g, 32g+1, 32g+31, which is #209's model (the game's mesh entry shifts v5 right by 7).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:51:24 -05:00
58f3fe8f6b GPU tests: run ps_vcc_x2 on the GPU with a seeded V# and heap in vk_harness (TEST-19)
ps_vcc_x2 reads two dwords through the V# in s[0:3], but vk_harness pushed zeros and bound no memory, so on the
GPU it read address 0 and lost the device; run_gpu_tests.py skipped it and check.py left it out. vk_harness now
takes VKH_SGPRS (user SGPRs) and VKH_HEAP (addr=word seeds in a 64 KiB device-address heap, passed as the heap
base, with bufferDeviceAddress and shaderInt64 enabled only then). Both runners give ps_vcc_x2 the V# and words
tests/semantic uses and expect 0x11223344 0x55667788 0 0.
2026-11-21 23:51:16 +02:00
59fc0da713 fix(xbox): run cs_wavemask under wave64 emulation in run_gpu_tests
SHADER-12: check.py already passes --require-wave64 only when
LEONIDA_W64_EMULATE is not 1. run_gpu_tests.py passed it
unconditionally, so cs_wavemask was skipped on every 32-wide GPU
even when the wave64 emulation path was active.

Mirror check.py: omit the flag under emulation and only apply the
64-wide-subgroup skip/confirmation checks when the flag is set.
2026-11-21 22:50:33 +01:00
8b4d2f781e Merge pull request #212 from Ayinaki
# Conflicts:
#	tests/test_shader_checks.py
2026-11-21 16:38:46 -05:00
a81bcb8284 Merge pull request #207 from LouisRiverstone
# Conflicts:
#	runtime/test/vk_harness.cpp
2026-11-21 16:38:32 -05:00
e9cb0b0e68 Merge pull request #203 from Ayinaki
# Conflicts:
#	tests/test_shader_checks.py
2026-11-21 16:38:18 -05:00
48adc7b9a5 Translator: v_perm_b32 sign selectors 8-11; integer ALU tests ps_ops7/ps_ops8
v_perm_b32 returned 0x00 for selectors 8-11. Per the RDNA ISa BYTE_PERMUTE
they give 0xff when bit 7 of byte 1, 3, 5 or 7 of {src0, src1} is set. Each
byte pick also shifted both sources by up to 56 bits (undefined in SPIR-V,
the select kept the right one); the shift is now (sel & 3) * 8 on the source
chosen by sel < 4.

New test shaders, checked on the GPU (check.py, run_gpu_tests.py) and in
tests/semantic with expected words derived from the ISA:
- ps_ops7: v_perm_b32 (byte picks, 0x00/0xff, sign selectors), v_alignbit_b32
  with a shift of 36, v_med3_i32 vs v_med3_u32.
- ps_ops8: v_mul_hi_u32/i32, v_bcnt_u32_b32, v_ffbl_b32, v_ffbh_u32 (of 0),
  v_xad_u32, v_add3_u32.

The semantic interpreter gains OpUMulExtended/OpSMulExtended,
OpUGreaterThanEqual and GLSL FindILsb, FindUMsb, UMax, SMin, UClamp, SClamp,
with direct tests; the unsupported-ext example moves from FindUMsb to Ldexp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 22:33:25 +01:00
e8a0b11ada Test mesh v5 against all 24 coordinates of a 3D draw 2026-11-21 22:33:25 +01:00
cdc67e4d20 GPU tests: report gs_tri/ms_tri as SKIP without geometry or mesh shaders (TEST-18)
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.
2026-11-21 18:29:45 -03:00
24115f1450 check.py and run_gpu_tests: run cs_bounds (num_records bounds check) 2026-11-21 21:29:30 +00:00
369a062595 Merge main and preserve clip fixtures alongside updated GPU test tooling 2026-11-21 13:26:15 -08:00
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
f348eb9be0 GPU tests: skip pixel tests without barycentrics and narrow subgroups 2026-11-21 21:17:07 +00: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
b39592d530 Test two-plane vertex clip coverage against per-pixel CPU masks 2026-11-21 13:05:32 -08: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