mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(graphics): make Auto-owned Mali fallback state explicit (#2406)
* fix(graphics): make Auto-owned Mali fallback state explicit * fix(graphics): a route Auto stored itself is not counted as the user's choice
This commit is contained in:
1 parent
decab6ea90
commit
a4558c841a
4 files changed
+123
-7
No files matched your search
@@ -286,7 +286,13 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
// Builds before 0.5.0-nad1 turned the bridge on under Auto without recording it, and
|
||||
// left it on for good (it wins over the pair). Under Auto that switch is taken as Auto's.
|
||||
if (!SessionPrefs.maliFallbackKnown(activity))
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, if (SessionPrefs.vkBridge(activity)) "bridge" else "")
|
||||
SessionPrefs.setMaliFallbackByAuto(
|
||||
activity,
|
||||
MaliAutoRoute.initialOwnership(
|
||||
SessionPrefs.vkBridge(activity), bridgeExplicit(),
|
||||
SessionPrefs.venus(activity), venusExplicit(),
|
||||
),
|
||||
)
|
||||
// A lone imported PanVK Android driver set by hand stalls the display the same way
|
||||
// ("black screen with the start-up logo"), so under Auto any imported display goes.
|
||||
val display = SessionPrefs.androidDriver(activity)
|
||||
@@ -356,8 +362,14 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
val pair = pairs.firstOrNull { it.key == key }
|
||||
val row = pairRows.firstOrNull { it.key == key }
|
||||
when {
|
||||
row?.active == true -> autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
|
||||
?: activity.getString(R.string.upd_current_status)
|
||||
row?.active == true -> {
|
||||
if (MaliAutoRoute.shouldEnd(
|
||||
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali,
|
||||
pair?.key?.let { DriverPairs.isNonAdreno(it) } == true,
|
||||
)) endMaliFallback()
|
||||
autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
|
||||
?: activity.getString(R.string.upd_current_status)
|
||||
}
|
||||
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
|
||||
// RADV is not published right now: the Xclipse falls back to the system route.
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
@@ -397,6 +409,12 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
}, "gpu-driver-auto").start()
|
||||
}
|
||||
|
||||
private fun bridgeExplicit(): Boolean =
|
||||
MaliAutoRoute.userChoice(SessionPrefs.vkBridgeExplicit(activity), SessionPrefs.maliFallbackByAuto(activity), MaliAutoRoute.BRIDGE)
|
||||
|
||||
private fun venusExplicit(): Boolean =
|
||||
MaliAutoRoute.userChoice(SessionPrefs.venusExplicit(activity), SessionPrefs.maliFallbackByAuto(activity), MaliAutoRoute.VENUS)
|
||||
|
||||
/**
|
||||
* A Mali with no open driver pair to install ([missing] names the unpublished pair, or null when
|
||||
* no PanVK build covers this GPU) runs through the phone's own driver: Mali (Venus) where this
|
||||
@@ -410,12 +428,21 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity)
|
||||
val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity)
|
||||
if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in")
|
||||
val ownership = MaliAutoRoute.fallbackOwnership(
|
||||
venus,
|
||||
SessionPrefs.vkBridge(activity), bridgeExplicit(),
|
||||
SessionPrefs.venus(activity), venusExplicit(),
|
||||
)
|
||||
if (venus && !SessionPrefs.venus(activity)) {
|
||||
SessionPrefs.setVenus(activity, true)
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, "venus")
|
||||
if (SessionPrefs.vkBridge(activity) && !bridgeExplicit())
|
||||
SessionPrefs.setVkBridge(activity, false)
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
|
||||
} else if (!venus && !SessionPrefs.vkBridge(activity)) {
|
||||
SessionPrefs.setVkBridge(activity, true)
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, "bridge")
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
|
||||
} else if (ownership != MaliAutoRoute.NONE) {
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
|
||||
}
|
||||
val route = activity.getString(if (venus) R.string.drivers_route_venus else R.string.drivers_route_bridge)
|
||||
Log.i(TAG, "auto: Mali stand-in route $route (missing pair: ${missing ?: "none covers ${gpu.name}"})")
|
||||
@@ -503,7 +530,9 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
// A route Auto switched on in place of a missing pair goes off now that one is
|
||||
// here. A Mali bridge or Venus switch the user set stays: it wins for the session
|
||||
// (DeviceSupport.vkBridge, VenusComponent.wanted) and the pair waits.
|
||||
if (gpu.family.mali && DriverPairs.isNonAdreno(pair.key)) endMaliFallback()
|
||||
if (MaliAutoRoute.shouldEnd(
|
||||
SessionPrefs.maliFallbackByAuto(activity), gpu.family.mali, DriverPairs.isNonAdreno(pair.key),
|
||||
)) endMaliFallback()
|
||||
val restart = displayChanged && CompositorHost.isStarted
|
||||
if (auto) {
|
||||
val trial = AutoDriverTrial.current(activity)
|
||||
@@ -744,4 +773,3 @@ internal fun Context.displayNameOf(uri: Uri): String? = if (uri.scheme == "file"
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.droiddeck.launcher
|
||||
|
||||
internal object MaliAutoRoute {
|
||||
const val NONE = ""
|
||||
const val BRIDGE = "bridge"
|
||||
const val VENUS = "venus"
|
||||
|
||||
fun initialOwnership(bridgeOn: Boolean, bridgeExplicit: Boolean, venusOn: Boolean, venusExplicit: Boolean): String =
|
||||
when {
|
||||
venusOn && !venusExplicit -> VENUS
|
||||
bridgeOn && !bridgeExplicit -> BRIDGE
|
||||
else -> NONE
|
||||
}
|
||||
|
||||
fun fallbackOwnership(
|
||||
venusAvailable: Boolean,
|
||||
bridgeOn: Boolean,
|
||||
bridgeExplicit: Boolean,
|
||||
venusOn: Boolean,
|
||||
venusExplicit: Boolean,
|
||||
): String = if (venusAvailable) {
|
||||
if (!venusOn || !venusExplicit) VENUS else NONE
|
||||
} else {
|
||||
if (!bridgeOn || !bridgeExplicit) BRIDGE else NONE
|
||||
}
|
||||
|
||||
fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route
|
||||
|
||||
fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean =
|
||||
mali && installedPair && ownsRoute != NONE
|
||||
}
|
||||
@@ -907,8 +907,12 @@ object SessionPrefs {
|
||||
@JvmStatic
|
||||
fun vkBridge(context: Context): Boolean = prefs(context).getBoolean("vkBridge", com.droiddeck.launcher.core.DeviceSupport.mali())
|
||||
|
||||
fun vkBridgeExplicit(context: Context): Boolean = prefs(context).contains("vkBridge")
|
||||
|
||||
fun venus(context: Context): Boolean = prefs(context).getBoolean("venus", false)
|
||||
|
||||
fun venusExplicit(context: Context): Boolean = prefs(context).contains("venus")
|
||||
|
||||
fun hostVulkanApi(context: Context): String = prefs(context).getString("hostVulkanApi", "").orEmpty()
|
||||
|
||||
fun setHostVulkanApi(context: Context, api: String) {
|
||||
|
||||
Reference in new issue
Block a user