Mali (Venus) as a selectable route, by David Cimo

Ports David Cimo's Venus route (DavidCimo/droiddeck-mali, mali-venus @ 4f838891) onto this branch
as "Mali (Venus)", one tap in Setup next to the Mali bridge:
- VenusComponent (his): stages the Venus ICD and runs virglrenderer's vtest server over the
  phone's own Vulkan driver; the guest gets VK_ICD_FILENAMES, VN_DEBUG=vtest, VTEST_SOCKET_NAME and
  MESA_VK_WSI_DEBUG=sw.
- Selection rule: Venus when Setup's "Mali (Venus)" is on, on a GPU that is neither an Adreno nor
  a system-driver one (PowerVR, Xclipse), and the apk carries it. It then replaces the Mali bridge
  and any open driver pair for the session, and the display stays on the phone's own driver.
  Auto is unchanged (the PanVK pair). Adreno never takes any of it.
- The compositor enables only the dma-buf extensions the driver has, logs a vendor driver's
  extension list, and gives a zero row pitch a packed row (his vk_present.c changes).
- The Mali compatibility layer is staged into the runtime on non-Adreno devices only.
- The component (vtest server, ICD, layer) comes from build-venus.yml as venus.tzst, published on
  The412Banner/droiddeck-nonadreno-drivers and pinned by sha in tools/venus/release.env.
- gamescope 3.16.29-p15 adds his shm upload patch (0127) next to 0126; pinned by sha.
- device.txt and graphics-report.txt name the route.

Co-authored-by: Dersim Abbas <derabb0620@gmail.com>
This commit is contained in:
The412BannerandDersim Abbas committed 2026-10-12 23:45:36 -04:00
1 parent 9035dd1dc2
commit a2c778f6e8
16 files changed
+231 -21

No files matched your search

