Performance: sysmem and Zink lazy-descriptor switches

The two tunables the Fold experiment needs, as switches under Performance
rather than files in Downloads: TU_DEBUG=sysmem for the runtime's Turnip and
ZINK_DESCRIPTORS=lazy for the client's menus. The Downloads files still win.
This commit is contained in:
The412Banner committed 2026-09-21 11:38:37 -04:00
1 parent f45bca182d
commit d7038a2b50
5 files changed
+70

No files matched your search

@@ -82,6 +82,8 @@ class MainActivity : ComponentActivity() {
private var clientOverride by mutableStateOf(false)
private var clientCores by mutableStateOf<Set<Int>>(emptySet())
private var gameCores by mutableStateOf<Set<Int>>(emptySet())
private var tuSysmem by mutableStateOf(false)
private var zinkLazy by mutableStateOf(false)
private var directAudio by mutableStateOf(false)
private var mic by mutableStateOf(false)
private var linuxRows by mutableStateOf<List<DriverRow>>(emptyList())
@@ -172,7 +174,10 @@ class MainActivity : ComponentActivity() {
if (showPerformance) PerformanceDialog(
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,
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on },
onZinkLazy = { on -> SessionPrefs.setZinkLazy(this, on); zinkLazy = on },
onClientCore = { core, on ->
clientCores = if (on) clientCores + core else clientCores - core
SessionPrefs.setClientCpus(this, CpuCores.format(clientCores))
@@ -320,6 +325,8 @@ class MainActivity : ComponentActivity() {
clientOverride = SessionPrefs.clientCpusOverride(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)
zinkLazy = SessionPrefs.zinkLazy(this)
}
private fun refreshProtons() {
@@ -105,6 +105,20 @@ object SessionPrefs {
prefs(context).edit().putString("gameCpus", list).apply()
}
/** 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 setTuSysmem(context: Context, on: Boolean) {
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)
fun setZinkLazy(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("zinkLazy", on).apply()
}
/** The Android driver the compositor loads: "" = pick by GPU, else a bundled or imported id. */
@JvmStatic
fun androidDriver(context: Context): String = prefs(context).getString("androidDriver", "") ?: ""
@@ -88,6 +88,7 @@ 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
@@ -144,6 +145,10 @@ class SessionService : Service() {
// imported driver from the A710/A720/A722 legs gets "sysmem" on its own, which is what both
// its authors advise for those GPUs and what nothing else in the list needs.
tuDebug(linuxDriverId)?.let { guest.add("TU_DEBUG=$it") }
// Zink renders the client's UI (Chromium -> ANGLE -> Zink -> Turnip). Lazy descriptors is
// 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")
// Anything else, for a device that cannot be reached with a debugger: Downloads/steamdeck-env
// holds KEY=VALUE lines that go into the session's environment as written, after ours, so a
// line here wins. Zink and Turnip tunables (ZINK_DESCRIPTORS=lazy, MESA_*), gamescope's,
@@ -34,7 +34,11 @@ fun PerformanceDialog(
clientOverride: Boolean,
clientCores: Set<Int>,
gameCores: Set<Int>,
tuSysmem: Boolean,
zinkLazy: Boolean,
onClientOverride: (Boolean) -> Unit,
onTuSysmem: (Boolean) -> Unit,
onZinkLazy: (Boolean) -> Unit,
onClientCore: (Int, Boolean) -> Unit,
onGameCore: (Int, Boolean) -> Unit,
onDismiss: () -> Unit,
@@ -73,6 +77,39 @@ fun PerformanceDialog(
)
Spacer(Modifier.height(4.dp))
CoreGrid(cores, gameCores, enabled = true, onToggle = onGameCore)
Spacer(Modifier.height(12.dp))
HorizontalDivider()
Spacer(Modifier.height(10.dp))
Text("Driver tunables", style = MaterialTheme.typography.titleSmall)
Text(
"Two switches for a runtime that renders slowly, tried one at a time. Both apply at the next session start.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp)) {
Column(modifier = Modifier.weight(1f)) {
Text("Turnip: sysmem rendering", style = MaterialTheme.typography.bodyMedium)
Text(
"Renders without the GPU's tile memory (TU_DEBUG=sysmem). Banners-Turnip's own advice for an Adreno 8xx that looks glitchy or slow, and required on a 710/720/722 (set on its own there).",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(checked = tuSysmem, onCheckedChange = onTuSysmem)
}
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp)) {
Column(modifier = Modifier.weight(1f)) {
Text("Zink: lazy descriptors", style = MaterialTheme.typography.bodyMedium)
Text(
"The Steam client's menus are drawn through Zink (GL on Vulkan). Lazy descriptor updates (ZINK_DESCRIPTORS=lazy) 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.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(checked = zinkLazy, onCheckedChange = onZinkLazy)
}
}
},
confirmButton = { TextButton(onClick = onDismiss) { Text("OK") } },