mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
feat(performance): switch the GPU top clock hold from the in-game menu (#2882)
This commit is contained in:
1 parent
f2d8e9e837
commit
c2adf3b3dd
40 files changed
+54
-41
No files matched your search
@@ -14,10 +14,22 @@ object GpuClockPin {
|
||||
@Volatile
|
||||
private var pinned = false
|
||||
|
||||
private val supported: Boolean by lazy { File(KGSL_NODE).exists() }
|
||||
@Volatile
|
||||
var failed = false
|
||||
private set
|
||||
|
||||
val supported: Boolean by lazy { File(KGSL_NODE).exists() }
|
||||
|
||||
private var live = false
|
||||
|
||||
@Synchronized
|
||||
fun start(context: Context): String {
|
||||
live = true
|
||||
return hold(context)
|
||||
}
|
||||
|
||||
private fun hold(context: Context): String {
|
||||
failed = false
|
||||
if (!SessionPrefs.gpuClockPin(context)) return "gpu clock: governed"
|
||||
if (!supported) return "gpu clock: no $KGSL_NODE, left governed"
|
||||
return try {
|
||||
@@ -28,12 +40,20 @@ object GpuClockPin {
|
||||
} catch (t: Throwable) {
|
||||
File(context.filesDir, MARKER).delete()
|
||||
Log.w(TAG, "pin", t)
|
||||
failed = true
|
||||
"gpu clock: pin failed"
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun sync(context: Context) {
|
||||
if (!live) return
|
||||
if (SessionPrefs.gpuClockPin(context)) hold(context) else if (pinned) clear(context)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun stop(context: Context) {
|
||||
live = false
|
||||
if (pinned) clear(context)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user