Merge upstream main while preserving PowerVR integration

This commit is contained in:
wallentx committed 2026-10-11 19:30:00 -05:00
commit bf033f2f11
108 files changed
+9859 -2070

No files matched your search

+217
View File
@@ -1,3 +1,4 @@
import hashlib
import json
import os
import shutil
@@ -158,6 +159,121 @@ class GameEnvironmentTest(unittest.TestCase):
self.assertEqual(env["REMOVE"], "inherited")
self.assertEqual(MODULE["apply_config"](env, config, "43")["CUSTOM"], "shared")
def test_component_profiles_override_general_and_restore_it_for_the_next_game(self):
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
home = root / "home"
component_dir = home / ".local/share/droiddeck-components"
base = root / "proton"
target = base / "files/lib/wine/dxvk/aarch64-windows/d3d11.dll"
leftover = target.with_name("d3d8.dll")
component_dir.mkdir(parents=True)
target.parent.mkdir(parents=True)
(base / "version").write_text("1 build-1\n")
general = root / "general.dll"
game = root / "game.dll"
general.write_text("general")
game.write_text("game")
target.write_text("old")
leftover.write_text("old")
digest = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
(component_dir / "desired.tsv").write_text(
"*\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d11.dll\t%s\t%s\n"
"42\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d11.dll\t%s\t%s\n"
"42\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d8.dll\t-\t-\n"
% (digest(general), general, digest(game), game)
)
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")
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
self.assertEqual(target.read_text(), "game")
self.assertFalse(leftover.exists())
env["STEAM_COMPAT_DATA_PATH"] = "/steam/compatdata/43"
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)
component_dir = root / ".local/share/droiddeck-components"
base = root / "proton"
target = base / "files/lib/wine/dxvk/aarch64-windows/d3d11.dll"
component_dir.mkdir(parents=True)
target.parent.mkdir(parents=True)
(base / "version").write_text("1 build-1\n")
rows = []
for scope in ("*", "42", "4294967295", "2147483648"):
source = root / ("default" if scope == "*" else scope)
source.write_text(scope)
rows.append("%s\tproton\tbuild-1\tdxvk\t%s\t%s\t%s\n" % (
scope, target.relative_to(base),
hashlib.sha256(source.read_bytes()).hexdigest(), source,
))
(component_dir / "desired.tsv").write_text("".join(rows))
script = COMPAT["BL_COMPONENTS_SETUP"] + '\nverb=waitforexitandrun; bl_components "$1"\n'
for value in (
"42", "00042", "43", "-1", "-0001", "4294967295", "-2147483648",
"2147483648", "-1///", "0", "-0", "000", "-2147483649", "4294967296",
"999999999999999999999999999", "not-an-id", "1+1", "",
):
with self.subTest(prefix=value):
env = dict(os.environ, HOME=str(root), STEAM_COMPAT_DATA_PATH="/steam/compatdata/" + value)
target.write_text("untouched")
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True, capture_output=True)
scope = MODULE["game_id"](env)
expected = "untouched" if scope is None else scope if scope in {"42", "4294967295", "2147483648"} else "*"
self.assertEqual(target.read_text(), expected)
def test_engine_fixes_follow_the_games_files(self):
with tempfile.TemporaryDirectory() as tmp:
game = Path(tmp) / "Godot Game"
@@ -215,6 +331,22 @@ class GameEnvironmentTest(unittest.TestCase):
with self.assertRaises(ValueError):
MODULE["apply_config"]({}, {**config, "dxvkConfig": bad}, "42")
def test_game_texture_filtering_overrides_default_without_leaking(self):
default = "d3d9.samplerAnisotropy = 16"
game = "d3d9.samplerAnisotropy = 4"
config = {
"version": 1,
"shared": {},
"games": {},
"dxvkConfig": default,
"dxvkConfigGames": {"42": game, "43": ""},
}
self.assertEqual(MODULE["apply_config"]({}, config, "42")["DXVK_CONFIG"], game)
self.assertNotIn("DXVK_CONFIG", MODULE["apply_config"]({}, config, "43"))
self.assertEqual(MODULE["apply_config"]({}, config, "44")["DXVK_CONFIG"], default)
with self.assertRaises(ValueError):
MODULE["apply_config"]({}, {**config, "dxvkConfigGames": []}, "42")
def test_game_ids_and_probes(self):
for prefix in ("", "/compatdata/0", "/compatdata/0-123", "/compatdata/nope", "/compatdata/4294967296"):
self.assertIsNone(MODULE["game_id"]({"STEAM_COMPAT_DATA_PATH": prefix}))
@@ -363,6 +495,40 @@ class GameEnvironmentTest(unittest.TestCase):
self.assertIn('"$here/proton"', (extra / COMPAT["EXTRA_WRAPPER"]).read_text())
self.assertIn("GE-Proton11-7", [entry["name"] for entry in COMPAT["tool_catalog"](str(home), None)])
def test_droiddeck_proton_is_adopted_and_labelled_like_any_other_extra(self):
# Its folder has a space ("DroidDeck-Proton 11-7.5") and its internal name starts with
# "DroidDeck-Proton-", which lower-cases to our own tools' prefix: neither may matter.
with tempfile.TemporaryDirectory() as tmp:
home = Path(tmp)
(home / "label").write_text("Compatible\n")
COMPAT["display_name"].__globals__["LABEL_FILE"] = str(home / "label")
tools = home / "compatibilitytools.d"
extra = tools / "DroidDeck-Proton 11-7.5"
extra.mkdir(parents=True)
(extra / "proton").write_text("")
(extra / "toolmanifest.vdf").write_text('"manifest" { "version" "2" "commandline" "/proton %verb%" "require_tool_appid" "4185400" }')
(extra / "compatibilitytool.vdf").write_text(
'"compatibilitytools" { "compat_tools" { "DroidDeck-Proton-11-7.5" { "install_path" "." '
'"display_name" "DroidDeck-Proton 11-7.5" "from_oslist" "windows" "to_oslist" "linux" } } }')
COMPAT["build_tool"](str(tools / COMPAT["TOOL"]), None)
protect = COMPAT["adopt_extras"](str(tools))
self.assertEqual(protect, {"DroidDeck-Proton-11-7.5": "DroidDeck-Proton 11-7.5"})
compat = (extra / "compatibilitytool.vdf").read_text()
self.assertIn('"DroidDeck-Proton-11-7.5"', compat)
self.assertIn('"display_name" "DroidDeck-Proton 11-7.5 (Compatible)"', compat)
self.assertNotIn("require_tool_appid", (extra / "toolmanifest.vdf").read_text())
self.assertIn('"$here/proton"', (extra / COMPAT["EXTRA_WRAPPER"]).read_text())
catalog = COMPAT["tool_catalog"](str(home), None)
self.assertIn({"name": "DroidDeck-Proton-11-7.5", "display": "DroidDeck-Proton 11-7.5 (Compatible)",
"dir": "DroidDeck-Proton 11-7.5", "valve": False}, catalog)
config = home / "config.vdf"
config.write_text(config_text([("0", COMPAT["TOOL"]), ("42", "DroidDeck-Proton-11-7.5")]))
COMPAT["register_default"](str(config), ["42", "43"], protect=protect)
self.assertEqual(mapping_of(config.read_text()), {"0": COMPAT["TOOL"], "42": "DroidDeck-Proton-11-7.5", "43": COMPAT["TOOL"]})
# Once removed it is no longer runnable, and its games go back to the default.
changes, _ = COMPAT["plan_mapping"]({"0": COMPAT["TOOL"], "42": "DroidDeck-Proton-11-7.5"}, ["42"], [COMPAT["TOOL"]], COMPAT["TOOL"], {})
self.assertEqual(changes, {"42": COMPAT["TOOL"]})
def test_both_proton_wrappers_call_environment_launcher(self):
for script in (COMPAT["LAUNCHER_SH"], COMPAT["EXTRA_WRAPPER_SH"] % "proton"):
subprocess.run(["bash", "-n"], input=script, text=True, check=True)
@@ -425,6 +591,57 @@ class ProtonDefaultTest(unittest.TestCase):
changes, auto = self.plan({"0": self.TOOL}, [], self.TOOL, {"10": self.TOOL})
self.assertEqual((changes, auto), ({}, {}))
def test_per_game_proton_override_and_inherit_follow_steam_mappings(self):
current = {"0": self.TOOL, "10": self.TOOL, "11": "GE-Proton11-7", "12": self.TOOL}
overrides = {"10": "GE-Proton11-7", "11": None}
changes, auto = COMPAT["plan_mapping"](
current, ["10", "11", "12"], self.NAMES, COMPAT["TOOL_11"],
{"10": self.TOOL, "12": self.TOOL}, overrides=overrides)
self.assertEqual(changes, {"0": COMPAT["TOOL_11"], "10": "GE-Proton11-7", "11": COMPAT["TOOL_11"], "12": COMPAT["TOOL_11"]})
self.assertEqual(auto, {"11": COMPAT["TOOL_11"], "12": COMPAT["TOOL_11"]})
def test_per_game_requests_resolve_identity_and_defer_a_new_live_tool(self):
requests = {
"10": {"valve": False, "dir": "GE-Proton11-7"},
"11": None,
"12": {"valve": True, "dir": "Proton 11.0 (ARM64)"},
"0": None,
}
self.assertEqual(
COMPAT["requested_games"](requests, self.CATALOG),
{"10": "GE-Proton11-7", "11": None, "12": COMPAT["TOOL_11"]},
)
self.assertEqual(
COMPAT["requested_games"](requests, self.CATALOG, [self.TOOL, COMPAT["TOOL_11"]]),
{"10": COMPAT["DEFERRED_GAME_TOOL"], "11": None, "12": COMPAT["TOOL_11"]},
)
def test_missing_per_game_proton_is_preserved_during_default_registration(self):
with tempfile.TemporaryDirectory() as tmp:
config = Path(tmp) / "config.vdf"
config.write_text(config_text([
("0", self.TOOL),
("10", "GE-Proton9-1"),
("11", self.TOOL),
]))
(Path(tmp) / "games.json").write_text(json.dumps({
"version": 1,
"games": {
"10": {"valve": False, "dir": "GE-Proton9-1"},
},
}))
COMPAT["register_default"](
str(config), ["10", "11"], default=COMPAT["TOOL_11"],
catalog=self.CATALOG, directory=tmp,
)
self.assertEqual(mapping_of(config.read_text()), {
"0": COMPAT["TOOL_11"],
"10": "GE-Proton9-1",
"11": COMPAT["TOOL_11"],
})
def test_the_last_side_to_change_wins(self):
state = {"default": self.TOOL, "applied": 5}
default, state = COMPAT["choose_default"]("GE-Proton11-7", state, {"seq": 5, "dir": "Proton 11.0 (ARM64)", "valve": True}, self.CATALOG, now=100)