Repository navigation
vk_pipeline_check: skip incompatible shaders before module creation - #4796
illusionart453-max wants to merge 4 commits into
Conversation
|
At Create an empty directory named {"cs_absent":{"stage":"cs","push_constant_bytes":512}}Run
An index entry with no file should count as a module failure on either adapter. Check the open result and file size before the feature skip. This keeps incompatible modules out of the driver and preserves the missing-file diagnostic. The existing CLI test passes on the PR head. AI-assisted. Rechecked at d05b83e. On both adapters, the new feature test passes on the PR and fails on the merge base. It writes both shader files before it runs the checker. The separate missing-file probe above still exits 0 on the PR and 1 on the merge base. Fix verified at The new tests also have a device availability issue. To reproduce on Windows, set |
|
Confirmed the early feature check on an Intel UHD 770 (Windows 11, driver
The same 18 shaders were skipped for the same reasons in all four runs. In a two-shader check, main created the One small change would let the new regression test pass independently on Intel. In AI-assisted. These runs checked pipeline creation. |
kacper-serewis
left a comment
There was a problem hiding this comment.
Independent AI-assisted Windows validation at 94c2222 on RTX 5070, driver 616.56. Vulkan loader diagnostics confirmed Khronos validation SDK 1.4.363.0 at instance and device level in all five runs. Supported + metadata-unsupported synthetic compute entries built one module and one pipeline, skipped one, exited 0. Missing, empty, 5-byte and 21-byte files each failed module handling before the capability skip and exited 1. Coverage is synthetic NVIDIA compute only.
|
Follow-up to @shdann's unavailable-driver reproduction and @PingasMech's descriptor-free fixture suggestion: reproduced at With The patch prints the instance-creation Tested on Windows 11, RTX 4070 Ti, NVIDIA 616.56, native Python 3.13.1, MSVC 19.44:
Synthetic inputs only. The Intel fixture adjustment was tested here on NVIDIA; no independent Intel run. Patch against 94c2222 (apply with git apply)diff --git a/runtime/test/vk_pipeline_check.cpp b/runtime/test/vk_pipeline_check.cpp
index 4e59580c..81de5796 100644
--- a/runtime/test/vk_pipeline_check.cpp
+++ b/runtime/test/vk_pipeline_check.cpp
@@ -908,7 +908,10 @@ int main(int argc, char** argv) {
app.apiVersion = VK_API_VERSION_1_3;
VkInstanceCreateInfo ici{VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO};
ici.pApplicationInfo = &app;
- if (vkCreateInstance(&ici, nullptr, &inst)) return 1;
+ if (VkResult r = vkCreateInstance(&ici, nullptr, &inst); r != VK_SUCCESS) {
+ std::fprintf(stderr, "vkCreateInstance failed (%d)\n", r);
+ return 1;
+ }
LOADI(vkEnumeratePhysicalDevices); LOADI(vkGetPhysicalDeviceProperties); LOADI(vkCreateDevice);
LOADI(vkGetPhysicalDeviceProperties2);
LOADI(vkGetDeviceProcAddr); LOADI(vkEnumerateDeviceExtensionProperties); LOADI(vkGetPhysicalDeviceFeatures2);
diff --git a/tests/test_vk_pipeline_check_features.py b/tests/test_vk_pipeline_check_features.py
index f501e07c..de919ed4 100644
--- a/tests/test_vk_pipeline_check_features.py
+++ b/tests/test_vk_pipeline_check_features.py
@@ -10,6 +10,7 @@ import subprocess
import sys
import tempfile
import unittest
+from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tools"))
@@ -42,21 +43,38 @@ class FeatureGateTest(unittest.TestCase):
self.skipTest("set LEONIDA_VK_PIPELINE_CHECK to a built checker")
self.binary = binary
+ def run_checker(self, root):
+ result = subprocess.run(
+ [str(self.binary), str(root), str(root / "cache.bin"), "--jobs", "1"],
+ capture_output=True, text=True, timeout=60)
+ # VK_ERROR_INCOMPATIBLE_DRIVER (-9) means no usable Vulkan implementation.
+ # Other instance failures (for example out-of-memory) must remain failures.
+ unavailable = any(
+ line == "vkCreateInstance failed (-9)"
+ or line in ("no Vulkan physical devices found", "no Vulkan physical device found")
+ or line.startswith("could not load vkGetInstanceProcAddr from ")
+ or (line.startswith("LEONIDA_VK_DEVICE=") and line.endswith(": no Vulkan physical device matches"))
+ for line in result.stderr.splitlines())
+ if result.returncode == 1 and unavailable:
+ self.skipTest(result.stderr.strip())
+ return result
+
def test_missing_or_invalid_size_is_failed_before_feature_skip(self):
for payload in (None, b"", b"short", bytes(21)):
- with self.subTest(payload=payload), tempfile.TemporaryDirectory() as directory:
+ with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
if payload is not None:
(root / "cs_absent.spv").write_bytes(payload)
with (root / "index.json").open("w", encoding="utf-8", newline="\n") as output:
json.dump({"cs_absent": {"stage": "cs", "push_constant_bytes": 512}}, output)
- result = subprocess.run(
- [str(self.binary), str(root), str(root / "cache.bin"), "--jobs", "1"],
- capture_output=True, text=True, timeout=60)
- self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
- self.assertIn("MODULE FAIL cs_absent", result.stdout)
- self.assertIn("cs: 0 modules ok, 1 failed", result.stdout)
- self.assertNotIn("SKIPPED cs_absent", result.stdout)
+ # Keep availability checks outside subTest, so a missing device skips
+ # this test once rather than recording a skip for every payload.
+ result = self.run_checker(root)
+ with self.subTest(payload=payload):
+ self.assertEqual(result.returncode, 1, result.stdout + result.stderr)
+ self.assertIn("MODULE FAIL cs_absent", result.stdout)
+ self.assertIn("cs: 0 modules ok, 1 failed", result.stdout)
+ self.assertNotIn("SKIPPED cs_absent", result.stdout)
def test_unsupported_entry_never_creates_a_module(self):
with tempfile.TemporaryDirectory() as directory:
@@ -65,17 +83,37 @@ class FeatureGateTest(unittest.TestCase):
for name in ("supported", "unsupported"):
(root / (name + ".spv")).write_bytes(code)
with (root / "index.json").open("w", encoding="utf-8", newline="\n") as output:
- json.dump({"supported": {"stage": "cs"},
+ json.dump({"supported": {"stage": "cs", "bindings": []},
"unsupported": {"stage": "cs", "float_controls": ["syntheticUnavailable"]}}, output)
- result = subprocess.run([str(self.binary), str(root), str(root / "cache.bin")],
- capture_output=True, text=True, timeout=60)
- if "no usable Vulkan" in result.stderr or "no Vulkan" in result.stderr:
- self.skipTest(result.stderr)
+ result = self.run_checker(root)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
self.assertIn("cs: 1 modules ok, 0 failed", result.stdout)
self.assertIn("cs pipelines: 1 ok, 0 failed, 1 skipped", result.stdout)
self.assertIn("SKIPPED unsupported (unknown float control syntheticUnavailable)", result.stdout)
+class AvailabilityTest(unittest.TestCase):
+ def run_result(self, result):
+ case = FeatureGateTest()
+ case.binary = Path("unused-checker")
+ with patch.object(subprocess, "run", return_value=result):
+ return case.run_checker(Path("unused-input"))
+
+ def test_unavailable_driver_or_device_skips(self):
+ for message in ("vkCreateInstance failed (-9)", "no Vulkan physical devices found",
+ "could not load vkGetInstanceProcAddr from vulkan-1.dll",
+ "LEONIDA_VK_DEVICE=missing: no Vulkan physical device matches"):
+ with self.subTest(message=message), self.assertRaises(unittest.SkipTest):
+ self.run_result(subprocess.CompletedProcess([], 1, "", message + "\n"))
+
+ def test_real_errors_are_not_skipped(self):
+ for message in ("vkCreateInstance failed (-1)", "vkCreateInstance failed (-2)",
+ "vkCreateInstance failed (-3)", "vkCreateDevice -3",
+ "MODULE FAIL no Vulkan physical device matches"):
+ with self.subTest(message=message):
+ result = subprocess.CompletedProcess([], 1, "MODULE FAIL cs_bad", message + "\n")
+ self.assertIs(self.run_result(result), result)
+
+
if __name__ == "__main__":
unittest.main() |
|
@shdann @PingasMech @l-CatDemon-l Addressed in 18d0bc0. Thank you for the reproductions and patch. The checker now reports vkCreateInstance's VkResult, both GPU tests use the shared availability check outside subTest, and the supported fixture declares bindings: []. I adapted the suggested patch while keeping an explicitly unmatched LEONIDA_VK_DEVICE filter as a configuration failure rather than a skip. Windows 11, RTX 5060 / 610.88, MSVC 19.44, Khronos validation 1.4.363.0: all four feature tests pass, with no VUIDs across the five checker invocations. A nonexistent ICD path gives two CPU passes and two GPU skips; the prior checker reproduced five failures. Seven index tests, the CLI regression, byte compilation, line-ending checks and diff check pass. CPU controls retain instance/device errors and actual module failures as failures. Missing/empty/short/unaligned shader inputs still fail before capability skips. AI-assisted. Synthetic inputs only. |
|
Tested 18d0bc0 on RTX 5070, driver 616.86, Windows 10.0.26200: pass. Built
( |
|
Tested Built
Counts and pass/fail only; no game data. No code changes. AI-assisted. |
|
Tested 18d0bc0 on AMD Radeon 610M (RADV, gfx1036, Mesa 26.2.6), CachyOS Linux, LEONIDA_VK_DEVICE=RADV: pass.
The missing-ICD case was not run here. AI-assisted. |
|
Code read + CPU tests, 18d0bc0: pass ( This is the tool I used for the two giant ScreenProbes modules in #884, and the change is the right one: checking the file and the feature gate before creating the module is what turns a validation error into an honest skip, and keeping missing/empty/undersized/unaligned as module failures keeps the diagnostic. Instance-creation failures printing their VkResult will save the next person the guessing I did. |
|
Verified on current main: merges cleanly; the Python half passes its two CPU-verifiable stderr-contract tests and the GPU half self-skips loudly rather than silently passing in this environment. Inspection of the C++ confirms the feature gate now runs before vkCreateShaderModule on every stage, per-stage record_skip covers missing stubs and attachment limits, module-file failures still fail, and only instance/device absence maps to the skip path. A Vulkan CI run of vk_pipeline_check is the remaining evidence — and no CI checks are reported on this branch, so as it stands the binary side never executes on any automated run. Worth triggering before merge. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Tested
|
|
Thanks for this work. Reading it against current AI-assisted (GLM-5.3). |
|
Tested head Machine: Linux 7.3, Mesa 26.3.1 RADV, Khronos validation layer 1.4.363.1 ( Feature tests (
Gating, synthetic SPIR-V (10 hand-written entries, all
Translated corpus (counts only):
Conflict with main: only
Defects: none found. Non-blocking notes:
No RDNA1 GPU was available; this check covers RADV on RDNA2 (gfx1036) and RDNA3 only. AI-assisted (Claude Code, Claude Opus 5.5). |
|
Checked the cleanup suggestion against current main 6312c05 with a fresh native MSVC 19.44 RelWithDebInfo build of vk_pipeline_check, RTX 5060 / driver 32.0.16.1088, Windows 11. This PR is not fully superseded. Main's check_missing_module_feature handles selected capabilities before module creation, but its broader check_missing_feature still runs afterward. With this PR's test file added to current main and no tool change, 3/4 tests pass and test_unsupported_entry_never_creates_a_module fails: the synthetic unsupported entry is SKIPPED, yet the summary is cs: 2 modules ok instead of 1. That matches the independent RADV measurements above and confirms the missing pre-module gate remains on current main. The PR needs a rebase that preserves main's newer module-level checks and moves the remaining feature checks before module creation. I am keeping it open for that integration rather than closing it as superseded. No game inputs. AI-assisted verification (Codex). |
|
Local rebase/integration is now committed as 37f55102c on main 6312c05 (branch fix/pipeline-feature-gate-current). It retains main's module-level dynamic-indexing/FMA gate, workgroup-memory limit check, float64 handling, and module isolation/progress logic. The remaining check_missing_feature calls now run before module creation, and the duplicate post-module calls are removed. Missing or malformed module sizes are still failures before a feature skip, and instance creation prints its failure code. Fresh MSVC 19.44 / RelWithDebInfo build passes. On Windows 11, RTX 5060 / 32.0.16.1088, Python 3.15.0, SDK 1.4.363.0:
The published head is unchanged. Publishing the updated branch remains blocked by GitHub's previously reported missing workflow scope, because the new base includes upstream workflow history. I have retained the tested local commit and will not force an unverified update. Synthetic inputs only. AI-assisted (Codex). |
The checker previously created shader modules before consulting device compatibility, allowing validation errors for shaders it would later skip. Check file open and module size first, then apply the existing feature gate before module creation. Missing, empty, undersized and unaligned files remain module failures instead of successful skips.
The synthetic regression uses a descriptor-free supported compute shader and an unsupported metadata entry. Instance-creation failures now print their VkResult while retaining exit 1. Both GPU tests skip only recognized unavailable-loader/driver/device diagnostics; out-of-memory, initialization errors, an explicitly unmatched LEONIDA_VK_DEVICE filter and real module failures remain failures.
Claim: #4683 (comment)
Validation at 18d0bc0 on Windows 11, RTX 5060, NVIDIA 610.88, MSVC 19.44, RelWithDebInfo, Khronos validation 1.4.363.0:
Independent Intel confirmation and fixture suggestion: #4796 (comment). Availability diagnostic/helper follow-up adapted from @l-CatDemon-l's suggested patch, preserving explicit device-filter errors: #4796 (comment).
Integration with #3045 / #3187: preserve file-open and module-size validation first, then retain both this PR's feature gate and that stack's sampled/storage dynamic-indexing guard before shader module creation. Remove the superseded post-module checks so entries are counted once. Dry-merge finding: #4683 (comment). #4811's descriptor sizing is independent.
AI-assisted (Codex). Synthetic inputs only; no game files.