From 2be08bc67d2e4d9896498d70d87c34b7c28a9918 Mon Sep 17 00:00:00 2001 From: Jamison Prine Date: Sun, 25 Oct 2026 11:06:45 -0500 Subject: [PATCH] feat: adjustable RAM and VRAM caps for the container (#1537) * feat: adjustable RAM and VRAM caps for the container Performance > Memory gets two sliders: - RAM cap (soft, Steam sessions): when the session is resident above the cap, the session watcher compresses the Steam client into zRAM, waits for its page-out acknowledgment, then compresses the rest of the session (processes that loaded libblsession) if still over. Nothing is closed. Measured at most every 30 s; the client is read back once usage drops below the cap. Invalid values leave the cap off. Needs zRAM swap. - VRAM cap: sets dxgi.maxDeviceMemory ahead of the game's own DXVK_CONFIG, so Direct3D games budget for less video memory. A game profile still wins. Applies from the next session. * fix: back off the RAM cap when paging out cannot get under it A cap below the game's working set was never met, so the watcher paged out the client and the whole session every 30 s for the rest of the session. Usage is still measured every 30 s, but after a page-out that leaves the session over the cap the next one waits twice as long (60 s up to 10 min), resetting once usage is under the cap. The client step is skipped while the client is already under 512 MB resident. * fix: RAM cap covers desktop Steam, signals each group once, no idle churn - Steam opened from the desktop runs the same session watcher, so the cap is exported whenever the Steam client runs, not only in Steam mode. - The second page-out goes to the rest of the session only; Steam was signalled again even when its own step had been skipped as already small. - A cap page-out while no game runs stays paged out. Reading the client back right away pushed it over the cap again and repeated every minute; only a game closing while over the cap still defers a read-back. * fix: RAM cap marks the client packed only when it compressed it When the cap skipped the client as already small during a game, it still recorded the client as packed, so the regular in-game client page-out waited up to 300 s for a page-out that never happened. --------- Co-authored-by: jazzyjames <182448902+jazzyjamesgames@users.noreply.github.com> --- .../droiddeck/launcher/FrontEndActivity.kt | 10 ++ .../droiddeck/launcher/core/DeviceReport.kt | 2 + .../launcher/session/SessionPrefs.kt | 12 ++ .../launcher/session/SessionService.kt | 6 +- .../launcher/session/SettingsReset.kt | 2 +- .../launcher/ui/PerformanceDialog.kt | 24 ++++ app/src/main/res/values/strings.xml | 8 ++ .../overlay/usr/local/bin/droiddeck-game-env | 13 +++ .../overlay/usr/local/bin/droiddeck-session | 108 ++++++++++++++++-- tools/tests/test_game_environment.py | 8 ++ 10 files changed, 180 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 72ec9349dd..f81680e0fa 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -152,6 +152,8 @@ class FrontEndActivity : ComponentActivity() { private var syncFallback by mutableStateOf(true) private var fsyncFirst by mutableStateOf(false) private var gamescopeRealtime by mutableStateOf(false) + private var ramCapMb by mutableStateOf(0) + private var vramCapMb by mutableStateOf(0) private var gpuClockPin by mutableStateOf(false) private var prootNoSeccomp by mutableStateOf(false) private var prootFastPath by mutableStateOf(true) @@ -1799,6 +1801,10 @@ class FrontEndActivity : ComponentActivity() { fsyncFirst = fsyncFirst, gamescopeRealtime = gamescopeRealtime, gpuClockPin = gpuClockPin, + ramCapMb = ramCapMb, vramCapMb = vramCapMb, + deviceRamMb = (android.app.ActivityManager.MemoryInfo() + .also((getSystemService(ACTIVITY_SERVICE) as android.app.ActivityManager)::getMemoryInfo).totalMem / (1024 * 1024)).toInt(), + ramCapAvailable = com.droiddeck.launcher.core.ZramSupport.supported(), prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, cursorComposite = cursorComposite, guestHostname = guestHostname, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, @@ -1812,6 +1818,8 @@ class FrontEndActivity : ComponentActivity() { onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on }, onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on }, onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on }, + onRamCapMb = { mb -> SessionPrefs.setRamCapMb(this, mb); ramCapMb = mb }, + onVramCapMb = { mb -> SessionPrefs.setVramCapMb(this, mb); vramCapMb = mb }, onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on }, onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on }, @@ -2007,6 +2015,8 @@ class FrontEndActivity : ComponentActivity() { syncFallback = SessionPrefs.syncFallback(this) fsyncFirst = SessionPrefs.fsyncFirst(this) gamescopeRealtime = SessionPrefs.gamescopeRealtime(this) + ramCapMb = SessionPrefs.ramCapMb(this) + vramCapMb = SessionPrefs.vramCapMb(this) gpuClockPin = SessionPrefs.gpuClockPin(this) prootNoSeccomp = SessionPrefs.prootNoSeccomp(this) prootFastPath = SessionPrefs.prootFastPath(this) diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 058b07dd5d..0246ed8e6b 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -256,6 +256,8 @@ object DeviceReport { EsyncPacks.status(LinuxRuntime.rootDir(context)).let { k("droiddeck-esync packs", "${it.installed} installed, ${it.wanted} wanted") } k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up") k("gamescope realtime", SessionPrefs.gamescopeRealtime(context)) + k("RAM cap", SessionPrefs.ramCapMb(context).let { if (it > 0) "$it MB" else "off" }) + k("VRAM cap", SessionPrefs.vramCapMb(context).let { if (it > 0) "$it MB" else "driver default" }) k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) k("proot fast path", SessionPrefs.prootFastPath(context)) k("Guest host name", SessionPrefs.guestHostname(context)) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index d77cced0b8..8ab1f7e751 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -453,6 +453,18 @@ object SessionPrefs { prefs(context).edit().putBoolean("gamescopeRealtime", on).apply() } + fun ramCapMb(context: Context): Int = prefs(context).getInt("ramCapMb", 0).coerceAtLeast(0) + + fun setRamCapMb(context: Context, mb: Int) { + prefs(context).edit().putInt("ramCapMb", mb.coerceAtLeast(0)).apply() + } + + fun vramCapMb(context: Context): Int = prefs(context).getInt("vramCapMb", 0).coerceAtLeast(0) + + fun setVramCapMb(context: Context, mb: Int) { + prefs(context).edit().putInt("vramCapMb", mb.coerceAtLeast(0)).apply() + } + fun gpuClockPin(context: Context): Boolean = prefs(context).getBoolean("gpuClockPin", false) fun setGpuClockPin(context: Context, on: Boolean) { 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 c49e3f7acb..9d0a99fe1b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -738,7 +738,11 @@ class SessionService : Service() { guest.add("BL_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0")) guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0")) if (SessionPrefs.cursorComposite(this)) guest.add("BL_CURSOR_COMPOSITE=1") - if (com.droiddeck.launcher.core.ZramSupport.supported()) guest.add("BL_ZRAM=1") + if (com.droiddeck.launcher.core.ZramSupport.supported()) { + guest.add("BL_ZRAM=1") + if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_RAM_CAP_MB=$it") } + } + SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") } guest.add("BANNER_AUDIO_DIRECT_DECAY=0") val extra = extraEnv() + com.droiddeck.launcher.agent.AgentEnv.beginSession(this) if (extra.none { it.startsWith("TU_DEBUG=") }) guest.add("$GAME_TU_DEBUG=" + (tuOverride ?: if (tuDriver) "sysmem" else "")) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt index 27bc081b0d..7d7f0cff52 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -18,7 +18,7 @@ object SettingsReset { "gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController", "stretch16x9", "picturePosition", "gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop", - "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", + "tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "ramCapMb", "vramCapMb", "directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus", "noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "cursorComposite", "guestHostname", "fexPreset", "forceSsbs", "logs", "storageDiagnostics", diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt index 25f344a77a..d8c83c9a0b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -28,6 +28,8 @@ import com.droiddeck.launcher.session.SessionPrefs class CoreRow(val core: Int, val label: String) +private const val MEMORY_CAP_STEP_MB = 256 + @Composable fun PerformancePage( cores: List, @@ -44,6 +46,10 @@ fun PerformancePage( fsyncFirst: Boolean, gamescopeRealtime: Boolean, gpuClockPin: Boolean, + ramCapMb: Int, + vramCapMb: Int, + deviceRamMb: Int, + ramCapAvailable: Boolean, prootNoSeccomp: Boolean, prootFastPath: Boolean, cursorComposite: Boolean, @@ -60,6 +66,8 @@ fun PerformancePage( onFsyncFirst: (Boolean) -> Unit, onGamescopeRealtime: (Boolean) -> Unit, onGpuClockPin: (Boolean) -> Unit, + onRamCapMb: (Int) -> Unit, + onVramCapMb: (Int) -> Unit, onProotNoSeccomp: (Boolean) -> Unit, onProotFastPath: (Boolean) -> Unit, onCursorComposite: (Boolean) -> Unit, @@ -123,6 +131,22 @@ fun PerformancePage( gpuClockPin, onChange = onGpuClockPin, ) } + SettingsGroup(stringResource(R.string.perf_memory)) { + val top = (deviceRamMb / MEMORY_CAP_STEP_MB * MEMORY_CAP_STEP_MB).coerceAtLeast(MEMORY_CAP_STEP_MB) + val off = stringResource(R.string.perf_cap_off) + val auto = stringResource(R.string.perf_cap_auto) + SliderRow( + stringResource(R.string.perf_ram_cap), + if (ramCapAvailable) stringResource(R.string.perf_ram_cap_hint) else stringResource(R.string.perf_ram_cap_unavailable), + ramCapMb.coerceAtMost(top), 0..top, step = MEMORY_CAP_STEP_MB, enabled = ramCapAvailable, + format = { if (it == 0) off else "$it MB" }, onChange = onRamCapMb, + ) + SliderRow( + stringResource(R.string.perf_vram_cap), stringResource(R.string.perf_vram_cap_hint), + vramCapMb.coerceAtMost(top), 0..top, step = MEMORY_CAP_STEP_MB, + format = { if (it == 0) auto else "$it MB" }, onChange = onVramCapMb, + ) + } SettingsGroup(stringResource(R.string.perf_fixes)) { ToggleRow( host, "sysmem", stringResource(R.string.perf_sysmem), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1ca3066271..0889e5d8be 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -552,6 +552,14 @@ gamescope: realtime GPU queue Prioritizes the compositor\'s GPU work. Can smooth frame pacing at some cost to games. GPU + Memory + Off + Driver default + RAM cap + Applies while the Steam client runs, in Steam mode or from the desktop. When the session uses more than this, Steam and then the session\'s other supported processes are compressed into zRAM. A soft cap: nothing is closed, but games may stutter while pages come back. + Needs zRAM swap, which this device does not have. + VRAM cap + The video memory DXVK reports to Direct3D games, so they budget textures for less. A game\'s own DXVK settings still win. Takes effect at the next session. Hold the GPU at its top clock Adreno only. Fewer hitches, more battery use and heat. Session fixes diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 3f7154ba3d..43f24138d7 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -287,6 +287,18 @@ def game_gpu(env): return result +def vram_cap(env): + """Puts the session's VRAM cap ahead of the game's own DXVK settings, so a game profile can still raise it.""" + value = env.get("BL_VRAM_MB", "") + if not re.fullmatch(r"[1-9][0-9]{0,6}", value): + return env + result = env.copy() + cap = "dxgi.maxDeviceMemory = %d" % int(value) + own = result.get("DXVK_CONFIG", "").strip().strip(";").strip() + result["DXVK_CONFIG"] = cap + "; " + own if own else cap + return result + + def apply_config(env, config, app_id, fixes=None): if config.get("version") != 1: raise ValueError("unsupported environment configuration") @@ -560,6 +572,7 @@ def main(): command = offline_without_anticheat(command, env) if mic_enabled == "0": env["BANNER_AUDIO_DIRECT_MIC"] = "0" + env = vram_cap(env) env = force_ssbs(command, env) try: xbox = runpy.run_path(str(Path(__file__).with_name("droiddeck-xbox"))) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index e95a7a940a..043e8304d5 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -446,48 +446,134 @@ case $mode in fi if [ "${BL_ZRAM:-0}" = 1 ]; then step "zRAM compression: on" + _bl_ram_cap=0 + case ${BL_RAM_CAP_MB:-} in + ''|0) ;; + *[!0-9]*|0*|???????*) step "RAM cap: ignored invalid value '$BL_RAM_CAP_MB'" ;; + *) _bl_ram_cap=$((BL_RAM_CAP_MB * 1024)); step "RAM cap: ${BL_RAM_CAP_MB} MB" ;; + esac ( bl_zram_scan() { - _bl_game=0 _bl_pids=() + _bl_game=0 _bl_pids=() _bl_others=() for _d in /proc/[0-9]*; do + [ "${_d#/proc/}" != "$BASHPID" ] || continue # Under FEX the program is FEX's first argument. { IFS= read -r -d '' _c && case ${_c##*/} in FEX|FEXInterpreter) IFS= read -r -d '' _c ;; esac; } \ 2>/dev/null < "$_d/cmdline" || continue case ${_c##*/} in reaper) _bl_game=1 ;; steam|steamwebhelper) _bl_pids+=("${_d#/proc/}") ;; + *) _bl_others+=("${_d#/proc/}") ;; esac done } bl_zram_usage() { local _p _k _v _u _rss=0 _swap=0 - for _p in "${_bl_pids[@]}"; do + for _p in "$@"; do while read -r _k _v _u; do case $_k in VmRSS:) _rss=$((_rss + _v)) ;; VmSwap:) _swap=$((_swap + _v)) ;; esac done 2>/dev/null < "/proc/$_p/status" done - echo "${#_bl_pids[@]} processes, resident $((_rss / 1024)) MB, in zram $((_swap / 1024)) MB" + _bl_rss=$_rss + echo "$# processes, resident $((_rss / 1024)) MB, in zram $((_swap / 1024)) MB" + } + # Only processes that loaded libblsession are the session's own and answer SIGURG. + bl_session_others() { + local _p + _bl_session=() + for _p in "${_bl_others[@]}"; do + grep -q -m1 '/libblsession\.so$' "/proc/$_p/maps" 2>/dev/null && _bl_session+=("$_p") + done + } + bl_zram_pick() { + if [ "$1" = session ]; then + bl_session_others + _pids=("${_bl_session[@]}") + else + _pids=("${_bl_pids[@]}") + fi + } + # Same protocol as SessionSuspendController: an empty ack when the page-out starts, a byte when it is done. + # A process whose SIGURG handler was replaced never acks, so it is not waited for after the first 2 s. + bl_zram_wait() { + local _p _left _start=$SECONDS + while [ $((SECONDS - _start)) -lt 12 ]; do + _left=0 + for _p in "$@"; do + [ -s "/tmp/.bl-zram.ack.$_p" ] && continue + [ -d "/proc/$_p" ] || continue + [ $((SECONDS - _start)) -ge 2 ] && [ ! -e "/tmp/.bl-zram.ack.$_p" ] && continue + _left=1 + done + [ "$_left" = 1 ] || break + nap 0.2 + done + for _p in "$@"; do rm -f "/tmp/.bl-zram.ack.$_p"; done } bl_zram_send() { - step "zRAM: $2 ($(bl_zram_usage))" - printf '%s' "$1" > /tmp/.bl-zram - [ "${#_bl_pids[@]}" = 0 ] || kill -URG "${_bl_pids[@]}" 2>/dev/null - nap 5 + local _mode=$1 _what=$2 _which=$3 _pids _p + bl_zram_pick "$_which" + step "zRAM: $_what ($(bl_zram_usage "${_pids[@]}"))" + for _p in "${_pids[@]}"; do rm -f "/tmp/.bl-zram.ack.$_p"; done + printf '%s' "$_mode" > /tmp/.bl-zram + [ "${#_pids[@]}" = 0 ] || kill -URG "${_pids[@]}" 2>/dev/null + if [ "$_mode" = 1 ]; then bl_zram_wait "${_pids[@]}"; else nap 5; fi bl_zram_scan - step "zRAM: done ($(bl_zram_usage))" + bl_zram_pick "$_which" + step "zRAM: done ($(bl_zram_usage "${_pids[@]}"))" } - _bl_since=-1 _bl_packed=-1 + bl_over_cap() { + [ "$_bl_ram_cap" -gt 0 ] || return 1 + _bl_measured=$SECONDS + bl_session_others + bl_zram_usage "${_bl_pids[@]}" "${_bl_session[@]}" > /dev/null + [ "$_bl_rss" -gt "$_bl_ram_cap" ] + } + bl_cap_due() { + [ "$_bl_ram_cap" -gt 0 ] && { [ "$_bl_measured" -lt 0 ] || [ $((SECONDS - _bl_measured)) -ge 30 ]; } + } + _bl_since=-1 _bl_packed=-1 _bl_measured=-1 _bl_unpack=0 _bl_capped=-1 _bl_backoff=30 while kill -0 $$ 2>/dev/null; do bl_zram_scan + if bl_cap_due; then + if bl_over_cap; then + # A cap below the game's working set cannot be met; paging out again every 30 s only churns. + if [ "$_bl_capped" -lt 0 ] || [ $((SECONDS - _bl_capped)) -ge "$_bl_backoff" ]; then + bl_zram_usage "${_bl_pids[@]}" > /dev/null + if [ "$_bl_rss" -ge $((512 * 1024)) ]; then + bl_zram_send 1 "over the ${BL_RAM_CAP_MB} MB RAM cap, compressing the client" client + [ "$_bl_game" = 1 ] && _bl_packed=$SECONDS + else + step "RAM cap: over, client already small ($((_bl_rss / 1024)) MB resident), skipping it" + fi + bl_over_cap && bl_zram_send 1 "still over the RAM cap, compressing the rest of the session" session + if bl_over_cap; then + _bl_backoff=$((_bl_backoff * 2 > 600 ? 600 : _bl_backoff * 2)) + step "RAM cap: still over after paging out, next try in ${_bl_backoff} s" + else + _bl_backoff=30 + fi + _bl_capped=$SECONDS + fi + else + _bl_backoff=30 + if [ "$_bl_unpack" = 1 ] && [ "$_bl_game" = 0 ]; then + bl_zram_send 0 "back under the RAM cap, reading the client back" client + _bl_unpack=0 + fi + fi + fi if [ "$_bl_game" = 1 ]; then [ "$_bl_since" -ge 0 ] || _bl_since=$SECONDS if [ $((SECONDS - _bl_since)) -ge 20 ] && [ "${#_bl_pids[@]}" -gt 0 ] && { [ "$_bl_packed" -lt 0 ] || [ $((SECONDS - _bl_packed)) -ge 300 ]; }; then - bl_zram_send 1 "compressing the client" + bl_zram_send 1 "compressing the client" client _bl_packed=$SECONDS fi elif [ "$_bl_since" -ge 0 ]; then - [ "$_bl_packed" -lt 0 ] || bl_zram_send 0 "game closed, reading the client back" + if [ "$_bl_packed" -ge 0 ]; then + if bl_over_cap; then _bl_unpack=1; else bl_zram_send 0 "game closed, reading the client back" client; _bl_unpack=0; fi + fi _bl_since=-1 _bl_packed=-1 fi nap 5 diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 56e5e651df..817281af5b 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -180,6 +180,14 @@ 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_the_vram_cap_comes_before_the_games_own_dxvk_settings(self): + cap = MODULE["vram_cap"] + self.assertEqual(cap({"BL_VRAM_MB": "4096"})["DXVK_CONFIG"], "dxgi.maxDeviceMemory = 4096") + self.assertEqual(cap({"BL_VRAM_MB": "2048", "DXVK_CONFIG": "dxvk.maxFrameRate = 60;"})["DXVK_CONFIG"], + "dxgi.maxDeviceMemory = 2048; dxvk.maxFrameRate = 60") + for off in ({}, {"BL_VRAM_MB": "0"}, {"BL_VRAM_MB": "lots"}, {"BL_VRAM_MB": "²"}, {"BL_VRAM_MB": "-1"}): + self.assertNotIn("DXVK_CONFIG", cap(off)) + def test_a_games_wine_sync_choice_also_reaches_its_setup_runs(self): env = {"BL_SYNC": "1", "BL_SYNC_FALLBACK": "1", "BL_FSYNC_FIRST": "0", "OTHER": "kept"} config = {"version": 1, "games": {"42": {"BL_SYNC": "0", "BL_FSYNC_FIRST": "1", "PROTON_NO_ESYNC": "1", "FEX_TSOENABLED": "1"}}}