upleb.uk

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

summaryrefslogtreecommitdiff
path: root/scripts/run_gpu_tests.py
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-21 16:08:57 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-21 16:08:57 -0500
commitf238f66a97d6ba4e208c41fd2bc7fcdf21f36543 (patch)
treed01c7c05e339e3c59221811db71892d1ae426e4c /scripts/run_gpu_tests.py
parentf3da088e5611be96dd0c356d63dd8b07e37a31df (diff)
parentce2cf7578549159ed6bb649c1bcb4f24142a1395 (diff)
Merge pull request #186 from imnotdiesel
# Conflicts: # runtime/test/shaders/build.py # scripts/run_gpu_tests.py
Diffstat (limited to 'scripts/run_gpu_tests.py')
-rw-r--r--scripts/run_gpu_tests.py30
1 files changed, 7 insertions, 23 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py
index a811dea15..cef73011b 100644
--- a/scripts/run_gpu_tests.py
+++ b/scripts/run_gpu_tests.py
@@ -20,6 +20,8 @@ SHADER_DIR = os.path.join(ROOT, "runtime", "test", "shaders")
20TRANSLATOR = os.path.join(ROOT, "tools", "rdna2spirv.py") 20TRANSLATOR = os.path.join(ROOT, "tools", "rdna2spirv.py")
21sys.path.insert(0, os.path.join(ROOT, "tools")) 21sys.path.insert(0, os.path.join(ROOT, "tools"))
22import mc_command # noqa: E402 22import mc_command # noqa: E402
23sys.path.insert(0, SHADER_DIR)
24from compute_fixture import compute_header
23 25
24 26
25def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes: 27def make_dxbc(chunks: list[tuple[bytes, bytes]]) -> bytes:
@@ -60,27 +62,6 @@ def make_ms_psv0(threads_x: int, maxv: int, maxp: int, topology: int = 2) -> byt
60 return struct.pack("<I", len(r)) + bytes(r) 62 return struct.pack("<I", len(r)) + bytes(r)
61 63
62 64
63def make_cs_fssm(rsrc2: int = 0x8088, lx: int = 64, ly: int = 1, lz: int = 1) -> bytes:
64 """Build minimal FSSM header (0x148 bytes) with COMPUTE_PGM_RSRC2 and group size."""
65 buf = bytearray(0x148)
66 struct.pack_into("<4I", buf, 0x138, rsrc2, lx, ly, lz)
67 return bytes(buf)
68
69
70def asm_group(asm_path: str) -> tuple[int, int, int]:
71 """Thread-group size from a leading "; group: X,Y,Z" comment in the .asm (default 64,1,1)."""
72 for ln in open(asm_path, encoding="utf-8").read().splitlines():
73 t = ln.strip()
74 if not t:
75 continue
76 if not t.startswith(";"):
77 break
78 m = re.match(r";\s*group:\s*(\d+),(\d+),(\d+)", t)
79 if m:
80 return int(m.group(1)), int(m.group(2)), int(m.group(3))
81 return 64, 1, 1
82
83
84def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None: 65def assemble_to_s(llvm_mc: str, asm_path: str, s_path: str, name: str) -> None:
85 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py.""" 66 """Assemble raw RDNA2 .asm with llvm-mc -show-encoding into .s format for rdna2spirv.py."""
86 raw = open(asm_path, encoding="utf-8").read() 67 raw = open(asm_path, encoding="utf-8").read()
@@ -419,7 +400,7 @@ def run_suite(a, work: str) -> int:
419 f.write(dxbc) 400 f.write(dxbc)
420 if name.startswith("cs_"): 401 if name.startswith("cs_"):
421 with open(os.path.join(fssm_dir, f"{name}.fssm"), "wb") as f: 402 with open(os.path.join(fssm_dir, f"{name}.fssm"), "wb") as f:
422 f.write(make_cs_fssm(0x8088, *asm_group(os.path.join(SHADER_DIR, fname)))) 403 f.write(compute_header(os.path.join(SHADER_DIR, fname)))
423 assemble_to_s(a.llvm_mc, os.path.join(SHADER_DIR, fname), os.path.join(disasm_dir, f"{name}.s"), name) 404 assemble_to_s(a.llvm_mc, os.path.join(SHADER_DIR, fname), os.path.join(disasm_dir, f"{name}.s"), name)
424 405
425 # 2. Translate all .s -> .spv 406 # 2. Translate all .s -> .spv
@@ -464,7 +445,10 @@ def run_suite(a, work: str) -> int:
464 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE=str(sg)) if sg else None 445 cs_env = dict(os.environ, VKC_SUBGROUP_SIZE=str(sg)) if sg else None
465 gfx_env = dict(os.environ, VKH_SUBGROUP_SIZE=str(sg)) if sg else None 446 gfx_env = dict(os.environ, VKH_SUBGROUP_SIZE=str(sg)) if sg else None
466 447
467 if name == "cs_lds": 448 if name == "cs_workgroup_yz":
449 rc, msg = run_cmd([vk_compute, spv, "2x3x4", "workgroup_yz"], env=cs_env)
450 results.append((name, rc == 0 and "2x3x4 workgroup Y/Z: 0 mismatches" in msg.splitlines(), msg))
451 elif name == "cs_lds":
468 rc, msg = run_cmd([vk_compute, spv, "4", "mirror64"], env=cs_env) 452 rc, msg = run_cmd([vk_compute, spv, "4", "mirror64"], env=cs_env)
469 results.append((name, rc == 0, msg.splitlines()[-1] if msg else "")) 453 results.append((name, rc == 0, msg.splitlines()[-1] if msg else ""))
470 elif name == "cs_exec64": 454 elif name == "cs_exec64":