fix(drivers): Auto gives Xclipse GPUs the old RADV pair only where that build supports them (#2337)

* fix: route unsupported Xclipse generations upstream

* fix: let Auto load upstream Xclipse pairs

* fix: clear stale auto-owned Xclipse RADV pair

* fix(drivers): clear independently owned fallback selections

* fix(drivers): keep independently chosen drivers when session start reconciles an unsupported Xclipse

* fix(drivers): name the Xclipse from Vulkan before session start picks which drivers Auto clears

* fix(drivers): keep the Vulkan query off the UI thread when session start reconciles Xclipse drivers

* test(drivers): control Xclipse GPU family in auto-driver reconciliation test

* fix(gpu): guard Xclipse auto-driver cleanup when running and handle open-driver bundles

* fix(gpu): keep active RADV-Xclipse-upstream bundle on unsupported Xclipse
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-18 10:44:32 -05:00
1 parent ca7b7e74ec
commit bb5218746f
8 files changed
+373 -28

No files matched your search

@@ -319,7 +319,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
refreshDrivers()
return
}
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null &&
if (gpu.family.mali && !DriverPairs.autoEligible(gpu) &&
com.droiddeck.launcher.gpu.VulkanInfo.cachedOrNull() == null) {
releaseChecking = true
autoStatus = activity.getString(R.string.drivers_checking_latest)
@@ -335,14 +335,14 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
}, "gpu-name").start()
return
}
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) -> " + (DriverPairs.recommendedKey(gpu, emptyList()) ?: "no pair"))
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null) {
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) eligible=${DriverPairs.autoEligible(gpu)}")
if (gpu.family.mali && !DriverPairs.autoEligible(gpu)) {
// No PanVK build covers this Mali (e.g. the G1 series, arch v14): the phone's own driver.
autoStatus = useMaliFallback(null)
refreshDrivers()
return
}
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
if (!DriverPairs.autoEligible(gpu)) {
autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity, com.droiddeck.launcher.core.DeviceSupport.vkBridge(activity)).lowercase())
return
}
@@ -372,7 +372,11 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
}
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)
if (gpu.name.contains("Xclipse", ignoreCase = true) && DriverPairs.xclipseNeedsUpstream(gpu.name)) {
if (!SessionState.running) SessionPrefs.ensurePowerVrAutoDrivers(activity, powerVr = true, autoOwnedOnly = true)
} else {
SessionPrefs.ensurePowerVrAutoDrivers(activity)
}
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
refreshDrivers()
}
@@ -18,6 +18,7 @@ object DriverPairs {
/** RADV-Xclipse rebased on JimVulkan's upstream: a manual choice, never Auto. */
const val NAD_RADV_XCLIPSE_UPSTREAM = "nad:radv-xclipse-upstream"
private val XCLIPSE_MODEL = Regex("""(?i)xclipse\s*(\d{3})\b""")
private val SUPPORTED_XCLIPSE_MODELS = setOf("530", "920", "940")
const val NAD_MALI_JM = "nad:panvk-mali-jm"
const val NAD_MALI_G710 = "nad:panvk-mali-g710"
const val NAD_MALI_G615 = "nad:panvk-mali-g615"
@@ -112,9 +113,12 @@ object DriverPairs {
}
}
/** 950 and 960 panic on the older build; a name without a model number is treated the same way. */
private fun xclipseNeedsUpstream(name: String): Boolean =
XCLIPSE_MODEL.find(name)?.groupValues?.get(1).let { it == null || it == "950" || it == "960" }
internal fun xclipseNeedsUpstream(name: String): Boolean =
XCLIPSE_MODEL.find(name)?.groupValues?.get(1) !in SUPPORTED_XCLIPSE_MODELS
fun autoEligible(gpu: GpuInfo, sdk: Int = android.os.Build.VERSION.SDK_INT): Boolean =
recommendedKey(gpu, emptyList(), sdk = sdk) != null ||
(gpu.family == Family.POWERVR && gpu.name.contains("Xclipse", ignoreCase = true))
fun recommendedKey(
gpu: GpuInfo, pairs: List<DriverPair>,
@@ -125,6 +129,7 @@ object DriverPairs {
Family.POWERVR -> return when {
!gpu.name.contains("Xclipse", ignoreCase = true) -> null
xclipseNeedsUpstream(gpu.name) && pairs.any { it.key == NAD_RADV_XCLIPSE_UPSTREAM } -> NAD_RADV_XCLIPSE_UPSTREAM
xclipseNeedsUpstream(gpu.name) -> null
else -> NAD_RADV_XCLIPSE
}
Family.MALI_OTHER, Family.NOT_ADRENO -> return null
@@ -118,9 +118,7 @@ data class GpuInfo(
val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
return GpuInfo(
name = when {
family == Family.POWERVR -> SystemVulkanDriver.gpuName().let { gpu ->
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
}
family == Family.POWERVR -> systemDriverName(SystemVulkanDriver.gpuName(), VulkanInfo.cachedOrNull())
mali != null && mali.isNotEmpty() -> mali
!adreno -> Build.HARDWARE.ifBlank { UNNAMED }
model > 0 -> "Adreno $model"
@@ -134,6 +132,9 @@ data class GpuInfo(
)
}
fun systemDriverName(gpu: String, vulkan: Map<String, String>?): String =
vulkan?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
internal fun verifiedOn(model: Int, device: String): Boolean =
model == 722 && device.equals("Retroid Pocket Duo", ignoreCase = true)
@@ -697,14 +697,42 @@ object SessionPrefs {
}
@JvmStatic
fun ensurePowerVrAutoDrivers(context: Context) {
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context)) return
ensurePowerVrAutoDrivers(context, SystemVulkanDriver.isPowerVr())
fun ensurePowerVrAutoDrivers(context: Context) = reconcilePowerVrAutoDrivers(
context, SystemVulkanDriver.isPowerVr(), SystemVulkanDriver.isXclipse(),
com.droiddeck.launcher.gpu.VulkanInfo::cachedOrNull,
)
fun ensurePowerVrAutoDriversAfterGpuQuery(context: Context) = reconcilePowerVrAutoDrivers(
context, SystemVulkanDriver.isPowerVr(), SystemVulkanDriver.isXclipse(),
com.droiddeck.launcher.gpu.VulkanInfo::query,
)
internal fun reconcilePowerVrAutoDrivers(
context: Context, powerVr: Boolean, xclipse: Boolean, vulkan: () -> Map<String, String>?,
) {
val device = if (xclipse) vulkan() ?: return else null
val unsupported = unsupportedXclipse(xclipse) {
com.droiddeck.launcher.gpu.GpuInfo.systemDriverName(SystemVulkanDriver.gpuName(), device)
}
val activeKey = com.droiddeck.launcher.gpu.DriverBundle.active(context)
?.id
?.let(com.droiddeck.launcher.gpu.DriverPairs::nonAdreno)
val upstreamBundle = activeKey == com.droiddeck.launcher.gpu.DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM ||
(activeKey != null && activeKey.startsWith("${com.droiddeck.launcher.gpu.DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM}-"))
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context) && (!unsupported || upstreamBundle)) return
ensurePowerVrAutoDrivers(context, powerVr, unsupported)
}
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean) {
internal fun unsupportedXclipse(xclipse: Boolean, gpuName: () -> String): Boolean =
xclipse && com.droiddeck.launcher.gpu.DriverPairs.xclipseNeedsUpstream(gpuName())
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean, autoOwnedOnly: Boolean = false) {
if (!powerVr || gpuDriverMode(context) != GPU_DRIVERS_AUTO) return
prefs(context).edit().putString("linuxDriver", "").putString("androidDriver", TurnipDriver.AUTO).apply()
val owned = gpuAutoInstalled(context)
val edit = prefs(context).edit()
if (!autoOwnedOnly || linuxDriver(context) in owned) edit.putString("linuxDriver", "")
if (!autoOwnedOnly || androidDriver(context) in owned) edit.putString("androidDriver", TurnipDriver.AUTO)
edit.apply()
}
fun gpuAutoInstalled(context: Context): Set<String> =
@@ -497,7 +497,7 @@ class SessionService : Service() {
private fun runSession(gen: Int) {
SessionPrefs.ensurePowerVrAutoDrivers(this)
SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this)
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
if (SessionPrefs.venus(this)) VenusComponent.hostVulkanTooOld(this)?.let {
@@ -8,6 +8,10 @@ import com.droiddeck.launcher.session.QuestExperimental
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.gpu.TpUbwcHint
import com.droiddeck.launcher.gpu.TurnipDriver
import com.droiddeck.launcher.gpu.TurnipReleases
import com.droiddeck.launcher.gpu.VulkanInfo
import com.droiddeck.launcher.gpu.SystemVulkanDriver
import com.droiddeck.launcher.wayland.CompositorHost
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
@@ -20,12 +24,26 @@ import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowBuild
import org.robolectric.shadows.ShadowLooper
import org.robolectric.annotation.Implementation
import org.robolectric.annotation.Implements
import org.robolectric.util.ReflectionHelpers
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
@Config(sdk = [28], manifest = Config.NONE, shadows = [DriverMenusAutoTest.XclipseDriver::class])
class DriverMenusAutoTest {
@Implements(SystemVulkanDriver::class)
class XclipseDriver {
companion object {
var enabled = false
@JvmStatic @Implementation fun isPowerVr() = enabled
@JvmStatic @Implementation fun isXclipse() = enabled
@JvmStatic @Implementation fun gpuName() = if (enabled) "Xclipse" else "PowerVR"
}
}
@Before fun reset() {
XclipseDriver.enabled = false
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "resolved", false)
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "cached", null)
ReflectionHelpers.setStaticField(TpUbwcHint::class.java, "activeMode", null)
@@ -35,6 +53,42 @@ class DriverMenusAutoTest {
ShadowBuild.setDevice("eureka")
}
@Test fun unsupportedXclipseFallsBackThroughAutoAndFlagsDisplayRestart() {
XclipseDriver.enabled = true
ShadowBuild.setModel("Generic phone")
ShadowBuild.setDevice("generic")
ReflectionHelpers.setStaticField(VulkanInfo::class.java, "cached", mapOf("device" to "Xclipse 540"))
val originalFetch = TurnipReleases.fetch
TurnipReleases.fetch = { _, _, _ -> "[]" }
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
SessionPrefs.setGpuDriverMode(activity, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setAndroidDriver(activity, "old-display")
SessionPrefs.setLinuxDriver(activity, "old-linux")
SessionPrefs.setGpuAutoInstalled(activity, setOf("old-display", "old-linux"))
ReflectionHelpers.setStaticField(CompositorHost::class.java, "started", true)
CompositorHost.displayChoice = "old-display"
try {
val menus = DriverMenus(activity, Handler(Looper.getMainLooper()))
menus.ensureAuto(force = true)
val deadline = System.currentTimeMillis() + 10000
while (menus.releaseChecking && System.currentTimeMillis() < deadline) {
Thread.sleep(10)
ShadowLooper.idleMainLooper()
}
assertFalse(menus.releaseChecking)
assertEquals(activity.getString(R.string.drivers_powervr_builtin), menus.autoStatus)
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(activity))
assertEquals("", SessionPrefs.linuxDriver(activity))
assertTrue(menus.restartPending)
} finally {
TurnipReleases.fetch = originalFetch
ReflectionHelpers.setStaticField(VulkanInfo::class.java, "cached", null)
ReflectionHelpers.setStaticField(CompositorHost::class.java, "started", false)
CompositorHost.displayChoice = null
XclipseDriver.enabled = false
}
}
@Test fun pickingTheAutoDisplayHandsBothHalvesToAuto() {
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
SessionPrefs.setGpuDriverMode(activity, SessionPrefs.GPU_DRIVERS_MIX)
@@ -217,13 +217,43 @@ class DriverPairsTest {
assertFalse(upstream.suits(GpuInfo("PowerVR", 0, Family.POWERVR, "", false)))
assertEquals("RADV upstream · Samsung Xclipse", upstream.name)
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(xclipse, pairs))
for (name in listOf("Samsung Xclipse 530", "Samsung Xclipse 540", "Samsung Xclipse 920"))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(GpuInfo("Samsung Xclipse 920", 0, Family.POWERVR, "", false), pairs))
for (name in listOf("Samsung Xclipse 530"))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(GpuInfo(name, 0, Family.POWERVR, "", false), pairs))
for (name in listOf("Samsung Xclipse 540", "Samsung Xclipse 950", "Samsung Xclipse 960", "Xclipse"))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM, DriverPairs.recommendedKey(GpuInfo(name, 0, Family.POWERVR, "", false), pairs))
assertTrue(DriverPairs.isNonAdreno("RADV-Xclipse-upstream"))
for (name in listOf("Samsung Xclipse 950", "Samsung Xclipse 960", "Xclipse")) {
val newer = GpuInfo(name, 0, Family.POWERVR, "", false)
assertEquals(DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM, DriverPairs.recommendedKey(newer, pairs))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(newer, pairs.filter { it.key != DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM }))
for (name in listOf("Samsung Xclipse 540", "Samsung Xclipse 950", "Samsung Xclipse 960", "Xclipse"))
assertNull(DriverPairs.recommendedKey(GpuInfo(name, 0, Family.POWERVR, "", false), pairs.filter { it.key != DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM }))
}
@Test
fun autoEligibilityDoesNotDependOnPublishedXclipsePairs() {
fun mali(name: String) = GpuInfo(name, 0, GpuInfo.familyOf(false, 0, mali = name), "", false)
val xclipse540 = GpuInfo("Samsung Xclipse 540", 0, Family.POWERVR, "", false)
val xclipse920 = GpuInfo("Samsung Xclipse 920", 0, Family.POWERVR, "", false)
val upstream = TurnipReleases.Asset("Non-Adreno", "r1", "RADV-Xclipse-upstream.zip", "https://example/upstream", 9_000_000,
false, "label", "0".repeat(64), DriverPairs.nonAdreno("RADV-Xclipse-upstream"), bundle = true)
val pairs = DriverPairs.from(TurnipReleases.Check(listOf(upstream), emptyList(), emptyList(), 0L))
assertTrue(DriverPairs.autoEligible(xclipse540))
assertNull(DriverPairs.recommendedKey(xclipse540, emptyList()))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM, DriverPairs.recommendedKey(xclipse540, pairs))
assertTrue(DriverPairs.autoEligible(xclipse920))
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(xclipse920, emptyList()))
assertTrue(DriverPairs.autoEligible(gpu(740)))
assertTrue(DriverPairs.autoEligible(mali("Mali-G57")))
assertFalse(DriverPairs.autoEligible(mali("Mali-G1-Ultra")))
assertFalse(DriverPairs.autoEligible(GpuInfo("PowerVR", 0, Family.POWERVR, "", false)))
}
@Test
fun autoEligibilityMatchesRecommendedKeyForAdrenoAndMali() {
fun mali(name: String) = GpuInfo(name, 0, GpuInfo.familyOf(false, 0, mali = name), "", false)
for (gpu in listOf(gpu(710), gpu(740), mali("Mali-G57"), mali("Mali-G925-Immortalis MC12"))) {
assertEquals(
DriverPairs.recommendedKey(gpu, emptyList(), sdk = 34) != null,
DriverPairs.autoEligible(gpu, sdk = 34),
)
}
}
@@ -1,26 +1,94 @@
package com.droiddeck.launcher.session
import android.content.Context
import org.robolectric.RuntimeEnvironment
import android.net.Uri
import com.droiddeck.launcher.DriverMenusAutoTest
import com.droiddeck.launcher.core.DeviceSupport
import com.droiddeck.launcher.gpu.DriverBundle
import com.droiddeck.launcher.gpu.GpuInfo
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
import com.droiddeck.launcher.gpu.TurnipDriver
import org.json.JSONObject
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import java.io.File
import java.util.zip.ZipEntry
import java.util.zip.ZipOutputStream
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], manifest = Config.NONE)
@Config(sdk = [28], manifest = Config.NONE, shadows = [DriverMenusAutoTest.XclipseDriver::class])
class PowerVrAutoDriversTest {
private val context: Context = RuntimeEnvironment.getApplication()
@Before fun reset() {
DriverMenusAutoTest.XclipseDriver.enabled = false
clearBundles()
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
SessionPrefs.setLinuxDriver(context, "imported-linux")
SessionPrefs.setAndroidDriver(context, "imported-display")
}
@After fun cleanupBundles() {
clearBundles()
}
private fun clearBundles() {
File(context.filesDir, "graphics_driver").deleteRecursively()
File(context.filesDir, LinuxVulkanDriverManager.DIR_NAME).deleteRecursively()
context.getSharedPreferences("driver_bundles", Context.MODE_PRIVATE).edit().clear().commit()
}
private fun installAndSelectNonAdrenoBundle(
tag: String = "RADV-Xclipse",
packageName: String = "RADV-Xclipse",
): DriverBundle.Bundle {
fun library(libc: String) = ByteArray(64).also {
byteArrayOf(0x7f, 'E'.code.toByte(), 'L'.code.toByte(), 'F'.code.toByte(), 2, 1).copyInto(it)
it[18] = 0xB7.toByte()
} + libc.toByteArray() + ByteArray(1)
val manifest = JSONObject()
.put("package", packageName)
.put("version", "0.1.0")
.put("tag", tag)
.put(
"drivers",
JSONObject()
.put("android", JSONObject().put("path", "android"))
.put("linux", JSONObject().put("path", "linux")),
)
val entries = mapOf(
"android/meta.json" to JSONObject().put("name", "radv v0.1.0").put("libraryName", "libvulkan_radeon.so").toString().toByteArray(),
"android/libvulkan_radeon.so" to library("libc.so"),
"linux/meta.json" to JSONObject().put("name", "radv v0.1.0").put("driverVersion", "radv-test").toString().toByteArray(),
"linux/libvulkan_radeon.so" to library("libc.so.6"),
"manifest.json" to manifest.toString().toByteArray(),
)
val file = File.createTempFile("radv-bundle", ".zip", context.cacheDir)
return try {
ZipOutputStream(file.outputStream()).use { z ->
for ((name, data) in entries) {
z.putNextEntry(ZipEntry(name))
z.write(data)
z.closeEntry()
}
}
val bundle = DriverBundle.install(context, Uri.fromFile(file))
DriverBundle.select(context, bundle)
bundle
} finally {
file.delete()
}
}
@Test fun autoRepairsStaleAdrenoSelectionsOnPowerVr() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true)
@@ -28,17 +96,172 @@ class PowerVrAutoDriversTest {
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
@Test fun explicitManualChoicesRemainOnPowerVr() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_MANUAL)
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true)
@Test fun nonXclipsePowerVrKeepsManualPair() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = true)
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
assertEquals("imported-display", SessionPrefs.androidDriver(context))
}
@Test fun unsupportedXclipseClearsAnAutoOwnedOldPair() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setLinuxDriver(context, "old-linux")
SessionPrefs.setAndroidDriver(context, "old-display")
SessionPrefs.setGpuAutoInstalled(context, setOf("old-display", "old-linux"))
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = true)
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
@Test fun unsupportedXclipseKeepsAManualPair() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_MANUAL)
SessionPrefs.setLinuxDriver(context, "old-linux")
SessionPrefs.setAndroidDriver(context, "old-display")
SessionPrefs.setGpuAutoInstalled(context, setOf("old-display", "old-linux"))
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = true)
assertEquals("old-linux", SessionPrefs.linuxDriver(context))
assertEquals("old-display", SessionPrefs.androidDriver(context))
}
@Test fun autoClearsOwnedDisplayButKeepsManualLinux() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-display"))
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = true)
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
}
@Test fun autoClearsOwnedLinuxButKeepsManualDisplay() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-linux"))
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = true)
assertEquals("imported-display", SessionPrefs.androidDriver(context))
assertEquals("", SessionPrefs.linuxDriver(context))
}
@Test fun adrenoAutoChoicesRemain() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = false)
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
assertEquals("imported-display", SessionPrefs.androidDriver(context))
}
@Test fun sessionStartKeepsStandaloneDriverOnUnsupportedXclipse() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setAndroidDriver(context, "standalone-display")
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-linux"))
val ownedOnly = SessionPrefs.unsupportedXclipse(true) { "Samsung Xclipse 540" }
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = ownedOnly)
assertEquals("standalone-display", SessionPrefs.androidDriver(context))
assertEquals("", SessionPrefs.linuxDriver(context))
}
@Test fun sessionStartOwnershipRuleIgnoresOtherGpus() {
assertEquals(false, SessionPrefs.unsupportedXclipse(false) { "Samsung Xclipse 540" })
assertEquals(false, SessionPrefs.unsupportedXclipse(true) { "Samsung Xclipse 920" })
}
@Test fun sessionStartNamesTheXclipseFromVulkanBeforeTheOwnershipRule() {
val queried = mapOf("device" to "Samsung Xclipse 920")
assertEquals("Xclipse", GpuInfo.systemDriverName("Xclipse", null))
assertEquals("Samsung Xclipse 920", GpuInfo.systemDriverName("Xclipse", queried))
assertEquals("PowerVR", GpuInfo.systemDriverName("PowerVR", queried))
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-linux"))
val ownedOnly = SessionPrefs.unsupportedXclipse(true) { GpuInfo.systemDriverName("Xclipse", queried) }
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true, autoOwnedOnly = ownedOnly)
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
@Test fun sessionStartLeavesTheGpuUnqueriedOffXclipse() {
var asked = false
assertEquals(false, SessionPrefs.unsupportedXclipse(false) { asked = true; "Xclipse" })
assertEquals(false, asked)
}
@Test fun cachedOnlySessionStartLeavesPrefsWhenTheXclipseIsUnnamed() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-display", "imported-linux"))
var reads = 0
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) { reads++; null }
assertEquals(1, reads)
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
assertEquals("imported-display", SessionPrefs.androidDriver(context))
}
@Test fun sessionStartWithANamedXclipseClearsOnlyAutoOwnedSelections() {
DriverMenusAutoTest.XclipseDriver.enabled = true
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf("imported-linux"))
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) {
mapOf("device" to "Samsung Xclipse 540")
}
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals("imported-display", SessionPrefs.androidDriver(context))
}
@Test fun sessionStartUnsupportedXclipseResetsAutoOwnedEvenWithBothOpenDriversSelected() {
DriverMenusAutoTest.XclipseDriver.enabled = true
val bundle = installAndSelectNonAdrenoBundle()
assertTrue(DeviceSupport.openDriverActive(context))
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf(bundle.androidId, bundle.linuxId))
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) {
mapOf("device" to "Samsung Xclipse 540")
}
assertFalse(DeviceSupport.openDriverActive(context))
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
@Test fun sessionStartUnsupportedXclipseKeepsAutoOwnedUpstreamBundle() {
DriverMenusAutoTest.XclipseDriver.enabled = true
val bundle = installAndSelectNonAdrenoBundle(
tag = "RADV-Xclipse-upstream",
packageName = "RADV-Xclipse-upstream",
)
assertTrue(DeviceSupport.openDriverActive(context))
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf(bundle.androidId, bundle.linuxId))
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) {
mapOf("device" to "Samsung Xclipse 540")
}
assertTrue(DeviceSupport.openDriverActive(context))
assertEquals(bundle.linuxId, SessionPrefs.linuxDriver(context))
assertEquals(bundle.androidId, SessionPrefs.androidDriver(context))
}
@Test fun sessionStartSupportedXclipseKeepsActiveOpenDriverBundle() {
DriverMenusAutoTest.XclipseDriver.enabled = true
val bundle = installAndSelectNonAdrenoBundle()
assertTrue(DeviceSupport.openDriverActive(context))
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.setGpuAutoInstalled(context, setOf(bundle.androidId, bundle.linuxId))
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) {
mapOf("device" to "Samsung Xclipse 920")
}
assertTrue(DeviceSupport.openDriverActive(context))
assertEquals(bundle.linuxId, SessionPrefs.linuxDriver(context))
assertEquals(bundle.androidId, SessionPrefs.androidDriver(context))
}
@Test fun sessionStartWithASupportedXclipseClearsUnownedSelections() {
DriverMenusAutoTest.XclipseDriver.enabled = true
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = true) {
mapOf("device" to "Samsung Xclipse 920")
}
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
@Test fun sessionStartReadsNoVulkanNameOffXclipse() {
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
SessionPrefs.reconcilePowerVrAutoDrivers(context, powerVr = true, xclipse = false) {
throw AssertionError("queried")
}
assertEquals("", SessionPrefs.linuxDriver(context))
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
}
}