@@ -147,6 +147,7 @@ class MainActivity : ComponentActivity() {
private var tuSysmem by mutableStateOf(false)
private var zinkLazy by mutableStateOf(false)
private var vkBridge by mutableStateOf(false)
private var venus by mutableStateOf(false)
private val adrenoGpu by lazy { com.droiddeck.launcher.core.DeviceSupport.adreno() }
private var noXalia by mutableStateOf(true)
private var fastSync by mutableStateOf(false)
@@ -557,7 +558,7 @@ class MainActivity : ComponentActivity() {
FrontEndScreen(
FrontEndState(
installed = installed, ready = ready, available = available?.version, removalPending = removalPending, runtimeActionsBlocked = runtimeChangesBlocked(),
vkBridge = vkBridge, adreno = adrenoGpu,
vkBridge = vkBridge, venus = venus, adreno = adrenoGpu,
shortcutPicker = shortcutPicker,
shortcutLibraryScanning = shortcutLibraryScanning,
gameSyncFolder = gameSyncFolder,
@@ -686,6 +687,7 @@ class MainActivity : ComponentActivity() {
onRemovePackage = { id -> removePackage(id) },
onRuntime = { onRuntimeButton() },
onVkBridge = { on -> SessionPrefs.setVkBridge(this, on); vkBridge = on },
onVenus = { on -> SessionPrefs.setVenus(this, on); venus = on },
onFrameGenPick = { mode ->
FrameGen.set(this, mode)
frameGenLabel = FrameGen.label(this)
@@ -1585,6 +1587,7 @@ class MainActivity : ComponentActivity() {
tuSysmem = SessionPrefs.tuSysmem(this)
zinkLazy = SessionPrefs.zinkLazy(this)
vkBridge = SessionPrefs.vkBridge(this)
venus = SessionPrefs.venus(this)
noXalia = SessionPrefs.noXalia(this)
fastSync = SessionPrefs.fastSync(this)
syncFallback = SessionPrefs.syncFallback(this)
@@ -148,6 +148,8 @@ object DeviceReport {
k("Linux driver", label)
}
k("Runtime's own ICD", LinuxRuntime.vulkanIcd(context)?.path)
k("Mali (Venus)", if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) "in use"
else if (com.droiddeck.launcher.session.VenusComponent.available(context)) "available, off" else "not in this build")
h("Runtime")
k("Installed version", LinuxRuntimeInstaller.installedVersion(context))
@@ -24,6 +24,7 @@ object DeviceSupport {
*/
fun vkBridge(context: Context): Boolean =
!adreno() && !SystemVulkanDriver.isAvailable() && !openDriverActive(context) &&
!com.droiddeck.launcher.session.VenusComponent.wanted(context) &&
com.droiddeck.launcher.session.SessionPrefs.vkBridge(context)
/**
@@ -32,6 +33,7 @@ object DeviceSupport {
*/
fun openDriverActive(context: Context): Boolean {
if (adreno()) return false
if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) return false
// The runtime half is what counts: a Mali pair may run with the system driver as its display.
val linux = com.droiddeck.launcher.session.SessionPrefs.linuxDriver(context).ifEmpty { return false }
return com.droiddeck.launcher.gpu.DriverPairs.isNonAdreno(com.droiddeck.launcher.gpu.DriverBundle.containing(context, linux, true)?.id)
@@ -41,7 +43,8 @@ object DeviceSupport {
* A session can draw: Adreno with Turnip, PowerVR/Xclipse on the system driver, an open
* non-Adreno driver pair, or the bridge.
*/
fun canDraw(context: Context): Boolean = graphicsAvailable() || openDriverActive(context) || vkBridge(context)
fun canDraw(context: Context): Boolean = graphicsAvailable() || openDriverActive(context) || vkBridge(context) ||
com.droiddeck.launcher.session.VenusComponent.wanted(context)
/** The chip as the device names it, for the card that explains the refusal. */
fun gpuName(context: Context): String {
@@ -317,6 +317,11 @@ public final class TurnipDriver {
private String choose() {
SessionPrefs.ensurePowerVrAutoDrivers(context);
String chosen = SessionPrefs.androidDriver(context);
// Mali (Venus): the phone's own driver draws the screen, as Venus replays on it.
if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) {
Log.i(TAG, "Mali (Venus): display on the system Vulkan loader");
return null;
}
// A Mali under Auto draws its display on Android's own Vulkan loader, whatever an earlier
// build set: a PanVK Android half fails on Mali gralloc. A manual pick is respected.
if (chosen != null && !chosen.isEmpty() && new File("/dev/mali0").exists()
@@ -102,6 +102,7 @@ object GraphicsReport {
/** Which backend this session's Vulkan goes through, as the session decides it. */
private fun path(context: Context): String = when {
DeviceSupport.adreno() -> "Turnip (Adreno, KGSL)"
VenusComponent.wanted(context) -> "Mali (Venus): Mesa Venus over vtest to the phone's own Vulkan driver, with the Mali compatibility layer"
DeviceSupport.vkBridge(context) -> "Mali bridge (#517): the phone's own Vulkan driver through the bridge"
DeviceSupport.openDriverActive(context) -> "open driver pair (PanVK / RADV)"
SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(context)) && SystemVulkanDriver.isAvailable() ->
@@ -141,6 +141,13 @@ object SessionFiles {
val fexPreloads = listOf("x86_64", "i386").flatMap { arch ->
listOf("libblsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
} + listOf("libthunkaudit.so", "libvulkan-thunk.so").map { "x86_64/$it" to "usr/local/lib/droiddeck-fex/x86_64/$it" }
// The Mali compatibility layer (tools/venus/layer, David Cimo): an implicit Vulkan layer that
// fills in the features DXVK requires and Mali lacks. Idle outside Wine and on GPUs that have them.
// Never staged on an Adreno: an implicit layer is loaded into every Vulkan program there.
val maliCompat = if (com.droiddeck.launcher.core.DeviceSupport.adreno()) emptyList() else listOf(
"usr/local/lib/droiddeck-mali/libVkLayer_droiddeck_mali_compat.so",
"usr/local/share/vulkan/implicit_layer.d/VkLayer_droiddeck_mali_compat.json",
).map { it to it }
val optional = (arrayOf(
"usr/local/bin/gamescope" to "usr/local/bin/gamescope",
// The Mali bridge's Linux side (tools/vkbridge): the ICD, its manifest and the self-test.
@@ -149,7 +156,7 @@ object SessionFiles {
"usr/local/bin/droiddeck-vkbridge-smoke" to "usr/local/bin/droiddeck-vkbridge-smoke",
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
) + mangoapp + xclipse.map { it to it } + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
) + mangoapp + xclipse.map { it to it } + maliCompat + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + fexPreloads).filter { (asset, _) ->
val dir = asset.substringBeforeLast('/')
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
}
@@ -509,6 +509,16 @@ object SessionPrefs {
@JvmStatic
fun vkBridge(context: Context): Boolean = prefs(context).getBoolean("vkBridge", false)
/**
* Setup's "Mali (Venus)": the session's Vulkan through Mesa's Venus to the phone's own driver
* (VenusComponent, David Cimo's route). Off by default; on a GPU that is not an Adreno only.
*/
fun venus(context: Context): Boolean = prefs(context).getBoolean("venus", false)
fun setVenus(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("venus", on).apply()
}
fun setVkBridge(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("vkBridge", on).apply()
}
@@ -391,6 +391,9 @@ class SessionService : Service() {
val pulse = startAudio(guest, sessionDir)
startVkBridge(guest, sessionDir)
if (VenusComponent.wanted(this)) {
components.add(VenusComponent(File(sessionDir, "venus.log")).also { it.attach(this) })
}
guest.add("BL_WIDTH=" + size.first)
guest.add("BL_HEIGHT=" + size.second)
@@ -645,7 +648,13 @@ class SessionService : Service() {
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
guest.add("GALLIUM_DRIVER=zink")
guest.add("LIBGL_KOPPER_DRI2=true")
LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
val venus = VenusComponent.wanted(this)
if (venus) {
// Mali (Venus): the session's Vulkan is Mesa's Venus ICD over vtest to the phone's driver.
VenusComponent.guestEnv(this).forEach { guest.add(it) }
} else {
LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
}
// An imported glibc Turnip, when one is set (by the user, or by Auto): the session script
// checks the manifest and its library from inside and points the loader at it with
// VK_DRIVER_FILES, so the runtime's own driver above stays untouched and is what a bad
@@ -655,10 +664,10 @@ class SessionService : Service() {
// Mali bridge (PR #517) on: the bridge ICD is the driver (startVkBridge). Otherwise the system
// PowerVR/Xclipse path (PR #570) or the imported/runtime Turnip, as before.
val bridge = com.droiddeck.launcher.core.DeviceSupport.vkBridge(this)
if (!bridge && SystemVulkanDriver.usesDefault(linuxDriverId)) {
if (!bridge && !venus && SystemVulkanDriver.usesDefault(linuxDriverId)) {
SystemVulkanDriver.addEnvironment(this, guest)
}
(if (bridge) null else LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId))
(if (bridge || venus) null else LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId))
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
// An open Mali driver pair: /dev/mali0 stands in as the render node (LinuxRuntime.bindGpuNode)
// and the session shim answers gamescope's PRIME calls on it as on KGSL. It only covers
@@ -697,7 +706,7 @@ class SessionService : Service() {
// Downloads holds the value verbatim ("sysmem", "sysmem,deck_emu"); with nothing there, an
// imported driver from the A710/A720/A722 legs gets "sysmem" on its own, which is what both
// its authors advise for those GPUs and what nothing else in the list needs.
tuDebug(linuxDriverId)?.let { guest.add("TU_DEBUG=$it") }
if (!venus) tuDebug(linuxDriverId)?.let { guest.add("TU_DEBUG=$it") }
// Zink renders the client's UI (Chromium -> ANGLE -> Zink -> Turnip). Lazy descriptors is
// the mode Zink recommends where the driver has no descriptor buffer, and what Ludashi ships
// by default for its Zink path; a switch here because on one Fold the menus run at 14 fps.
@@ -0,0 +1,113 @@
package com.droiddeck.launcher.session
import android.content.Context
import android.os.Process
import android.util.Log
import com.droiddeck.launcher.core.DeviceSupport
import com.droiddeck.launcher.core.FileUtils
import com.droiddeck.launcher.core.HostProcess
import com.droiddeck.launcher.core.SessionPart
import java.io.File
import java.io.PrintWriter
/**
* Vulkan for the session on a Mali, through Venus (the "Mali (Venus)" route; by David Cimo,
* DavidCimo/droiddeck-mali, ported to this branch).
*
* The guest's processes are glibc and cannot load the vendor's bionic driver. Instead they load
* Mesa's Venus ICD (libvulkan_virtio.so), which serializes every Vulkan call over a unix socket to
* virglrenderer's vtest server. The server runs here, on the Android side, and replays the calls
* on the device's own Vulkan driver. Both ends of the socket are under the app's files directory,
* which the session binds at its own path, so the same path works inside and out.
*/
class VenusComponent(private val logFile: File?) : SessionPart() {
@Volatile private var pid = -1
override fun start() {
val context = app()
stageIcd(context)
val libDir = context.applicationInfo.nativeLibraryDir
val socket = socket(context)
socket.delete()
val env = arrayOf(
"LD_LIBRARY_PATH=$libDir",
// vtest forks a render server per client; this is where its executable is.
"RENDER_SERVER_EXEC_PATH=$libDir/libvirgl_render_server.so",
"TMPDIR=" + context.cacheDir.path,
)
val command = "$libDir/libvirgl_test_server.so --venus --no-virgl --socket-path " + socket.path
val out = logFile?.let { runCatching { PrintWriter(java.io.FileWriter(it, true)) }.getOrNull() }
pid = HostProcess.start(command, env, context.filesDir, { status ->
Log.w(TAG, "vtest server exited: $status")
out?.let { synchronized(it) { it.println("vtest server exited: $status"); it.flush() } }
}, { line ->
Log.i(TAG, line)
out?.let { synchronized(it) { it.println(line); it.flush() } }
})
Log.i(TAG, "vtest server pid $pid on $socket")
}
override fun stop() {
if (pid > 1) Process.killProcess(pid)
pid = -1
}
companion object {
private const val TAG = "Venus"
private const val ASSET = "venus/libvulkan_virtio.so"
private const val DIR = "venus"
private const val LIB = "libvulkan_virtio.so"
private const val ICD = "virtio_icd.json"
/**
* The selection rule: Venus when Setup's "Mali (Venus)" is on, on a GPU that is neither an
* Adreno nor one the system-driver route covers (PowerVR, Xclipse), and the apk carries it.
* It then replaces the Mali bridge and any open driver pair for the session.
*/
@JvmStatic
fun wanted(context: Context): Boolean =
!DeviceSupport.adreno() && !com.droiddeck.launcher.gpu.SystemVulkanDriver.isAvailable() &&
SessionPrefs.venus(context) && available(context)
/** Whether this apk carries the Venus component (tools/venus, venus.tzst). */
@JvmStatic
fun available(context: Context): Boolean = runCatching {
context.assets.list(DIR)?.contains(LIB) == true &&
File(context.applicationInfo.nativeLibraryDir, "libvirgl_test_server.so").isFile
}.getOrDefault(false)
@JvmStatic
fun socket(context: Context): File = File(File(context.filesDir, DIR), "vtest.sock")
/** What the guest needs to find the ICD and the server. */
@JvmStatic
fun guestEnv(context: Context): List<String> {
val dir = File(context.filesDir, DIR)
return listOf(
"VK_ICD_FILENAMES=" + File(dir, ICD).path,
"VN_DEBUG=vtest",
"VTEST_SOCKET_NAME=" + socket(context).path,
// Xwayland has no DRI3 without a DRM node, so swapchains present through shared memory.
"MESA_VK_WSI_DEBUG=sw",
)
}
/** Copies the ICD out of the APK when it changed, and writes its manifest with an absolute path. */
private fun stageIcd(context: Context) {
val dir = File(context.filesDir, DIR).apply { mkdirs() }
val lib = File(dir, LIB)
// Copied again after every app update: the asset is compressed, so its size is unknown up front.
val installed = context.packageManager.getPackageInfo(context.packageName, 0).lastUpdateTime
if (!lib.isFile || lib.lastModified() < installed) {
val tmp = File(dir, "$LIB.tmp")
context.assets.open(ASSET).use { input -> tmp.outputStream().use { input.copyTo(it) } }
if (!tmp.renameTo(lib)) Log.e(TAG, "could not move the Venus ICD into place")
Log.i(TAG, "staged $lib (${lib.length()} bytes)")
}
FileUtils.writeString(
File(dir, ICD),
"""{"file_format_version":"1.0.1","ICD":{"library_path":"${lib.path}","api_version":"1.4.354"}}""",
)
}
}
}
@@ -135,6 +135,8 @@ class FrontEndState(
val adreno: Boolean = true,
/** Setup's "Mali bridge (experimental)" (SessionPrefs.vkBridge). */
val vkBridge: Boolean = false,
/** Setup's "Mali (Venus)" (SessionPrefs.venus). */
val venus: Boolean = false,
val showPhantomGate: Boolean = false,
val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
val launcherFullscreen: Boolean = true,
@@ -193,6 +195,7 @@ class FrontEndActions(
val onRemovePackage: (String) -> Unit,
val onRuntime: () -> Unit,
val onVkBridge: (Boolean) -> Unit = {},
val onVenus: (Boolean) -> Unit = {},
val onFrameGenPick: (FrameGen.Mode) -> Unit,
val onImportLossless: () -> Unit,
val onProtons: () -> Unit,
@@ -218,10 +218,16 @@ internal fun SetupPanel(
divider = divider,
// Not an Adreno: the experimental Vulkan bridge is the one way to draw.
action = if (s.adreno) null else { {
SecondaryButton(
stringResource(if (s.vkBridge) R.string.setup_gpu_bridge_on else R.string.setup_gpu_bridge_off),
enabled = !s.sessionRunning, compact = true, onClick = { a.onVkBridge(!s.vkBridge) },
)
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
SecondaryButton(
stringResource(if (s.venus) R.string.setup_gpu_venus_on else R.string.setup_gpu_venus_off),
enabled = !s.sessionRunning, compact = true, onClick = { a.onVenus(!s.venus) },
)
SecondaryButton(
stringResource(if (s.vkBridge) R.string.setup_gpu_bridge_on else R.string.setup_gpu_bridge_off),
enabled = !s.sessionRunning, compact = true, onClick = { a.onVkBridge(!s.vkBridge) },
)
}
} },
)
}