upleb.uk

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

summaryrefslogtreecommitdiff
path: root/scripts/run_gpu_tests.py
diff options
context:
space:
mode:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 21:53:14 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 21:53:14 +0100
commit01763ffeeb76eeb98e4b1fef7b0488f804df8882 (patch)
treea2662c7bf1aa7ac2a208172dd22652d65a284e7a /scripts/run_gpu_tests.py
parente620b926447a3bd4bf2a45948f715a46c74b7068 (diff)
parentf847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff)
Merge main into image-sample-c (#2965)
tools/rdna2spirv.py AI-assisted.
Diffstat (limited to 'scripts/run_gpu_tests.py')
-rw-r--r--scripts/run_gpu_tests.py71
1 files changed, 66 insertions, 5 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 824f1f55b..2e398637c 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -38,7 +38,7 @@ from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: tex
38from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT) 38from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT)
39from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS 39from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS
40from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip, 40from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip,
41 vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py 41 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py
42from check import PIXEL_VERTEX, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks 42from check import PIXEL_VERTEX, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks
43from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries 43from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries
44from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide 44from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide
@@ -294,6 +294,11 @@ def w64_emulated() -> bool:
294 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates 294 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates
295 # the trailing space cmd.exe's `set VAR=1 &` leaves in the value. 295 # the trailing space cmd.exe's `set VAR=1 &` leaves in the value.
296 return (os.environ.get("LEONIDA_W64_EMULATE") or "").strip().lower() in ("1", "true", "yes", "on") 296 return (os.environ.get("LEONIDA_W64_EMULATE") or "").strip().lower() in ("1", "true", "yes", "on")
297def pc_tail_ubo() -> bool:
298 # LEONIDA_PC_TAIL_UBO=1: translate with --pc-tail-ubo (s0..s31 in 128 push-constant bytes, the tail in a uniform
299 # block at set 1), for devices whose maxPushConstantsSize is 128. The test programs read the same variable
300 # (runtime/test/vk_pc_tail.h) and bind the block; same accepted values as LEONIDA_W64_EMULATE.
301 return (os.environ.get("LEONIDA_PC_TAIL_UBO") or "").strip().lower() in ("1", "true", "yes", "on")
297def wavemask_check(vk_compute: str, spv: str, env: dict | None, emulated: bool) -> tuple[bool | None, str]: 302def wavemask_check(vk_compute: str, spv: str, env: dict | None, emulated: bool) -> tuple[bool | None, str]:
298 """cs_wavemask, as in check.py: (passed, detail), passed None for a skip. The native build needs a 64-wide 303 """cs_wavemask, as in check.py: (passed, detail), passed None for a skip. The native build needs a 64-wide
299 subgroup and skips where the device has none; with LEONIDA_W64_EMULATE=1 it was translated with 304 subgroup and skips where the device has none; with LEONIDA_W64_EMULATE=1 it was translated with
@@ -312,6 +317,22 @@ def dump_words(msg: str) -> list[int] | None:
312 return [int(x) for x in m.group(1).split()] if m else None 317 return [int(x) for x in m.group(1).split()] if m else None
313 318
314 319
320def subgroup_pin_skip(msg: str, cs_env: dict | None) -> Skip | None:
321 """A Skip when the runner asked for a subgroup size (VKC_SUBGROUP_SIZE) and vk_compute_test says this device
322 cannot pin it, so the dispatched words are not the ones the fixture was written for. Only for the dumps in
323 WAVE32_PIN_DUMPS: everything else the runner judges at the device's own width, which is how cs_store and the
324 cs_w32_* fixtures keep being tested on a 64-only device (check.py is conservative and skips all of them)."""
325 if cs_env and "VKC_SUBGROUP_SIZE" in cs_env:
326 return unpinned_subgroup_skip(msg)
327 return None
328
329
330# Dumps whose expected words depend on the wave width but are not lane-mask dumps (those are WAVE32_LANE_DUMPS):
331# cs_barrier_loop's trip count is 4 waves of 32, so at 64 lanes it writes a different pattern and the words would
332# report a failure that is really an unpinnable wave size (GCN3/GCN4 expose 64..64 only).
333WAVE32_PIN_DUMPS = ("cs_barrier_loop",)
334
335
315def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial: bool, emulated: bool, 336def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial: bool, emulated: bool,
316 hexwords: bool = False) -> tuple[bool | None, str]: 337 hexwords: bool = False) -> tuple[bool | None, str]:
317 """Judge one vk_compute_test "dump" run: (True, words), (False, why), or (None, why) when the device can't run it. 338 """Judge one vk_compute_test "dump" run: (True, words), (False, why), or (None, why) when the device can't run it.
@@ -558,7 +579,8 @@ DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_textur
558 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm", 579 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm",
559 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", 580 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm",
560 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm", 581 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm",
561 SIGNED_MIP_TEST: "vs_ids.asm"} 582 SIGNED_MIP_TEST: "vs_ids.asm",
583 "vs_base_ids": "ps_flat.asm"}
562DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS}) 584DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS})
563 585
564 586
@@ -722,6 +744,8 @@ def run_suite(a, work: str) -> int:
722 cmd.append("--texel-offset-fallback") 744 cmd.append("--texel-offset-fallback")
723 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py 745 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py
724 cmd.append("--mesh-compute") 746 cmd.append("--mesh-compute")
747 if pc_tail_ubo(): # 128 push-constant bytes; heap base and code base from a uniform block at set 1
748 cmd.append("--pc-tail-ubo")
725 if os.environ.get("LEONIDA_FMA") in ("glsl", "khr"): # fused multiply-add: GLSL Fma or OpFmaKHR (docs/design.md) 749 if os.environ.get("LEONIDA_FMA") in ("glsl", "khr"): # fused multiply-add: GLSL Fma or OpFmaKHR (docs/design.md)
726 cmd += ["--fma", os.environ["LEONIDA_FMA"]] 750 cmd += ["--fma", os.environ["LEONIDA_FMA"]]
727 rc, out = run_cmd(cmd, gpu=False) 751 rc, out = run_cmd(cmd, gpu=False)
@@ -810,7 +834,7 @@ def run_suite(a, work: str) -> int:
810 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " 834 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the "
811 "clamped and the calculated LOD within 1/16")) 835 "clamped and the calculated LOD within 1/16"))
812 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail", 836 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail",
813 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8"): 837 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_buf_load_sub", "cs_buf_fmt8"):
814 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds 838 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds
815 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. 839 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement.
816 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either. 840 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either.
@@ -832,6 +856,9 @@ def run_suite(a, work: str) -> int:
832 0xBEEF0001], 856 0xBEEF0001],
833 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 857 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
834 "cs_cvt_pk_u8": CVT_PK_U8_WORDS, 858 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
859 # TEST-510: sub-dword MUBUF loads (RAW end check by element size) and GFX10_FORMAT_8_UINT
860 "cs_buf_load_sub": [0x80, 0xFFFFFF80, 0x1FF, 0xFFFF807F, 0xAB01, 0xCD, 0, 0],
861 "cs_buf_fmt8": [0x7F, 0x80, 0xFF, 0x01, 0, 0, 0xFF, 1],
835 }[name] 862 }[name]
836 words = dump_words(msg) 863 words = dump_words(msg)
837 vals = words[:len(want)] if words else [] 864 vals = words[:len(want)] if words else []
@@ -868,6 +895,14 @@ def run_suite(a, work: str) -> int:
868 vals = words[:len(USER_SGPRS_WORDS)] if words else [] 895 vals = words[:len(USER_SGPRS_WORDS)] if words else []
869 results.append((name, rc == 0 and vals == USER_SGPRS_WORDS, 896 results.append((name, rc == 0 and vals == USER_SGPRS_WORDS,
870 " ".join(hex(x) for x in vals) if vals else msg)) 897 " ".join(hex(x) for x in vals) if vals else msg))
898 elif name == "cs_f64_add":
899 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
900 if rc == 77:
901 results.append((name, None, "SKIP (no shaderFloat64 on this device)"))
902 else:
903 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False,
904 hexwords=True)
905 results.append((name, ok, detail))
871 elif name == "cs_cvt_f32_sat": 906 elif name == "cs_cvt_f32_sat":
872 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS). 907 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS).
873 wrong = [] 908 wrong = []
@@ -1004,6 +1039,10 @@ def run_suite(a, work: str) -> int:
1004 cs_env = dict(os.environ, **WAVE32_LANE_ENV) 1039 cs_env = dict(os.environ, **WAVE32_LANE_ENV)
1005 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env) 1040 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env)
1006 skip = wave32_lane_skip(msg) if name in WAVE32_LANE_DUMPS else None 1041 skip = wave32_lane_skip(msg) if name in WAVE32_LANE_DUMPS else None
1042 if skip is None and name in WAVE32_PIN_DUMPS:
1043 # the device may not be able to run the wave size this fixture was written for (a 64-only device
1044 # can't pin 32, so cs_barrier_loop's words mean nothing); check.py skips it too
1045 skip = subgroup_pin_skip(msg, cs_env)
1007 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right 1046 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right
1008 ok, detail = None, str(skip) 1047 ok, detail = None, str(skip)
1009 else: 1048 else:
@@ -1082,7 +1121,7 @@ def run_suite(a, work: str) -> int:
1082 problem = sampler_test(a.build, spirv_dir) 1121 problem = sampler_test(a.build, spirv_dir)
1083 results.append((name, None if isinstance(problem, Skip) else not problem, 1122 results.append((name, None if isinstance(problem, Skip) else not problem,
1084 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact")) 1123 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact"))
1085 elif name in ("ps_texoff", "ps_texoff_implicit"): 1124 elif name in ("ps_texoff", "ps_texoff_implicit", "ps_texoff_forms"):
1086 # Texel offsets: needs vk_texture_test's texture, sampler and descriptor table (vk_harness binds none), 1125 # Texel offsets: needs vk_texture_test's texture, sampler and descriptor table (vk_harness binds none),
1087 # and VK_KHR_maintenance8 for the non-constant Offset; the tool exits 77 without it. 1126 # and VK_KHR_maintenance8 for the non-constant Offset; the tool exits 77 without it.
1088 raw = os.path.join(raw_dir, f"{name}.raw") 1127 raw = os.path.join(raw_dir, f"{name}.raw")
@@ -1094,7 +1133,7 @@ def run_suite(a, work: str) -> int:
1094 results.append((name, False, msg)) 1133 results.append((name, False, msg))
1095 else: 1134 else:
1096 with open(raw, "rb") as f: 1135 with open(raw, "rb") as f:
1097 problem, covered = texoff_problem(f.read(), msg) 1136 problem, covered = texoff_problem(f.read(), msg, name=name)
1098 results.append((name, not problem, problem or f"4096/4096 pixels exact ({covered})")) 1137 results.append((name, not problem, problem or f"4096/4096 pixels exact ({covered})"))
1099 elif name in OTHER_HARNESS: 1138 elif name in OTHER_HARNESS:
1100 results.append((name, None, f"SKIP (run by {OTHER_HARNESS[name]})")) 1139 results.append((name, None, f"SKIP (run by {OTHER_HARNESS[name]})"))
@@ -1127,6 +1166,7 @@ def run_suite(a, work: str) -> int:
1127 "ps_ops4": (0x34000010, 0x00120800, 0xBEEF0000, 0x12343C00), 1166 "ps_ops4": (0x34000010, 0x00120800, 0xBEEF0000, 0x12343C00),
1128 "ps_scc": (1, 1, 3, 0x80000000), 1167 "ps_scc": (1, 1, 3, 0x80000000),
1129 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000), 1168 "ps_sdwa": (0x000000F1, 0xBFFEFFF2, 0x3C003344, 0xBFF70000),
1169 "ps_sdwa_dword_hi": (0x00004000, 0x00000003, 0x00004700, 0x0000C000), # 16-bit SDWA, dst_sel:DWORD
1130 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py 1170 "ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py
1131 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers 1171 "ps_ops5": (0x12340010, 0xBEEF0800, 0xAAAAFFFF, 0xDEADBC00), # from the .asm headers
1132 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0), 1172 "ps_ops6": (0xF800FFFF, 0x01000010, 0x00800800, 0x8000FFF0),
@@ -1159,6 +1199,10 @@ def run_suite(a, work: str) -> int:
1159 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1199 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
1160 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers) 1200 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers)
1161 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000), 1201 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000),
1202 "ps_vcmp_f16": (0x48A12080, 0x4CE9B1A2, 0x4BA72C98, 0x4FEFBDBA), # 16-bit float v_cmp e32 (.asm header)
1203 "ps_vcmp_f16_e64": (0x44C11100, 0x4CF171C1, 0x47C71D18, 0x4FF77DD9), # same, e64 with swapped operands
1204 "ps_vcmpx_f16": (0x68A12080, 0x6CE9B1A2, 0x6BA72C98, 0x6FEFBDBA), # 16-bit float v_cmpx e32 (.asm header)
1205 "ps_vcmpx_f16_e64": (0x64C11100, 0x6CF171C1, 0x67C71D18, 0x6FF77DD9), # same, e64 with swapped operands
1162 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000), 1206 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000),
1163 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3E00, 0xAAAA0000, 0xAAAA4000), 1207 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3E00, 0xAAAA0000, 0xAAAA4000),
1164 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00), 1208 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00),
@@ -1270,6 +1314,19 @@ def run_suite(a, work: str) -> int:
1270 else: 1314 else:
1271 ok, detail = check_clip_half(raw, 0.5, 1.0) 1315 ok, detail = check_clip_half(raw, 0.5, 1.0)
1272 results.append((name, ok, detail)) 1316 results.append((name, ok, detail))
1317 elif name == "vs_base_ids":
1318 # Zero-based v0 / v3 (the hardware's VS input VGPRs): drawn with firstVertex 16 and firstInstance 7,
1319 # ps_flat must still see vertex 0 of instance 0 (0x101), as check.py checks.
1320 raw = os.path.join(raw_dir, f"{name}.raw")
1321 env = dict(gfx_env or os.environ, VKH_DRAW="16,7")
1322 rc, msg = run_cmd([vk_harness, spv, os.path.join(spirv_dir, "ps_flat.spv"), raw], env=env)
1323 if rc == UNSUPPORTED:
1324 results.append((name, None, unsupported_skip(msg)))
1325 elif rc != 0:
1326 results.append((name, False, msg))
1327 else:
1328 ok, detail = check_flat(raw)
1329 results.append((name, ok, detail))
1273 1330
1274 if a.filter and not results: # the filter matched only inputs/partners: say so rather than "0/0 passed" 1331 if a.filter and not results: # the filter matched only inputs/partners: say so rather than "0/0 passed"
1275 names = [os.path.splitext(f)[0] for f in asm_files] 1332 names = [os.path.splitext(f)[0] for f in asm_files]
@@ -1299,4 +1356,8 @@ def run_suite(a, work: str) -> int:
1299 1356
1300 1357
1301if __name__ == "__main__": 1358if __name__ == "__main__":
1359 try: # a redirected stdout is strict ANSI code page under -I; write '?' for what it cannot encode
1360 sys.stdout.reconfigure(errors="replace")
1361 except (AttributeError, ValueError, OSError):
1362 pass
1302 sys.exit(main()) 1363 sys.exit(main())