diff options
| author | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 12:42:42 +0100 |
|---|---|---|
| committer | AlxcBTW <187763517+AlxcBTW@users.noreply.github.com> | 2026-11-22 12:42:47 +0100 |
| commit | 810acc75fe0bc673fbca2cb99974c1f97dba9b10 (patch) | |
| tree | b05a7a795c5da67525248237fc8fc2e763fa0036 /scripts/run_gpu_tests.py | |
| parent | 40f239be13a09f3c0bb9e4e34ca53ef6b2ae098a (diff) | |
| parent | bb2e18421dac527374eb837c88b5063c5d96f81f (diff) | |
Merge origin/main into m2-textured-draw
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'scripts/run_gpu_tests.py')
| -rw-r--r-- | scripts/run_gpu_tests.py | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index bb42382aa..37f9b3431 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py | |||
| @@ -214,14 +214,14 @@ def make_fs_passthru(loc: int) -> str: | |||
| 214 | def read_raw_rgba32f(path: str) -> list[tuple[float, float, float, float]]: | 214 | def read_raw_rgba32f(path: str) -> list[tuple[float, float, float, float]]: |
| 215 | with open(path, "rb") as source: | 215 | with open(path, "rb") as source: |
| 216 | data = source.read() | 216 | data = source.read() |
| 217 | n = len(data) // 16 | 217 | n = len(data) // 16 if len(data) % 16 == 0 else 0 # a partial pixel means a malformed readback: no frame |
| 218 | return [struct.unpack_from("<4f", data, 16 * i) for i in range(n)] | 218 | return [struct.unpack_from("<4f", data, 16 * i) for i in range(n)] |
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | def read_raw_u32(path: str) -> list[tuple[int, int, int, int]]: | 221 | def read_raw_u32(path: str) -> list[tuple[int, int, int, int]]: |
| 222 | with open(path, "rb") as source: | 222 | with open(path, "rb") as source: |
| 223 | data = source.read() | 223 | data = source.read() |
| 224 | n = len(data) // 16 | 224 | n = len(data) // 16 if len(data) % 16 == 0 else 0 # a partial pixel means a malformed readback: no frame |
| 225 | return [struct.unpack_from("<4I", data, 16 * i) for i in range(n)] | 225 | return [struct.unpack_from("<4I", data, 16 * i) for i in range(n)] |
| 226 | 226 | ||
| 227 | 227 | ||
| @@ -331,6 +331,8 @@ def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]: | |||
| 331 | px = read_raw_u32(raw_path) | 331 | px = read_raw_u32(raw_path) |
| 332 | if skip := bitmask_perm_narrow_skip(msg, px): | 332 | if skip := bitmask_perm_narrow_skip(msg, px): |
| 333 | return None, str(skip) | 333 | return None, str(skip) |
| 334 | if problem := frame_problem(px): | ||
| 335 | return False, problem | ||
| 334 | bad = 0 | 336 | bad = 0 |
| 335 | first = "" | 337 | first = "" |
| 336 | judged = 0 | 338 | judged = 0 |
| @@ -350,6 +352,13 @@ def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]: | |||
| 350 | # Pixel shaders that read memory: vk_harness puts this V# in s[0:3] and seeds the heap it points at, as | 352 | # Pixel shaders that read memory: vk_harness puts this V# in s[0:3] and seeds the heap it points at, as |
| 351 | # tests/semantic/test_value_semantics.py does for the interpreter (same table as check.py). | 353 | # tests/semantic/test_value_semantics.py does for the interpreter (same table as check.py). |
| 352 | PIXEL_ENV = {"ps_vcc_x2": {"VKH_SGPRS": "0x1000,0,16,0", "VKH_HEAP": "0x1000=0x11223344,0x1004=0x55667788"}, | 354 | PIXEL_ENV = {"ps_vcc_x2": {"VKH_SGPRS": "0x1000,0,16,0", "VKH_HEAP": "0x1000=0x11223344,0x1004=0x55667788"}, |
| 355 | # the 14 v_cmpx forms: f32 and 64-bit operands from memory (derivations in the .asm header) | ||
| 356 | "ps_vcmpx_forms": {"VKH_SGPRS": "0x1000,0,96,0", | ||
| 357 | "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x3f800000,0x1008=0x40000000,0x100c=0x80000000," | ||
| 358 | "0x1010=0,0x1014=0xff800000,0x1018=0,0x101c=0,0x1020=0x80000000,0x1024=0," | ||
| 359 | "0x1028=0x1,0x102c=0,0x1030=0x7,0x1034=0x80000000,0x1038=0x7,0x103c=0," | ||
| 360 | "0x1040=0x1,0x1044=0x5,0x1048=0x80000000,0x104c=0x5,0x1050=0x7,0x1054=0x5," | ||
| 361 | "0x1058=0x7,0x105c=0x5"}, | ||
| 353 | # float NaN / fract rows measured on RDNA2 hardware (see the .asm headers) | 362 | # float NaN / fract rows measured on RDNA2 hardware (see the .asm headers) |
| 354 | "ps_fnan_med3": {"VKH_SGPRS": "0x1000,0,32,0", | 363 | "ps_fnan_med3": {"VKH_SGPRS": "0x1000,0,32,0", |
| 355 | "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000," | 364 | "VKH_HEAP": "0x1000=0x7fc10001,0x1004=0x40e00000,0x1008=0x40a00000," |
| @@ -362,7 +371,11 @@ def check_flat(raw_path: str) -> tuple[bool, str]: | |||
| 362 | """ps_flat with vs_ids: the integer IDs come from the first (provoking) vertex, the UVs still interpolate.""" | 371 | """ps_flat with vs_ids: the integer IDs come from the first (provoking) vertex, the UVs still interpolate.""" |
| 363 | with open(raw_path, "rb") as source: | 372 | with open(raw_path, "rb") as source: |
| 364 | data = source.read() | 373 | data = source.read() |
| 374 | if len(data) != 64 * 64 * 16: | ||
| 375 | return False, f"expected a 64x64 frame, got {len(data)} bytes" | ||
| 365 | px = list(struct.iter_unpack("<2I2f", data)) | 376 | px = list(struct.iter_unpack("<2I2f", data)) |
| 377 | if problem := frame_problem(px): | ||
| 378 | return False, problem | ||
| 366 | w = int(len(px) ** 0.5) | 379 | w = int(len(px) ** 0.5) |
| 367 | wrong = sum((a, b) != (0x101, 0x102) for a, b, _, _ in px) | 380 | wrong = sum((a, b) != (0x101, 0x102) for a, b, _, _ in px) |
| 368 | err = max(max(abs(u - (i % w + 0.5) / w), abs(v - (i // w + 0.5) / w)) for i, (_, _, u, v) in enumerate(px)) | 381 | err = max(max(abs(u - (i % w + 0.5) / w), abs(v - (i // w + 0.5) / w)) for i, (_, _, u, v) in enumerate(px)) |
| @@ -389,6 +402,9 @@ def check_uniform_branch(raw_path: str) -> tuple[bool, str]: | |||
| 389 | """ps_uniform_branch / ps_scc_mask32: s5 = 8 wherever the lane's own bit is set; a lane with bit 0 gets 8 when | 402 | """ps_uniform_branch / ps_scc_mask32: s5 = 8 wherever the lane's own bit is set; a lane with bit 0 gets 8 when |
| 390 | another lane of its wave has the bit (the wave-wide vote), else 7. All three kinds must occur, as in check.py: | 403 | another lane of its wave has the bit (the wave-wide vote), else 7. All three kinds must occur, as in check.py: |
| 391 | without a (8, bit 0) pixel the vote is not shown, and a translator that decides per lane would pass.""" | 404 | without a (8, bit 0) pixel the vote is not shown, and a translator that decides per lane would pass.""" |
| 405 | # Only z (the barycentric i) is judged as a float; a NaN i passes both range tests below. | ||
| 406 | if problem := frame_problem([p[2:3] for p in px]): | ||
| 407 | return False, problem | ||
| 392 | bad = 0 | 408 | bad = 0 |
| 393 | n8 = 0 | 409 | n8 = 0 |
| 394 | n7 = 0 | 410 | n7 = 0 |
| @@ -460,8 +476,8 @@ def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool, | |||
| 460 | """Check 64x64 output with ClipDistance[0] = NDC x: left half (x < 32) clipped to clear (-1), | 476 | """Check 64x64 output with ClipDistance[0] = NDC x: left half (x < 32) clipped to clear (-1), |
| 461 | right half (x >= 32) covered (2048/4096 pixels) with the gradient.""" | 477 | right half (x >= 32) covered (2048/4096 pixels) with the gradient.""" |
| 462 | px = read_raw_rgba32f(raw_path) | 478 | px = read_raw_rgba32f(raw_path) |
| 463 | if len(px) != 64 * 64: | 479 | if problem := frame_problem(px): |
| 464 | return False, f"expected 4096 pixels, got {len(px)}" | 480 | return False, problem |
| 465 | covered = 0 | 481 | covered = 0 |
| 466 | bad = 0 | 482 | bad = 0 |
| 467 | first = "" | 483 | first = "" |
| @@ -497,7 +513,7 @@ OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "vs_m15": "d3d12_transl | |||
| 497 | DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm", | 513 | DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm", |
| 498 | "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm", | 514 | "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm", |
| 499 | "ps_gather_wrap": "vs_ids.asm", | 515 | "ps_gather_wrap": "vs_ids.asm", |
| 500 | **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_ops.asm", | 516 | **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm", |
| 501 | "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", | 517 | "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", |
| 502 | "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm"} | 518 | "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm"} |
| 503 | 519 | ||
| @@ -645,6 +661,8 @@ def run_suite(a, work: str) -> int: | |||
| 645 | cmd.append("--texel-offset-fallback") | 661 | cmd.append("--texel-offset-fallback") |
| 646 | if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py | 662 | if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py |
| 647 | cmd.append("--mesh-compute") | 663 | cmd.append("--mesh-compute") |
| 664 | if os.environ.get("LEONIDA_FMA") in ("glsl", "khr"): # fused multiply-add: GLSL Fma or OpFmaKHR (docs/design.md) | ||
| 665 | cmd += ["--fma", os.environ["LEONIDA_FMA"]] | ||
| 648 | rc, out = run_cmd(cmd, gpu=False) | 666 | rc, out = run_cmd(cmd, gpu=False) |
| 649 | print("=== rdna2spirv.py ===") | 667 | print("=== rdna2spirv.py ===") |
| 650 | print(out) | 668 | print(out) |
| @@ -768,7 +786,7 @@ def run_suite(a, work: str) -> int: | |||
| 768 | # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. | 786 | # Whole-wave mask test, as in check.py: needs a 64-wide subgroup, skipped where the device has none. |
| 769 | # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. | 787 | # With LEONIDA_W64_EMULATE=1 it was translated with --wave64-emulate and runs on any subgroup size. |
| 770 | results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) | 788 | results.append((name,) + wavemask_check(vk_compute, spv, cs_env, w64_emulated())) |
| 771 | elif name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_exec_const", "cs_w32_lds_u8_d16", "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", | 789 | elif name in ("cs_store", "cs_smem_soffset_imm", "cs_w32_lane_wrap", "cs_movrelsd_2", "cs_w32_permute", "cs_exec_const", "cs_w32_mask_imm", "cs_w64_mask_imm", "cs_w32_lds_u8_d16", "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", |
| 772 | "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", | 790 | "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", "cs_dpp_ops", "cs_dpp_bank", "cs_dpp_fi", |
| 773 | "cs_dpp_bound", "cs_dpp_w64", | 791 | "cs_dpp_bound", "cs_dpp_w64", |
| 774 | "cs_w64_mask_detect", | 792 | "cs_w64_mask_detect", |
| @@ -779,7 +797,7 @@ def run_suite(a, work: str) -> int: | |||
| 779 | "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", | 797 | "cs_bpermute32", "cs_w64x_partial_scmp", "cs_w32_partial_scmp", "cs_barrier_early_end", |
| 780 | "cs_barrier_loop", "cs_w64x_andn2_exec"): | 798 | "cs_barrier_loop", "cs_w64x_andn2_exec"): |
| 781 | cs_dump_wants = { | 799 | cs_dump_wants = { |
| 782 | "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800], | 800 | "cs_store": [0x400080FF, 0xE00003FF, 0x3C004000, 0xEEEEEEEE, 0x40003C00, 0xBC003800, 0x40FF8000, 0x3FF00000], |
| 783 | # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone | 801 | # base + soffset + imm (cs_smem_soffset_imm.asm); out[4..7] are seeds the shader leaves alone |
| 784 | "cs_smem_soffset_imm": [0x5EED0024, 0x5EED0028, 0x5EED002C, 0x5EED0030, | 802 | "cs_smem_soffset_imm": [0x5EED0024, 0x5EED0028, 0x5EED002C, 0x5EED0030, |
| 785 | 0x5EED0010, 0x5EED0014, 0x5EED0018, 0x5EED001C], | 803 | 0x5EED0010, 0x5EED0014, 0x5EED0018, 0x5EED001C], |
| @@ -793,6 +811,9 @@ def run_suite(a, work: str) -> int: | |||
| 793 | "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234], | 811 | "cs_w32_lds_u8_d16": [0xBEEF00FF, 0x00FF1234, 0xBEEFFF80, 0xFF801234, 0xBEEF007F, 0x007F1234, 0xBEEF0080, 0xFFFF1234], |
| 794 | # constant EXEC masks (cs_exec_const.asm): each lane takes its own bit of the constant | 812 | # constant EXEC masks (cs_exec_const.asm): each lane takes its own bit of the constant |
| 795 | "cs_exec_const": [16, 8, 2, 16, 0, 16], | 813 | "cs_exec_const": [16, 8, 2, 16, 0, 16], |
| 814 | # constant lane masks: lane L takes bit L (cs_w32_mask_imm.asm / cs_w64_mask_imm.asm headers) | ||
| 815 | "cs_w32_mask_imm": [2056, 20, 2, 6152, 2050, 4112, 258, 32], | ||
| 816 | "cs_w64_mask_imm": [2056, 1084, 828, 2052, 319, 2104, 516, 2064], | ||
| 796 | "cs_dpp": [1, 0, 3, 2, 5, 4, 7, 6], | 817 | "cs_dpp": [1, 0, 3, 2, 5, 4, 7, 6], |
| 797 | "cs_dpp_row": [0, 0, 1, 2, 3, 4, 5, 6], | 818 | "cs_dpp_row": [0, 0, 1, 2, 3, 4, 5, 6], |
| 798 | "cs_dpp_mask": [1, 0, 3, 2, 0xEEEEEEEE, 0xEEEEEEEE, 0xEEEEEEEE, 0xEEEEEEEE], | 819 | "cs_dpp_mask": [1, 0, 3, 2, 0xEEEEEEEE, 0xEEEEEEEE, 0xEEEEEEEE, 0xEEEEEEEE], |
| @@ -852,7 +873,7 @@ def run_suite(a, work: str) -> int: | |||
| 852 | wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", | 873 | wave64 = name not in ("cs_store", "cs_smem_soffset_imm", "cs_wqm_w32", "cs_w32_lane_wrap", "cs_movrelsd_2", |
| 853 | "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", | 874 | "cs_w32_permute", "cs_barrier_divergent", "cs_barrier_early_end", "cs_barrier_loop", |
| 854 | "cs_w32_lds_u8_d16", "cs_bpermute32", "cs_w32_partial_scmp", | 875 | "cs_w32_lds_u8_d16", "cs_bpermute32", "cs_w32_partial_scmp", |
| 855 | "cs_exec_const", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", | 876 | "cs_exec_const", "cs_w32_mask_imm", "cs_dpp", "cs_dpp_row", "cs_dpp_mask", "cs_dpp8", |
| 856 | "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial | 877 | "cs_dpp_ops", "cs_dpp_bound", "cs_dpp_bank", "cs_dpp_fi") and not emulated and not partial |
| 857 | if partial and not emulated: | 878 | if partial and not emulated: |
| 858 | cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") | 879 | cs_env = dict(os.environ, VKC_SUBGROUP_SIZE="64") |
| @@ -870,7 +891,7 @@ def run_suite(a, work: str) -> int: | |||
| 870 | rc, msg = run_cmd([vk_store, spv]) | 891 | rc, msg = run_cmd([vk_store, spv]) |
| 871 | results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) | 892 | results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) |
| 872 | elif name in ("cs_imgload", "cs_imgload_d16"): | 893 | elif name in ("cs_imgload", "cs_imgload_d16"): |
| 873 | rc, msg = run_cmd([vk_store, spv, "load"]) | 894 | rc, msg = run_cmd([vk_store, spv, "load-d16" if name == "cs_imgload_d16" else "load"]) |
| 874 | results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) | 895 | results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) |
| 875 | elif name in MIP_TEST_PASSES: | 896 | elif name in MIP_TEST_PASSES: |
| 876 | problem = texture_mip_test(a.build, spirv_dir, name) | 897 | problem = texture_mip_test(a.build, spirv_dir, name) |
| @@ -971,6 +992,7 @@ def run_suite(a, work: str) -> int: | |||
| 971 | results.append((name, False, msg)) | 992 | results.append((name, False, msg)) |
| 972 | continue | 993 | continue |
| 973 | const_wants = { | 994 | const_wants = { |
| 995 | "ps_clip_color": (0x3E800000, 0x3F000000, 0x3F400000, 0x3F800000), | ||
| 974 | "ps_ops": (0x48804300, 5, 7, 0xFFFFFFFC), | 996 | "ps_ops": (0x48804300, 5, 7, 0xFFFFFFFC), |
| 975 | "ps_ops2": (0xABCD4400, 0x46001234, 0xFFFFFFFA, 7), | 997 | "ps_ops2": (0xABCD4400, 0x46001234, 0xFFFFFFFA, 7), |
| 976 | "ps_ops3": (0xFFFFFFFA, 0x44660066, 0x44AABBCC, 16), | 998 | "ps_ops3": (0xFFFFFFFA, 0x44660066, 0x44AABBCC, 16), |
| @@ -984,6 +1006,7 @@ def run_suite(a, work: str) -> int: | |||
| 984 | "ps_ops8": (0x80000000, 0xFFFFFFFF, 0x000F100E, 0x0F0F0F1F), | 1006 | "ps_ops8": (0x80000000, 0xFFFFFFFF, 0x000F100E, 0x0F0F0F1F), |
| 985 | "ps_f32_mods": (0xC0256A01, 0x3F800000, 0x41E00000, 0x3FC00000), | 1007 | "ps_f32_mods": (0xC0256A01, 0x3F800000, 0x41E00000, 0x3FC00000), |
| 986 | "ps_vcc_x2": (0x11223344, 0x55667788, 0, 0), | 1008 | "ps_vcc_x2": (0x11223344, 0x55667788, 0, 0), |
| 1009 | "ps_vcmpx_forms": (0xF05B2A48, 0xF05E8A12, 0xB174BE18, 0x15550000), # 14 v_cmpx forms (.asm header) | ||
| 987 | "ps_med3_mods": (0x3F800000, 0x40400000, 0x40C00000, 0x3F400000), | 1010 | "ps_med3_mods": (0x3F800000, 0x40400000, 0x40C00000, 0x3F400000), |
| 988 | "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203), | 1011 | "ps_scc_minmax": (0x00030205, 0x00030207, 0x00030209, 0x00030203), |
| 989 | "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000), | 1012 | "ps_fma_literal": (0x41B80000, 0x41800000, 0x40E00000, 0x41A40000), |