From 1e804562b15fe4d19b1c1491b16ad8713ba5b0ed Mon Sep 17 00:00:00 2001 From: xXJsonDeruloXx Date: Tue, 29 Sep 2026 16:22:51 -0400 Subject: [PATCH] perf: WinNative's GPU and FEX defaults, opt-in sustained mode, the panel's top refresh rate, and fork-free session polling --- .../com/droiddeck/launcher/MainActivity.kt | 7 ++- .../com/droiddeck/launcher/SessionActivity.kt | 11 ++++- .../droiddeck/launcher/core/DeviceReport.kt | 1 + .../launcher/core/GameEnvironment.kt | 5 ++- .../droiddeck/launcher/session/PerfMode.kt | 6 +-- .../launcher/session/SessionPrefs.kt | 21 +++++++-- .../launcher/session/SessionService.kt | 12 +++-- .../launcher/ui/PerformanceDialog.kt | 9 +++- .../overlay/usr/local/bin/bannerlator-session | 44 ++++++++++++++++--- 9 files changed, 93 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt index c35d2c20bf..a663975bf9 100644 --- a/app/src/main/java/com/droiddeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/MainActivity.kt @@ -124,10 +124,11 @@ class MainActivity : ComponentActivity() { private var clientOverride by mutableStateOf(false) private var clientCores by mutableStateOf>(emptySet()) private var gameCores by mutableStateOf>(emptySet()) - private var tuSysmem by mutableStateOf(false) + private var tuSysmem by mutableStateOf(true) private var zinkLazy by mutableStateOf(false) private var noXalia by mutableStateOf(true) private var gamescopeRealtime by mutableStateOf(false) + private var sustainedPerformance by mutableStateOf(false) private var prootNoSeccomp by mutableStateOf(false) private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME) private var phantomWarning by mutableStateOf(null) @@ -895,7 +896,7 @@ class MainActivity : ComponentActivity() { cores = CpuCores.all.map { c -> CoreRow(c, "cpu$c" + (CpuCores.maxGhz(c)?.let { String.format(java.util.Locale.US, " · %.1f GHz", it) } ?: "")) }, clientOverride = clientOverride, clientCores = clientCores, gameCores = gameCores, tuSysmem = tuSysmem, zinkLazy = zinkLazy, glThread = glThread, noGlError = noGlError, noXalia = noXalia, - gamescopeRealtime = gamescopeRealtime, + gamescopeRealtime = gamescopeRealtime, sustainedPerformance = sustainedPerformance, prootNoSeccomp = prootNoSeccomp, guestHostname = guestHostname, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on }, @@ -904,6 +905,7 @@ class MainActivity : ComponentActivity() { onNoGlError = { on -> SessionPrefs.setNoGlError(this, on); noGlError = on }, onNoXalia = { on -> SessionPrefs.setNoXalia(this, on); noXalia = on }, onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on }, + onSustainedPerformance = { on -> SessionPrefs.setSustainedPerformance(this, on); sustainedPerformance = on }, onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) }, onClientCore = { core, on -> @@ -999,6 +1001,7 @@ class MainActivity : ComponentActivity() { zinkLazy = SessionPrefs.zinkLazy(this) noXalia = SessionPrefs.noXalia(this) gamescopeRealtime = SessionPrefs.gamescopeRealtime(this) + sustainedPerformance = SessionPrefs.sustainedPerformance(this) prootNoSeccomp = SessionPrefs.prootNoSeccomp(this) guestHostname = SessionPrefs.guestHostname(this) refreshPhantomStatus() diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 82d9f86e69..8d4bdd50ff 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -849,9 +849,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { return Pair(width and 1.inv(), height and 1.inv()) } + /** + * The rate the panel runs the session at: its fastest mode at the current size, which PerfMode + * asks for. The display's current rate is read too early for that - a phone still at 60 Hz + * when the surface arrives handed gamescope -r 60 and capped every game at 60. + */ private fun refreshHz(): Float { val display = if (Build.VERSION.SDK_INT >= 30) display else windowManager.defaultDisplay - val hz = display?.refreshRate ?: 60f + val cur = display?.mode + val best = if (cur == null) null else display.supportedModes + .filter { it.physicalWidth == cur.physicalWidth && it.physicalHeight == cur.physicalHeight } + .maxOfOrNull { it.refreshRate } + val hz = maxOf(best ?: 0f, display?.refreshRate ?: 0f) return if (hz > 1f) hz else 60f } 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 944b752a6a..6410304bd8 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -147,6 +147,7 @@ object DeviceReport { k("FEX preset", SessionPrefs.fexPreset(context).ifEmpty { "FEX defaults" }) k("Skip xalia", SessionPrefs.noXalia(context)) k("gamescope realtime", SessionPrefs.gamescopeRealtime(context)) + k("Sustained performance mode", SessionPrefs.sustainedPerformance(context)) k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) k("Guest host name", SessionPrefs.guestHostname(context)) k("DirectAudio for games", SessionPrefs.directAudio(context)) diff --git a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt index 11975edd38..69c98d9456 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/GameEnvironment.kt @@ -27,8 +27,9 @@ object GameEnvironment { fun defaults(preset: String): Map = linkedMapOf( "MESA_SHADER_CACHE_DISABLE" to "false", - "VKD3D_FEATURE_LEVEL" to "12_2", - "VKD3D_SHADER_MODEL" to "6_9", + // The feature level is left to vkd3d-proton, which reports what the driver can do; forcing + // 12_2 sent games down DX12 Ultimate paths Turnip only emulates. 6_6 is WinNative's model. + "VKD3D_SHADER_MODEL" to "6_6", ).apply { FexPreset.env(preset).forEach { put(it.substringBefore('='), it.substringAfter('=')) } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/PerfMode.kt b/app/src/main/java/com/droiddeck/launcher/session/PerfMode.kt index 16d1425607..b4c9d72008 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/PerfMode.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/PerfMode.kt @@ -13,8 +13,8 @@ import android.util.Log * The manifest already makes the app a game (appCategory + game_mode_config); this is the * per-window half, applied when the session activity is created: * - * - sustained performance mode (Android 7+): a clock floor that does not throttle away after - * two minutes, which suits an hour in Big Picture better than a boost that fades; + * - sustained performance mode (Android 7+), only when the Performance page asks for it: clocks + * the SoC can hold for hours, which on many devices caps the peak a session otherwise gets; * - the panel's fastest mode at its current size (Android 6+): a 120 Hz phone is switched to * 120 Hz for the menu, not only when a game votes for it; * - GameManager's game state (Android 13+): "in gameplay", so an OEM framework that releases @@ -30,7 +30,7 @@ object PerfMode { val parts = ArrayList(3) // Sustained performance mode. - parts += if (Build.VERSION.SDK_INT >= 24) { + parts += if (!SessionPrefs.sustainedPerformance(a)) "sustained mode off" else if (Build.VERSION.SDK_INT >= 24) { val pm = a.getSystemService(PowerManager::class.java) if (pm?.isSustainedPerformanceModeSupported == true) { try { a.window.setSustainedPerformanceMode(true); "sustained mode on" } catch (t: Throwable) { Log.w(TAG, "sustained mode", t); "sustained mode refused" } 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 63e6ac8297..35ff11ff6d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -204,6 +204,17 @@ object SessionPrefs { * Bannerlator's session: the compositor's queue preempting the game's buys nothing on a device * whose GPU is waiting on the CPU. */ + /** + * Whether the session window asks for Android's sustained performance mode. Off by default: it + * holds the SoC at clocks it can keep for hours, which on many devices is a cap well under + * the peak a game session gets without it (WinNative never asks for it). + */ + fun sustainedPerformance(context: Context): Boolean = prefs(context).getBoolean("sustainedPerformance", false) + + fun setSustainedPerformance(context: Context, on: Boolean) { + prefs(context).edit().putBoolean("sustainedPerformance", on).apply() + } + fun gamescopeRealtime(context: Context): Boolean = prefs(context).getBoolean("gamescopeRealtime", false) fun setGamescopeRealtime(context: Context, on: Boolean) { @@ -242,7 +253,7 @@ object SessionPrefs { } /** Turnip's sysmem rendering (TU_DEBUG=sysmem) for the runtime's driver: bypasses GMEM tiling. */ - fun tuSysmem(context: Context): Boolean = prefs(context).getBoolean("tuSysmem", false) + fun tuSysmem(context: Context): Boolean = prefs(context).getBoolean("tuSysmem", true) fun setTuSysmem(context: Context, on: Boolean) { prefs(context).edit().putBoolean("tuSysmem", on).apply() @@ -323,8 +334,12 @@ object SessionPrefs { fun resolutionChosen(context: Context, mode: String): Boolean = prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null - /** The FEXCore preset for the games the client launches (core/FexPreset ids); "" = FEX's defaults. */ - fun fexPreset(context: Context): String = prefs(context).getString("fexPreset", "") ?: "" + /** + * The FEXCore preset for the games the client launches (core/FexPreset ids); "" = FEX's own + * defaults. PERFORMANCE_TSO unless chosen: TSO only on the main path, x87 reduced precision + * and multiblock, as WinNative ships it. + */ + fun fexPreset(context: Context): String = prefs(context).getString("fexPreset", "PERFORMANCE_TSO") ?: "PERFORMANCE_TSO" fun setFexPreset(context: Context, id: String) { prefs(context).edit().putString("fexPreset", id).apply() 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 4c61618448..fa9ccae78a 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -240,10 +240,12 @@ class SessionService : Service() { val override = File(Environment.getExternalStorageDirectory(), TU_DEBUG_SWITCH) .takeIf { it.isFile }?.let { FileUtils.readString(it)?.trim() } if (!override.isNullOrEmpty()) return override - if (SessionPrefs.tuSysmem(this)) return "sysmem" - if (linuxDriverId.isEmpty()) return null - val name = LinuxVulkanDriverManager(this).getDriverName(linuxDriverId).lowercase() - return if (name.contains("710-720") || name.contains("710_720")) "sysmem" else null + // noconform: Turnip keeps the Vulkan features it has not passed conformance for (WinNative's + // default beside sysmem), which DXVK and vkd3d-proton reach for. + val sysmem = SessionPrefs.tuSysmem(this) || linuxDriverId.isNotEmpty() && + LinuxVulkanDriverManager(this).getDriverName(linuxDriverId).lowercase() + .let { it.contains("710-720") || it.contains("710_720") } + return if (sysmem) "noconform,sysmem" else "noconform" } // ── The session ───────────────────────────────────────────────────────────────────────── @@ -519,6 +521,8 @@ class SessionService : Service() { // BL_STEAMDECK; it is the one that builds the command line). if (SessionPrefs.glThread(this)) guest.add("mesa_glthread=true") if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1") + // Zink packs its descriptor sets and shader interfaces tighter (WinNative's default). + guest.add("ZINK_DEBUG=compact") if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAMDECK=" + (if (SessionPrefs.steamDeckMode(this)) "1" else "0")) if (steamHere) guest.add("BL_STEAM_CHANNEL=" + SessionPrefs.steamChannel(this)) if (SessionState.mode == MODE_STEAM) { 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 da5c0960fb..2fe8324bed 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -38,6 +38,7 @@ fun PerformancePage( noGlError: Boolean, noXalia: Boolean, gamescopeRealtime: Boolean, + sustainedPerformance: Boolean, prootNoSeccomp: Boolean, guestHostname: String, phantomWarning: String?, @@ -48,6 +49,7 @@ fun PerformancePage( onNoGlError: (Boolean) -> Unit, onNoXalia: (Boolean) -> Unit, onGamescopeRealtime: (Boolean) -> Unit, + onSustainedPerformance: (Boolean) -> Unit, onProotNoSeccomp: (Boolean) -> Unit, onGuestHostname: (String) -> Unit, onClientCore: (Int, Boolean) -> Unit, @@ -105,7 +107,7 @@ fun PerformancePage( SettingsGroup("Session fixes") { ToggleRow( host, "sysmem", "Turnip: sysmem rendering", - "Required on Adreno 710/720/722. May fix corruption on other Adreno GPUs, but can reduce performance.", + "On by default, as in WinNative. Required on Adreno 710/720/722; turn off to try GMEM tiling on other Adreno GPUs.", tuSysmem, onChange = onTuSysmem, ) ToggleRow( @@ -113,6 +115,11 @@ fun PerformancePage( "Disables Proton's gamepad navigation helper, which costs every game CPU time. Turn off only if a game needs it.", noXalia, onChange = onNoXalia, ) + ToggleRow( + host, "sustained", "Android sustained performance mode", + "Holds clocks the device can keep for hours. Steadier on hot devices, but usually a lower peak.", + sustainedPerformance, onChange = onSustainedPerformance, + ) ToggleRow( host, "seccomp", "Run proot without seccomp", "May fix missing syscall errors on some kernels, but can reduce performance.", diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session index 17d83160ee..7f5ae487eb 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session @@ -372,11 +372,18 @@ case $mode in # ~/.droiddeck-fill, and each change goes to gamescope as GAMESCOPE_FORCE_WINDOWS_FULLSCREEN on # the root window, which it watches. What gamescope was started with is where this begins. # Not on the desktop (BL_DESKTOP): no gamescope there, and the loop would outlive the client. + # The loops below poll for the whole session, and every sleep, cat or script they start is a + # fork and exec under proot. They wait with a read timeout on a FIFO nothing writes to and + # read files with builtins, so an idle beat costs no process at all. + _bl_fifo=$(mktemp -u "${TMPDIR:-/tmp}/bl-nap.XXXXXX") && mkfifo "$_bl_fifo" \ + && exec {_bl_nap}<>"$_bl_fifo" && rm -f "$_bl_fifo" + nap() { if [ -n "${_bl_nap:-}" ]; then read -r -t "$1" -u "$_bl_nap" _ || true; else sleep "$1"; fi; } [ -z "${BL_DESKTOP:-}" ] && ( last=${BL_GAMESCOPE_FORCE_FULLSCREEN:-1} while :; do - sleep 1 - want=$(cat "$HOME/.droiddeck-fill" 2>/dev/null) || continue + nap 1 + want= + read -r want <"$HOME/.droiddeck-fill" 2>/dev/null || [ -n "$want" ] || continue case $want in 0|1) ;; *) continue ;; esac [ "$want" = "$last" ] && continue if xprop -root -f GAMESCOPE_FORCE_WINDOWS_FULLSCREEN 32c -set GAMESCOPE_FORCE_WINDOWS_FULLSCREEN "$want" 2>/dev/null; then @@ -385,14 +392,37 @@ case $mode in fi done ) & + # Each beat only starts a script when there is something for it: the seeder when a prefix has + # a registry it has not marked, the registrar (Python, the heavier start) when a library, the + # tools directory or the client's config changed since its last run. ( + compat_stamp=$HOME/.cache/droiddeck-compat-stamp + needs_seed() { + local r + for r in "$steam_root"/steamapps/compatdata/*/pfx/system.reg \ + /mnt/bannerlator-sd/steamapps/compatdata/*/pfx/system.reg; do + [ -f "$r" ] && [ ! -e "${r%/system.reg}/.bannerlator-redists" ] && return 0 + done + return 1 + } + needs_compat() { + local d + [ -e "$compat_stamp" ] || return 0 + for d in "$steam_root/steamapps" "$steam_root/compatibilitytools.d" "$steam_root/config" \ + /mnt/bannerlator-sd/steamapps; do + [[ -e $d && $d -nt $compat_stamp ]] && return 0 + done + return 1 + } beat=0 - for _ in $(seq 1 720); do - sleep 5 - bannerlator-seed-redists "$steam_root" >/dev/null 2>&1 || true + while [ "$beat" -lt 720 ]; do + nap 5 + needs_seed && { bannerlator-seed-redists "$steam_root" >/dev/null 2>&1 || true; } beat=$((beat + 1)) - if [ "$((beat % 3))" -eq 0 ]; then + if [ "$((beat % 3))" -eq 0 ] && needs_compat; then + : >"$compat_stamp" bannerlator-steam-compat "$steam_root" >/dev/null 2>&1 || true + : >"$compat_stamp" fi done ) & @@ -559,7 +589,7 @@ BUSCONF "$steam_root/steamrtarm64/steam" -shutdown >/dev/null 2>&1 || true exit 0 fi - sleep 0.5 + nap 0.5 done ) & stop_watcher=$!