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:
authorMatheus Gomes <39656344+matheuskshn@users.noreply.github.com>2026-11-22 16:27:39 -0300
committerMatheus Gomes <39656344+matheuskshn@users.noreply.github.com>2026-11-22 16:27:39 -0300
commit54e13c51b7d42e86d1eefc570f9ce1f56fc88cc3 (patch)
tree824340eeb75e0795ad8b36699ffcef5b21a2cbf6 /scripts
parent03d9ce780d8ce43d5d341a1ade0c6b864d061ec8 (diff)
parent162821017ea3c286c8bec860f3ff94f037912061 (diff)
Merge upstream main into the Wine timeout fix
Keep the per-test CTest environment and pass its subprocess the more restrictive deadline.
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.py85
-rw-r--r--scripts/run_wine_tests.py17
-rw-r--r--scripts/shader_stats.py28
5 files changed, 102 insertions, 43 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 025504fb8..3a23250fc 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, 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]:
@@ -541,8 +543,9 @@ def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool,
541# checker runs them: the test program that owns them judges them. 543# checker runs them: the test program that owns them judges them.
542OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_translated_draw_test", 544OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_translated_draw_test",
543 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test", 545 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test",
546 "ps_m2_array": "d3d12_m2_formats_test",
544 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test", 547 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test",
545 "ps_m3_post": "d3d12_m3_frame_test", 548 "ps_m3_post": "d3d12_m3_frame_test", "ps_m3_query": "d3d12_m3_frame_test",
546 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test", 549 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test",
547 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test"} 550 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test"}
548 551
@@ -598,6 +601,7 @@ def main() -> int:
598 "subfolder that has the test programs is found by itself") 601 "subfolder that has the test programs is found by itself")
599 ap.add_argument("--work", default=None) 602 ap.add_argument("--work", default=None)
600 ap.add_argument("--filter", default="") 603 ap.add_argument("--filter", default="")
604 ap.add_argument("--require-pass", action="store_true", help="exit 1 if no GPU test passes")
601 a = ap.parse_args() 605 a = ap.parse_args()
602 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path 606 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path
603 # given here would point somewhere else for them. 607 # given here would point somewhere else for them.
@@ -805,10 +809,10 @@ def run_suite(a, work: str) -> int:
805 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " 809 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the "
806 "clamped and the calculated LOD within 1/16")) 810 "clamped and the calculated LOD within 1/16"))
807 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail", 811 elif name in ("cs_bounds", "cs_smem_bounds", "cs_smem_stride_align", "cs_smem_sload_neg", "cs_buf_tail", "cs_oob_select", "cs_oob_tail",
808 "cs_buf_swizzle", "cs_cmpx_class_f32"): 812 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8"):
809 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds 813 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds
810 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. 814 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement.
811 # cs_cmpx_class_f32 is per-lane and needs no particular subgroup width either. 815 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either.
812 # The other four pin the SMEM and raw MUBUF rules measured on an RX 6800 (derivations in each .asm). 816 # The other four pin the SMEM and raw MUBUF rules measured on an RX 6800 (derivations in each .asm).
813 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env) 817 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
814 want = { 818 want = {
@@ -822,10 +826,11 @@ def run_suite(a, work: str) -> int:
822 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0], 826 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0],
823 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0], 827 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0],
824 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010], 828 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010],
825 # swizzled MUBUF addressing and ADD_TID_ENABLE (lanes 0 and 1 store; derivation in the .asm header) 829 # swizzled MUBUF addressing (measured natively on gfx1036) and ADD_TID_ENABLE (lanes 0 and 1 store)
826 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED0028, 0, 0xBEEF0000, 830 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED000C, 0, 0xBEEF0000,
827 0xBEEF0001], 831 0xBEEF0001],
828 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 832 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
833 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
829 }[name] 834 }[name]
830 words = dump_words(msg) 835 words = dump_words(msg)
831 vals = words[:len(want)] if words else [] 836 vals = words[:len(want)] if words else []
@@ -837,6 +842,9 @@ def run_suite(a, work: str) -> int:
837 elif name == "cs_fmt_sint32": 842 elif name == "cs_fmt_sint32":
838 problem = fmt_sint32_test(a.build, spirv_dir, cs_env) 843 problem = fmt_sint32_test(a.build, spirv_dir, cs_env)
839 results.append((name, not problem, problem or "64/64 dumped words exact")) 844 results.append((name, not problem, problem or "64/64 dumped words exact"))
845 elif name == "cs_fmt_int_narrow":
846 problem = fmt_int_narrow_test(a.build, spirv_dir, cs_env)
847 results.append((name, not problem, problem or "136/136 dumped words exact"))
840 elif name == "cs_fmt_xy_xyz": 848 elif name == "cs_fmt_xy_xyz":
841 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header) 849 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header)
842 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env) 850 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env)
@@ -876,7 +884,7 @@ def run_suite(a, work: str) -> int:
876 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 884 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
877 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 885 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
878 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 886 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
879 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", 887 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",
880 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 888 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
881 "cs_dpp_bound", "cs_dpp_w64", 889 "cs_dpp_bound", "cs_dpp_w64",
882 "cs_w64_mask_detect", 890 "cs_w64_mask_detect",
@@ -885,7 +893,8 @@ def run_suite(a, work: str) -> int:
885 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 893 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
886 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", 894 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
887 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", 895 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end",
888 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst"): 896 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst",
897 "cs_mask_vgpr_exec"):
889 cs_dump_wants = { 898 cs_dump_wants = {
890 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], 899 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000],
891 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone 900 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
@@ -924,6 +933,9 @@ def run_suite(a, work: str) -> int:
924 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7], 933 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7],
925 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777], 934 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777],
926 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6], 935 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6],
936 # SHADER-99: -0 and NaN survive (SignedZeroInfNanPreserve, cs_signed_zero_nan.asm); 0 in out[4..7]
937 # without it
938 "cs_signed_zero_nan": [0x80000000, 0x80000000, 0x80008000, 0x00008000, 1, 1, 1, 0x00007C00],
927 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48], 939 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48],
928 "cs_wm_half_ops": [32, 16, 16, 0, 16], 940 "cs_wm_half_ops": [32, 16, 16, 0, 16],
929 "cs_wm_half_cmp": [1, 0, 1, 1], 941 "cs_wm_half_cmp": [1, 0, 1, 1],
@@ -962,10 +974,14 @@ def run_suite(a, work: str) -> int:
962 # differs per wave (cs_barrier_loop.asm) 974 # differs per wave (cs_barrier_loop.asm)
963 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120], 975 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120],
964 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE], 976 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE],
977 # SHADER-21 part 2: a mask copied to a VGPR with v_mov_b32 respects EXEC —
978 # inactive lanes keep the old VGPR (cs_mask_vgpr_exec.asm)
979 "cs_mask_vgpr_exec": [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
980 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF],
965 } 981 }
966 want = cs_dump_wants[name] 982 want = cs_dump_wants[name]
967 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute / 983 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute /
968 # 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 984 # 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
969 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, 985 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip,
970 # as check.py does, where the device has none 986 # as check.py does, where the device has none
971 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were 987 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were
@@ -974,11 +990,11 @@ def run_suite(a, work: str) -> int:
974 # size 64 without them. 990 # size 64 without them.
975 emulated = w64_emulated() 991 emulated = w64_emulated()
976 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp") 992 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp")
977 wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 993 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
978 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 994 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
979 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 995 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
980 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", 996 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos",
981 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", 997 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
982 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 998 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
983 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial 999 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial
984 if partial and not emulated: 1000 if partial and not emulated:
@@ -990,9 +1006,13 @@ def run_suite(a, work: str) -> int:
990 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right 1006 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right
991 ok, detail = None, str(skip) 1007 ok, detail = None, str(skip)
992 else: 1008 else:
1009 want = judged_words(name, msg, want) # cs_signed_zero_nan on Apple and llvmpipe (check.py)
993 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated, 1010 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated,
994 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16", 1011 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16",
995 "cs_lds_b64_cmpst")) 1012 "cs_lds_b64_cmpst", "cs_signed_zero_nan"))
1013 if ok and None in want:
1014 unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None)
1015 detail += f" (words {unjudged} not judged on this device: UNJUDGED_WORDS in check.py)"
996 results.append((name, ok, detail)) 1016 results.append((name, ok, detail))
997 elif name == "cs_imgstore": 1017 elif name == "cs_imgstore":
998 rc, msg = run_cmd([vk_store, spv]) 1018 rc, msg = run_cmd([vk_store, spv])
@@ -1020,13 +1040,7 @@ def run_suite(a, work: str) -> int:
1020 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"], 1040 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"],
1021 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, []) 1041 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, [])
1022 cmd = [tool, *mode, raw] 1042 cmd = [tool, *mode, raw]
1023 try: 1043 rc, msg = run_cmd(cmd, cwd=spirv_dir)
1024 p = subprocess.run(cmd, capture_output=True, text=True, cwd=spirv_dir)
1025 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1026 except FileNotFoundError:
1027 rc, msg = 1, f"missing {tool}"
1028 except OSError as e:
1029 rc, msg = 1, start_failure(tool, e)
1030 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need 1044 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need
1031 results.append((name, None, unsupported_skip(msg))) 1045 results.append((name, None, unsupported_skip(msg)))
1032 elif name == "ps_texture_sample_d16" and rc == 0: 1046 elif name == "ps_texture_sample_d16" and rc == 0:
@@ -1038,12 +1052,8 @@ def run_suite(a, work: str) -> int:
1038 expected = TEXTURE_CONSTANTS[name] 1052 expected = TEXTURE_CONSTANTS[name]
1039 tool = os.path.join(a.build, "vk_texture_test" + ext) 1053 tool = os.path.join(a.build, "vk_texture_test" + ext)
1040 raw = os.path.join(raw_dir, f"{name}.raw") 1054 raw = os.path.join(raw_dir, f"{name}.raw")
1041 try: 1055 rc, msg = run_cmd([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000",
1042 p = subprocess.run([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000", 1056 "14500000", "0"], cwd=spirv_dir)
1043 "14500000", "0"], capture_output=True, text=True, cwd=spirv_dir)
1044 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1045 except FileNotFoundError:
1046 rc, msg = 1, f"missing {tool}"
1047 bad = 4096 1057 bad = 4096
1048 if rc == 0 and os.path.isfile(raw): 1058 if rc == 0 and os.path.isfile(raw):
1049 data = Path(raw).read_bytes() 1059 data = Path(raw).read_bytes()
@@ -1090,7 +1100,9 @@ def run_suite(a, work: str) -> int:
1090 raw = os.path.join(raw_dir, f"{name}.raw") 1100 raw = os.path.join(raw_dir, f"{name}.raw")
1091 vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids 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
1092 if name in PIXEL_VERTEX: 1102 if name in PIXEL_VERTEX:
1093 if bary_fallback() and name == "ps_interp_f16_high": # no PerVertexKHR inputs under --bary-fallback 1103 # --bary-fallback alone has no PerVertexKHR inputs, so the f16 halves can't be interpolated; with
1104 # --f16-interp-fallback too (on by itself without fragmentShaderBarycentric) it reads decoded halves.
1105 if name == "ps_interp_f16_high" and bary_fallback() and not f16_interp_fallback():
1094 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1106 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1095 continue 1107 continue
1096 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv") 1108 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv")
@@ -1127,6 +1139,7 @@ def run_suite(a, work: str) -> int:
1127 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16), 1139 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16),
1128 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000), 1140 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000),
1129 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64 1141 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64
1142 "ps_outmods_f16": (0xAAAA3C00, 0xAAAA3E00, 0x7C000000, 0x3C000000),
1130 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers) 1143 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers)
1131 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555), 1144 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555),
1132 "ps_f16_med3_mods": (0x41005555, 0x3C005555, 0x41003800, 0xAAAABA00), 1145 "ps_f16_med3_mods": (0x41005555, 0x3C005555, 0x41003800, 0xAAAABA00),
@@ -1138,6 +1151,7 @@ def run_suite(a, work: str) -> int:
1138 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3), 1151 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3),
1139 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200), 1152 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200),
1140 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400), 1153 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400),
1154 "ps_sdwa_f16_const": (0xAAAA3800, 0xAAAA1C00, 0xAAAA3E00, 0xAAAA73F0), # measured on gfx1036
1141 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate 1155 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate
1142 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware 1156 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware
1143 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1157 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
@@ -1231,7 +1245,7 @@ def run_suite(a, work: str) -> int:
1231 raw = os.path.join(raw_dir, f"{name}.raw") 1245 raw = os.path.join(raw_dir, f"{name}.raw")
1232 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS 1246 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS
1233 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv") 1247 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv")
1234 if bary_fallback(): 1248 if bary_fallback() and not f16_interp_fallback():
1235 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1249 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1236 continue 1250 continue
1237 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env) 1251 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env)
@@ -1274,7 +1288,12 @@ def run_suite(a, work: str) -> int:
1274 skipped += ok is None 1288 skipped += ok is None
1275 print(f" {tag:4s} {name:<20s} {detail}") 1289 print(f" {tag:4s} {name:<20s} {detail}")
1276 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else "")) 1290 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else ""))
1277 return 0 if passed + skipped == len(results) else 1 1291 if passed + skipped != len(results):
1292 return 1
1293 if getattr(a, "require_pass", False) and not passed:
1294 print("error: --require-pass: no GPU tests passed", file=sys.stderr)
1295 return 1
1296 return 0
1278 1297
1279 1298
1280if __name__ == "__main__": 1299if __name__ == "__main__":
diff --git a/scripts/run_wine_tests.py b/scripts/run_wine_tests.py
index e4fbdf1fa..5c16cfb16 100644
--- a/scripts/run_wine_tests.py
+++ b/scripts/run_wine_tests.py
@@ -119,6 +119,9 @@ def regex_list(value: str | list[str]) -> list[str]:
119 119
120def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]: 120def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
121 """Returns (status, detail): status is pass, fail or skip.""" 121 """Returns (status, detail): status is pass, fail or skip."""
122 props = properties(test)
123 if truthy(props.get("DISABLED")):
124 return "skip", "disabled by CTest"
122 command = test.get("command") 125 command = test.get("command")
123 if not command: 126 if not command:
124 return "fail", "no command (target not built?)" 127 return "fail", "no command (target not built?)"
@@ -132,11 +135,21 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
132 for a in command[1:]: 135 for a in command[1:]:
133 mapped = map_path(a, args.windows_root, args.root) 136 mapped = map_path(a, args.windows_root, args.root)
134 argv.append(wine_path(mapped) if mapped is not None else a) 137 argv.append(wine_path(mapped) if mapped is not None else a)
135 props = properties(test)
136 cwd = props.get("WORKING_DIRECTORY") 138 cwd = props.get("WORKING_DIRECTORY")
137 cwd = map_path(cwd, args.windows_root, args.root) if cwd else os.path.dirname(exe) 139 cwd = map_path(cwd, args.windows_root, args.root) if cwd else os.path.dirname(exe)
138 if not cwd or not os.path.isdir(cwd): 140 if not cwd or not os.path.isdir(cwd):
139 cwd = os.path.dirname(exe) 141 cwd = os.path.dirname(exe)
142 assignments = props.get("ENVIRONMENT", [])
143 if not isinstance(assignments, list):
144 return "fail", "invalid CTest ENVIRONMENT: expected a list of NAME=value entries"
145 env = os.environ.copy()
146 for assignment in assignments:
147 if not isinstance(assignment, str):
148 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value"
149 key, equals, value = assignment.partition("=")
150 if not key or not equals or "\0" in assignment:
151 return "fail", "invalid CTest ENVIRONMENT entry: expected NAME=value"
152 env[key] = value
140 timeout = args.timeout 153 timeout = args.timeout
141 if "TIMEOUT" in props: 154 if "TIMEOUT" in props:
142 try: 155 try:
@@ -149,7 +162,7 @@ def run_test(test: dict, args, wine: list[str]) -> tuple[str, str]:
149 timeout = min(timeout, ctest_timeout) 162 timeout = min(timeout, ctest_timeout)
150 start = time.monotonic() 163 start = time.monotonic()
151 try: 164 try:
152 proc = subprocess.run(argv, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, 165 proc = subprocess.run(argv, cwd=cwd, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
153 timeout=timeout) 166 timeout=timeout)
154 except subprocess.TimeoutExpired as e: 167 except subprocess.TimeoutExpired as e:
155 out = (e.stdout or b"").decode("utf-8", "replace") 168 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)