mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
Save the Qualcomm capability checks between sessions
Every Qualcomm session started the driver through libhybris twice before Steam: droiddeck-qualcomm-caps (up to 20 s) and glxinfo for the browser's OpenGL level (up to 15 s). Both answers only change with the driver, so they are now saved under $XDG_CACHE_HOME/droiddeck and reused while the driver file (SHA-256), the selected driver, the bridge build, the layers and the check script are unchanged. Gamescope's linux-dmabuf global is still checked every session, failed or empty results are never saved, and the log marks a reused result.
This commit is contained in:
1 parent
563dff6d75
commit
dfce775514
4 files changed
+146
-11
No files matched your search
@@ -1,9 +1,13 @@
|
||||
from pathlib import Path
|
||||
import json
|
||||
import runpy
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
CAPS = runpy.run_path(str(Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-qualcomm-caps"))
|
||||
decide = CAPS["decide"]
|
||||
cache_key = CAPS["cache_key"]
|
||||
cached_probe = CAPS["cached_probe"]
|
||||
REQUIRED = set(CAPS["REQUIRED"])
|
||||
CAPABLE = {"extensions": REQUIRED | {"VK_EXT_image_drm_format_modifier"}, "linear_export": True,
|
||||
"linear_import": True, "export_fd": True, "gamescope_dmabuf": True}
|
||||
@@ -35,5 +39,72 @@ class QualcommCapsTest(unittest.TestCase):
|
||||
self.assertFalse(decide({})[0])
|
||||
|
||||
|
||||
|
||||
class QualcommCapsCacheTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dir = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.dir.cleanup)
|
||||
root = Path(self.dir.name)
|
||||
self.hal = root / "vulkan.adreno.so"
|
||||
self.hal.write_bytes(b"driver one")
|
||||
self.script = root / "caps"
|
||||
self.script.write_text("checks")
|
||||
self.path = str(root / "cache/qualcomm-caps.json")
|
||||
self.env = {"HYBRIS_VULKAN_HAL": str(self.hal), "DROIDDECK_QUALCOMM_DRIVER": "system-qualcomm",
|
||||
"DROIDDECK_QUALCOMM_ROOT": "/data/qualcomm-system/abc"}
|
||||
self.probes = 0
|
||||
globals_ = cached_probe.__globals__
|
||||
original = globals_["probe"]
|
||||
self.addCleanup(globals_.__setitem__, "probe", original)
|
||||
globals_["probe"] = self.fake_probe
|
||||
|
||||
def fake_probe(self):
|
||||
self.probes += 1
|
||||
return {"device": "Adreno (TM) 750", "driver": "0.762.24", "extensions": set(REQUIRED),
|
||||
"linear_export": True, "linear_import": True, "export_fd": True}
|
||||
|
||||
def key(self, **changes):
|
||||
return cache_key(dict(self.env, **changes), str(self.script))
|
||||
|
||||
def test_the_key_follows_the_driver_file_the_selection_and_the_checks(self):
|
||||
key = self.key()
|
||||
self.assertEqual(key, self.key())
|
||||
self.assertNotEqual(key, self.key(DROIDDECK_QUALCOMM_DRIVER="qualcomm-adrenotools:v891"))
|
||||
self.assertNotEqual(key, self.key(DROIDDECK_QUALCOMM_ROOT="/data/qualcomm-system/def"))
|
||||
self.hal.write_bytes(b"driver two")
|
||||
self.assertNotEqual(key, self.key())
|
||||
self.hal.write_bytes(b"driver one")
|
||||
self.script.write_text("new checks")
|
||||
self.assertNotEqual(key, self.key())
|
||||
self.assertIsNone(self.key(HYBRIS_VULKAN_HAL=str(self.hal) + ".missing"))
|
||||
|
||||
def test_a_saved_result_is_reused_only_for_the_same_key(self):
|
||||
caps, saved = cached_probe(self.path, self.key())
|
||||
self.assertEqual((saved, self.probes), (False, 1))
|
||||
caps, saved = cached_probe(self.path, self.key())
|
||||
self.assertEqual((saved, self.probes), (True, 1))
|
||||
self.assertEqual(caps["extensions"], set(REQUIRED))
|
||||
self.assertEqual(decide(dict(caps, gamescope_dmabuf=True)), (True, []))
|
||||
self.assertNotIn("gamescope_dmabuf", json.loads(Path(self.path).read_text())["caps"])
|
||||
_, saved = cached_probe(self.path, self.key(DROIDDECK_QUALCOMM_DRIVER="qualcomm-adrenotools:v891"))
|
||||
self.assertEqual((saved, self.probes), (False, 2))
|
||||
|
||||
def test_failed_probes_and_unreadable_drivers_are_not_saved(self):
|
||||
def failing():
|
||||
raise RuntimeError("vkCreateInstance returned -9")
|
||||
cached_probe.__globals__["probe"] = failing
|
||||
self.assertEqual(cached_probe(self.path, self.key()), ({"error": "vkCreateInstance returned -9"}, False))
|
||||
self.assertFalse(Path(self.path).exists())
|
||||
cached_probe.__globals__["probe"] = self.fake_probe
|
||||
self.assertEqual(cached_probe(self.path, None)[1], False)
|
||||
self.assertFalse(Path(self.path).exists())
|
||||
|
||||
def test_a_damaged_saved_file_probes_again(self):
|
||||
Path(self.path).parent.mkdir(parents=True)
|
||||
Path(self.path).write_text("{not json")
|
||||
self.assertEqual(cached_probe(self.path, self.key())[1], False)
|
||||
self.assertEqual(self.probes, 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user