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:
authorAlmogaver295 <133548141+guimsolutions@users.noreply.github.com>2026-11-23 23:53:36 +0100
committerAlmogaver295 <133548141+guimsolutions@users.noreply.github.com>2026-11-23 23:53:36 +0100
commit33f4a5aedeb48e27b004efe5d6ae306130d55cdd (patch)
tree08361685151a2a6a4ecf9156955fabb35b4b570c /scripts/run_gpu_tests.py
parent57cb669f52ba6ca4bb58bf2e09492ffbe2b8ee60 (diff)
parent5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff)
Merge upstream main and preserve 1D UAV clear compatibilityold-pr/9948
Diffstat (limited to 'scripts/run_gpu_tests.py')
-rw-r--r--scripts/run_gpu_tests.py340
1 files changed, 272 insertions, 68 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 1a0bab1d5..1f9d9fa7f 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -25,29 +25,33 @@ sys.path.insert(0, os.path.join(ROOT, "tools"))
25import mc_command # noqa: E402 25import mc_command # noqa: E402
26sys.path.insert(0, SHADER_DIR) 26sys.path.insert(0, SHADER_DIR)
27from build import CLIP_CASES, clip_container, shader_source 27from build import CLIP_CASES, clip_container, shader_source
28from check import (Skip, clip_test, fmt_1010102_test, fmt_int_narrow_test, fmt_sint32_test, fmt_xy_xyz_test, 28from check import (Skip, clip_test, fmt_1010102_test, fmt_d16_xyz_test, fmt_int_narrow_test,
29 tbuffer_store_test) 29 fmt_sint32_test, fmt_xy_xyz_test, tbuffer_store_test, compute_unsupported)
30from compute_fixture import compute_header 30from compute_fixture import compute_header
31from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test) 31from check import SAMPLER_CASES, sampler_test
32from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, GATHER_LOD_TEST, GRADIENT_TESTS, 32from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, PK_MUL_LO_WORDS,
33 IMAGE_STORE_CASES, MIP_TEST_PASSES, SIGNED_MIP_TEST, TEST_PROGRAMS, TEXTURE_CONSTANTS, 33 GATHER_LOD_TEST, GRADIENT_TESTS, IMAGE_STORE_CASES, MIP_TEST_PASSES, SIGNED_MIP_TEST,
34 TEXTURE_MIP_DEPENDENCIES, TEXTURE_MIP_TEST, USER_SGPRS_ENV, USER_SGPRS_WORDS, mesh_v5_test, 34 UINT_MIP_TEST, TEST_PROGRAMS, TEXTURE_CONSTANTS, TEXTURE_MIP_DEPENDENCIES,
35 not_found_message, pick_build_dir, start_failure, texture_gradient_a16_test, texture_mip_test, 35 TEXTURE_MIP_TEST, USER_SGPRS_ENV, USER_SGPRS_WORDS, mesh_v5_test,
36 texture_uav_test) 36 not_found_message, pick_build_dir, start_failure, table_fetch_test,
37 texture_gradient_a16_test, texture_mip_test, texture_uav_test)
37from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT 38from check import HEAP_INIT_EXPECTED, heap_init_env # cs_heap_init: vk_compute_test's VKC_HEAP_INIT
38from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan) 39from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan)
39from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py 40from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py
40from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8 41from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8
41from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT) 42from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT)
43from check import failure # "exit <status>: <last lines>", check.py's detail for a program that exited non-zero
42from check import run_readback 44from check import run_readback
43from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS 45from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS
44from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip, 46from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip,
45 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py 47 unpinned_subgroup_skip, vcmpx_forms_narrow_skip, wave32_lane_skip) # as in check.py
46from check import PIXEL_VERTEX, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks 48from check import PIXEL_VERTEX, VINT_ENV, interp_f16_high_problem, ij_computed_problem, mandelbrot_problem # pixel producers and checks
47from check import barycentric_problem 49from check import barycentric_problem
50from check import NAN_PAYLOAD_TEST, nan_payload_problem
48from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries 51from check import GET_LOD_TESTS, STORE_WORDS, get_lod_test, store_words_problem # TEST-184: image atomics and queries
49from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide 52from check import wide_pixel_skip # ps_w64x_readlane: judged only where the fragment stage was required 64-wide
50from check import FMA_FUSED_ENV, judge_fma_fused # cs_fma_fused: strict under LEONIDA_FMA=khr, fused/split under glsl 53from check import FMA_FUSED_ENV, judge_fma_fused # cs_fma_fused: strict under LEONIDA_FMA=khr, fused/split under glsl
54from check import bary_persp_problem # ps_persp_bary's perspective-correct reference
51 55
52 56
53def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes: 57def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes:
@@ -126,7 +130,25 @@ def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None:
126 f.write("\n".join(lines) + "\n") 130 f.write("\n".join(lines) + "\n")
127 131
128 132
129def spirv_as(asm_text: str, out_spv: str) -> None: 133def resolve_assembler(choice: str) -> str:
134 """Resolve --assembler choice ('auto', 'spirv-as', or 'python') to a concrete assembler name."""
135 if choice in ("spirv-as", "python"):
136 return choice
137 if choice == "auto":
138 return "spirv-as" if shutil.which("spirv-as") else "python"
139 raise ValueError(f"unknown assembler: {choice!r}")
140
141
142def spirv_as(asm_text: str, out_spv: str, assembler: str = "spirv-as") -> None:
143 if assembler == "python":
144 import spirv_asm
145 try:
146 spv_bytes = spirv_asm.assemble(asm_text, target_env="vulkan1.2")
147 except spirv_asm.SpirvAsmError as exc:
148 raise RuntimeError(f"spirv_asm failed for {out_spv}:\n{exc}") from None
149 with open(out_spv, "wb") as f:
150 f.write(spv_bytes)
151 return
130 p = subprocess.run(["spirv-as", "--target-env", "vulkan1.2", "-o", out_spv, "-"], 152 p = subprocess.run(["spirv-as", "--target-env", "vulkan1.2", "-o", out_spv, "-"],
131 input=asm_text, capture_output=True, text=True) 153 input=asm_text, capture_output=True, text=True)
132 if p.returncode != 0: 154 if p.returncode != 0:
@@ -245,6 +267,29 @@ def unsupported_skip(msg: str) -> str:
245 return f"SKIP ({m.group(0) if m else 'unsupported device'})" 267 return f"SKIP ({m.group(0) if m else 'unsupported device'})"
246 268
247 269
270def verdict_line(rc: int, msg: str) -> str:
271 """The detail of a row whose test program judges itself and prints its verdict last: that line. A program that
272 exited non-zero gets its exit status in front, as in check.py, so one that died before its verdict (exit -11 on
273 Linux, 3221225477 = 0xC0000005 on Windows) does not read as a FAIL with only its device or extension line, or
274 with no detail at all."""
275 return failure(rc, msg, 1) if rc else msg.splitlines()[-1] if msg else ""
276
277
278def helper_result(rc: int, msg: str) -> tuple[bool | None, str]:
279 """(ok, detail) for a helper that judges its own output (vk_store_test): 77 is a SKIP that names the missing
280 feature, not a failure (TEST-469); otherwise the exit code decides and verdict_line gives the detail."""
281 if rc == UNSUPPORTED:
282 return None, unsupported_skip(msg)
283 return rc == 0, verdict_line(rc, msg)
284
285
286def compute_result(rc: int, msg: str, ok: bool, detail: str) -> tuple[bool | None, str]:
287 """(ok, detail) for a vk_compute_test run the caller judges itself, unless the module needs a feature the device
288 lacks (check.compute_unsupported: exit 77 with an "unsupported: ..." line), which is a SKIP quoting it."""
289 skip = compute_unsupported(rc, msg)
290 return (None, skip) if skip else (ok, detail)
291
292
248def run_cmd(cmd: list[str], env: dict | None = None, gpu: bool = True, *, 293def run_cmd(cmd: list[str], env: dict | None = None, gpu: bool = True, *,
249 cwd: str | None = None) -> tuple[int, str]: 294 cwd: str | None = None) -> tuple[int, str]:
250 # A hung GPU test program fails its test instead of stalling the suite (check.py, LEONIDA_GPU_TEST_TIMEOUT). 295 # A hung GPU test program fails its test instead of stalling the suite (check.py, LEONIDA_GPU_TEST_TIMEOUT).
@@ -260,10 +305,15 @@ def run_cmd(cmd: list[str], env: dict | None = None, gpu: bool = True, *,
260 305
261 306
262def bary_fallback() -> bool: 307def bary_fallback() -> bool:
263 """LEONIDA_BARY_FALLBACK=1: pixel shaders that read raw barycentrics are translated with --bary-fallback and drawn 308 """LEONIDA_BARY_FALLBACK=1 (or 0): translate raw barycentrics to an ordinary vec3 input and draw it through
264 through their pass-through geometry shader (tools/bary_fallback_gs.py), so they run on a device without 309 tools/bary_fallback_gs.py. Unset, it is on where tools/vk_subgroup_info.py reports a driver with a known
265 VK_KHR_fragment_shader_barycentric (NVIDIA Pascal, for one).""" 310 BaryCoordKHR bug: Mesa ANV (SHADER-925) and AMD's Windows driver on gfx90c iGPUs (#5933)."""
266 return (os.environ.get("LEONIDA_BARY_FALLBACK") or "").strip().lower() in ("1", "true", "yes", "on") 311 v = (os.environ.get("LEONIDA_BARY_FALLBACK") or "").strip().lower()
312 if v in ("1", "true", "yes", "on"):
313 return True
314 if v in ("0", "false", "no", "off"):
315 return False
316 return _device_barycentric_fallback() is True
267 317
268 318
269def f16_interp_fallback() -> bool: 319def f16_interp_fallback() -> bool:
@@ -279,6 +329,7 @@ def f16_interp_fallback() -> bool:
279 329
280 330
281_PER_VERTEX = [] 331_PER_VERTEX = []
332_BARYCENTRIC_FALLBACK = []
282 333
283 334
284def _device_per_vertex(): 335def _device_per_vertex():
@@ -295,6 +346,21 @@ def _device_per_vertex():
295 return _PER_VERTEX[0] 346 return _PER_VERTEX[0]
296 347
297 348
349def _device_barycentric_fallback():
350 """barycentric_fallback from tools/vk_subgroup_info.py (Mesa ANV, SHADER-925; AMD Windows on gfx90c, #5933),
351 cached per suite."""
352 if not _BARYCENTRIC_FALLBACK:
353 answer = None
354 try:
355 r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "tools", "vk_subgroup_info.py")],
356 capture_output=True, text=True, timeout=60)
357 answer = json.loads(r.stdout.strip().splitlines()[-1]).get("barycentric_fallback")
358 except (OSError, ValueError, IndexError, subprocess.SubprocessError):
359 pass
360 _BARYCENTRIC_FALLBACK.append(answer)
361 return _BARYCENTRIC_FALLBACK[0]
362
363
298def w64_emulated() -> bool: 364def w64_emulated() -> bool:
299 # Wave64 emulation on: the suite runs every wave64 check without asking for a 64-wide 365 # Wave64 emulation on: the suite runs every wave64 check without asking for a 64-wide
300 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates 366 # subgroup, matching check.py (W64_EMULATED). Accepts "1"/"true"/"yes"/"on" and tolerates
@@ -311,11 +377,13 @@ def wavemask_check(vk_compute: str, spv: str, env: dict | None, emulated: bool)
311 --wave64-emulate and runs on any subgroup size, so it asks for none.""" 377 --wave64-emulate and runs on any subgroup size, so it asks for none."""
312 cmd = [vk_compute, spv, "1", "wavemask"] + ([] if emulated else ["--require-wave64"]) 378 cmd = [vk_compute, spv, "1", "wavemask"] + ([] if emulated else ["--require-wave64"])
313 rc, msg = run_cmd(cmd, env=env) 379 rc, msg = run_cmd(cmd, env=env)
380 if skip := compute_unsupported(rc, msg):
381 return None, skip
314 if not emulated and rc == 77: 382 if not emulated and rc == 77:
315 return None, "SKIP (no 64-wide compute subgroup on this device)" 383 return None, "SKIP (no 64-wide compute subgroup on this device)"
316 if not emulated and rc == 0 and "compute subgroup size: 64" not in msg.splitlines(): 384 if not emulated and rc == 0 and "compute subgroup size: 64" not in msg.splitlines():
317 return False, "64-wide subgroup was not confirmed (rebuild vk_compute_test)" 385 return False, "64-wide subgroup was not confirmed (rebuild vk_compute_test)"
318 return rc == 0, msg.splitlines()[-1] if msg else "" 386 return rc == 0, verdict_line(rc, msg)
319def dump_words(msg: str) -> list[int] | None: 387def dump_words(msg: str) -> list[int] | None:
320 """The eight words of vk_compute_test's "out[0..7] = ..." line, or None unless it is eight decimal words (as in 388 """The eight words of vk_compute_test's "out[0..7] = ..." line, or None unless it is eight decimal words (as in
321 check.py): trailing text, a missing word or a non-number is a malformed dump, not a result.""" 389 check.py): trailing text, a missing word or a non-number is a malformed dump, not a result."""
@@ -345,6 +413,10 @@ def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial:
345 wave64: it was run with --require-wave64, so exit 77 is a skip and the 64-wide confirmation must be printed. 413 wave64: it was run with --require-wave64, so exit 77 is a skip and the 64-wide confirmation must be printed.
346 partial: a group smaller than a wave, run at subgroup size 64 without full subgroups; skipped when the device 414 partial: a group smaller than a wave, run at subgroup size 64 without full subgroups; skipped when the device
347 reports no subgroup size of 64. emulated: translated with --wave64-emulate, runs on any subgroup size.""" 415 reports no subgroup size of 64. emulated: translated with --wave64-emulate, runs on any subgroup size."""
416 if rc == 77: # the program refused the module and said why ("unsupported: <why>"): a skip with that reason, in every mode
417 why = next((ln for ln in msg.splitlines() if ln.startswith("unsupported:")), None)
418 if why:
419 return None, "SKIP (" + why[len("unsupported:"):].strip() + ")"
348 no64 = partial and not emulated and not any(int(x) >= 64 for x in re.findall(r"subgroup \d+\.\.(\d+)", msg)) 420 no64 = partial and not emulated and not any(int(x) >= 64 for x in re.findall(r"subgroup \d+\.\.(\d+)", msg))
349 if (wave64 and rc == 77) or (no64 and rc == 0): 421 if (wave64 and rc == 77) or (no64 and rc == 0):
350 return None, "SKIP (no 64-wide compute subgroup on this device)" 422 return None, "SKIP (no 64-wide compute subgroup on this device)"
@@ -390,8 +462,6 @@ def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]:
390 first = "" 462 first = ""
391 judged = 0 463 judged = 0
392 for i, (lane, v1, v2, v3) in enumerate(px): 464 for i, (lane, v1, v2, v3) in enumerate(px):
393 if lane >= 32: # wave32 test: in a 64-wide subgroup lanes 32-63 hold values it never wrote
394 continue
395 judged += 1 465 judged += 1
396 w1 = lane ^ 9 466 w1 = lane ^ 9
397 w2 = ((lane & 5) | 16) ^ 1 467 w2 = ((lane & 5) | 16) ^ 1
@@ -399,7 +469,7 @@ def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]:
399 if not bad: 469 if not bad:
400 first = f"at ({i%64},{i//64}) lane={lane}: got ({v1},{v2},{v3}), want ({w1},{w2},0)" 470 first = f"at ({i%64},{i//64}) lane={lane}: got ({v1},{v2},{v3}), want ({w1},{w2},0)"
401 bad += 1 471 bad += 1
402 return (bad == 0 and judged > 0), (first if bad else f"{judged}/{judged} pixels in lanes 0-31 exact") 472 return (bad == 0 and judged > 0), (first if bad else f"{judged}/{judged} pixels exact")
403 473
404 474
405# Pixel shaders that read memory: vk_harness puts this V# in s[0:3] and seeds the heap it points at, as 475# Pixel shaders that read memory: vk_harness puts this V# in s[0:3] and seeds the heap it points at, as
@@ -412,19 +482,33 @@ PIXEL_ENV = {"ps_vcc_x2": {"VKH_SGPRS": "0x1000,0,16,0", "VKH_HEAP": "0x1000=0x1
412 "0x1028=0x1,0x102c=0,0x1030=0x7,0x1034=0x80000000,0x1038=0x7,0x103c=0," 482 "0x1028=0x1,0x102c=0,0x1030=0x7,0x1034=0x80000000,0x1038=0x7,0x103c=0,"
413 "0x1040=0x1,0x1044=0x5,0x1048=0x80000000,0x104c=0x5,0x1050=0x7,0x1054=0x5," 483 "0x1040=0x1,0x1044=0x5,0x1048=0x80000000,0x104c=0x5,0x1050=0x7,0x1054=0x5,"
414 "0x1058=0x7,0x105c=0x5"}, 484 "0x1058=0x7,0x105c=0x5"},
485 # 32-bit integer compares: operands from memory (derivations in the .asm header)
486 "ps_vcmp_int32": {"VKH_SGPRS": "0x1000,0,32,0",
487 "VKH_HEAP": "0x1000=0x1,0x1004=0,0x1008=0x80000000,0x100c=0x12345678,0x1010=0x3,"
488 "0x1014=0x5,0x1018=0,0x101c=0"},
415 # float NaN / fract rows measured on RDNA2 hardware (see the .asm headers) 489 # float NaN / fract rows measured on RDNA2 hardware (see the .asm headers)
416 "ps_fnan_med3": {"VKH_SGPRS": "0x1000,0,32,0", 490 "ps_fnan_med3": {"VKH_SGPRS": "0x1000,0,32,0",
417 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000," 491 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000,"
418 "0x100c=0x7fc10001,0x1010=0x40600000,0x1014=0xc0200000"}, 492 "0x100c=0x7fc10001,0x1010=0x40600000,0x1014=0xc0200000"},
419 "ps_fnan_fract": {"VKH_SGPRS": "0x1000,0,16,0", 493 "ps_fnan_fract": {"VKH_SGPRS": "0x1000,0,16,0",
420 "VKH_HEAP": "0x1000=0xaedbe6ff,0x1004=0x00008800,0x1008=0x7fc10001,0x100c=0xc0200000"}, 494 "VKH_HEAP": "0x1000=0xaedbe6ff,0x1004=0x00008800,0x1008=0x7fc10001,0x100c=0xc0200000"},
495 "ps_fnan_med3_s2": {"VKH_SGPRS": "0x1000,0,16,0",
496 "VKH_HEAP": "0x1000=0x40a00000,0x1004=0x40e00000,0x1008=0x7fc10001,0x100c=0xc0200000"},
497 "ps_f16_fnan_med3": {"VKH_SGPRS": "0x1000,0,16,0",
498 "VKH_HEAP": "0x1000=0x00004500,0x1004=0x00004700,0x1008=0x00007e01,0x100c=0x0000c100"},
421 # f32 VOPC with a NaN, 64-bit integer VOPC: inputs from memory (derivations in the .asm headers) 499 # f32 VOPC with a NaN, 64-bit integer VOPC: inputs from memory (derivations in the .asm headers)
422 "ps_vcmp_f32_nan": {"VKH_SGPRS": "0x1000,0,16,0", 500 "ps_vcmp_f32_nan": {"VKH_SGPRS": "0x1000,0,16,0",
423 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x3f800000,0x1008=0x40000000"}, 501 "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x3f800000,0x1008=0x40000000"},
424 "ps_vcmp_64": {"VKH_SGPRS": "0x1000,0,64,0", 502 "ps_vcmp_64": {"VKH_SGPRS": "0x1000,0,64,0",
425 "VKH_HEAP": "0x1000=0x80000000,0x1004=0,0x1008=1,0x100c=0,0x1010=0xffffffff," 503 "VKH_HEAP": "0x1000=0x80000000,0x1004=0,0x1008=1,0x100c=0,0x1010=0xffffffff,"
426 "0x1014=0xffffffff,0x1018=1,0x101c=0,0x1020=1,0x1024=0,0x1028=0x80000000," 504 "0x1014=0xffffffff,0x1018=1,0x101c=0,0x1020=1,0x1024=0,0x1028=0x80000000,"
427 "0x102c=0,0x1030=7,0x1034=5,0x1038=7,0x103c=5"}} 505 "0x102c=0,0x1030=7,0x1034=5,0x1038=7,0x103c=5"},
506 # the ps_vint_* integer fixtures share one heap, h0..h7 (see their .asm headers)
507 "ps_vint_logic3": VINT_ENV,
508 "ps_vint_bits": VINT_ENV,
509 "ps_vint_mul24": VINT_ENV,
510 "ps_vint_minmax": VINT_ENV,
511 "ps_vint_minmax3": VINT_ENV}
428 512
429 513
430def check_flat(raw_path: str) -> tuple[bool, str]: 514def check_flat(raw_path: str) -> tuple[bool, str]:
@@ -572,18 +656,19 @@ OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_transl
572 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test", 656 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test",
573 "ps_m3_post": "d3d12_m3_frame_test", "ps_m3_query": "d3d12_m3_frame_test", 657 "ps_m3_post": "d3d12_m3_frame_test", "ps_m3_query": "d3d12_m3_frame_test",
574 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test", 658 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test",
575 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test"} 659 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test",
660 "ps_live_width": "w64_graphics.py"}
576 661
577 662
578# Shaders a selected test draws with, built even when the filter leaves them out (#192). 663# Shaders a selected test draws with, built even when the filter leaves them out (#192).
579DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm", 664DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_persp_bary": "vs_persp.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm",
580 "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm", 665 "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm",
581 "ps_sample_c": "vs_ids.asm", "ps_sample_c_b": "vs_ids.asm", 666 "ps_table_fetch": "vs_ids.asm", "ps_sample_c": "vs_ids.asm", "ps_sample_c_b": "vs_ids.asm",
582 **{name: "vs_ids.asm" for name in TEXTURE_CONSTANTS}, "ps_ssharp": "vs_ids.asm", "ps_imgatomic": "vs_ids.asm", 667 **{name: "vs_ids.asm" for name in TEXTURE_CONSTANTS}, "ps_ssharp": "vs_ids.asm", "ps_imgatomic": "vs_ids.asm",
583 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm", 668 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm",
584 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", 669 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm",
585 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm", 670 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm",
586 SIGNED_MIP_TEST: "vs_ids.asm", 671 SIGNED_MIP_TEST: "vs_ids.asm", UINT_MIP_TEST: "vs_ids.asm",
587 "vs_base_ids": "ps_flat.asm"} 672 "vs_base_ids": "ps_flat.asm"}
588DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS}) 673DRAWN_WITH.update({name: "vs_ids.asm" for name in GET_LOD_TESTS})
589 674
@@ -654,12 +739,26 @@ def main() -> int:
654 ap.add_argument("--work", default=None) 739 ap.add_argument("--work", default=None)
655 ap.add_argument("--filter", default="") 740 ap.add_argument("--filter", default="")
656 ap.add_argument("--require-pass", action="store_true", help="exit 1 if no GPU test passes") 741 ap.add_argument("--require-pass", action="store_true", help="exit 1 if no GPU test passes")
742 ap.add_argument("--assembler", choices=("auto", "spirv-as", "python"), default="auto",
743 help="SPIR-V assembler: auto (use spirv-as if on PATH, else tools/spirv_asm.py), "
744 "spirv-as, or python")
745 ap.add_argument("--no-validate", action="store_true",
746 help="skip spirv-val during translation (automatic when --assembler resolves to python "
747 "and spirv-val is not on PATH)")
748 ap.add_argument("--disasm-dir", default=None,
749 help="folder of pre-disassembled <name>.s listings (e.g. tests/semantic/fixtures/disasm); "
750 "skips llvm-mc and runs only fixtures present there")
657 a = ap.parse_args() 751 a = ap.parse_args()
658 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path 752 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path
659 # given here would point somewhere else for them. 753 # given here would point somewhere else for them.
660 a.build = os.path.abspath(a.build) 754 a.build = os.path.abspath(a.build)
661 if a.work: 755 if a.work:
662 a.work = os.path.abspath(a.work) 756 a.work = os.path.abspath(a.work)
757 if a.disasm_dir is not None:
758 a.disasm_dir = os.path.abspath(a.disasm_dir)
759 if not os.path.isdir(a.disasm_dir):
760 print(f"error: --disasm-dir is not a directory: {a.disasm_dir}", file=sys.stderr)
761 return 2
663 762
664 ext = ".exe" if os.name == "nt" else "" 763 ext = ".exe" if os.name == "nt" else ""
665 required = tuple(t + ext for t in TEST_PROGRAMS) 764 required = tuple(t + ext for t in TEST_PROGRAMS)
@@ -687,7 +786,11 @@ def main() -> int:
687 786
688 work = a.work or tempfile.mkdtemp(prefix="leonida_gpu_tests_") 787 work = a.work or tempfile.mkdtemp(prefix="leonida_gpu_tests_")
689 try: 788 try:
690 os.makedirs(work, exist_ok=True) 789 try:
790 os.makedirs(work, exist_ok=True)
791 except OSError as exc: # the same report run_suite gives for its own folders (#4544)
792 print(f"error: cannot prepare GPU test directory {work}: {exc.strerror or exc}", file=sys.stderr)
793 return 2
691 native = native_folder(work) 794 native = native_folder(work)
692 if native is None: 795 if native is None:
693 print(f"error: the work folder {ascii(work)} has characters outside this PC's ANSI code page and no 8.3 " 796 print(f"error: the work folder {ascii(work)} has characters outside this PC's ANSI code page and no 8.3 "
@@ -712,10 +815,24 @@ W64_GRAPHICS_ONLY = _w64_graphics_only()
712 815
713 816
714def run_suite(a, work: str) -> int: 817def run_suite(a, work: str) -> int:
818 assembler = resolve_assembler(getattr(a, "assembler", "auto"))
819 explicit_no_validate = bool(getattr(a, "no_validate", False))
820 no_validate = explicit_no_validate or (assembler == "python" and shutil.which("spirv-val") is None)
821 disasm_src = getattr(a, "disasm_dir", None)
822
715 asm_files = sorted({f for f in os.listdir(SHADER_DIR) if f.endswith(".asm")} | {n + ".asm" for n in CLIP_CASES}) 823 asm_files = sorted({f for f in os.listdir(SHADER_DIR) if f.endswith(".asm")} | {n + ".asm" for n in CLIP_CASES})
716 # The wave64 pixel fixtures of runtime/test/shaders/w64_graphics.py (tiers A-C, #1541) are checked by that 824 # The wave64 pixel fixtures of runtime/test/shaders/w64_graphics.py (tiers A-C, #1541) are checked by that
717 # runner, not here: they need a 64-wide fragment subgroup or the halves-aware lowering it drives. 825 # runner, not here: they need a 64-wide fragment subgroup or the halves-aware lowering it drives.
718 asm_files = [f for f in asm_files if f[:-4] not in W64_GRAPHICS_ONLY] 826 asm_files = [f for f in asm_files if f[:-4] not in W64_GRAPHICS_ONLY]
827 if disasm_src is not None:
828 available = {os.path.splitext(f)[0] for f in os.listdir(disasm_src) if f.endswith(".s")}
829 asm_files = [
830 f for f in asm_files
831 if all(os.path.splitext(p)[0] in available for p in with_draw_shaders([f]))
832 ]
833 if not asm_files:
834 print(f"error: --disasm-dir {disasm_src!r} matched no GPU test cases", file=sys.stderr)
835 return 2
719 if a.filter: 836 if a.filter:
720 asm_files = [f for f in asm_files if a.filter in f] 837 asm_files = [f for f in asm_files if a.filter in f]
721 if not asm_files: 838 if not asm_files:
@@ -727,8 +844,12 @@ def run_suite(a, work: str) -> int:
727 disasm_dir = os.path.join(work, "disasm") 844 disasm_dir = os.path.join(work, "disasm")
728 spirv_dir = os.path.join(work, "spirv") 845 spirv_dir = os.path.join(work, "spirv")
729 raw_dir = os.path.join(work, "raw") 846 raw_dir = os.path.join(work, "raw")
730 for d in (fssm_dir, disasm_dir, spirv_dir, raw_dir): 847 for directory in (work, fssm_dir, disasm_dir, spirv_dir, raw_dir):
731 os.makedirs(d, exist_ok=True) 848 try:
849 os.makedirs(directory, exist_ok=True)
850 except OSError as exc:
851 print(f"error: cannot prepare GPU test directory {directory}: {exc.strerror or exc}", file=sys.stderr)
852 return 2
732 853
733 # 1. Create synthetic DXBC / FSSM metadata + assemble .asm -> .s 854 # 1. Create synthetic DXBC / FSSM metadata + assemble .asm -> .s
734 disasm_files = [] 855 disasm_files = []
@@ -760,7 +881,14 @@ def run_suite(a, work: str) -> int:
760 f.write(compute_header(os.path.join(SHADER_DIR, fname))) 881 f.write(compute_header(os.path.join(SHADER_DIR, fname)))
761 fname = shader_source(name) + ".asm" 882 fname = shader_source(name) + ".asm"
762 disasm_path = os.path.join(disasm_dir, f"{name}.s") 883 disasm_path = os.path.join(disasm_dir, f"{name}.s")
763 assemble_to_s(a.llvm_mc, os.path.join(SHADER_DIR, fname), disasm_path, name) 884 if disasm_src is not None:
885 try:
886 shutil.copyfile(os.path.join(disasm_src, f"{name}.s"), disasm_path)
887 except shutil.SameFileError:
888 # A replay can use the work folder's existing listings as its source.
889 pass
890 else:
891 assemble_to_s(a.llvm_mc, os.path.join(SHADER_DIR, fname), disasm_path, name)
764 disasm_files.append(disasm_path) 892 disasm_files.append(disasm_path)
765 # A failed translation must not run an old binary left in a reused --work directory. 893 # A failed translation must not run an old binary left in a reused --work directory.
766 Path(spirv_dir, f"{name}.spv").unlink(missing_ok=True) 894 Path(spirv_dir, f"{name}.spv").unlink(missing_ok=True)
@@ -770,6 +898,12 @@ def run_suite(a, work: str) -> int:
770 for path in disasm_files: 898 for path in disasm_files:
771 shutil.copyfile(path, os.path.join(selected_disasm, os.path.basename(path))) 899 shutil.copyfile(path, os.path.join(selected_disasm, os.path.basename(path)))
772 cmd = [sys.executable, "-I", TRANSLATOR, selected_disasm, "--out", spirv_dir] 900 cmd = [sys.executable, "-I", TRANSLATOR, selected_disasm, "--out", spirv_dir]
901 if assembler == "python":
902 cmd += ["--assembler", "python"]
903 if no_validate:
904 if not explicit_no_validate:
905 print("note: spirv-val not found on PATH; translating with --no-validate", flush=True)
906 cmd.append("--no-validate")
773 if w64_emulated(): # wave64 compute/mesh exact on any subgroup size 907 if w64_emulated(): # wave64 compute/mesh exact on any subgroup size
774 cmd.append("--wave64-emulate") 908 cmd.append("--wave64-emulate")
775 if bary_fallback(): # raw barycentrics from an interpolated input, fed by a pass-through GS 909 if bary_fallback(): # raw barycentrics from an interpolated input, fed by a pass-through GS
@@ -803,9 +937,9 @@ def run_suite(a, work: str) -> int:
803 vs_tri = os.path.join(spirv_dir, "vs_tri.spv") 937 vs_tri = os.path.join(spirv_dir, "vs_tri.spv")
804 fs_passthru = os.path.join(spirv_dir, "fs_passthru.spv") 938 fs_passthru = os.path.join(spirv_dir, "fs_passthru.spv")
805 fs_loc1 = os.path.join(spirv_dir, "fs_loc1.spv") 939 fs_loc1 = os.path.join(spirv_dir, "fs_loc1.spv")
806 spirv_as(VS_TRI_SPVASM, vs_tri) 940 spirv_as(VS_TRI_SPVASM, vs_tri, assembler=assembler)
807 spirv_as(make_fs_passthru(0), fs_passthru) 941 spirv_as(make_fs_passthru(0), fs_passthru, assembler=assembler)
808 spirv_as(make_fs_passthru(1), fs_loc1) 942 spirv_as(make_fs_passthru(1), fs_loc1, assembler=assembler)
809 943
810 index = {} 944 index = {}
811 idx_path = os.path.join(spirv_dir, "index.json") 945 idx_path = os.path.join(spirv_dir, "index.json")
@@ -841,16 +975,17 @@ def run_suite(a, work: str) -> int:
841 results.append((name, None if isinstance(detail, Skip) else not detail, detail or "four pixel masks exact")) 975 results.append((name, None if isinstance(detail, Skip) else not detail, detail or "four pixel masks exact"))
842 elif name == "cs_workgroup_yz": 976 elif name == "cs_workgroup_yz":
843 rc, msg = run_cmd([vk_compute, spv, "2x3x4", "workgroup_yz"], env=cs_env) 977 rc, msg = run_cmd([vk_compute, spv, "2x3x4", "workgroup_yz"], env=cs_env)
844 results.append((name, rc == 0 and "2x3x4 workgroup Y/Z: 0 mismatches" in msg.splitlines(), msg)) 978 results.append((name,) + compute_result(rc, msg, rc == 0 and "2x3x4 workgroup Y/Z: 0 mismatches"
979 in msg.splitlines(), msg))
845 elif name == "cs_lds": 980 elif name == "cs_lds":
846 rc, msg = run_cmd([vk_compute, spv, "4", "mirror64"], env=cs_env) 981 rc, msg = run_cmd([vk_compute, spv, "4", "mirror64"], env=cs_env)
847 results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) 982 results.append((name,) + compute_result(rc, msg, rc == 0, verdict_line(rc, msg)))
848 elif name == "cs_exec64": 983 elif name == "cs_exec64":
849 rc, msg = run_cmd([vk_compute, spv, "1", "exec64"], env=cs_env) 984 rc, msg = run_cmd([vk_compute, spv, "1", "exec64"], env=cs_env)
850 results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) 985 results.append((name,) + compute_result(rc, msg, rc == 0, verdict_line(rc, msg)))
851 elif name in ("cs_bvh", "cs_bvh32"): # the 64-bit and the 32-bit node pointer: one scene, the same words 986 elif name in ("cs_bvh", "cs_bvh32"): # the 64-bit and the 32-bit node pointer: one scene, the same words
852 rc, msg = run_cmd([vk_compute, spv, "1", "bvh"], env=cs_env) 987 rc, msg = run_cmd([vk_compute, spv, "1", "bvh"], env=cs_env)
853 results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) 988 results.append((name,) + compute_result(rc, msg, rc == 0, verdict_line(rc, msg)))
854 elif name in STORE_WORDS: 989 elif name in STORE_WORDS:
855 # TEST-184: image atomics (cs_imgatomic, cs_imgatomic3d) and image_get_resinfo (cs_resinfo). vk_store_test 990 # TEST-184: image atomics (cs_imgatomic, cs_imgatomic3d) and image_get_resinfo (cs_resinfo). vk_store_test
856 # binds the images and prints the r32 ones after the dispatch; the expected words are check.py's. 991 # binds the images and prints the r32 ones after the dispatch; the expected words are check.py's.
@@ -870,7 +1005,7 @@ def run_suite(a, work: str) -> int:
870 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " 1005 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the "
871 "clamped and the calculated LOD within 1/16")) 1006 "clamped and the calculated LOD within 1/16"))
872 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_smem_sconst_off", "cs_buf_tail", "cs_oob_select", "cs_oob_tail", 1007 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_smem_sconst_off", "cs_buf_tail", "cs_oob_select", "cs_oob_tail",
873 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_buf_load_sub", "cs_buf_fmt8"): 1008 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8", "cs_pk_mul_lo_const", "cs_buf_load_sub", "cs_buf_fmt8"):
874 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds 1009 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds
875 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. 1010 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement.
876 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either. 1011 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either.
@@ -894,14 +1029,15 @@ def run_suite(a, work: str) -> int:
894 0xBEEF0001], 1029 0xBEEF0001],
895 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 1030 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
896 "cs_cvt_pk_u8": CVT_PK_U8_WORDS, 1031 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
1032 "cs_pk_mul_lo_const": PK_MUL_LO_WORDS,
897 # TEST-510: sub-dword MUBUF loads (RAW end check by element size) and GFX10_FORMAT_8_UINT 1033 # TEST-510: sub-dword MUBUF loads (RAW end check by element size) and GFX10_FORMAT_8_UINT
898 "cs_buf_load_sub": [0x80, 0xFFFFFF80, 0x1FF, 0xFFFF807F, 0xAB01, 0xCD, 0, 0], 1034 "cs_buf_load_sub": [0x80, 0xFFFFFF80, 0x1FF, 0xFFFF807F, 0xAB01, 0xCD, 0, 0],
899 "cs_buf_fmt8": [0x7F, 0x80, 0xFF, 0x01, 0, 0, 0xFF, 1], 1035 "cs_buf_fmt8": [0x7F, 0x80, 0xFF, 0x01, 0, 0, 0xFF, 1],
900 }[name] 1036 }[name]
901 words = dump_words(msg) 1037 words = dump_words(msg)
902 vals = words[:len(want)] if words else [] 1038 vals = words[:len(want)] if words else []
903 results.append((name, rc == 0 and vals == want, 1039 results.append((name,) + compute_result(rc, msg, rc == 0 and vals == want,
904 " ".join(hex(x) for x in vals) if vals else msg)) 1040 " ".join(hex(x) for x in vals) if vals else msg))
905 elif name == "cs_fmt_1010102": 1041 elif name == "cs_fmt_1010102":
906 problem = fmt_1010102_test(a.build, spirv_dir, cs_env) 1042 problem = fmt_1010102_test(a.build, spirv_dir, cs_env)
907 results.append((name, not problem, problem or "64/64 dumped words exact")) 1043 results.append((name, not problem, problem or "64/64 dumped words exact"))
@@ -923,11 +1059,14 @@ def run_suite(a, work: str) -> int:
923 problem = fmt_d16_xyz_test(a.build, spirv_dir, cs_env) 1059 problem = fmt_d16_xyz_test(a.build, spirv_dir, cs_env)
924 results.append((name, not problem, problem or "80/80 dumped words exact")) 1060 results.append((name, not problem, problem or "80/80 dumped words exact"))
925 results.append((name, not problem, problem or "128/128 dumped words exact")) 1061 results.append((name, not problem, problem or "128/128 dumped words exact"))
926 elif name == "cs_global_neg_offset": 1062 elif name in ("cs_global_neg_offset", "cs_global_mem_ext"):
927 # Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups give a 0x2800-byte 1063 # Negative global_load/global_store offsets (cs_global_neg_offset.asm): 40 groups give a 0x2800-byte
928 # heap holding both the right addresses and the 4096-lower ones. One thread, no wave64 requirement. 1064 # heap holding both the right addresses and the 4096-lower ones. One thread, no wave64 requirement.
1065 # cs_global_mem_ext.asm: global/buffer atomics, 8/16-bit global stores and d16 loads in the same heap.
929 rc, msg = run_cmd([vk_compute, spv, "40", "dump"], env=cs_env) 1066 rc, msg = run_cmd([vk_compute, spv, "40", "dump"], env=cs_env)
930 want = [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 0x9E, 0xFFFF8BAD, 0x57023FFC, 0xEEEEEEEE] 1067 want = {"cs_global_neg_offset": [0x5EED1FFC, 0x8BAD1800, 0x5EED1FF0, 0x5EED1FF4, 0x9E, 0xFFFF8BAD,
1068 0x57023FFC, 0xEEEEEEEE],
1069 "cs_global_mem_ext": [0x5, 0xC, 0x977, 0xFFF00000, 0xEDCB5678, 0xEF332211, 0x887766BE, 0xFF801234]}[name]
931 ok, detail = judge_cs_dump(rc, msg, want, wave64=False, partial=False, emulated=False, hexwords=True) 1070 ok, detail = judge_cs_dump(rc, msg, want, wave64=False, partial=False, emulated=False, hexwords=True)
932 results.append((name, ok, detail)) 1071 results.append((name, ok, detail))
933 elif name == "cs_heap_init": 1072 elif name == "cs_heap_init":
@@ -935,36 +1074,56 @@ def run_suite(a, work: str) -> int:
935 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **heap_init_env())) 1074 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **heap_init_env()))
936 words = dump_words(msg) 1075 words = dump_words(msg)
937 vals = words[:len(HEAP_INIT_EXPECTED)] if words else [] 1076 vals = words[:len(HEAP_INIT_EXPECTED)] if words else []
938 results.append((name, rc == 0 and vals == HEAP_INIT_EXPECTED, 1077 results.append((name,) + compute_result(rc, msg, rc == 0 and vals == HEAP_INIT_EXPECTED,
939 " ".join(hex(x) for x in vals) if vals else msg)) 1078 " ".join(hex(x) for x in vals) if vals else msg))
940 elif name == "cs_user_sgprs": 1079 elif name == "cs_user_sgprs":
941 # vk_compute_test seeds s4..s7 from VKC_SGPRS; the shader stores them back. 1080 # vk_compute_test seeds s4..s7 from VKC_SGPRS; the shader stores them back.
942 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **USER_SGPRS_ENV)) 1081 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=dict(cs_env or os.environ, **USER_SGPRS_ENV))
943 words = dump_words(msg) 1082 words = dump_words(msg)
944 vals = words[:len(USER_SGPRS_WORDS)] if words else [] 1083 vals = words[:len(USER_SGPRS_WORDS)] if words else []
945 results.append((name, rc == 0 and vals == USER_SGPRS_WORDS, 1084 results.append((name,) + compute_result(rc, msg, rc == 0 and vals == USER_SGPRS_WORDS,
946 " ".join(hex(x) for x in vals) if vals else msg)) 1085 " ".join(hex(x) for x in vals) if vals else msg))
947 elif name == "cs_f64_add": 1086 elif name == "cs_f64_add":
948 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env) 1087 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
949 if rc == 77: 1088 if rc == 77: # Float64, or Int64 where the module declares both: quote whichever it names
950 results.append((name, None, "SKIP (no shaderFloat64 on this device)")) 1089 results.append((name, None, compute_unsupported(rc, msg) or "SKIP (no shaderFloat64 on this device)"))
951 else: 1090 else:
952 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False, 1091 ok, detail = judge_cs_dump(rc, msg, [0, 0x40040000], wave64=False, partial=False, emulated=False,
953 hexwords=True) 1092 hexwords=True)
954 results.append((name, ok, detail)) 1093 results.append((name, ok, detail))
1094 elif name == "cs_div_fmas_f64":
1095 # One-rounding binary64 FMA: strict where the translator emitted OpFmaKHR on doubles (shaderFmaFloat64,
1096 # --fma khr); under the default GLSL Fma the split result (0) is allowed, as cs_fma_fused allows it.
1097 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
1098 if rc == UNSUPPORTED: # no shaderFloat64, or (--fma khr) no shaderFmaFloat64
1099 results.append((name, None, unsupported_skip(msg)))
1100 else:
1101 words = (dump_words(msg) or [])[:2] if rc == 0 else []
1102 strict = "shaderFmaFloat64" in ((index.get(name) or {}).get("features") or ())
1103 fused, split = [0, 0x3c300000], [0, 0]
1104 ok = rc == 0 and (words == fused or (not strict and words == split))
1105 detail = " ".join(hex(x) for x in words) if words else msg
1106 if ok and words == split:
1107 detail += " (split: the driver rounds GLSL Fma on doubles twice; --fma khr fixes it)"
1108 results.append((name, ok, detail))
955 elif name == "cs_cvt_f32_sat": 1109 elif name == "cs_cvt_f32_sat":
956 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS). 1110 # #300's saturating float -> int conversions: one dispatch per input word in s4 (VKC_SGPRS).
957 wrong = [] 1111 wrong, skip = [], None
958 for bits, unsigned, signed in CVT_F32_SAT_CASES: 1112 for bits, unsigned, signed in CVT_F32_SAT_CASES:
959 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], 1113 rc, msg = run_cmd([vk_compute, spv, "1", "dump"],
960 env=dict(cs_env or os.environ, VKC_SGPRS=f"{bits:#010x}")) 1114 env=dict(cs_env or os.environ, VKC_SGPRS=f"{bits:#010x}"))
1115 if skip := compute_unsupported(rc, msg): # the module, not this input: no other input can run either
1116 break
961 words = dump_words(msg) 1117 words = dump_words(msg)
962 if rc != 0 or not words or words[:2] != [unsigned, signed]: 1118 if rc != 0 or not words or words[:2] != [unsigned, signed]:
963 got = " ".join(hex(x) for x in words[:2]) if words else msg.splitlines()[-1] if msg else "no output" 1119 got = " ".join(hex(x) for x in words[:2]) if words else msg.splitlines()[-1] if msg else "no output"
964 wrong.append(f"{bits:#010x} gave {got}, want {unsigned:#x} {signed:#x}") 1120 wrong.append(f"{bits:#010x} gave {got}, want {unsigned:#x} {signed:#x}")
965 n = len(CVT_F32_SAT_CASES) 1121 n = len(CVT_F32_SAT_CASES)
966 results.append((name, not wrong, f"{n}/{n} inputs exact" if not wrong 1122 if skip:
967 else f"{len(wrong)}/{n} inputs wrong, first {wrong[0]}")) 1123 results.append((name, None, skip))
1124 else:
1125 results.append((name, not wrong, f"{n}/{n} inputs exact" if not wrong
1126 else f"{len(wrong)}/{n} inputs wrong, first {wrong[0]}"))
968 elif name == "cs_fma_fused": 1127 elif name == "cs_fma_fused":
969 # Single-rounded f32 FMA (+ f16 round-to-odd): strict under LEONIDA_FMA=khr (OpFmaKHR, exit 77 if 1128 # Single-rounded f32 FMA (+ f16 round-to-odd): strict under LEONIDA_FMA=khr (OpFmaKHR, exit 77 if
970 # unsupported), fused-or-split f32 allowed under default --fma glsl (e.g. Mesa RADV splits 5/7). 1129 # unsupported), fused-or-split f32 allowed under default --fma glsl (e.g. Mesa RADV splits 5/7).
@@ -974,14 +1133,23 @@ def run_suite(a, work: str) -> int:
974 elif rc != 0: 1133 elif rc != 0:
975 results.append((name, False, msg)) 1134 results.append((name, False, msg))
976 else: 1135 else:
977 khr = os.environ.get("LEONIDA_FMA") == "khr" 1136 # TEST-1147: judge by the mode the translator recorded in index.json, as check.py does.
978 ok, detail = judge_fma_fused(dump_words(msg), khr=khr) 1137 # --fma exact has no KHR capability, so capability/env alone used to accept split words here.
1138 meta = index.get("cs_fma_fused") or {}
1139 mode = meta.get("fma") or ""
1140 if mode:
1141 # The recorded mode wins over a stale LEONIDA_FMA, as in check.py.
1142 strict = mode in ("khr", "exact")
1143 else:
1144 strict = ("shaderFmaFloat32" in (meta.get("features") or ())
1145 or os.environ.get("LEONIDA_FMA") in ("khr", "exact"))
1146 ok, detail = judge_fma_fused(dump_words(msg), khr=strict)
979 results.append((name, ok, detail)) 1147 results.append((name, ok, detail))
980 elif name == "cs_wavemask": 1148 elif name == "cs_wavemask":
981 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 1149 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
982 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 1150 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
983 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 1151 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
984 elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "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", 1152 elif name in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_w32_sincos", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap", "cs_w32_permlane_fi", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "cs_w32_lds_subdword", "cs_w32_lds_wide", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", "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",
985 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 1153 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
986 "cs_dpp_bound", "cs_dpp_w64", 1154 "cs_dpp_bound", "cs_dpp_w64",
987 "cs_w64_mask_detect", 1155 "cs_w64_mask_detect",
@@ -1008,6 +1176,12 @@ def run_suite(a, work: str) -> int:
1008 # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm) 1176 # 64-bit scalar data ops and v_mad_u64_u32 (cs_w32_salu64.asm)
1009 # more ops with CPU-only checks until now (cs_w32_misc_ext.asm) 1177 # more ops with CPU-only checks until now (cs_w32_misc_ext.asm)
1010 # ops merged on 2026-11-22 with CPU-only checks (cs_w32_new_ops.asm) 1178 # ops merged on 2026-11-22 with CPU-only checks (cs_w32_new_ops.asm)
1179 # plain 8/16-bit MUBUF stores, one crossing a dword (cs_w32_buffer_store_sub.asm)
1180 "cs_w32_buffer_store_sub": [0x1122AB44, 0xCDEF7788, 0x34AABBCC, 0xDDDDDD12, 0x0102035A, 0x05061234, 0xAB, 0xFFFFCDEF],
1181 # 8/16-bit MUBUF d16 loads and stores (cs_w32_buffer_sub16.asm)
1182 "cs_w32_buffer_sub16": [0xBEEF00AA, 0x00AA1234, 0xBEEFFFAA, 0xFFAA1234, 0xBEEF8899, 0x88991234, 0x1122CD44, 0xABCD7788],
1183 # ds_cmpst_f32 and buffer_atomic_fcmpswap: float compare (cs_w32_fcmpswap.asm)
1184 "cs_w32_fcmpswap": [0, 0x3F800000, 0x7FC00000, 0x3F800000, 0x80000000, 0x40400000, 0x3F800000, 0x7FC00000],
1011 "cs_w32_new_ops": [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234], 1185 "cs_w32_new_ops": [0x55, 0x8001, 0xC0000000, 0x80014000, 0x4000FFFF, 0x77, 0x99, 0x1234],
1012 "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D], 1186 "cs_w32_misc_ext": [0x0FFF0FFF, 0xE2C4A688, 0x0007FFFF, 0x7FFF8000, 0xFFFE0002, 0xFFFF0005, 0x509, 0xCAFEF00D],
1013 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE], 1187 "cs_w32_salu64": [0x1E6A2C48, 0x1234, 0xFFFFFFFF, 0x100, 47, 48, 0xFFFF8000, 0xFFFFFFFE],
@@ -1064,6 +1238,8 @@ def run_suite(a, work: str) -> int:
1064 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32 1238 "cs_w32_partial_scmp": [0, 1, 1, 0, 1, 1, 1, 1], # the same in a 20-thread wave32
1065 "cs_w32_andn2_exec": [1, 8, 16, 2064, 2068, 3, 20, 1544], # s_andn2_saveexec/wrexec_b32 (.asm header) 1239 "cs_w32_andn2_exec": [1, 8, 16, 2064, 2068, 3, 20, 1544], # s_andn2_saveexec/wrexec_b32 (.asm header)
1066 "cs_w32_sincos": [1, 1, 1, 1, 1, 1], # SHADER-88 (cs_w32_sincos.asm): angles in turns 1240 "cs_w32_sincos": [1, 1, 1, 1, 1, 1], # SHADER-88 (cs_w32_sincos.asm): angles in turns
1241 # SHADER-74: v_permlane16/x16 FI / BOUND_CTRL with the source lane off in EXEC (cs_w32_permlane_fi.asm)
1242 "cs_w32_permlane_fi": [1000, 0, 4, 1, 1000, 0, 52, 49],
1067 "cs_w64x_sbarrier": [605, 605, 686, 686, 3032, 3013, 3032, 3031], 1243 "cs_w64x_sbarrier": [605, 605, 686, 686, 3032, 3013, 3032, 3031],
1068 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32], 1244 "cs_w64x_load_ballot_load": [43, 74, 75, 42, 42, 18, 41, 32],
1069 "cs_w64x_andn2_exec": [1, 16, 32, 4144, 2052, 3, 8, 1544], # s_andn2_saveexec/wrexec_b64 (.asm header) 1245 "cs_w64x_andn2_exec": [1, 16, 32, 4144, 2052, 3, 8, 1544], # s_andn2_saveexec/wrexec_b64 (.asm header)
@@ -1095,7 +1271,7 @@ def run_suite(a, work: str) -> int:
1095 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 1271 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
1096 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 1272 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
1097 "cs_w32_lds_subdword", "cs_w32_lds_wide", 1273 "cs_w32_lds_subdword", "cs_w32_lds_wide",
1098 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", 1274 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_permlane_fi", "cs_w32_sincos", "cs_w32_buffer_sub16", "cs_w32_buffer_store_sub", "cs_w32_fcmpswap",
1099 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec", 1275 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
1100 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1276 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
1101 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial 1277 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial
@@ -1104,7 +1280,13 @@ def run_suite(a, work: str) -> int:
1104 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774) 1280 if name in WAVE32_LANE_DUMPS: # 32 lanes even without index.json, as check.py requests (#774)
1105 cs_env = dict(os.environ, **WAVE32_LANE_ENV) 1281 cs_env = dict(os.environ, **WAVE32_LANE_ENV)
1106 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env) 1282 rc, msg = run_cmd([vk_compute, spv, "1", "dump"] + (["--require-wave64"] if wave64 else []), env=cs_env)
1107 skip = wave32_lane_skip(msg) if name in WAVE32_LANE_DUMPS else None 1283 skip = None
1284 if name in WAVE32_LANE_DUMPS:
1285 if rc == UNSUPPORTED:
1286 results.append((name, None, unsupported_skip(msg)))
1287 continue
1288 if rc == 0:
1289 skip = wave32_lane_skip(msg)
1108 if skip is None and name in WAVE32_PIN_DUMPS: 1290 if skip is None and name in WAVE32_PIN_DUMPS:
1109 # the device may not be able to run the wave size this fixture was written for (a 64-only device 1291 # the device may not be able to run the wave size this fixture was written for (a 64-only device
1110 # can't pin 32, so cs_barrier_loop's words mean nothing); check.py skips it too 1292 # can't pin 32, so cs_barrier_loop's words mean nothing); check.py skips it too
@@ -1123,10 +1305,7 @@ def run_suite(a, work: str) -> int:
1123 results.append((name, ok, detail)) 1305 results.append((name, ok, detail))
1124 elif name in IMAGE_STORE_CASES: 1306 elif name in IMAGE_STORE_CASES:
1125 rc, msg = run_cmd([vk_store, spv, *IMAGE_STORE_CASES[name]]) 1307 rc, msg = run_cmd([vk_store, spv, *IMAGE_STORE_CASES[name]])
1126 if rc == UNSUPPORTED: 1308 results.append((name, *helper_result(rc, msg)))
1127 results.append((name, None, unsupported_skip(msg)))
1128 else:
1129 results.append((name, rc == 0, msg.splitlines()[-1] if msg else ""))
1130 elif name == "cs_texture_uav": 1309 elif name == "cs_texture_uav":
1131 problem = texture_uav_test(a.build, spv) 1310 problem = texture_uav_test(a.build, spv)
1132 results.append((name, None if isinstance(problem, Skip) else not problem, 1311 results.append((name, None if isinstance(problem, Skip) else not problem,
@@ -1135,6 +1314,10 @@ def run_suite(a, work: str) -> int:
1135 problem = texture_mip_test(a.build, spirv_dir, name) 1314 problem = texture_mip_test(a.build, spirv_dir, name)
1136 ok = None if isinstance(problem, Skip) else not problem 1315 ok = None if isinstance(problem, Skip) else not problem
1137 results.append((name, ok, problem or "two passes, 4096 RGBA32F pixels each exact; wrong mip and UV rejected")) 1316 results.append((name, ok, problem or "two passes, 4096 RGBA32F pixels each exact; wrong mip and UV rejected"))
1317 elif name == "ps_table_fetch":
1318 problem = table_fetch_test(a.build, spirv_dir)
1319 results.append((name, None if isinstance(problem, Skip) else not problem,
1320 problem or "4096 exact pixels each for SINT, UINT and descriptor miss"))
1138 elif name in GRADIENT_TESTS: 1321 elif name in GRADIENT_TESTS:
1139 problem = texture_gradient_a16_test(a.build, spirv_dir, name) 1322 problem = texture_gradient_a16_test(a.build, spirv_dir, name)
1140 ok = None if isinstance(problem, Skip) else not problem 1323 ok = None if isinstance(problem, Skip) else not problem
@@ -1158,7 +1341,7 @@ def run_suite(a, work: str) -> int:
1158 ok, detail = check_d16_texture(raw) 1341 ok, detail = check_d16_texture(raw)
1159 results.append((name, ok, detail)) 1342 results.append((name, ok, detail))
1160 else: 1343 else:
1161 results.append((name, rc == 0 and "PASSED" in msg, msg.splitlines()[-1] if msg else "")) 1344 results.append((name, rc == 0 and "PASSED" in msg, verdict_line(rc, msg)))
1162 elif name in TEXTURE_CONSTANTS: 1345 elif name in TEXTURE_CONSTANTS:
1163 expected = TEXTURE_CONSTANTS[name] 1346 expected = TEXTURE_CONSTANTS[name]
1164 tool = os.path.join(a.build, "vk_texture_test" + ext) 1347 tool = os.path.join(a.build, "vk_texture_test" + ext)
@@ -1172,8 +1355,10 @@ def run_suite(a, work: str) -> int:
1172 if rc == UNSUPPORTED: 1355 if rc == UNSUPPORTED:
1173 results.append((name, None, unsupported_skip(msg))) 1356 results.append((name, None, unsupported_skip(msg)))
1174 else: 1357 else:
1175 results.append((name, rc == 0 and bad == 0, "4096/4096 pixels exact" if bad == 0 else 1358 detail = ("4096/4096 pixels exact" if bad == 0 else
1176 f"{bad} pixels differ from {expected}: {msg.splitlines()[-1] if msg else ''}")) 1359 f"{bad} pixels differ from {expected}: {verdict_line(0, msg)}")
1360 # After a non-zero exit no frame was compared: the exit status, not a pixel count.
1361 results.append((name, rc == 0 and bad == 0, verdict_line(rc, msg) if rc else detail))
1177 elif name in ("ps_tex", "ps_imgatomic"): 1362 elif name in ("ps_tex", "ps_imgatomic"):
1178 # A texture through the descriptor hash table and the bindless set (ps_tex), or image atomics in a pixel 1363 # A texture through the descriptor hash table and the bindless set (ps_tex), or image atomics in a pixel
1179 # shader through the set's r32ui storage arrays (ps_imgatomic, drawn with vs_ids). vk_bindless_test 1364 # shader through the set's r32ui storage arrays (ps_imgatomic, drawn with vs_ids). vk_bindless_test
@@ -1185,7 +1370,7 @@ def run_suite(a, work: str) -> int:
1185 reason = next((ln for ln in lines if ln.startswith("unsupported:")), "unsupported device") 1370 reason = next((ln for ln in lines if ln.startswith("unsupported:")), "unsupported device")
1186 results.append((name, None, f"SKIP ({reason})")) 1371 results.append((name, None, f"SKIP ({reason})"))
1187 else: 1372 else:
1188 results.append((name, rc == 0, lines[-1] if lines else "")) 1373 results.append((name, rc == 0, verdict_line(rc, msg)))
1189 elif name == "ps_ssharp": 1374 elif name == "ps_ssharp":
1190 # The S#/T# mip fields through vulkan_sampler() and the view range (check.py's SAMPLER_CASES). 1375 # The S#/T# mip fields through vulkan_sampler() and the view range (check.py's SAMPLER_CASES).
1191 problem = sampler_test(a.build, spirv_dir) 1376 problem = sampler_test(a.build, spirv_dir)
@@ -1230,6 +1415,7 @@ def run_suite(a, work: str) -> int:
1230 continue 1415 continue
1231 const_wants = { 1416 const_wants = {
1232 "ps_clip_color": (0x3E800000, 0x3F000000, 0x3F400000, 0x3F800000), 1417 "ps_clip_color": (0x3E800000, 0x3F000000, 0x3F400000, 0x3F800000),
1418 "ps_exp_color_mask": (0x40000000, 0x40800000, 0x40000000, 0x40800000), # .asm header
1233 "ps_ops": (0x48804300, 5, 7, 0xBFFFFFFC), 1419 "ps_ops": (0x48804300, 5, 7, 0xBFFFFFFC),
1234 "ps_ops2": (0xABCD4400, 0x46001234, 0xBFFFFFFA, 7), 1420 "ps_ops2": (0xABCD4400, 0x46001234, 0xBFFFFFFA, 7),
1235 "ps_ops3": (0xBFFFFFFA, 0x44660066, 0x44AABBCC, 16), 1421 "ps_ops3": (0xBFFFFFFA, 0x44660066, 0x44AABBCC, 16),
@@ -1247,6 +1433,7 @@ def run_suite(a, work: str) -> int:
1247 "ps_f32_mods": (0xC0256A01, 0x3F800000, 0x41E00000, 0x3FC00000), 1433 "ps_f32_mods": (0xC0256A01, 0x3F800000, 0x41E00000, 0x3FC00000),
1248 "ps_vcc_x2": (0x11223344, 0x55667788, 0, 0), 1434 "ps_vcc_x2": (0x11223344, 0x55667788, 0, 0),
1249 "ps_vcmpx_forms": (0xF05B2A48, 0xF05E8A12, 0xB174BE18, 0x15550000), # 14 v_cmpx forms (.asm header) 1435 "ps_vcmpx_forms": (0xF05B2A48, 0xF05E8A12, 0xB174BE18, 0x15550000), # 14 v_cmpx forms (.asm header)
1436 "ps_vcmp_int32": (0x963E52E8, 0x984DCEE8, 0xB9458EE8, 0xB73612E8), # u32/i32 compares (.asm header)
1250 "ps_med3_mods": (0x3F800000, 0x40400000, 0x40C00000, 0x3F400000), 1437 "ps_med3_mods": (0x3F800000, 0x40400000, 0x40C00000, 0x3F400000),
1251 "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203), 1438 "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203),
1252 "ps_scc_logic32": (0x0fff0fff, 0x000f000f, 0xf00ff00f, 0x36), 1439 "ps_scc_logic32": (0x0fff0fff, 0x000f000f, 0xf00ff00f, 0x36),
@@ -1270,6 +1457,9 @@ def run_suite(a, work: str) -> int:
1270 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate 1457 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate
1271 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware 1458 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware
1272 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1459 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
1460 # v_med3 with a NaN in S2 or in two operands, by the same measured rule (derivations in the .asm headers)
1461 "ps_fnan_med3_s2": (0x40A00000, 0x40A00000, 0xC0200000, 0x40E00000),
1462 "ps_f16_fnan_med3": (0xAAAA4500, 0xAAAA4500, 0xAAAAC100, 0xAAAA4700),
1273 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers) 1463 # TEST-175: docs/design.md rules that were checked on the CPU only (derivations in the .asm headers)
1274 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000), 1464 "ps_cmp_nlg": (0x40000037, 0x40000007, 0x40000001, 0x3F800000),
1275 "ps_far_branch": (0x00000007, 0x00000013, 0x00000051, 0x0000000B), # far branches (.asm header) 1465 "ps_far_branch": (0x00000007, 0x00000013, 0x00000051, 0x0000000B), # far branches (.asm header)
@@ -1278,15 +1468,23 @@ def run_suite(a, work: str) -> int:
1278 "ps_vcmpx_f16": (0x68A12080, 0x6CE9B1A2, 0x6BA72C98, 0x6FEFBDBA), # 16-bit float v_cmpx e32 (.asm header) 1468 "ps_vcmpx_f16": (0x68A12080, 0x6CE9B1A2, 0x6BA72C98, 0x6FEFBDBA), # 16-bit float v_cmpx e32 (.asm header)
1279 "ps_vcmpx_f16_e64": (0x64C11100, 0x6CF171C1, 0x67C71D18, 0x6FF77DD9), # same, e64 with swapped operands 1469 "ps_vcmpx_f16_e64": (0x64C11100, 0x6CF171C1, 0x67C71D18, 0x6FF77DD9), # same, e64 with swapped operands
1280 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000), 1470 "ps_cvt_off": (0xBF000000, 0x3EE00000, 0xBE800000, 0x3F800000),
1281 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3E00, 0xAAAA0000, 0xAAAA4000), 1471 "ps_fmac_f16_mods": (0xAAAA3C00, 0xAAAA3A00, 0xAAAA0000, 0xAAAA4400),
1282 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00), 1472 "ps_vop3_const_mods": (0xC0000000, 0xBF800000, 0x3F800000, 0xAAAABC00),
1473 "ps_cndmask_sign_mods": (0xFF800001, 0x7F800001, 0x80000001, 0x7F800001),
1283 "ps_interp_f32_mods": (0x3F800000, 0x00000000, 0x3F400000, 0x3F800000), # drawn with vs_interp_consts 1474 "ps_interp_f32_mods": (0x3F800000, 0x00000000, 0x3F400000, 0x3F800000), # drawn with vs_interp_consts
1284 "ps_interp_mov_mods": (0x3F800000, 0x3FC00000, 0x40000000, 0x3F400000), 1475 "ps_interp_mov_mods": (0x3F800000, 0x3FC00000, 0x40000000, 0x3F400000),
1285 # v_mad_u32_u16 / v_mad_i32_i16 and v_subrev_f16, which had CPU checks only (.asm headers) 1476 # v_mad_u32_u16 / v_mad_i32_i16 and v_subrev_f16, which had CPU checks only (.asm headers)
1286 "ps_valu16_mad": (0x00000002, 0x00030002, 0x00008000, 0x00000004), 1477 "ps_valu16_mad": (0x00000002, 0x00030002, 0x00008000, 0x00000004),
1478 "ps_valu16_mad_sel": (0x00008003, 0xDB880000, 0xFFFFFFFF, 0x80000000), # measured on gfx1036
1287 "ps_valu16_subrev": (0xAAAABC00, 0xAAAAC000, 0xAAAA3C00, 0x42003800), 1479 "ps_valu16_subrev": (0xAAAABC00, 0xAAAAC000, 0xAAAA3C00, 0x42003800),
1288 "ps_vcmp_f32_nan": (0x0000376C, 0x0000FD5B, 0x0000D36C, 0x00000FE7), # from the .asm headers 1480 "ps_vcmp_f32_nan": (0x0000376C, 0x0000FD5B, 0x0000D36C, 0x00000FE7), # from the .asm headers
1289 "ps_vcmp_64": (0x0000B3C4, 0x000091E6, 0x00006787, 0x00007C93), 1481 "ps_vcmp_64": (0x0000B3C4, 0x000091E6, 0x00006787, 0x00007C93),
1482 # 32-bit integer VALU ops on VINT_ENV's heap (derivations in the .asm headers)
1483 "ps_vint_logic3": (0xFFFFFFFE, 0xBBB05070, 0x1D3B5977, 0x123F5F7E),
1484 "ps_vint_bits": (0xFFFFFFFE, 0x40000000, 0x1E6A2C48, 0x000001D5),
1485 "ps_vint_mul24": (0x13345678, 0xFFFFFFFD, 0x00007FFF, 0x0000FFFF),
1486 "ps_vint_minmax": (0x7FFFFFFE, 0x80000001, 0x80000001, 0x7FFFFFFE),
1487 "ps_vint_minmax3": (0xF0F0F0F0, 0xAB800000, 0xF0F0F0F0, 0xAB800000),
1290 "ps_w64x_readlane": (0x40000079, 0x40000010, 0x40000064, 0x400000BE), # same expectation as check.py 1488 "ps_w64x_readlane": (0x40000079, 0x40000010, 0x40000064, 0x400000BE), # same expectation as check.py
1291 } 1489 }
1292 if skip := wide_pixel_skip(name, msg): # a 64-wide pixel stage the device could not give: nothing to judge 1490 if skip := wide_pixel_skip(name, msg): # a 64-wide pixel stage the device could not give: nothing to judge
@@ -1297,8 +1495,14 @@ def run_suite(a, work: str) -> int:
1297 ok, detail = None, str(skip) 1495 ok, detail = None, str(skip)
1298 else: 1496 else:
1299 ok, detail = check_pixel_const(raw, const_wants[name]) 1497 ok, detail = check_pixel_const(raw, const_wants[name])
1498 elif name == NAN_PAYLOAD_TEST:
1499 problem = nan_payload_problem(read_raw_u32(raw), msg)
1500 ok, detail = not problem, problem or "4096/4096 pixels match the driver-aware NaN payload check"
1300 elif name == "ps_bary": 1501 elif name == "ps_bary":
1301 ok, detail = check_bary(raw) 1502 ok, detail = check_bary(raw)
1503 elif name == "ps_persp_bary":
1504 problem = bary_persp_problem(read_raw_rgba32f(raw))
1505 ok, detail = not problem, problem or "perspective-correct on every covered pixel"
1302 elif name == "ps_bitmask_perm": 1506 elif name == "ps_bitmask_perm":
1303 m = re.search(r"subgroup \d+\.\.(\d+)", msg) 1507 m = re.search(r"subgroup \d+\.\.(\d+)", msg)
1304 if m and int(m.group(1)) < 32: 1508 if m and int(m.group(1)) < 32:
@@ -1312,12 +1516,11 @@ def run_suite(a, work: str) -> int:
1312 elif name == "ps_flat": 1516 elif name == "ps_flat":
1313 ok, detail = check_flat(raw) 1517 ok, detail = check_flat(raw)
1314 elif name == "ps_interp_f16_high": 1518 elif name == "ps_interp_f16_high":
1315 with open(raw, "rb") as source: 1519 # A missing or partial readback is an empty frame for this test, not a crash of the suite (as #3442).
1316 problem = interp_f16_high_problem(list(struct.iter_unpack("<4I", source.read()))) 1520 problem = interp_f16_high_problem(read_raw_u32(raw) if os.path.isfile(raw) else [])
1317 ok, detail = not problem, problem or "f16 low/high halves and f32 control within 2e-3" 1521 ok, detail = not problem, problem or "f16 low/high halves and f32 control within 2e-3"
1318 elif name == "ps_ij_computed": 1522 elif name == "ps_ij_computed":
1319 with open(raw, "rb") as source: 1523 problem = ij_computed_problem(read_raw_u32(raw) if os.path.isfile(raw) else [])
1320 problem = ij_computed_problem(list(struct.iter_unpack("<4I", source.read())))
1321 ok, detail = not problem, problem or "computed I/J pair words and v/2 within 1e-6" 1524 ok, detail = not problem, problem or "computed I/J pair words and v/2 within 1e-6"
1322 elif name == "ps_mandelbrot": 1525 elif name == "ps_mandelbrot":
1323 px = read_raw_u32(raw) if os.path.isfile(raw) else [] 1526 px = read_raw_u32(raw) if os.path.isfile(raw) else []
@@ -1375,8 +1578,8 @@ def run_suite(a, work: str) -> int:
1375 elif rc != 0: 1578 elif rc != 0:
1376 results.append((name, False, msg)) 1579 results.append((name, False, msg))
1377 else: 1580 else:
1378 with open(raw, "rb") as source: 1581 # A missing or partial readback is an empty frame for this test, not a crash of the suite (as #3442).
1379 problem = interp_f16_high_problem(list(struct.iter_unpack("<4I", source.read()))) 1582 problem = interp_f16_high_problem(read_raw_u32(raw) if os.path.isfile(raw) else [])
1380 results.append((name, not problem, problem or "f16 low/high halves and f32 control within 2e-3")) 1583 results.append((name, not problem, problem or "f16 low/high halves and f32 control within 2e-3"))
1381 elif name == "ms_clip": 1584 elif name == "ms_clip":
1382 raw = os.path.join(raw_dir, f"{name}.raw") 1585 raw = os.path.join(raw_dir, f"{name}.raw")
@@ -1417,6 +1620,7 @@ def run_suite(a, work: str) -> int:
1417 print("\n=== GPU TEST RESULTS ===") 1620 print("\n=== GPU TEST RESULTS ===")
1418 passed = skipped = 0 1621 passed = skipped = 0
1419 for name, ok, detail in results: 1622 for name, ok, detail in results:
1623 ok = None if isinstance(detail, Skip) else ok # a check.py helper's "this device can't run it" (cs_fmt_*)
1420 tag = "SKIP" if ok is None else "PASS" if ok else "FAIL" 1624 tag = "SKIP" if ok is None else "PASS" if ok else "FAIL"
1421 passed += ok is True 1625 passed += ok is True
1422 skipped += ok is None 1626 skipped += ok is None