Compare commits

..
Author SHA1 Message Date
maxjivi05 0157a727bb fix(steam-compat): repair stale mappings and apply explicit requests on tools with a Linux build 2026-12-01 13:44:54 -05:00
maxjivi05 2d13d0770a fix(steam): tools that ship a Linux build are not mapped to Proton
Steam lists some tools with a Windows-only common oslist while their
launch entries include a Linux build. The tool platform scan read only
the common oslist, so those tools were given the Proton default before
install and Steam replaced their Linux files with the Windows depots.

Launch entry platforms now count toward a tool's platforms. A tool with
a Linux build is never given the default, and a Proton mapping that
DroidDeck set on it earlier is cleared. User selections are kept.
2026-12-01 13:22:30 -05:00
7 changed files with 82 additions and 99 deletions

No files matched your search

@@ -108,11 +108,7 @@ public class HudMetrics {
}
private List<String> discoverGpuUsagePaths() {
if (gpuUsagePathsCache == null) gpuUsagePathsCache = gpuUsagePaths();
return gpuUsagePathsCache;
}
public static List<String> gpuUsagePaths() {
if (gpuUsagePathsCache != null) return gpuUsagePathsCache;
LinkedHashSet<String> candidates = new LinkedHashSet<>();
for (String p : GPU_USAGE_STATIC_PATHS) {
@@ -161,7 +157,8 @@ public class HudMetrics {
}
}
return new ArrayList<>(candidates);
gpuUsagePathsCache = new ArrayList<>(candidates);
return gpuUsagePathsCache;
}
private static final String[] GPU_USAGE_STATIC_PATHS = {
@@ -3,18 +3,11 @@ package com.droiddeck.launcher.session
import android.os.SystemClock
import android.util.Log
import com.droiddeck.launcher.core.SessionPart
import com.droiddeck.launcher.hud.HudMetrics
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
import java.io.RandomAccessFile
class GpuStatsComponent(
val dir: File,
private val root: File,
private val metrics: HudMetrics? = null,
private val kgsl: Boolean = File(KGSL).exists(),
private val loadNodes: () -> List<String> = HudMetrics::gpuUsagePaths,
) : SessionPart() {
class GpuStatsComponent(val dir: File, private val root: File) : SessionPart() {
@Volatile private var running = false
private var thread: Thread? = null
private val feeds = ArrayList<Feed>()
@@ -30,7 +23,6 @@ class GpuStatsComponent(
)
fun binds(): List<String> {
if (!kgsl) return emptyList()
val list = mutableListOf(dir.path + ":" + KGSL)
if (File(dir, "perf_now").exists()) list.add(File(dir, "perf_now").path + ":" + MSM_LOAD)
if (File(dir, "cur_freq").exists()) list.add(File(dir, "cur_freq").path + ":" + MSM_CLOCK)
@@ -41,9 +33,10 @@ class GpuStatsComponent(
sources = ""
KgslBusy.status = "not tried"
KgslClock.status = "not tried"
if (!File(KGSL).exists()) return false
val unreadable = MANGOHUD_FILES.any { File(KGSL, it).let { f -> f.exists() && !f.canRead() } }
// Where SELinux hides the kgsl nodes completely (exists() is false too), the layer and cycle-counter feeds stand in.
if (kgsl && !unreadable && !File(GPUBUSY).canRead() && !loadBlocked()) return false
if (!unreadable && !File(GPUBUSY).canRead() && !loadBlocked()) return false
return try {
dir.mkdirs()
dir.listFiles()?.forEach { java.nio.file.Files.deleteIfExists(it.toPath()) }
@@ -51,20 +44,19 @@ class GpuStatsComponent(
PASSTHROUGH_FILES.forEach { name ->
runCatching { File(dir, name).writeText(File(KGSL, name).readText()) }
}
((if (kgsl) loadFeed() else nodeLoadFeed()) ?: blockedLoadFeed())?.let { load ->
(loadFeed() ?: blockedLoadFeed())?.let { load ->
feeds.add(load)
feeds.add(Feed(File(dir, "perf_now"), load.source, load.read, "%-6s\n", percent = true))
}
(pick("clock_mhz", clockSources(), "%5d\n") { mhz(it) } ?: (if (kgsl) cycleClockFeed() else null))?.let { clock ->
(pick("clock_mhz", clockSources(), "%5d\n") { mhz(it) } ?: cycleClockFeed())?.let { clock ->
feeds.add(clock)
feeds.add(Feed(File(dir, "cur_freq"), clock.source, { clock.read()?.times(1_000_000) }, "%-10d\n"))
}
if (kgsl) pick("temp", tempSources(), "%6d\n") { milliCelsius(it) }?.let { feeds.add(it) }
if (!kgsl && feeds.isEmpty()) return false
pick("temp", tempSources(), "%6d\n") { milliCelsius(it) }?.let { feeds.add(it) }
refresh()
createMissing(feeds.map { it.file })
describeSources()
Log.i(TAG, "hud: GPU stats from the session's own: $sources")
Log.i(TAG, "hud: kgsl stats from the session's own: $sources")
true
} catch (e: Exception) {
Log.w(TAG, "hud: could not stand in for kgsl stats: $e")
@@ -154,10 +146,10 @@ class GpuStatsComponent(
// Vulkan layer and the compositor time their own GPU work until the memstore timestamps are seen moving, and
// for the whole session where they never move.
private fun blockedLoadFeed(): Feed? {
if (!noLoadNode(kgsl, loadNodes)) return null
if (!loadBlocked()) return null
val load = LayerLoad(guestLoadDir(root), extra = ::compositorBusyNs, onWanted = ::compositorTiming)
.also { it.clear(); layerLoad = it }
val sampled = if (!kgsl) null else KgslBusy.open()?.let { reader ->
val sampled = KgslBusy.open()?.let { reader ->
memstore = reader
MemstoreLoad(reader::counts).also { memstoreLoad = it }
}
@@ -297,12 +289,6 @@ class GpuStatsComponent(
}
}
private fun nodeLoadFeed(): Feed? {
val metrics = metrics ?: return null
val node = loadNodes().firstOrNull() ?: return null
return Feed(File(dir, "gpu_busy_percentage"), node, { metrics.gpuUsagePercent?.toLong() }, "%3d %%\n")
}
private fun loadFeed(): Feed? {
latchedBusyFeed()?.let { return it }
return pick("gpu_busy_percentage", LOAD_SOURCES, "%3d %%\n") { it.coerceIn(0, 100) }
@@ -376,14 +362,9 @@ class GpuStatsComponent(
/** True when this app can see kgsl but none of its GPU load nodes (SELinux-blocked, e.g. the Retroid Pocket Duo). */
fun loadBlocked(): Boolean = File(KGSL).exists() && !File(GPUBUSY).canRead() && LOAD_SOURCES.none { File(it).canRead() }
private fun noLoadNode(): Boolean = noLoadNode(File(KGSL).exists(), HudMetrics::gpuUsagePaths)
internal fun noLoadNode(kgsl: Boolean, loadNodes: () -> List<String>): Boolean =
if (kgsl) loadBlocked() else loadNodes().isEmpty()
/** Turns on the in-game layer (tools/gpuload) where the load is blocked; empty elsewhere. */
fun guestEnv(root: File): List<String> {
if (!noLoadNode()) return emptyList()
if (!loadBlocked()) return emptyList()
guestLoadDir(root).mkdirs()
return listOf("DROIDDECK_GPU_LOAD=1", "DROIDDECK_GPU_LOAD_DIR=$GUEST_LOAD_DIR")
}
@@ -4,7 +4,6 @@ import com.droiddeck.launcher.core.AddonPack
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
import com.droiddeck.launcher.gpu.SystemVulkanDriver
import com.droiddeck.launcher.hud.HudMetrics
import android.app.Notification
import android.app.NotificationChannel
@@ -1294,7 +1293,7 @@ class SessionService : Service() {
gpuMem.attach(this)
components.add(gpuMem)
}
val gpuStats = GpuStatsComponent(File(filesDir, "session/sys/kgsl-3d0"), LinuxRuntime.rootDir(this), HudMetrics(this))
val gpuStats = GpuStatsComponent(File(filesDir, "session/sys/kgsl-3d0"), LinuxRuntime.rootDir(this))
if (gpuStats.prepare()) {
gpuStats.attach(this)
components.add(gpuStats)
@@ -13,7 +13,7 @@ class GpuStatsBindsTest {
@Test fun feedsWithNoValueYetAreStillBound() {
val dir = tmp.newFolder("kgsl-3d0")
GpuStatsComponent.createMissing(listOf(File(dir, "perf_now"), File(dir, "cur_freq")))
val binds = GpuStatsComponent(dir, tmp.root, kgsl = true).binds()
val binds = GpuStatsComponent(dir, tmp.root).binds()
assertTrue(binds.contains(File(dir, "perf_now").path + ":" + GpuStatsComponent.MSM_LOAD))
assertTrue(binds.contains(File(dir, "cur_freq").path + ":" + GpuStatsComponent.MSM_CLOCK))
}
@@ -1,57 +0,0 @@
package com.droiddeck.launcher.session
import com.droiddeck.launcher.hud.HudMetrics
import java.io.File
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
class GpuStatsComponentWithoutKgslTest {
@get:Rule val tmp = TemporaryFolder()
private val parts = ArrayList<GpuStatsComponent>()
private fun component(nodes: List<String>, metrics: HudMetrics? = null) =
GpuStatsComponent(tmp.newFolder("kgsl-3d0"), tmp.root, metrics, kgsl = false, loadNodes = { nodes }).also { parts += it }
@After fun reset() {
parts.forEach { it.stop() }
KgslBusy.status = "not tried"
KgslClock.status = "not tried"
}
@Test fun noReadableLoadNodeWithoutKgslTurnsTheTimingFeedOn() {
assertTrue(GpuStatsComponent.noLoadNode(false) { emptyList() })
assertFalse(GpuStatsComponent.noLoadNode(false) { listOf(MALI_NODE) })
}
@Test fun kgslDevicesIgnoreOtherGpusNodes() {
val decided = GpuStatsComponent.noLoadNode(true) { throw AssertionError("kgsl devices read other GPUs' nodes") }
assertEquals(GpuStatsComponent.loadBlocked(), decided)
}
@Test fun withoutAnyLoadNodeTheHudLoadComesFromVulkanTiming() {
val gpu = component(emptyList())
assertTrue(gpu.prepare())
assertTrue(GpuStatsComponent.sources, GpuStatsComponent.sources.startsWith("gpu_busy_percentage Vulkan timing"))
assertTrue(File(gpu.dir, "perf_now").isFile)
assertEquals(emptyList<String>(), gpu.binds())
assertEquals("", GpuStatsComponent.readerStatus())
}
@Test fun aReadableLoadNodeFeedsTheHudInsteadOfTheLayer() {
val gpu = component(listOf(MALI_NODE), HudMetrics(null))
assertTrue(gpu.prepare())
assertTrue(GpuStatsComponent.sources, GpuStatsComponent.sources.startsWith("gpu_busy_percentage $MALI_NODE"))
assertTrue(File(gpu.dir, "perf_now").isFile)
assertFalse(File(GpuStatsComponent.guestLoadDir(tmp.root), "on").exists())
assertEquals("", GpuStatsComponent.readerStatus())
}
private companion object {
const val MALI_NODE = "/sys/class/misc/mali0/device/utilisation"
}
}
@@ -984,10 +984,15 @@ def valve_picks(steam_root):
return sorted(picks, key=int)
def launch_platforms(entry):
return {part.strip() for option in entry.get("launch_options", ())
for part in option["oslist"].split(",") if part.strip()}
def tool_platforms(steam_root):
entries = appinfo_entries(os.path.join(steam_root, "appcache", "appinfo.vdf"))
return {app: entry["oslist"] for app, entry in entries.items()
if entry["type"] == "tool" and entry["oslist"] & {"linux", "windows"}}
platforms = {app: entry["oslist"] | launch_platforms(entry) for app, entry in entries.items() if entry["type"] == "tool"}
return {app: found for app, found in platforms.items() if found & {"linux", "windows"}}
def native_targets(steam_root, apps):
@@ -1227,8 +1232,16 @@ def plan_mapping(current, installed, runnable, default, auto, native=None, picks
changes["0"] = default
for app in sorted((set(current) | installed | picks | set(auto) | set(overrides) | native_choices | set(tools)) - {"0"}, key=app_order):
name = current.get(app, "")
if app in tools and "linux" in tools[app] and "windows" not in tools[app]:
if name and (name.lower() in runnable or "proton" in name.lower()):
if app in tools and "linux" in tools[app]:
if "windows" not in tools[app]:
if name and (name.lower() in runnable or "proton" in name.lower()):
changes[app] = None
continue
if app in overrides:
target = overrides[app]
if target is not DEFERRED_GAME_TOOL and (target or None) != (name or None):
changes[app] = target or None
elif name and (name == auto.get(app) or unrunnable(name, runnable) or name.lower() in removed):
changes[app] = None
continue
if app in overrides:
+50
View File
@@ -73,6 +73,56 @@ class ToolPlatformsTest(unittest.TestCase):
self.assertEqual(auto["900001"], TOOL)
self.assertEqual(auto["976730"], TOOL)
def add_launch_only_linux_tool(self):
self.entries[900007] = {"common": {"type": "Tool", "oslist": "windows"}, "config": {"launch": {
"0": {"executable": "bin\\win64\\start.exe", "config": {"oslist": "windows"}},
"1": {"executable": "bin\\start.sh", "config": {"oslist": "linux", "osarch": "64"}},
}}}
self.write_appinfo()
def test_linux_launch_entry_counts_as_a_linux_platform(self):
self.add_launch_only_linux_tool()
self.assertEqual(self.platforms()["900007"], {"windows", "linux"})
self.assertEqual(self.platforms()["900001"], {"windows"})
def test_tool_with_a_linux_build_is_not_given_proton_before_install(self):
self.add_launch_only_linux_tool()
changes, auto = self.plan({"0": TOOL})
self.assertNotIn("900007", changes)
self.assertNotIn("900007", auto)
self.assertEqual(changes["900001"], TOOL)
def test_own_proton_mapping_on_a_tool_with_a_linux_build_is_cleared(self):
self.add_launch_only_linux_tool()
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, {"900007": TOOL})
self.assertIsNone(changes["900007"])
self.assertNotIn("900007", auto)
def test_user_selection_on_a_tool_with_a_linux_build_survives(self):
self.add_launch_only_linux_tool()
for name in (TOOL, "custom-windows"):
with self.subTest(name=name):
changes, auto = self.plan({"0": TOOL, "900007": name}, {"976730": TOOL})
self.assertNotIn("900007", changes)
def test_stale_tool_on_a_tool_with_a_linux_build_is_cleared(self):
self.add_launch_only_linux_tool()
for name, removed in (("GE-Proton11-7", ("GE-Proton11-7",)), ("proton_9", ())):
with self.subTest(name=name):
changes, auto = self.plan({"0": TOOL, "900007": name}, removed=removed)
self.assertIsNone(changes["900007"])
self.assertNotIn("900007", auto)
def test_explicit_request_on_a_tool_with_a_linux_build_is_applied(self):
self.add_launch_only_linux_tool()
changes, auto = self.plan({"0": TOOL}, overrides={"900007": TOOL})
self.assertEqual(changes["900007"], TOOL)
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, overrides={"900007": None})
self.assertIsNone(changes["900007"])
changes, auto = self.plan({"0": TOOL, "900007": TOOL}, overrides={"900007": TOOL})
self.assertNotIn("900007", changes)
self.assertNotIn("900007", auto)
def test_removed_ge_proton_is_cleared_with_or_without_saved_ownership(self):
for saved in ({}, {"1826330": "GE-Proton11-7"}):
with self.subTest(saved=saved):