mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
Present Qualcomm Proton games through Gamescope's zero-copy WSI path
Games in Qualcomm sessions now hand Gamescope LINEAR DMA-BUFs exported by
the driver instead of copying frames through X11 SHM. The ARM WSI layer is
rebuilt with its Wayland backend and the private Gamescope gains a
linux-dmabuf global without a DRM device. BL_QUALCOMM_SHM=1 keeps the
shared-memory path; Turnip sessions are unchanged.
(cherry picked from commit 1bd4c04f193f48bdaf4d4aad374010abaf48765d)
(cherry picked from commit d24b824f25)
This commit is contained in:
1 parent
ceb68ade64
commit
3158933489
14 files changed
+969
-13
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import runpy
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
|
||||
COMPAT = runpy.run_path(str(BIN / "steam-compatibility"))
|
||||
SHOW = 'echo "DISABLE_GAMESCOPE_WSI=${DISABLE_GAMESCOPE_WSI-unset} WSI_X11_FORCE_SHM=${WSI_X11_FORCE_SHM-unset}"\n'
|
||||
SESSION_DEFAULT = "DISABLE_GAMESCOPE_WSI=1 WSI_X11_FORCE_SHM=1"
|
||||
|
||||
|
||||
class QualcommPresentTest(unittest.TestCase):
|
||||
def present(self, **extra):
|
||||
env = dict(os.environ, DISABLE_GAMESCOPE_WSI="1", WSI_X11_FORCE_SHM="1")
|
||||
env.pop("DROIDDECK_SYSTEM_QUALCOMM", None)
|
||||
env.pop("BL_QUALCOMM_SHM", None)
|
||||
env.update(extra)
|
||||
script = COMPAT["BL_PRESENT_SETUP"] + "\nbl_present\n" + SHOW
|
||||
return subprocess.run(["bash", "-c", script], env=env, capture_output=True, text=True, check=True).stdout.strip()
|
||||
|
||||
def test_qualcomm_games_present_through_gamescope_wsi(self):
|
||||
self.assertEqual(self.present(DROIDDECK_SYSTEM_QUALCOMM="1"), "DISABLE_GAMESCOPE_WSI=unset WSI_X11_FORCE_SHM=unset")
|
||||
|
||||
def test_turnip_sessions_and_the_shm_override_keep_the_session_default(self):
|
||||
for extra in ({}, {"DROIDDECK_SYSTEM_QUALCOMM": "0"}, {"DROIDDECK_SYSTEM_QUALCOMM": "1", "BL_QUALCOMM_SHM": "1"}):
|
||||
with self.subTest(extra=extra):
|
||||
self.assertEqual(self.present(**extra), SESSION_DEFAULT)
|
||||
|
||||
def test_every_proton_launch_selects_the_present_path(self):
|
||||
self.assertIn("bl_present()", COMPAT["LAUNCHER_SH"])
|
||||
self.assertEqual((BIN / "steam-compatibility").read_text().count("BL_LIBPATH_SETUP + BL_PRESENT_SETUP"), 2)
|
||||
for script in (COMPAT["LAUNCHER_SH"], COMPAT["EXTRA_WRAPPER_SH"] % "proton"):
|
||||
lines = [line.strip() for line in script.splitlines()]
|
||||
launches = [i for i, line in enumerate(lines) if line.startswith("bl_run") and "droiddeck-game-env" in line]
|
||||
self.assertTrue(launches)
|
||||
for index in launches:
|
||||
self.assertIn("bl_present", lines[max(0, index - 6):index])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -115,6 +115,47 @@ class QualcommRuntimeTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(FileNotFoundError, 'Build private Gamescope'):
|
||||
runtime.stage(output, cache, lock)
|
||||
|
||||
def test_built_wsi_members_come_from_the_pinned_local_build(self):
|
||||
bridge, binary, license_text, layer = b'bridge', b'gamescope', b'MIT', b'Wayland WSI layer'
|
||||
def package(members):
|
||||
output = io.BytesIO()
|
||||
with zipfile.ZipFile(output, 'w') as archive:
|
||||
for name, data in members:
|
||||
archive.writestr(name, data)
|
||||
return output.getvalue()
|
||||
gamescope_archive = package([('gamescope', binary)])
|
||||
wsi_archive = package([('LICENSE', license_text), ('layer.so', b'X11-only layer')])
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
built, cache = root / 'build/qualcomm-wsi', root / 'cache'
|
||||
built.mkdir(parents=True)
|
||||
cache.mkdir()
|
||||
(built / 'layer.so').write_bytes(layer)
|
||||
lock = self.lock(bridge)
|
||||
lock['gamescope'] = self.lock(gamescope_archive) | dict(member='gamescope', member_sha256=hashlib.sha256(binary).hexdigest())
|
||||
lock['wsi'] = self.lock(wsi_archive) | dict(build=dict(directory='build/qualcomm-wsi'), files=[
|
||||
dict(name='LICENSE', path='licenses/wsi-LICENSE', size=len(license_text), sha256=hashlib.sha256(license_text).hexdigest()),
|
||||
dict(name='layer.so', path='wsi/layer.so', size=len(layer), sha256=hashlib.sha256(layer).hexdigest(), built=True)])
|
||||
for data, entry in [(bridge, lock), (gamescope_archive, lock['gamescope']), (wsi_archive, lock['wsi'])]:
|
||||
(cache / (entry['sha256'] + '.tzst')).write_bytes(data)
|
||||
with patch.object(runtime, '__file__', str(root / 'tools/qualcomm/fetch_runtime.py')):
|
||||
output = root / 'output'
|
||||
runtime.stage(output, cache, lock)
|
||||
self.assertEqual((output / 'wsi/layer.so').read_bytes(), layer)
|
||||
self.assertEqual((output / 'licenses/wsi-LICENSE').read_bytes(), license_text)
|
||||
(built / 'layer.so').write_bytes(b'tampered layer')
|
||||
with self.assertRaisesRegex(ValueError, 'WSI member'):
|
||||
runtime.stage(root / 'tampered', cache, lock)
|
||||
(built / 'layer.so').unlink()
|
||||
with self.assertRaisesRegex(FileNotFoundError, 'build_wsi.py'):
|
||||
runtime.stage(root / 'missing', cache, lock)
|
||||
lock['wsi']['files'][1]['name'] = 'nested/layer.so'
|
||||
with self.assertRaisesRegex(ValueError, 'build member'):
|
||||
runtime.stage(root / 'nested', cache, lock)
|
||||
lock['wsi']['build']['directory'] = '../outside'
|
||||
with self.assertRaisesRegex(ValueError, 'build path'):
|
||||
runtime.stage(root / 'outside', cache, lock)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user