mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
Add system and imported Qualcomm drivers as Linux runtime choices
(cherry picked from commit 08fbd19f74561231e6a3adc2069686af111bd0ad)
This commit is contained in:
1 parent
ca9f416118
commit
dd6a86a187
18 files changed
+403
-14
No files matched your search
@@ -19,6 +19,8 @@ import com.droiddeck.launcher.gpu.GpuInfo
|
|||||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||||
|
import com.droiddeck.launcher.gpu.QualcommSystemDriver
|
||||||
|
import com.droiddeck.launcher.gpu.QualcommDriverPackage
|
||||||
import com.droiddeck.launcher.gpu.TurnipReleases
|
import com.droiddeck.launcher.gpu.TurnipReleases
|
||||||
import com.droiddeck.launcher.session.SessionService
|
import com.droiddeck.launcher.session.SessionService
|
||||||
import com.droiddeck.launcher.session.SessionPrefs
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
@@ -143,6 +145,10 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
}
|
}
|
||||||
linuxRows = LinuxVulkanDriver.optionValues(activity).map { id ->
|
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(R.string.gpu_runtime_default), activity.getString(R.string.drivers_runtime_builtin), false)
|
||||||
|
else if (id == QualcommSystemDriver.ID) DriverRow(id, "System Qualcomm driver", QualcommSystemDriver.label(), false)
|
||||||
|
else if (QualcommDriverPackage.isRuntimeId(id)) DriverRow(id,
|
||||||
|
QualcommDriverPackage.label(activity, id), listOf(QualcommDriverPackage.version(activity, id),
|
||||||
|
activity.getString(R.string.drivers_qualcomm_runtime_display)).filter { it.isNotEmpty() }.joinToString(" · "), false, DriverRow.IMPORTED)
|
||||||
else bundleRow(id, linux = true) ?: DriverRow(
|
else bundleRow(id, linux = true) ?: DriverRow(
|
||||||
id, lm.getDriverName(id),
|
id, lm.getDriverName(id),
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
@@ -157,6 +163,8 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
val td = TurnipDriver(activity)
|
val td = TurnipDriver(activity)
|
||||||
val auto = td.autoId()
|
val auto = td.autoId()
|
||||||
androidRows = buildList {
|
androidRows = buildList {
|
||||||
|
if (QualcommSystemDriver.detected()) add(DriverRow(TurnipDriver.SYSTEM,
|
||||||
|
"System Qualcomm driver", QualcommSystemDriver.label(), false))
|
||||||
add(DriverRow(
|
add(DriverRow(
|
||||||
TurnipDriver.AUTO, activity.getString(R.string.gpu_auto_by_gpu),
|
TurnipDriver.AUTO, activity.getString(R.string.gpu_auto_by_gpu),
|
||||||
if (auto == "system") activity.getString(R.string.drivers_system_vulkan) else activity.getString(R.string.drivers_bundled, td.displayName(auto)),
|
if (auto == "system") activity.getString(R.string.drivers_system_vulkan) else activity.getString(R.string.drivers_bundled, td.displayName(auto)),
|
||||||
@@ -431,7 +439,10 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
|||||||
val bundle = DriverBundle.containing(activity, id, linux)
|
val bundle = DriverBundle.containing(activity, id, linux)
|
||||||
when {
|
when {
|
||||||
bundle != null -> useBundle(bundle)
|
bundle != null -> useBundle(bundle)
|
||||||
linux -> SessionPrefs.setLinuxDriver(activity, id)
|
linux -> {
|
||||||
|
SessionPrefs.setLinuxDriver(activity, id)
|
||||||
|
if (QualcommSystemDriver.handles(id)) SessionPrefs.setAndroidDriver(activity, TurnipDriver.SYSTEM)
|
||||||
|
}
|
||||||
else -> SessionPrefs.setAndroidDriver(activity, id)
|
else -> SessionPrefs.setAndroidDriver(activity, id)
|
||||||
}
|
}
|
||||||
pairModeOpen = false
|
pairModeOpen = false
|
||||||
|
|||||||
@@ -222,7 +222,10 @@ object DeviceReport {
|
|||||||
val lm = LinuxVulkanDriverManager(context)
|
val lm = LinuxVulkanDriverManager(context)
|
||||||
run {
|
run {
|
||||||
val id = SessionPrefs.linuxDriver(context)
|
val id = SessionPrefs.linuxDriver(context)
|
||||||
val label = if (id.isEmpty()) "runtime default (the Turnip built into the runtime)"
|
val label = if (id == com.droiddeck.launcher.gpu.QualcommSystemDriver.ID) com.droiddeck.launcher.gpu.QualcommSystemDriver.label()
|
||||||
|
else if (com.droiddeck.launcher.gpu.QualcommDriverPackage.isRuntimeId(id))
|
||||||
|
"${com.droiddeck.launcher.gpu.QualcommDriverPackage.label(context, id)} ${com.droiddeck.launcher.gpu.QualcommDriverPackage.version(context, id)}"
|
||||||
|
else if (id.isEmpty()) "runtime default (the Turnip built into the runtime)"
|
||||||
else "${lm.getDriverName(id)} ${lm.getDriverVersion(id)}".trim() +
|
else "${lm.getDriverName(id)} ${lm.getDriverVersion(id)}".trim() +
|
||||||
lm.getMinGlibc(id).let { if (it.isEmpty()) "" else " (glibc $it+)" } +
|
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 " [MISSING - falls back to the runtime's own]"
|
||||||
|
|||||||
@@ -149,7 +149,9 @@ object DeviceInfo {
|
|||||||
add("Display driver", "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
add("Display driver", "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
||||||
val linux = LinuxVulkanDriverManager(context)
|
val linux = LinuxVulkanDriverManager(context)
|
||||||
val id = SessionPrefs.linuxDriver(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 == QualcommSystemDriver.ID) QualcommSystemDriver.label()
|
||||||
|
else if (QualcommDriverPackage.isRuntimeId(id)) "${QualcommDriverPackage.label(context, id)} ${QualcommDriverPackage.version(context, id)}"
|
||||||
|
else if (id.isEmpty()) "the runtime's own Turnip" 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")
|
if (gpu.oneUi8Gen2) add("Note", "One UI on an 8 Gen 2: needs the OneUI Turnip build")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -12,8 +12,8 @@ public final class LinuxVulkanDriver {
|
|||||||
|
|
||||||
public static final String HELP_TEXT =
|
public static final String HELP_TEXT =
|
||||||
"The driver the Steam client, the games it launches and the desktop's programs render on, "
|
"The driver the Steam client, the games it launches and the desktop's programs render on, "
|
||||||
+ "inside the Linux runtime. Imported \"-Linux\" Turnip zips only: these are Linux processes "
|
+ "inside the Linux runtime. Import \"-Linux\" Turnip zips, or select the experimental system "
|
||||||
+ "and cannot load an Android or Wayland driver. Frames still reach the screen through the "
|
+ "Qualcomm bridge or a Qualcomm package already imported as an AdrenoTools zip. Frames reach the screen through the "
|
||||||
+ "display driver below. Takes effect at the next session start.";
|
+ "display driver below. Takes effect at the next session start.";
|
||||||
|
|
||||||
private LinuxVulkanDriver() {}
|
private LinuxVulkanDriver() {}
|
||||||
@@ -21,12 +21,18 @@ public final class LinuxVulkanDriver {
|
|||||||
public static List<String> optionValues(Context context) {
|
public static List<String> optionValues(Context context) {
|
||||||
ArrayList<String> values = new ArrayList<>();
|
ArrayList<String> values = new ArrayList<>();
|
||||||
values.add("");
|
values.add("");
|
||||||
|
if (QualcommSystemDriver.detected()) {
|
||||||
|
values.add(QualcommSystemDriver.ID);
|
||||||
|
values.addAll(QualcommDriverPackage.available(context));
|
||||||
|
}
|
||||||
values.addAll(new LinuxVulkanDriverManager(context).enumerateInstalledDrivers());
|
values.addAll(new LinuxVulkanDriverManager(context).enumerateInstalledDrivers());
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String optionLabel(Context context, String value) {
|
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 "Runtime default (built into the runtime)";
|
||||||
|
if (QualcommSystemDriver.ID.equals(value)) return QualcommSystemDriver.label();
|
||||||
|
if (QualcommDriverPackage.isRuntimeId(value)) return QualcommDriverPackage.label(context, value);
|
||||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||||
if (!m.isInstalled(value)) return value + " (imported, missing - uses the runtime default)";
|
if (!m.isInstalled(value)) return value + " (imported, missing - uses the runtime default)";
|
||||||
String ver = m.getDriverVersion(value);
|
String ver = m.getDriverVersion(value);
|
||||||
@@ -35,6 +41,11 @@ public final class LinuxVulkanDriver {
|
|||||||
|
|
||||||
public static String resolveIcdPath(Context context, String value) {
|
public static String resolveIcdPath(Context context, String value) {
|
||||||
if (value == null || value.isEmpty()) return null;
|
if (value == null || value.isEmpty()) return null;
|
||||||
|
if (QualcommSystemDriver.handles(value)) {
|
||||||
|
if (QualcommDriverPackage.isRuntimeId(value) && !QualcommDriverPackage.isInstalled(context, value))
|
||||||
|
throw new IllegalStateException("The selected Qualcomm AdrenoTools package is missing or incompatible");
|
||||||
|
return QualcommSystemDriver.prepare(context).getAbsolutePath();
|
||||||
|
}
|
||||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||||
String icd = m.getIcdPath(value);
|
String icd = m.getIcdPath(value);
|
||||||
if (icd == null) {
|
if (icd == null) {
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.droiddeck.launcher.gpu
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import com.droiddeck.launcher.core.FileUtils
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object QualcommDriverPackage {
|
||||||
|
private const val PREFIX = "qualcomm-adrenotools:"
|
||||||
|
|
||||||
|
@JvmStatic fun runtimeId(importedId: String): String {
|
||||||
|
require(validName(importedId)) { "Invalid imported driver ID" }
|
||||||
|
return PREFIX + importedId
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic fun importedId(runtimeId: String?): String? = runtimeId
|
||||||
|
?.takeIf { it.startsWith(PREFIX) }?.removePrefix(PREFIX)?.takeIf(::validName)
|
||||||
|
|
||||||
|
@JvmStatic fun isRuntimeId(id: String?): Boolean = id?.startsWith(PREFIX) == true
|
||||||
|
|
||||||
|
private fun validName(name: String): Boolean = name.isNotBlank() && name != "." && !name.contains("..") &&
|
||||||
|
name.none { it == '/' || it == '\\' || it == ':' || it == '\u0000' }
|
||||||
|
|
||||||
|
private fun metadata(context: Context, id: String): JSONObject? {
|
||||||
|
if (!validName(id)) return null
|
||||||
|
return runCatching { JSONObject(FileUtils.readString(File(TurnipDriver(context).driverPath(id), "meta.json"))) }.getOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic fun available(context: Context): List<String> = TurnipDriver(context).enumerateImported()
|
||||||
|
.filter { isInstalled(context, runtimeId(it)) }.map(::runtimeId)
|
||||||
|
|
||||||
|
@JvmStatic fun isInstalled(context: Context, runtimeId: String): Boolean {
|
||||||
|
val id = importedId(runtimeId) ?: return false
|
||||||
|
val meta = metadata(context, id) ?: return false
|
||||||
|
val vendor = meta.optString("vendor")
|
||||||
|
val description = listOf(meta.optString("name"), meta.optString("description"), meta.optString("libraryName")).joinToString(" ")
|
||||||
|
if (!vendor.equals("Qualcomm", true) || description.contains("turnip", true) || description.contains("mesa", true)) return false
|
||||||
|
if (meta.optInt("minApi", 0) > Build.VERSION.SDK_INT) return false
|
||||||
|
val library = meta.optString("libraryName")
|
||||||
|
return validName(library) && library.endsWith(".so") && TurnipDriver(context).isInstalled(id) &&
|
||||||
|
LinuxVulkanDriverManager.isAarch64Elf(File(TurnipDriver(context).driverPath(id), library))
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic fun label(context: Context, runtimeId: String): String {
|
||||||
|
val id = importedId(runtimeId) ?: return "Invalid Qualcomm package"
|
||||||
|
val driver = TurnipDriver(context)
|
||||||
|
return "${driver.displayName(id)} · Qualcomm (AdrenoTools, experimental)" +
|
||||||
|
if (isInstalled(context, runtimeId)) "" else " [missing or incompatible]"
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic fun version(context: Context, runtimeId: String): String = importedId(runtimeId)
|
||||||
|
?.let { TurnipDriver(context).driverVersion(it) }.orEmpty()
|
||||||
|
|
||||||
|
@JvmStatic fun mounts(context: Context, runtimeId: String): List<String> {
|
||||||
|
check(isInstalled(context, runtimeId)) { "The selected Qualcomm AdrenoTools package is missing or incompatible" }
|
||||||
|
val id = importedId(runtimeId)!!
|
||||||
|
val driver = TurnipDriver(context)
|
||||||
|
val directory = File(driver.driverPath(id))
|
||||||
|
val primary = driver.libraryName(id)!!
|
||||||
|
val mounts = arrayListOf("${File(directory, primary).path}:${QualcommSystemDriver.HAL}")
|
||||||
|
for (library in directory.listFiles().orEmpty().sortedBy { it.name }) {
|
||||||
|
val name = library.name
|
||||||
|
if (name == primary || !name.endsWith(".so") || !validName(name) ||
|
||||||
|
name in setOf("libc.so", "libdl.so", "libm.so", "liblog.so", "libvulkan.so") ||
|
||||||
|
!LinuxVulkanDriverManager.isAarch64Elf(library)) continue
|
||||||
|
mounts.add("${library.path}:/vendor/lib64/$name")
|
||||||
|
// The SP-HAL namespace resolves libc++ from system before vendor.
|
||||||
|
if (name == "libc++.so") mounts.add("${library.path}:/system/lib64/$name")
|
||||||
|
}
|
||||||
|
return mounts
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package com.droiddeck.launcher.gpu
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.os.Build
|
||||||
|
import com.droiddeck.launcher.BuildConfig
|
||||||
|
import com.droiddeck.launcher.core.FileUtils
|
||||||
|
import com.droiddeck.launcher.core.TarZst
|
||||||
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
object QualcommSystemDriver {
|
||||||
|
const val ID = "system-qualcomm"
|
||||||
|
const val HAL = "/vendor/lib64/hw/vulkan.adreno.so"
|
||||||
|
private val required = listOf("lib/libhybris-vulkan-icd.so.0", "lib/libhybris-common.so.1", "lib/libhybris/linker/q.so",
|
||||||
|
"bin/gamescope", "shaders/qualcomm-shaders.so", "wsi/libVkLayer_window_system_integration.so")
|
||||||
|
|
||||||
|
@JvmStatic fun detected(): Boolean {
|
||||||
|
if (Build.VERSION.SDK_INT < 29 || !File(HAL).canRead()) return false
|
||||||
|
val vk = VulkanInfo.query()
|
||||||
|
return isQualcomm(vk)
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun isQualcomm(vk: Map<String, String>): Boolean =
|
||||||
|
vk["vendor_id"] == "0x5143" && (vk["driver_id"] == "8" ||
|
||||||
|
(vk["driver_id"] == null && vk["driver_name"]?.contains("Qualcomm", ignoreCase = true) == true))
|
||||||
|
|
||||||
|
@JvmStatic fun handles(id: String?) = id == ID || QualcommDriverPackage.isRuntimeId(id)
|
||||||
|
|
||||||
|
@JvmStatic fun selected(context: Context) = handles(SessionPrefs.linuxDriver(context))
|
||||||
|
|
||||||
|
@JvmStatic fun mounts(context: Context, id: String): List<String> = androidPaths() +
|
||||||
|
if (QualcommDriverPackage.isRuntimeId(id)) QualcommDriverPackage.mounts(context, id) else emptyList()
|
||||||
|
|
||||||
|
@JvmStatic fun label(): String {
|
||||||
|
val vk = VulkanInfo.query()
|
||||||
|
val version = vk["driver_version_raw"]?.toULongOrNull()?.let { "${(it shr 22) and 0x7fu}.${(it shr 12) and 0x3ffu}.${it and 0xfffu}" }
|
||||||
|
?: vk["driver_version"] ?: "unknown version"
|
||||||
|
return "System Qualcomm · ${vk["device"] ?: "Adreno"} · $version (experimental)"
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic @Synchronized fun prepare(context: Context): File {
|
||||||
|
check(detected()) { "The installed Vulkan driver is not a supported Qualcomm Android driver" }
|
||||||
|
val sha = BuildConfig.QUALCOMM_BRIDGE_SHA256 + "-" + BuildConfig.QUALCOMM_FIXES_REVISION.take(16)
|
||||||
|
val root = File(context.filesDir, "qualcomm-system")
|
||||||
|
val dir = File(root, sha)
|
||||||
|
if (!File(dir, ".complete").isFile || required.any { !File(dir, it).isFile }) {
|
||||||
|
val staging = File(root, "$sha.partial")
|
||||||
|
FileUtils.delete(staging)
|
||||||
|
check(TarZst.extractAsset(context, "qualcomm/runtime.tzst", staging)) { "Cannot extract the Qualcomm Vulkan bridge" }
|
||||||
|
val gamescope = File(staging, "bin/gamescope")
|
||||||
|
gamescope.parentFile!!.mkdirs()
|
||||||
|
check(FileUtils.copyAsset(context, "qualcomm/gamescope", gamescope)) { "Cannot prepare Qualcomm Gamescope" }
|
||||||
|
check(gamescope.setExecutable(true, false)) { "Cannot prepare Qualcomm Gamescope" }
|
||||||
|
copyAssets(context, "qualcomm/wsi", File(staging, "wsi"))
|
||||||
|
copyAssets(context, "qualcomm/shaders", File(staging, "shaders"))
|
||||||
|
copyAssets(context, "qualcomm/licenses", File(staging, "licenses"))
|
||||||
|
check(required.all { File(staging, it).isFile }) { "The Qualcomm Vulkan bridge is incomplete" }
|
||||||
|
File(staging, ".complete").writeText(sha)
|
||||||
|
FileUtils.delete(dir)
|
||||||
|
check(staging.renameTo(dir)) { "Cannot install the Qualcomm Vulkan bridge" }
|
||||||
|
}
|
||||||
|
val manifest = JSONObject().put("file_format_version", "1.0.0").put("ICD", JSONObject()
|
||||||
|
.put("library_path", File(dir, "lib/libhybris-vulkan-icd.so.0").path)
|
||||||
|
.put("api_version", VulkanInfo.query()["api"] ?: "1.1.0"))
|
||||||
|
val icd = File(dir, "icd.json")
|
||||||
|
if (!icd.isFile || icd.readText() != manifest.toString()) icd.writeText(manifest.toString())
|
||||||
|
return icd
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic @JvmOverloads fun addEnvironment(context: Context, environment: MutableList<String>, id: String = SessionPrefs.linuxDriver(context)) {
|
||||||
|
if (QualcommDriverPackage.isRuntimeId(id)) check(QualcommDriverPackage.isInstalled(context, id)) {
|
||||||
|
"The selected Qualcomm AdrenoTools package is missing or incompatible"
|
||||||
|
}
|
||||||
|
val icd = prepare(context)
|
||||||
|
val dir = icd.parentFile!!
|
||||||
|
val source = if (id == ID) label() else QualcommDriverPackage.label(context, id)
|
||||||
|
android.util.Log.i("QualcommSystemDriver", "$source; Android mounts: ${mounts(context, id).joinToString()}")
|
||||||
|
environment.addAll(listOf(
|
||||||
|
"VK_DRIVER_FILES=${icd.path}", "VK_ICD_FILENAMES=${icd.path}",
|
||||||
|
"HYBRIS_ANDROID_SDK_VERSION=${Build.VERSION.SDK_INT}", "HYBRIS_VULKAN_HAL=$HAL",
|
||||||
|
"HYBRIS_LINKER_DIR=${File(dir, "lib/libhybris/linker").path}",
|
||||||
|
"HYBRIS_LD_LIBRARY_PATH=/system/lib64:/system_ext/lib64:/vendor/lib64/egl:/vendor/lib64/hw:/vendor/lib64",
|
||||||
|
"DROIDDECK_SYSTEM_QUALCOMM=1", "BL_GAMESCOPE_BACKEND=sdl",
|
||||||
|
"DROIDDECK_QUALCOMM_DRIVER=$id",
|
||||||
|
"BL_STEAM_CEF_SOFTWARE=1",
|
||||||
|
"BL_GAMESCOPE_BINARY=${File(dir, "bin/gamescope").path}",
|
||||||
|
"DROIDDECK_QUALCOMM_ROOT=${dir.path}",
|
||||||
|
"DROIDDECK_QUALCOMM_SHADERS=${File(dir, "shaders").path}",
|
||||||
|
"VK_LAYER_PATH=${File(dir, "shaders").path}",
|
||||||
|
"VK_INSTANCE_LAYERS=VK_LAYER_DROIDDECK_qualcomm_shaders",
|
||||||
|
"PATH=${File(dir, "bin").path}:/usr/local/bin:/usr/bin:/bin",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun copyAssets(context: Context, path: String, destination: File) {
|
||||||
|
val children = context.assets.list(path) ?: emptyArray()
|
||||||
|
if (children.isEmpty()) {
|
||||||
|
check(FileUtils.copyAsset(context, path, destination)) { "Cannot prepare $path" }
|
||||||
|
} else {
|
||||||
|
check(destination.isDirectory || destination.mkdirs()) { "Cannot prepare $path" }
|
||||||
|
for (child in children) copyAssets(context, "$path/$child", File(destination, child))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic fun androidPaths(): List<String> = listOf(
|
||||||
|
"/system", "/vendor", "/odm", "/system_ext", "/product", "/apex", "/linkerconfig",
|
||||||
|
"/dev/__properties__"
|
||||||
|
).filter { File(it).exists() }
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ public final class TurnipDriver {
|
|||||||
private static final String PREFS = "graphics_driver";
|
private static final String PREFS = "graphics_driver";
|
||||||
private static final String KEY_HIDDEN = "hiddenBundled";
|
private static final String KEY_HIDDEN = "hiddenBundled";
|
||||||
public static final String AUTO = "";
|
public static final String AUTO = "";
|
||||||
|
public static final String SYSTEM = "system";
|
||||||
|
|
||||||
public static final String HELP_TEXT =
|
public static final String HELP_TEXT =
|
||||||
"The driver the app's compositor puts frames on the screen with - the last step of every "
|
"The driver the app's compositor puts frames on the screen with - the last step of every "
|
||||||
@@ -139,6 +140,8 @@ public final class TurnipDriver {
|
|||||||
Log.d(TAG, "removing imported driver " + driverId);
|
Log.d(TAG, "removing imported driver " + driverId);
|
||||||
FileUtils.delete(new File(contentDir, driverId));
|
FileUtils.delete(new File(contentDir, driverId));
|
||||||
if (driverId.equals(SessionPrefs.androidDriver(context))) SessionPrefs.setAndroidDriver(context, AUTO);
|
if (driverId.equals(SessionPrefs.androidDriver(context))) SessionPrefs.setAndroidDriver(context, AUTO);
|
||||||
|
if (driverId.equals(QualcommDriverPackage.importedId(SessionPrefs.INSTANCE.linuxDriver(context))))
|
||||||
|
SessionPrefs.INSTANCE.setLinuxDriver(context, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String installFromZip(Uri zipUri, String displayName) throws IOException {
|
public String installFromZip(Uri zipUri, String displayName) throws IOException {
|
||||||
@@ -257,6 +260,7 @@ public final class TurnipDriver {
|
|||||||
|
|
||||||
private String choose() {
|
private String choose() {
|
||||||
String chosen = SessionPrefs.androidDriver(context);
|
String chosen = SessionPrefs.androidDriver(context);
|
||||||
|
if (SYSTEM.equals(chosen)) return null;
|
||||||
if (chosen != null && !chosen.isEmpty()) {
|
if (chosen != null && !chosen.isEmpty()) {
|
||||||
if (BUNDLED.contains(chosen)) {
|
if (BUNDLED.contains(chosen)) {
|
||||||
Log.i(TAG, "driver pinned by the user: " + chosen);
|
Log.i(TAG, "driver pinned by the user: " + chosen);
|
||||||
|
|||||||
@@ -179,6 +179,15 @@ object BwrapSpawner {
|
|||||||
val argv = request.getJSONArray("argv").let { a -> (0 until a.length()).map { a.getString(it) } }
|
val argv = request.getJSONArray("argv").let { a -> (0 until a.length()).map { a.getString(it) } }
|
||||||
val env = LinkedHashMap<String, String>()
|
val env = LinkedHashMap<String, String>()
|
||||||
request.optJSONObject("env")?.let { e -> e.keys().forEach { k -> env[k] = e.getString(k) } }
|
request.optJSONObject("env")?.let { e -> e.keys().forEach { k -> env[k] = e.getString(k) } }
|
||||||
|
val runtimeDriver = com.droiddeck.launcher.session.SessionState.runtimeDriver
|
||||||
|
if (com.droiddeck.launcher.gpu.QualcommSystemDriver.handles(runtimeDriver)) {
|
||||||
|
val driver = com.droiddeck.launcher.gpu.QualcommSystemDriver
|
||||||
|
val variables = ArrayList<String>()
|
||||||
|
driver.addEnvironment(context, variables, runtimeDriver!!)
|
||||||
|
for (entry in variables) env.putIfAbsent(entry.substringBefore('='), entry.substringAfter('='))
|
||||||
|
for (path in driver.mounts(context, runtimeDriver) + File(context.filesDir, "qualcomm-system").path)
|
||||||
|
addBind(Bind.parse(path))
|
||||||
|
}
|
||||||
if (binds.any { it.guest == "/dev" }) gpu(rootfs, root, env)?.forEach { addBind(it) }
|
if (binds.any { it.guest == "/dev" }) gpu(rootfs, root, env)?.forEach { addBind(it) }
|
||||||
preload(session, rootfs, env).forEach { addBind(it) }
|
preload(session, rootfs, env).forEach { addBind(it) }
|
||||||
zypakShims(binds, root, dir).forEach { addBind(it) }
|
zypakShims(binds, root, dir).forEach { addBind(it) }
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ public final class LinuxRuntime {
|
|||||||
bind(cmd, "/dev");
|
bind(cmd, "/dev");
|
||||||
bind(cmd, "/proc");
|
bind(cmd, "/proc");
|
||||||
bind(cmd, "/sys");
|
bind(cmd, "/sys");
|
||||||
|
if (com.droiddeck.launcher.gpu.QualcommSystemDriver.selected(context)) {
|
||||||
|
for (String path : com.droiddeck.launcher.gpu.QualcommSystemDriver.mounts(context,
|
||||||
|
SessionPrefs.INSTANCE.linuxDriver(context))) bind(cmd, path);
|
||||||
|
}
|
||||||
bind(cmd, "/dev/urandom:/dev/random");
|
bind(cmd, "/dev/urandom:/dev/random");
|
||||||
bind(cmd, "/proc/self/fd:/dev/fd");
|
bind(cmd, "/proc/self/fd:/dev/fd");
|
||||||
bind(cmd, "/proc/self/fd/0:/dev/stdin");
|
bind(cmd, "/proc/self/fd/0:/dev/stdin");
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ object SessionFiles {
|
|||||||
"usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard",
|
"usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard",
|
||||||
"usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window",
|
"usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window",
|
||||||
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
|
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
|
||||||
|
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/bin/droiddeck-steam-taskset",
|
||||||
|
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/libexec/droiddeck-steam/taskset",
|
||||||
"usr/local/bin/droiddeck-steam-ui-scale" to "usr/local/bin/droiddeck-steam-ui-scale",
|
"usr/local/bin/droiddeck-steam-ui-scale" to "usr/local/bin/droiddeck-steam-ui-scale",
|
||||||
"usr/local/bin/droiddeck-steam-language" to "usr/local/bin/droiddeck-steam-language",
|
"usr/local/bin/droiddeck-steam-language" to "usr/local/bin/droiddeck-steam-language",
|
||||||
"usr/local/bin/droiddeck-steam-shaders" to "usr/local/bin/droiddeck-steam-shaders",
|
"usr/local/bin/droiddeck-steam-shaders" to "usr/local/bin/droiddeck-steam-shaders",
|
||||||
|
|||||||
@@ -684,8 +684,10 @@ class SessionService : Service() {
|
|||||||
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
|
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
|
||||||
guest.add("GALLIUM_DRIVER=zink")
|
guest.add("GALLIUM_DRIVER=zink")
|
||||||
guest.add("LIBGL_KOPPER_DRI2=true")
|
guest.add("LIBGL_KOPPER_DRI2=true")
|
||||||
LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
|
|
||||||
val linuxDriverId = SessionPrefs.linuxDriver(this)
|
val linuxDriverId = SessionPrefs.linuxDriver(this)
|
||||||
|
val systemQualcomm = com.droiddeck.launcher.gpu.QualcommSystemDriver.handles(linuxDriverId)
|
||||||
|
if (systemQualcomm) com.droiddeck.launcher.gpu.QualcommSystemDriver.addEnvironment(this, guest)
|
||||||
|
else LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
|
||||||
SessionState.runtimeDriver = linuxDriverId
|
SessionState.runtimeDriver = linuxDriverId
|
||||||
com.droiddeck.launcher.gpu.AutoDriverTrial.sessionStarting(
|
com.droiddeck.launcher.gpu.AutoDriverTrial.sessionStarting(
|
||||||
this,
|
this,
|
||||||
@@ -695,9 +697,9 @@ class SessionService : Service() {
|
|||||||
)
|
)
|
||||||
LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId)
|
LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId)
|
||||||
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
|
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
|
||||||
val tuOverride = tuDebugOverride()
|
val tuOverride = if (systemQualcomm) null else tuDebugOverride()
|
||||||
val tuDriver = sysmemDriver(linuxDriverId)
|
val tuDriver = sysmemDriver(linuxDriverId)
|
||||||
(tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
if (!systemQualcomm) (tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
||||||
if (SessionPrefs.zinkLazy(this)) {
|
if (SessionPrefs.zinkLazy(this)) {
|
||||||
guest.add("ZINK_DESCRIPTORS=lazy")
|
guest.add("ZINK_DESCRIPTORS=lazy")
|
||||||
guest.add("ZINK_DEBUG=compact")
|
guest.add("ZINK_DEBUG=compact")
|
||||||
@@ -705,7 +707,9 @@ class SessionService : Service() {
|
|||||||
if (SessionPrefs.glThread(this)) guest.add("mesa_glthread=true")
|
if (SessionPrefs.glThread(this)) guest.add("mesa_glthread=true")
|
||||||
if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1")
|
if (SessionPrefs.noGlError(this)) guest.add("MESA_NO_ERROR=1")
|
||||||
guest.add("MESA_DISK_CACHE_DATABASE=1")
|
guest.add("MESA_DISK_CACHE_DATABASE=1")
|
||||||
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
|
// Steam loads libhybris after other TLS users; its Bionic TLS bridge requires static storage.
|
||||||
|
val staticTls = if (systemQualcomm) ":glibc.rtld.optional_static_tls=16384" else ""
|
||||||
|
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216$staticTls")
|
||||||
if (SessionState.mode == MODE_STEAM) guest.add("BL_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
if (SessionState.mode == MODE_STEAM) guest.add("BL_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
|
||||||
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
|
||||||
SessionState.steamClientArch?.let { arch ->
|
SessionState.steamClientArch?.let { arch ->
|
||||||
|
|||||||
@@ -425,6 +425,7 @@
|
|||||||
<string name="common_size_mb">%1$.1f MB</string>
|
<string name="common_size_mb">%1$.1f MB</string>
|
||||||
<string name="comp_runtime_driver">Runtime driver</string>
|
<string name="comp_runtime_driver">Runtime driver</string>
|
||||||
<string name="comp_runtime_driver_hint">Used by Steam, games and the desktop. Applies next session.</string>
|
<string name="comp_runtime_driver_hint">Used by Steam, games and the desktop. Applies next session.</string>
|
||||||
|
<string name="drivers_qualcomm_runtime_display">Uses the system display driver</string>
|
||||||
<string name="comp_import_turnip">Import Turnip zip…</string>
|
<string name="comp_import_turnip">Import Turnip zip…</string>
|
||||||
<string name="comp_display_driver">Display driver</string>
|
<string name="comp_display_driver">Display driver</string>
|
||||||
<string name="comp_display_driver_hint">Draws frames to the screen in both modes. Restart the app to apply.</string>
|
<string name="comp_display_driver_hint">Draws frames to the screen in both modes. Restart the app to apply.</string>
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.droiddeck.launcher.gpu
|
||||||
|
|
||||||
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
|
import org.json.JSONObject
|
||||||
|
import org.junit.Assert.*
|
||||||
|
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
|
||||||
|
|
||||||
|
@RunWith(RobolectricTestRunner::class)
|
||||||
|
@Config(sdk = [28], manifest = Config.NONE)
|
||||||
|
class QualcommDriverPackageTest {
|
||||||
|
private val context get() = RuntimeEnvironment.getApplication()
|
||||||
|
private val id = "v891.7"
|
||||||
|
private val runtimeId get() = QualcommDriverPackage.runtimeId(id)
|
||||||
|
private val directory get() = File(TurnipDriver(context).driverPath(id))
|
||||||
|
|
||||||
|
@Before fun reset() {
|
||||||
|
File(context.filesDir, "graphics_driver").deleteRecursively()
|
||||||
|
context.getSharedPreferences("session", 0).edit().clear().commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun previouslyImportedQualcommPackagesAreAvailableWithoutReimporting() {
|
||||||
|
install()
|
||||||
|
assertEquals(listOf(runtimeId), QualcommDriverPackage.available(context))
|
||||||
|
assertTrue(QualcommSystemDriver.handles(runtimeId))
|
||||||
|
assertTrue(QualcommDriverPackage.label(context, runtimeId).contains(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun turnipAndPackagesRequiringANewerAndroidAreExcluded() {
|
||||||
|
install(vendor = "Mesa")
|
||||||
|
assertTrue(QualcommDriverPackage.available(context).isEmpty())
|
||||||
|
install(minApi = 36)
|
||||||
|
assertTrue(QualcommDriverPackage.available(context).isEmpty())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun mountsKeepTheAndroidLoaderAndBridgeOnTheSameImportedHal() {
|
||||||
|
install()
|
||||||
|
elf(File(directory, "libc++.so"))
|
||||||
|
elf(File(directory, "libllvm-qgl.so"))
|
||||||
|
elf(File(directory, "libc.so"))
|
||||||
|
elf(File(directory, "wrong-architecture.so"), arm64 = false)
|
||||||
|
val binds = QualcommDriverPackage.mounts(context, runtimeId)
|
||||||
|
assertTrue("${File(directory, "vulkan.ad891.so").path}:${QualcommSystemDriver.HAL}" in binds)
|
||||||
|
assertTrue("${File(directory, "libc++.so").path}:/system/lib64/libc++.so" in binds)
|
||||||
|
assertTrue("${File(directory, "libc++.so").path}:/vendor/lib64/libc++.so" in binds)
|
||||||
|
assertTrue("${File(directory, "libllvm-qgl.so").path}:/vendor/lib64/libllvm-qgl.so" in binds)
|
||||||
|
assertFalse(binds.any { "wrong-architecture" in it || it.endsWith("/libc.so") })
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun deletingTheDisplayPackageAlsoClearsItsLinuxSelection() {
|
||||||
|
install()
|
||||||
|
SessionPrefs.setLinuxDriver(context, runtimeId)
|
||||||
|
SessionPrefs.setAndroidDriver(context, id)
|
||||||
|
TurnipDriver(context).remove(id)
|
||||||
|
assertEquals("", SessionPrefs.linuxDriver(context))
|
||||||
|
assertEquals("", SessionPrefs.androidDriver(context))
|
||||||
|
assertFalse(QualcommDriverPackage.isInstalled(context, runtimeId))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun invalidAndMissingPackagesCannotSilentlyUseTheSystemDriver() {
|
||||||
|
assertNull(QualcommDriverPackage.importedId("qualcomm-adrenotools:../escape"))
|
||||||
|
assertNull(QualcommDriverPackage.importedId("qualcomm-adrenotools:/absolute"))
|
||||||
|
assertNull(QualcommDriverPackage.importedId("qualcomm-adrenotools:a:b"))
|
||||||
|
assertThrows(IllegalStateException::class.java) { QualcommDriverPackage.mounts(context, runtimeId) }
|
||||||
|
assertThrows(IllegalStateException::class.java) { LinuxVulkanDriver.resolveIcdPath(context, runtimeId) }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun install(vendor: String = "Qualcomm", minApi: Int = 28) {
|
||||||
|
directory.mkdirs()
|
||||||
|
File(directory, "meta.json").writeText(JSONObject().put("name", id).put("vendor", vendor)
|
||||||
|
.put("libraryName", "vulkan.ad891.so").put("minApi", minApi).put("driverVersion", "Vulkan 1.4.359").toString())
|
||||||
|
elf(File(directory, "vulkan.ad891.so"))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun elf(file: File, arm64: Boolean = true) {
|
||||||
|
file.writeBytes(ByteArray(20).apply {
|
||||||
|
this[0] = 0x7f; this[1] = 'E'.code.toByte(); this[2] = 'L'.code.toByte(); this[3] = 'F'.code.toByte()
|
||||||
|
this[4] = 2; this[5] = 1; this[18] = (if (arm64) 0xb7 else 0x3e).toByte()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.droiddeck.launcher.gpu
|
||||||
|
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class QualcommSystemDriverTest {
|
||||||
|
@Test fun detectsTheProprietaryDriverByIdentity() {
|
||||||
|
assertTrue(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x5143", "driver_id" to "8")))
|
||||||
|
assertFalse(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x5143", "driver_id" to "18", "driver_name" to "Qualcomm")))
|
||||||
|
assertFalse(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x13b5", "driver_id" to "8")))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test fun olderDriverPropertiesRequireAnExplicitVendorName() {
|
||||||
|
assertTrue(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x5143", "driver_name" to "Qualcomm Technologies Inc.")))
|
||||||
|
assertFalse(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x5143", "driver_name" to "Mesa Turnip")))
|
||||||
|
assertFalse(QualcommSystemDriver.isQualcomm(mapOf("vendor_id" to "0x5143", "device" to "Adreno 840")))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,8 @@ if [ -n "${BL_DEBUG_DIR:-}" ]; then
|
|||||||
fi
|
fi
|
||||||
width=${BL_WIDTH:-1280}
|
width=${BL_WIDTH:-1280}
|
||||||
height=${BL_HEIGHT:-720}
|
height=${BL_HEIGHT:-720}
|
||||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
|
backend=${BL_GAMESCOPE_BACKEND:-wayland}
|
||||||
|
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$width" -h "$height")
|
||||||
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
||||||
args+=(-r "$BL_FPS")
|
args+=(-r "$BL_FPS")
|
||||||
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
elif [ "${BL_REFRESH:-0}" -gt 0 ]; then
|
||||||
@@ -20,7 +21,15 @@ unset LIBGL_ALWAYS_SOFTWARE QT_QUICK_BACKEND KWIN_COMPOSE
|
|||||||
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
export MESA_LOADER_DRIVER_OVERRIDE=zink GALLIUM_DRIVER=zink LIBGL_KOPPER_DRI2=true
|
||||||
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
|
[ -n "${DROIDDECK_GLTHREAD:-}" ] && export mesa_glthread=$DROIDDECK_GLTHREAD
|
||||||
export APPIMAGE_EXTRACT_AND_RUN=1
|
export APPIMAGE_EXTRACT_AND_RUN=1
|
||||||
gamescope "${args[@]}" -- /usr/local/bin/droiddeck-gpu-window "$@"
|
if [ "$backend" = sdl ]; then export SDL_VIDEODRIVER=wayland; fi
|
||||||
|
child_env=(SDL_VIDEODRIVER=x11)
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
export VK_LAYER_PATH="$DROIDDECK_QUALCOMM_ROOT/shaders"
|
||||||
|
export VK_INSTANCE_LAYERS=VK_LAYER_DROIDDECK_qualcomm_shaders
|
||||||
|
child_env+=("VK_LAYER_PATH=$DROIDDECK_QUALCOMM_ROOT/wsi:$DROIDDECK_QUALCOMM_ROOT/lib"
|
||||||
|
VK_INSTANCE_LAYERS=VK_LAYER_window_system_integration:VK_LAYER_HYBRIS_compat WSI_X11_FORCE_SHM=1 DISABLE_GAMESCOPE_WSI=1)
|
||||||
|
fi
|
||||||
|
"${BL_GAMESCOPE_BINARY:-gamescope}" "${args[@]}" -- /usr/bin/env "${child_env[@]}" /usr/local/bin/droiddeck-gpu-window "$@"
|
||||||
rc=$?
|
rc=$?
|
||||||
echo "== droiddeck-gpu $(date -u +%H:%M:%S): exited $rc"
|
echo "== droiddeck-gpu $(date -u +%H:%M:%S): exited $rc"
|
||||||
exit $rc
|
exit $rc
|
||||||
@@ -75,7 +75,7 @@ run_gamescope() (
|
|||||||
status_file=$(mktemp "${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steam-exit.XXXXXX") || exit 73
|
status_file=$(mktemp "${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steam-exit.XXXXXX") || exit 73
|
||||||
trap 'rm -f "$status_file"' EXIT
|
trap 'rm -f "$status_file"' EXIT
|
||||||
# Gamescope can return success when its primary child crashed.
|
# Gamescope can return success when its primary child crashed.
|
||||||
BL_STEAM_EXIT_FILE="$status_file" gamescope "$@"
|
BL_STEAM_EXIT_FILE="$status_file" "${BL_GAMESCOPE_BINARY:-gamescope}" "$@"
|
||||||
compositor_status=$?
|
compositor_status=$?
|
||||||
if read -r child_status < "$status_file" && [[ $child_status =~ ^[0-9]{1,3}$ ]] \
|
if read -r child_status < "$status_file" && [[ $child_status =~ ^[0-9]{1,3}$ ]] \
|
||||||
&& [ "$child_status" -gt 0 ] && [ "$child_status" -le 255 ]; then
|
&& [ "$child_status" -gt 0 ] && [ "$child_status" -le 255 ]; then
|
||||||
@@ -105,6 +105,9 @@ collect_steam_logs() {
|
|||||||
echo "== steam logs copied to $BL_DEBUG_DIR/steam"
|
echo "== steam logs copied to $BL_DEBUG_DIR/steam"
|
||||||
}
|
}
|
||||||
trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
trap 'collect_steam_logs 2>/dev/null || true' TERM INT HUP
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
echo "== Qualcomm driver source: ${DROIDDECK_QUALCOMM_DRIVER:-system-qualcomm}"
|
||||||
|
fi
|
||||||
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
if [ -n "${BL_VK_DRIVER:-}" ]; then
|
||||||
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
bl_icd_lib=$(sed -n 's/.*"library_path"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$BL_VK_DRIVER" 2>/dev/null | head -1)
|
||||||
bl_icd_lib=$(printf '%s' "$bl_icd_lib" | sed 's|\\/|/|g')
|
bl_icd_lib=$(printf '%s' "$bl_icd_lib" | sed 's|\\/|/|g')
|
||||||
@@ -232,7 +235,10 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
|||||||
if [ "$mode" = steam ] && [ "${BL_CURSOR_COMPOSITE:-0}" = 1 ]; then
|
if [ "$mode" = steam ] && [ "${BL_CURSOR_COMPOSITE:-0}" = 1 ]; then
|
||||||
export gamescope_cursor_composite=2
|
export gamescope_cursor_composite=2
|
||||||
fi
|
fi
|
||||||
args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
|
backend=${BL_GAMESCOPE_BACKEND:-wayland}
|
||||||
|
case "$backend" in wayland|sdl) ;; *) echo "Invalid Gamescope backend: $backend"; exit 1 ;; esac
|
||||||
|
[ "$backend" != sdl ] || export SDL_VIDEODRIVER=wayland
|
||||||
|
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height")
|
||||||
[ "$nested" != "$width" ] && args+=(-S stretch) && export BL_STRETCHED=1
|
[ "$nested" != "$width" ] && args+=(-S stretch) && export BL_STRETCHED=1
|
||||||
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
if [ "${BL_FPS:-0}" -gt 0 ]; then
|
||||||
args+=(-r "$BL_FPS")
|
args+=(-r "$BL_FPS")
|
||||||
@@ -267,7 +273,7 @@ if [ -z "${BL_INSIDE:-}" ]; then
|
|||||||
/usr/local/bin/droiddeck-pipewire stop
|
/usr/local/bin/droiddeck-pipewire stop
|
||||||
exit $_bl_status
|
exit $_bl_status
|
||||||
fi
|
fi
|
||||||
exec gamescope "${args[@]}" -- "$0" "$mode" "$@"
|
exec "${BL_GAMESCOPE_BINARY:-gamescope}" "${args[@]}" -- "$0" "$mode" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bl_displays() {
|
bl_displays() {
|
||||||
@@ -283,6 +289,13 @@ bl_xprop_set_all() {
|
|||||||
[ "$ok" = 1 ]
|
[ "$ok" = 1 ]
|
||||||
}
|
}
|
||||||
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
export VK_LAYER_PATH="$DROIDDECK_QUALCOMM_ROOT/wsi:$DROIDDECK_QUALCOMM_ROOT/lib"
|
||||||
|
export VK_INSTANCE_LAYERS=VK_LAYER_window_system_integration:VK_LAYER_HYBRIS_compat
|
||||||
|
export VK_LOADER_DEBUG=error
|
||||||
|
export WSI_X11_FORCE_SHM=1 DISABLE_GAMESCOPE_WSI=1
|
||||||
|
. "$DROIDDECK_QUALCOMM_ROOT/mesa/qualcomm-gl.sh"
|
||||||
|
fi
|
||||||
reap_orphans() {
|
reap_orphans() {
|
||||||
local round p stat pid left
|
local round p stat pid left
|
||||||
for round in 1 2 3 4 5; do
|
for round in 1 2 3 4 5; do
|
||||||
@@ -380,6 +393,7 @@ case $mode in
|
|||||||
steam_x64=0
|
steam_x64=0
|
||||||
[ "${BL_STEAM_CLIENT_ARCH:-}" = x86_64 ] && steam_x64=1
|
[ "${BL_STEAM_CLIENT_ARCH:-}" = x86_64 ] && steam_x64=1
|
||||||
steam_cef_gpu=1
|
steam_cef_gpu=1
|
||||||
|
[ "${BL_STEAM_CEF_SOFTWARE:-0}" != 1 ] || steam_cef_gpu=0
|
||||||
if [ "$steam_x64" = 1 ]; then
|
if [ "$steam_x64" = 1 ]; then
|
||||||
step "checking the Steam client's arm64 parts (first run downloads them, ~1-2 min)"
|
step "checking the Steam client's arm64 parts (first run downloads them, ~1-2 min)"
|
||||||
# droiddeck-steam-install removes the repair request: read it first so Repair Steam covers both clients.
|
# droiddeck-steam-install removes the repair request: read it first so Repair Steam covers both clients.
|
||||||
@@ -766,6 +780,11 @@ BUSCONF
|
|||||||
# A containerized client re-executes itself through pressure-vessel-wrap (bwrap) unless told it is already inside.
|
# A containerized client re-executes itself through pressure-vessel-wrap (bwrap) unless told it is already inside.
|
||||||
export STEAM_STEAMRT_RECURSION_GUARD=1
|
export STEAM_STEAMRT_RECURSION_GUARD=1
|
||||||
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
export LD_LIBRARY_PATH=$steam_root/steamrtarm64:$steam_root/steamrtarm64/panorama${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
|
||||||
|
bl_steam_path=$PATH
|
||||||
|
bl_steam_helper=$XDG_DATA_HOME/Steam/steamrtarm64/steamwebhelper
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
bl_steam_path="/usr/local/libexec/droiddeck-steam:$PATH"
|
||||||
|
fi
|
||||||
export SDL_VIDEO_X11_DGAMOUSE=0
|
export SDL_VIDEO_X11_DGAMOUSE=0
|
||||||
decky_loader=$HOME/homebrew/services/PluginLoader
|
decky_loader=$HOME/homebrew/services/PluginLoader
|
||||||
if [ -f "$HOME/.droiddeck-decky-enabled" ] && [ -x "$decky_loader" ]; then
|
if [ -f "$HOME/.droiddeck-decky-enabled" ] && [ -x "$decky_loader" ]; then
|
||||||
@@ -1173,6 +1192,7 @@ BUSCONF
|
|||||||
desktop_ui_pid=$!
|
desktop_ui_pid=$!
|
||||||
fi
|
fi
|
||||||
steam_started=$SECONDS
|
steam_started=$SECONDS
|
||||||
|
PATH="$bl_steam_path" BL_STEAM_WEBHELPER="$bl_steam_helper" \
|
||||||
"${steam_client[@]}" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
"${steam_client[@]}" "${_bl_ui[@]}" "${_bl_cdp[@]}" "${_bl_lang[@]}" -clientbeta "$steam_channel" \
|
||||||
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
-no-cef-sandbox -cef-ozone-platform=x11 "${_bl_cef[@]}" "$@"
|
||||||
rc=$?
|
rc=$?
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -u
|
||||||
|
if [ "$#" -ge 2 ] && [[ "$1" =~ ^(0[xX])?[0-9a-fA-F]+$ ]] &&
|
||||||
|
[ -n "${BL_STEAM_WEBHELPER:-}" ] && [ "$2" -ef "$BL_STEAM_WEBHELPER" ]; then
|
||||||
|
mask=$1
|
||||||
|
shift
|
||||||
|
/usr/bin/taskset -p "$mask" "$$" >/dev/null 2>&1 || true
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
# SDL's accelerated window-surface setup stalls on this X11 SHM presentation path.
|
||||||
|
export SDL_FRAMEBUFFER_ACCELERATION=0
|
||||||
|
# Valve's helper disables Kopper; Zink needs it to reach the managed X11 WSI layer.
|
||||||
|
unset LIBGL_KOPPER_DISABLE
|
||||||
|
fi
|
||||||
|
exec -- "$@"
|
||||||
|
fi
|
||||||
|
exec /usr/bin/taskset "$@"
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
export XDG_SESSION_TYPE=x11
|
export XDG_SESSION_TYPE=x11
|
||||||
|
if [ "${DROIDDECK_SYSTEM_QUALCOMM:-0}" = 1 ]; then
|
||||||
|
export VK_LAYER_PATH="$DROIDDECK_QUALCOMM_ROOT/wsi:$DROIDDECK_QUALCOMM_ROOT/lib"
|
||||||
|
export VK_INSTANCE_LAYERS=VK_LAYER_window_system_integration:VK_LAYER_HYBRIS_compat
|
||||||
|
export WSI_X11_FORCE_SHM=1 DISABLE_GAMESCOPE_WSI=1
|
||||||
|
fi
|
||||||
starts=/tmp/droiddeck-mangoapp-starts
|
starts=/tmp/droiddeck-mangoapp-starts
|
||||||
now=$(date +%s)
|
now=$(date +%s)
|
||||||
recent=$(awk -v now="$now" '$1 > now - 60' "$starts" 2>/dev/null)
|
recent=$(awk -v now="$now" '$1 > now - 60' "$starts" 2>/dev/null)
|
||||||
|
|||||||
Reference in new issue
Block a user