mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(components): DXVK Auto on Adreno 6xx keeps DroidDeck-Proton on DXVK-gplasync 2.7.1 (#2226)
* fix(components): DXVK Auto on Adreno 6xx keeps DroidDeck-Proton on DXVK-gplasync 2.7.1 * fix(components): DXVK Auto says so when the pinned DXVK could not be installed * fix(components): a DXVK the player picked is shown as their choice, not a failed pinned install
This commit is contained in:
1 parent
e4d4096342
commit
d74575ed7f
40 files changed
+231
-11
No files matched your search
@@ -39,7 +39,7 @@ internal class ComponentsMenu(private val activity: android.app.Activity, privat
|
||||
runCatching { ComponentUpdater.settle(activity) }
|
||||
val modes = ComponentsManager.COMPONENTS.associateWith { SessionPrefs.componentMode(activity, it) }
|
||||
val auto = ComponentsManager.COMPONENTS.associateWith { runCatching { ComponentUpdater.status(activity, it) }.getOrDefault(emptyList()) }
|
||||
val held = if (runCatching { ComponentsManager.hardwareDxvk(activity) }.getOrDefault(false)) setOf("dxvk") else emptySet()
|
||||
val held = if (runCatching { ComponentsManager.autoDxvkHeld(activity) }.getOrDefault(false)) setOf("dxvk") else emptySet()
|
||||
ui.post {
|
||||
compModes = modes
|
||||
compAuto = auto
|
||||
|
||||
@@ -5,15 +5,17 @@ import android.util.AtomicFile
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.AutoComponents
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import java.io.File
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
object ComponentUpdater {
|
||||
private const val TAG = "ComponentUpdater"
|
||||
private const val CHECK_EVERY_MS = 3_600_000L
|
||||
private const val BOOTED_KEPT = 200
|
||||
private const val HANDED_BACK = "handedBack"
|
||||
private const val PINNED_NOTE = "pinnedNote"
|
||||
internal const val HAND_BACK_FILES = "handBackFiles"
|
||||
private const val IMPORTED = "imported"
|
||||
private val lock = Any()
|
||||
@@ -103,6 +105,13 @@ object ComponentUpdater {
|
||||
val protons = found ?: emptyList()
|
||||
if (found != null) handBack(context, state, found)
|
||||
judge(context, state, protons, notes)
|
||||
ComponentsManager.pinnedAutoDxvk(context)?.let { pinned ->
|
||||
runCatching { ComponentsManager.ensureForcedPackages(context) }
|
||||
.onSuccess { if (it != null) Log.i(TAG, it) }.onFailure { Log.w(TAG, "pinned DXVK", it) }
|
||||
val followers = protons.filter { ComponentUpdates.follows(it) && ComponentsManager.supports(it, "dxvk") }.map { it.id to it.version }
|
||||
if (pinnedHeld(pinned, followers, ComponentsManager.activeChoices(context), pinnedBase())) state.remove(PINNED_NOTE)
|
||||
else state.put(PINNED_NOTE, context.getString(R.string.comp_auto_install_failed, pinned.removeSuffix(".wcp")))
|
||||
}
|
||||
val due = force || System.currentTimeMillis() - state.optLong("checkedAt") >= CHECK_EVERY_MS
|
||||
val wanted = ComponentsManager.COMPONENTS.filter { managed(context, it) }
|
||||
if (wanted.isEmpty() || protons.isEmpty()) {
|
||||
@@ -385,7 +394,32 @@ object ComponentUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
internal fun pinnedHeld(pinned: String, followers: List<Pair<String, String>>, choices: Map<String, Map<String, ComponentsManager.Choice>>, base: String?): Boolean =
|
||||
followers.all { (id, version) ->
|
||||
val choice = choices[id]?.get("dxvk")
|
||||
ownChoice(choice, version, pinned, base) || choice?.let { it.file == ComponentsManager.safeName(pinned) && it.protonVersion == version } == true
|
||||
}
|
||||
|
||||
internal fun ownChoice(choice: ComponentsManager.Choice?, version: String, pinned: String, base: String?): Boolean =
|
||||
choice != null && !choice.auto && choice.protonVersion == version && choice.file != ComponentsManager.safeName(pinned) &&
|
||||
(base == null || choice.file != ComponentsManager.safeName(base))
|
||||
|
||||
private fun pinnedBase(): String? = ComponentsManager.forcedDxvk(GpuInfo.detect())?.file
|
||||
|
||||
fun status(context: Context, comp: String): List<Status> {
|
||||
val pinned = if (comp == "dxvk") ComponentsManager.pinnedAutoDxvk(context) else null
|
||||
if (pinned != null) {
|
||||
val on = runCatching { ComponentsManager.protons(context) }.getOrDefault(emptyList())
|
||||
.filter { ComponentUpdates.follows(it) && ComponentsManager.supports(it, comp) }
|
||||
if (on.isEmpty()) return emptyList()
|
||||
val choices = ComponentsManager.activeChoices(context)
|
||||
val base = pinnedBase()
|
||||
val (own, auto) = on.partition { ownChoice(choices[it.id]?.get(comp), it.version, pinned, base) }
|
||||
val held = pinnedHeld(pinned, auto.map { it.id to it.version }, choices, base)
|
||||
val pinnedLine = if (auto.isEmpty()) emptyList()
|
||||
else listOf(Status(comp, pinned, pinned, auto.map { it.name }, if (held) "" else load(context).optString(PINNED_NOTE)))
|
||||
return pinnedLine + own.groupBy { choices.getValue(it.id).getValue(comp).file }.map { (file, ps) -> Status(comp, file, file, ps.map { it.name }, "") }
|
||||
}
|
||||
val state = load(context)
|
||||
val lines = state.optJSONObject("lines") ?: JSONObject()
|
||||
val protons = runCatching { ComponentsManager.protons(context) }.getOrDefault(emptyList())
|
||||
|
||||
@@ -1065,14 +1065,24 @@ object ComponentsManager {
|
||||
val file: String,
|
||||
val release: String,
|
||||
val models: Set<Int> = emptySet(),
|
||||
val autoFile: String? = null,
|
||||
val autoRelease: String? = null,
|
||||
) {
|
||||
fun matches(gpu: GpuInfo) = gpu.family in families && (models.isEmpty() || gpu.model in models)
|
||||
|
||||
fun autoRule(): ForcedPackage? =
|
||||
if (autoFile != null && autoRelease != null) copy(file = autoFile, release = autoRelease, autoFile = null, autoRelease = null) else null
|
||||
}
|
||||
|
||||
internal val FORCED_PACKAGES = listOf(
|
||||
ForcedPackage(setOf(GpuInfo.Family.A6XX), "dxvk", "dxvk-2.7.1-linux.wcp", "Dxvk-Linux"),
|
||||
ForcedPackage(setOf(GpuInfo.Family.A6XX), "dxvk", "dxvk-2.7.1-linux.wcp", "Dxvk-Linux",
|
||||
autoFile = "dxvk-gplasync-2.7.1-1-linux.wcp", autoRelease = "Dxvk-gplasync-Linux"),
|
||||
)
|
||||
|
||||
internal fun autoDxvk(gpu: GpuInfo): ForcedPackage? = forcedDxvk(gpu)?.autoRule()
|
||||
|
||||
internal fun forcedDxvk(gpu: GpuInfo): ForcedPackage? = FORCED_PACKAGES.firstOrNull { it.comp == "dxvk" && it.matches(gpu) }
|
||||
|
||||
private val ARM64EC_PROBE = mapOf("dxvk" to "d3d11.dll", "vkd3d" to "d3d12.dll")
|
||||
|
||||
fun arm64ec(context: Context, p: Proton, comp: String): Boolean? = stockProbe(context, p, comp)?.let(ComponentUpdates::arm64ec)
|
||||
@@ -1124,6 +1134,12 @@ object ComponentsManager {
|
||||
(com.droiddeck.launcher.core.DeviceSupport.vkBridge(context) && !SessionPrefs.bridgeProtonDxvk(context) &&
|
||||
bridgeDxvk(AppVulkan.detect(context)) != null)
|
||||
|
||||
fun autoDxvkHeld(context: Context): Boolean =
|
||||
hardwareDxvk(context) && (runtimeManaged(context, "dxvk") || autoDxvk(GpuInfo.detect()) == null)
|
||||
|
||||
fun pinnedAutoDxvk(context: Context): String? =
|
||||
if (SessionPrefs.componentMode(context, "dxvk") == ComponentUpdates.AUTO) autoDxvk(GpuInfo.detect())?.file else null
|
||||
|
||||
data class Choice(val file: String, val auto: Boolean, val protonVersion: String)
|
||||
|
||||
fun activeChoices(context: Context): Map<String, Map<String, Choice>> = synchronized(lock) {
|
||||
@@ -1168,6 +1184,14 @@ object ComponentsManager {
|
||||
internal const val DXVK_FOR_VULKAN_1_1 = "dxvk-1.10.3-linux.wcp"
|
||||
internal const val DXVK_FOR_VULKAN_1_3_NO_INT64 = "dxvk-2.6.2-linux.wcp"
|
||||
|
||||
private data class ForcedRule(
|
||||
val pkg: ForcedPackage,
|
||||
val auto: Boolean,
|
||||
val covers: (Proton) -> Boolean,
|
||||
val replaces: String? = null,
|
||||
val label: String? = null,
|
||||
)
|
||||
|
||||
internal fun autoDxvkUndoWanted(bridgeSession: Boolean, keepProtonDxvk: Boolean, vulkan: AppVulkan?, bridgeRule: ForcedPackage?): Boolean =
|
||||
!bridgeSession || keepProtonDxvk || (vulkan != null && bridgeRule == null)
|
||||
|
||||
@@ -1200,6 +1224,7 @@ object ComponentsManager {
|
||||
undoAuto = { id, comp -> undoAutoChoice(context, id, comp) },
|
||||
keepProtonDxvk = SessionPrefs.bridgeProtonDxvk(context),
|
||||
autoPossible = !com.droiddeck.launcher.core.DeviceSupport.adreno(),
|
||||
dxvkAuto = pinnedAutoDxvk(context) != null,
|
||||
) }
|
||||
|
||||
fun settleAutoDxvk(context: Context) {
|
||||
@@ -1239,10 +1264,16 @@ object ComponentsManager {
|
||||
undoAuto: (protonId: String, comp: String) -> String = { _, _ -> "" },
|
||||
keepProtonDxvk: Boolean = false,
|
||||
autoPossible: Boolean = true,
|
||||
dxvkAuto: Boolean = false,
|
||||
follows: (Proton) -> Boolean = ComponentUpdates::follows,
|
||||
): String? {
|
||||
val chooseDxvk = bridgeSession && !keepProtonDxvk
|
||||
val bridgeRule = if (chooseDxvk) bridgeDxvk(vulkan) else null
|
||||
val rules = FORCED_PACKAGES.filter { it.matches(gpu) }.map { it to false } + listOfNotNull(bridgeRule?.let { it to true })
|
||||
val family = FORCED_PACKAGES.filter { it.matches(gpu) }
|
||||
val pinned = if (dxvkAuto) family.mapNotNull { base -> base.autoRule()?.let { base to it } } else emptyList()
|
||||
val rules = family.map { base -> ForcedRule(base, false, if (pinned.any { it.first == base }) { p -> !follows(p) } else { _ -> true }) } +
|
||||
pinned.map { (base, rule) -> ForcedRule(rule, true, follows, replaces = base.file) } +
|
||||
listOfNotNull(bridgeRule?.let { ForcedRule(it, true, { true }, label = "${vulkan?.label}: DXVK ${it.file}") })
|
||||
if (rules.isEmpty() && !autoPossible) return null
|
||||
val installed = protons(context)
|
||||
val lines = mutableListOf<String>()
|
||||
@@ -1256,12 +1287,13 @@ object ComponentsManager {
|
||||
if (autoChoiceStale(entry, null)) lines.add(each(p) { undoAuto(p.id, "dxvk") })
|
||||
}
|
||||
}
|
||||
for ((rule, auto) in rules) {
|
||||
for ((rule, auto, covers, replaces, label) in rules) {
|
||||
val state = loadState(context)
|
||||
val targets = installed.filter { p ->
|
||||
val active = state.optJSONObject("active")?.optJSONObject(p.id)?.optJSONObject(rule.comp)
|
||||
forcedPackageWanted(active?.optString("file"), active?.optString("protonVersion") == p.version) ||
|
||||
(auto && autoChoiceStale(active, rule.file))
|
||||
val current = active?.optString("protonVersion") == p.version
|
||||
covers(p) && (forcedPackageWanted(active?.optString("file"), current) ||
|
||||
(auto && autoChoiceStale(active, rule.file)) || (replaces != null && current && active?.optString("file") == replaces))
|
||||
}
|
||||
if (targets.isEmpty()) continue
|
||||
val missing = missingPackage(context, rule, lookup, fetch)
|
||||
@@ -1269,7 +1301,7 @@ object ComponentsManager {
|
||||
lines.add(missing)
|
||||
continue
|
||||
}
|
||||
if (auto) lines.add("${vulkan?.label}: DXVK ${rule.file}")
|
||||
if (label != null) lines.add(label)
|
||||
lines.add(targets.joinToString("; ") { p -> if (auto) each(p) { applyAuto(p.id, rule.file) } else apply(p.id, rule.file) })
|
||||
}
|
||||
return lines.filter { it.isNotEmpty() }.joinToString("; ").ifEmpty { null }
|
||||
|
||||
@@ -1112,7 +1112,7 @@ private fun AutoComponentBody(label: String, lines: List<ComponentUpdater.Status
|
||||
if (lines.isEmpty()) EmptyLine(stringResource(R.string.comp_auto_none))
|
||||
for (line in lines) {
|
||||
val previous = line.previous.removeSuffix(".wcp").ifEmpty { stringResource(R.string.comp_tag_original) }
|
||||
val fallback = if (line.current.isEmpty()) null else stringResource(R.string.comp_auto_fallback, previous)
|
||||
val fallback = if (line.current.isEmpty() || line.current == line.previous) null else stringResource(R.string.comp_auto_fallback, previous)
|
||||
PanelRow(
|
||||
line.current.removeSuffix(".wcp").ifEmpty { stringResource(if (checking) R.string.comp_auto_checking else R.string.comp_tag_original) },
|
||||
listOfNotNull(line.protons.joinToString(", ").ifEmpty { null }, fallback).joinToString(" · "),
|
||||
|
||||
Reference in new issue
Block a user