mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-11 19:11:08 +00:00
The chain copy that clears the emulated textureCompressionBC only knew a handful of structure sizes, so a valid chain such as VkPhysicalDeviceTimelineSemaphoreFeatures -> VkPhysicalDeviceFeatures2 was passed on unchanged and the compat layer refused the bit. Size every structure that may extend VkDeviceCreateInfo from a table generated from the Vulkan registry (gen_device_chain.py, Vulkan-Headers 1.3.275, the headers the build compiles with), and copy onto the heap instead of a fixed buffer. Only a structure newer than those headers still passes the chain unchanged. Add a regression test that runs the layer between a simulated loader and a mock driver: the timeline-semaphore chain, pEnabledFeatures, an unknown structure, the caller's structures left untouched, per-device YCbCr sampler tracking with handle reuse, and the KHR calibrated-timestamp forwarding. CI installs libvulkan-dev for it.
48 lines
2.4 KiB
Python
48 lines
2.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
TOOLS = Path(__file__).resolve().parents[1]
|
|
LAYER = TOOLS / "linuxfs/xclipse-layer"
|
|
|
|
|
|
class XclipseLayerTest(unittest.TestCase):
|
|
def test_layer_against_a_mock_loader_and_driver(self):
|
|
compiler = shutil.which(os.environ.get("CC", "cc"))
|
|
if not compiler:
|
|
self.fail("A C compiler is required for the Xclipse layer regression test")
|
|
# The build compiles the layer against the distribution's headers (libvulkan-dev);
|
|
# VULKAN_INCLUDE points elsewhere, e.g. a Vulkan-Headers checkout on macOS.
|
|
include = Path(os.environ.get("VULKAN_INCLUDE", "/usr/include"))
|
|
if not (include / "vulkan/vk_layer.h").is_file():
|
|
self.fail("Vulkan headers are required: install libvulkan-dev or set VULKAN_INCLUDE")
|
|
with tempfile.TemporaryDirectory(prefix="droiddeck-xclipse-") as tmp:
|
|
program = Path(tmp) / "xclipse-layer"
|
|
built = subprocess.run([compiler, "-std=gnu11", "-Wall", "-Wextra", "-Werror", "-Wno-unused-parameter",
|
|
"-UNDEBUG", "-pthread", "-I", str(LAYER), "-I", str(include),
|
|
str(Path(__file__).with_name("xclipse_layer_test.c")), "-ldl", "-o", str(program)],
|
|
capture_output=True, text=True)
|
|
self.assertEqual(built.returncode, 0, built.stdout + built.stderr)
|
|
ran = subprocess.run([str(program)], capture_output=True, text=True, timeout=30)
|
|
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
|
|
self.assertIn("xclipse layer ok", ran.stdout)
|
|
|
|
def test_device_chain_table_matches_its_generator(self):
|
|
registry = os.environ.get("VULKAN_REGISTRY")
|
|
if not registry:
|
|
self.skipTest("set VULKAN_REGISTRY to a Vulkan-Headers 1.3.275 checkout to recheck device_chain.inc")
|
|
with tempfile.TemporaryDirectory(prefix="droiddeck-chain-") as tmp:
|
|
output = Path(tmp) / "device_chain.inc"
|
|
subprocess.run(["python3", str(LAYER / "gen_device_chain.py"), str(Path(registry) / "registry/vk.xml"),
|
|
str(Path(registry) / "include/vulkan/vulkan_core.h"), str(output)],
|
|
check=True, capture_output=True)
|
|
self.assertEqual(output.read_text(), (LAYER / "device_chain.inc").read_text())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|