upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 07:38:08 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 07:38:08 -0500
commitc7dfd34fdae77d0a6543fa4ec345df4402e8c1c8 (patch)
tree6d04b0b46eb20d6731097be739875a788952d402
parent41557027b6005ab36cab5b02e0a68ba9e4644f71 (diff)
parent444de13ca4799646976fbd6890438cf84de24b2d (diff)
Merge pull request #1552 from Luiz Neves
-rw-r--r--runtime/test/shaders/check.py4
-rw-r--r--runtime/test/shaders/cs_w32_misc_ext.asm69
-rw-r--r--scripts/run_gpu_tests.py12
-rw-r--r--tests/semantic/fixtures/disasm/cs_w32_misc_ext.s57
-rw-r--r--tests/semantic/regen_fixtures.py2
-rw-r--r--tests/semantic/test_misc_ext_fixture.py89
6 files changed, 227 insertions, 6 deletions
diff --git a/runtime/test/shaders/check.py b/runtime/test/shaders/check.py
index 357836767..eb1946a79 100644
--- a/runtime/test/shaders/check.py
+++ b/runtime/test/shaders/check.py
@@ -81,7 +81,7 @@ CS_SMEM = [0x5eed0024, 0x5eed0028, 0x5eed002c, 0x5eed0030, 0x5eed0010, 0x5eed001
81WAVE32_DUMPS = ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", 81WAVE32_DUMPS = ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute",
82 "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_bpermute32", 82 "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", "cs_w32_lds_u8_d16", "cs_bpermute32",
83 "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext", 83 "cs_w32_partial_scmp", "cs_exec_const", "cs_w32_mask_imm", "cs_w32_int_ext",
84 "cs_w32_salu64") 84 "cs_w32_salu64", "cs_w32_misc_ext")
85# Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is 85# Wave32 lane-mask dumps: their EXEC/VCC masks and lane selects cover 32 lanes, so a device whose widest subgroup is
86# narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with 86# narrower (Mesa llvmpipe: 8) can't produce their words. They are skipped there, as ps_bitmask_perm is. They run with
87# 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may 87# 32 lanes requested (WAVE32_LANE_ENV), as run_gpu_tests.py does: a device with a range like 8..32 (Intel ANV) may
@@ -109,6 +109,8 @@ CS_DUMPS = [*CS_DPP, ("cs_store", CS_STORE), ("cs_smem_soffset_imm", CS_SMEM),
109 # integer ops with CPU-only checks until now (derivations in cs_w32_int_ext.asm) 109 # integer ops with CPU-only checks until now (derivations in cs_w32_int_ext.asm)
110 ("cs_w32_int_ext", [1, 27, 1, 0x33332222, 0xC0000000, 0x4000, 18, 0x20304050]), 110 ("cs_w32_int_ext", [1, 27, 1, 0x33332222, 0xC0000000, 0x4000, 18, 0x20304050]),
111 # 64-bit scalar data ops and v_mad_u64_u32 (derivations in cs_w32_salu64.asm) 111 # 64-bit scalar data ops and v_mad_u64_u32 (derivations in cs_w32_salu64.asm)
112 # more ops with CPU-only checks until now (derivations in cs_w32_misc_ext.asm)
113 ("cs_w32_misc_ext", [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D]),
112 ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]), 114 ("cs_w32_salu64", [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE]),
113 # SHADER-85: 8-bit LDS reads into one half of a VGPR, the other half kept 115 # SHADER-85: 8-bit LDS reads into one half of a VGPR, the other half kept
114 ("cs_w32_lds_u8_d16", [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234]), 116 ("cs_w32_lds_u8_d16", [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234]),
diff --git a/runtime/test/shaders/cs_w32_misc_ext.asm b/runtime/test/shaders/cs_w32_misc_ext.asm
new file mode 100644
index 000000000..c7d4dd774
--- /dev/null
+++ b/runtime/test/shaders/cs_w32_misc_ext.asm
@@ -0,0 +1,69 @@
1; Ops merged with CPU-only checks (#1471 #825 #828 #814 #810), run once on a GPU.
2; Lane 0 of a wave32 group computes one result per op and stores eight dwords:
3; out[0] = high word of s_nand_b64(0xF0F0F0F0_12345678, 0xFF00FF00_FFFFFFFF) = 0x0FFF0FFF (~(S0 & S1))
4; out[1] = low word of s_xnor_b64(0xF0F0F0F0_12345678, 0xFF00FF00_0F0F0F0F) = 0xE2C4A688 (~(S0 ^ S1))
5; out[2] = v_cvt_pk_u16_u32(0x12345, 7) = 0x0007FFFF (low half saturated to 0xFFFF)
6; out[3] = v_cvt_pk_i16_i32(-40000, 40000) = 0x7FFF8000 (each half saturated to i16)
7; out[4] = v_mad_u32_u16(0xFFFF, 0xFFFF, 1) = 0xFFFE0002
8; out[5] = v_mad_i32_i16(0x8000, 2, 5) = 0xFFFF0005 (-32768 * 2 + 5)
9; out[6] = (ds_cmpst_rtn_b32 old << 8) | LDS after = 0x509 (LDS 5, compare 5, store 9)
10; out[7] = high dword of the second ds_read2_b64 element = 0xCAFEF00D (written by ds_write2_b64 offset1:3)
11; group: 32,1,1
12; Run: vk_compute_test cs_w32_misc_ext.spv 1 dump -> out[0..7] = 268374015 3804538504 524287 2147450880 4294836226 4294901765 1289 3405705229
13; mattr: +wavefrontsize32,-wavefrontsize64
14s_mov_b32 s6, 0x12345678
15s_mov_b32 s7, 0xf0f0f0f0
16s_mov_b32 s10, -1
17s_mov_b32 s11, 0xff00ff00
18s_nand_b64 s[8:9], s[6:7], s[10:11]
19s_mov_b32 s10, 0xf0f0f0f
20s_xnor_b64 s[12:13], s[6:7], s[10:11]
21v_mov_b32_e32 v1, 0x12345
22v_mov_b32_e32 v2, 7
23v_cvt_pk_u16_u32 v3, v1, v2
24v_mov_b32_e32 v1, 0xffff63c0
25v_mov_b32_e32 v2, 0x9c40
26v_cvt_pk_i16_i32 v4, v1, v2
27v_mov_b32_e32 v1, 0xffff
28v_mad_u32_u16 v5, v1, v1, 1
29v_mov_b32_e32 v1, 0x8000
30v_mad_i32_i16 v6, v1, 2, 5
31v_mov_b32_e32 v10, 0x10
32v_mov_b32_e32 v11, 5
33v_mov_b32_e32 v12, 9
34ds_write_b32 v10, v11
35s_waitcnt lgkmcnt(0)
36ds_cmpst_rtn_b32 v13, v10, v11, v12
37s_waitcnt lgkmcnt(0)
38ds_read_b32 v14, v10
39s_waitcnt lgkmcnt(0)
40v_lshl_or_b32 v7, v13, 8, v14
41v_mov_b32_e32 v10, 0x40
42v_mov_b32_e32 v16, 0x11111111
43v_mov_b32_e32 v17, 0x22222222
44v_mov_b32_e32 v18, 0x33333333
45v_mov_b32_e32 v19, 0xcafef00d
46ds_write2_b64 v10, v[16:17], v[18:19] offset0:1 offset1:3
47s_waitcnt lgkmcnt(0)
48ds_read2_b64 v[20:23], v10 offset0:1 offset1:3
49s_waitcnt lgkmcnt(0)
50v_cmpx_eq_u32_e32 0, v0
51v_mov_b32_e32 v24, s9
52v_mov_b32_e32 v25, 0
53buffer_store_dword v24, v25, s[0:3], 0 offen
54v_mov_b32_e32 v24, s12
55v_mov_b32_e32 v25, 4
56buffer_store_dword v24, v25, s[0:3], 0 offen
57v_mov_b32_e32 v25, 8
58buffer_store_dword v3, v25, s[0:3], 0 offen
59v_mov_b32_e32 v25, 12
60buffer_store_dword v4, v25, s[0:3], 0 offen
61v_mov_b32_e32 v25, 16
62buffer_store_dword v5, v25, s[0:3], 0 offen
63v_mov_b32_e32 v25, 20
64buffer_store_dword v6, v25, s[0:3], 0 offen
65v_mov_b32_e32 v25, 24
66buffer_store_dword v7, v25, s[0:3], 0 offen
67v_mov_b32_e32 v25, 28
68buffer_store_dword v23, v25, s[0:3], 0 offen
69s_endpgm
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index f7fb88af6..1f8a554a1 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -853,7 +853,7 @@ def run_suite(a, work: str) -> int:
853 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 853 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
854 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 854 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
855 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 855 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
856 elif name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half", 856 elif name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_wave64_ballot", "cs_wm_half_ops", "cs_wm_half_cmp", "cs_wm_bfm64", "cs_wm_scc_rfl", "cs_wqm_w64", "cs_wqm_w32", "cs_wqm_w64_half",
857 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 857 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
858 "cs_dpp_bound", "cs_dpp_w64", 858 "cs_dpp_bound", "cs_dpp_w64",
859 "cs_w64_mask_detect", 859 "cs_w64_mask_detect",
@@ -877,6 +877,8 @@ def run_suite(a, work: str) -> int:
877 # integer ops with CPU-only checks until now (cs_w32_int_ext.asm) 877 # integer ops with CPU-only checks until now (cs_w32_int_ext.asm)
878 "cs_w32_int_ext": [1, 27, 1, 0x33332222, 0xC0000000, 0x4000, 18, 0x20304050], 878 "cs_w32_int_ext": [1, 27, 1, 0x33332222, 0xC0000000, 0x4000, 18, 0x20304050],
879 # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm) 879 # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm)
880 # more ops with CPU-only checks until now (cs_w32_misc_ext.asm)
881 "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D],
880 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], 882 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE],
881 # SHADER-85: ds_read_u8/i8_d16[_hi] (cs_w32_lds_u8_d16.asm header) 883 # SHADER-85: ds_read_u8/i8_d16[_hi] (cs_w32_lds_u8_d16.asm header)
882 "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234], 884 "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234],
@@ -933,8 +935,9 @@ def run_suite(a, work: str) -> int:
933 } 935 }
934 want = cs_dump_wants[name] 936 want = cs_dump_wants[name]
935 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute / 937 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute /
936 # cs_w32_lds_u8_d16 / cs_w32_int_ext / cs_w32_salu64, the wave32 cs_wqm_w32 / cs_bpermute32 and the DPP 938 # cs_w32_lds_u8_d16 / cs_w32_int_ext / cs_w32_salu64 / cs_w32_misc_ext, the wave32 cs_wqm_w32 /
937 # tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, as check.py does, where the device has none 939 # cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip,
940 # as check.py does, where the device has none
938 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were 941 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were
939 # translated with --wave64-emulate and run on any subgroup size. 942 # translated with --wave64-emulate and run on any subgroup size.
940 # cs_w64x_partial and cs_w64x_partial_scmp (40-thread groups) can't have full subgroups: they ask for 943 # cs_w64x_partial and cs_w64x_partial_scmp (40-thread groups) can't have full subgroups: they ask for
@@ -943,7 +946,8 @@ def run_suite(a, work: str) -> int:
943 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp") 946 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp")
944 wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 947 wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
945 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 948 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
946 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_bpermute32", "cs_w32_partial_scmp", 949 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext",
950 "cs_bpermute32", "cs_w32_partial_scmp",
947 "cs_exec_const", "cs_w32_mask_imm", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 951 "cs_exec_const", "cs_w32_mask_imm", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
948 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial 952 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial
949 if partial and not emulated: 953 if partial and not emulated:
diff --git a/tests/semantic/fixtures/disasm/cs_w32_misc_ext.s b/tests/semantic/fixtures/disasm/cs_w32_misc_ext.s
new file mode 100644
index 000000000..894c6790f
--- /dev/null
+++ b/tests/semantic/fixtures/disasm/cs_w32_misc_ext.s
@@ -0,0 +1,57 @@
1; cs_w32_misc_ext test fixture generated by tests/semantic/regen_fixtures.py from runtime/test/shaders/cs_w32_misc_ext.asm
2 s_mov_b32 s6, 0x12345678
3 s_mov_b32 s7, 0xf0f0f0f0
4 s_mov_b32 s10, -1
5 s_mov_b32 s11, 0xff00ff00
6 s_nand_b64 s[8:9], s[6:7], s[10:11]
7 s_mov_b32 s10, 0xf0f0f0f
8 s_xnor_b64 s[12:13], s[6:7], s[10:11]
9 v_mov_b32_e32 v1, 0x12345
10 v_mov_b32_e32 v2, 7
11 v_cvt_pk_u16_u32 v3, v1, v2
12 v_mov_b32_e32 v1, 0xffff63c0
13 v_mov_b32_e32 v2, 0x9c40
14 v_cvt_pk_i16_i32 v4, v1, v2
15 v_mov_b32_e32 v1, 0xffff
16 v_mad_u32_u16 v5, v1, v1, 1
17 v_mov_b32_e32 v1, 0x8000
18 v_mad_i32_i16 v6, v1, 2, 5
19 v_mov_b32_e32 v10, 0x10
20 v_mov_b32_e32 v11, 5
21 v_mov_b32_e32 v12, 9
22 ds_write_b32 v10, v11
23 s_waitcnt lgkmcnt(0)
24 ds_cmpst_rtn_b32 v13, v10, v11, v12
25 s_waitcnt lgkmcnt(0)
26 ds_read_b32 v14, v10
27 s_waitcnt lgkmcnt(0)
28 v_lshl_or_b32 v7, v13, 8, v14
29 v_mov_b32_e32 v10, 0x40
30 v_mov_b32_e32 v16, 0x11111111
31 v_mov_b32_e32 v17, 0x22222222
32 v_mov_b32_e32 v18, 0x33333333
33 v_mov_b32_e32 v19, 0xcafef00d
34 ds_write2_b64 v10, v[16:17], v[18:19] offset0:1 offset1:3
35 s_waitcnt lgkmcnt(0)
36 ds_read2_b64 v[20:23], v10 offset0:1 offset1:3
37 s_waitcnt lgkmcnt(0)
38 v_cmpx_eq_u32_e32 0, v0
39 v_mov_b32_e32 v24, s9
40 v_mov_b32_e32 v25, 0
41 buffer_store_dword v24, v25, s[0:3], 0 offen
42 v_mov_b32_e32 v24, s12
43 v_mov_b32_e32 v25, 4
44 buffer_store_dword v24, v25, s[0:3], 0 offen
45 v_mov_b32_e32 v25, 8
46 buffer_store_dword v3, v25, s[0:3], 0 offen
47 v_mov_b32_e32 v25, 12
48 buffer_store_dword v4, v25, s[0:3], 0 offen
49 v_mov_b32_e32 v25, 16
50 buffer_store_dword v5, v25, s[0:3], 0 offen
51 v_mov_b32_e32 v25, 20
52 buffer_store_dword v6, v25, s[0:3], 0 offen
53 v_mov_b32_e32 v25, 24
54 buffer_store_dword v7, v25, s[0:3], 0 offen
55 v_mov_b32_e32 v25, 28
56 buffer_store_dword v23, v25, s[0:3], 0 offen
57 s_endpgm
diff --git a/tests/semantic/regen_fixtures.py b/tests/semantic/regen_fixtures.py
index d413cf97f..49805b659 100644
--- a/tests/semantic/regen_fixtures.py
+++ b/tests/semantic/regen_fixtures.py
@@ -20,7 +20,7 @@ SHADERS = ("cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_bu
20 "ps_fnan_med3", "ps_fnan_fract", # float NaN / fract rows measured on RDNA2 hardware 20 "ps_fnan_med3", "ps_fnan_fract", # float NaN / fract rows measured on RDNA2 hardware
21 "ps_sdwa", "ps_ops", "ps_ops2", "ps_ops3", "ps_ops4", "ps_ops5", "ps_ops6", "ps_ops7", "ps_ops8", 21 "ps_sdwa", "ps_ops", "ps_ops2", "ps_ops3", "ps_ops4", "ps_ops5", "ps_ops6", "ps_ops7", "ps_ops8",
22 "ps_legacy_mul", "ps_vcc_x2", "ps_vcmpx_forms", "ps_flat", "cs_bounds", "cs_fmt_1010102", "cs_w64x_readlane", 22 "ps_legacy_mul", "ps_vcc_x2", "ps_vcmpx_forms", "ps_flat", "cs_bounds", "cs_fmt_1010102", "cs_w64x_readlane",
23 "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_int_ext", "cs_w32_salu64", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane", 23 "cs_w64x_writelane", "cs_w64x_bpermute", "cs_w32_permute", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w64x_permute", "cs_w64x_ballot", "cs_w64x_readfirstlane",
24 "cs_w64x_load_ballot_load", "cs_w64x_partial", "cs_wave64_ballot", "cs_wm_bfm64", "cs_wm_half_cmp", 24 "cs_w64x_load_ballot_load", "cs_w64x_partial", "cs_wave64_ballot", "cs_wm_bfm64", "cs_wm_half_cmp",
25 "cs_wavemask", "cs_cvt_f32_sat", "ps_scc_minmax", "ps_fma_literal", "ps_f16_vop2", 25 "cs_wavemask", "cs_cvt_f32_sat", "ps_scc_minmax", "ps_fma_literal", "ps_f16_vop2",
26 "ps_f32_mods", "ps_f64_mods", "ps_sff_imm", "cs_w32_lds_u8_d16", "cs_w32_lane_wrap", "ps_bary", 26 "ps_f32_mods", "ps_f64_mods", "ps_sff_imm", "cs_w32_lds_u8_d16", "cs_w32_lane_wrap", "ps_bary",
diff --git a/tests/semantic/test_misc_ext_fixture.py b/tests/semantic/test_misc_ext_fixture.py
new file mode 100644
index 000000000..62a49aa5e
--- /dev/null
+++ b/tests/semantic/test_misc_ext_fixture.py
@@ -0,0 +1,89 @@
1"""cs_w32_misc_ext: the GPU test of more ops that had CPU-only checks, run here on the CPU too.
2
3Standard library only; no GPU, no LLVM, no game files.
4
5runtime/test/shaders/cs_w32_misc_ext.asm has lane 0 of a wave32 group store one word of each of s_nand_b64,
6s_xnor_b64, v_cvt_pk_u16_u32, v_cvt_pk_i16_i32, v_mad_u32_u16, v_mad_i32_i16, ds_cmpst_rtn_b32 (old value and the
7LDS word after it) and ds_write2_b64 / ds_read2_b64 (derivations in its header). This runs the fixture
8(tests/semantic/regen_fixtures.py) through spirv_mini_interp, checks the eight words against values computed here
9from the ISA definitions, and checks that check.py and scripts/run_gpu_tests.py expect the same words on the GPU.
10"""
11import os
12import re
13import struct
14import unittest
15
16import support
17import spirv_mini_interp as si
18
19HERE = os.path.dirname(os.path.abspath(__file__))
20ROOT = os.path.dirname(os.path.dirname(HERE))
21M32 = 0xFFFFFFFF
22M64 = (1 << 64) - 1
23
24# 4 user SGPRs (the output V#), workgroup id in s4, 512 bytes of LDS (LDS_SIZE 1), 32x1x1 threads.
25FSSM = bytearray(0x148)
26struct.pack_into("<4I", FSSM, 0x138, 0x8088, 32, 1, 1)
27FSSM = bytes(FSSM)
28VSHARP = [0, 0, 0x1000, 0x31016FAC]
29
30
31def s16(x: int) -> int:
32 x &= 0xFFFF
33 return x - 0x10000 if x >> 15 else x
34
35
36def s32(x: int) -> int:
37 x &= M32
38 return x - (1 << 32) if x >> 31 else x
39
40
41def sat_u16(x: int) -> int:
42 return min(x & M32, 0xFFFF)
43
44
45def sat_i16(x: int) -> int:
46 return max(-32768, min(32767, s32(x))) & 0xFFFF
47
48
49A, B_NAND, B_XNOR = 0xF0F0F0F0_12345678, 0xFF00FF00_FFFFFFFF, 0xFF00FF00_0F0F0F0F
50LDS_INIT, CMP, NEW = 5, 5, 9
51EXPECTED = [
52 (~(A & B_NAND) & M64) >> 32, # s_nand_b64, high word
53 ~(A ^ B_XNOR) & M32, # s_xnor_b64, low word
54 sat_u16(0x12345) | sat_u16(7) << 16, # v_cvt_pk_u16_u32
55 sat_i16(-40000) | sat_i16(40000) << 16, # v_cvt_pk_i16_i32
56 (0xFFFF * 0xFFFF + 1) & M32, # v_mad_u32_u16
57 (s16(0x8000) * 2 + 5) & M32, # v_mad_i32_i16
58 LDS_INIT << 8 | (NEW if LDS_INIT == CMP else LDS_INIT), # ds_cmpst_rtn_b32: old, then LDS
59 0xCAFEF00D, # ds_read2_b64: element 2, high dword
60]
61
62
63class MiscExtFixture(unittest.TestCase):
64 def test_reference(self):
65 self.assertEqual(EXPECTED, [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509,
66 0xCAFEF00D])
67
68 def test_translated_shader(self):
69 spv = support.translate_fixture("cs_w32_misc_ext", fssm=FSSM)
70 mem = si.run_workgroup(spv, 1, 32, inputs_for=lambda i: {"%wg_id": (0, 0, 0), "%local_id": (i, 0, 0),
71 "%sg_lane": i},
72 push_constants=VSHARP + [0] * 28, memory={})
73 self.assertEqual(sorted(mem), [4 * k for k in range(8)])
74 for k, want in enumerate(EXPECTED):
75 with self.subTest(word=k):
76 self.assertEqual(mem[4 * k], want)
77
78 def test_gpu_runners_expect_the_same_words(self):
79 for rel in (("runtime", "test", "shaders", "check.py"), ("scripts", "run_gpu_tests.py")):
80 with open(os.path.join(ROOT, *rel), encoding="utf-8") as f:
81 text = f.read()
82 m = re.search(r'"cs_w32_misc_ext"\)?[,:]\s*\[([^\]]*)\]', text)
83 with self.subTest(file="/".join(rel)):
84 self.assertIsNotNone(m)
85 self.assertEqual([int(v, 0) for v in m.group(1).split(",")], EXPECTED)
86
87
88if __name__ == "__main__":
89 unittest.main()