upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:13:55 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 15:13:55 -0500
commit50ccfe4cf6b4e2a1ceeeb23626cac3d445ccfa2c (patch)
tree1bc1db50bb8d6a5c41fa1fc0b91a37b707b55b4a
parentb46397dba9890c6585da1139f60e4abd850c340c (diff)
parent4b71b65588695df8aaa34e346101c5b4156d02e1 (diff)
Merge pull request #2997 from Vonsek
-rw-r--r--runtime/test/shaders/w64_graphics.py2
-rw-r--r--tests/test_w64_graphics_reference.py44
2 files changed, 46 insertions, 0 deletions
diff --git a/runtime/test/shaders/w64_graphics.py b/runtime/test/shaders/w64_graphics.py
index 5e85c5d3c..b39e016b9 100644
--- a/runtime/test/shaders/w64_graphics.py
+++ b/runtime/test/shaders/w64_graphics.py
@@ -372,6 +372,8 @@ def check(tools, spirv, name):
372 for size, (words, heap) in runs.items(): 372 for size, (words, heap) in runs.items():
373 if size == 64: 373 if size == 64:
374 continue 374 continue
375 if tier == "C" and comparable(name, ref_words, None) != comparable(name, words, None):
376 return "a partition-invariant word differs from the 64-lane reference"
375 if tier == "C": 377 if tier == "C":
376 if comparable(name, ref_words, None) != comparable(name, words, None): 378 if comparable(name, ref_words, None) != comparable(name, words, None):
377 return "a word that must not depend on the partition differs from the 64-lane reference" 379 return "a word that must not depend on the partition differs from the 64-lane reference"
diff --git a/tests/test_w64_graphics_reference.py b/tests/test_w64_graphics_reference.py
new file mode 100644
index 000000000..01a126bb9
--- /dev/null
+++ b/tests/test_w64_graphics_reference.py
@@ -0,0 +1,44 @@
1"""CPU replay of the wave64 graphics runner's saved-reference comparisons."""
2
3import os
4from pathlib import Path
5import struct
6import sys
7import tempfile
8import unittest
9from unittest.mock import patch
10
11sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "runtime" / "test" / "shaders"))
12import w64_graphics
13
14
15class TierCReferenceTests(unittest.TestCase):
16 def test_partition_invariant_word_must_match_reference(self) -> None:
17 name = "ps_w64_c_lane_id"
18 # The fixture writes lane ID, lane ID within a half, pixel X and zero.
19 wave64 = [(i % 64, i % 32, i % 64, 0) for i in range(64 * 64)]
20 wave32 = [(i % 32, i % 32, i % 64, 0) for i in range(64 * 64)]
21 wrong_x = wave32.copy()
22 lane, half, x, zero = wrong_x[73]
23 wrong_x[73] = (lane, half, x + 1, zero)
24
25 with tempfile.TemporaryDirectory() as work:
26 (Path(work) / f"{name}.spv").touch()
27 (Path(work) / f"{name}.ref64.raw").write_bytes(
28 b"".join(struct.pack("<4I", *pixel) for pixel in wave64)
29 )
30 with patch.dict(os.environ, W64G_REF=work, W64G_SAVE_REF=""):
31 for frame, expected in ((wave32, ""), (wrong_x, "partition-invariant word")):
32 with self.subTest(expected=expected), patch.object(
33 w64_graphics, "draw",
34 side_effect=lambda _tools, _spirv, _name, size, _tmp: (frame, None, size == 32),
35 ):
36 result = w64_graphics.check(work, work, name)
37 if expected:
38 self.assertIn(expected, result)
39 else:
40 self.assertEqual(result, "")
41
42
43if __name__ == "__main__":
44 unittest.main()