diff --git a/app/src/main/java/com/steamdeck/launcher/MainActivity.kt b/app/src/main/java/com/steamdeck/launcher/MainActivity.kt index 10c30f8145..23a40e8679 100644 --- a/app/src/main/java/com/steamdeck/launcher/MainActivity.kt +++ b/app/src/main/java/com/steamdeck/launcher/MainActivity.kt @@ -72,6 +72,10 @@ class MainActivity : ComponentActivity() { private var failed by mutableStateOf(false) private var frameGenLabel by mutableStateOf("Off") private var showRemove by mutableStateOf(false) + private var showNonAdreno by mutableStateOf(null) + private var glThread by mutableStateOf(true) + private var noGlError by mutableStateOf(true) + private var steamDeckMode by mutableStateOf(false) private var showFrameGen by mutableStateOf(false) private var showCredits by mutableStateOf(false) private var showProtons by mutableStateOf(false) @@ -240,6 +244,15 @@ class MainActivity : ComponentActivity() { onRemove = { id -> ProtonExtras.tools.first { it.id == id }.let { ProtonExtras.remove(this, it) }; refreshProtons() }, onDismiss = { showProtons = false }, ) + showNonAdreno?.let { release -> + ConfirmDialog( + title = "Not an Adreno GPU", + text = "The runtime draws with Turnip, an Adreno driver. On ${com.steamdeck.launcher.core.DeviceSupport.gpuName()} the compositor gets no usable Vulkan device and a session comes up as sound over a black screen. The download is ${"%.0f".format(release.size / 1e6)} MB.", + confirm = "Install anyway", + onConfirm = { showNonAdreno = null; install(release) }, + onDismiss = { showNonAdreno = null }, + ) + } if (showRemove) ConfirmDialog( title = "Remove Linux runtime", text = "This deletes the runtime, the Steam client inside it, and every game installed there.", @@ -392,11 +405,14 @@ class MainActivity : ComponentActivity() { PerformancePage( 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, noXalia = noXalia, + tuSysmem = tuSysmem, zinkLazy = zinkLazy, glThread = glThread, noGlError = noGlError, steamDeckMode = steamDeckMode, noXalia = noXalia, prootNoSeccomp = prootNoSeccomp, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on }, onZinkLazy = { on -> SessionPrefs.setZinkLazy(this, on); zinkLazy = on }, + onGlThread = { on -> SessionPrefs.setGlThread(this, on); glThread = on }, + onNoGlError = { on -> SessionPrefs.setNoGlError(this, on); noGlError = on }, + onSteamDeckMode = { on -> SessionPrefs.setSteamDeckMode(this, on); steamDeckMode = on }, onNoXalia = { on -> SessionPrefs.setNoXalia(this, on); noXalia = on }, onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, onClientCore = { core, on -> @@ -507,6 +523,9 @@ class MainActivity : ComponentActivity() { /** The two masks as the dialog shows them; an empty stored list shows as every core ticked. */ private fun refreshCores() { clientOverride = SessionPrefs.clientCpusOverride(this) + glThread = SessionPrefs.glThread(this) + noGlError = SessionPrefs.noGlError(this) + steamDeckMode = SessionPrefs.steamDeckMode(this) clientCores = CpuCores.parse(SessionPrefs.clientCpus(this)).ifEmpty { CpuCores.all.toSet() } gameCores = CpuCores.parse(SessionPrefs.gameCpus(this)).ifEmpty { CpuCores.all.toSet() } tuSysmem = SessionPrefs.tuSysmem(this) @@ -565,6 +584,10 @@ class MainActivity : ComponentActivity() { Thread({ checkCatalog() }, "catalog").start() return } + // The runtime draws with Turnip, an Adreno driver: on Mali, Xclipse or PowerVR the + // compositor gets no usable Vulkan device and a session is sound over a black screen. + // Said before the download, not after it; the user may still go ahead. + if (installed == null && !com.steamdeck.launcher.core.DeviceSupport.adreno()) { showNonAdreno = release; return } install(release) } diff --git a/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt index 9cfe9fa234..4bde1448ac 100644 --- a/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/steamdeck/launcher/core/DeviceReport.kt @@ -140,6 +140,10 @@ object DeviceReport { k(" game cores", CpuCores.restrictionOrEmpty(SessionPrefs.gameCpus(context)).ifEmpty { "every core (nothing sent)" }) k("Turnip sysmem", SessionPrefs.tuSysmem(context)) k("Zink lazy descriptors", SessionPrefs.zinkLazy(context)) + k("Threaded GL (glthread)", SessionPrefs.glThread(context)) + k("No GL error checks", SessionPrefs.noGlError(context)) + k("Steam Deck mode", SessionPrefs.steamDeckMode(context)) + k("FEX preset", SessionPrefs.fexPreset(context).ifEmpty { "FEX defaults" }) k("Skip xalia", SessionPrefs.noXalia(context)) k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) k("DirectAudio for games", SessionPrefs.directAudio(context)) diff --git a/app/src/main/java/com/steamdeck/launcher/core/DeviceSupport.kt b/app/src/main/java/com/steamdeck/launcher/core/DeviceSupport.kt new file mode 100644 index 0000000000..2c6e126019 --- /dev/null +++ b/app/src/main/java/com/steamdeck/launcher/core/DeviceSupport.kt @@ -0,0 +1,24 @@ +package com.steamdeck.launcher.core + +import android.os.Build +import java.io.File + +/** + * Whether this device can draw a Linux session at all. + * + * The runtime draws with Turnip, an Adreno driver. On Mali, Xclipse and PowerVR the compositor + * gets no usable Vulkan device and a session comes up as sound over a black screen - a failure + * with nothing in it to read. The app cannot fix that, so it says so before the download rather + * than after it. Adreno is recognised by what only Qualcomm's stack has: the KGSL node, or the + * vendor's own Vulkan driver at its usual path. + */ +object DeviceSupport { + fun adreno(): Boolean = + File("/sys/class/kgsl/kgsl-3d0").exists() || File("/vendor/lib64/hw/vulkan.adreno.so").exists() + + /** The chip as the device names it, for the card that explains the refusal. */ + fun gpuName(): String { + val soc = if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL.takeIf { it.isNotBlank() && it != Build.UNKNOWN } else null + return soc?.let { "$it (${Build.HARDWARE})" } ?: Build.HARDWARE.ifBlank { "this GPU" } + } +} diff --git a/app/src/main/java/com/steamdeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/steamdeck/launcher/runtime/LinuxRuntime.java index dc95fc129b..d64de787ba 100644 --- a/app/src/main/java/com/steamdeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/steamdeck/launcher/runtime/LinuxRuntime.java @@ -157,7 +157,30 @@ public final class LinuxRuntime { // Android denies apps these; glibc, Steam and libcap read them at startup. File fakeProc = new File(root, "etc/bannerlator/proc"); + // libpci picks its procfs backend on whether it can read the /proc/bus/pci directory, which + // the app can, then die()s - exit(1) on the calling process - on the devices file inside + // it, which the app cannot. Chromium loads libpci in its GPU process to name the video + // card, so that exit kills the process; after a few tries CEF gives up on hardware and + // draws the rest of the session on SwiftShader: the client's interface rendered on the + // CPU. An empty list is the truthful answer from in here - nothing the app can see is on + // a PCI bus. Created at session start rather than shipped in the rootfs so an installed + // runtime is fixed too, and the table's guard below binds it only when the real file + // cannot be read, so it can never stand in front of real data. (WinNative, maxjivi05, + // deff1ac6, via Bannerlator 8fb668d1: 44 -> 85 fps scrolling the Big Picture library on a + // OnePlus 15, GPU-process crashes 12 -> 0.) + File pciDevices = new File(fakeProc, "pci_devices"); + if (!pciDevices.isFile()) { + try { + //noinspection ResultOfMethodCallIgnored + pciDevices.getParentFile().mkdirs(); + //noinspection ResultOfMethodCallIgnored + pciDevices.createNewFile(); + } catch (java.io.IOException e) { + // It then fails the isFile() test below and the session runs as it did before. + } + } String[][] procFiles = { + {"pci_devices", "/proc/bus/pci/devices"}, {"stat", "/proc/stat"}, {"version", "/proc/version"}, {"loadavg", "/proc/loadavg"}, diff --git a/app/src/main/java/com/steamdeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/steamdeck/launcher/session/SessionPrefs.kt index f3f894a1be..53b6054498 100644 --- a/app/src/main/java/com/steamdeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/steamdeck/launcher/session/SessionPrefs.kt @@ -141,8 +141,26 @@ object SessionPrefs { prefs(context).edit().putBoolean("tuSysmem", on).apply() } - /** Zink's lazy descriptor mode (ZINK_DESCRIPTORS=lazy) for the client's GL-on-Vulkan UI. */ - fun zinkLazy(context: Context): Boolean = prefs(context).getBoolean("zinkLazy", false) + /* + * The client's interface is drawn Chromium -> ANGLE -> Zink -> Turnip, and that chain is what + * limits its menus (~14 fps on an Adreno 840 while a game ran 89). These make the chain + * cheaper rather than asking for more; the three environment switches are on by default, + * Deck mode off. Bannerlator's LinuxTuning, carried over; none device-proven here yet. + */ + /** mesa_glthread=true: GL marshalled off the calling thread. */ + fun glThread(context: Context): Boolean = prefs(context).getBoolean("glThread", true) + fun setGlThread(context: Context, on: Boolean) { prefs(context).edit().putBoolean("glThread", on).apply() } + + /** MESA_NO_ERROR=1: no GL error checking. */ + fun noGlError(context: Context): Boolean = prefs(context).getBoolean("noGlError", true) + fun setNoGlError(context: Context, on: Boolean) { prefs(context).edit().putBoolean("noGlError", on).apply() } + + /** `steam -steamdeck -steamos3`: the client as SteamOS runs it. Expects Deck hardware; untested. */ + fun steamDeckMode(context: Context): Boolean = prefs(context).getBoolean("steamDeckMode", false) + fun setSteamDeckMode(context: Context, on: Boolean) { prefs(context).edit().putBoolean("steamDeckMode", on).apply() } + + /** Zink's lazy descriptor mode (ZINK_DESCRIPTORS=lazy) for the client's GL-on-Vulkan UI. On by default. */ + fun zinkLazy(context: Context): Boolean = prefs(context).getBoolean("zinkLazy", true) fun setZinkLazy(context: Context, on: Boolean) { prefs(context).edit().putBoolean("zinkLazy", on).apply() diff --git a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt index 9751ad0b6c..1f771e6289 100644 --- a/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/steamdeck/launcher/session/SessionService.kt @@ -195,6 +195,12 @@ class SessionService : Service() { // the mode Zink recommends where the driver has no descriptor buffer, and what Ludashi ships // by default for its Zink path; a switch here because on one Fold the menus run at 14 fps. if (SessionPrefs.zinkLazy(this)) guest.add("ZINK_DESCRIPTORS=lazy") + // The rest of the client-interface switches (SessionPrefs): GL marshalled off the calling + // thread, no GL error checks, and the client run as SteamOS runs it (the script reads + // 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") + if (SessionState.mode == MODE_STEAM) guest.add("BL_STEAMDECK=" + (if (SessionPrefs.steamDeckMode(this)) "1" else "0")) // Proton's own gate for its xalia helper (its `proton` script reads this, and sets // XALIA_SUPPORTED_ONLY itself otherwise). Off by default: xalia is Valve's, and on a device // whose seccomp answers its syscalls normally there is no reason to take it away. diff --git a/app/src/main/java/com/steamdeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/steamdeck/launcher/ui/PerformanceDialog.kt index f656646e41..b15fbfabbf 100644 --- a/app/src/main/java/com/steamdeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/steamdeck/launcher/ui/PerformanceDialog.kt @@ -34,12 +34,18 @@ fun PerformancePage( gameCores: Set, tuSysmem: Boolean, zinkLazy: Boolean, + glThread: Boolean, + noGlError: Boolean, + steamDeckMode: Boolean, noXalia: Boolean, prootNoSeccomp: Boolean, phantomWarning: String?, onClientOverride: (Boolean) -> Unit, onTuSysmem: (Boolean) -> Unit, onZinkLazy: (Boolean) -> Unit, + onGlThread: (Boolean) -> Unit, + onNoGlError: (Boolean) -> Unit, + onSteamDeckMode: (Boolean) -> Unit, onNoXalia: (Boolean) -> Unit, onProotNoSeccomp: (Boolean) -> Unit, onClientCore: (Int, Boolean) -> Unit, @@ -72,17 +78,34 @@ fun PerformancePage( coreItems, gameCores, note = "Tick or untick as many as you like; the menu stays open.", onToggle = onGameCore, ) } + SettingsGroup("Client interface") { + ToggleRow( + host, "glthread", "Threaded GL", + "The client's menus are drawn Chromium → ANGLE → Zink → Turnip, and that chain is what limits them. mesa_glthread marshals GL off the calling thread, the shape of this bottleneck. On by default; none of these four is device-proven yet.", + glThread, onChange = onGlThread, + ) + ToggleRow( + host, "zink", "Zink: lazy descriptors", + "Lazy descriptor updates is the mode Zink recommends on drivers without descriptor buffers. On by default.", + zinkLazy, onChange = onZinkLazy, + ) + ToggleRow( + host, "noglerror", "Skip GL error checks", + "MESA_NO_ERROR: the driver stops validating every GL call. On by default.", + noGlError, onChange = onNoGlError, + ) + ToggleRow( + host, "deck", "Steam Deck mode", + "Runs the client as SteamOS runs its own session (-steamdeck -steamos3), the shape Valve tunes Big Picture for. Off by default: the client then expects Deck hardware that is not here, and that cost is untested.", + steamDeckMode, onChange = onSteamDeckMode, + ) + } SettingsGroup("Session fixes") { ToggleRow( host, "sysmem", "Turnip: sysmem rendering", "Renders without the GPU's tile memory (TU_DEBUG=sysmem). A fix for an Adreno 8xx that shows corruption, and required on a 710/720/722 (set on its own there). Not a speed setting: elsewhere it COSTS frames — leave it off unless the picture is wrong.", tuSysmem, onChange = onTuSysmem, ) - ToggleRow( - host, "zink", "Zink: lazy descriptors", - "The client's menus are drawn through Zink (GL on Vulkan). Lazy descriptor updates is the mode Zink recommends on drivers without descriptor buffers, and the first thing to try when the menus are slow while games are fast.", - zinkLazy, onChange = onZinkLazy, - ) ToggleRow( host, "xalia", "Skip Steam's xalia helper", "xalia is a Windows program Proton starts for gamepad navigation in Windows programs. On some devices its system calls are refused in a way it cannot cope with and the session dies seconds after Big Picture appears. Turn on if a session will not stay up.", diff --git a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session index edbb40fbf2..dd080122d2 100755 --- a/tools/linuxfs/overlay/usr/local/bin/bannerlator-session +++ b/tools/linuxfs/overlay/usr/local/bin/bannerlator-session @@ -323,6 +323,15 @@ BUSCONF # desktop's launchers ask for; gamescope shows one window at a time and the game takes over. _bl_ui=(-gamepadui) [ "${BL_STEAM_UI:-}" = desktop ] && _bl_ui=() + # SteamOS runs its own session as `steam -gamepadui -steamos3 -steamdeck`, which is the shape + # Valve tunes Big Picture for. BL_STEAMDECK=1 (the Performance page) tries it. Off by default: + # it also makes the client expect Deck hardware (battery, TDP controls, a Deck input device) + # that is not here, and that cost is untested. + if [ "${BL_STEAMDECK:-0}" = 1 ] && [ "${BL_STEAM_UI:-}" != desktop ]; then + _bl_ui+=(-steamdeck -steamos3) + echo "== steam: Deck mode on (-steamdeck -steamos3)" + fi + echo "== steam args: ${_bl_ui[*]} -clientbeta publicbeta -no-cef-sandbox -cef-force-gpu -cef-ozone-platform=x11 -cef-use-gl=angle -cef-use-angle=vulkan $*" while :; do step "starting the Steam client${BL_STEAM_UI:+ ($BL_STEAM_UI UI)}" "$steam_root/steamrtarm64/steam" "${_bl_ui[@]}" -clientbeta publicbeta \