mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
Only save the browser's OpenGL check when the driver file can be read
Without a readable driver file every check got the same key, so one saved answer was reused for any driver. Now nothing is saved or read back in that case, the cache falls back to ~/.cache when XDG_CACHE_HOME is unset, and the browser gate test runs with its own cache and covers the saved answer.
This commit is contained in:
1 parent
409c871a03
commit
d404de54c4
2 files changed
+36
-7
No files matched your search
@@ -316,15 +316,15 @@ fi
|
||||
# glxinfo starts the driver through libhybris (up to 15 s), so the version is saved per driver file and bridge build.
|
||||
bl_qualcomm_browser_gpu() {
|
||||
[ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ] && [ -z "${BL_STEAM_CEF_SOFTWARE+x}" ] || return 0
|
||||
local gl key saved_key saved= cache=$XDG_CACHE_HOME/droiddeck/qualcomm-gl
|
||||
key=$({ sha256sum "${HYBRIS_VULKAN_HAL:-/vendor/lib64/hw/vulkan.adreno.so}" &&
|
||||
printf '%s\n' "${DROIDDECK_QUALCOMM_DRIVER:-}" "${DROIDDECK_QUALCOMM_ROOT:-}"; } 2>/dev/null |
|
||||
sha256sum | cut -c1-32)
|
||||
if read -r saved_key gl 2>/dev/null < "$cache" && [ "$saved_key" = "$key" ] && [ -n "$gl" ]; then
|
||||
local gl hal key= saved_key saved= cache=${XDG_CACHE_HOME:-$HOME/.cache}/droiddeck/qualcomm-gl
|
||||
# No key, no saved answer: an unreadable driver file is checked every time.
|
||||
hal=$(sha256sum "${HYBRIS_VULKAN_HAL:-/vendor/lib64/hw/vulkan.adreno.so}" 2>/dev/null) &&
|
||||
key=$(printf '%s\n' "${hal%% *}" "${DROIDDECK_QUALCOMM_DRIVER:-}" "${DROIDDECK_QUALCOMM_ROOT:-}" | sha256sum | cut -c1-32)
|
||||
if [ -n "$key" ] && read -r saved_key gl 2>/dev/null < "$cache" && [ "$saved_key" = "$key" ] && [ -n "$gl" ]; then
|
||||
saved="; saved earlier"
|
||||
else
|
||||
gl=$(timeout 15 glxinfo -B 2>/dev/null | sed -n 's/^ *Max core profile version: *\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -1)
|
||||
[ -z "$gl" ] || { mkdir -p "${cache%/*}" && printf '%s %s\n' "$key" "$gl" > "$cache"; } 2>/dev/null
|
||||
[ -z "$gl" ] || [ -z "$key" ] || { mkdir -p "${cache%/*}" && printf '%s %s\n' "$key" "$gl" > "$cache"; } 2>/dev/null
|
||||
fi
|
||||
if [ "${gl%%.*}" -ge 4 ] 2>/dev/null; then
|
||||
echo "== steam: browser GPU compositing on (Zink OpenGL $gl$saved)"
|
||||
|
||||
@@ -9,11 +9,19 @@ GATE = SESSION[SESSION.index("bl_qualcomm_browser_gpu() {"):SESSION.index("reap_
|
||||
|
||||
|
||||
class QualcommBrowserTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
cache = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(cache.cleanup)
|
||||
self.cache = cache.name
|
||||
|
||||
def gate(self, glxinfo=None, **extra):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
env = dict(os.environ)
|
||||
for name in ("DROIDDECK_SYSTEM_QUALCOMM", "BL_STEAM_CEF_SOFTWARE"):
|
||||
for name in ("DROIDDECK_SYSTEM_QUALCOMM", "BL_STEAM_CEF_SOFTWARE", "HYBRIS_VULKAN_HAL",
|
||||
"DROIDDECK_QUALCOMM_DRIVER", "DROIDDECK_QUALCOMM_ROOT"):
|
||||
env.pop(name, None)
|
||||
env["XDG_CACHE_HOME"] = self.cache
|
||||
env["HYBRIS_VULKAN_HAL"] = str(Path(self.cache) / "missing-driver.so")
|
||||
if glxinfo is not None:
|
||||
stub = Path(directory) / "glxinfo"
|
||||
stub.write_text("#!/bin/sh\necho 'touched' > \"$0.ran\"\n" + glxinfo, newline="\n")
|
||||
@@ -49,6 +57,27 @@ class QualcommBrowserTest(unittest.TestCase):
|
||||
self.assertEqual(out, "rc=0")
|
||||
self.assertFalse(ran)
|
||||
|
||||
def test_the_version_is_saved_per_driver_file_and_bridge(self):
|
||||
hal = Path(self.cache) / "vulkan.adreno.so"
|
||||
hal.write_bytes(b"driver one")
|
||||
probe = "printf ' Max core profile version: 4.6\\n'\n"
|
||||
env = dict(DROIDDECK_SYSTEM_QUALCOMM="1", HYBRIS_VULKAN_HAL=str(hal), DROIDDECK_QUALCOMM_ROOT="/r1")
|
||||
self.assertEqual(self.gate(probe, **env), ("== steam: browser GPU compositing on (Zink OpenGL 4.6)\nrc=0", True))
|
||||
self.assertEqual(self.gate(probe, **env),
|
||||
("== steam: browser GPU compositing on (Zink OpenGL 4.6; saved earlier)\nrc=0", False))
|
||||
self.assertTrue(self.gate(probe, **dict(env, DROIDDECK_QUALCOMM_ROOT="/r2"))[1])
|
||||
hal.write_bytes(b"driver two")
|
||||
self.assertTrue(self.gate(probe, **dict(env, DROIDDECK_QUALCOMM_ROOT="/r2"))[1])
|
||||
|
||||
def test_unreadable_drivers_and_failed_probes_are_not_saved(self):
|
||||
probe = "printf ' Max core profile version: 4.6\\n'\n"
|
||||
self.assertTrue(self.gate(probe, DROIDDECK_SYSTEM_QUALCOMM="1")[1])
|
||||
self.assertTrue(self.gate(probe, DROIDDECK_SYSTEM_QUALCOMM="1")[1])
|
||||
hal = Path(self.cache) / "vulkan.adreno.so"
|
||||
hal.write_bytes(b"driver")
|
||||
self.assertIn("OpenGL unknown", self.gate("exit 1\n", DROIDDECK_SYSTEM_QUALCOMM="1", HYBRIS_VULKAN_HAL=str(hal))[0])
|
||||
self.assertTrue(self.gate(probe, DROIDDECK_SYSTEM_QUALCOMM="1", HYBRIS_VULKAN_HAL=str(hal))[1])
|
||||
|
||||
def test_the_steam_launch_applies_the_gate(self):
|
||||
self.assertIn("bl_qualcomm_browser_gpu || steam_cef_gpu=0", SESSION)
|
||||
|
||||
|
||||
Reference in new issue
Block a user