upleb.uk

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

summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 19:52:12 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 19:52:12 +0100
commit676c6abae3ca07ca1d3498c26bb12b4e90e21c3e (patch)
tree93f21b78c6dc4340075556286a18eae5ce12c909 /scripts
parentdd678a7681f7a046aa5ff173edcbec60a1552f31 (diff)
parent162821017ea3c286c8bec860f3ff94f037912061 (diff)
Merge main into coverage-gaps (#1299)
runtime/test/shaders/check.py scripts/run_gpu_tests.py tests/semantic/test_value_semantics.py AI-assisted.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/audit_shader4_regs.py4
-rw-r--r--scripts/bench_wave64.py11
-rw-r--r--scripts/run_gpu_tests.py74
-rw-r--r--scripts/run_wine_tests.py17
-rw-r--r--scripts/shader_stats.py28
5 files changed, 95 insertions, 39 deletions
diff --git a/scripts/audit_shader4_regs.py b/scripts/audit_shader4_regs.py
index 6a6c449de..6bc3b42af 100644
--- a/scripts/audit_shader4_regs.py
+++ b/scripts/audit_shader4_regs.py
@@ -171,8 +171,8 @@ def rbw_registers(insns):
171 reads_imm_dst or "fmac" in op or "mac_" in op or op == "v_writelane_b32" 171 reads_imm_dst or "fmac" in op or "mac_" in op or op == "v_writelane_b32"
172 or op == "v_swap_b32" or "_atomic_" in op 172 or op == "v_swap_b32" or "_atomic_" in op
173 ) 173 )
174 # v_add_co_u32 / v_sub_co_u32 write both a[0] (VGPR) and a[1] (carry SGPR/vcc). 174 # Carry-out forms write the VGPR and scalar mask first, even when they also take a carry-in source.
175 if not is_no_dest and op.startswith("v_") and "_co_" in op and "_ci_" not in op and len(args) >= 2: 175 if not is_no_dest and op.startswith("v_") and "_co_" in op and len(args) >= 2:
176 dsts = args[:2] 176 dsts = args[:2]
177 srcs = args[2:] 177 srcs = args[2:]
178 elif is_no_dest: 178 elif is_no_dest:
diff --git a/scripts/bench_wave64.py b/scripts/bench_wave64.py
index 14b397f97..b41c6e97e 100644
--- a/scripts/bench_wave64.py
+++ b/scripts/bench_wave64.py
@@ -110,9 +110,16 @@ def main():
110 print(f"no reference output from {ref_name}: cannot compare") 110 print(f"no reference output from {ref_name}: cannot compare")
111 return 1 111 return 1
112 bad = [n for n, _, _ in CONFIGS[1:] if n in hashes and hashes[n] != ref] 112 bad = [n for n, _, _ in CONFIGS[1:] if n in hashes and hashes[n] != ref]
113 missing = [n for n, _, _ in CONFIGS[1:] if n not in hashes]
113 print(f"reference output hash: {next(iter(ref))} ({ref_name})") 114 print(f"reference output hash: {next(iter(ref))} ({ref_name})")
114 print("emulated output equals the reference" if not bad else f"OUTPUT DIFFERS from the reference: {', '.join(bad)}") 115 if bad:
115 return 1 if bad or len(hashes) < len(CONFIGS) else 0 116 print(f"OUTPUT DIFFERS from the reference: {', '.join(bad)}")
117 if missing:
118 print(f"incomplete comparison: no complete result from {', '.join(missing)}")
119 if bad or missing:
120 return 1
121 print("emulated output equals the reference")
122 return 0
116 123
117 124
118if __name__ == "__main__": 125if __name__ == "__main__":
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index e630a99be..53e35ff78 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -1,7 +1,7 @@
1"""Assemble, translate, and run the synthetic RDNA2->SPIR-V GPU test suite on Vulkan. 1"""Assemble, translate, and run the synthetic RDNA2->SPIR-V GPU test suite on Vulkan.
2 2
3Usage: 3Usage:
4 python -I scripts/run_gpu_tests.py [--llvm-mc CMD] [--build DIR] [--work DIR] [--filter SUBSTR] 4 python -I scripts/run_gpu_tests.py [--llvm-mc CMD] [--build DIR] [--work DIR] [--filter SUBSTR] [--require-pass]
5 5
6--llvm-mc (or LLVM_MC) is a path or a whole command, e.g. "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc". 6--llvm-mc (or LLVM_MC) is a path or a whole command, e.g. "wsl -d Ubuntu -e /usr/lib/llvm-21/bin/llvm-mc".
7""" 7"""
@@ -25,13 +25,14 @@ 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_sint32_test, fmt_xy_xyz_test, tbuffer_store_test 28from check import Skip, clip_test, fmt_1010102_test, fmt_int_narrow_test, fmt_sint32_test, fmt_xy_xyz_test, tbuffer_store_test
29from compute_fixture import compute_header 29from compute_fixture import compute_header
30from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test) 30from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test)
31from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES, 31from check import (CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES,
32 TEXTURE_MIP_TEST, GATHER_LOD_TEST, MIP_TEST_PASSES, TEXTURE_CONSTANTS, USER_SGPRS_ENV, USER_SGPRS_WORDS, Skip, mesh_v5_test, not_found_message, 32 TEXTURE_MIP_TEST, GATHER_LOD_TEST, MIP_TEST_PASSES, TEXTURE_CONSTANTS, USER_SGPRS_ENV, USER_SGPRS_WORDS, Skip, mesh_v5_test, not_found_message,
33 pick_build_dir, start_failure, texture_gradient_a16_test, texture_mip_test) 33 pick_build_dir, start_failure, texture_gradient_a16_test, texture_mip_test)
34from check import SIGNED_MIP_TEST 34from check import SIGNED_MIP_TEST
35from check import judged_words, words_match # dump words not judged on some devices (cs_signed_zero_nan)
35from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py 36from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and arguments live in check.py
36from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8 37from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8
37from 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)
@@ -238,12 +239,13 @@ def unsupported_skip(msg: str) -> str:
238 return f"SKIP ({m.group(0) if m else 'unsupported device'})" 239 return f"SKIP ({m.group(0) if m else 'unsupported device'})"
239 240
240 241
241def run_cmd(cmd: list[str], env: dict | None = None, gpu: bool = True) -> tuple[int, str]: 242def run_cmd(cmd: list[str], env: dict | None = None, gpu: bool = True, *,
243 cwd: str | None = None) -> tuple[int, str]:
242 # A hung GPU test program fails its test instead of stalling the suite (check.py, LEONIDA_GPU_TEST_TIMEOUT). 244 # A hung GPU test program fails its test instead of stalling the suite (check.py, LEONIDA_GPU_TEST_TIMEOUT).
243 # gpu=False (the translator over the whole suite) runs without a limit. 245 # gpu=False (the translator over the whole suite) runs without a limit.
244 limit = gpu_test_timeout() if gpu else None 246 limit = gpu_test_timeout() if gpu else None
245 try: 247 try:
246 p = subprocess.run(cmd, capture_output=True, text=True, env=env, timeout=limit) 248 p = subprocess.run(cmd, capture_output=True, text=True, env=env, timeout=limit, cwd=cwd)
247 except subprocess.TimeoutExpired: 249 except subprocess.TimeoutExpired:
248 return 1, timed_out(cmd[0], limit) 250 return 1, timed_out(cmd[0], limit)
249 except OSError as e: # e.g. Smart App Control blocked a fresh build: fail this test, keep running the others 251 except OSError as e: # e.g. Smart App Control blocked a fresh build: fail this test, keep running the others
@@ -325,7 +327,7 @@ def judge_cs_dump(rc: int, msg: str, want: list[int], *, wave64: bool, partial:
325 if rc != 0 or words is None: 327 if rc != 0 or words is None:
326 return False, msg 328 return False, msg
327 vals = words[:len(want)] 329 vals = words[:len(want)]
328 return vals == want, " ".join((hex if hexwords else str)(x) for x in vals) 330 return words_match(vals, want), " ".join((hex if hexwords else str)(x) for x in vals)
329 331
330 332
331def check_pixel_const(raw_path: str, want: tuple[int, int, int, int]) -> tuple[bool, str]: 333def check_pixel_const(raw_path: str, want: tuple[int, int, int, int]) -> tuple[bool, str]:
@@ -606,6 +608,7 @@ def main() -> int:
606 "subfolder that has the test programs is found by itself") 608 "subfolder that has the test programs is found by itself")
607 ap.add_argument("--work", default=None) 609 ap.add_argument("--work", default=None)
608 ap.add_argument("--filter", default="") 610 ap.add_argument("--filter", default="")
611 ap.add_argument("--require-pass", action="store_true", help="exit 1 if no GPU test passes")
609 a = ap.parse_args() 612 a = ap.parse_args()
610 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path 613 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path
611 # given here would point somewhere else for them. 614 # given here would point somewhere else for them.
@@ -830,8 +833,8 @@ def run_suite(a, work: str) -> int:
830 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0], 833 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0],
831 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0], 834 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0],
832 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010], 835 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010],
833 # swizzled MUBUF addressing and ADD_TID_ENABLE (lanes 0 and 1 store; derivation in the .asm header) 836 # swizzled MUBUF addressing (measured natively on gfx1036) and ADD_TID_ENABLE (lanes 0 and 1 store)
834 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED0028, 0, 0xBEEF0000, 837 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED000C, 0, 0xBEEF0000,
835 0xBEEF0001], 838 0xBEEF0001],
836 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 839 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
837 "cs_cvt_pk_u8": CVT_PK_U8_WORDS, 840 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
@@ -846,6 +849,9 @@ def run_suite(a, work: str) -> int:
846 elif name == "cs_fmt_sint32": 849 elif name == "cs_fmt_sint32":
847 problem = fmt_sint32_test(a.build, spirv_dir, cs_env) 850 problem = fmt_sint32_test(a.build, spirv_dir, cs_env)
848 results.append((name, not problem, problem or "64/64 dumped words exact")) 851 results.append((name, not problem, problem or "64/64 dumped words exact"))
852 elif name == "cs_fmt_int_narrow":
853 problem = fmt_int_narrow_test(a.build, spirv_dir, cs_env)
854 results.append((name, not problem, problem or "136/136 dumped words exact"))
849 elif name == "cs_fmt_xy_xyz": 855 elif name == "cs_fmt_xy_xyz":
850 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header) 856 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header)
851 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env) 857 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env)
@@ -885,7 +891,7 @@ def run_suite(a, work: str) -> int:
885 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 891 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
886 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 892 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
887 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 893 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
888 elif name in ("cs_store", "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_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", 894 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_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",
889 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 895 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
890 "cs_dpp_bound", "cs_dpp_w64", 896 "cs_dpp_bound", "cs_dpp_w64",
891 "cs_w64_mask_detect", 897 "cs_w64_mask_detect",
@@ -894,7 +900,8 @@ def run_suite(a, work: str) -> int:
894 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 900 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
895 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", 901 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
896 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", 902 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end",
897 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst", "cs_w32_andn2_exec"): 903 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst", "cs_w32_andn2_exec",
904 "cs_mask_vgpr_exec"):
898 cs_dump_wants = { 905 cs_dump_wants = {
899 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], 906 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000],
900 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone 907 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
@@ -933,6 +940,9 @@ def run_suite(a, work: str) -> int:
933 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7], 940 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7],
934 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777], 941 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777],
935 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6], 942 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6],
943 # SHADER-99: -0 and NaN survive (SignedZeroInfNanPreserve, cs_signed_zero_nan.asm); 0 in out[4..7]
944 # without it
945 "cs_signed_zero_nan": [0x80000000, 0x80000000, 0x80008000, 0x00008000, 1, 1, 1, 0x00007C00],
936 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48], 946 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48],
937 "cs_wm_half_ops": [32, 16, 16, 0, 16], 947 "cs_wm_half_ops": [32, 16, 16, 0, 16],
938 "cs_wm_half_cmp": [1, 0, 1, 1], 948 "cs_wm_half_cmp": [1, 0, 1, 1],
@@ -972,10 +982,14 @@ def run_suite(a, work: str) -> int:
972 # differs per wave (cs_barrier_loop.asm) 982 # differs per wave (cs_barrier_loop.asm)
973 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120], 983 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120],
974 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE], 984 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE],
985 # SHADER-21 part 2: a mask copied to a VGPR with v_mov_b32 respects EXEC —
986 # inactive lanes keep the old VGPR (cs_mask_vgpr_exec.asm)
987 "cs_mask_vgpr_exec": [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
988 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF],
975 } 989 }
976 want = cs_dump_wants[name] 990 want = cs_dump_wants[name]
977 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute / 991 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute /
978 # cs_w32_lds_u8_d16 / cs_w32_sincos / cs_w32_int_ext / cs_w32_salu64 / cs_w32_misc_ext / cs_w32_new_ops, the wave32 992 # cs_w32_lds_u8_d16 / cs_w32_sincos / cs_w32_int_ext / cs_w32_salu64 / cs_w32_misc_ext / cs_w32_new_ops / cs_signed_zero_nan, the wave32
979 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, 993 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip,
980 # as check.py does, where the device has none 994 # as check.py does, where the device has none
981 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were 995 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were
@@ -984,11 +998,11 @@ def run_suite(a, work: str) -> int:
984 # size 64 without them. 998 # size 64 without them.
985 emulated = w64_emulated() 999 emulated = w64_emulated()
986 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp") 1000 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp")
987 wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 1001 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
988 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 1002 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
989 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 1003 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
990 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", 1004 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos",
991 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", 1005 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
992 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1006 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
993 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial 1007 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi", "cs_w32_andn2_exec") and not emulated and not partial
994 if partial and not emulated: 1008 if partial and not emulated:
@@ -1000,9 +1014,13 @@ def run_suite(a, work: str) -> int:
1000 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right 1014 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right
1001 ok, detail = None, str(skip) 1015 ok, detail = None, str(skip)
1002 else: 1016 else:
1017 want = judged_words(name, msg, want) # cs_signed_zero_nan on Apple and llvmpipe (check.py)
1003 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated, 1018 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated,
1004 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16", 1019 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16",
1005 "cs_lds_b64_cmpst")) 1020 "cs_lds_b64_cmpst", "cs_signed_zero_nan"))
1021 if ok and None in want:
1022 unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None)
1023 detail += f" (words {unjudged} not judged on this device: UNJUDGED_WORDS in check.py)"
1006 results.append((name, ok, detail)) 1024 results.append((name, ok, detail))
1007 elif name == "cs_imgstore": 1025 elif name == "cs_imgstore":
1008 rc, msg = run_cmd([vk_store, spv]) 1026 rc, msg = run_cmd([vk_store, spv])
@@ -1030,13 +1048,7 @@ def run_suite(a, work: str) -> int:
1030 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"], 1048 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"],
1031 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, []) 1049 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, [])
1032 cmd = [tool, *mode, raw] 1050 cmd = [tool, *mode, raw]
1033 try: 1051 rc, msg = run_cmd(cmd, cwd=spirv_dir)
1034 p = subprocess.run(cmd, capture_output=True, text=True, cwd=spirv_dir)
1035 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1036 except FileNotFoundError:
1037 rc, msg = 1, f"missing {tool}"
1038 except OSError as e:
1039 rc, msg = 1, start_failure(tool, e)
1040 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need 1052 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need
1041 results.append((name, None, unsupported_skip(msg))) 1053 results.append((name, None, unsupported_skip(msg)))
1042 elif name == "ps_texture_sample_d16" and rc == 0: 1054 elif name == "ps_texture_sample_d16" and rc == 0:
@@ -1048,12 +1060,8 @@ def run_suite(a, work: str) -> int:
1048 expected = TEXTURE_CONSTANTS[name] 1060 expected = TEXTURE_CONSTANTS[name]
1049 tool = os.path.join(a.build, "vk_texture_test" + ext) 1061 tool = os.path.join(a.build, "vk_texture_test" + ext)
1050 raw = os.path.join(raw_dir, f"{name}.raw") 1062 raw = os.path.join(raw_dir, f"{name}.raw")
1051 try: 1063 rc, msg = run_cmd([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000",
1052 p = subprocess.run([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000", 1064 "14500000", "0"], cwd=spirv_dir)
1053 "14500000", "0"], capture_output=True, text=True, cwd=spirv_dir)
1054 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1055 except FileNotFoundError:
1056 rc, msg = 1, f"missing {tool}"
1057 bad = 4096 1065 bad = 4096
1058 if rc == 0 and os.path.isfile(raw): 1066 if rc == 0 and os.path.isfile(raw):
1059 data = Path(raw).read_bytes() 1067 data = Path(raw).read_bytes()
@@ -1100,7 +1108,9 @@ def run_suite(a, work: str) -> int:
1100 raw = os.path.join(raw_dir, f"{name}.raw") 1108 raw = os.path.join(raw_dir, f"{name}.raw")
1101 vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids 1109 vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids
1102 if name in PIXEL_VERTEX: 1110 if name in PIXEL_VERTEX:
1103 if bary_fallback() and name == "ps_interp_f16_high": # no PerVertexKHR inputs under --bary-fallback 1111 # --bary-fallback alone has no PerVertexKHR inputs, so the f16 halves can't be interpolated; with
1112 # --f16-interp-fallback too (on by itself without fragmentShaderBarycentric) it reads decoded halves.
1113 if name == "ps_interp_f16_high" and bary_fallback() and not f16_interp_fallback():
1104 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1114 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1105 continue 1115 continue
1106 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv") 1116 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv")
@@ -1149,6 +1159,7 @@ def run_suite(a, work: str) -> int:
1149 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3), 1159 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3),
1150 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200), 1160 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200),
1151 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400), 1161 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400),
1162 "ps_sdwa_f16_const": (0xAAAA3800, 0xAAAA1C00, 0xAAAA3E00, 0xAAAA73F0), # measured on gfx1036
1152 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate 1163 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate
1153 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware 1164 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware
1154 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1165 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
@@ -1244,7 +1255,7 @@ def run_suite(a, work: str) -> int:
1244 raw = os.path.join(raw_dir, f"{name}.raw") 1255 raw = os.path.join(raw_dir, f"{name}.raw")
1245 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS 1256 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS
1246 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv") 1257 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv")
1247 if bary_fallback(): 1258 if bary_fallback() and not f16_interp_fallback():
1248 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1259 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1249 continue 1260 continue
1250 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env) 1261 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env)
@@ -1287,7 +1298,12 @@ def run_suite(a, work: str) -> int:
1287 skipped += ok is None 1298 skipped += ok is None
1288 print(f" {tag:4s} {name:<20s} {detail}") 1299 print(f" {tag:4s} {name:<20s} {detail}")
1289 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else "")) 1300 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else ""))
1290 return 0 if passed + skipped == len(results) else 1 1301 if passed + skipped != len(results):
1302 return 1
1303 if getattr(a, "require_pass", False) and not passed:
1304 print("error: --require-pass: no GPU tests passed", file=sys.stderr)
1305 return 1
1306 return 0
1291 1307
1292 1308
1293if __name__ == "__main__": 1309if __name__ == "__main__":
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index 0a02525e5..28c7f2f63 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -118,6 +118,9 @@ def regex_list(value: str | list[str]) -> list[str]:
118 118
119def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]: 119def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
120 """Returns (status, detail): status is pass, fail or skip.""" 120 """Returns (status, detail): status is pass, fail or skip."""
121 props = properties(test)
122 if truthy(props.get("DISABLED")):
123 return "skip", "disabled by CTest"
121 command = test.get("command") 124 command = test.get("command")
122 if not command: 125 if not command:
123 return "fail", "no command (target not built?)" 126 return "fail", "no command (target not built?)"
@@ -131,14 +134,24 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
131 for a in command[1:]: 134 for a in command[1:]:
132 mapped = map_path(a, args.windows_root, args.root) 135 mapped = map_path(a, args.windows_root, args.root)
133 argv.append(wine_path(mapped) if mapped is not None else a) 136 argv.append(wine_path(mapped) if mapped is not None else a)
134 props = properties(test)
135 cwd = props.get("WORKING_DIRECTORY") 137 cwd = props.get("WORKING_DIRECTORY")
136 cwd = map_path(cwd, args.windows_root, args.root) if cwd else os.path.dirname(exe) 138 cwd = map_path(cwd, args.windows_root, args.root) if cwd else os.path.dirname(exe)
137 if not cwd or not os.path.isdir(cwd): 139 if not cwd or not os.path.isdir(cwd):
138 cwd = os.path.dirname(exe) 140 cwd = os.path.dirname(exe)
141 assignments = props.get("ENVIRONMENT", [])
142 if not isinstance(assignments, list):
143 return "fail", "invalid CTest ENVIRONMENT: expected a list of NAME=value entries"
144 env = os.environ.copy()
145 for assignment in assignments:
146 if not isinstance(assignment, str):
147 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value"
148 key, equals, value = assignment.partition("=")
149 if not key or not equals or "\0" in assignment:
150 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value"
151 env[key] = value
139 start = time.monotonic() 152 start = time.monotonic()
140 try: 153 try:
141 proc = subprocess.run(argv, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 154 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
142 timeout=args.timeout) 155 timeout=args.timeout)
143 except subprocess.TimeoutExpired as e: 156 except subprocess.TimeoutExpired as e:
144 out = (e.stdout or b"").decode("utf-8", "replace") 157 out = (e.stdout or b"").decode("utf-8", "replace")
diff --git a/scripts/shader_stats.py b/scripts/shader_stats.py
index 3fb3d8795..e7c7eb450 100644
--- a/scripts/shader_stats.py
+++ b/scripts/shader_stats.py
@@ -38,10 +38,17 @@ COLUMNS = [("orig", "orig", 5, ""), ("aco", "aco", 5, ""), ("growth", "growth",
38 ("spill_detail", "spills", 6, ""), ("waves", "waves", 5, "")] 38 ("spill_detail", "spills", 6, ""), ("waves", "waves", 5, "")]
39 39
40 40
41def original(path): 41def original(path: str) -> tuple[int, int]:
42 """(instruction count, VGPRs used) of an original RDNA listing.""" 42 """(instruction count, VGPRs used) of an original RDNA listing."""
43 insns = shader_ir.parse_file(path)["insns"] 43 insns = shader_ir.parse_file(path)["insns"]
44 top = max((a["r"] + a.get("n", 1) for i in insns for a in i["args"] if a.get("k") == "vgpr"), default=0) 44 top = 0
45 for insn in insns:
46 for operand in insn["args"]:
47 kind = operand.get("k")
48 if kind == "vgpr":
49 top = max(top, operand["r"] + operand.get("n", 1))
50 elif kind == "vlist":
51 top = max(top, max(operand["r"]) + 1)
45 return len(insns), top 52 return len(insns), top
46 53
47 54
@@ -131,10 +138,23 @@ def median_clause(rs, key, label):
131 return f"{label} median {statistics.median(r[key] for r in known):g}{coverage(len(known), len(rs))}" 138 return f"{label} median {statistics.median(r[key] for r in known):g}{coverage(len(known), len(rs))}"
132 139
133 140
141USAGE = "usage: shader_stats.py <stats.csv> <disasm dir> [--details]"
142
143
134def main(): 144def main():
135 args = [a for a in sys.argv[1:] if not a.startswith("--")] 145 argv = sys.argv[1:]
146 if "-h" in argv or "--help" in argv:
147 print(__doc__)
148 return 0
149 # A misspelt option (--detail) used to be dropped, and the summary printed as if it had been asked for.
150 unknown = [a for a in argv if a.startswith("--") and a != "--details"]
151 if unknown:
152 print(f"unknown option {unknown[0]}\n{USAGE}", file=sys.stderr)
153 return 2
154 args = [a for a in argv if not a.startswith("--")]
136 if len(args) != 2: 155 if len(args) != 2:
137 sys.exit(__doc__) 156 print(USAGE, file=sys.stderr)
157 return 2
138 path = args[0] 158 path = args[0]
139 try: 159 try:
140 stats = load_stats(path) 160 stats = load_stats(path)