diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 6613319033..8da979cc39 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -997,7 +997,9 @@ class SessionService : Service() { SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") } guest.add("AUDIO_DIRECT_DECAY=0") val extra = extraEnv() + agentEnvironment - if (extra.none { it.startsWith("TU_DEBUG=") }) guest.add("$GAME_TU_DEBUG=" + (tuOverride ?: if (tuDriver) "sysmem" else "")) + mapOf("TU_DEBUG" to (tuOverride ?: if (tuDriver) "sysmem" else ""), "MESA_NO_ERROR" to "").forEach { (name, game) -> + if (extra.none { it.startsWith("$name=") }) guest.add("$GAME_PREFIX$name=$game") + } extra.forEach { guest.add(it) } com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") } val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this) @@ -2377,7 +2379,7 @@ class SessionService : Service() { private const val TRACER_NICE = -6 private const val MIC_RELEASE_TIMEOUT_MS = 5_000L private const val TU_DEBUG_SWITCH = "Download/droiddeck-tu-debug" - private const val GAME_TU_DEBUG = "DROIDDECK_GAME_TU_DEBUG" + private const val GAME_PREFIX = "DROIDDECK_GAME_" private const val LEGACY_ENV_SWITCH = "Download/droiddeck-env" private const val ENV_SWITCH_NAME = "droiddeck-env" diff --git a/docs/development/game-environment.md b/docs/development/game-environment.md index 766a565a55..5fb2f1be40 100644 --- a/docs/development/game-environment.md +++ b/docs/development/game-environment.md @@ -254,6 +254,14 @@ The former feature-level rules for Caravan SandWitch, RoboCop: Rogue City, ReSkate and Cyberpunk 2077 compensated for the global `12_2` override and are removed. Stellar Blade also uses automatic detection. The separate Deep Rock Galactic GDK ray-tracing opt-out and Mali bridge capability cap remain. + +"Skip GL error checks" (under "Client interface") sets `MESA_NO_ERROR=1` for the client +interface and Chromium apps only. Games keep Mesa's GL error checks: with +`MESA_NO_ERROR`, an invalid call such as `glBufferData` with no buffer bound reads +a NULL buffer object instead of returning `GL_INVALID_OPERATION`, and the game's +render thread stops. A game profile entry, or `MESA_NO_ERROR` in the session's own +environment, still applies to games. + Other picker suggestions are editable starting values and are enabled only when added and saved. Older or custom components can support a different set of options. Android Wine wrapper, diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 459e8a6fac..75c740a58e 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -10,7 +10,8 @@ import sys import tempfile from pathlib import Path -GAME_TU_DEBUG = "DROIDDECK_GAME_TU_DEBUG" +GAME_PREFIX = "DROIDDECK_GAME_" +GAME_SPLIT_KEYS = ("TU_DEBUG", "MESA_NO_ERROR") CHROMIUM_FILES = {"chrome-sandbox", "chrome_100_percent.pak", "v8_context_snapshot.bin"} D3D9_DEFAULT_MEMORY_MB = 4096 SYNC_KEYS = ("BL_SYNC", "BL_SYNC_FALLBACK", "BL_FSYNC_FIRST", "BL_SYNC_MIN_NOFILE", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC") @@ -385,16 +386,19 @@ def chromium_app(folder): def game_gpu(env, keep=False): - if GAME_TU_DEBUG not in env: + if not any(GAME_PREFIX + key in env for key in GAME_SPLIT_KEYS): return env result = env.copy() - value = result.pop(GAME_TU_DEBUG) - if keep: - return result - if value: - result["TU_DEBUG"] = value - else: - result.pop("TU_DEBUG", None) + for key in GAME_SPLIT_KEYS: + if GAME_PREFIX + key not in result: + continue + value = result.pop(GAME_PREFIX + key) + if keep: + continue + if value: + result[key] = value + else: + result.pop(key, None) return result diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 5f7b4af087..d423d8a355 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -950,6 +950,22 @@ class GameEnvironmentTest(unittest.TestCase): self.assertEqual(MODULE["apply_config"](env, config, "42")["TU_DEBUG"], "sysmem") self.assertNotIn("TU_DEBUG", MODULE["apply_config"](env, config, "43")) + def test_games_run_with_gl_error_checks_unless_the_user_turns_them_off(self): + gpu = MODULE["game_gpu"] + session = {"MESA_NO_ERROR": "1", "DROIDDECK_GAME_MESA_NO_ERROR": "", "KEEP": "1"} + self.assertEqual(gpu(session), {"KEEP": "1"}) + self.assertEqual(gpu(session, True), {"MESA_NO_ERROR": "1", "KEEP": "1"}) + self.assertEqual(gpu({"MESA_NO_ERROR": "1"}), {"MESA_NO_ERROR": "1"}) + self.assertEqual(gpu({"MESA_NO_ERROR": "1", "DROIDDECK_GAME_MESA_NO_ERROR": "1"}), {"MESA_NO_ERROR": "1"}) + both = gpu({"MESA_NO_ERROR": "1", "DROIDDECK_GAME_MESA_NO_ERROR": "", "TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": "nolrz"}) + self.assertEqual(both, {"TU_DEBUG": "nolrz"}) + self.assertEqual(gpu({"TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": "", "MESA_NO_ERROR": "1"}), + {"MESA_NO_ERROR": "1"}) + config = {"version": 1, "games": {"42": {"MESA_NO_ERROR": "1"}}} + env = gpu(session) + self.assertEqual(MODULE["apply_config"](env, config, "42")["MESA_NO_ERROR"], "1") + self.assertNotIn("MESA_NO_ERROR", MODULE["apply_config"](env, config, "43")) + def test_a_chromium_app_keeps_the_sessions_turnip_debug(self): gpu = MODULE["game_gpu"] self.assertEqual(gpu({"TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": "", "KEEP": "1"}, True), diff --git a/tools/tests/test_game_gpu_launchers.py b/tools/tests/test_game_gpu_launchers.py index 09b3aef85a..b4ddd3cbf4 100644 --- a/tools/tests/test_game_gpu_launchers.py +++ b/tools/tests/test_game_gpu_launchers.py @@ -9,7 +9,7 @@ from pathlib import Path BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "MESA_LOADER_DRIVER_OVERRIDE", "GALLIUM_DRIVER", - "LIBGL_KOPPER_DRI2", "VK_ICD_FILENAMES", "VK_DRIVER_FILES") + "LIBGL_KOPPER_DRI2", "VK_ICD_FILENAMES", "VK_DRIVER_FILES", "MESA_NO_ERROR", "DROIDDECK_GAME_MESA_NO_ERROR") SESSION = {"TU_DEBUG": "sysmem", "DROIDDECK_GAME_TU_DEBUG": ""} GPU_SESSION = {"MESA_LOADER_DRIVER_OVERRIDE": "zink", "GALLIUM_DRIVER": "zink", "LIBGL_KOPPER_DRI2": "true", "VK_ICD_FILENAMES": "/runtime/turnip.json", @@ -68,6 +68,15 @@ class GameGpuLaunchersTest(unittest.TestCase): self.chromium() self.assertEqual("sysmem", self.wrapper("--for", str(self.app / "files"))["TU_DEBUG"]) + def test_programs_get_gl_error_checks_back_while_chromium_keeps_the_client_setting(self): + session = dict(GPU_SESSION, MESA_NO_ERROR="1", DROIDDECK_GAME_MESA_NO_ERROR="") + values = self.wrapper(session=session) + self.assertEqual(("unset", "unset"), (values["MESA_NO_ERROR"], values["DROIDDECK_GAME_MESA_NO_ERROR"])) + self.assertEqual(GPU_SESSION, {key: values[key] for key in GPU_SESSION}) + self.assertEqual("1", self.wrapper("--chromium", session=session)["MESA_NO_ERROR"]) + self.assertEqual("unset", self.flatpak(session)["MESA_NO_ERROR"]) + self.assertEqual("1", self.wrapper(session={"MESA_NO_ERROR": "1"})["MESA_NO_ERROR"]) + def test_without_the_game_setting_the_wrapper_changes_nothing(self): self.assertEqual("sysmem", self.wrapper(session={"TU_DEBUG": "sysmem"})["TU_DEBUG"]) self.assertEqual("unset", self.wrapper(session={})["TU_DEBUG"])