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:53:43 +0100
committerVonsek <45567075+Vonsek@users.noreply.github.com>2026-11-22 19:53:43 +0100
commit9fe7fee5e1064ff2f136712f7f9b47db7c52d90e (patch)
treed6cfb33e455b98beb2d7fd92b7baa572f2add295 /scripts
parent7d370cdfbca638eb87d7a487d1a6886fbe946e6e (diff)
parent162821017ea3c286c8bec860f3ff94f037912061 (diff)
Merge main into gpu-vopc-int (#2220)
tests/semantic/regen_fixtures.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.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 2bb3c636d..8e8e04ab9 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]:
@@ -545,8 +547,9 @@ def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool,
545# checker runs them: the test program that owns them judges them. 547# checker runs them: the test program that owns them judges them.
546OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_translated_draw_test", 548OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_translated_draw_test",
547 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test", 549 "ps_m2": "d3d12_m2_textured_test", "vs_m2": "d3d12_m2_textured_test", "ps_m2_uoff": "d3d12_m2_textured_test",
550 "ps_m2_array": "d3d12_m2_formats_test",
548 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test", 551 "ps_m3": "d3d12_m3_frame_test", "vs_m3": "d3d12_m3_frame_test",
549 "ps_m3_post": "d3d12_m3_frame_test", 552 "ps_m3_post": "d3d12_m3_frame_test", "ps_m3_query": "d3d12_m3_frame_test",
550 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test", 553 "cs_m4_fill": "d3d12_m4_compute_test", "cs_m4_indirect": "d3d12_m4_compute_test",
551 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test"} 554 "cs_buf_typed": "d3d12_buffer_uav_test", "cs_buf_counter": "d3d12_buffer_uav_test"}
552 555
@@ -602,6 +605,7 @@ def main() -> int:
602 "subfolder that has the test programs is found by itself") 605 "subfolder that has the test programs is found by itself")
603 ap.add_argument("--work", default=None) 606 ap.add_argument("--work", default=None)
604 ap.add_argument("--filter", default="") 607 ap.add_argument("--filter", default="")
608 ap.add_argument("--require-pass", action="store_true", help="exit 1 if no GPU test passes")
605 a = ap.parse_args() 609 a = ap.parse_args()
606 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path 610 # Some test programs run with their working directory in <work>/spirv (vk_texture_test), so a relative path
607 # given here would point somewhere else for them. 611 # given here would point somewhere else for them.
@@ -809,10 +813,10 @@ def run_suite(a, work: str) -> int:
809 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the " 813 results.append((name, ok, problem or f"4096 pixels in each of {len(GET_LOD_TESTS[name])} draw(s): the "
810 "clamped and the calculated LOD within 1/16")) 814 "clamped and the calculated LOD within 1/16"))
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", 815 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",
812 "cs_buf_swizzle", "cs_cmpx_class_f32"): 816 "cs_buf_swizzle", "cs_cmpx_class_f32", "cs_cvt_pk_u8"):
813 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds 817 # num_records bounds check (cs_bounds.asm): the out-of-bounds store is dropped and the out-of-bounds
814 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement. 818 # load reads 0, so thread 0's four output words are fixed. One thread, no wave64 requirement.
815 # cs_cmpx_class_f32 is per-lane and needs no particular subgroup width either. 819 # cs_cmpx_class_f32 and cs_cvt_pk_u8 are per-lane and need no particular subgroup width either.
816 # The other four pin the SMEM and raw MUBUF rules measured on an RX 6800 (derivations in each .asm). 820 # The other four pin the SMEM and raw MUBUF rules measured on an RX 6800 (derivations in each .asm).
817 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env) 821 rc, msg = run_cmd([vk_compute, spv, "1", "dump"], env=cs_env)
818 want = { 822 want = {
@@ -826,10 +830,11 @@ def run_suite(a, work: str) -> int:
826 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0], 830 "cs_buf_tail": [0, 0x5EED000C, 0x5EED0008, 0x5EED000C, 0, 0, 0x5EED0010, 0],
827 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0], 831 "cs_oob_select": [0x5EED000C, 0, 0x5EED0014, 0, 0x5EED0018, 0xEEEEEEEE, 0, 0],
828 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010], 832 "cs_oob_tail": [0, 0, 0x5EED0010, 0, 0xBEEF0000, 0xEEEEEEEE, 0, 0x5EED0010],
829 # swizzled MUBUF addressing and ADD_TID_ENABLE (lanes 0 and 1 store; derivation in the .asm header) 833 # swizzled MUBUF addressing (measured natively on gfx1036) and ADD_TID_ENABLE (lanes 0 and 1 store)
830 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED0028, 0, 0xBEEF0000, 834 "cs_buf_swizzle": [0x5EED0024, 0x5EED0044, 0x5EED004C, 0x5EED0008, 0x5EED000C, 0, 0xBEEF0000,
831 0xBEEF0001], 835 0xBEEF0001],
832 "cs_cmpx_class_f32": CMPX_CLASS_WORDS, 836 "cs_cmpx_class_f32": CMPX_CLASS_WORDS,
837 "cs_cvt_pk_u8": CVT_PK_U8_WORDS,
833 }[name] 838 }[name]
834 words = dump_words(msg) 839 words = dump_words(msg)
835 vals = words[:len(want)] if words else [] 840 vals = words[:len(want)] if words else []
@@ -841,6 +846,9 @@ def run_suite(a, work: str) -> int:
841 elif name == "cs_fmt_sint32": 846 elif name == "cs_fmt_sint32":
842 problem = fmt_sint32_test(a.build, spirv_dir, cs_env) 847 problem = fmt_sint32_test(a.build, spirv_dir, cs_env)
843 results.append((name, not problem, problem or "64/64 dumped words exact")) 848 results.append((name, not problem, problem or "64/64 dumped words exact"))
849 elif name == "cs_fmt_int_narrow":
850 problem = fmt_int_narrow_test(a.build, spirv_dir, cs_env)
851 results.append((name, not problem, problem or "136/136 dumped words exact"))
844 elif name == "cs_fmt_xy_xyz": 852 elif name == "cs_fmt_xy_xyz":
845 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header) 853 # TEST-185: xy/xyz format loads and stores, words measured natively on a Radeon 680M (the .asm header)
846 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env) 854 problem = fmt_xy_xyz_test(a.build, spirv_dir, cs_env)
@@ -880,7 +888,7 @@ def run_suite(a, work: str) -> int:
880 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. 888 # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none.
881 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. 889 # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size.
882 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) 890 results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated()))
883 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", 891 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",
884 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", 892 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi",
885 "cs_dpp_bound", "cs_dpp_w64", 893 "cs_dpp_bound", "cs_dpp_w64",
886 "cs_w64_mask_detect", 894 "cs_w64_mask_detect",
@@ -889,7 +897,8 @@ def run_suite(a, work: str) -> int:
889 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load", 897 "cs_w64x_lds_war", "cs_w64x_partial", "cs_w64x_sbarrier", "cs_w64x_load_ballot_load",
890 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent", 898 "cs_w64x_mask_reuse", "cs_w64x_mask_reuse2", "cs_w64x_chain_barrier", "cs_barrier_divergent",
891 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", 899 "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end",
892 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst"): 900 "cs_barrier_loop", "cs_w64x_andn2_exec", "cs_w64x_saveexec_b64", "cs_lds_b64_cmpst",
901 "cs_mask_vgpr_exec"):
893 cs_dump_wants = { 902 cs_dump_wants = {
894 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], 903 "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000],
895 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone 904 # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone
@@ -928,6 +937,9 @@ def run_suite(a, work: str) -> int:
928 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7], 937 "cs_dpp_bank": [0xFFFFFFFF, 0xFFFFFFFE, 0xFFFFFFFD, 0xFFFFFFFC, 7, 7, 7, 7],
929 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777], 938 "cs_dpp_fi": [1, 2, 3, 0x7777, 5, 6, 7, 0x7777],
930 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6], 939 "cs_dpp_w64": [1, 0, 3, 2, 5, 4, 7, 6],
940 # SHADER-99: -0 and NaN survive (SignedZeroInfNanPreserve, cs_signed_zero_nan.asm); 0 in out[4..7]
941 # without it
942 "cs_signed_zero_nan": [0x80000000, 0x80000000, 0x80008000, 0x00008000, 1, 1, 1, 0x00007C00],
931 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48], 943 "cs_wave64_ballot": [32, 16, 24, 40, 8, 48],
932 "cs_wm_half_ops": [32, 16, 16, 0, 16], 944 "cs_wm_half_ops": [32, 16, 16, 0, 16],
933 "cs_wm_half_cmp": [1, 0, 1, 1], 945 "cs_wm_half_cmp": [1, 0, 1, 1],
@@ -966,10 +978,14 @@ def run_suite(a, work: str) -> int:
966 # differs per wave (cs_barrier_loop.asm) 978 # differs per wave (cs_barrier_loop.asm)
967 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120], 979 "cs_barrier_early_end": [127, 126, 125, 124, 123, 122, 121, 120],
968 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE], 980 "cs_barrier_loop": [128, 96, 64, 32, 128, 96, 64, 0xEEEEEEEE],
981 # SHADER-21 part 2: a mask copied to a VGPR with v_mov_b32 respects EXEC —
982 # inactive lanes keep the old VGPR (cs_mask_vgpr_exec.asm)
983 "cs_mask_vgpr_exec": [0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
984 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF, 0xDEADBEEF],
969 } 985 }
970 want = cs_dump_wants[name] 986 want = cs_dump_wants[name]
971 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute / 987 # Every dump but cs_store / cs_smem_soffset_imm / cs_w32_lane_wrap / cs_movrelsd_2 / cs_w32_permute /
972 # 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 988 # 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
973 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip, 989 # cs_wqm_w32 / cs_bpermute32 and the DPP tests is a whole-wave (wave64) mask test: ask for a 64-wide subgroup and skip,
974 # as check.py does, where the device has none 990 # as check.py does, where the device has none
975 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were 991 # (vk_compute_test exits 77) instead of reporting a failure. With LEONIDA_W64_EMULATE=1 they were
@@ -978,11 +994,11 @@ def run_suite(a, work: str) -> int:
978 # size 64 without them. 994 # size 64 without them.
979 emulated = w64_emulated() 995 emulated = w64_emulated()
980 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp") 996 partial = name in ("cs_w64x_partial", "cs_w64x_partial_scmp")
981 wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", 997 wave64 = name not in ("cs_store", "cs_signed_zero_nan", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2",
982 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", 998 "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop",
983 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops", 999 "cs_w32_lds_u8_d16", "cs_w32_int_ext", "cs_w32_salu64", "cs_w32_misc_ext", "cs_w32_new_ops",
984 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos", 1000 "cs_bpermute32", "cs_w32_partial_scmp", "cs_w32_sincos",
985 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", 1001 "cs_lds_b64_cmpst", "cs_exec_const", "cs_w32_mask_imm", "cs_mask_vgpr_exec",
986 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", 1002 "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8",
987 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial 1003 "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial
988 if partial and not emulated: 1004 if partial and not emulated:
@@ -994,9 +1010,13 @@ def run_suite(a, work: str) -> int:
994 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right 1010 if skip: # e.g. Mesa llvmpipe's 8-wide subgroups: these 32-lane masks can't come out right
995 ok, detail = None, str(skip) 1011 ok, detail = None, str(skip)
996 else: 1012 else:
1013 want = judged_words(name, msg, want) # cs_signed_zero_nan on Apple and llvmpipe (check.py)
997 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated, 1014 ok, detail = judge_cs_dump(rc, msg, want, wave64=wave64, partial=partial, emulated=emulated,
998 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16", 1015 hexwords=name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lds_u8_d16",
999 "cs_lds_b64_cmpst")) 1016 "cs_lds_b64_cmpst", "cs_signed_zero_nan"))
1017 if ok and None in want:
1018 unjudged = ", ".join(str(i) for i, w in enumerate(want) if w is None)
1019 detail += f" (words {unjudged} not judged on this device: UNJUDGED_WORDS in check.py)"
1000 results.append((name, ok, detail)) 1020 results.append((name, ok, detail))
1001 elif name == "cs_imgstore": 1021 elif name == "cs_imgstore":
1002 rc, msg = run_cmd([vk_store, spv]) 1022 rc, msg = run_cmd([vk_store, spv])
@@ -1024,13 +1044,7 @@ def run_suite(a, work: str) -> int:
1024 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"], 1044 mode = {"ps_cube_sample": ["cube"], "ps_sample_c_lz": ["dref"],
1025 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, []) 1045 "ps_sample_c_lz_a16": ["dref_a16"]}.get(name, [])
1026 cmd = [tool, *mode, raw] 1046 cmd = [tool, *mode, raw]
1027 try: 1047 rc, msg = run_cmd(cmd, cwd=spirv_dir)
1028 p = subprocess.run(cmd, capture_output=True, text=True, cwd=spirv_dir)
1029 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1030 except FileNotFoundError:
1031 rc, msg = 1, f"missing {tool}"
1032 except OSError as e:
1033 rc, msg = 1, start_failure(tool, e)
1034 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need 1048 if rc == UNSUPPORTED: # e.g. fewer push constant bytes than the texture tests need
1035 results.append((name, None, unsupported_skip(msg))) 1049 results.append((name, None, unsupported_skip(msg)))
1036 elif name == "ps_texture_sample_d16" and rc == 0: 1050 elif name == "ps_texture_sample_d16" and rc == 0:
@@ -1042,12 +1056,8 @@ def run_suite(a, work: str) -> int:
1042 expected = TEXTURE_CONSTANTS[name] 1056 expected = TEXTURE_CONSTANTS[name]
1043 tool = os.path.join(a.build, "vk_texture_test" + ext) 1057 tool = os.path.join(a.build, "vk_texture_test" + ext)
1044 raw = os.path.join(raw_dir, f"{name}.raw") 1058 raw = os.path.join(raw_dir, f"{name}.raw")
1045 try: 1059 rc, msg = run_cmd([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000",
1046 p = subprocess.run([tool, os.path.join(spirv_dir, "vs_ids.spv"), spv, raw, "0", "92", "c00000", 1060 "14500000", "0"], cwd=spirv_dir)
1047 "14500000", "0"], capture_output=True, text=True, cwd=spirv_dir)
1048 rc, msg = p.returncode, (p.stdout + "\n" + p.stderr).strip()
1049 except FileNotFoundError:
1050 rc, msg = 1, f"missing {tool}"
1051 bad = 4096 1061 bad = 4096
1052 if rc == 0 and os.path.isfile(raw): 1062 if rc == 0 and os.path.isfile(raw):
1053 data = Path(raw).read_bytes() 1063 data = Path(raw).read_bytes()
@@ -1094,7 +1104,9 @@ def run_suite(a, work: str) -> int:
1094 raw = os.path.join(raw_dir, f"{name}.raw") 1104 raw = os.path.join(raw_dir, f"{name}.raw")
1095 vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids 1105 vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids
1096 if name in PIXEL_VERTEX: 1106 if name in PIXEL_VERTEX:
1097 if bary_fallback() and name == "ps_interp_f16_high": # no PerVertexKHR inputs under --bary-fallback 1107 # --bary-fallback alone has no PerVertexKHR inputs, so the f16 halves can't be interpolated; with
1108 # --f16-interp-fallback too (on by itself without fragmentShaderBarycentric) it reads decoded halves.
1109 if name == "ps_interp_f16_high" and bary_fallback() and not f16_interp_fallback():
1098 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1110 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1099 continue 1111 continue
1100 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv") 1112 vs = os.path.join(spirv_dir, PIXEL_VERTEX[name] + ".spv")
@@ -1132,6 +1144,7 @@ def run_suite(a, work: str) -> int:
1132 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16), 1144 "ps_scc_logic64": (0x0fff0fff, 0xff000000, 0xff0000ff, 0x16),
1133 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000), 1145 "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000),
1134 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64 1146 "ps_f64_mods": (0x40040000, 0x3FF00000, 0x3FE40000, 0x3FF00000), # needs shaderFloat64
1147 "ps_outmods_f16": (0xAAAA3C00, 0xAAAA3E00, 0x7C000000, 0x3C000000),
1135 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers) 1148 # f16 op_sel / partial writes / inline constants: RDNA2 hardware words (see the .asm headers)
1136 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555), 1149 "ps_f16_med3_opsel": (0xAAAA4100, 0xAAAA4200, 0xAAAA3E00, 0x40005555),
1137 "ps_f16_med3_mods": (0x41005555, 0x3C005555, 0x41003800, 0xAAAABA00), 1150 "ps_f16_med3_mods": (0x41005555, 0x3C005555, 0x41003800, 0xAAAABA00),
@@ -1143,6 +1156,7 @@ def run_suite(a, work: str) -> int:
1143 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3), 1156 "ps_f16_const2": (0x42003D00, 0x3D004200, 0xAAAABC00, 3),
1144 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200), 1157 "ps_f16_pack": (0x34003C00, 0x38003400, 0x34000000, 0x44004200),
1145 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400), 1158 "ps_f16_pack_mods": (0x4400B400, 0xC4003400, 0x4400C200, 0xB400B400),
1159 "ps_sdwa_f16_const": (0xAAAA3800, 0xAAAA1C00, 0xAAAA3E00, 0xAAAA73F0), # measured on gfx1036
1146 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate 1160 "ps_sff_imm": (2, 1, 20, 16), # SHADER-46: s_ff0/s_ff1 of an immediate
1147 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware 1161 "ps_fnan_med3": (0x40A00000, 0xC0200000, 0xC0200000, 0x40600000), # measured on RDNA2 hardware
1148 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000), 1162 "ps_fnan_fract": (0x3F7FFFFF, 0x00003BFF, 0xC0200000, 0xC0200000),
@@ -1236,7 +1250,7 @@ def run_suite(a, work: str) -> int:
1236 raw = os.path.join(raw_dir, f"{name}.raw") 1250 raw = os.path.join(raw_dir, f"{name}.raw")
1237 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS 1251 env = mesh_env(spirv_dir, name, gfx_env) # VKH_MESH=1, or the --mesh-compute pass and its VS
1238 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv") 1252 fs = os.path.join(spirv_dir, "ps_interp_f16_high.spv")
1239 if bary_fallback(): 1253 if bary_fallback() and not f16_interp_fallback():
1240 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)")) 1254 results.append((name, None, "SKIP (per-vertex f16 interpolants need barycentrics)"))
1241 continue 1255 continue
1242 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env) 1256 rc, msg = run_cmd([vk_harness, spv, fs, raw], env=env)
@@ -1279,7 +1293,12 @@ def run_suite(a, work: str) -> int:
1279 skipped += ok is None 1293 skipped += ok is None
1280 print(f" {tag:4s} {name:<20s} {detail}") 1294 print(f" {tag:4s} {name:<20s} {detail}")
1281 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else "")) 1295 print(f"\n{passed}/{len(results)} passed" + (f", {skipped} skipped" if skipped else ""))
1282 return 0 if passed + skipped == len(results) else 1 1296 if passed + skipped != len(results):
1297 return 1
1298 if getattr(a, "require_pass", False) and not passed:
1299 print("error: --require-pass: no GPU tests passed", file=sys.stderr)
1300 return 1
1301 return 0
1283 1302
1284 1303
1285if __name__ == "__main__": 1304if __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)