Compare commits

..
Author SHA1 Message Date
maxjivi05 d80cbbd364 fix(display): vote for the requested refresh on compositor surfaces 2026-11-29 19:47:02 -05:00
MaxsTechReview 861121144c fix(xbox): try the next listed executable when one is missing (#3446)
A package can list several PC executables while shipping only some of them. Try each listed executable in order and fail only when none of them exist.
2026-11-29 19:33:55 -05:00
d7fcea74b4 fix(mali): Auto respects Venus turned off and picks the bridge on Mali-G2-Ultra (#3198)
* fix(mali): Auto respects Venus turned off and picks the bridge on Mali-G2-Ultra

With GPU drivers on Auto, Mali (Venus) was turned back on after the user turned it off. Auto now respects that choice, and picks the bridge on Mali-G2-Ultra, where Steam's web helper dies on its first window through Venus (#2879). When Auto itself turns Venus off it clears the stored key, so its own decision does not read as the user's later.

* fix(mali): clear Auto-owned Venus preference when fallback ends

---------

Co-authored-by: Unixcision <14082251+Unixcision@users.noreply.github.com>
Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
2026-11-29 17:17:51 -05:00
12 changed files with 164 additions and 62 deletions

No files matched your search

@@ -430,21 +430,28 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
*/
private fun useMaliFallback(missing: String?): String {
val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity)
val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity)
val venusByUser = venusExplicit()
val venus = MaliAutoRoute.venusStandsIn(
com.droiddeck.launcher.session.VenusComponent.available(activity), oldVulkan == null,
SessionPrefs.venus(activity), venusByUser, gpu.name,
)
if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in")
val ownership = MaliAutoRoute.fallbackOwnership(
venus,
SessionPrefs.vkBridge(activity), bridgeExplicit(),
SessionPrefs.venus(activity), venusExplicit(),
SessionPrefs.venus(activity), venusByUser,
)
if (venus && !SessionPrefs.venus(activity)) {
SessionPrefs.setVenus(activity, true)
if (SessionPrefs.vkBridge(activity) && !bridgeExplicit())
SessionPrefs.setVkBridge(activity, false)
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (!venus && !SessionPrefs.vkBridge(activity)) {
SessionPrefs.setVkBridge(activity, true)
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (!venus) {
val venusOff = SessionPrefs.venus(activity) && !venusByUser
val bridgeOn = !SessionPrefs.vkBridge(activity)
if (venusOff) SessionPrefs.clearVenus(activity)
if (bridgeOn) SessionPrefs.setVkBridge(activity, true)
if (venusOff || bridgeOn || ownership != MaliAutoRoute.NONE) SessionPrefs.setMaliFallbackByAuto(activity, ownership)
} else if (ownership != MaliAutoRoute.NONE) {
SessionPrefs.setMaliFallbackByAuto(activity, ownership)
}
@@ -467,7 +474,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
/** A pair is installed for this Mali: the route Auto switched on in its place goes off again. */
private fun endMaliFallback() {
when (SessionPrefs.maliFallbackByAuto(activity)) {
"venus" -> SessionPrefs.setVenus(activity, false)
"venus" -> SessionPrefs.clearVenus(activity)
"bridge" -> SessionPrefs.setVkBridge(activity, false)
else -> return
}
@@ -26,6 +26,12 @@ internal object MaliAutoRoute {
fun userChoice(keyStored: Boolean, owner: String, route: String): Boolean = keyStored && owner != route
fun venusStandsIn(available: Boolean, hostVulkanOk: Boolean, venusOn: Boolean, venusExplicit: Boolean, gpuName: String): Boolean =
available && hostVulkanOk && if (venusExplicit) venusOn else !venusStallsOn(gpuName)
// Steam's web helper dies on its first window through Venus on these (#2879), so the bridge stands in.
fun venusStallsOn(gpuName: String): Boolean = gpuName.contains("G2-Ultra", ignoreCase = true)
fun shouldEnd(ownsRoute: String, mali: Boolean, installedPair: Boolean): Boolean =
mali && installedPair && ownsRoute != NONE
}
@@ -2987,10 +2987,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
Log.i(TAG, "hdr: " + (if (on) "on" else "off") + " for this $mode session")
}
com.droiddeck.launcher.gpu.DriverSetupLog.write(this, "compositor.start driver=$driverId")
val outputRefresh = refreshHz(holder)
CompositorHost.startOrAttach(
this, holder.surface, runtimeDir.path,
driverId?.let { turnip.driverPath(it) }, driverId?.let { turnip.libraryName(it) },
applicationInfo.nativeLibraryDir, size.first, size.second, refreshHz(holder), outputFpsLimit(),
applicationInfo.nativeLibraryDir, size.first, size.second, outputRefresh, outputFpsLimit(),
outputFrameRateVote(outputRefresh),
)
onOutputAttached(holder)
if (SessionState.running && size != previous) {
@@ -3200,6 +3202,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
}
private fun outputFrameRateVote(hz: Float): Float =
if (glassesScreen == null && !bottomOutputActive && !panelHeld) PerfMode.frameRateVote(this, hz) else hz
private fun applyOutputPacing() {
val frameGen = appliedFrameGenMode
pacedFrameGenMode = frameGen
@@ -3218,7 +3223,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
)
val hz = refreshHz()
val changed = kotlin.math.abs(SessionState.refreshHz - hz) > 0.1f
CompositorHost.updatePacing(hz, outputFpsLimit())
CompositorHost.updatePacing(hz, outputFpsLimit(), outputFrameRateVote(hz))
pushCardboard(activeCardboard)
if (changed && ::surfaceView.isInitialized) applyFrameGen()
}
@@ -82,6 +82,16 @@ object PerfMode {
internal fun panelHeld(requestedHz: Float, activeHz: Float): Boolean =
requestedHz > 1f && activeHz > 1f && Math.abs(requestedHz - activeHz) > 0.5f
fun frameRateVote(a: Activity, activeHz: Float): Float = try {
val display = if (Build.VERSION.SDK_INT >= 30) a.display else @Suppress("DEPRECATION") a.windowManager.defaultDisplay
val wanted = a.window.attributes.preferredDisplayModeId
val requested = display?.supportedModes?.firstOrNull { wanted != 0 && it.modeId == wanted }
frameRateVote(requested?.refreshRate ?: 0f, activeHz)
} catch (t: Throwable) { Log.w(TAG, "frame rate vote", t); activeHz }
internal fun frameRateVote(requestedHz: Float, activeHz: Float): Float =
requestedHz.takeIf { it > 1f } ?: activeHz
fun pacedRate(ownLimit: Int, limiterRate: Int, limiterRefresh: Int, steadyRate: Int): Int = when {
ownLimit > 0 -> ownLimit
limiterRate <= 0 -> steadyRate
@@ -1229,6 +1229,11 @@ object SessionPrefs {
prefs(context).edit().putBoolean("venus", on).apply()
}
/** Venus off with no choice stored, so that Auto turning it off does not read as the user's own choice. */
fun clearVenus(context: Context) {
prefs(context).edit().remove("venus").apply()
}
fun setVkBridge(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("vkBridge", on).putBoolean("bridgeFellBack", false).apply()
}
@@ -94,17 +94,16 @@ internal object XboxManifest {
}
fun executable(folder: File): String {
for (path in read(folder).executables) {
val listed = read(folder).executables
for (path in listed) {
require(!path.startsWith('/') && !path.contains(':') && path.split('/').none { it == ".." || it.isEmpty() })
var file = folder
for (part in path.split('/')) {
val matches = file.listFiles().orEmpty().filter { it.name.equals(part, true) }
require(matches.size == 1) { "Missing or ambiguous Xbox launch path." }
file = matches.single()
}
val file = path.split('/').fold<String, File?>(folder) { dir, part ->
dir?.listFiles().orEmpty().filter { it.name.equals(part, true) }.singleOrNull()
} ?: continue
require(file.canonicalPath.startsWith(folder.canonicalPath + File.separator))
if (file.isFile) return forwarded(folder, file) ?: file.relativeTo(folder).invariantSeparatorsPath
}
require(listed.isEmpty()) { "Missing or ambiguous Xbox launch path." }
error("The Xbox package has no supported PC launch executable.")
}
@@ -4,6 +4,7 @@ import android.os.Build
import android.os.Handler
import android.os.HandlerThread
import android.os.Process
import android.util.Log
import android.view.Choreographer
import android.view.Surface
import com.droiddeck.launcher.session.SessionPrefs
@@ -67,13 +68,14 @@ object CompositorHost {
outputHeight: Int,
refreshHz: Float,
fpsLimit: Int,
frameRateVote: Float = refreshHz,
): Boolean {
WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.dd-clock").path)
ownVsyncThread = SessionPrefs.vsyncThread(context)
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
blackFrameInsertion = SessionPrefs.blackFrameInsertion(context)
WaylandCompositor.nativeSetBlackFrameInsertion(blackFrameInsertion)
pace(refreshHz, fpsLimit)
pace(refreshHz, fpsLimit, frameRateVote)
if (!SessionState.running) WaylandCompositor.nativeSetOutputSize(outputWidth, outputHeight)
if (started) {
attached = surface
@@ -95,16 +97,21 @@ object CompositorHost {
private var blackFrameInsertion = false
private var pictureHolds = 0
private fun pace(refreshHz: Float, fpsLimit: Int) {
private fun pace(refreshHz: Float, fpsLimit: Int, frameRateVote: Float = refreshHz) {
WaylandCompositor.nativeSetFpsLimit(fpsLimit)
WaylandCompositor.nativeSetLayerFrameRate(if (fpsLimit > 0 && !blackFrameInsertion) fpsLimit.toFloat() else refreshHz)
surfaceFrameRate = layerFrameRate(frameRateVote, fpsLimit, blackFrameInsertion)
applySurfaceFrameRate()
WaylandCompositor.nativeSetLayerFrameRate(surfaceFrameRate)
WaylandCompositor.nativeSetOutputRefreshRate(refreshHz)
SessionState.refreshHz = refreshHz
}
internal fun layerFrameRate(refreshHz: Float, fpsLimit: Int, blackFrameInsertion: Boolean): Float =
if (fpsLimit > 0 && !blackFrameInsertion) fpsLimit.toFloat() else refreshHz
@Synchronized
fun updatePacing(refreshHz: Float, fpsLimit: Int) {
if (started) pace(refreshHz, fpsLimit)
fun updatePacing(refreshHz: Float, fpsLimit: Int, frameRateVote: Float = refreshHz) {
if (started) pace(refreshHz, fpsLimit, frameRateVote)
}
@Synchronized
@@ -146,7 +153,31 @@ object CompositorHost {
android.os.Handler(android.os.Looper.getMainLooper()).postDelayed(rearm, 600)
}
private var surfaceFrameRate = 0f
private var appliedSurfaceFrameRate = Float.NaN
private var attached: Surface? = null
set(value) {
field = value
appliedSurfaceFrameRate = Float.NaN
applySurfaceFrameRate()
}
private fun applySurfaceFrameRate() {
val surface = attached ?: return
if (Build.VERSION.SDK_INT < 30 || !surface.isValid || appliedSurfaceFrameRate == surfaceFrameRate) return
try {
if (Build.VERSION.SDK_INT >= 31) {
surface.setFrameRate(surfaceFrameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT, Surface.CHANGE_FRAME_RATE_ALWAYS)
} else {
surface.setFrameRate(surfaceFrameRate, Surface.FRAME_RATE_COMPATIBILITY_DEFAULT)
}
appliedSurfaceFrameRate = surfaceFrameRate
} catch (t: IllegalArgumentException) {
Log.w("CompositorHost", "surface frame rate", t)
} catch (t: IllegalStateException) {
Log.w("CompositorHost", "surface frame rate", t)
}
}
@Synchronized
fun attachXr() {
@@ -50,4 +50,28 @@ class MaliAutoRouteTest {
assertTrue(MaliAutoRoute.userChoice(true, MaliAutoRoute.VENUS, MaliAutoRoute.BRIDGE))
assertFalse(MaliAutoRoute.userChoice(false, MaliAutoRoute.NONE, MaliAutoRoute.BRIDGE))
}
@Test
fun venusTheUserSwitchedOffIsNotSwitchedBackOn() {
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, true, "Mali-G715"))
assertTrue(MaliAutoRoute.venusStandsIn(true, true, true, true, "Mali-G2-Ultra-NX MC12"))
}
@Test
fun venusIsAutosStandInOnlyWhereSteamStartsThroughIt() {
assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, false, "Mali-G2-Ultra-NX MC12"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, true, false, "Mali-G2-Ultra-NX MC16"))
assertFalse(MaliAutoRoute.venusStandsIn(false, true, true, true, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, false, true, true, "Mali-G715"))
}
@Test
fun venusThatAutoTurnedOffIsStillAutosToTurnOn() {
// Auto clears the stored key when it moves to the bridge: a stored "off" would read as the user's own choice.
val cleared = MaliAutoRoute.userChoice(keyStored = false, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS)
val writtenOff = MaliAutoRoute.userChoice(keyStored = true, owner = MaliAutoRoute.BRIDGE, route = MaliAutoRoute.VENUS)
assertTrue(MaliAutoRoute.venusStandsIn(true, true, false, cleared, "Mali-G715"))
assertFalse(MaliAutoRoute.venusStandsIn(true, true, false, writtenOff, "Mali-G715"))
}
}
@@ -17,6 +17,22 @@ class PerfModeTest {
ShadowDisplayManager.ModeBuilder.modeBuilder(id)
.setWidth(width).setHeight(2520).setRefreshRate(hz).build()
@Test fun aPendingModeSwitchVotesForTheSelectedRateWithoutChangingMeasuredPacing() {
assertEquals(185f, PerfMode.frameRateVote(185f, 60f), 0f)
assertEquals(60f, PerfMode.frameRateVote(60f, 185f), 0f)
assertEquals(120f, PerfMode.frameRateVote(120f, 120f), 0f)
assertEquals(60f, PerfMode.frameRateVote(0f, 60f), 0f)
}
@Test fun aSurfaceVoteUsesTheSelectedCapAndGuestCadence() {
val modes = arrayOf(mode(1, 60f), mode(2, 90f), mode(3, 120f), mode(4, 185f))
val current = modes[0]
val capped = PerfMode.selectMode(modes, current, 0, 90f)!!
val limited = PerfMode.selectMode(modes, current, 60, Float.POSITIVE_INFINITY)!!
assertEquals(90f, PerfMode.frameRateVote(capped.refreshRate, 60f), 0f)
assertEquals(120f, PerfMode.frameRateVote(limited.refreshRate, 60f), 0f)
}
@Test fun sixtyHzMirrorChoosesSixtyEvenThoughOneTwentyHasMatchingCadence() {
val low = mode(1, 60f)
val high = mode(2, 120f)
@@ -16,6 +16,34 @@ class XboxManifestTest {
java.io.File(root, "MicrosoftGame.Config").writeText("<Game><ExecutableList><Executable Name=\"bin\\GAME.EXE\" TargetDeviceFamily=\"PC\"/></ExecutableList></Game>")
assertEquals("Bin/Game.exe", XboxInstaller.executable(root))
}
@Test fun aListedExecutableThePackageDoesNotShipFallsThroughToTheNextOne() {
val root = temporary.newFolder()
java.io.File(root, "bin/x64_dx12").mkdirs()
java.io.File(root, "bin/x64_dx12/game.exe").writeText("encrypted")
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"bin\\x64\\game.exe\" TargetDeviceFamily=\"PC\"/>" +
"<Executable Name=\"Launcher\\start.exe\" TargetDeviceFamily=\"PC\"/>" +
"<Executable Name=\"bin\\x64_dx12\\game.exe\" TargetDeviceFamily=\"PC\"/></ExecutableList></Game>")
assertEquals("bin/x64_dx12/game.exe", XboxInstaller.executable(root))
}
@Test fun anAmbiguouslyCasedExecutableFallsThroughToTheNextOne() {
val root = temporary.newFolder()
java.io.File(root, "Game.exe").writeText("one")
java.io.File(root, "GAME.exe").writeText("two")
java.io.File(root, "Other.exe").writeText("three")
org.junit.Assume.assumeTrue(root.listFiles().orEmpty().count { it.name.equals("game.exe", true) } == 2)
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"game.exe\"/><Executable Name=\"Other.exe\"/></ExecutableList></Game>")
assertEquals("Other.exe", XboxInstaller.executable(root))
}
@Test fun aPackageWithNoneOfItsListedExecutablesStillFails() {
val root = temporary.newFolder()
java.io.File(root, "Unlisted.exe").writeText("encrypted")
java.io.File(root, "MicrosoftGame.config").writeText("<Game><ExecutableList>" +
"<Executable Name=\"bin\\Game.exe\"/><Executable Name=\"Game.exe\"/></ExecutableList></Game>")
val failure = assertThrows(IllegalArgumentException::class.java) { XboxInstaller.executable(root) }
assertEquals("Missing or ambiguous Xbox launch path.", failure.message)
}
@Test fun aLauncherMenuIsSkippedForTheProgramItNames() {
val root = temporary.newFolder()
java.io.File(root, "EmuMenu").mkdir()
@@ -0,0 +1,13 @@
package com.droiddeck.launcher.wayland
import org.junit.Assert.assertEquals
import org.junit.Test
class CompositorHostTest {
@Test fun aPendingRefreshVotePreservesExplicitLimitsAndBlackFrameInsertion() {
assertEquals(185f, CompositorHost.layerFrameRate(185f, 0, false), 0f)
assertEquals(30f, CompositorHost.layerFrameRate(185f, 30, false), 0f)
assertEquals(185f, CompositorHost.layerFrameRate(185f, 30, true), 0f)
assertEquals(60f, CompositorHost.layerFrameRate(60f, 0, false), 0f)
}
}
@@ -1,42 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
Subject: [PATCH] zink: clear batch usage of freed slab entries
bo_destroy_or_cache() drops a real BO's batch usage before the BO goes into
the cache, but bo_slab_destroy() hands slab entries to pb_slab_free() with
their reads/writes usage still set. Zink only frees a BO once no batch holds a
reference any more, so whatever usage is left at that point is stale: it
points at a batch state the BO is no longer tracked by.
A stale pointer can name a batch state that is never submitted again, for
example the recording batch of a context that was destroyed (its unflushed
flag stays set while it waits in the screen's free list) or of a context that
another thread keeps current without ever flushing. bo_can_reclaim() then
returns false for that entry forever. pb_slabs_reclaim_locked() walks the
reclaim list from the oldest entry and stops after MAX_FAILED_RECLAIMS (2)
failures, so two such entries at the head stop all slab reclaim for the
screen: every later small buffer gets a fresh 2 MB slab and nothing is ever
freed.
WineD3D through Proton 11 with Zink on Venus can hit this
as soon as it enters the 3D world: about 0.2 new slabs per frame,
gigabytes of GPU memory after a few minutes, until Android kills the
session. Clear the usage the same way bo_destroy_or_cache() does.
Upstream fixed the same ballooning in Mesa 26.2 with commit fa867cf18
("zink/bo: check for usage before completion when reclaiming bos",
MR !41936), which relies on the per-BO submit_count tracking added in
26.1 and does not apply to 26.0. This is a minimal alternative for the
26.0 series; drop it once DroidDeck moves to Mesa >= 26.2.
---
diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c
--- a/src/gallium/drivers/zink/zink_bo.c
+++ b/src/gallium/drivers/zink/zink_bo.c
@@ -185,6 +185,8 @@
struct zink_bo *bo = zink_bo(pbuf);
assert(!bo->mem);
+ bo->reads.u = NULL;
+ bo->writes.u = NULL;
//if (bo->base.usage & RADEON_FLAG_ENCRYPTED)
//pb_slab_free(get_slabs(screen, bo->base.size, RADEON_FLAG_ENCRYPTED), &bo->u.slab.entry);