GPU tests: skip what the device can't run instead of failing (fixes #88 points 2-3)

vk_store_test exits 77 when the GPU lacks format-less storage image read/write (Intel Gen9), and check.py
reports it as SKIP. run_gpu_tests.py catches up with check.py: ps_flat (drawn with vs_ids), ps_legacy_mul,
and ps_bitmask_perm judged on lanes 0-31 only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ItsNotRexed
2026-11-21 14:16:04 -05:00
parent 4f4189ef3e
commit d51bddc84e
3 changed files with 42 additions and 5 deletions

View File

@ -42,6 +42,10 @@ def failure(code, output, lines):
return f"exit {code}: {details or 'no test output'}"
class Skip(str):
"""A result that is neither a pass nor a failure: the device can't run the test."""
def compute_test(tools, spirv, name, groups, mode, *, require_wave64=False, expected_words=None):
"""Return an empty string for a pass, None for unsupported wave64, or a failure diagnostic."""
shader = os.path.join(spirv, name + ".spv")
@ -129,6 +133,9 @@ def main():
expected_words=want)))
for name, args in (("cs_imgstore", []), ("cs_imgload", ["load"])):
code, out = run(os.path.join(tools, "vk_store_test" + EXE), os.path.join(spirv, name + ".spv"), *args)
if code == 77: # vk_store_test: the device lacks format-less storage image access
results.append((name, Skip("SKIP (no format-less storage image read/write on this device)")))
continue
bad = re.findall(r"(\d+) bad", out)
results.append((name, "" if code == 0 and len(bad) == 3 and set(bad) == {"0"} else failure(code, out, 3)))
for name in PIXEL_TESTS:
@ -137,8 +144,8 @@ def main():
if problem is None:
problem = "SKIP (full 64-wide compute subgroups unavailable)"
print(f"{name:20} {'ok' if not problem else problem}")
failed = sum(bool(p) for _, p in results)
skipped = sum(p is None for _, p in results)
skipped = sum(p is None or isinstance(p, Skip) for _, p in results)
failed = sum(bool(p) for _, p in results) - sum(isinstance(p, Skip) for _, p in results)
print(f"{len(results) - failed - skipped} of {len(results)} pass, {skipped} skipped")
return 1 if failed else 0

View File

@ -55,7 +55,7 @@ int main(int argc, char** argv) {
CHECK(vkCreateInstance(&ici, nullptr, &inst));
LOADI(vkEnumeratePhysicalDevices); LOADI(vkGetPhysicalDeviceProperties); LOADI(vkCreateDevice);
LOADI(vkGetPhysicalDeviceQueueFamilyProperties); LOADI(vkGetDeviceProcAddr);
LOADI(vkGetPhysicalDeviceMemoryProperties);
LOADI(vkGetPhysicalDeviceMemoryProperties); LOADI(vkGetPhysicalDeviceFeatures);
uint32_t n = 0;
vkEnumeratePhysicalDevices(inst, &n, nullptr);
std::vector<VkPhysicalDevice> pds(n);
@ -76,6 +76,16 @@ int main(int argc, char** argv) {
float prio = 1;
VkDeviceQueueCreateInfo qci{VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO};
qci.queueFamilyIndex = qi; qci.queueCount = 1; qci.pQueuePriorities = &prio;
// The typed stores/loads need format-less storage image access. Some GPUs (e.g. Intel Gen9) lack the read side:
// report that and exit 77 (unsupported, as vk_compute_test does) instead of failing vkCreateDevice.
VkPhysicalDeviceFeatures have{};
vkGetPhysicalDeviceFeatures(pd, &have);
if (!have.shaderStorageImageWriteWithoutFormat || !have.shaderStorageImageReadWithoutFormat || !have.shaderInt64) {
std::fprintf(stderr, "unsupported: shaderStorageImageWriteWithoutFormat=%u shaderStorageImageReadWithoutFormat=%u "
"shaderInt64=%u\n", have.shaderStorageImageWriteWithoutFormat,
have.shaderStorageImageReadWithoutFormat, have.shaderInt64);
return 77;
}
VkPhysicalDeviceVulkan12Features f12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
f12.runtimeDescriptorArray = VK_TRUE; f12.bufferDeviceAddress = VK_TRUE;
f12.shaderStorageImageArrayNonUniformIndexing = VK_TRUE;

View File

@ -236,14 +236,30 @@ def check_bitmask_perm(raw_path: str) -> tuple[bool, str]:
px = read_raw_u32(raw_path)
bad = 0
first = ""
judged = 0
for i, (lane, v1, v2, v3) in enumerate(px):
if lane >= 32: # wave32 test: in a 64-wide subgroup lanes 32-63 hold values it never wrote
continue
judged += 1
w1 = lane ^ 9
w2 = ((lane & 5) | 16) ^ 1
if v1 != w1 or v2 != w2 or v3 != 0:
if not bad:
first = f"at ({i%64},{i//64}) lane={lane}: got ({v1},{v2},{v3}), want ({w1},{w2},0)"
bad += 1
return (bad == 0), (first if bad else "4096/4096 pixels exact")
return (bad == 0 and judged > 0), (first if bad else f"{judged}/{judged} pixels in lanes 0-31 exact")
def check_flat(raw_path: str) -> tuple[bool, str]:
"""ps_flat with vs_ids: the integer IDs come from the first (provoking) vertex, the UVs still interpolate."""
data = open(raw_path, "rb").read()
px = list(struct.iter_unpack("<2I2f", data))
w = int(len(px) ** 0.5)
wrong = sum((a, b) != (0x101, 0x102) for a, b, _, _ in px)
err = max(max(abs(u - (i % w + 0.5) / w), abs(v - (i // w + 0.5) / w)) for i, (_, _, u, v) in enumerate(px))
ok = wrong == 0 and err < 1e-6
return ok, (f"{len(px)} pixels: flat IDs exact, uv within {err:.1g}" if ok else
f"{wrong} pixels without the first vertex's value, uv off by {err:.3g}")
def check_uniform_branch(raw_path: str) -> tuple[bool, str]:
@ -408,7 +424,8 @@ def run_suite(a, work: str) -> int:
results.append((name, rc == 0, msg.splitlines()[-1] if msg else ""))
elif name.startswith("ps_"):
raw = os.path.join(raw_dir, f"{name}.raw")
rc, msg = run_cmd([vk_harness, vs_tri, spv, raw], env=gfx_env)
vs = os.path.join(spirv_dir, "vs_ids.spv") if name == "ps_flat" else vs_tri # check.py draws ps_flat with vs_ids
rc, msg = run_cmd([vk_harness, vs, spv, raw], env=gfx_env)
if rc != 0:
results.append((name, False, msg))
continue
@ -419,6 +436,7 @@ def run_suite(a, work: str) -> int:
"ps_ops4": (0x34000010, 0x00120800, 0xBEEF0000, 0x12343C00),
"ps_scc": (1, 1, 3, 0x80000000),
"ps_sdwa": (0x000000F1, 0xFFFEFFF2, 0x3C003344, 0xFFF70000),
"ps_legacy_mul": (0, 0, 0, 0x40C00000), # same expectation as check.py
}
if name in const_wants:
ok, detail = check_pixel_const(raw, const_wants[name])
@ -428,6 +446,8 @@ def run_suite(a, work: str) -> int:
ok, detail = check_bitmask_perm(raw)
elif name == "ps_uniform_branch":
ok, detail = check_uniform_branch(raw)
elif name == "ps_flat":
ok, detail = check_flat(raw)
else:
ok, detail = False, "no checker defined"
results.append((name, ok, detail))