mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
fix(game-env): per-game DROIDDECK_GAME_TU_DEBUG reaches the game (#2781)
* fix(game-env): per-game DROIDDECK_GAME_TU_DEBUG reaches the game game_gpu() ran on the inherited environment before apply_config() added the entries from game-environment.json, so a DROIDDECK_GAME_TU_DEBUG (or DROIDDECK_GAME_MESA_NO_ERROR) set for one game was passed through unchanged and TU_DEBUG was never set. apply_config() now returns its result through game_gpu(), so a per-game value is applied the same way as one from the session. * fix(game-env): a game's own TU_DEBUG still wins over a shared prefixed one Resolve the prefixed GPU keys inside the shared entries and inside the game's entries separately, before the game's entries are laid over the shared ones. A game's plain TU_DEBUG (or its removal with null) now beats a shared DROIDDECK_GAME_TU_DEBUG, and a prefixed value set for one game still applies. * fix(game-env): keep a plain TU_DEBUG over the prefixed key in the same profile --------- Co-authored-by: zdennisz <15849186+zdennisz@users.noreply.github.com> Co-authored-by: maxjivi05 <maxjividen@gmail.com>
This commit is contained in:
2 files changed
+28
-2
No files matched your search
@@ -453,6 +453,16 @@ def game_gpu(env, keep=False):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def split_game_gpu(entries):
|
||||||
|
result = dict(entries)
|
||||||
|
for key in GAME_SPLIT_KEYS:
|
||||||
|
if GAME_PREFIX + key in result:
|
||||||
|
value = result.pop(GAME_PREFIX + key)
|
||||||
|
if key not in entries:
|
||||||
|
result[key] = None if value == "" else value
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
def vram_cap(env):
|
def vram_cap(env):
|
||||||
value = env.get("DD_VRAM_MB", "")
|
value = env.get("DD_VRAM_MB", "")
|
||||||
if not re.fullmatch(r"[1-9][0-9]{0,6}", value):
|
if not re.fullmatch(r"[1-9][0-9]{0,6}", value):
|
||||||
@@ -596,12 +606,12 @@ def apply_config(env, config, app_id, fixes=None):
|
|||||||
if config.get("version") != 1:
|
if config.get("version") != 1:
|
||||||
raise ValueError("unsupported environment configuration")
|
raise ValueError("unsupported environment configuration")
|
||||||
result = env.copy()
|
result = env.copy()
|
||||||
entries = dict(config.get("shared", {}))
|
entries = split_game_gpu(config.get("shared", {}))
|
||||||
for name, value in (fixes or {}).items():
|
for name, value in (fixes or {}).items():
|
||||||
if name == "WINEDLLOVERRIDES" and entries.get(name, env.get(name)):
|
if name == "WINEDLLOVERRIDES" and entries.get(name, env.get(name)):
|
||||||
value = entries.get(name, env.get(name)) + ";" + value
|
value = entries.get(name, env.get(name)) + ";" + value
|
||||||
entries[name] = value
|
entries[name] = value
|
||||||
game = config.get("games", {}).get(app_id, {})
|
game = split_game_gpu(config.get("games", {}).get(app_id, {}))
|
||||||
fix = (fixes or {}).get("WINEDLLOVERRIDES")
|
fix = (fixes or {}).get("WINEDLLOVERRIDES")
|
||||||
if fix and isinstance(game.get("WINEDLLOVERRIDES"), str):
|
if fix and isinstance(game.get("WINEDLLOVERRIDES"), str):
|
||||||
own = game["WINEDLLOVERRIDES"]
|
own = game["WINEDLLOVERRIDES"]
|
||||||
|
|||||||
@@ -1231,6 +1231,22 @@ class GameEnvironmentTest(unittest.TestCase):
|
|||||||
env = gpu({"TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": ""})
|
env = gpu({"TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": ""})
|
||||||
self.assertEqual(MODULE["apply_config"](env, config, "42")["TU_DEBUG"], "sysmem")
|
self.assertEqual(MODULE["apply_config"](env, config, "42")["TU_DEBUG"], "sysmem")
|
||||||
self.assertNotIn("TU_DEBUG", MODULE["apply_config"](env, config, "43"))
|
self.assertNotIn("TU_DEBUG", MODULE["apply_config"](env, config, "43"))
|
||||||
|
def applied(config, app_id="42", env=None):
|
||||||
|
return MODULE["apply_config"](env or {"TU_DEBUG": "sysmem"}, config, app_id)
|
||||||
|
prefixed = "DROIDDECK_GAME_TU_DEBUG"
|
||||||
|
config = {"version": 1, "games": {"42": {prefixed: "gmem"}, "43": {prefixed: ""}}}
|
||||||
|
self.assertEqual(applied(config)["TU_DEBUG"], "gmem")
|
||||||
|
self.assertNotIn("TU_DEBUG", applied(config, "43"))
|
||||||
|
self.assertNotIn(prefixed, applied(config))
|
||||||
|
shared = {"version": 1, "shared": {prefixed: "gmem"}, "games": {"42": {"TU_DEBUG": "nolrz"}, "43": {"TU_DEBUG": None}}}
|
||||||
|
self.assertEqual(applied(shared)["TU_DEBUG"], "nolrz")
|
||||||
|
self.assertNotIn("TU_DEBUG", applied(shared, "43"))
|
||||||
|
self.assertEqual(applied(shared, "44")["TU_DEBUG"], "gmem")
|
||||||
|
self.assertNotIn(prefixed, applied(shared, "44"))
|
||||||
|
both = {"version": 1, "games": {"42": {"TU_DEBUG": "sysmem", prefixed: ""}, "43": {"TU_DEBUG": None, prefixed: "gmem"}}}
|
||||||
|
self.assertEqual(applied(both)["TU_DEBUG"], "sysmem")
|
||||||
|
self.assertNotIn("TU_DEBUG", applied(both, "43", {"TU_DEBUG": "nolrz"}))
|
||||||
|
self.assertNotIn(prefixed, applied(both))
|
||||||
|
|
||||||
def test_games_run_with_gl_error_checks_unless_the_user_turns_them_off(self):
|
def test_games_run_with_gl_error_checks_unless_the_user_turns_them_off(self):
|
||||||
gpu = MODULE["game_gpu"]
|
gpu = MODULE["game_gpu"]
|
||||||
|
|||||||
Reference in new issue
Block a user