diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 15:47:57 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-21 15:47:57 -0500 |
| commit | 89ca8c85e5df9d15239fc4bc69c7b92cfb517ed1 (patch) | |
| tree | f8e83449e04b4e67bd2e412c98f0d4d829aefcc0 /scripts/run_gpu_tests.py | |
| parent | 0d7dbaa4ddc1d8620e0883368d92965202b92e6f (diff) | |
| parent | 12ddbc68f35a8812727a91af37e7e0412921990c (diff) | |
Merge pull request #149 from eIBart0
Diffstat (limited to 'scripts/run_gpu_tests.py')
| -rw-r--r-- | scripts/run_gpu_tests.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/run_gpu_tests.py b/scripts/run_gpu_tests.py index d42277a20..ec11f0fb0 100644 --- a/scripts/run_gpu_tests.py +++ b/scripts/run_gpu_tests.py | |||
| @@ -310,6 +310,37 @@ def check_grad(raw_path: str, want_b: float, want_a: float) -> tuple[bool, str]: | |||
| 310 | return (bad == 0), (first if bad else "4096/4096 pixels exact") | 310 | return (bad == 0), (first if bad else "4096/4096 pixels exact") |
| 311 | 311 | ||
| 312 | 312 | ||
| 313 | def check_clip_half(raw_path: str, want_b: float, want_a: float) -> tuple[bool, str]: | ||
| 314 | """Check 64x64 output with ClipDistance[0] = NDC x: left half (x < 32) clipped to clear (-1), | ||
| 315 | right half (x >= 32) covered (2048/4096 pixels) with the gradient.""" | ||
| 316 | px = read_raw_rgba32f(raw_path) | ||
| 317 | if len(px) != 64 * 64: | ||
| 318 | return False, f"expected 4096 pixels, got {len(px)}" | ||
| 319 | covered = 0 | ||
| 320 | bad = 0 | ||
| 321 | first = "" | ||
| 322 | for i, (r, g, b, a) in enumerate(px): | ||
| 323 | x, y = i % 64, i // 64 | ||
| 324 | is_clear = (r == -1.0 and g == -1.0 and b == -1.0 and a == -1.0) | ||
| 325 | if not is_clear: | ||
| 326 | covered += 1 | ||
| 327 | if x < 32: | ||
| 328 | if not is_clear: | ||
| 329 | if not bad: | ||
| 330 | first = f"unclipped pixel at ({x},{y}): got ({r:.4f},{g:.4f},{b:.4f},{a:.4f})" | ||
| 331 | bad += 1 | ||
| 332 | else: | ||
| 333 | wx = (x + 0.5) / 64.0 | ||
| 334 | wy = (y + 0.5) / 64.0 | ||
| 335 | if is_clear or abs(r - wx) > 1e-3 or abs(g - wy) > 1e-3 or abs(b - want_b) > 1e-3 or abs(a - want_a) > 1e-3: | ||
| 336 | if not bad: | ||
| 337 | first = f"at ({x},{y}): got ({r:.4f},{g:.4f},{b:.4f},{a:.4f}), want ({wx:.4f},{wy:.4f},{want_b},{want_a})" | ||
| 338 | bad += 1 | ||
| 339 | ok = (bad == 0 and covered == 2048) | ||
| 340 | detail = f"{covered}/4096 pixels covered (expected 2048)" if ok else f"covered={covered}/2048; {first}" | ||
| 341 | return ok, detail | ||
| 342 | |||
| 343 | |||
| 313 | def main() -> int: | 344 | def main() -> int: |
| 314 | ap = argparse.ArgumentParser() | 345 | ap = argparse.ArgumentParser() |
| 315 | ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc")) | 346 | ap.add_argument("--llvm-mc", default=os.environ.get("LLVM_MC", "llvm-mc")) |
| @@ -357,6 +388,12 @@ def run_suite(a, work: str) -> int: | |||
| 357 | ]) | 388 | ]) |
| 358 | elif name == "ms_tri": | 389 | elif name == "ms_tri": |
| 359 | dxbc = make_dxbc([(b"PSV0", make_ms_psv0(128, 64, 64, 2))]) | 390 | dxbc = make_dxbc([(b"PSV0", make_ms_psv0(128, 64, 64, 2))]) |
| 391 | elif name == "ms_clip": | ||
| 392 | dxbc = make_dxbc([ | ||
| 393 | (b"PSV0", make_ms_psv0(128, 64, 64, 2)), | ||
| 394 | # OSG1: SV_Position (sysv=1) reg 0 xyzw, SV_ClipDistance (sysv=2) reg 1 x | ||
| 395 | (b"OSG1", make_sig_chunk([(1, 3, 0, 0xF, 0xF), (2, 3, 1, 0x1, 0xE)])), | ||
| 396 | ]) | ||
| 360 | else: | 397 | else: |
| 361 | dxbc = make_dxbc([]) | 398 | dxbc = make_dxbc([]) |
| 362 | with open(os.path.join(work, f"{name}.dxbc"), "wb") as f: | 399 | with open(os.path.join(work, f"{name}.dxbc"), "wb") as f: |
| @@ -502,6 +539,15 @@ def run_suite(a, work: str) -> int: | |||
| 502 | else: | 539 | else: |
| 503 | ok, detail = check_grad(raw, 0.5, 1.0) | 540 | ok, detail = check_grad(raw, 0.5, 1.0) |
| 504 | results.append((name, ok, detail)) | 541 | results.append((name, ok, detail)) |
| 542 | elif name == "ms_clip": | ||
| 543 | raw = os.path.join(raw_dir, f"{name}.raw") | ||
| 544 | env = dict(gfx_env or os.environ, VKH_MESH="1") | ||
| 545 | rc, msg = run_cmd([vk_harness, spv, fs_passthru, raw], env=env) | ||
| 546 | if rc != 0: | ||
| 547 | results.append((name, False, msg)) | ||
| 548 | else: | ||
| 549 | ok, detail = check_clip_half(raw, 0.5, 1.0) | ||
| 550 | results.append((name, ok, detail)) | ||
| 505 | 551 | ||
| 506 | print("\n=== GPU TEST RESULTS ===") | 552 | print("\n=== GPU TEST RESULTS ===") |
| 507 | passed = skipped = 0 | 553 | passed = skipped = 0 |