mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
Merge #570 (PowerVR + Xclipse system Vulkan) into the non-Adreno test branch
# Conflicts: # .github/workflows/build.yml # app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt # app/src/main/java/com/droiddeck/launcher/session/SessionService.kt # tools/build_local.sh # tools/dxvk/build.sh # tools/linuxfs/overlay/usr/local/bin/droiddeck-session # tools/release/runtime_inputs.py # tools/tests/test_runtime_inputs.py
This commit is contained in:
commit
56dc433673
104 files changed
+7206
-206
No files matched your search
@@ -16,6 +16,7 @@ import com.droiddeck.launcher.gpu.DriverPairs
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipReleases
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
@@ -64,7 +65,8 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
autoStatus = autoStatus, releaseStatus = releaseStatus.ifEmpty { activity.getString(R.string.drivers_not_checked) }, checking = releaseChecking,
|
||||
linuxRows = linuxRows, linuxSelected = linuxSelected, androidRows = androidRows, androidSelected = androidSelected,
|
||||
linuxDownloads = linuxDownloads, androidDownloads = androidDownloads, canRestoreBundled = canRestoreBundled,
|
||||
activeBundle = activeBundle,
|
||||
activeBundle = activeBundle, powerVr = gpu.family == GpuInfo.Family.POWERVR,
|
||||
systemPowerVr = SystemVulkanDriver.usesDefault(linuxSelected),
|
||||
)
|
||||
var androidRows by mutableStateOf<List<DriverRow>>(emptyList())
|
||||
var androidSelected by mutableStateOf("")
|
||||
@@ -77,7 +79,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
DriverRow(id, it.label, activity.getString(if (linux) R.string.drivers_bundle_sets_display else R.string.drivers_bundle_sets_runtime), true, DriverRow.BUNDLE)
|
||||
}
|
||||
linuxRows = LinuxVulkanDriver.optionValues(activity).map { id ->
|
||||
if (id.isEmpty()) DriverRow("", activity.getString(R.string.gpu_runtime_default), activity.getString(R.string.drivers_runtime_builtin), false)
|
||||
if (id.isEmpty()) DriverRow("", activity.getString(if (gpu.family == GpuInfo.Family.POWERVR) R.string.gpu_system_powervr else R.string.gpu_runtime_default), activity.getString(R.string.drivers_runtime_builtin), false)
|
||||
else bundleRow(id, linux = true) ?: DriverRow(
|
||||
id, lm.getDriverName(id),
|
||||
listOfNotNull(
|
||||
@@ -110,6 +112,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
/** One line for the settings row that opens this: "Auto · WinNative · Balanced". */
|
||||
fun summary(): String {
|
||||
val active = pairRows.firstOrNull { it.active }?.name ?: activeBundle
|
||||
?: if (SystemVulkanDriver.usesDefault(linuxSelected) && androidSelected == TurnipDriver.AUTO) activity.getString(R.string.gpu_system_powervr) else null
|
||||
val label = activity.getString(if (mode == SessionPrefs.GPU_DRIVERS_AUTO) R.string.common_auto else R.string.drivers_manual)
|
||||
return active?.let { activity.getString(R.string.drivers_summary, label, it) } ?: label
|
||||
}
|
||||
@@ -152,6 +155,13 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
fun ensureAuto(force: Boolean) {
|
||||
mode = SessionPrefs.gpuDriverMode(activity)
|
||||
if (mode != SessionPrefs.GPU_DRIVERS_AUTO || pairBusy != null || releaseChecking) return
|
||||
if (gpu.family == GpuInfo.Family.POWERVR) {
|
||||
// Auto owns both choices. Manual imports remain available when Manual is selected.
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
if (!force && autoCheckedThisProcess) return
|
||||
autoCheckedThisProcess = true
|
||||
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
|
||||
|
||||
@@ -1677,7 +1677,7 @@ class MainActivity : ComponentActivity() {
|
||||
// The runtime draws with Turnip, an Adreno driver: on Mali, Xclipse or PowerVR the
|
||||
// compositor gets no usable Vulkan device and a session is sound over a black screen.
|
||||
// Said before the download, not after it; the user may still go ahead.
|
||||
if (installed == null && !com.droiddeck.launcher.core.DeviceSupport.adreno()) { showNonAdreno = release; return }
|
||||
if (installed == null && !com.droiddeck.launcher.core.DeviceSupport.graphicsAvailable()) { showNonAdreno = release; return }
|
||||
install(release)
|
||||
}
|
||||
|
||||
@@ -1689,7 +1689,7 @@ class MainActivity : ComponentActivity() {
|
||||
showPhantomGate = true
|
||||
return false
|
||||
}
|
||||
val warn = installed == null && !com.droiddeck.launcher.core.DeviceSupport.adreno()
|
||||
val warn = installed == null && !com.droiddeck.launcher.core.DeviceSupport.graphicsAvailable()
|
||||
if (warn && available != null) { showNonAdreno = available; return false }
|
||||
startActivity(intent)
|
||||
return true
|
||||
|
||||
@@ -588,6 +588,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
)
|
||||
SessionDrawer(drawerOpen, drawerPage, drawerControllerActive, onPageChange = { drawerPage = it }, a = DrawerActions(
|
||||
steam = SessionState.mode == SessionService.MODE_STEAM,
|
||||
systemPowerVr = com.droiddeck.launcher.gpu.SystemVulkanDriver.usesDefault(
|
||||
SessionPrefs.linuxDriver(this@SessionActivity)),
|
||||
title = if (SessionState.mode == SessionService.MODE_RUN)
|
||||
com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_title_game) else null,
|
||||
isHomeApp = isHomeApp,
|
||||
@@ -1288,8 +1290,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
// the evdev codes we inject.
|
||||
FileUtils.copyAsset(this, "wayland/keymap.xkb", File(runtimeDir, "keymap.xkb"))
|
||||
|
||||
// Turnip, not the system Adreno driver: importing the dma-bufs gamescope commits needs
|
||||
// VK_EXT_image_drm_format_modifier, which the system driver does not implement.
|
||||
// Adreno imports dma-bufs with Turnip. PowerVR uses its system Vulkan driver
|
||||
// to import the Android hardware buffers supplied by the runtime bridge.
|
||||
val turnip = TurnipDriver(this)
|
||||
val driverId = if (CompositorHost.isStarted) null else turnip.install()
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.gpu.DeviceInfo
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
@@ -103,7 +105,11 @@ object DeviceReport {
|
||||
h("GPU")
|
||||
k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model"))
|
||||
k("KGSL chip id", readSys("/sys/class/kgsl/kgsl-3d0/gpu_chipid"))
|
||||
k("System Vulkan ICD", if (File("/vendor/lib64/hw/vulkan.adreno.so").exists()) "/vendor/lib64/hw/vulkan.adreno.so" else "not at the usual path")
|
||||
k("System Vulkan ICD", when {
|
||||
SystemVulkanDriver.isPowerVr() -> SystemVulkanDriver.hal()
|
||||
File("/vendor/lib64/hw/vulkan.adreno.so").exists() -> "/vendor/lib64/hw/vulkan.adreno.so"
|
||||
else -> "not at the usual path"
|
||||
})
|
||||
|
||||
h("Display")
|
||||
k("Session output", SessionState.outputSize?.let { "${it.first}x${it.second}" })
|
||||
@@ -124,16 +130,20 @@ object DeviceReport {
|
||||
com.droiddeck.launcher.gpu.TurnipReleases.cached(context)))?.let { " (recommended pair: $it)" } ?: ""))
|
||||
val turnip = TurnipDriver(context)
|
||||
val androidChoice = SessionPrefs.androidDriver(context)
|
||||
k("Display driver (chosen)", if (androidChoice.isEmpty()) "Auto -> ${turnip.autoId()}" else androidChoice)
|
||||
k(" name / version", "${turnip.displayName(if (androidChoice.isEmpty()) turnip.autoId() else androidChoice)} ${turnip.driverVersion(if (androidChoice.isEmpty()) turnip.autoId() else androidChoice)}".trim())
|
||||
val displayId = androidChoice.ifEmpty { turnip.autoId() }
|
||||
val displayLabel = if (displayId == "system") DeviceInfo.builtinDriverLabel(SystemVulkanDriver.isPowerVr(), runtime = false)
|
||||
else "${turnip.displayName(displayId)} ${turnip.driverVersion(displayId)}".trim()
|
||||
k("Display driver (chosen)", if (androidChoice.isEmpty()) "Auto -> $displayLabel" else androidChoice)
|
||||
k(" name / version", displayLabel)
|
||||
k(" imported available", turnip.enumerateImported().ifEmpty { listOf("none") }.joinToString(", "))
|
||||
val lm = LinuxVulkanDriverManager(context)
|
||||
run {
|
||||
val id = SessionPrefs.linuxDriver(context)
|
||||
val label = if (id.isEmpty()) "runtime default (the Turnip built into the runtime)"
|
||||
val label = if (id.isEmpty()) DeviceInfo.builtinDriverLabel(SystemVulkanDriver.isPowerVr(), runtime = true)
|
||||
else "${lm.getDriverName(id)} ${lm.getDriverVersion(id)}".trim() +
|
||||
lm.getMinGlibc(id).let { if (it.isEmpty()) "" else " (glibc $it+)" } +
|
||||
if (lm.isInstalled(id)) "" else " [MISSING - falls back to the runtime's own]"
|
||||
if (lm.isInstalled(id)) "" else if (SystemVulkanDriver.isPowerVr()) " [MISSING - select an installed driver or Auto]"
|
||||
else " [MISSING - falls back to the runtime's own]"
|
||||
k("Linux driver", label)
|
||||
}
|
||||
k("Runtime's own ICD", LinuxRuntime.vulkanIcd(context)?.path)
|
||||
|
||||
@@ -3,21 +3,20 @@ package com.droiddeck.launcher.core
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Whether this device can draw a Linux session at all.
|
||||
*
|
||||
* The runtime draws with Turnip, an Adreno driver. On Mali, Xclipse and PowerVR the compositor
|
||||
* gets no usable Vulkan device and a session comes up as sound over a black screen - a failure
|
||||
* with nothing in it to read. The app cannot fix that, so it says so before the download rather
|
||||
* than after it. Adreno is recognised by what only Qualcomm's stack has: the KGSL node, or the
|
||||
* vendor's own Vulkan driver at its usual path.
|
||||
*/
|
||||
/** Whether this device has a graphics backend the runtime can use. Adreno uses Turnip;
|
||||
* PowerVR uses its vendor Vulkan driver through the bundled runtime bridge. Other GPU families
|
||||
* still need a supported backend before a session can display frames. */
|
||||
object DeviceSupport {
|
||||
fun adreno(): Boolean =
|
||||
File("/sys/class/kgsl/kgsl-3d0").exists() || File("/vendor/lib64/hw/vulkan.adreno.so").exists()
|
||||
|
||||
fun graphicsAvailable(): Boolean = graphicsAvailable(adreno(), SystemVulkanDriver.isAvailable())
|
||||
|
||||
internal fun graphicsAvailable(adreno: Boolean, powerVrReady: Boolean): Boolean = adreno || powerVrReady
|
||||
|
||||
/** The chip as the device names it, for the card that explains the refusal. */
|
||||
fun gpuName(context: Context): String {
|
||||
val soc = if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL.takeIf { it.isNotBlank() && it != Build.UNKNOWN } else null
|
||||
|
||||
@@ -157,10 +157,20 @@ object DeviceInfo {
|
||||
add("Driver mode", SessionPrefs.gpuDriverMode(context))
|
||||
val turnip = TurnipDriver(context)
|
||||
val choice = SessionPrefs.androidDriver(context).ifEmpty { turnip.autoId() }
|
||||
add("Display driver", "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
||||
val powerVr = gpu.family == GpuInfo.Family.POWERVR
|
||||
add("Display driver", if (choice == "system") builtinDriverLabel(powerVr, runtime = false)
|
||||
else "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
||||
val linux = LinuxVulkanDriverManager(context)
|
||||
val id = SessionPrefs.linuxDriver(context)
|
||||
add("Game driver", if (id.isEmpty()) "the runtime's own Turnip" else "${linux.getDriverName(id)} ${linux.getDriverVersion(id)}".trim())
|
||||
add("Game driver", if (id.isEmpty()) builtinDriverLabel(powerVr, runtime = true) else "${linux.getDriverName(id)} ${linux.getDriverVersion(id)}".trim())
|
||||
if (gpu.oneUi8Gen2) add("Note", "One UI on an 8 Gen 2: needs the OneUI Turnip build")
|
||||
})
|
||||
|
||||
/** Shared by the device card and the session report, which are written in English. */
|
||||
internal fun builtinDriverLabel(powerVr: Boolean, runtime: Boolean): String = when {
|
||||
powerVr -> "System PowerVR"
|
||||
runtime -> "the runtime's own Turnip"
|
||||
else -> "System Vulkan"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,7 +93,7 @@ object DriverPairs {
|
||||
* the 710/720/722, and upstream Banners-Turnip for the rest. Null when nothing fits (not Adreno).
|
||||
*/
|
||||
fun recommendedKey(gpu: GpuInfo, pairs: List<DriverPair>): String? = when (gpu.family) {
|
||||
Family.NOT_ADRENO -> null
|
||||
Family.NOT_ADRENO, Family.POWERVR -> null
|
||||
Family.A8XX -> if (gpu.model == 840) newestDdTurnip(pairs) ?: WN_BALANCED else WN_BALANCED
|
||||
Family.A7XX_LOW -> BANNER_710
|
||||
Family.A7XX -> if (gpu.oneUi8Gen2) BANNER_ONEUI else BANNER
|
||||
|
||||
@@ -35,6 +35,7 @@ data class GpuInfo(
|
||||
A6XX("Adreno 6xx"),
|
||||
/** An Adreno whose model KGSL does not give: treated as the newest family it could be. */
|
||||
ADRENO_UNKNOWN("Adreno"),
|
||||
POWERVR("PowerVR"),
|
||||
NOT_ADRENO("Not an Adreno GPU");
|
||||
|
||||
/** [label] in the app's language: the Adreno families are names, the rest is words. */
|
||||
@@ -56,15 +57,22 @@ data class GpuInfo(
|
||||
val supportText: String
|
||||
get() = when (support) {
|
||||
Support.TESTED -> "Supported"
|
||||
Support.UNTESTED -> if (family == Family.A7XX_LOW) "Experimental: its drivers are test builds"
|
||||
else "Outside tested hardware (Adreno 650, 725 and newer): it may not run"
|
||||
Support.UNSUPPORTED -> "Not supported: DroidDeck needs an Adreno (Snapdragon) GPU"
|
||||
Support.UNTESTED -> when (family) {
|
||||
Family.POWERVR -> "System PowerVR driver: compatibility varies by device"
|
||||
Family.A7XX_LOW -> "Experimental: its drivers are test builds"
|
||||
else -> "Outside tested hardware (Adreno 650, 725 and newer): it may not run"
|
||||
}
|
||||
Support.UNSUPPORTED -> "Not supported: no compatible graphics backend is available for this GPU"
|
||||
}
|
||||
|
||||
/** [supportText] in the app's language. */
|
||||
fun supportText(context: Context): String = context.getString(when (support) {
|
||||
Support.TESTED -> R.string.gpuinfo_supported
|
||||
Support.UNTESTED -> if (family == Family.A7XX_LOW) R.string.gpuinfo_experimental else R.string.gpuinfo_below_tested
|
||||
Support.UNTESTED -> when (family) {
|
||||
Family.POWERVR -> R.string.gpuinfo_powervr
|
||||
Family.A7XX_LOW -> R.string.gpuinfo_experimental
|
||||
else -> R.string.gpuinfo_below_tested
|
||||
}
|
||||
Support.UNSUPPORTED -> R.string.gpuinfo_unsupported
|
||||
})
|
||||
|
||||
@@ -94,10 +102,17 @@ data class GpuInfo(
|
||||
fromPlatform > 0 -> "platform"
|
||||
else -> ""
|
||||
}
|
||||
val family = familyOf(adreno, model)
|
||||
val family = familyOf(adreno, model, SystemVulkanDriver.isPowerVr())
|
||||
val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||
return GpuInfo(
|
||||
name = if (!adreno) Build.HARDWARE.ifBlank { UNNAMED } else if (model > 0) "Adreno $model" else "Adreno",
|
||||
name = when {
|
||||
family == Family.POWERVR -> SystemVulkanDriver.gpuName().let { gpu ->
|
||||
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
|
||||
}
|
||||
!adreno -> Build.HARDWARE.ifBlank { UNNAMED }
|
||||
model > 0 -> "Adreno $model"
|
||||
else -> "Adreno"
|
||||
},
|
||||
model = model, family = family, soc = soc,
|
||||
oneUi8Gen2 = samsung && model == 740,
|
||||
kgslName = raw.orEmpty(), modelSource = source,
|
||||
@@ -122,7 +137,8 @@ data class GpuInfo(
|
||||
""
|
||||
}
|
||||
|
||||
internal fun familyOf(adreno: Boolean, model: Int): Family = when {
|
||||
internal fun familyOf(adreno: Boolean, model: Int, powerVr: Boolean = false): Family = when {
|
||||
!adreno && powerVr -> Family.POWERVR
|
||||
!adreno -> Family.NOT_ADRENO
|
||||
model == 0 -> Family.ADRENO_UNKNOWN
|
||||
model >= 800 -> Family.A8XX
|
||||
|
||||
@@ -3,8 +3,12 @@ package com.droiddeck.launcher.gpu;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.droiddeck.launcher.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* The Vulkan driver a session draws with inside the runtime: in Steam mode the native client's
|
||||
@@ -17,7 +21,8 @@ import java.util.List;
|
||||
* these are glibc processes, that one is bionic.
|
||||
*
|
||||
* <p>"" (the default) means the driver the runtime was built with, at
|
||||
* {@code usr/lib/libvulkan_freedreno.so} inside it - nothing is set and nothing is touched.
|
||||
* {@code usr/lib/libvulkan_freedreno.so} on Adreno, or the bundled bridge to the system
|
||||
* PowerVR driver.
|
||||
* Otherwise the value is an imported driver's id ({@link LinuxVulkanDriverManager}), and the
|
||||
* session is handed that driver's ICD manifest in {@code BL_VK_DRIVER}: the session script points
|
||||
* the Vulkan loader at it with {@code VK_DRIVER_FILES} after checking both the manifest and the
|
||||
@@ -47,30 +52,44 @@ public final class LinuxVulkanDriver {
|
||||
}
|
||||
|
||||
/**
|
||||
* Label for a stored value. An id that is no longer installed says so - the launch path falls
|
||||
* back to the runtime's own driver for it.
|
||||
* Label for a stored value. Missing imports fall back to the runtime on Adreno;
|
||||
* PowerVR requires another explicit selection or Auto before launching.
|
||||
*/
|
||||
public static String optionLabel(Context context, String value) {
|
||||
if (value == null || value.isEmpty()) return "Runtime default (built into the runtime)";
|
||||
if (value == null || value.isEmpty()) return SystemVulkanDriver.isPowerVr()
|
||||
? context.getString(R.string.gpu_system_powervr) : "Runtime default (built into the runtime)";
|
||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||
if (!m.isInstalled(value)) return value + " (imported, missing - uses the runtime default)";
|
||||
if (!m.isInstalled(value)) return value + (SystemVulkanDriver.isPowerVr()
|
||||
? " (imported, missing)" : " (imported, missing - uses the runtime default)");
|
||||
String ver = m.getDriverVersion(value);
|
||||
return m.getDriverName(value) + (ver.isEmpty() ? "" : " " + ver) + " (imported)";
|
||||
}
|
||||
|
||||
/**
|
||||
* The ICD manifest path to hand the session, or null to leave the runtime's own driver alone.
|
||||
* An id whose import is gone resolves to null rather than failing the launch.
|
||||
* A missing import uses the runtime's own driver on Adreno. PowerVR fails clearly instead:
|
||||
* its system backend needs environment setup that an explicit import does not receive.
|
||||
*/
|
||||
public static String resolveIcdPath(Context context, String value) {
|
||||
boolean powerVr = SystemVulkanDriver.isPowerVr();
|
||||
return resolveIcdPath(value, powerVr,
|
||||
() -> SystemVulkanDriver.icdPath(context), id -> {
|
||||
String icd = new LinuxVulkanDriverManager(context).getIcdPath(id);
|
||||
if (icd == null) Log.w(TAG, "imported Linux driver \"" + id + "\" is gone"
|
||||
+ (powerVr ? "" : "; using the runtime's own driver"));
|
||||
else Log.i(TAG, "Linux session draws with imported driver " + id + " (" + icd + ")");
|
||||
return icd;
|
||||
});
|
||||
}
|
||||
|
||||
/** Resolve the selected backend before looking up an imported driver. */
|
||||
static String resolveIcdPath(String value, boolean powerVr, Supplier<String> systemIcd,
|
||||
Function<String, String> importedIcd) {
|
||||
if (SystemVulkanDriver.usesDefault(powerVr, value)) return systemIcd.get();
|
||||
if (value == null || value.isEmpty()) return null;
|
||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||
String icd = m.getIcdPath(value);
|
||||
if (icd == null) {
|
||||
Log.w(TAG, "imported Linux driver \"" + value + "\" is gone; using the runtime's own driver");
|
||||
return null;
|
||||
}
|
||||
Log.i(TAG, "Linux session draws with imported driver " + value + " (" + icd + ")");
|
||||
String icd = importedIcd.apply(value);
|
||||
if (powerVr && icd == null) throw new IllegalStateException(
|
||||
"Selected Linux Vulkan driver \"" + value + "\" is unavailable. Select an installed driver or use Auto.");
|
||||
return icd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
package com.droiddeck.launcher.gpu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
import com.droiddeck.launcher.core.FileUtils;
|
||||
import com.droiddeck.launcher.core.TarZst;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/** Isolated glibc-to-Android Vulkan bridge. It does not replace the rootfs's Mesa libraries. */
|
||||
public final class SystemVulkanDriver {
|
||||
private static final String ASSET = "hybris/runtime.tzst";
|
||||
/** Vendor HALs the bridge loads. Samsung Xclipse (Exynos, sgpu) is experimental. */
|
||||
private static final String[] HALS = {
|
||||
"/vendor/lib64/hw/vulkan.powervr.so",
|
||||
"/vendor/lib64/hw/vulkan.samsung.so"
|
||||
};
|
||||
private static final String[] REQUIRED = {
|
||||
"lib/libhybris-vulkan-icd.so.0", "lib/libhybris-common.so.1",
|
||||
"lib/libhybris/linker/q.so", "lib/libVkLayer_hybris_compat.so",
|
||||
"run-proton.py", "wsi/libVkLayer_window_system_integration.so",
|
||||
"wsi/VkLayer_window_system_integration.json",
|
||||
"dxvk/x32/d3d8.dll", "dxvk/x32/d3d9.dll", "dxvk/x32/d3d10core.dll",
|
||||
"dxvk/x32/d3d11.dll", "dxvk/x32/dxgi.dll",
|
||||
"dxvk/x64/d3d8.dll", "dxvk/x64/d3d9.dll", "dxvk/x64/d3d10core.dll",
|
||||
"dxvk/x64/d3d11.dll", "dxvk/x64/dxgi.dll"
|
||||
};
|
||||
|
||||
/** Rootfs directory of the Xclipse layer the apk stages (SessionFiles). */
|
||||
private static final String XCLIPSE_LAYER_DIR = "/usr/local/lib/droiddeck-xclipse";
|
||||
|
||||
private SystemVulkanDriver() {}
|
||||
|
||||
/** The first vendor HAL present, or null. */
|
||||
public static String hal() {
|
||||
for (String path : HALS) if (new File(path).isFile()) return path;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Samsung's Xclipse (Exynos, sgpu) rather than PowerVR. */
|
||||
public static boolean isXclipse() {
|
||||
String hal = hal();
|
||||
return hal != null && hal.endsWith("/vulkan.samsung.so");
|
||||
}
|
||||
|
||||
/** The system-driver GPU family, for labels. */
|
||||
public static String gpuName() { return isXclipse() ? "Xclipse" : "PowerVR"; }
|
||||
|
||||
/** Whether a system-driver GPU (PowerVR or Xclipse) is present; the name predates Xclipse. */
|
||||
public static boolean isPowerVr() { return hal() != null; }
|
||||
|
||||
/** HAL detection names the GPU; launching also needs the real DRM render node. */
|
||||
public static boolean isAvailable() { return isPowerVr() && renderNodeAvailable(); }
|
||||
|
||||
public static boolean renderNodeAvailable() {
|
||||
return renderNodePath() != null;
|
||||
}
|
||||
|
||||
/** Select the actual PowerVR node, including devices where another GPU owns renderD128. */
|
||||
public static String renderNodePath() {
|
||||
String[] nodes = new File("/dev/dri").list();
|
||||
if (nodes == null) nodes = new File("/sys/class/drm").list();
|
||||
return findRenderNode(nodes, SystemVulkanDriver::renderNodeAvailable);
|
||||
}
|
||||
|
||||
static String findRenderNode(String[] nodes, Predicate<String> available) {
|
||||
TreeSet<String> candidates = new TreeSet<>();
|
||||
// Android can deny directory listing while allowing direct access. Probe the kernel's
|
||||
// reserved render range too; directory entries also cover dynamically allocated minors.
|
||||
for (int minor = 128; minor < 192; minor++) candidates.add("renderD" + minor);
|
||||
if (nodes != null) for (String node : nodes)
|
||||
if (node.matches("renderD[0-9]+")) candidates.add(node);
|
||||
for (String node : candidates) {
|
||||
String path = "/dev/dri/" + node;
|
||||
if (available.test(path)) return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean renderNodeAvailable(String node) {
|
||||
try {
|
||||
if (!renderNodeAvailable(OsConstants.S_ISCHR(Os.stat(node).st_mode),
|
||||
Os.access(node, OsConstants.R_OK), Os.access(node, OsConstants.W_OK))) return false;
|
||||
return powerVrDevice(new File("/sys/class/drm/" + new File(node).getName() + "/device"));
|
||||
} catch (ErrnoException error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean powerVrDriver(String driver) {
|
||||
return "pvrsrvkm".equals(driver) || "pvr".equals(driver) || "powervr".equals(driver)
|
||||
|| "sgpu".equals(driver);
|
||||
}
|
||||
|
||||
static boolean powerVrDevice(File device) {
|
||||
try {
|
||||
return powerVrDriver(Files.readSymbolicLink(new File(device, "driver").toPath())
|
||||
.getFileName().toString());
|
||||
} catch (IOException error) {
|
||||
// Some Android policies expose uevent but deny reading the driver symlink.
|
||||
try (BufferedReader input = Files.newBufferedReader(
|
||||
new File(device, "uevent").toPath(), StandardCharsets.US_ASCII)) {
|
||||
String line;
|
||||
while ((line = input.readLine()) != null)
|
||||
if (line.startsWith("DRIVER=")) return powerVrDriver(line.substring(7));
|
||||
} catch (IOException ignored) { }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean renderNodeAvailable(boolean characterDevice, boolean readable, boolean writable) {
|
||||
return characterDevice && readable && writable;
|
||||
}
|
||||
|
||||
public static boolean usesDefault(String choice) {
|
||||
return usesDefault(isPowerVr(), choice);
|
||||
}
|
||||
|
||||
static boolean usesDefault(boolean powerVr, String choice) {
|
||||
return powerVr && (choice == null || choice.isEmpty());
|
||||
}
|
||||
|
||||
/** APK-versioned directories stay intact while an older session still has libraries mapped. */
|
||||
public static synchronized File prepare(Context context) throws IOException {
|
||||
if (!isPowerVr()) throw new IOException("System PowerVR Vulkan driver is unavailable");
|
||||
if (!renderNodeAvailable()) throw new IOException(
|
||||
"System PowerVR requires an identifiable, readable and writable DRM render node");
|
||||
File target = runtimeDirectory(context);
|
||||
File base = target.getParentFile();
|
||||
if (complete(target)) return target;
|
||||
if (!base.isDirectory() && !base.mkdirs()) throw new IOException("Cannot create system Vulkan directory");
|
||||
File staged = new File(base, ".stage-" + UUID.randomUUID());
|
||||
try {
|
||||
if (!TarZst.extractAsset(context, ASSET, staged)) throw new IOException("Cannot unpack system Vulkan runtime");
|
||||
for (String name : REQUIRED)
|
||||
if (!present(staged, name)) throw new IOException("Missing system Vulkan component: " + name);
|
||||
if (!new File(staged, "run-proton.py").canExecute())
|
||||
throw new IOException("System Vulkan Proton wrapper is not executable");
|
||||
JSONObject library = new JSONObject();
|
||||
library.put("library_path", new File(target, REQUIRED[0]).getPath());
|
||||
library.put("api_version", "1.3.0");
|
||||
JSONObject manifest = new JSONObject();
|
||||
manifest.put("file_format_version", "1.0.0");
|
||||
manifest.put("ICD", library);
|
||||
Files.write(new File(staged, "icd.json").toPath(), manifest.toString().getBytes(StandardCharsets.UTF_8));
|
||||
if (target.exists()) throw new IOException("Incomplete system Vulkan runtime directory: " + target.getName());
|
||||
if (!staged.renameTo(target)) throw new IOException("Cannot publish system Vulkan runtime");
|
||||
return target;
|
||||
} catch (org.json.JSONException error) {
|
||||
throw new IOException("Cannot write system Vulkan manifest", error);
|
||||
} finally {
|
||||
if (staged.exists()) FileUtils.delete(staged);
|
||||
}
|
||||
}
|
||||
|
||||
/** The current APK's versioned runtime path, without extracting or modifying it. */
|
||||
public static File runtimeDirectory(Context context) throws IOException {
|
||||
String version;
|
||||
try (BufferedReader input = new BufferedReader(new InputStreamReader(
|
||||
context.getAssets().open("hybris/version.txt"), StandardCharsets.US_ASCII))) {
|
||||
version = input.readLine();
|
||||
}
|
||||
if (version == null || !version.matches("[0-9a-f]{64}")) throw new IOException("Invalid system Vulkan runtime version");
|
||||
return new File(new File(context.getFilesDir(), "system_vulkan"), version);
|
||||
}
|
||||
|
||||
/** Collect abandoned stages, and obsolete versions once older guests can no longer load them. */
|
||||
public static synchronized void pruneUnused(Context context, boolean guestsStopped) throws IOException {
|
||||
pruneUnused(runtimeDirectory(context), guestsStopped);
|
||||
}
|
||||
|
||||
static synchronized void pruneUnused(File current, boolean guestsStopped) {
|
||||
File base = current.getParentFile();
|
||||
if (base == null || Files.isSymbolicLink(base.toPath()) || Files.isSymbolicLink(current.toPath())) return;
|
||||
File[] entries = base.listFiles();
|
||||
if (entries == null) return;
|
||||
// Retain the previous good version if publishing the replacement failed.
|
||||
boolean pruneVersions = guestsStopped && complete(current);
|
||||
for (File entry : entries) {
|
||||
if (entry.equals(current)) continue;
|
||||
String name = entry.getName();
|
||||
boolean oldVersion = pruneVersions && name.matches("[0-9a-f]{64}");
|
||||
boolean abandonedStage = name.matches("\\.stage-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
||||
// The prepare monitor excludes any extraction still writing a .stage directory.
|
||||
if (oldVersion || abandonedStage) FileUtils.delete(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean complete(File directory) {
|
||||
if (!new File(directory, "icd.json").isFile()) return false;
|
||||
for (String name : REQUIRED) if (!present(directory, name)) return false;
|
||||
return new File(directory, "run-proton.py").canExecute();
|
||||
}
|
||||
|
||||
private static boolean present(File directory, String name) {
|
||||
File file = new File(directory, name);
|
||||
return file.isFile() && file.length() > 0;
|
||||
}
|
||||
|
||||
public static String icdPath(Context context) {
|
||||
try {
|
||||
return new File(prepare(context), "icd.json").getPath();
|
||||
} catch (IOException error) {
|
||||
throw new IllegalStateException("System Vulkan runtime is unavailable", error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addEnvironment(Context context, List<String> environment) {
|
||||
File directory;
|
||||
try { directory = prepare(context); }
|
||||
catch (IOException error) { throw new IllegalStateException("System Vulkan runtime is unavailable", error); }
|
||||
String node = renderNodePath();
|
||||
if (node == null) throw new IllegalStateException("System PowerVR render node is unavailable");
|
||||
environment.add("HYBRIS_ANDROID_SDK_VERSION=" + Build.VERSION.SDK_INT);
|
||||
environment.add("HYBRIS_VULKAN_HAL=" + hal());
|
||||
environment.add("HYBRIS_LINKER_DIR=" + new File(directory, "lib/libhybris/linker").getPath());
|
||||
// Prefer framework dependencies for the system Vulkan loader, including libbase.so.
|
||||
environment.add("HYBRIS_LD_LIBRARY_PATH=/system/lib64:/system_ext/lib64:/vendor/lib64/egl:/vendor/lib64/hw:/vendor/lib64");
|
||||
boolean xclipse = isXclipse();
|
||||
// Xclipse gets its own layer (tools/linuxfs/xclipse-layer) in front of everything: it sets
|
||||
// bionic's environ for the driver's shader compiler, among other driver workarounds. The
|
||||
// session's own clients need nothing else; games keep the compat layer's BC emulation.
|
||||
String layers = xclipse ? "VK_LAYER_DROIDDECK_xclipse" : "VK_LAYER_HYBRIS_compat";
|
||||
environment.add("VK_LAYER_PATH=" + new File(directory, "lib").getPath() + (xclipse ? ":" + XCLIPSE_LAYER_DIR : ""));
|
||||
environment.add("VK_INSTANCE_LAYERS=" + layers);
|
||||
// Proton game launches add their WSI layer in front of these (droiddeck-game-env).
|
||||
environment.add("DROIDDECK_HYBRIS_LAYERS=" + (xclipse ? layers + ":VK_LAYER_HYBRIS_compat" : layers));
|
||||
if (xclipse) environment.add("DROIDDECK_HYBRIS_LAYER_PATH=" + XCLIPSE_LAYER_DIR);
|
||||
// DXVK 3 needs 256 bytes of push constants; this driver has 128.
|
||||
if (xclipse) environment.add("DROIDDECK_HYBRIS_DXVK=dxvk-2.6.2");
|
||||
// The Android driver has a render node, but no KMS primary node. SDL presents
|
||||
// through the wrapper's Wayland Vulkan swapchain instead of a KMS-style path.
|
||||
environment.add("BL_GAMESCOPE_BACKEND=sdl");
|
||||
// The Android pvr kernel accepts Vulkan DMA-BUF imports but rejects PRIME GEM handles.
|
||||
environment.add("BL_POWERVR_DRM_HANDLES=1");
|
||||
environment.add("BL_POWERVR_RENDER_NODE=" + node);
|
||||
// Inner Gamescope/Xwayland lacks the bridge's Android-buffer WSI protocols.
|
||||
environment.add("BL_STEAM_GL_PRESENT=1");
|
||||
// Only actual Proton game launches use the bundled DXVK and X11 WSI layer.
|
||||
environment.add("DROIDDECK_POWERVR_RUNTIME=" + directory.getPath());
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,10 @@ import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* The Vulkan driver the in-app compositor runs on. It has to be Turnip: the system Adreno driver
|
||||
* The Vulkan driver the in-app compositor runs on. Adreno uses Turnip: the system Adreno driver
|
||||
* does not implement VK_EXT_image_drm_format_modifier, so importing the dma-bufs gamescope hands
|
||||
* over fails and the session renders nothing. Two builds ship in the apk, one per Adreno
|
||||
* over fails and the session renders nothing. PowerVR uses the system driver and Android hardware
|
||||
* buffers instead. Two Turnip builds ship in the apk, one per Adreno
|
||||
* generation, and the GPU decides which is unpacked - unless the user has imported an AdrenoTools
|
||||
* zip of their own and chosen it, which then wins.
|
||||
*
|
||||
@@ -314,6 +315,7 @@ public final class TurnipDriver {
|
||||
* and falls through, so a stale preference never blocks a session.
|
||||
*/
|
||||
private String choose() {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(context);
|
||||
String chosen = SessionPrefs.androidDriver(context);
|
||||
if (chosen != null && !chosen.isEmpty()) {
|
||||
if (BUNDLED.contains(chosen)) {
|
||||
@@ -339,6 +341,7 @@ public final class TurnipDriver {
|
||||
if (forced.startsWith("a8")) return DRIVER_A8XX;
|
||||
if (forced.startsWith("a7")) return DRIVER_A7XX;
|
||||
}
|
||||
if (SystemVulkanDriver.isPowerVr()) return null;
|
||||
String model = gpuModel();
|
||||
Log.i(TAG, "gpu model: " + (model == null ? "unknown" : model));
|
||||
if (model != null) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.StructStat;
|
||||
import android.system.StructUtsname;
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver;
|
||||
import com.droiddeck.launcher.session.SessionPrefs;
|
||||
|
||||
|
||||
@@ -200,6 +201,13 @@ public final class LinuxRuntime {
|
||||
bind(cmd, "/dev");
|
||||
bind(cmd, "/proc");
|
||||
bind(cmd, "/sys");
|
||||
if (com.droiddeck.launcher.gpu.SystemVulkanDriver.isPowerVr()) {
|
||||
// The glibc bridge loads the device's existing Android HAL and its dependencies.
|
||||
// These read-only Android partitions remain subject to the app's normal permissions.
|
||||
for (String path : new String[]{"/system", "/vendor", "/apex", "/system_ext", "/product", "/odm"})
|
||||
if (new File(path).isDirectory()) bind(cmd, path);
|
||||
if (new File("/linkerconfig/ld.config.txt").isFile()) bind(cmd, "/linkerconfig/ld.config.txt");
|
||||
}
|
||||
bind(cmd, "/dev/urandom:/dev/random");
|
||||
bind(cmd, "/proc/self/fd:/dev/fd");
|
||||
bind(cmd, "/proc/self/fd/0:/dev/stdin");
|
||||
@@ -277,7 +285,11 @@ public final class LinuxRuntime {
|
||||
bind(cmd, fake.getPath() + ":" + entry[1]);
|
||||
}
|
||||
}
|
||||
bindGpuNode(context, cmd);
|
||||
if (com.droiddeck.launcher.gpu.SystemVulkanDriver.isPowerVr()) {
|
||||
bindPowerVrGpuNode(context, cmd);
|
||||
} else {
|
||||
bindGpuNode(context, cmd);
|
||||
}
|
||||
bindAdrenoStats(cmd, extraBinds);
|
||||
bindCpuTemps(cmd, root);
|
||||
if (extraBinds != null) {
|
||||
@@ -288,6 +300,30 @@ public final class LinuxRuntime {
|
||||
return specs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tensor's render node is accessible directly, but Android denies listing its parent
|
||||
* directory. libdrm enumerates that directory even when given the device number. Expose
|
||||
* the real node through a listable private directory; retain its real sysfs identity.
|
||||
*/
|
||||
private static void bindPowerVrGpuNode(Context context, List<String> cmd) {
|
||||
if (new File("/dev/dri").list() != null) return;
|
||||
String node = SystemVulkanDriver.renderNodePath();
|
||||
if (node == null) return;
|
||||
String name = new File(node).getName();
|
||||
// Keep only this node listable even if a previous boot assigned a different minor.
|
||||
File dri = new File(context.getCacheDir(), "powervr-drm/" + name + "/dri");
|
||||
try {
|
||||
if (!dri.isDirectory() && !dri.mkdirs()) return;
|
||||
new File(dri, name).createNewFile();
|
||||
} catch (IOException e) {
|
||||
android.util.Log.w("LinuxRuntime", "Cannot expose the PowerVR render node", e);
|
||||
return;
|
||||
}
|
||||
bind(cmd, dri.getPath() + ":/dev/dri");
|
||||
bind(cmd, node + ":" + node);
|
||||
android.util.Log.i("LinuxRuntime", "PowerVR: exposing real " + name + " through a listable directory");
|
||||
}
|
||||
|
||||
/**
|
||||
* An app process may not open {@code /dev/dri} - the nodes exist but are labelled
|
||||
* {@code graphics_device}, which stock policy grants surfaceflinger and not us - yet libdrm and
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.droiddeck.launcher.core.Downloader
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.github.luben.zstd.ZstdInputStream
|
||||
import com.github.luben.zstd.ZstdOutputStream
|
||||
@@ -219,9 +220,13 @@ object ComponentsManager {
|
||||
COMPONENTS.mapNotNull { comp -> profile.optString(comp).takeIf(String::isNotEmpty)?.let { comp to it } }.toMap()
|
||||
}
|
||||
|
||||
fun setGameComponent(context: Context, scope: String, comp: String, file: String?) = synchronized(lock) {
|
||||
fun setGameComponent(context: Context, scope: String, comp: String, file: String?) =
|
||||
setGameComponent(context, scope, comp, file) { runtimeManaged(context, it) }
|
||||
|
||||
internal fun setGameComponent(context: Context, scope: String, comp: String, file: String?, managed: (String) -> Boolean) = synchronized(lock) {
|
||||
require(scope.matches(Regex("[1-9][0-9]{0,9}")) && scope.toLong() <= 4294967295L)
|
||||
require(comp in COMPONENTS)
|
||||
if (file != null) requireSelectable(context, comp, managed)
|
||||
val state = loadState(context)
|
||||
val profiles = state.sub("profiles")
|
||||
val profile = profiles.optJSONObject(scope) ?: JSONObject().also { profiles.put(scope, it) }
|
||||
@@ -694,6 +699,16 @@ object ComponentsManager {
|
||||
return PreparedLaunchState(lines.toString(), keep)
|
||||
}
|
||||
|
||||
/** DXVK is supplied at game launch by the selected system PowerVR runtime. */
|
||||
internal fun runtimeManaged(comp: String, systemPowerVr: Boolean): Boolean = comp == "dxvk" && systemPowerVr
|
||||
|
||||
private fun runtimeManaged(context: Context, comp: String): Boolean =
|
||||
runtimeManaged(comp, SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(context)))
|
||||
|
||||
private fun requireSelectable(context: Context, comp: String, managed: (String) -> Boolean = { runtimeManaged(context, it) }) {
|
||||
check(!managed(comp)) { context.getString(R.string.cmgr_powervr_dxvk_managed) }
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ actions
|
||||
|
||||
/** Applies a package now, or queues it when a game is running on that Proton. Returns what happened. */
|
||||
@@ -701,6 +716,7 @@ object ComponentsManager {
|
||||
val p = proton(context, protonId)
|
||||
val wcp = File(packagesDir(context), safeName(file))
|
||||
val info = packageInfo(context, wcp)
|
||||
requireSelectable(context, info.comp)
|
||||
val state = loadState(context)
|
||||
if (inUse(context, p)) {
|
||||
state.sub("queued").sub(p.id).put(info.comp, JSONObject().put("kind", "package").put("file", wcp.name).put("label", info.version))
|
||||
@@ -724,6 +740,7 @@ object ComponentsManager {
|
||||
}
|
||||
|
||||
fun restore(context: Context, protonId: String, comp: String, protonVersion: String): String = synchronized(lock) {
|
||||
requireSelectable(context, comp)
|
||||
val p = proton(context, protonId)
|
||||
val wcp = File(originalsDir(context), "$protonId/${safeName(protonVersion)}/$comp.wcp")
|
||||
check(wcp.isFile) { context.getString(R.string.cmgr_original_missing) }
|
||||
@@ -750,7 +767,9 @@ object ComponentsManager {
|
||||
}
|
||||
|
||||
/** Runs the swaps that waited for a game to close. Cheap when nothing is queued. */
|
||||
fun applyQueued(context: Context): List<String> = synchronized(lock) {
|
||||
fun applyQueued(context: Context): List<String> = applyQueued(context) { runtimeManaged(context, it) }
|
||||
|
||||
internal fun applyQueued(context: Context, managed: (String) -> Boolean): List<String> = synchronized(lock) {
|
||||
val state = loadState(context)
|
||||
val queued = state.sub("queued")
|
||||
if (queued.length() == 0) return emptyList()
|
||||
@@ -762,6 +781,7 @@ object ComponentsManager {
|
||||
val comps = queued.optJSONObject(pid) ?: continue
|
||||
for (comp in comps.keys().asSequence().toList()) {
|
||||
val q = comps.optJSONObject(comp) ?: continue
|
||||
if (managed(comp)) continue
|
||||
runCatching {
|
||||
if (q.optString("kind") == "original") {
|
||||
val v = q.optString("protonVersion")
|
||||
|
||||
@@ -27,6 +27,23 @@ object OrphanReaper {
|
||||
|
||||
fun release(pid: Int) { kept.remove(pid) }
|
||||
|
||||
/** Signal 0 checks ownership/liveness without sending a signal, even when /proc is unreadable. */
|
||||
fun hasOtherProcesses(): Boolean = hasOtherProcesses(
|
||||
File("/proc").list()?.mapNotNull { it.toIntOrNull() }, android.os.Process.myPid(),
|
||||
) { pid ->
|
||||
try {
|
||||
android.system.Os.kill(pid, 0)
|
||||
true
|
||||
} catch (error: android.system.ErrnoException) {
|
||||
error.errno != android.system.OsConstants.ESRCH && error.errno != android.system.OsConstants.EPERM
|
||||
} catch (error: SecurityException) {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
internal fun hasOtherProcesses(pids: List<Int>?, ownPid: Int, signalable: (Int) -> Boolean): Boolean =
|
||||
pids == null || pids.any { it > 1 && it != ownPid && signalable(it) }
|
||||
|
||||
fun reap(reason: String): Int {
|
||||
val me = android.os.Process.myPid()
|
||||
val uid = android.os.Process.myUid()
|
||||
|
||||
@@ -53,6 +53,7 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-msi-install" to "usr/local/bin/droiddeck-msi-install",
|
||||
"usr/local/bin/droiddeck-esync" to "usr/local/bin/droiddeck-esync",
|
||||
"usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat",
|
||||
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/libexec/droiddeck-steam/taskset",
|
||||
"usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex",
|
||||
"libblsession.so" to "usr/local/lib/libblsession.so",
|
||||
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
|
||||
@@ -129,6 +130,10 @@ object SessionFiles {
|
||||
"usr/local/lib/mangoapp/libtraceevent.so.1",
|
||||
"usr/local/lib/mangoapp/libtracefs.so.1",
|
||||
).map { it to it }
|
||||
// Samsung Xclipse driver workarounds (tools/linuxfs/xclipse-layer), the Vulkan layer
|
||||
// SystemVulkanDriver enables on that GPU.
|
||||
val xclipse = listOf("libVkLayer_droiddeck_xclipse.so", "VkLayer_droiddeck_xclipse.json")
|
||||
.map { "usr/local/lib/droiddeck-xclipse/$it" }
|
||||
// What the Windows components installer reads .msi packages with (tools/msitools).
|
||||
val msitools = listOf("msiinfo", "cabextract", "7z", "7z.so", "libmsi-1.0.so.0", "libgsf-1.so.114", "libgcab-1.0.so.0")
|
||||
.map { "usr/local/lib/droiddeck-msitools/$it" } +
|
||||
@@ -140,7 +145,7 @@ object SessionFiles {
|
||||
"usr/local/bin/gamescope" to "usr/local/bin/gamescope",
|
||||
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
|
||||
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
|
||||
) + mangoapp + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
|
||||
) + mangoapp + xclipse.map { it to it } + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.droiddeck.launcher.core.CpuAllocationDefaults
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.core.TextureFiltering
|
||||
import com.droiddeck.launcher.gpu.ScreenEffects
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import org.json.JSONObject
|
||||
|
||||
/** The in-session switches: the HUD and how the on-screen controls decide to appear. */
|
||||
@@ -216,6 +218,15 @@ object SessionPrefs {
|
||||
p.edit().putString("gpuDriverMode", if (chosen) GPU_DRIVERS_MANUAL else GPU_DRIVERS_AUTO).apply()
|
||||
}
|
||||
|
||||
/** Also called by direct session launches, which may never open the driver settings. */
|
||||
@JvmStatic
|
||||
fun ensurePowerVrAutoDrivers(context: Context) = ensurePowerVrAutoDrivers(context, SystemVulkanDriver.isPowerVr())
|
||||
|
||||
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean) {
|
||||
if (!powerVr || gpuDriverMode(context) != GPU_DRIVERS_AUTO) return
|
||||
prefs(context).edit().putString("linuxDriver", "").putString("androidDriver", TurnipDriver.AUTO).apply()
|
||||
}
|
||||
|
||||
/** Drivers Auto downloaded: the only ones it removes when a newer pair replaces them. */
|
||||
fun gpuAutoInstalled(context: Context): Set<String> =
|
||||
prefs(context).getStringSet("gpuAutoInstalled", emptySet()).orEmpty()
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.droiddeck.launcher.session
|
||||
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
@@ -318,6 +319,7 @@ class SessionService : Service() {
|
||||
// ── The session ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private fun runSession(gen: Int) {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(this)
|
||||
SessionTerminal.clear()
|
||||
try {
|
||||
LinuxRuntime.writeAccounts(this)
|
||||
@@ -331,7 +333,17 @@ class SessionService : Service() {
|
||||
val sessionRoot = LinuxRuntime.sessionRoot(this).apply { mkdirs() }
|
||||
val runtimeDir = File(filesDir, ".wayland-rt").apply { mkdirs() }
|
||||
killStragglers()
|
||||
SessionFiles.stage(this, root)
|
||||
try {
|
||||
if (SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(this))) {
|
||||
SystemVulkanDriver.prepare(this)
|
||||
pruneSystemVulkanRuntime()
|
||||
}
|
||||
SessionFiles.stage(this, root)
|
||||
} catch (error: Exception) {
|
||||
Log.e(TAG, "Could not prepare the session graphics runtime", error)
|
||||
stopSession(-1)
|
||||
return
|
||||
}
|
||||
com.droiddeck.launcher.agent.AgentGuest.reset(this)
|
||||
// The compat tool asks for an Epic game's sign-in code at every launch, the client's Play button included.
|
||||
com.droiddeck.launcher.stores.gog.GogComet.begin()
|
||||
@@ -617,6 +629,9 @@ class SessionService : Service() {
|
||||
// import falls back to. One driver for every session: the driver's shader cache is keyed on
|
||||
// its build, and with one per mode every emulator compiled its shaders twice.
|
||||
val linuxDriverId = SessionPrefs.linuxDriver(this)
|
||||
if (SystemVulkanDriver.usesDefault(linuxDriverId)) {
|
||||
SystemVulkanDriver.addEnvironment(this, guest)
|
||||
}
|
||||
LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId)
|
||||
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
|
||||
// Turnip's own debug switches, for the runtime's driver and everything on it. The file in
|
||||
@@ -1477,6 +1492,12 @@ class SessionService : Service() {
|
||||
}.onFailure { Log.w(TAG, "could not request Steam wake", it) }
|
||||
}
|
||||
|
||||
/** Background-only: preserve old runtimes until all earlier guest processes are gone. */
|
||||
private fun pruneSystemVulkanRuntime() {
|
||||
runCatching { SystemVulkanDriver.pruneUnused(this, !OrphanReaper.hasOtherProcesses()) }
|
||||
.onFailure { Log.w(TAG, "could not prune unused system Vulkan runtimes", it) }
|
||||
}
|
||||
|
||||
private fun finishSessionStop(status: Int, stoppedGen: Int) {
|
||||
mainHandler.post {
|
||||
if (stoppedGen != sessionGen || SessionState.running) {
|
||||
@@ -1594,9 +1615,11 @@ class SessionService : Service() {
|
||||
auxiliary.forEach { (pid, started) -> teardown(pid, started) }
|
||||
if (prootPid > 1) teardown(prootPid)
|
||||
killGuestLeftovers()
|
||||
pruneSystemVulkanRuntime()
|
||||
finishSessionStop(status, stoppedGen)
|
||||
}, "session-teardown").start()
|
||||
} else {
|
||||
Thread({ pruneSystemVulkanRuntime() }, "system-vulkan-prune").start()
|
||||
Thread({ com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession); finishSessionStop(status, stoppedGen) }, "gog-session-stop").start()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,9 +502,10 @@ fun ComponentsPage(
|
||||
val active = gpu.activePair
|
||||
InUseBar(
|
||||
queued = gpu.busy != null,
|
||||
sentence = (active?.let { "${it.name} ${it.version}" } ?: gpu.activeBundle ?: stringResource(R.string.gpu_builtin))
|
||||
sentence = (active?.let { "${it.name} ${it.version}" } ?: gpu.activeBundle ?: stringResource(if (gpu.systemPowerVr) R.string.gpu_system_powervr else R.string.gpu_builtin))
|
||||
.let { if (gpu.auto) stringResource(R.string.gpu_bar_auto, it) else it },
|
||||
note = if (gpu.busy != null) (if (gpu.percent >= 0) "${gpu.percent}%" else "…")
|
||||
else if (gpu.systemPowerVr) stringResource(R.string.gpu_auto_system_hint)
|
||||
else gpu.autoStatus.ifEmpty { if (active != null || gpu.activeBundle != null) "" else gpu.pairs.firstOrNull { it.recommended }?.let { stringResource(R.string.gpu_recommended_for, it.name) } ?: stringResource(R.string.gpu_refresh_hint) },
|
||||
)
|
||||
}
|
||||
@@ -515,17 +516,27 @@ fun ComponentsPage(
|
||||
)
|
||||
else -> {
|
||||
val st = compState(l)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
if (st == null) InUseBar(false, stringResource(R.string.comp_no_proton), "")
|
||||
else {
|
||||
val reappliedAt = view?.reappliedAt?.takeIf { it > 0 }?.let { DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(it * 1000)) }
|
||||
InUseBar(
|
||||
queued = st.queued != null,
|
||||
sentence = (if (st.queued != null) stringResource(R.string.comp_next_queued, st.queued) else stringResource(R.string.comp_in_use, label, st.inUse))
|
||||
.let { if (reappliedAt != null) stringResource(R.string.comp_reapplied, it, reappliedAt) else it },
|
||||
note = if (view?.inUseByGame == true) stringResource(R.string.comp_waits) else stringResource(R.string.comp_applies_next_game),
|
||||
onCancel = if (st.queued != null) onCancelQueued else null,
|
||||
)
|
||||
Column {
|
||||
InUseBar(
|
||||
queued = st.queued != null,
|
||||
sentence = (if (managedDxvk) stringResource(R.string.comp_in_use, label, stringResource(R.string.gpu_system_powervr)) +
|
||||
(st.queued?.let { "\n" + stringResource(R.string.cmgr_powervr_dxvk_queued, it) } ?: "")
|
||||
else if (st.queued != null) stringResource(R.string.comp_next_queued, st.queued) else stringResource(R.string.comp_in_use, label, st.inUse))
|
||||
.let { if (reappliedAt != null && !managedDxvk) stringResource(R.string.comp_reapplied, it, reappliedAt) else it },
|
||||
note = if (managedDxvk) "" else if (view?.inUseByGame == true) stringResource(R.string.comp_waits) else stringResource(R.string.comp_applies_next_game),
|
||||
onCancel = if (st.queued != null) onCancelQueued else null,
|
||||
maxLines = if (managedDxvk && st.queued != null) 3 else 2,
|
||||
)
|
||||
if (managedDxvk) Text(
|
||||
stringResource(R.string.cmgr_powervr_dxvk_managed),
|
||||
fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -552,11 +563,11 @@ fun ComponentsPage(
|
||||
GPU_TAB -> {
|
||||
val autoKey = "gpu:auto"
|
||||
ChoiceLine(
|
||||
stringResource(R.string.common_auto), stringResource(R.string.gpu_auto_keeps), gpu.auto, removable = false,
|
||||
stringResource(R.string.common_auto), stringResource(if (gpu.powerVr) R.string.gpu_auto_system_hint else R.string.gpu_auto_keeps), gpu.auto, removable = false,
|
||||
modifier = Modifier.focusRequester(firstRow).trackRow(autoKey, rowsAt),
|
||||
onSelect = {
|
||||
if (gpu.auto) return@ChoiceLine
|
||||
ask(autoKey, right, ctx.getString(R.string.gpu_use_title, ctx.getString(R.string.common_auto)), ctx.getString(R.string.gpu_auto_hint), ctx.getString(R.string.common_use), false, ctx.getString(R.string.common_auto)) {
|
||||
ask(autoKey, right, ctx.getString(R.string.gpu_use_title, ctx.getString(R.string.common_auto)), ctx.getString(if (gpu.powerVr) R.string.gpu_auto_system_hint else R.string.gpu_auto_hint), ctx.getString(R.string.common_use), false, ctx.getString(R.string.common_auto)) {
|
||||
gpuActions.onAuto(true); flyHome(autoKey, GPU_TAB)
|
||||
}
|
||||
},
|
||||
@@ -601,16 +612,17 @@ fun ComponentsPage(
|
||||
}
|
||||
else -> {
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
val rows = installedFor(l, view, snapshot)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
val rows = installedFor(l, view, snapshot, managedDxvk)
|
||||
if (rows.isEmpty()) EmptyLine(stringResource(R.string.comp_nothing_stored, label))
|
||||
val p = view?.proton
|
||||
rows.forEachIndexed { i, item ->
|
||||
val key = "row:$l:${item.file ?: item.protonVersion}"
|
||||
ChoiceLine(
|
||||
item.name, item.detail, item.selected, item.removable, tag = item.tag,
|
||||
modifier = (if (i == 0) Modifier.focusRequester(firstRow) else Modifier).trackRow(key, rowsAt),
|
||||
item.name, item.detail, item.selected, item.removable, tag = item.tag, enabled = !managedDxvk,
|
||||
modifier = (if (i == 0 && !managedDxvk) Modifier.focusRequester(firstRow) else Modifier).trackRow(key, rowsAt),
|
||||
onSelect = {
|
||||
if (item.selected || p == null) return@ChoiceLine
|
||||
if (managedDxvk || item.selected || p == null) return@ChoiceLine
|
||||
val waits = if (view.inUseByGame) ctx.getString(R.string.comp_waits_long) else ctx.getString(R.string.comp_applies_long)
|
||||
if (item.file != null) ask(key, right, ctx.getString(R.string.comp_swap_title, label), ctx.getString(R.string.comp_swap_body, item.name, p.name, waits), ctx.getString(R.string.comp_swap), false, item.name) {
|
||||
onSwap(item.file); flyHome(key, l)
|
||||
@@ -712,14 +724,19 @@ fun ComponentsPage(
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
SmallButton(stringResource(R.string.comp_import_wcp), onClick = onImport)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
SmallButton(
|
||||
stringResource(R.string.comp_import_wcp), onClick = onImport,
|
||||
modifier = if (managedDxvk) Modifier.focusRequester(firstRow) else Modifier,
|
||||
)
|
||||
val st = compState(l)
|
||||
val p = view?.proton
|
||||
val build = p?.let { ComponentsManager.safeName(it.version) }
|
||||
if (st != null && p != null && st.activeFile != null && view.originals.any { it.comp == l && it.protonVersion == build }) {
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
Box(Modifier.trackRow("restore:$l", rowsAt)) {
|
||||
FocusText(stringResource(R.string.comp_restore_original), pal.signal) {
|
||||
if (managedDxvk) SmallButton(stringResource(R.string.comp_restore_original), enabled = false) {}
|
||||
else FocusText(stringResource(R.string.comp_restore_original), pal.signal) {
|
||||
ask("restore:$l", false, ctx.getString(R.string.comp_restore_title, label), ctx.getString(R.string.comp_restore_original_body, p.name, label), ctx.getString(R.string.common_restore), false, ctx.getString(R.string.comp_restore_original)) {
|
||||
onRestore(build!!); flyHome("restore:$l", l)
|
||||
}
|
||||
@@ -867,6 +884,7 @@ fun ComponentsPage(
|
||||
protonChoice = gameProtonChoice,
|
||||
packages = snapshot?.packages.orEmpty(),
|
||||
componentChoices = gameComponents,
|
||||
systemPowerVr = gpu.systemPowerVr,
|
||||
componentMenu = gameComponentMenu,
|
||||
protonMenu = gameProtonMenu,
|
||||
fexMenu = fexMenu,
|
||||
@@ -1010,11 +1028,11 @@ fun ComponentsPage(
|
||||
|
||||
/** The Installed rows of one component layer for the Proton the page shows. */
|
||||
@Composable
|
||||
private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapshot: Snapshot?): List<InstalledItem> {
|
||||
private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapshot: Snapshot?, runtimeManaged: Boolean = false): List<InstalledItem> {
|
||||
view ?: return emptyList()
|
||||
val st = view.components[l] ?: return emptyList()
|
||||
val build = ComponentsManager.safeName(view.proton.version)
|
||||
val activeIsOriginal = st.activeFile == null
|
||||
val activeIsOriginal = !runtimeManaged && st.activeFile == null
|
||||
return view.originals.filter { it.comp == l }.map { o ->
|
||||
val isCurrent = o.protonVersion == build
|
||||
InstalledItem(
|
||||
@@ -1023,7 +1041,7 @@ private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapsho
|
||||
"ORIGINAL", activeIsOriginal && isCurrent, !isCurrent, null, o.protonVersion,
|
||||
)
|
||||
} + (snapshot?.packages ?: emptyList()).filter { it.comp == l }.map { s ->
|
||||
InstalledItem(s.version, stringResource(R.string.common_size_mb, s.size / 1048576.0), "STORED", s.file == st.activeFile, true, s.file, null)
|
||||
InstalledItem(s.version, stringResource(R.string.common_size_mb, s.size / 1048576.0), "STORED", !runtimeManaged && s.file == st.activeFile, true, s.file, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1062,11 +1080,12 @@ private fun Stack(
|
||||
LayerCard(
|
||||
title = LayerTitle(l),
|
||||
value = when (l) {
|
||||
GPU_TAB -> if (gpu.auto) auto else gpu.activePair?.name ?: gpu.activeBundle ?: auto
|
||||
GPU_TAB -> if (gpu.systemPowerVr) stringResource(R.string.gpu_system_powervr) else if (gpu.auto) auto else gpu.activePair?.name ?: gpu.activeBundle ?: auto
|
||||
PROTON_TAB -> (view?.proton?.name ?: "") + " ▾"
|
||||
else -> st?.let { if (it.activeFile == null) original else it.inUse } ?: ""
|
||||
else -> if (ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else st?.let { if (it.activeFile == null) original else it.inUse } ?: ""
|
||||
},
|
||||
swapped = l in ComponentsManager.COMPONENTS && st?.activeFile != null,
|
||||
swapped = l in ComponentsManager.COMPONENTS && st?.activeFile != null && !ComponentsManager.runtimeManaged(l, gpu.systemPowerVr),
|
||||
selected = l == layer,
|
||||
landed = landed[l] ?: 0, ring = rings[l] ?: 0,
|
||||
modifier = Modifier.focusRequester(focus.getValue(l)).onGloballyPositioned { onPlaced(l, it.boundsInRoot()) },
|
||||
@@ -1137,7 +1156,7 @@ private fun LayerCard(
|
||||
|
||||
/** What is in use for the layer: a dot (green, or amber while a change waits), a sentence, and a note or Cancel. */
|
||||
@Composable
|
||||
private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel: (() -> Unit)? = null) {
|
||||
private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel: (() -> Unit)? = null, maxLines: Int = 2) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Row(
|
||||
@@ -1146,7 +1165,7 @@ private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel:
|
||||
.border(1.dp, pal.line, RoundedCornerShape(12.dp)).padding(horizontal = 14.dp, vertical = 8.dp),
|
||||
) {
|
||||
Box(Modifier.size(8.dp).background(if (queued) QUEUED else pal.good, CircleShape))
|
||||
Text(sentence, fontSize = 14.sp, color = colors.onBackground, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
Text(sentence, fontSize = 14.sp, color = colors.onBackground, maxLines = maxLines, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
if (onCancel != null) FocusText(stringResource(R.string.common_cancel), pal.signal, onClick = onCancel)
|
||||
else if (note.isNotEmpty() && !LocalNarrowPane.current) Text(note, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
@@ -1182,6 +1201,7 @@ private fun GameComponentOverrides(
|
||||
protonChoice: ProtonDefault.GameChoice?,
|
||||
packages: List<ComponentsManager.Package>,
|
||||
componentChoices: Map<String, String>,
|
||||
systemPowerVr: Boolean,
|
||||
componentMenu: String?,
|
||||
protonMenu: Boolean,
|
||||
fexMenu: Boolean,
|
||||
@@ -1273,6 +1293,7 @@ private fun GameComponentOverrides(
|
||||
}
|
||||
GamePackageRow(
|
||||
comp = "dxvk",
|
||||
runtimeManaged = ComponentsManager.runtimeManaged("dxvk", systemPowerVr),
|
||||
packages = packages,
|
||||
selectedFile = componentChoices["dxvk"],
|
||||
open = componentMenu == "dxvk",
|
||||
@@ -1337,13 +1358,16 @@ private fun GamePackageRow(
|
||||
onMenu: (String?) -> Unit,
|
||||
onPick: (String, String?) -> Unit,
|
||||
onRuntimeOptions: (() -> Unit)? = null,
|
||||
runtimeManaged: Boolean = false,
|
||||
) {
|
||||
val choices = packages.filter { it.comp == comp }
|
||||
val selected = choices.firstOrNull { it.file == selectedFile }
|
||||
val title = ComponentsManager.LABEL[comp] ?: comp
|
||||
val enabled = !busy && (!runtimeManaged || selectedFile != null)
|
||||
SettingsRow(
|
||||
title,
|
||||
if (selected == null) {
|
||||
if (runtimeManaged) stringResource(R.string.cmgr_powervr_dxvk_managed)
|
||||
else if (selected == null) {
|
||||
if (proton == null) stringResource(R.string.comp_game_component_general)
|
||||
else stringResource(R.string.comp_game_component_runtime, proton.name)
|
||||
} else stringResource(R.string.comp_game_component_override, selected.version),
|
||||
@@ -1351,18 +1375,18 @@ private fun GamePackageRow(
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Box {
|
||||
ValueChip(
|
||||
selected?.version ?: stringResource(R.string.comp_game_use_general),
|
||||
open,
|
||||
enabled = !busy,
|
||||
if (runtimeManaged) stringResource(R.string.gpu_system_powervr) else selected?.version ?: stringResource(R.string.comp_game_use_general),
|
||||
open && enabled,
|
||||
enabled = enabled,
|
||||
modifier = Modifier.widthIn(max = 240.dp),
|
||||
) { onMenu(if (open) null else comp) }
|
||||
AnchoredMenu(open, onDismiss = { onMenu(null) }, title = title) { first ->
|
||||
AnchoredMenu(open && enabled, onDismiss = { onMenu(null) }, title = title) { first ->
|
||||
MenuItem(
|
||||
stringResource(R.string.comp_game_use_general),
|
||||
checked = selected == null,
|
||||
focusRequester = first,
|
||||
) { onPick(comp, null); onMenu(null) }
|
||||
choices.forEach { option ->
|
||||
if (!runtimeManaged) choices.forEach { option ->
|
||||
MenuItem(option.version, checked = option.file == selectedFile, detail = option.description) {
|
||||
onPick(comp, option.file)
|
||||
onMenu(null)
|
||||
@@ -1492,13 +1516,13 @@ private fun Tag(text: String) {
|
||||
@Composable
|
||||
private fun ChoiceLine(
|
||||
name: String, detail: String, selected: Boolean, removable: Boolean,
|
||||
modifier: Modifier = Modifier, tag: String? = null, badge: String? = null, progress: Int? = null,
|
||||
modifier: Modifier = Modifier, tag: String? = null, badge: String? = null, progress: Int? = null, enabled: Boolean = true,
|
||||
onSelect: () -> Unit, onDelete: () -> Unit = {},
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val hot = rememberHot(src) && enabled
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -1508,8 +1532,8 @@ private fun ChoiceLine(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.weight(1f).heightIn(min = 56.dp).then(modifier)
|
||||
.glideBorder(hot, ROW_SHAPE, pal.signal)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onSelect)
|
||||
.controllerConfirm(onClick = onSelect)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onSelect)
|
||||
.controllerConfirm(enabled = enabled, onClick = onSelect)
|
||||
.padding(start = 14.dp, end = 8.dp, top = 8.dp, bottom = 8.dp),
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(20.dp).border(2.dp, if (selected) pal.signal else colors.onSurfaceVariant, CircleShape)) {
|
||||
@@ -1519,7 +1543,7 @@ private fun ChoiceLine(
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(
|
||||
name, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, maxLines = 2, overflow = TextOverflow.Ellipsis,
|
||||
color = if (selected) pal.signal else colors.onBackground, modifier = Modifier.weight(1f, fill = false),
|
||||
color = if (!enabled) colors.onSurfaceVariant else if (selected) pal.signal else colors.onBackground, modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
if (tag != null) Tag(tag)
|
||||
}
|
||||
|
||||
@@ -84,6 +84,9 @@ class GpuDriversState(
|
||||
val supported: Boolean = true,
|
||||
val unsupported: Boolean = false,
|
||||
val auto: Boolean = true,
|
||||
val powerVr: Boolean = false,
|
||||
/** The selected runtime supplies DXVK for PowerVR game launches. */
|
||||
val systemPowerVr: Boolean = false,
|
||||
val pairs: List<PairRow> = emptyList(),
|
||||
/** The pair key being installed, and how far along (-1 = unknown). */
|
||||
val busy: String? = null,
|
||||
|
||||
@@ -263,6 +263,8 @@ class DrawerActions(
|
||||
val onClose: () -> Unit,
|
||||
/** Games tab: every Proton with what it uses; null until first read. */
|
||||
val components: ComponentsManager.Snapshot? = null,
|
||||
/** DXVK is supplied by the selected system PowerVR runtime. */
|
||||
val systemPowerVr: Boolean = false,
|
||||
/** Re-reads the Protons (and runs swaps that waited for a game to close). */
|
||||
val onComponentsRefresh: () -> Unit = {},
|
||||
/** Installed games available for profile inspection in the session drawer. */
|
||||
@@ -1049,7 +1051,11 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S
|
||||
for (component in ComponentsManager.COMPONENTS) {
|
||||
val value = profile.components.getValue(component)
|
||||
if (!value.inherited) {
|
||||
ProfileSummaryRow(ComponentsManager.LABEL.getValue(component), profileValueLabel(value))
|
||||
ProfileSummaryRow(
|
||||
ComponentsManager.LABEL.getValue(component),
|
||||
if (ComponentsManager.runtimeManaged(component, a.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else profileValueLabel(value),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (profile.startWithoutSteam) {
|
||||
@@ -1151,20 +1157,23 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
}
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
val value = gameProfile.components.getValue(comp)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(comp, a.systemPowerVr)
|
||||
val options: List<Pair<String?, String>> =
|
||||
listOf(null to stringResource(R.string.comp_game_use_general)) +
|
||||
snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
if (managedDxvk) emptyList() else snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
DrawerStackedChoice(
|
||||
host = host,
|
||||
key = "game-cmp-$comp",
|
||||
label = ComponentsManager.LABEL.getValue(comp),
|
||||
hint = if (value.inherited) {
|
||||
hint = if (managedDxvk) stringResource(R.string.cmgr_powervr_dxvk_managed) else if (value.inherited) {
|
||||
stringResource(R.string.drawer_component_inherited, value.value)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
options = options,
|
||||
selected = gameProfile.componentFiles[comp],
|
||||
enabled = !managedDxvk || gameProfile.componentFiles[comp] != null,
|
||||
valueLabel = if (managedDxvk) stringResource(R.string.gpu_system_powervr) else null,
|
||||
chipModifier = track("cmp-$comp"),
|
||||
onPick = { file -> a.onGameComponent(gameProfile.appId, comp, file) },
|
||||
)
|
||||
@@ -1200,7 +1209,11 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
Row(modifier = Modifier.fillMaxWidth().padding(top = 3.dp)) {
|
||||
Text(ComponentsManager.LABEL.getValue(comp), fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.width(96.dp))
|
||||
Text(r.components.getValue(comp).inUse, fontSize = 12.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
if (ComponentsManager.runtimeManaged(comp, a.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else r.components.getValue(comp).inUse,
|
||||
fontSize = 12.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1228,17 +1241,22 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
val build = ComponentsManager.safeName(p.version)
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
val st = view.components.getValue(comp)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(comp, a.systemPowerVr)
|
||||
val originals = view.originals.filter { it.comp == comp }
|
||||
val options = originals.map { "orig:${it.protonVersion}" to (if (it.protonVersion == build) originalLabel else stringResource(R.string.comp_original, it.protonVersion)) } +
|
||||
snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
if (options.isEmpty()) continue
|
||||
if (options.isEmpty() && !managedDxvk) continue
|
||||
val current = st.activeFile ?: "orig:$build"
|
||||
val shown = options.firstOrNull { it.first == current }?.second
|
||||
DrawerStackedChoice(
|
||||
host, "cmp-$comp", ComponentsManager.LABEL.getValue(comp),
|
||||
// The box already shows the choice: only say more when there is more to say.
|
||||
st.queued?.let { stringResource(R.string.comp_next_queued, it) } ?: st.inUse.takeIf { it != shown },
|
||||
if (managedDxvk) stringResource(R.string.cmgr_powervr_dxvk_managed) +
|
||||
(st.queued?.let { "\n" + stringResource(R.string.cmgr_powervr_dxvk_queued, it) } ?: "")
|
||||
else st.queued?.let { stringResource(R.string.comp_next_queued, it) } ?: st.inUse.takeIf { it != shown },
|
||||
options, current,
|
||||
enabled = !managedDxvk,
|
||||
valueLabel = if (managedDxvk) stringResource(R.string.gpu_system_powervr) else null,
|
||||
note = if (view.inUseByGame) stringResource(R.string.comp_waits_long) else stringResource(R.string.comp_applies_long),
|
||||
chipModifier = track("cmp-$comp"),
|
||||
onPick = { v -> if (v != current || st.queued != null) a.onComponentSwap(p.id, comp, v) },
|
||||
@@ -1259,11 +1277,11 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
private fun <T> DrawerStackedChoice(
|
||||
host: MenuHost, key: String, label: String, hint: String?,
|
||||
options: List<Pair<T, String>>, selected: T, note: String? = null,
|
||||
chipModifier: Modifier = Modifier, onPick: (T) -> Unit,
|
||||
chipModifier: Modifier = Modifier, enabled: Boolean = true, valueLabel: String? = null, onPick: (T) -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val open = host.open == key
|
||||
val open = host.open == key && enabled
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.background(if (open) pal.signal.copy(alpha = 0.10f) else Color.Transparent)
|
||||
@@ -1271,7 +1289,7 @@ private fun <T> DrawerStackedChoice(
|
||||
) {
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
Box(modifier = Modifier.fillMaxWidth().padding(top = 6.dp)) {
|
||||
ValueChip(options.firstOrNull { it.first == selected }?.second ?: "-", open, modifier = chipModifier.fillMaxWidth()) {
|
||||
ValueChip(valueLabel ?: options.firstOrNull { it.first == selected }?.second ?: "-", open, enabled = enabled, modifier = chipModifier.fillMaxWidth()) {
|
||||
host.open = if (open) null else key
|
||||
}
|
||||
AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus ->
|
||||
|
||||
Reference in new issue
Block a user