Mali bridge: DXVK 1.10.3 on phones whose Vulkan stops below 1.3

Proton's DXVK 3 refuses a device below Vulkan 1.3, without shaderInt64 or
with less than 256 bytes of push constants, so on a Mali with a 1.1 driver
(OnePlus Ace 2V, Mali-G710, r32p1) every D3D9-11 game exits. On a bridge
session the forced-package step now picks the newest DXVK that starts on
what games see: 1.10.3 below Vulkan 1.3, 2.6.2 on 1.3 without shaderInt64
or 256 bytes of push constants, Proton's own otherwise.

What games see comes from <bridge cache dir>/apps-vulkan (a bridge with
Vulkan promotion writes it after its self-test) or else from the phone's
driver (vkinfo now reports shader_int64 and max_push_constants). These
choices are marked automatic: a later session with another answer swaps or
restores them, and the player's own choice in Components is never touched.
This commit is contained in:
ASEbrahim authored and maxjivi05 committed 2026-10-26 13:55:31 -04:00
1 parent e63fad1daa
commit 9040f828e9
4 files changed
+308 -12

No files matched your search

@@ -0,0 +1,179 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.gpu.AppVulkan
import com.droiddeck.launcher.gpu.GpuInfo
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.github.luben.zstd.ZstdOutputStream
import org.apache.commons.compress.archivers.tar.TarArchiveEntry
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream
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 BridgeDxvkTest {
private val old = ComponentsManager.DXVK_FOR_VULKAN_1_1
private val mid = ComponentsManager.DXVK_FOR_VULKAN_1_3_NO_INT64
private lateinit var context: Context
private val g710 = AppVulkan(1, 1, shaderInt64 = false, maxPushConstants = 128, source = "driver")
private val promoted = g710.copy(minor = 2, source = "bridge")
private val full = AppVulkan(1, 3, shaderInt64 = true, maxPushConstants = 256, source = "driver")
private val mali = GpuInfo("Mali-G710", 0, GpuInfo.Family.NOT_ADRENO, "", false)
@Before fun setUp() {
context = RuntimeEnvironment.getApplication()
File(context.filesDir, "components").deleteRecursively()
LinuxRuntime.rootDir(context).deleteRecursively()
}
@Test fun theNewestDxvkThatStartsIsChosen() {
assertEquals(old, ComponentsManager.bridgeDxvk(g710)?.file)
assertEquals(old, ComponentsManager.bridgeDxvk(promoted)?.file)
assertEquals(mid, ComponentsManager.bridgeDxvk(full.copy(shaderInt64 = false))?.file)
assertEquals(mid, ComponentsManager.bridgeDxvk(full.copy(maxPushConstants = 128))?.file)
assertNull(ComponentsManager.bridgeDxvk(full))
assertNull(ComponentsManager.bridgeDxvk(full.copy(shaderInt64 = null, maxPushConstants = null)))
assertNull(ComponentsManager.bridgeDxvk(AppVulkan(1, 0, null, null, "driver")))
assertNull(ComponentsManager.bridgeDxvk(null))
assertEquals("Dxvk-Linux", ComponentsManager.bridgeDxvk(g710)?.release)
assertEquals("dxvk", ComponentsManager.bridgeDxvk(g710)?.comp)
}
@Test fun theDriversLinesAreRead() {
val vk = AppVulkan.fromDriver(mapOf("device" to "Mali-G710 MC10", "api" to "1.1.177", "shader_int64" to "no", "max_push_constants" to "128"))
assertEquals(g710, vk)
assertNull(AppVulkan.fromDriver(mapOf("error" to "no Vulkan device")))
assertNull(AppVulkan.fromDriver(mapOf("api" to "garbage")))
val older = AppVulkan.fromDriver(mapOf("api" to "1.3.250"))!!
assertNull(older.shaderInt64)
assertNull(older.maxPushConstants)
}
@Test fun theBridgesFileWinsForItsOwnGpuOnly() {
val text = "device=Mali-G710 MC10\napi=1.2.177\ndriver_api=1.1.177\nshader_int64=0\nmax_push_constants=128\n"
assertEquals(promoted, AppVulkan.fromBridgeFile(text, "Mali-G710 MC10"))
assertEquals(promoted, AppVulkan.fromBridgeFile(text, null))
assertNull(AppVulkan.fromBridgeFile(text, "Mali-G720 Immortalis MC12"))
assertNull(AppVulkan.fromBridgeFile("device=x\n", null))
}
@Test fun anAdrenoSessionIsNotTouched() {
proton("proton-exp")
assertNull(run(g710, bridge = false))
}
@Test fun aShippedDxvk3IsReplacedOnAVulkan11Phone() {
proton("proton-exp")
proton("ge")
val applied = mutableListOf<String>()
val result = run(g710, applyAuto = { id, file -> applied += "$id $file"; "swapped $id" })
assertEquals(listOf("ge $old", "proton-exp $old"), applied.sorted())
assertTrue(result!!.startsWith("Vulkan 1.1, shaderInt64 no, push constants 128 (driver): DXVK $old"))
}
@Test fun thePlayersOwnChoiceIsKept() {
proton("proton-exp")
writeState("proton-exp", JSONObject().put("file", "dxvk-3.1-linux.wcp").put("protonVersion", "experimental-11"))
assertNull(run(g710))
assertNull(run(full))
}
@Test fun anAutomaticChoiceFollowsTheDevice() {
proton("proton-exp")
writeState("proton-exp", JSONObject().put("file", mid).put("protonVersion", "experimental-11").put("auto", true))
val applied = mutableListOf<String>()
run(g710, applyAuto = { id, file -> applied += "$id $file"; "swapped" })
assertEquals(listOf("proton-exp $old"), applied)
writeState("proton-exp", JSONObject().put("file", old).put("protonVersion", "experimental-11").put("auto", true))
assertNull(run(g710))
val undone = mutableListOf<String>()
run(full, undoAuto = { id, comp -> undone += "$id $comp"; "undone" })
assertEquals(listOf("proton-exp dxvk"), undone)
}
@Test fun theSwapAndItsUndoReachTheProton() {
proton("proton-exp")
val d3d11 = File(protonDir("proton-exp"), "files/lib/wine/dxvk/aarch64-windows/d3d11.dll")
writePackage(old, "DXVK 1.10.3")
val auto: (String, String) -> String = { id, file -> ComponentsManager.swap(context, id, file, auto = true) }
val undo: (String, String) -> String = { id, comp -> ComponentsManager.undoAutoChoice(context, id, comp) }
assertNotNull(run(g710, applyAuto = auto, undoAuto = undo))
assertEquals("DXVK 1.10.3", d3d11.readText())
val entry = state().getJSONObject("active").getJSONObject("proton-exp").getJSONObject("dxvk")
assertEquals(old, entry.getString("file"))
assertTrue(entry.getBoolean("auto"))
assertNull(run(g710, applyAuto = auto, undoAuto = undo))
run(full, applyAuto = auto, undoAuto = undo)
assertEquals("bundled DXVK experimental-11", d3d11.readText())
assertNull(state().getJSONObject("active").optJSONObject("proton-exp")?.optJSONObject("dxvk"))
}
@Test fun aProtonUpdateWithNoRuleLeftJustForgetsTheChoice() {
proton("proton-exp", "experimental-12")
writeState("proton-exp", JSONObject().put("file", old).put("protonVersion", "experimental-11").put("auto", true))
run(full, undoAuto = { id, comp -> ComponentsManager.undoAutoChoice(context, id, comp) })
assertNull(state().getJSONObject("active").optJSONObject("proton-exp")?.optJSONObject("dxvk"))
assertEquals("bundled DXVK experimental-12", File(protonDir("proton-exp"), "files/lib/wine/dxvk/aarch64-windows/d3d11.dll").readText())
}
private fun run(
vk: AppVulkan?,
bridge: Boolean = true,
applyAuto: (String, String) -> String = { id, file -> error("apply $id $file") },
undoAuto: (String, String) -> String = { id, comp -> error("undo $id $comp") },
) = ComponentsManager.ensureForcedPackages(
context, mali,
lookup = { file, release -> ComponentsManager.CatalogItem(file, "dxvk", release, "https://example.invalid/$file", 4, "sha256:" + "ab".repeat(32)) },
fetch = {},
apply = { id, file -> error("non-automatic apply $id $file") },
vulkan = vk, bridgeSession = bridge, applyAuto = applyAuto, undoAuto = undoAuto,
)
private fun protonDir(name: String) = File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps/common/$name")
private fun proton(name: String, version: String = "experimental-11") {
val dir = protonDir(name)
File(dir, "files/lib/wine").mkdirs()
File(dir, "proton").writeText("#!/bin/sh\n")
File(dir, "version").writeText("1 $version\n")
File(dir, "files/lib/wine/dxvk/aarch64-windows/d3d11.dll").apply {
parentFile!!.mkdirs()
writeText("bundled DXVK $version")
}
}
private fun state() = JSONObject(File(context.filesDir, "components/state.json").readText())
private fun writeState(protonId: String, dxvk: JSONObject) {
val f = File(context.filesDir, "components/state.json")
f.parentFile!!.mkdirs()
f.writeText(JSONObject().put("active", JSONObject().put(protonId, JSONObject().put("dxvk", dxvk)))
.put("queued", JSONObject()).toString())
}
private fun writePackage(file: String, d3d11: String) {
val dest = File(context.filesDir, "components/packages/$file")
dest.parentFile!!.mkdirs()
TarArchiveOutputStream(ZstdOutputStream(dest.outputStream())).use { tar ->
fun put(name: String, bytes: ByteArray) {
tar.putArchiveEntry(TarArchiveEntry(name).apply { size = bytes.size.toLong() })
tar.write(bytes)
tar.closeArchiveEntry()
}
put("./profile.json", JSONObject().put("type", "DXVK-Linux").put("versionName", file.removeSuffix(".wcp")).toString().toByteArray())
put("./files/lib/wine/dxvk/aarch64-windows/d3d11.dll", d3d11.toByteArray())
}
}
}