mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
perf(session): boost the game's busiest threads on every Snapdragon 8 Elite (#2608)
Game thread hints only ran on the Odin 3 (CQ8725S). Phones with the SM8750 have the same core layout and power HAL, so turn them on there too. Co-authored-by: Tapuuk <177422350+Tapuuk@users.noreply.github.com>
This commit is contained in:
1 parent
293ed4fb08
commit
68f1d5baa3
2 files changed
+14
-1
No files matched your search
@@ -8,6 +8,7 @@ import android.os.Process
|
||||
import android.system.Os
|
||||
import android.system.OsConstants
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.gpu.SocNames
|
||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
||||
import java.io.File
|
||||
import kotlin.math.abs
|
||||
@@ -26,13 +27,14 @@ object GameThreadHints {
|
||||
private const val PACE_TOLERANCE = 0.08
|
||||
|
||||
private val NOT_GAMES = setOf("steam", "steamwebhelper")
|
||||
private val SOCS = setOf("CQ8725S", "SM8750")
|
||||
|
||||
private var worker: Thread? = null
|
||||
|
||||
@Synchronized
|
||||
fun start(context: Context): String {
|
||||
if (!SessionPrefs.gameThreadHints(context)) return "game thread hints: off"
|
||||
if (Build.VERSION.SDK_INT < 31 || Build.SOC_MODEL != "CQ8725S") return "game thread hints: Odin 3 only"
|
||||
if (Build.VERSION.SDK_INT < 31 || !supported(Build.SOC_MODEL)) return "game thread hints: Snapdragon 8 Elite only"
|
||||
val hm = context.getSystemService(PerformanceHintManager::class.java)
|
||||
?: return "game thread hints: no PerformanceHintManager"
|
||||
val pm = context.getSystemService(PowerManager::class.java)
|
||||
@@ -99,6 +101,8 @@ object GameThreadHints {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun supported(soc: String): Boolean = SocNames.normalizedModel(soc) in SOCS
|
||||
|
||||
internal fun holdsPace(fps: Double, refreshHz: Double): Boolean =
|
||||
fps >= 10 && refreshHz > 0 && (1..4).any { k -> abs(fps - refreshHz / k) < PACE_TOLERANCE * refreshHz / k }
|
||||
|
||||
|
||||
@@ -6,6 +6,15 @@ import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class GameThreadHintsTest {
|
||||
@Test fun `hints run on the Snapdragon 8 Elite only`() {
|
||||
assertTrue(GameThreadHints.supported("CQ8725S"))
|
||||
assertTrue(GameThreadHints.supported("SM8750"))
|
||||
assertTrue(GameThreadHints.supported("QTI SM8750"))
|
||||
assertFalse(GameThreadHints.supported("SM8650"))
|
||||
assertFalse(GameThreadHints.supported("SM8850"))
|
||||
assertFalse(GameThreadHints.supported(""))
|
||||
}
|
||||
|
||||
@Test fun `a thread joins above 60 percent and leaves under 15`() {
|
||||
assertEquals(emptySet<Int>(), GameThreadHints.pick(emptySet(), mapOf(1 to 0.55)))
|
||||
assertEquals(setOf(1), GameThreadHints.pick(emptySet(), mapOf(1 to 0.68)))
|
||||
|
||||
Reference in new issue
Block a user