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:
authorAslan2142 <jan.trencansky@protonmail.com>2026-12-01 12:45:24 +0100
committerGitHub <noreply@github.com>2026-12-01 12:45:24 +0100
commita726736ec20a5a1ae8242a9efee75bcd2e1c5844 (patch)
tree5e8ffbb6eb42a39afec5049469a2a9a7741542e1 /scripts
parent13573d92528fa46dcaa61ab978caf2ac675738d2 (diff)
parentd99ba5c095c0a66f27bd0b9418756f6ef1cfaed3 (diff)
Merge pull request #1774 from Tauwni/fix/explicit-lod-bias-moltenvk
rdna2spirv: --explicit-lod-bias applies the S# LOD bias where MoltenVK drops the sampler's; ps_ssharp passes on Macs (SHADER-EXPLICIT-LOD-BIAS-MVK)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/run_gpu_tests.py38
1 files changed, 34 insertions, 4 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index 7f299b0be..1d0e7952d 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -28,7 +28,7 @@ from build import CLIP_CASES, clip_container, shader_source
28from check import (Skip, clip_test, fmt_1010102_test, fmt_d16_xyz_test, fmt_int_narrow_test, 28from check import (Skip, clip_test, fmt_1010102_test, fmt_d16_xyz_test, fmt_int_narrow_test,
29 fmt_sint32_test, fmt_xy_xyz_test, tbuffer_store_test, compute_unsupported) 29 fmt_sint32_test, fmt_xy_xyz_test, tbuffer_store_test, compute_unsupported)
30from compute_fixture import compute_header 30from compute_fixture import compute_header
31from check import SAMPLER_CASES, sampler_test # ps_ssharp: the S#/T# mip fields (vk_sampler_test) 31from check import SAMPLER_CASES, SAMPLER_FIXTURES, sampler_test # ps_ssharp*: the S#/T# mip fields (vk_sampler_test)
32from check import (CS_SMEM_VCC, CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, PK_MUL_LO_WORDS, PK_MUL_LO_ENV, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES, 32from check import (CS_SMEM_VCC, CMPX_CLASS_WORDS, CVT_F32_SAT_CASES, CVT_PK_U8_WORDS, PK_MUL_LO_WORDS, PK_MUL_LO_ENV, GRADIENT_TESTS, TEST_PROGRAMS, TEXTURE_MIP_DEPENDENCIES,
33 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 TEXTURE_MIP_TEST, GATHER_LOD_TEST, MIP_TEST_PASSES, TEXTURE_CONSTANTS, USER_SGPRS_ENV, USER_SGPRS_WORDS, Skip, mesh_v5_test, not_found_message,
34 pick_build_dir, start_failure, table_fetch_test, texture_gradient_a16_test, texture_mip_test) 34 pick_build_dir, start_failure, table_fetch_test, texture_gradient_a16_test, texture_mip_test)
@@ -378,6 +378,7 @@ def no_ftz32() -> bool:
378 378
379_PER_VERTEX = [] 379_PER_VERTEX = []
380_BARYCENTRIC_FALLBACK = [] 380_BARYCENTRIC_FALLBACK = []
381_EXPLICIT_LOD_BIAS = []
381_DENORM_FTZ_F32 = [] 382_DENORM_FTZ_F32 = []
382 383
383 384
@@ -414,6 +415,33 @@ def _device_barycentric_fallback():
414 return _BARYCENTRIC_FALLBACK[0] 415 return _BARYCENTRIC_FALLBACK[0]
415 416
416 417
418def _device_explicit_lod_bias(build: str | None):
419 """tools/lod_bias_probe.py's answer for the device the tests run on (cached per suite), or None: vk_subgroup_info.py
420 --lod-bias's compute measurement, else (with the test programs) ps_ssharp drawn without the flag."""
421 if not _EXPLICIT_LOD_BIAS:
422 answer = None
423 try:
424 r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "tools", "lod_bias_probe.py"),
425 *(["--build", build] if build else [])], capture_output=True, text=True, timeout=300)
426 answer = json.loads(r.stdout.strip().splitlines()[-1]).get("explicit_lod_bias")
427 except (OSError, ValueError, IndexError, subprocess.SubprocessError):
428 pass
429 _EXPLICIT_LOD_BIAS.append(answer)
430 return _EXPLICIT_LOD_BIAS[0]
431
432
433def explicit_lod_bias(build: str | None) -> bool:
434 """LEONIDA_EXPLICIT_LOD_BIAS=1 (or 0): translate with --explicit-lod-bias, so samples take the S# LOD_BIAS in the
435 shader. Unset, it is on where tools/lod_bias_probe.py measures that the sampler drops mipLodBias (MoltenVK on an
436 Apple M3, not on an M5 Pro: a driver ID can't tell); a probe without an answer leaves it off."""
437 v = (os.environ.get("LEONIDA_EXPLICIT_LOD_BIAS") or "").strip().lower()
438 if v in ("1", "true", "yes", "on"):
439 return True
440 if v in ("0", "false", "no", "off"):
441 return False
442 return _device_explicit_lod_bias(build) is True
443
444
417def _device_denorm_ftz_f32(): 445def _device_denorm_ftz_f32():
418 """denorm_flush_to_zero_f32 from tools/vk_subgroup_info.py for the device the tests run on (cached), or None.""" 446 """denorm_flush_to_zero_f32 from tools/vk_subgroup_info.py for the device the tests run on (cached), or None."""
419 if not _DENORM_FTZ_F32: 447 if not _DENORM_FTZ_F32:
@@ -887,7 +915,7 @@ OTHER_HARNESS = {"ps_m15": "d3d12_translated_draw_test", "ps_m15_dual": "d3d12_t
887DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_persp_bary": "vs_persp.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm", 915DRAWN_WITH = {GATHER_LOD_TEST: "vs_ids.asm", "ps_flat": "vs_ids.asm", "ps_persp_bary": "vs_persp.asm", "ps_texture_sample": "vs_ids.asm", "ps_cube_sample": "vs_ids.asm",
888 "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm", 916 "ps_texture_sample_d16": "vs_ids.asm", "ps_sample_c_lz": "vs_ids.asm", "ps_sample_c_lz_a16": "vs_ids.asm",
889 "ps_table_fetch": "vs_ids.asm", "ps_sample_c": "vs_ids.asm", "ps_sample_c_b": "vs_ids.asm", 917 "ps_table_fetch": "vs_ids.asm", "ps_sample_c": "vs_ids.asm", "ps_sample_c_b": "vs_ids.asm",
890 **{name: "vs_ids.asm" for name in TEXTURE_CONSTANTS}, "ps_ssharp": "vs_ids.asm", "ps_imgatomic": "vs_ids.asm", 918 **{name: "vs_ids.asm" for name in TEXTURE_CONSTANTS}, **{name: "vs_ids.asm" for name in SAMPLER_FIXTURES}, "ps_imgatomic": "vs_ids.asm",
891 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm", 919 **{name: "vs_ids.asm" for name in GRADIENT_TESTS}, "vs_clip": "ps_clip_color.asm",
892 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm", 920 "ps_interp_f16_high": "vs_f16_pack.asm", "ms_f16_pack": "ps_interp_f16_high.asm",
893 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm", 921 "ps_interp_f32_mods": "vs_interp_consts.asm", "ps_interp_mov_mods": "vs_interp_consts.asm",
@@ -1154,6 +1182,8 @@ def run_suite(a, work: str) -> int:
1154 cmd.append("--no-ftz32") 1182 cmd.append("--no-ftz32")
1155 if TEXOFF_FALLBACK: # image_sample*_o: offset folded into the coordinate, no VK_KHR_maintenance8 1183 if TEXOFF_FALLBACK: # image_sample*_o: offset folded into the coordinate, no VK_KHR_maintenance8
1156 cmd.append("--texel-offset-fallback") 1184 cmd.append("--texel-offset-fallback")
1185 if explicit_lod_bias(getattr(a, "build", None)): # the S# LOD bias in the shader, where the sampler drops it (measured)
1186 cmd.append("--explicit-lod-bias")
1157 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py 1187 if MESH_COMPUTE: # mesh shaders as compute writing to a buffer, drawn by tools/mesh_compute_vs.py
1158 cmd.append("--mesh-compute") 1188 cmd.append("--mesh-compute")
1159 if os.environ.get("LEONIDA_MESH_SERIAL_WAVES") == "1": # with --wave64-emulate: one pass per wave 1189 if os.environ.get("LEONIDA_MESH_SERIAL_WAVES") == "1": # with --wave64-emulate: one pass per wave
@@ -1536,9 +1566,9 @@ def run_suite(a, work: str) -> int:
1536 results.append((name, None, f"SKIP ({reason})")) 1566 results.append((name, None, f"SKIP ({reason})"))
1537 else: 1567 else:
1538 results.append((name, rc == 0, verdict_line(rc, msg))) 1568 results.append((name, rc == 0, verdict_line(rc, msg)))
1539 elif name == "ps_ssharp": 1569 elif name in SAMPLER_FIXTURES:
1540 # The S#/T# mip fields through vulkan_sampler() and the view range (check.py's SAMPLER_CASES). 1570 # The S#/T# mip fields through vulkan_sampler() and the view range (check.py's SAMPLER_CASES).
1541 problem = sampler_test(a.build, spirv_dir) 1571 problem = sampler_test(a.build, spirv_dir, name)
1542 results.append((name, None if isinstance(problem, Skip) else not problem, 1572 results.append((name, None if isinstance(problem, Skip) else not problem,
1543 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact")) 1573 problem or f"{len(SAMPLER_CASES)} S#/T# cases, 4096 pixels each exact"))
1544 elif name in ("ps_texoff", "ps_texoff_implicit", "ps_texoff_forms"): 1574 elif name in ("ps_texoff", "ps_texoff_implicit", "ps_texoff_forms"):