mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
perf: tile rendering for games, faster session start (#1188)
Games launched from Steam get Turnip's own per-render-pass choice between tile memory and system memory again; TU_DEBUG=sysmem now stays with the Steam client, whose interface it was set for. A per-game TU_DEBUG, the debug override file and the Adreno 710/720 driver still win. On the REDMAGIC tablet (Adreno 840) PEAK runs 46.8 -> 52.3 fps over 7 alternating pairs and Valheim's 3D menu needs 12.6 % less GPU time per frame; light games are unchanged. droiddeck-seed-redists remembers the identity (inode, size, mtime) of each prefix registry it has verified and skips re-reading it while it is unchanged. Steam started after it on every session, ~1.8 s later. SessionFiles keeps a ledger of the files it staged for the installed APK and copies only the ones that changed, ~180 ms less per session start. Session start to Steam ready: 5.57 -> 3.57 s.
This commit is contained in:
1 parent
ca352bf225
commit
b868863133
41 files changed
+161
-51
No files matched your search
@@ -15,6 +15,7 @@ object SessionFiles {
|
||||
private const val TAG = "SessionFiles"
|
||||
private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad"
|
||||
const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio"
|
||||
private const val STAGED_LEDGER = "usr/local/.droiddeck-staged"
|
||||
val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread")
|
||||
|
||||
internal val DESKTOP_FILES = arrayOf(
|
||||
@@ -141,8 +142,10 @@ object SessionFiles {
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
}
|
||||
val all = (if (DesktopCatalog.desktopInstalled(root)) files + DESKTOP_FILES else files) + optional
|
||||
val ledger = StageLedger(File(root, STAGED_LEDGER), apkIdentity(context))
|
||||
for ((asset, relative) in all) {
|
||||
val target = File(root, relative)
|
||||
if (ledger.current(relative, target)) continue
|
||||
val staged = File(target.parentFile, target.name + ".staged")
|
||||
var installed = false
|
||||
try {
|
||||
@@ -156,7 +159,7 @@ object SessionFiles {
|
||||
} finally {
|
||||
if (!installed) staged.delete()
|
||||
}
|
||||
if (!installed) Log.e(TAG, "$relative NOT staged")
|
||||
if (installed) ledger.staged(relative, target) else Log.e(TAG, "$relative NOT staged")
|
||||
}
|
||||
File(root, "usr/local/bin/bannerlator-steam-compat").delete()
|
||||
LegacyNames.migrateRootfs(root)
|
||||
@@ -169,7 +172,9 @@ object SessionFiles {
|
||||
"version.txt",
|
||||
)
|
||||
for (set in DIRECTAUDIO_SETS) for (relative in directAudio) {
|
||||
val target = File(root, "$DIRECTAUDIO_DIR/$set/lib/wine/$relative")
|
||||
val key = "$DIRECTAUDIO_DIR/$set/lib/wine/$relative"
|
||||
val target = File(root, key)
|
||||
if (ledger.current(key, target)) continue
|
||||
val staged = File(target.parentFile, target.name + ".staged")
|
||||
var installed = false
|
||||
try {
|
||||
@@ -183,8 +188,9 @@ object SessionFiles {
|
||||
} finally {
|
||||
if (!installed) staged.delete()
|
||||
}
|
||||
if (!installed) Log.e(TAG, "DirectAudio $set/$relative NOT staged")
|
||||
if (installed) ledger.staged(key, target) else Log.e(TAG, "DirectAudio $set/$relative NOT staged")
|
||||
}
|
||||
ledger.save()
|
||||
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
||||
val preload = StringBuilder("/usr/local/lib/libblsession.so\n")
|
||||
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
|
||||
@@ -217,6 +223,43 @@ object SessionFiles {
|
||||
}
|
||||
}
|
||||
|
||||
private fun apkIdentity(context: Context): String {
|
||||
val apk = File(context.applicationInfo.sourceDir)
|
||||
return "${apk.path} ${apk.length()} ${apk.lastModified()}"
|
||||
}
|
||||
|
||||
private class StageLedger(private val file: File, private val identity: String) {
|
||||
private val before: Map<String, String> = FileUtils.readString(file)?.lines()
|
||||
?.takeIf { it.firstOrNull() == identity }
|
||||
?.drop(1)?.mapNotNull { line -> line.split('\t').takeIf { it.size == 2 }?.let { it[0] to it[1] } }?.toMap()
|
||||
.orEmpty()
|
||||
private val after = LinkedHashMap<String, String>()
|
||||
|
||||
fun current(relative: String, target: File): Boolean {
|
||||
val mark = mark(target) ?: return false
|
||||
if (before[relative] != mark) return false
|
||||
after[relative] = mark
|
||||
return true
|
||||
}
|
||||
|
||||
fun staged(relative: String, target: File) {
|
||||
mark(target)?.let { after[relative] = it }
|
||||
}
|
||||
|
||||
fun save() {
|
||||
if (after == before) return
|
||||
val text = (listOf(identity) + after.map { (relative, mark) -> "$relative\t$mark" }).joinToString("\n")
|
||||
val staged = File(file.parentFile, file.name + ".staged")
|
||||
if (!FileUtils.writeString(staged, text) || !staged.renameTo(file)) {
|
||||
staged.delete()
|
||||
file.delete()
|
||||
}
|
||||
}
|
||||
|
||||
private fun mark(target: File): String? =
|
||||
if (target.isFile) "${target.length()} ${target.lastModified()} ${target.canExecute()}" else null
|
||||
}
|
||||
|
||||
private fun stageStartupMovie(source: File, directory: File, name: String): Boolean {
|
||||
val movie = File(directory, name)
|
||||
val stamp = File(directory, ".$name.source")
|
||||
|
||||
@@ -294,14 +294,13 @@ class SessionService : Service() {
|
||||
return lines
|
||||
}
|
||||
|
||||
private fun tuDebug(linuxDriverId: String): String? {
|
||||
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
|
||||
private fun tuDebugOverride(): String? = File(Environment.getExternalStorageDirectory(), TU_DEBUG_SWITCH)
|
||||
.takeIf { it.isFile }?.let { FileUtils.readString(it)?.trim() }?.takeIf { it.isNotEmpty() }
|
||||
|
||||
private fun sysmemDriver(linuxDriverId: String): Boolean {
|
||||
if (linuxDriverId.isEmpty()) return false
|
||||
val name = LinuxVulkanDriverManager(this).getDriverName(linuxDriverId).lowercase()
|
||||
return if (name.contains("710-720") || name.contains("710_720")) "sysmem" else null
|
||||
return name.contains("710-720") || name.contains("710_720")
|
||||
}
|
||||
|
||||
|
||||
@@ -576,7 +575,9 @@ class SessionService : Service() {
|
||||
)
|
||||
LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId)
|
||||
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
|
||||
tuDebug(linuxDriverId)?.let { guest.add("TU_DEBUG=$it") }
|
||||
val tuOverride = tuDebugOverride()
|
||||
val tuDriver = sysmemDriver(linuxDriverId)
|
||||
(tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
||||
com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice()?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") }
|
||||
if (SessionPrefs.zinkLazy(this)) {
|
||||
guest.add("ZINK_DESCRIPTORS=lazy")
|
||||
@@ -604,8 +605,9 @@ class SessionService : Service() {
|
||||
if (SessionState.mode == MODE_STEAM && SessionPrefs.zramCompression(this) &&
|
||||
com.droiddeck.launcher.core.ZramSupport.supported()) guest.add("BL_ZRAM=1")
|
||||
guest.add("BANNER_AUDIO_DIRECT_DECAY=0")
|
||||
extraEnv().forEach { guest.add(it) }
|
||||
com.droiddeck.launcher.agent.AgentEnv.beginSession(this).forEach { guest.add(it) }
|
||||
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 ""))
|
||||
extra.forEach { guest.add(it) }
|
||||
val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this)
|
||||
if (clientPinned) {
|
||||
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
|
||||
@@ -1674,6 +1676,7 @@ class SessionService : Service() {
|
||||
private const val TAG = "SessionService"
|
||||
private const val TRACER_NICE = -6
|
||||
private const val TU_DEBUG_SWITCH = "Download/droiddeck-tu-debug"
|
||||
private const val GAME_TU_DEBUG = "DROIDDECK_GAME_TU_DEBUG"
|
||||
private const val LEGACY_ENV_SWITCH = "Download/droiddeck-env"
|
||||
private const val ENV_SWITCH_NAME = "droiddeck-env"
|
||||
|
||||
|
||||
Reference in new issue
Block a user