Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion runtime/test/vk_bindless_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ int main(int argc, char** argv) {
VkPhysicalDeviceProperties2 props{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &props12};
vkGetPhysicalDeviceProperties2(pd, &props);
std::printf("device: %s%s\n", props.properties.deviceName, validation ? " (validation on)" : "");
// The pipeline layout pushes the 144-byte translated user-data block. A device with fewer push constant bytes
// (128 on Intel Arc and some AMD drivers) can't create it: a device limit, not a wrong result (TEST-149).
constexpr std::uint32_t push_bytes = 144;
if (props.properties.limits.maxPushConstantsSize < push_bytes) {
std::printf("unsupported: need %u push constant bytes, device has %u\n", push_bytes,
props.properties.limits.maxPushConstantsSize);
return unsupported;
}

// The features ps_tex's metadata names (bufferDeviceAddress, runtimeDescriptorArray, shaderInt64), dynamic
// indexing of the image array, and whichever descriptor-indexing flags the set can use.
Expand Down Expand Up @@ -515,7 +523,7 @@ int main(int argc, char** argv) {
BindlessSet set(vkGetDeviceProcAddr, dev, mp, flags);
EXPECT(set.ok() && set.layout() && set.set());

const VkPushConstantRange push{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, 144};
const VkPushConstantRange push{VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, push_bytes};
const VkDescriptorSetLayout set_layout = set.layout();
VkPipelineLayoutCreateInfo pli{VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO};
pli.setLayoutCount = 1;
Expand Down
10 changes: 9 additions & 1 deletion runtime/test/vk_image_fuzz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ int main(int argc, char** argv) {
std::printf("unsupported: %s lacks the required image feature\n", spec.format_name.c_str());
return unsupported;
}
// The pipeline layout pushes the 144-byte translated user-data block. A device with fewer push constant bytes
// (128 on Intel Arc and some AMD drivers) can't create it: a device limit, not a wrong result (TEST-149).
constexpr std::uint32_t push_bytes = 144;
if (props.properties.limits.maxPushConstantsSize < push_bytes) {
std::printf("unsupported: need %u push constant bytes, device has %u\n", push_bytes,
props.properties.limits.maxPushConstantsSize);
return unsupported;
}
VkPhysicalDeviceVulkan12Features have12{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES};
VkPhysicalDeviceFeatures2 have{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, &have12};
vkGetPhysicalDeviceFeatures2(pd, &have);
Expand Down Expand Up @@ -476,7 +484,7 @@ int main(int argc, char** argv) {
return 1;
}
set->insert_key(make_tsharp_key(spec.tsharp), index);
const VkPushConstantRange push{.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .size = 144};
const VkPushConstantRange push{.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .size = push_bytes};
const VkDescriptorSetLayout set_layout = set->layout();
VkPipelineLayoutCreateInfo pli{.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.setLayoutCount = 1,
Expand Down
31 changes: 31 additions & 0 deletions tests/test_image_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,37 @@ def test_compare_treats_any_nan_as_equal():
assert imf.compare("R32G32B32A32_SFLOAT", texels, width, height, got) == []


def run_case_with_harness_result(monkeypatch, tmp_path, returncode, stdout):
"""run_case with the translator stubbed out and vk_image_fuzz answering `returncode`/`stdout`."""
build = tmp_path / "build"
build.mkdir()
(build / (imf.HARNESS + (".exe" if os.name == "nt" else ""))).touch()
monkeypatch.setattr(imf, "assemble", lambda *_args: None)
monkeypatch.setattr(imf, "translate", lambda work: str(tmp_path / "spirv"))
monkeypatch.setattr(imf.subprocess, "run",
lambda cmd, **_kw: subprocess.CompletedProcess(cmd, returncode, stdout, ""))
return imf.run_case("R8G8B8A8_UNORM", 4, 4, random.Random(1), str(tmp_path), str(build), False, False)


def test_unsupported_device_skips_with_the_harness_reason(monkeypatch, tmp_path, capsys):
# TEST-149: a 128-byte push constant device exits 77 with its own reason, which the skip line quotes.
result = run_case_with_harness_result(
monkeypatch, tmp_path, 77, "device: X\nunsupported: need 144 push constant bytes, device has 128\n")
assert result is None
assert "SKIP (unsupported: need 144 push constant bytes, device has 128)" in capsys.readouterr().out


def test_unsupported_without_a_reason_line_still_skips(monkeypatch, tmp_path, capsys):
assert run_case_with_harness_result(monkeypatch, tmp_path, 77, "device: X\n") is None
assert "SKIP (the device does not support the set)" in capsys.readouterr().out


def test_a_harness_error_is_a_failure_not_a_skip(monkeypatch, tmp_path, capsys):
assert run_case_with_harness_result(monkeypatch, tmp_path, 1, "device: X\nvkCreateDevice failed\n") is False
out = capsys.readouterr().out
assert "FAIL (vkCreateDevice failed)" in out and "SKIP" not in out


def test_self_test_runs():
r = subprocess.run([sys.executable, "-I", os.path.join(ROOT, "tools", "image_fuzz.py"), "--self-test"],
capture_output=True, text=True)
Expand Down
34 changes: 34 additions & 0 deletions tests/test_run_gpu_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,40 @@ def test_bindless_texture_and_gather_tests_skip(self):
self.assertNotIn("no runnable", out)


class BindlessTestOnASmallPushConstantDevice(unittest.TestCase):
"""vk_bindless_test (ps_tex) exits 77 below its 144 push constant bytes (TEST-149): a SKIP with that reason."""

def run_ps_tex(self, rc, msg):
with tempfile.TemporaryDirectory() as tmp:
args = SimpleNamespace(filter="ps_tex.asm", build=tmp, llvm_mc="unused") # not ps_texoff etc.

def run(cmd, env=None, gpu=True):
if Path(cmd[0]).stem == "vk_bindless_test":
return rc, msg
(Path(tmp) / "spirv" / "ps_tex.spv").touch() # rdna2spirv.py "translating" the shader
return 0, ""

output = io.StringIO()
with (patch.object(rgt, "assemble_to_s", side_effect=lambda _mc, _src, dst, _name: Path(dst).touch()),
patch.object(rgt, "spirv_as"),
patch.object(rgt, "run_cmd", side_effect=run),
contextlib.redirect_stdout(output), contextlib.redirect_stderr(output)):
suite_rc = rgt.run_suite(args, tmp)
return suite_rc, output.getvalue()

def test_too_few_push_constant_bytes_skip(self):
rc, out = self.run_ps_tex(77, "device: X\nunsupported: need 144 push constant bytes, device has 128")
self.assertEqual(rc, 0, out)
self.assertIn("SKIP (unsupported: need 144 push constant bytes, device has 128)", out)
self.assertIn("0/1 passed, 1 skipped", out)

def test_other_failures_still_fail(self):
rc, out = self.run_ps_tex(1, "device: X\nps_tex: 12 pixels differ")
self.assertEqual(rc, 1, out)
self.assertIn("0/1 passed", out)
self.assertNotIn("skipped", out)


class FilterWithoutRunnableCases(unittest.TestCase):
"""A filter selecting only an input shader (cs_bench_mix) must not report 0/0 passed with exit 0."""

Expand Down
16 changes: 7 additions & 9 deletions tools/image_fuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,14 @@ def run_case(fmt_name, width, height, rng, work, build, keep, show, dmask=0xf) -
f"(cmake --build <build> --target {HARNESS})")
r = subprocess.run([harness, os.path.join(spirv, "vs_ids.spv"), os.path.join(spirv, "ps_image_load.spv"),
out_path, spec_path], capture_output=True, text=True)
reason = None
if r.returncode == 77:
reason = "unsupported"
elif r.returncode != 0:
if r.returncode == 77: # a device limit or missing feature, named on the harness's "unsupported:" line
why = next((ln for ln in f"{r.stdout}\n{r.stderr}".splitlines() if ln.startswith("unsupported:")),
"the device does not support the set")
print(f"{fmt_name} {width}x{height} dmask:0x{dmask:x}: SKIP ({why})")
return None
if r.returncode != 0:
reason = (r.stderr or r.stdout).strip().splitlines()[-1:] or ["harness error"]
if reason:
if reason == "unsupported":
print(f"{fmt_name} {width}x{height} dmask:0x{dmask:x}: SKIP (the device does not support the set)")
return None
print(f"{fmt_name} {width}x{height} dmask:0x{dmask:x}: FAIL ({reason[0] if isinstance(reason, list) else reason})")
print(f"{fmt_name} {width}x{height} dmask:0x{dmask:x}: FAIL ({reason[0]})")
return False
got = read_rgba(out_path)
problems = compare(fmt_name, texels, width, height, got, dmask)
Expand Down
Loading