mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +00:00
Merge #570 (PowerVR + Xclipse system Vulkan) into the non-Adreno test branch
# Conflicts: # .github/workflows/build.yml # app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt # app/src/main/java/com/droiddeck/launcher/session/SessionService.kt # tools/build_local.sh # tools/dxvk/build.sh # tools/linuxfs/overlay/usr/local/bin/droiddeck-session # tools/release/runtime_inputs.py # tools/tests/test_runtime_inputs.py
This commit is contained in:
commit
56dc433673
104 files changed
+7206
-206
No files matched your search
@@ -8,6 +8,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin"
|
||||
MODULE = runpy.run_path(str(BIN / "droiddeck-game-env"))
|
||||
@@ -26,6 +27,137 @@ def config_text(entries):
|
||||
return '"InstallConfigStore" { "Software" { "Valve" { "Steam" { "CompatToolMapping" { %s } } } } }' % mapping
|
||||
|
||||
|
||||
class SystemGraphicsLaunchTest(unittest.TestCase):
|
||||
def runtime(self, root):
|
||||
runtime = root / "system_vulkan" / ("a" * 64)
|
||||
files = ["run-proton.py", "lib/libVkLayer_hybris_compat.so",
|
||||
"wsi/libVkLayer_window_system_integration.so",
|
||||
"wsi/VkLayer_window_system_integration.json"]
|
||||
files += ["dxvk/%s/%s.dll" % (arch, name) for arch in ("x32", "x64")
|
||||
for name in ("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi")]
|
||||
for name in files:
|
||||
target = runtime / name
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_bytes(b"component")
|
||||
(runtime / "run-proton.py").chmod(0o755)
|
||||
return runtime, files
|
||||
|
||||
def test_other_gpus_and_non_game_calls_keep_the_original_launch(self):
|
||||
command = ["/proton", "waitforexitandrun", "game.exe"]
|
||||
base = {"STEAM_COMPAT_DATA_PATH": "/compatdata/42", "VK_LAYER_PATH": "original"}
|
||||
selected = dict(base, DROIDDECK_POWERVR_RUNTIME="/not-installed")
|
||||
cases = [(command, base), (command, dict(selected, STEAM_COMPAT_DATA_PATH="/compatdata/0")),
|
||||
(command, dict(selected, STEAM_COMPAT_DATA_PATH="/compatdata/invalid")),
|
||||
(["/proton", "run", "iscriptevaluator.exe"], selected),
|
||||
(["/proton", "getcompatpath", "x"], selected), (command[:2], selected)]
|
||||
for args, env in cases:
|
||||
with self.subTest(args=args, env=env):
|
||||
actual, inherited = MODULE["system_graphics_launch"](args, env)
|
||||
self.assertIs(actual, args)
|
||||
self.assertIs(inherited, env)
|
||||
|
||||
def test_system_graphics_follow_game_configuration_and_preserve_other_keys(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
runtime, _ = self.runtime(Path(tmp))
|
||||
base = {"DROIDDECK_POWERVR_RUNTIME": str(runtime), "STEAM_COMPAT_DATA_PATH": "/compatdata/42"}
|
||||
config = {"version": 1, "games": {"42": {
|
||||
"PROTON_USE_WINED3D": "1", "DISABLE_WSI_LAYER": "1",
|
||||
"ENABLE_VK_LAYER_VALVE_steam_fossilize_1": "1", "HYBRIS_BC_TEXTURES": "0",
|
||||
"VK_LAYER_PATH": "old", "VK_INSTANCE_LAYERS": "old", "ENABLE_GAMESCOPE_WSI": "1",
|
||||
"FEX_TSOENABLED": "1", "WINESERVER": "/selected/wineserver", "CUSTOM": "literal $value",
|
||||
}}}
|
||||
env = MODULE["apply_config"](base, config, "42")
|
||||
command = ["/selected/proton", "waitforexitandrun", "game with spaces.exe"]
|
||||
launch, result = MODULE["system_graphics_launch"](command, env)
|
||||
self.assertEqual(launch, [str(runtime / "run-proton.py"), *command])
|
||||
self.assertEqual(result["HYBRIS_BC_TEXTURES"], "dxvk")
|
||||
self.assertEqual(result["VK_LAYER_PATH"], f"{runtime}/wsi:{runtime}/lib")
|
||||
self.assertEqual(result["VK_INSTANCE_LAYERS"], "VK_LAYER_window_system_integration:VK_LAYER_HYBRIS_compat")
|
||||
self.assertEqual(result["VK_LOADER_LAYERS_DISABLE"], "*gamescope*")
|
||||
self.assertEqual(result["ENABLE_GAMESCOPE_WSI"], "0")
|
||||
self.assertEqual(result["DISABLE_VK_LAYER_VALVE_steam_fossilize_1"], "1")
|
||||
for key in ("PROTON_USE_WINED3D", "DISABLE_WSI_LAYER", "ENABLE_VK_LAYER_VALVE_steam_fossilize_1"):
|
||||
self.assertNotIn(key, result)
|
||||
self.assertIn(key, env)
|
||||
for key in ("FEX_TSOENABLED", "WINESERVER", "CUSTOM"):
|
||||
self.assertEqual(result[key], env[key])
|
||||
|
||||
def test_xclipse_selection_adds_its_layers_layer_path_and_dxvk_payload(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
runtime, _ = self.runtime(Path(tmp))
|
||||
env = {"DROIDDECK_POWERVR_RUNTIME": str(runtime), "STEAM_COMPAT_DATA_PATH": "/compatdata/42",
|
||||
"DROIDDECK_HYBRIS_LAYERS": "VK_LAYER_DROIDDECK_xclipse:VK_LAYER_HYBRIS_compat",
|
||||
"DROIDDECK_HYBRIS_LAYER_PATH": "/usr/local/lib/droiddeck-xclipse",
|
||||
"DROIDDECK_HYBRIS_DXVK": "dxvk-2.6.2"}
|
||||
command = ["/proton", "waitforexitandrun", "game.exe"]
|
||||
# The selected payload is required like the default one.
|
||||
with self.assertRaises(MODULE["SystemGraphicsError"]):
|
||||
MODULE["system_graphics_launch"](command, env)
|
||||
for arch in ("x32", "x64"):
|
||||
for name in ("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi"):
|
||||
target = runtime / "dxvk-2.6.2" / arch / (name + ".dll")
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_bytes(b"component")
|
||||
launch, result = MODULE["system_graphics_launch"](command, env)
|
||||
self.assertEqual(launch, [str(runtime / "run-proton.py"), *command])
|
||||
self.assertEqual(result["VK_INSTANCE_LAYERS"],
|
||||
"VK_LAYER_window_system_integration:VK_LAYER_DROIDDECK_xclipse:VK_LAYER_HYBRIS_compat")
|
||||
self.assertEqual(result["VK_LAYER_PATH"], f"{runtime}/wsi:{runtime}/lib:/usr/local/lib/droiddeck-xclipse")
|
||||
self.assertEqual(result["DROIDDECK_HYBRIS_DXVK"], "dxvk-2.6.2")
|
||||
for name in ("../dxvk", "other", "dxvk/x"):
|
||||
with self.subTest(name=name), self.assertRaises(MODULE["SystemGraphicsError"]):
|
||||
MODULE["system_graphics_launch"](command, dict(env, DROIDDECK_HYBRIS_DXVK=name))
|
||||
|
||||
def test_incomplete_runtime_fails_before_any_proton_exec(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
runtime, files = self.runtime(Path(tmp))
|
||||
env = {"DROIDDECK_POWERVR_RUNTIME": str(runtime), "STEAM_COMPAT_DATA_PATH": "/compatdata/42"}
|
||||
command = ["/proton", "waitforexitandrun", "game.exe"]
|
||||
for name in files:
|
||||
target = runtime / name
|
||||
original = target.read_bytes()
|
||||
for missing in (False, True):
|
||||
with self.subTest(name=name, missing=missing):
|
||||
target.unlink() if missing else target.write_bytes(b"")
|
||||
with patch.object(os, "execvpe") as execute:
|
||||
with self.assertRaises(MODULE["SystemGraphicsError"]):
|
||||
MODULE["exec_proton"](command, env)
|
||||
execute.assert_not_called()
|
||||
target.write_bytes(original)
|
||||
if name == "run-proton.py":
|
||||
target.chmod(0o755)
|
||||
(runtime / "run-proton.py").chmod(0o644)
|
||||
with self.assertRaises(MODULE["SystemGraphicsError"]):
|
||||
MODULE["system_graphics_launch"](command, env)
|
||||
with self.assertRaises(MODULE["SystemGraphicsError"]):
|
||||
MODULE["system_graphics_launch"](command, dict(env, DROIDDECK_POWERVR_RUNTIME="relative"))
|
||||
|
||||
def test_wrapper_receives_the_sync_selected_proton(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
runtime, _ = self.runtime(root)
|
||||
env = {"HOME": tmp, "DROIDDECK_POWERVR_RUNTIME": str(runtime),
|
||||
"STEAM_COMPAT_DATA_PATH": "/compatdata/42"}
|
||||
command = ["/stock/proton", "waitforexitandrun", "game.exe"]
|
||||
selected = ["/sync-pack/proton", *command[1:]]
|
||||
selected_env = dict(env, WINESERVER="/sync-pack/wineserver", BL_SYNC_PACK="selected")
|
||||
main = MODULE["main"]
|
||||
with patch.dict(os.environ, env, clear=True), patch.object(sys, "argv", ["game-env", *command]), \
|
||||
patch.dict(main.__globals__, {"load_sync": lambda: {},
|
||||
"select_sync": lambda *args: (selected, selected_env),
|
||||
"win_components": lambda *args: ""}), \
|
||||
patch.object(os, "execvpe", side_effect=SystemExit(23)) as execute:
|
||||
with self.assertRaises(SystemExit) as stopped:
|
||||
main()
|
||||
self.assertEqual(stopped.exception.code, 23)
|
||||
execute.assert_called_once()
|
||||
path, args, actual_env = execute.call_args.args
|
||||
self.assertEqual(path, str(runtime / "run-proton.py"))
|
||||
self.assertEqual(args, [path, *selected])
|
||||
self.assertEqual(actual_env["WINESERVER"], "/sync-pack/wineserver")
|
||||
self.assertEqual(actual_env["BL_SYNC_PACK"], "selected")
|
||||
|
||||
|
||||
class GameEnvironmentTest(unittest.TestCase):
|
||||
def test_the_install_script_evaluator_gets_its_scripts_marked_first(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -87,6 +219,55 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
|
||||
self.assertEqual(target.read_text(), "general")
|
||||
|
||||
def test_system_powervr_preserves_dxvk_profiles_without_applying_them(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
home = root / "home"
|
||||
component_dir = home / ".local/share/droiddeck-components"
|
||||
component_dir.mkdir(parents=True)
|
||||
base = root / "proton"
|
||||
paths = {
|
||||
"dxvk": "files/lib/wine/dxvk/aarch64-windows/d3d11.dll",
|
||||
"fex": "files/lib/wine/aarch64-windows/libarm64ecfex.dll",
|
||||
"vkd3d": "files/lib/wine/vkd3d-proton/aarch64-windows/d3d12.dll",
|
||||
}
|
||||
rows = []
|
||||
for comp, rel in paths.items():
|
||||
target = base / rel
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
target.write_text("bundled " + comp)
|
||||
for scope in ("*", "42"):
|
||||
source = root / (comp + ("-general" if scope == "*" else "-game"))
|
||||
source.write_text(source.name)
|
||||
rows.append("%s\tproton\tbuild-1\t%s\t%s\t%s\t%s\n" % (
|
||||
scope, comp, rel, hashlib.sha256(source.read_bytes()).hexdigest(), source,
|
||||
))
|
||||
leftover = (base / paths["dxvk"]).with_name("d3d8.dll")
|
||||
leftover.write_text("bundled d3d8")
|
||||
rows.append("42\tproton\tbuild-1\tdxvk\t%s\t-\t-\n" % leftover.relative_to(base))
|
||||
(base / "version").write_text("1 build-1\n")
|
||||
selection = component_dir / "desired.tsv"
|
||||
selection.write_text("".join(rows))
|
||||
saved = selection.read_bytes()
|
||||
script = COMPAT["BL_COMPONENTS_SETUP"] + '\nverb=waitforexitandrun; bl_components "$1"\n'
|
||||
env = dict(os.environ, HOME=str(home), STEAM_COMPAT_DATA_PATH="/steam/compatdata/42",
|
||||
DROIDDECK_POWERVR_RUNTIME="/system_vulkan/runtime")
|
||||
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
|
||||
|
||||
self.assertEqual((base / paths["dxvk"]).read_text(), "bundled dxvk")
|
||||
self.assertEqual(leftover.read_text(), "bundled d3d8")
|
||||
for comp in ("fex", "vkd3d"):
|
||||
self.assertEqual((base / paths[comp]).read_text(), comp + "-game")
|
||||
self.assertEqual(selection.read_bytes(), saved)
|
||||
|
||||
# A subsequent manual-driver session still applies the saved per-game DXVK choice.
|
||||
env.pop("DROIDDECK_POWERVR_RUNTIME")
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
|
||||
self.assertEqual((base / paths["dxvk"]).read_text(), "dxvk-game")
|
||||
self.assertFalse(leftover.exists())
|
||||
self.assertEqual(selection.read_bytes(), saved)
|
||||
|
||||
def test_component_scope_matches_environment_scope_for_shortcut_ids(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
|
||||
Reference in new issue
Block a user