upleb.uk

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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSolthodox <100046219+Solthodox@users.noreply.github.com>2026-11-23 16:55:11 +0100
committerGitHub <noreply@github.com>2026-11-23 09:55:11 -0600
commit9b72d0d2cc81a4c49a0085e0efffa6a6f4e44fdd (patch)
tree83229b08cb257c5ea34c3d4423d7e7a6a9197360
parentd231919b88c9ee5aa4da75a4333dfd2da60b6aba (diff)
tests: check sparse buffer sharing evidence within each API dump record (#6756)
Squash-merged after diff review of PR #6756 - tests: verify sparse queue-family indices within each buffer record
-rw-r--r--runtime/test/check_sparse_queue_family.py33
-rw-r--r--tests/test_check_sparse_queue_family.py26
2 files changed, 42 insertions, 17 deletions
diff --git a/runtime/test/check_sparse_queue_family.py b/runtime/test/check_sparse_queue_family.py
index d77887726..27ebc1f5d 100644
--- a/runtime/test/check_sparse_queue_family.py
+++ b/runtime/test/check_sparse_queue_family.py
@@ -40,26 +40,31 @@ CASE = re.compile(r"^RESULT (LAYER_MAP_(?:DIRECT|COPY|COMPUTE)_COPY_COMPUTE) PAS
40 40
41def check_trace(path: Path, expect_exclusive: bool) -> tuple[int, int]: 41def check_trace(path: Path, expect_exclusive: bool) -> tuple[int, int]:
42 rows = path.read_text(encoding="utf-8", errors="replace").splitlines() 42 rows = path.read_text(encoding="utf-8", errors="replace").splitlines()
43 seen = [] 43 records = 0
44 for i, line in enumerate(rows): 44 for i, line in enumerate(rows):
45 if SPARSE_FLAGS not in line: 45 if SPARSE_FLAGS not in line:
46 continue 46 continue
47 tail = "\n".join(rows[i + 1 : i + 13]) 47 end = i + 1
48 while end < len(rows) and "VkBufferCreateFlags =" not in rows[end] and not CALL_HEAD.match(rows[end]):
49 end += 1
50 tail = "\n".join(rows[i + 1:end])
48 mode, count = MODE.search(tail), COUNT.search(tail) 51 mode, count = MODE.search(tail), COUNT.search(tail)
49 if not mode or not count: 52 if not mode or not count:
50 raise AssertionError(f"incomplete API dump sparse VkBuffer at line {i+1}") 53 raise AssertionError(f"incomplete API dump sparse VkBuffer at line {i+1}")
51 inds = tuple(int(index) for _, index in INDICES.findall(tail)) 54 sharing, n = mode.group(1), int(count.group(1))
52 seen.append((mode.group(1), int(count.group(1)), inds)) 55 indices = [(int(slot), int(family)) for slot, family in INDICES.findall(tail)]
53 if len(seen) < 6 or len(seen) % 2: 56 if expect_exclusive:
54 raise AssertionError(f"insufficient sparse VkBuffer create-info records: {len(seen)}") 57 if sharing != "VK_SHARING_MODE_EXCLUSIVE" or n != 0 or indices:
55 if expect_exclusive: 58 raise AssertionError(f"baseline negative control not reproduced at line {i+1}")
56 assert all(mode == "VK_SHARING_MODE_EXCLUSIVE" and count == 0 59 elif (sharing != "VK_SHARING_MODE_CONCURRENT" or n < 2 or len(indices) != n
57 for mode, count, _ in seen), f"baseline negative control not reproduced: {set(seen)}" 60 or len({slot for slot, _ in indices if slot < n}) != n
58 else: 61 or len({family for _, family in indices}) != n):
59 assert all(mode == "VK_SHARING_MODE_CONCURRENT" and count >= 2 and len(inds) == count 62 raise AssertionError(f"incomplete or non-concurrent sparse buffer at line {i+1}: "
60 and len(set(inds)) == count 63 f"{sharing}, count={n}, indices={indices}")
61 for mode, count, inds in seen), f"BUG: not all sparse buffers share active families: {set(seen)}" 64 records += 1
62 return len(seen) // 2, len(seen) 65 if records < 6 or records % 2:
66 raise AssertionError(f"insufficient sparse VkBuffer create-info records: {records}")
67 return records // 2, records
63 68
64 69
65def main() -> int: 70def main() -> int:
diff --git a/tests/test_check_sparse_queue_family.py b/tests/test_check_sparse_queue_family.py
index c9109dc06..630b8bbfb 100644
--- a/tests/test_check_sparse_queue_family.py
+++ b/tests/test_check_sparse_queue_family.py
@@ -135,9 +135,29 @@ CONCURRENT_TRACE = (checker.SPARSE_FLAGS + ")\n"
135 " sharingMode: VkSharingMode = VK_SHARING_MODE_CONCURRENT (1)\n" 135 " sharingMode: VkSharingMode = VK_SHARING_MODE_CONCURRENT (1)\n"
136 " queueFamilyIndexCount: uint32_t = 2\n" 136 " queueFamilyIndexCount: uint32_t = 2\n"
137 " pQueueFamilyIndices[0]: const uint32_t = 0\n" 137 " pQueueFamilyIndices[0]: const uint32_t = 0\n"
138 " pQueueFamilyIndices[1]: const uint32_t = 1\n" 138 " pQueueFamilyIndices[1]: const uint32_t = 1\n") * 6
139 # check_trace reads the 12 lines after each flags line; real records are longer than that. 139
140 + " pNext: const void* = NULL\n" * 12) * 6 140
141class TraceTest(unittest.TestCase):
142 def check(self, text):
143 with tempfile.TemporaryDirectory() as td:
144 path = Path(td) / "sparse.log"
145 path.write_text(text, encoding="utf-8", newline="\n")
146 return checker.check_trace(path, expect_exclusive=False)
147
148 def test_large_family_list_is_not_truncated(self):
149 record = (f"{checker.SPARSE_FLAGS})\nsharingMode: VkSharingMode = VK_SHARING_MODE_CONCURRENT\n"
150 "queueFamilyIndexCount: uint32_t = 12\n")
151 record += "".join(f"pQueueFamilyIndices[{i}]: const uint32_t = {2*i}\n" for i in range(12))
152 self.assertEqual(self.check(record * 6), (3, 6))
153
154 def test_each_sparse_buffer_must_supply_its_own_complete_array(self):
155 for invalid in (CONCURRENT_TRACE.replace("Indices[1]", "Indices[0]", 1),
156 CONCURRENT_TRACE.replace("Indices[1]", "Indices[2]", 1),
157 CONCURRENT_TRACE.replace(" pQueueFamilyIndices[1]: const uint32_t = 1\n", "", 1),
158 CONCURRENT_TRACE.replace(" pQueueFamilyIndices[1]", "vkOtherCall()\n pQueueFamilyIndices[1]", 1)):
159 with self.subTest(trace=invalid[:300]), self.assertRaises(AssertionError):
160 self.check(invalid)
141 161
142 162
143class MainTest(unittest.TestCase): 163class MainTest(unittest.TestCase):