Merge pull request #1318 from Freem

This commit is contained in:
ItsNotRexed
2026-11-22 05:08:05 -05:00
4 changed files with 77 additions and 3 deletions

View File

@ -440,6 +440,22 @@ def wave32_lane_skip(out):
return narrow_subgroup_skip(out) or unpinned_subgroup_skip(out)
def bitmask_perm_narrow_skip(out, px):
"""A Skip when ps_bitmask_perm ran narrower than 32 lanes on a device whose subgroup range permits it (#618).
Requires every lane 0..width-1 of a power-of-two width in [min, 32), so a broken v_mbcnt still fails."""
m = re.search(r"subgroup (\d+)\.\.(\d+)", out)
if not m or len(px) != 64 * 64:
return None
lo, hi = int(m.group(1)), int(m.group(2))
if lo >= 32:
return None
lanes = {p[0] for p in px}
width = max(lanes) + 1
if lo <= width < 32 and width & (width - 1) == 0 and lanes == set(range(width)):
return Skip(f"SKIP (fragment subgroup ran at {width} lanes on {lo}..{hi} device; needs 32)")
return None
def compute_test(tools, spirv, name, groups, mode, *, require_wave64=False, expected_words=None, needs_32_lanes=False,
env=None):
"""Return an empty string for a pass, None for unsupported wave64, a Skip for a wave32 lane-mask test on a device
@ -796,6 +812,8 @@ def pixel_test(tools, spirv, name):
if name == "ps_interp_f16_high":
return interp_f16_high_problem(px)
if name == "ps_bitmask_perm":
if skip := bitmask_perm_narrow_skip(out, px):
return skip
low = [p for p in px if p[0] < 32]
wrong = sum(not (a == lane ^ 9 and b == ((lane & 5) | 16) ^ 1) for lane, a, b, _ in low)
return "" if low and not wrong else f"{wrong} of {len(low)} pixels in lanes 0-31 wrong"

View File

@ -34,7 +34,8 @@ from check import TEXOFF_ARGS, texoff_problem # ps_texoff's expected words and
from check import TEXOFF_FALLBACK, texoff_env # LEONIDA_TEXOFF_FALLBACK=1: texel offsets without maintenance8
from check import gpu_test_timeout, timed_out # per-program time limit (LEONIDA_GPU_TEST_TIMEOUT)
from check import MESH_COMPUTE, mesh_env # LEONIDA_MESH_COMPUTE=1: mesh shaders as compute + a generated VS
from check import WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, narrow_subgroup_skip, wave32_lane_skip # as in check.py
from check import (WAVE32_LANE_DUMPS, WAVE32_LANE_ENV, bitmask_perm_narrow_skip, narrow_subgroup_skip,
wave32_lane_skip) # as in check.py
from check import PIXEL_VERTEX, interp_f16_high_problem # ps_interp_f16_high's producers and check
@ -326,8 +327,10 @@ def check_bary(raw_path: str) -> tuple[bool, str]:
return (bad == 0), (first if bad else "4096/4096 pixels exact")
def check_bitmask_perm(raw_path: str) -> tuple[bool, str]:
def check_bitmask_perm(raw_path: str, msg: str = "") -> tuple[bool | None, str]:
px = read_raw_u32(raw_path)
if skip := bitmask_perm_narrow_skip(msg, px):
return None, str(skip)
bad = 0
first = ""
judged = 0
@ -1002,7 +1005,7 @@ def run_suite(a, work: str) -> int:
if m and int(m.group(1)) < 32:
ok, detail = None, f"SKIP (subgroup {m.group(1)} is narrower than 32 lanes)"
else:
ok, detail = check_bitmask_perm(raw)
ok, detail = check_bitmask_perm(raw, msg)
elif name in ("ps_uniform_branch", "ps_scc_mask32"): # same expected pattern (see the .asm headers)
ok, detail = check_uniform_branch(raw)
elif name == "ps_wqm":

View File

@ -76,6 +76,26 @@ class PixelChecks(unittest.TestCase):
with self.subTest(check=name):
self.assertFalse(check(empty)[0])
def test_bitmask_perm_narrow_fragment_subgroup_skip(self):
import check
self.assertIs(rgt.bitmask_perm_narrow_skip, check.bitmask_perm_narrow_skip)
simd16 = self.raw(b"".join(struct.pack("<4I", i % 16, (i % 16) ^ 9, 0, 0) for i in range(64 * 64)))
ok, detail = rgt.check_bitmask_perm(simd16, "device: Intel ANV (subgroup 8..32)\nok 64x64\n")
self.assertIsNone(ok)
self.assertIn("16 lanes", detail)
# Same narrow output on a fixed 32..32 device is a real failure, not a skip.
ok, detail = rgt.check_bitmask_perm(simd16, "device: NVIDIA (subgroup 32..32)\nok 64x64\n")
self.assertIs(ok, False)
self.assertIn("want (9,17,0)", detail)
# Full 32-lane output on an 8..32 device is still judged.
simd32 = self.raw(b"".join(
struct.pack("<4I", i % 32, (i % 32) ^ 9, (((i % 32) & 5) | 16) ^ 1, 0) for i in range(64 * 64)))
ok, detail = rgt.check_bitmask_perm(simd32, "device: Intel ANV (subgroup 8..32)\nok 64x64\n")
self.assertIs(ok, True)
self.assertIn("4096/4096", detail)
if __name__ == "__main__":
unittest.main()

View File

@ -298,6 +298,39 @@ class PixelDeviceLimits(unittest.TestCase):
self.assertIsInstance(problem, check.Skip)
self.assertIn("no subgroup width", problem)
def test_bitmask_perm_skips_when_variable_device_runs_narrow_fragment_subgroup(self):
out = "device: Intel(R) HD Graphics 530 (subgroup 8..32)\nok 64x64\n"
for width in (8, 16):
with self.subTest(width=width):
# In SIMD8/SIMD16, "10p0i" targets lanes >= 16 (out of bounds), returning 0 or wrapped values.
data = b"".join(struct.pack("<4I", i % width, (i % width) ^ 9, 0, 0) for i in range(64 * 64))
problem = self.run_pixel("ps_bitmask_perm", 0, out, data=data)
self.assertIsInstance(problem, check.Skip)
self.assertIn(f"{width} lanes", problem)
def test_bitmask_perm_judges_variable_device_at_32_lanes(self):
out = "device: Intel(R) HD Graphics 530 (subgroup 8..32)\nok 64x64\n"
self.assertEqual(self.run_pixel("ps_bitmask_perm", 0, out, data=self.bitmask_pixels(32)), "")
bad = b"".join(struct.pack("<4I", i % 32, (i % 32) ^ 9, 0, 0) for i in range(64 * 64))
problem = self.run_pixel("ps_bitmask_perm", 0, out, data=bad)
self.assertNotIsInstance(problem, check.Skip)
self.assertIn("wrong", problem)
def test_bitmask_perm_fails_broken_lanes_instead_of_skipping(self):
# Fixed 32..32 device producing only lanes 0..15, or 8..32 device producing incomplete/too-narrow lanes.
simd16 = b"".join(struct.pack("<4I", i % 16, (i % 16) ^ 9, 0, 0) for i in range(64 * 64))
problem = self.run_pixel("ps_bitmask_perm", 0, "device: fake (subgroup 32..32)\nok 64x64\n", data=simd16)
self.assertNotIsInstance(problem, check.Skip)
self.assertIn("wrong", problem)
out = "device: fake (subgroup 8..32)\nok 64x64\n"
for lanes in (1, 4, 15):
with self.subTest(lanes=lanes):
bad = b"".join(struct.pack("<4I", i % lanes, (i % lanes) ^ 9, 0, 0) for i in range(64 * 64))
problem = self.run_pixel("ps_bitmask_perm", 0, out, data=bad)
self.assertNotIsInstance(problem, check.Skip)
self.assertIn("wrong", problem)
class SeededPixelTests(unittest.TestCase):
"""ps_vcc_x2 reads a V# from s[0:3]; check.py hands vk_harness that V# and the heap words behind it (TEST-19)."""