fix: Snapdragon 8 Gen 2 no longer pins Steam to one core by default

This commit is contained in:
maxjivi05 committed 2026-10-23 19:47:41 -04:00
1 parent 0d8b5a7cf2
commit c7bcd82782
4 files changed
+14 -110

No files matched your search

@@ -1,27 +0,0 @@
package com.droiddeck.launcher.core
import com.droiddeck.launcher.gpu.GpuInfo
import com.droiddeck.launcher.gpu.SocNames
object CpuAllocationDefaults {
data class Allocation(val client: String, val game: String)
val device: Allocation? by lazy {
forDevice(SocNames.model(), GpuInfo.systemProperty("ro.board.platform"),
CpuCores.all.associateWith(CpuCores::maxGhz))
}
fun forDevice(model: String, platform: String, frequencies: Map<Int, Double?>): Allocation? {
val chip = model.trim().uppercase().substringBefore('-')
val gen2 = chip in setOf("SM8550", "QCS8550") ||
(chip.isEmpty() && platform.trim().equals("kalama", ignoreCase = true))
if (!gen2 || frequencies.size != 8 || frequencies.keys.any { it < 0 } ||
frequencies.values.any { it == null || !it.isFinite() || it <= 0.0 }) return null
val clusters = frequencies.entries.groupBy { it.value }.toSortedMap(compareBy { it ?: 0.0 }).values.toList()
if (clusters.map { it.size } != listOf(3, 4, 1)) return null
return Allocation(
client = CpuCores.format(clusters[2].map { it.key }.toSet()),
game = CpuCores.format(clusters[1].map { it.key }.toSet()),
)
}
}
@@ -4,7 +4,6 @@ import android.content.Context
import android.content.pm.ActivityInfo
import androidx.annotation.StringRes
import com.droiddeck.launcher.R
import com.droiddeck.launcher.core.CpuAllocationDefaults
import com.droiddeck.launcher.core.GameEnvironment
import com.droiddeck.launcher.core.TextureFiltering
import com.droiddeck.launcher.gpu.Cardboard
@@ -382,30 +381,19 @@ object SessionPrefs {
prefs(context).edit().putBoolean("wifiDiscoveryAsked", true).apply()
}
internal data class CoreAllocation(val clientOverride: Boolean, val clientCpus: String, val gameCpus: String)
internal fun coreAllocation(context: Context, defaults: CpuAllocationDefaults.Allocation? = CpuAllocationDefaults.device): CoreAllocation {
val saved = prefs(context)
return CoreAllocation(
saved.getBoolean("clientCpusOverride", defaults != null && !saved.contains("clientCpus")),
saved.getString("clientCpus", defaults?.client.orEmpty()).orEmpty(),
saved.getString("gameCpus", defaults?.game.orEmpty()).orEmpty(),
)
}
fun clientCpusOverride(context: Context): Boolean = coreAllocation(context).clientOverride
fun clientCpusOverride(context: Context): Boolean = prefs(context).getBoolean("clientCpusOverride", false)
fun setClientCpusOverride(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("clientCpusOverride", on).apply()
}
fun clientCpus(context: Context): String = coreAllocation(context).clientCpus
fun clientCpus(context: Context): String = prefs(context).getString("clientCpus", "").orEmpty()
fun setClientCpus(context: Context, list: String) {
prefs(context).edit().putString("clientCpus", list).apply()
}
fun gameCpus(context: Context): String = coreAllocation(context).gameCpus
fun gameCpus(context: Context): String = prefs(context).getString("gameCpus", "").orEmpty()
fun setGameCpus(context: Context, list: String) {
prefs(context).edit().putString("gameCpus", list).apply()
@@ -1,42 +0,0 @@
package com.droiddeck.launcher.core
import org.junit.Assert.*
import org.junit.Test
class CpuAllocationDefaultsTest {
private val thor = (0..7).associateWith { when (it) { in 0..2 -> 2.016; in 3..6 -> 2.8032; else -> 3.1872 } }
@Test fun gen2UsesTheFourMiddleCoresAndOnePrime() {
for (model in listOf("SM8550", "QCS8550", "sm8550-ac")) {
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice(model, "", thor))
}
assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice("", "kalama", thor))
}
@Test fun coreNumbersAndClockVariantsAreDetectedInsteadOfHardcoded() {
val reordered = mapOf(0 to 3.36, 1 to 2.0, 2 to 2.0, 3 to 2.0, 4 to 2.8, 5 to 2.8, 6 to 2.8, 7 to 2.8)
assertEquals(CpuAllocationDefaults.Allocation("0", "4,5,6,7"), CpuAllocationDefaults.forDevice("SM8550-AC", "kalama", reordered))
}
@Test fun anotherOrUnknownChipDoesNotAcquireThisDefault() {
assertNull(CpuAllocationDefaults.forDevice("SM8650", "pineapple", thor))
assertNull(CpuAllocationDefaults.forDevice("SM8650", "kalama", thor))
assertNull(CpuAllocationDefaults.forDevice("", "", thor))
}
@Test fun missingOrUnexpectedTopologyKeepsTheSchedulerDefault() {
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor - 7))
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to null)))
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to 0.0)))
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to Double.NaN)))
assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", (0..7).associateWith { 2.8 }))
}
@Test fun allCoreGamesUndoTheClientsInheritedRestriction() {
val all = CpuCores.listOrAll("")
assertEquals(all, CpuCores.gameLaunchList("", clientPinned = true))
assertEquals(all, CpuCores.gameLaunchList(all, clientPinned = true))
assertEquals("", CpuCores.gameLaunchList("", clientPinned = false))
assertEquals("0", CpuCores.gameLaunchList("0", clientPinned = true))
}
}
@@ -1,7 +1,6 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.core.CpuAllocationDefaults
import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
@@ -14,36 +13,22 @@ import org.robolectric.annotation.Config
@Config(sdk = [33])
class CoreAllocationPrefsTest {
private val app get() = RuntimeEnvironment.getApplication()
private val defaults = CpuAllocationDefaults.Allocation("7", "3,4,5,6")
private val saved get() = app.getSharedPreferences("session", Context.MODE_PRIVATE)
@Before fun clear() { saved.edit().clear().commit() }
@Test fun absentPreferencesUseTheDeviceDefaultWithoutWritingIt() {
assertEquals(SessionPrefs.CoreAllocation(true, "7", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
assertTrue(saved.all.isEmpty())
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, null))
@Test fun absentPreferencesLeaveEveryCoreToTheScheduler() {
assertFalse(SessionPrefs.clientCpusOverride(app))
assertEquals("", SessionPrefs.clientCpus(app))
assertEquals("", SessionPrefs.gameCpus(app))
}
@Test fun explicitDisableAndAllCoreChoicesSurviveAnUpdate() {
saved.edit().putBoolean("clientCpusOverride", false).putString("clientCpus", "").putString("gameCpus", "").commit()
assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, defaults))
}
@Test fun existingCustomMasksArePreserved() {
saved.edit().putBoolean("clientCpusOverride", true).putString("clientCpus", "0,1").putString("gameCpus", "2,7").commit()
assertEquals(SessionPrefs.CoreAllocation(true, "0,1", "2,7"), SessionPrefs.coreAllocation(app, defaults))
}
@Test fun anOldClientMaskIsNotEnabledWithoutAnOverrideChoice() {
saved.edit().putString("clientCpus", "0,1").commit()
assertEquals(SessionPrefs.CoreAllocation(false, "0,1", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults))
}
@Test fun changingOneChoiceDoesNotReplaceTheOtherDefaults() {
SessionPrefs.setGameCpus(app, "0,1,2,3,4,5,6,7")
assertEquals(SessionPrefs.CoreAllocation(true, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
SessionPrefs.setClientCpusOverride(app, false)
assertEquals(SessionPrefs.CoreAllocation(false, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults))
@Test fun savedChoicesAreKept() {
SessionPrefs.setClientCpusOverride(app, true)
SessionPrefs.setClientCpus(app, "7")
SessionPrefs.setGameCpus(app, "3,4,5,6")
assertTrue(SessionPrefs.clientCpusOverride(app))
assertEquals("7", SessionPrefs.clientCpus(app))
assertEquals("3,4,5,6", SessionPrefs.gameCpus(app))
}
}