mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d79fc14d | ||
|
|
c6743730aa | ||
|
|
780c5658d0 | ||
|
|
a9e8a01bb6 | ||
|
|
861121144c | ||
|
|
d7fcea74b4 | ||
|
|
44b429ca20 | ||
|
|
c91b100bc1 | ||
|
|
90df30f4d7 | ||
|
|
2b6ded9fd4 | ||
|
|
38c2c00c86 |
No files matched your search
@@ -232,6 +232,16 @@ static VkResult timed_wait(VkFence fence, uint64_t timeout) {
|
||||
return g_dev_state == -2 ? VK_ERROR_DEVICE_LOST : VK_ERROR_UNKNOWN;
|
||||
int64_t t0 = perf_now();
|
||||
VkResult r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, timeout);
|
||||
if (r == VK_TIMEOUT) {
|
||||
droiddeck_log("gpu", "GPU fence delayed: retaining frame resources until completion");
|
||||
/* A scheduling delay does not invalidate the device. Keep this submission's
|
||||
* resources and call stack alive, as the main render path already does. */
|
||||
do {
|
||||
r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, UINT64_MAX);
|
||||
} while (r == VK_TIMEOUT);
|
||||
if (r == VK_SUCCESS)
|
||||
droiddeck_log("gpu", "GPU fence completed: continuing presentation");
|
||||
}
|
||||
perf_add(&g_perf.wait_ns, &g_perf.wait_max_ns, &g_perf.waits, perf_now() - t0);
|
||||
if (r != VK_SUCCESS && r != VK_ERROR_DEVICE_LOST)
|
||||
quarantine_pending_work(r, "fence wait");
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1038,14 +1038,18 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onHandled()
|
||||
return
|
||||
}
|
||||
val files = game.gameFiles
|
||||
if (game.source != com.droiddeck.launcher.stores.Store.XBOX.id || files == null) {
|
||||
val files = game.gameFiles?.takeIf { game.source == com.droiddeck.launcher.stores.Store.XBOX.id }
|
||||
val steamClient = Library.fromSteamClient(game)
|
||||
if (files == null && !steamClient) {
|
||||
if (startGame(game, returnHome, onHandled, request)) onSettled()
|
||||
else launchCoordinator.releaseHandling(request)
|
||||
return
|
||||
}
|
||||
val app = applicationContext
|
||||
Thread({
|
||||
val refused = com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||
val refused = files != null && com.droiddeck.launcher.stores.xbox.XboxManifest.needsAppModel(files)
|
||||
val uncached = steamClient && !com.droiddeck.launcher.session.NoSteamLaunch.enabled(app, game) &&
|
||||
com.droiddeck.launcher.session.OfflineMode.lacksAppInfo(app, game.appId)
|
||||
ui.post {
|
||||
when {
|
||||
!launchCoordinator.isCurrent(request) || isFinishing || isDestroyed -> {
|
||||
@@ -1057,11 +1061,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
android.widget.Toast.makeText(this, getString(R.string.game_needs_app_model, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
onSettled()
|
||||
}
|
||||
startGame(game, returnHome, onHandled, request) -> onSettled()
|
||||
else -> launchCoordinator.releaseHandling(request)
|
||||
else -> {
|
||||
if (uncached) android.widget.Toast.makeText(this, getString(R.string.game_steam_offline_uncached, game.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
if (startGame(game, returnHome, onHandled, request)) onSettled()
|
||||
else launchCoordinator.releaseHandling(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "xbox-app-model").start()
|
||||
}, "game-launch-check").start()
|
||||
}
|
||||
|
||||
private fun startGame(game: Library.SteamGame, returnHome: Boolean, onHandled: () -> Unit, ticket: LaunchTicket): Boolean {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -80,20 +80,38 @@ object SteamAppInfo {
|
||||
|
||||
private fun JSONArray?.strings(): List<String> = if (this == null) emptyList() else (0 until length()).map { optString(it) }
|
||||
|
||||
internal fun read(file: File, appId: Int): Info? {
|
||||
if (!file.isFile) return null
|
||||
internal fun read(file: File, appId: Int): Info? = scan(file, appId, unreadable = null, missing = null) { raf, entry ->
|
||||
if (entry.size > 64L * 1024 * 1024) return@scan null
|
||||
val body = ByteArray(entry.size.toInt())
|
||||
raf.readFully(body)
|
||||
val strings = entry.tableAt?.let { readStrings(raf, it) }
|
||||
val kv = ByteBuffer.wrap(body, entry.fixed, body.size - entry.fixed).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val tree = readMap(kv, strings)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
|
||||
infoOf(app)
|
||||
}
|
||||
|
||||
fun cached(file: File, appId: Int): Boolean? =
|
||||
runCatching { scan(file, appId, unreadable = null, missing = false) { _, _ -> true } }
|
||||
.onFailure { Log.w(TAG, "appinfo: ${it.javaClass.simpleName}") }
|
||||
.getOrNull()
|
||||
|
||||
private class Entry(val fixed: Int, val tableAt: Long?, val size: Long)
|
||||
|
||||
private fun <T> scan(file: File, appId: Int, unreadable: T, missing: T, found: (RandomAccessFile, Entry) -> T): T {
|
||||
if (!file.isFile) return unreadable
|
||||
RandomAccessFile(file, "r").use { raf ->
|
||||
val head = ByteBuffer.allocate(16).order(ByteOrder.LITTLE_ENDIAN)
|
||||
raf.readFully(head.array(), 0, 8)
|
||||
val magic = head.getInt(0)
|
||||
val version = magic and 0xFF
|
||||
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return null
|
||||
var strings: List<String>? = null
|
||||
if (magic ushr 8 != 0x075644 || version !in 0x27..0x29) return unreadable
|
||||
var tableAt: Long? = null
|
||||
var pos = 8L
|
||||
if (version >= 0x29) {
|
||||
raf.readFully(head.array(), 8, 8)
|
||||
val tableAt = head.getLong(8)
|
||||
strings = readStrings(raf, tableAt)
|
||||
tableAt = head.getLong(8)
|
||||
pos = 16L
|
||||
}
|
||||
val fixed = if (version >= 0x28) 4 + 4 + 8 + 20 + 4 + 20 else 4 + 4 + 8 + 20 + 4
|
||||
@@ -103,20 +121,11 @@ object SteamAppInfo {
|
||||
raf.readFully(entry.array(), 0, 8)
|
||||
val id = entry.getInt(0)
|
||||
val size = entry.getInt(4).toLong() and 0xFFFFFFFFL
|
||||
if (id == 0) return null
|
||||
if (id == appId) {
|
||||
if (size > 64L * 1024 * 1024) return null
|
||||
val body = ByteArray(size.toInt())
|
||||
raf.readFully(body)
|
||||
val kv = ByteBuffer.wrap(body, fixed, body.size - fixed).order(ByteOrder.LITTLE_ENDIAN)
|
||||
val tree = readMap(kv, strings)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val app = (tree["appinfo"] as? Map<String, Any>) ?: tree
|
||||
return infoOf(app)
|
||||
}
|
||||
if (id == 0) return missing
|
||||
if (id == appId) return found(raf, Entry(fixed, tableAt, size))
|
||||
pos += 8 + size
|
||||
}
|
||||
return null
|
||||
return missing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +112,9 @@ object NativeGuest {
|
||||
File(BwrapSpawner.hostPath(binds.map { BwrapSpawner.Bind.parse(it) }, root.path, cwd)).takeIf { it.isDirectory } ?: root
|
||||
|
||||
/** A process for [guest] (argv) started as proot would with [binds], in guest directory [cwd]. */
|
||||
fun processBuilder(context: Context, root: File, binds: List<String>, guest: List<String>, cwd: String = "/root"): ProcessBuilder =
|
||||
ProcessBuilder(command(root, guest.first(), guest.drop(1)))
|
||||
fun processBuilder(context: Context, root: File, binds: List<String>, guest: List<String>, cwd: String = "/root"): ProcessBuilder {
|
||||
if (sessionMode == null) prepare(context, root)
|
||||
return ProcessBuilder(command(root, guest.first(), guest.drop(1)))
|
||||
.directory(workingDirectory(root, binds, cwd))
|
||||
.also { builder ->
|
||||
builder.environment().apply {
|
||||
@@ -121,6 +122,7 @@ object NativeGuest {
|
||||
putAll(sessionEnvironment(root, binds, guest.first(), SessionPrefs.guestHostname(context)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val RUNPATH_CONF = "etc/ld.so.conf.d/zz-droiddeck-native.conf"
|
||||
private val SCAN_DIRS = listOf("usr/lib", "usr/local/lib", "opt")
|
||||
@@ -149,6 +151,7 @@ object NativeGuest {
|
||||
}
|
||||
|
||||
/** What a rootfs needs before anything runs in it natively; cheap once done. */
|
||||
@Synchronized
|
||||
fun prepare(context: Context, root: File) {
|
||||
val relinked = relinkAbsoluteSymlinks(context, root)
|
||||
if (relinked > 0) android.util.Log.i(TAG, "native userland: $relinked absolute symlinks made relative")
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.session
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.agent.AgentGuest
|
||||
import com.droiddeck.launcher.frontend.SteamAppInfo
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import java.io.File
|
||||
|
||||
@@ -63,6 +64,9 @@ object OfflineMode {
|
||||
fun active(context: Context): Boolean =
|
||||
offline(enabled(context), isOnline(context), auto(context))
|
||||
|
||||
fun lacksAppInfo(context: Context, appId: Int): Boolean =
|
||||
active(context) && SteamAppInfo.cached(SteamAppInfo.appinfoFile(context), appId) == false
|
||||
|
||||
@Synchronized
|
||||
fun setEnabled(context: Context, on: Boolean) {
|
||||
write(context, LinuxRuntime.rootDir(context), on)
|
||||
|
||||
@@ -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.")
|
||||
}
|
||||
|
||||
|
||||
@@ -195,6 +195,10 @@ internal fun librarySources(
|
||||
}
|
||||
}
|
||||
|
||||
internal fun alwaysLibraryTabs(signedIn: Collection<Store>, stores: Boolean, soundMode: Boolean): Set<String> =
|
||||
(if (soundMode) emptyList() else signedIn.map { it.librarySource }).toSet() +
|
||||
listOfNotNull(Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores })
|
||||
|
||||
internal object LibraryDisplay {
|
||||
const val DEFAULT_LEVEL = 2
|
||||
val scales = listOf(0.75f, 0.875f, 1f, 1.2f, 1.45f)
|
||||
@@ -374,7 +378,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
.map { it.store.id }.toSet()
|
||||
val sources = librarySources(
|
||||
all, storeTabs.map { it.store.id },
|
||||
listOfNotNull(Store.ITCH.id.takeIf { itchSignedIn && !soundMode }, Store.GAMEJOLT.id.takeIf { gameJoltSignedIn && !soundMode }, Library.ADDED.takeIf { stores }, Store.BATTLENET.id.takeIf { stores }).toSet() + signInChips,
|
||||
alwaysLibraryTabs(owned.keys, stores, soundMode) + signInChips,
|
||||
favorites, concealed,
|
||||
offStores = if (soundMode) emptySet() else storeTabs.filterNot { it.shown }.map { it.store.id }.toSet(),
|
||||
places = if (soundMode) DEFAULT_LIBRARY_PLACES else StoreTabsState.libraryPlaces,
|
||||
|
||||
@@ -4310,4 +4310,5 @@
|
||||
<string name="steam_store_linux_build">تثبّت هذه اللعبة إصدار Linux الخاص بها. ثبّتها من Steam.</string>
|
||||
<string name="game_zoom_title">تكبير اللعبة</string>
|
||||
<string name="game_zoom_hint">اضبط تكبير اللعبة من 100% إلى 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam في وضع عدم الاتصال ولم يحمّل %1$s بعد. اتصل بالإنترنت في Steam مرة واحدة لتشغيلها.</string>
|
||||
</resources>
|
||||
@@ -4188,4 +4188,5 @@
|
||||
<string name="steam_store_close_steam">Cierra Steam primero</string>
|
||||
<string name="steam_store_session_wait">Pausa primero la descarga de Steam</string>
|
||||
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
|
||||
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y todavía no cargó %1$s. Conéctate en Steam una vez para jugarlo.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Тази игра инсталира версията си за Linux. Инсталирайте я от Steam.</string>
|
||||
<string name="game_zoom_title">Мащабиране на играта</string>
|
||||
<string name="game_zoom_hint">Регулирайте увеличението на играта от 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam е в офлайн режим и още не е заредил %1$s. Свържете Steam онлайн веднъж, за да я играете.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Tato hra instaluje svou verzi pro Linux. Nainstalujte ji ze Steamu.</string>
|
||||
<string name="game_zoom_title">Přiblížení hry</string>
|
||||
<string name="game_zoom_hint">Nastavte zvětšení hry od 100 % do 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam je v režimu offline a %1$s ještě nenačetl. Jednou se ve Steamu připojte online, abyste ji mohli hrát.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dette spil installerer sin Linux-version. Installer det fra Steam.</string>
|
||||
<string name="game_zoom_title">Spilzoom</string>
|
||||
<string name="game_zoom_hint">Juster spillets forstørrelse fra 100 % til 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam er i offlinetilstand og har ikke indlæst %1$s endnu. Gå online i Steam én gang for at spille det.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dieses Spiel installiert seine Linux-Version. Installiere es über Steam.</string>
|
||||
<string name="game_zoom_title">Spielzoom</string>
|
||||
<string name="game_zoom_hint">Spielvergrößerung von 100 % bis 300 % anpassen</string>
|
||||
<string name="game_steam_offline_uncached">Steam ist im Offlinemodus und hat %1$s noch nicht geladen. Gehe einmal in Steam online, um es zu spielen.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Αυτό το παιχνίδι εγκαθιστά την έκδοσή του για Linux. Εγκαταστήστε το από το Steam.</string>
|
||||
<string name="game_zoom_title">Ζουμ παιχνιδιού</string>
|
||||
<string name="game_zoom_hint">Ρυθμίστε τη μεγέθυνση του παιχνιδιού από 100% έως 300%</string>
|
||||
<string name="game_steam_offline_uncached">Το Steam είναι σε λειτουργία εκτός σύνδεσης και δεν έχει φορτώσει ακόμη το %1$s. Συνδεθείτε μία φορά στο Steam για να το παίξετε.</string>
|
||||
</resources>
|
||||
@@ -4190,4 +4190,5 @@
|
||||
<string name="steam_store_linux_build">Este juego instala su versión para Linux. Instálalo desde Steam.</string>
|
||||
<string name="game_zoom_title">Zoom del juego</string>
|
||||
<string name="game_zoom_hint">Ajusta la ampliación del juego del 100 % al 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam está en modo sin conexión y aún no ha cargado %1$s. Conéctate en Steam una vez para jugarlo.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Tämä peli asentaa Linux-versionsa. Asenna se Steamista.</string>
|
||||
<string name="game_zoom_title">Pelin zoomaus</string>
|
||||
<string name="game_zoom_hint">Säädä pelin suurennusta välillä 100–300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam on offline-tilassa eikä ole vielä ladannut peliä %1$s. Siirry Steamissa kerran online-tilaan pelataksesi sitä.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Ce jeu installe sa version Linux. Installez-le depuis Steam.</string>
|
||||
<string name="game_zoom_title">Zoom du jeu</string>
|
||||
<string name="game_zoom_hint">Réglez le grossissement du jeu de 100 % à 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam est en mode hors ligne et n\'a pas encore chargé %1$s. Passez en ligne une fois dans Steam pour y jouer.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">यह गेम अपना Linux संस्करण इंस्टॉल करता है। इसे Steam से इंस्टॉल करें।</string>
|
||||
<string name="game_zoom_title">गेम ज़ूम</string>
|
||||
<string name="game_zoom_hint">गेम का ज़ूम 100% से 300% तक समायोजित करें</string>
|
||||
<string name="game_steam_offline_uncached">Steam ऑफ़लाइन मोड में है और उसने अभी तक %1$s लोड नहीं किया है। इसे खेलने के लिए Steam में एक बार ऑनलाइन जाएँ।</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Ez a játék a Linux-verzióját telepíti. Telepítsd a Steamből.</string>
|
||||
<string name="game_zoom_title">Játék nagyítása</string>
|
||||
<string name="game_zoom_hint">A játék nagyításának beállítása 100% és 300% között</string>
|
||||
<string name="game_steam_offline_uncached">A Steam offline módban van, és még nem töltötte be ezt: %1$s. A játékhoz egyszer lépj online módba a Steamben.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Game ini memasang versi Linux-nya. Pasang dari Steam.</string>
|
||||
<string name="game_zoom_title">Zoom game</string>
|
||||
<string name="game_zoom_hint">Sesuaikan pembesaran game dari 100% hingga 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam dalam mode luring dan belum memuat %1$s. Hubungkan Steam secara daring sekali untuk memainkannya.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Questo gioco installa la sua versione Linux. Installalo da Steam.</string>
|
||||
<string name="game_zoom_title">Zoom del gioco</string>
|
||||
<string name="game_zoom_hint">Regola l\'ingrandimento del gioco dal 100% al 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam è in modalità offline e non ha ancora caricato %1$s. Vai online in Steam una volta per giocarci.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">このゲームは Linux 版をインストールします。Steam からインストールしてください。</string>
|
||||
<string name="game_zoom_title">ゲームズーム</string>
|
||||
<string name="game_zoom_hint">ゲームの拡大率を100%から300%の間で調整します</string>
|
||||
<string name="game_steam_offline_uncached">Steam はオフラインモードのため、%1$s をまだ読み込んでいません。プレイするには Steam で一度オンラインにしてください。</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">이 게임은 Linux 버전을 설치합니다. Steam에서 설치하세요.</string>
|
||||
<string name="game_zoom_title">게임 확대</string>
|
||||
<string name="game_zoom_hint">게임 확대율을 100%에서 300%까지 조정합니다</string>
|
||||
<string name="game_steam_offline_uncached">Steam이 오프라인 모드이며 아직 %1$s을(를) 불러오지 않았습니다. 플레이하려면 Steam에서 한 번 온라인으로 전환하세요.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Permainan ini memasang versi Linuxnya. Pasang daripada Steam.</string>
|
||||
<string name="game_zoom_title">Zum permainan</string>
|
||||
<string name="game_zoom_hint">Laraskan pembesaran permainan daripada 100% hingga 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam dalam mod luar talian dan belum memuatkan %1$s. Pergi dalam talian dalam Steam sekali untuk memainkannya.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Dette spillet installerer Linux-versjonen sin. Installer det fra Steam.</string>
|
||||
<string name="game_zoom_title">Spillzoom</string>
|
||||
<string name="game_zoom_hint">Juster spillforstørrelsen fra 100 % til 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam er i frakoblet modus og har ikke lastet inn %1$s ennå. Gå tilkoblet i Steam én gang for å spille det.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Deze game installeert zijn Linux-versie. Installeer hem via Steam.</string>
|
||||
<string name="game_zoom_title">Gamezoom</string>
|
||||
<string name="game_zoom_hint">Pas de spelvergroting aan van 100% tot 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam staat in offlinemodus en heeft %1$s nog niet geladen. Ga één keer online in Steam om het te spelen.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Ta gra instaluje swoją wersję dla Linuksa. Zainstaluj ją ze Steama.</string>
|
||||
<string name="game_zoom_title">Powiększenie gry</string>
|
||||
<string name="game_zoom_hint">Dostosuj powiększenie gry w zakresie od 100% do 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam jest w trybie offline i nie wczytał jeszcze %1$s. Przejdź raz do trybu online w Steamie, aby w to zagrać.</string>
|
||||
</resources>
|
||||
@@ -4189,4 +4189,5 @@
|
||||
<string name="steam_store_linux_build">Este jogo instala a sua versão para Linux. Instale-o a partir do Steam.</string>
|
||||
<string name="game_zoom_title">Zoom do jogo</string>
|
||||
<string name="game_zoom_hint">Ajuste a ampliação do jogo de 100% a 300%</string>
|
||||
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
|
||||
</resources>
|
||||
@@ -4197,4 +4197,5 @@
|
||||
<string name="steam_store_close_steam">Feche o Steam primeiro</string>
|
||||
<string name="steam_store_session_wait">Pause o download do Steam primeiro</string>
|
||||
<string name="steam_store_linux_build">Este jogo instala sua versão para Linux. Instale-o pelo Steam.</string>
|
||||
<string name="game_steam_offline_uncached">O Steam está no modo offline e ainda não carregou %1$s. Fique online no Steam uma vez para jogar.</string>
|
||||
</resources>
|
||||
@@ -4190,4 +4190,5 @@
|
||||
<string name="steam_store_linux_build">Acest joc își instalează versiunea pentru Linux. Instalează-l din Steam.</string>
|
||||
<string name="game_zoom_title">Zoom joc</string>
|
||||
<string name="game_zoom_hint">Reglați mărirea jocului între 100% și 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam este în modul offline și nu a încărcat încă %1$s. Treci o dată online în Steam ca să îl joci.</string>
|
||||
</resources>
|
||||
@@ -4231,4 +4231,5 @@
|
||||
<string name="steam_store_linux_build">Эта игра устанавливает свою версию для Linux. Установите её из Steam.</string>
|
||||
<string name="game_zoom_title">Масштаб игры</string>
|
||||
<string name="game_zoom_hint">Настройте увеличение игры от 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam в автономном режиме и ещё не загрузил %1$s. Чтобы играть, один раз переведите Steam в сеть.</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Det här spelet installerar sin Linux-version. Installera det från Steam.</string>
|
||||
<string name="game_zoom_title">Spelzoom</string>
|
||||
<string name="game_zoom_hint">Justera spelförstoringen från 100 % till 300 %</string>
|
||||
<string name="game_steam_offline_uncached">Steam är i offlineläge och har inte läst in %1$s än. Gå online i Steam en gång för att spela det.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">เกมนี้ติดตั้งเวอร์ชัน Linux ของตัวเอง ให้ติดตั้งจาก Steam</string>
|
||||
<string name="game_zoom_title">ซูมเกม</string>
|
||||
<string name="game_zoom_hint">ปรับการขยายเกมตั้งแต่ 100% ถึง 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam อยู่ในโหมดออฟไลน์และยังไม่ได้โหลด %1$s ออนไลน์ใน Steam หนึ่งครั้งเพื่อเล่นเกมนี้</string>
|
||||
</resources>
|
||||
@@ -4150,4 +4150,5 @@
|
||||
<string name="steam_store_linux_build">Bu oyun Linux sürümünü yükler. Steam\'den yükleyin.</string>
|
||||
<string name="game_zoom_title">Oyun yakınlaştırma</string>
|
||||
<string name="game_zoom_hint">Oyun yakınlaştırmasını %100 ile %300 arasında ayarlayın</string>
|
||||
<string name="game_steam_offline_uncached">Steam çevrimdışı modda ve %1$s henüz yüklenmedi. Oynamak için Steam\'de bir kez çevrimiçi olun.</string>
|
||||
</resources>
|
||||
@@ -4230,4 +4230,5 @@
|
||||
<string name="steam_store_linux_build">Ця гра встановлює свою версію для Linux. Установіть її зі Steam.</string>
|
||||
<string name="game_zoom_title">Масштаб гри</string>
|
||||
<string name="game_zoom_hint">Налаштуйте збільшення гри від 100% до 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam в офлайн-режимі й ще не завантажив %1$s. Щоб грати, один раз перейдіть у Steam онлайн.</string>
|
||||
</resources>
|
||||
@@ -4120,4 +4120,5 @@
|
||||
<string name="steam_store_linux_build">Trò chơi này cài bản dành cho Linux. Hãy cài từ Steam.</string>
|
||||
<string name="game_zoom_title">Thu phóng trò chơi</string>
|
||||
<string name="game_zoom_hint">Điều chỉnh độ phóng đại trò chơi từ 100% đến 300%</string>
|
||||
<string name="game_steam_offline_uncached">Steam đang ở chế độ ngoại tuyến và chưa tải %1$s. Hãy trực tuyến trong Steam một lần để chơi.</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">请先关闭 Steam</string>
|
||||
<string name="steam_store_session_wait">请先暂停 Steam 下载</string>
|
||||
<string name="steam_store_linux_build">此游戏会安装其 Linux 版本。请通过 Steam 安装。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 处于离线模式,尚未加载 %1$s。请在 Steam 中联网一次后再玩。</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">請先關閉 Steam</string>
|
||||
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
|
||||
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
|
||||
</resources>
|
||||
@@ -4118,4 +4118,5 @@
|
||||
<string name="steam_store_close_steam">請先關閉 Steam</string>
|
||||
<string name="steam_store_session_wait">請先暫停 Steam 下載</string>
|
||||
<string name="steam_store_linux_build">此遊戲會安裝其 Linux 版本。請透過 Steam 安裝。</string>
|
||||
<string name="game_steam_offline_uncached">Steam 處於離線模式,尚未載入 %1$s。請在 Steam 中連線一次後再玩。</string>
|
||||
</resources>
|
||||
@@ -1755,6 +1755,7 @@
|
||||
<string name="game_link_session_busy">Stop the current session before launching a Steam game.</string>
|
||||
<string name="game_link_failed">Could not send the game to Steam. Try launching it again.</string>
|
||||
<string name="game_needs_app_model">%1$s is a UWP app. This runtime has no Windows app-model host to start it.</string>
|
||||
<string name="game_steam_offline_uncached">Steam is in offline mode and has not loaded %1$s yet. Go online in Steam once to play it.</string>
|
||||
<string name="setup_retry_removal">Retry removal</string>
|
||||
<string name="runtime_removing">Removing</string>
|
||||
<string name="runtime_removal_incomplete">Removal incomplete</string>
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.droiddeck.launcher.frontend
|
||||
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class SteamAppInfoTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
private fun file() = File(tmp.newFolder(), "appinfo.vdf")
|
||||
|
||||
private fun le(size: Int) = ByteBuffer.allocate(size).order(ByteOrder.LITTLE_ENDIAN)
|
||||
|
||||
private fun writeV28(file: File, appId: Int, name: String) {
|
||||
val kv = ByteArrayOutputStream().apply {
|
||||
fun cstring(s: String) { write(s.toByteArray()); write(0) }
|
||||
write(0x00); cstring("appinfo")
|
||||
write(0x00); cstring("common")
|
||||
write(0x01); cstring("name"); cstring(name)
|
||||
write(0x08); write(0x08); write(0x08)
|
||||
}.toByteArray()
|
||||
val body = ByteArray(60) + kv
|
||||
val out = le(8 + 8 + body.size + 4).putInt(0x07564428).putInt(1).putInt(appId).putInt(body.size).put(body).putInt(0)
|
||||
file.writeBytes(out.array())
|
||||
}
|
||||
|
||||
@Test fun anAppInTheClientsCacheIsToldApartFromOneMissingFromIt() {
|
||||
val file = file()
|
||||
WinCompSourcesTest.writeAppinfo(file, 17470)
|
||||
assertEquals(true, SteamAppInfo.cached(file, 17470))
|
||||
assertEquals(false, SteamAppInfo.cached(file, 1145360))
|
||||
}
|
||||
|
||||
@Test fun theOlderFormatWithoutAStringTableIsReadToo() {
|
||||
val file = file()
|
||||
writeV28(file, 17470, "Some Game")
|
||||
assertTrue(SteamAppInfo.cached(file, 17470)!!)
|
||||
assertFalse(SteamAppInfo.cached(file, 22330)!!)
|
||||
assertEquals("Some Game", SteamAppInfo.read(file, 17470)!!.name)
|
||||
assertNull(SteamAppInfo.read(file, 22330))
|
||||
}
|
||||
|
||||
@Test fun aMissingOrUnknownCacheIsNotTakenAsMissingTheApp() {
|
||||
val missing = file()
|
||||
assertNull(SteamAppInfo.cached(missing, 17470))
|
||||
val newer = file().apply { writeBytes(le(16).putInt(0x0756442A).putInt(1).array()) }
|
||||
assertNull(SteamAppInfo.cached(newer, 17470))
|
||||
val garbage = file().apply { writeBytes(byteArrayOf(1, 2, 3)) }
|
||||
assertNull(SteamAppInfo.cached(garbage, 17470))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import java.io.File
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.file.Files
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
class NativeGuestPrepareTest {
|
||||
private val svc = 0xd4000001.toInt()
|
||||
private val rseq = 0xd28024a8.toInt()
|
||||
private val enosys = 0x928004a0.toInt()
|
||||
|
||||
private fun unpatchedLoader(): ByteArray {
|
||||
val data = ByteArray(0x200)
|
||||
val b = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN)
|
||||
b.put(0, 0x7f); b.put(1, 'E'.code.toByte()); b.put(2, 'L'.code.toByte()); b.put(3, 'F'.code.toByte())
|
||||
b.put(4, 2); b.put(5, 1)
|
||||
b.putShort(18, 183)
|
||||
b.putLong(32, 64)
|
||||
b.putShort(54, 56); b.putShort(56, 1)
|
||||
b.putInt(64, 1); b.putInt(68, 5)
|
||||
b.putLong(72, 0x100); b.putLong(96, 0x100)
|
||||
b.putInt(0x100, rseq); b.putInt(0x104, svc)
|
||||
return data
|
||||
}
|
||||
|
||||
private fun rootWithUnpatchedLoader(): Pair<File, File> {
|
||||
val root = Files.createTempDirectory("native-prepare").toFile()
|
||||
val loader = File(root, "usr/lib/ld-linux-aarch64.so.1")
|
||||
loader.parentFile!!.mkdirs()
|
||||
loader.writeBytes(unpatchedLoader())
|
||||
return root to loader
|
||||
}
|
||||
|
||||
private fun instructionAfterRseq(loader: File): Int =
|
||||
ByteBuffer.wrap(loader.readBytes()).order(ByteOrder.LITTLE_ENDIAN).getInt(0x104)
|
||||
|
||||
@After
|
||||
fun endSession() {
|
||||
NativeGuest.sessionMode = null
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aProgramStartedOutsideASessionGetsALoaderThatSurvivesSeccomp() {
|
||||
val (root, loader) = rootWithUnpatchedLoader()
|
||||
NativeGuest.sessionMode = null
|
||||
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
|
||||
assertEquals(enosys, instructionAfterRseq(loader))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aProgramStartedInARunningSessionLeavesTheRootfsAsTheSessionPreparedIt() {
|
||||
val (root, loader) = rootWithUnpatchedLoader()
|
||||
val before = loader.readBytes()
|
||||
NativeGuest.sessionMode = true
|
||||
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
|
||||
assertArrayEquals(before, loader.readBytes())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun anAlreadyPreparedLoaderIsNotRewritten() {
|
||||
val (root, loader) = rootWithUnpatchedLoader()
|
||||
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
|
||||
val modified = loader.lastModified()
|
||||
val bytes = loader.readBytes()
|
||||
loader.setLastModified(modified - 10_000)
|
||||
NativeGuest.processBuilder(ApplicationProvider.getApplicationContext(), root, emptyList(), listOf("/usr/bin/true"))
|
||||
assertArrayEquals(bytes, loader.readBytes())
|
||||
assertEquals(modified - 10_000, loader.lastModified())
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,32 @@ class OfflineModeTest {
|
||||
shadowOf(cm).setNetworkCapabilities(cm.activeNetwork, caps)
|
||||
}
|
||||
|
||||
private fun clientCache(appId: Int) =
|
||||
com.droiddeck.launcher.frontend.WinCompSourcesTest.writeAppinfo(com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context), appId)
|
||||
|
||||
@Test
|
||||
fun offlineSteamReportsAGameMissingFromItsCache() {
|
||||
writeSteam("1")
|
||||
clientCache(220)
|
||||
assertTrue(OfflineMode.active(context))
|
||||
assertTrue(OfflineMode.lacksAppInfo(context, 17470))
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 220))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onlineSteamNeverReportsAMissingGame() {
|
||||
clientCache(220)
|
||||
assertFalse(OfflineMode.active(context))
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offlineSteamWithoutAReadableCacheReportsNothing() {
|
||||
writeSteam("1")
|
||||
com.droiddeck.launcher.frontend.SteamAppInfo.appinfoFile(context).delete()
|
||||
assertFalse(OfflineMode.lacksAppInfo(context, 17470))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offlineWhenChosenOrWithoutInternet() {
|
||||
assertFalse(OfflineMode.offline(manual = false, online = true))
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -122,6 +122,19 @@ class LibraryEntriesTest {
|
||||
assertEquals(listOf("steam", "xbox", "itch", "gamejolt"), librarySources(entries, listOf("xbox", "itch", "gamejolt"), setOf("itch", "gamejolt")))
|
||||
}
|
||||
|
||||
@Test fun everySignedInStoreKeepsItsTabWhenItsLibraryIsEmptyOrFailedToLoad() {
|
||||
val entries = listOf(LibraryEntry("epic:1", "epic", "Game", null, null, true))
|
||||
val order = listOf("epic", Store.ROCKSTAR.id, "gog")
|
||||
val always = alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = false)
|
||||
assertEquals(listOf("steam", "epic", "rockstar", "battlenet", "added"), librarySources(entries, order, always))
|
||||
}
|
||||
|
||||
@Test fun signedOutStoresAndSoundtrackModeDoNotGainEmptyTabs() {
|
||||
assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(emptyList(), stores = true, soundMode = false))
|
||||
assertEquals(setOf("added", "battlenet"), alwaysLibraryTabs(listOf(Store.STEAM, Store.ROCKSTAR), stores = true, soundMode = true))
|
||||
assertEquals(emptySet<String>(), alwaysLibraryTabs(emptyList(), stores = false, soundMode = false))
|
||||
}
|
||||
|
||||
@Test fun gameKeysNameEitherAnAppOrAStoreProduct() {
|
||||
GameRef.parse("app:440").let { assertEquals(440, it.appId); assertNull(it.store) }
|
||||
GameRef.parse("app:-12").let { assertEquals(-12, it.appId) }
|
||||
|
||||
@@ -193,6 +193,15 @@ A Unity game under FEX (`UnityPlayer.dll` for Windows builds under Proton,
|
||||
turns it off: without TSO such games can deadlock or crash (seen with Megabonk
|
||||
and Crab Game). A FEX preset chosen for the game itself still applies.
|
||||
|
||||
An Inno Setup installer added as a game runs with the Stability preset's FEX
|
||||
settings (full TSO, full x87 precision, no multiblock). Under the default
|
||||
Performance + TSO preset the 32-bit setup stub corrupts its own paths and stops
|
||||
with Wine's "Path not fpund." dialog (#1277, #3067). The stub is found by the
|
||||
setup loader's offset-table ID in its resources, or by the `Inno` marker that
|
||||
loaders older than 5.1.5 keep at offset 0x30. GOG installs avoid the stub by
|
||||
extracting natively. A FEX preset chosen for the installer's own entry still
|
||||
applies.
|
||||
|
||||
Games launched through Proton get `vblank_mode=0`, so OpenGL does not wait for
|
||||
each screen refresh. Wine asks for a swap interval of 1 on every OpenGL window, and WineD3D's front-buffer
|
||||
drawing (DirectDraw, Direct3D 1–7) never lowers it, so those games ran at the
|
||||
|
||||
@@ -150,6 +150,19 @@ The SPIR-V version the driver gets:
|
||||
- This is what Dawn ("Disable SPIR-V 1.4 on Android ARM"), ANGLE (`supportsSPIRV14`) and naga
|
||||
(`AVOID_SPIRV_COPY_LOGICAL`) do for a proprietary compiler they cannot trust.
|
||||
|
||||
Geometry shaders:
|
||||
- The Mali-G610's driver (r38p1) crashes compiling Zink's geometry shaders, always at the same
|
||||
place (SIGSEGV at 0x40 in `cmpbe_v2_compile_multiple_shaders`): its shader for `GL_QUADS`, and
|
||||
a GLSL geometry shader that only passes triangles on.
|
||||
- A geometry shader that only passes triangles on, from a plain Vulkan program, does not crash it
|
||||
but draws nothing, in SPIR-V 1.0, 1.3 and 1.6, with and without the layer.
|
||||
- Zink writes them in SPIR-V 1.6 with the Vulkan memory model, which the version cap leaves alone.
|
||||
Lowering them would not help, since the plain shader draws nothing at 1.0 and 1.3 either.
|
||||
- On ARM GPUs the layer reports no `geometryShader` to Zink (engine name `mesa zink`). Mesa then
|
||||
splits quads into triangles itself, and Zink still offers OpenGL 3.2. DXVK keeps the feature: it
|
||||
needs it for D3D10 and 11.
|
||||
- `DROIDDECK_MALI_COMPAT_NO_GS=0` keeps the feature for Zink, `=1` hides it from every application.
|
||||
|
||||
Files:
|
||||
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
|
||||
- `pipeline.c`: pipelines, shader modules, viewports.
|
||||
|
||||
@@ -66,6 +66,69 @@ DOTNET_FEX = {
|
||||
"FEX_HALFBARRIERTSOENABLED": "1",
|
||||
"FEX_X87REDUCEDPRECISION": "0",
|
||||
}
|
||||
STABILITY_FEX = dict(DOTNET_FEX, FEX_MULTIBLOCK="0")
|
||||
# Setup loader offset-table IDs, as innoextract's known_setup_loader_versions lists them. Loaders
|
||||
# from 5.1.5 keep the table in a resource; older ones also put "Inno" at file offset 0x30.
|
||||
INNO_LOADER_IDS = (b"rDlPtS", b"nS5W7dT\x83\xaa\x1b\x0fj")
|
||||
INNO_RESOURCE_LIMIT = 4 << 20
|
||||
|
||||
|
||||
def is_inno_setup(path):
|
||||
try:
|
||||
with open(path, "rb") as exe:
|
||||
head = exe.read(4096)
|
||||
if head[:2] != b"MZ":
|
||||
return False
|
||||
if head[0x30:0x34] == b"Inno":
|
||||
return True
|
||||
pe = int.from_bytes(head[0x3C:0x40], "little")
|
||||
if head[pe:pe + 4] != b"PE\0\0" or int.from_bytes(head[pe + 4:pe + 6], "little") != 0x14C:
|
||||
return False
|
||||
count = int.from_bytes(head[pe + 6:pe + 8], "little")
|
||||
table = pe + 24 + int.from_bytes(head[pe + 20:pe + 22], "little")
|
||||
for entry in range(table, table + 40 * count, 40):
|
||||
if head[entry:entry + 8].rstrip(b"\0") == b".rsrc":
|
||||
exe.seek(int.from_bytes(head[entry + 20:entry + 24], "little"))
|
||||
size = int.from_bytes(head[entry + 16:entry + 20], "little")
|
||||
resources = exe.read(min(size, INNO_RESOURCE_LIMIT))
|
||||
return any(marker in resources for marker in INNO_LOADER_IDS)
|
||||
except OSError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
STORE_LAUNCHER = ".droiddeck-launch.bat"
|
||||
STORE_SIDECAR = ".droiddeck-store.json"
|
||||
|
||||
|
||||
def store_game_exe(exe):
|
||||
if os.path.basename(exe).lower() != STORE_LAUNCHER:
|
||||
return exe
|
||||
folder = os.path.dirname(exe)
|
||||
try:
|
||||
with open(os.path.join(folder, STORE_SIDECAR), encoding="utf-8") as source:
|
||||
sidecar = json.load(source)
|
||||
except (OSError, ValueError):
|
||||
return exe
|
||||
target = sidecar.get("exe") if isinstance(sidecar, dict) else None
|
||||
if not isinstance(target, str) or not target.strip() or "\0" in target:
|
||||
return exe
|
||||
normalized = target.replace("\\", "/")
|
||||
if ":" in normalized or normalized.startswith("/") or ".." in normalized.split("/"):
|
||||
return exe
|
||||
relative = os.path.normpath(normalized)
|
||||
if os.path.isabs(relative) or relative in (".", "..") or relative.startswith(".." + os.sep):
|
||||
return exe
|
||||
candidate = os.path.join(folder, relative)
|
||||
if not os.path.isfile(candidate):
|
||||
return exe
|
||||
root = os.path.realpath(folder)
|
||||
try:
|
||||
if os.path.commonpath((root, os.path.realpath(candidate))) != root:
|
||||
return exe
|
||||
except ValueError:
|
||||
return exe
|
||||
return candidate
|
||||
|
||||
|
||||
def game_files(exe):
|
||||
@@ -89,6 +152,7 @@ def game_files(exe):
|
||||
class Game:
|
||||
|
||||
def __init__(self, exe, args, app_id=""):
|
||||
exe = store_game_exe(exe)
|
||||
self.exe = exe
|
||||
self.args = args
|
||||
self.app_id = app_id
|
||||
@@ -191,6 +255,12 @@ def split_second_x87_fip(game):
|
||||
return {"FEX_JITFEATURES": "enablex87fip"}, [], "Split/Second: FEX x87 FIP emulation on (its SecuROM stops with error 8016 without it)"
|
||||
|
||||
|
||||
@fix
|
||||
def inno_setup_stability(game):
|
||||
if is_inno_setup(game.exe):
|
||||
return STABILITY_FEX, [], "Inno Setup installer: FEX Stability settings (under Performance + TSO the 32-bit setup stub corrupts its own paths)"
|
||||
|
||||
|
||||
@fix
|
||||
def doom_2016_swapchain_images(game):
|
||||
if "doomx64vk.exe" in game.files and game.stem in ("doomx64", "doomx64vk"):
|
||||
@@ -273,7 +343,7 @@ def with_system_settings(text, settings):
|
||||
|
||||
# The game ignores -ini: overrides and deletes a writable Engine.ini after reading it, so this runs at every launch.
|
||||
def dragon_quest_monsters_4_mesh_detail(exe, env):
|
||||
project = Path(exe).stem.split("-", 1)[0]
|
||||
project = Path(store_game_exe(exe)).stem.split("-", 1)[0]
|
||||
if not project.lower().startswith("dragonquestmonsters4"):
|
||||
return
|
||||
prefix = Path(env.get("STEAM_COMPAT_DATA_PATH", "/nonexistent")) / "pfx"
|
||||
@@ -398,7 +468,7 @@ def zomboid_rewrite(node):
|
||||
def project_zomboid_jvm(command):
|
||||
if len(command) <= 2:
|
||||
return
|
||||
exe = Path(command[2])
|
||||
exe = Path(store_game_exe(command[2]))
|
||||
if not exe.stem.lower().startswith("projectzomboid"):
|
||||
return
|
||||
settings = exe.with_suffix(".json")
|
||||
@@ -721,12 +791,15 @@ def apply_config(env, config, app_id, fixes=None):
|
||||
|
||||
|
||||
def render_path_defaults(command, env):
|
||||
if len(command) < 3 or command[1] != "waitforexitandrun" or Path(command[2]).name.lower() != "spintires.exe":
|
||||
if len(command) < 3 or command[1] != "waitforexitandrun":
|
||||
return None
|
||||
exe = Path(store_game_exe(command[2]))
|
||||
if exe.name.lower() != "spintires.exe":
|
||||
return None
|
||||
own = env.get("DXVK_CONFIG", "")
|
||||
if re.search(r"(?:^|;)\s*dxvk\.tilerMode\s*=", own) or env.get("DXVK_CONFIG_FILE"):
|
||||
return None
|
||||
if Path("dxvk.conf").is_file() or Path(command[2]).with_name("dxvk.conf").is_file():
|
||||
if Path("dxvk.conf").is_file() or exe.with_name("dxvk.conf").is_file():
|
||||
return None
|
||||
driver = env.get("VK_DRIVER_FILES", env.get("VK_ICD_FILENAMES", ""))
|
||||
if Path(driver).parent.name != "DD-Turnip_v0.4.0":
|
||||
@@ -1290,7 +1363,7 @@ def dirt_ws2_wanted(command, env):
|
||||
prefix = env.get("STEAM_COMPAT_DATA_PATH", "").rstrip("/")
|
||||
if len(command) < 3 or not prefix or not os.path.isfile(DIRT_WS2):
|
||||
return None
|
||||
game = DIRT_GAMES.get(os.path.splitext(os.path.basename(command[2]))[0].lower())
|
||||
game = DIRT_GAMES.get(os.path.splitext(os.path.basename(store_game_exe(command[2])))[0].lower())
|
||||
if not game or not dirt_telemetry_on(prefix, game) or proton_has_dirt_fix(command[0]):
|
||||
return None
|
||||
return prefix if os.path.lexists(prefix_ws2(prefix)) else None
|
||||
@@ -1347,7 +1420,7 @@ def ego_core_plan(command, env):
|
||||
count = windows_core_count(env)
|
||||
if not count or len(command) < 3:
|
||||
return None
|
||||
folder = Path(command[2]).parent
|
||||
folder = Path(store_game_exe(command[2])).parent
|
||||
path = folder / EGO_RESTRICTIONS
|
||||
try:
|
||||
raw = path.read_bytes()
|
||||
@@ -1676,14 +1749,26 @@ def main():
|
||||
if note:
|
||||
print("droiddeck-game-env: " + note, file=sys.stderr)
|
||||
else:
|
||||
# An installer started with the run verb gets the same Stability settings as one started with
|
||||
# waitforexitandrun; explicit game settings still win over them in apply_config.
|
||||
installer = {}
|
||||
if len(command) > 2 and command[1] == "run" and is_inno_setup(command[2]):
|
||||
installer = dict(STABILITY_FEX)
|
||||
print("droiddeck-game-env: Inno Setup installer: FEX Stability settings", file=sys.stderr)
|
||||
path = Path.home() / ".config/droiddeck/game-environment.json"
|
||||
try:
|
||||
with path.open(encoding="utf-8") as source:
|
||||
config = json.load(source)
|
||||
env = apply_config(env, sync_config(config, app_id), app_id)
|
||||
synced = sync_config(config, app_id)
|
||||
if installer:
|
||||
# A FEX preset chosen for the game itself still wins, as on every other launch path.
|
||||
game = config.get("games", {}).get(app_id, {})
|
||||
synced["games"][app_id].update({k: v for k, v in game.items() if k in STABILITY_FEX})
|
||||
env = apply_config(env, synced, app_id, installer)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
env = dict(env, **installer)
|
||||
except (OSError, ValueError, TypeError, AttributeError):
|
||||
env = dict(env, **installer)
|
||||
print("droiddeck-game-env: invalid configuration; using inherited environment", file=sys.stderr)
|
||||
if waiting:
|
||||
before_debug = env
|
||||
|
||||
@@ -224,15 +224,23 @@ if [ -n "${DD_VK_DRIVER:-}" ]; then
|
||||
unset dd_icd_lib
|
||||
fi
|
||||
dd_webhelper_layout() {
|
||||
local layout
|
||||
if [ -n "${DD_VKBRIDGE_WEBHELPER_ARGS:-}" ]; then
|
||||
printf '%s\n' "$DD_VKBRIDGE_WEBHELPER_ARGS"
|
||||
elif [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
|
||||
echo stock
|
||||
elif [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
|
||||
echo "--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
|
||||
else
|
||||
echo "--use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
|
||||
return
|
||||
fi
|
||||
if [ -z "${DD_VKBRIDGE_CEF_ANGLE:-}" ]; then
|
||||
echo stock
|
||||
return
|
||||
fi
|
||||
# ANGLE switches must not replace the helper's stable single-process layout.
|
||||
layout="--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
|
||||
if [ "$DD_VKBRIDGE_CEF_ANGLE" = vulkan ] && [ "${DD_VKBRIDGE_CEF_VULKAN:-1}" != 0 ]; then
|
||||
layout="$layout --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan"
|
||||
else
|
||||
layout="$layout --use-gl=angle --use-angle=$DD_VKBRIDGE_CEF_ANGLE"
|
||||
fi
|
||||
printf '%s\n' "$layout"
|
||||
}
|
||||
dd_now_ms() {
|
||||
if [ -n "${EPOCHREALTIME:-}" ]; then
|
||||
|
||||
@@ -1594,15 +1594,6 @@ STEAM_EA_STATE = ".droiddeck-ea-steam.json"
|
||||
STEAM_EA_CLIENT = "drive_c/Program Files/Electronic Arts/EA Desktop/EA Desktop/EADesktop.exe"
|
||||
STEAM_EA_OFFER = re.compile(r"^(Origin\.OFR\.[0-9]+\.[0-9]+)\.dat$", re.IGNORECASE)
|
||||
REPLACED = 13
|
||||
STEAM_EA_LOCALES = {
|
||||
"arabic": ("ar_SA",), "brazilian": ("pt_BR",), "bulgarian": ("bg_BG",), "czech": ("cs_CZ",), "danish": ("da_DK",),
|
||||
"dutch": ("nl_NL",), "english": ("en_US",), "finnish": ("fi_FI",), "french": ("fr_FR",), "german": ("de_DE",),
|
||||
"greek": ("el_GR",), "hungarian": ("hu_HU",), "indonesian": ("id_ID",), "italian": ("it_IT",), "japanese": ("ja_JP",),
|
||||
"koreana": ("ko_KR",), "latam": ("es_MX",), "malay": ("ms_MY",), "norwegian": ("no_NO", "nb_NO"), "polish": ("pl_PL",),
|
||||
"portuguese": ("pt_PT",), "romanian": ("ro_RO",), "russian": ("ru_RU",), "schinese": ("zh_CN",), "spanish": ("es_ES",),
|
||||
"swedish": ("sv_SE",), "tchinese": ("zh_TW", "zh_HK"), "thai": ("th_TH",), "turkish": ("tr_TR",), "ukrainian": ("uk_UA",),
|
||||
"vietnamese": ("vi_VN",),
|
||||
}
|
||||
|
||||
|
||||
def steam_ea_link(argv):
|
||||
@@ -1632,7 +1623,6 @@ def ea_manifest(folder):
|
||||
launcher = next((l for l in launchers if not l[2]), launchers[0] if launchers else None)
|
||||
version = root.find("buildMetaData/gameVersion")
|
||||
titles = {e.get("locale"): (e.text or "").strip() for e in root.iter("gameTitle") if e.get("locale")}
|
||||
listed = [l.strip() for l in (root.findtext("installMetaData/locales") or "").split(",") if l.strip()]
|
||||
exe = None
|
||||
if launcher is not None:
|
||||
relative = re.sub(r"^\[[^\]]*\]", "", launcher[0]).replace("{installLocation}", "").lstrip("\\/")
|
||||
@@ -1643,7 +1633,6 @@ def ea_manifest(folder):
|
||||
"parameters": launcher[1] if launcher else "",
|
||||
"version": version.get("version", "") if version is not None else "",
|
||||
"title": titles.get("en_US") or next(iter(titles.values()), "") or Path(folder).name,
|
||||
"locales": listed or list(titles),
|
||||
}
|
||||
|
||||
|
||||
@@ -1656,27 +1645,6 @@ def steam_ea_offers(folder):
|
||||
return [m.group(1) for m in map(STEAM_EA_OFFER.match, names) if m]
|
||||
|
||||
|
||||
def steam_game_language(folder, appid):
|
||||
try:
|
||||
text = decode_output((Path(folder).parent.parent / ("appmanifest_%s.acf" % appid)).read_bytes())
|
||||
except OSError:
|
||||
text = ""
|
||||
found = re.search(r'"UserConfig"\s*\{[^{}]*?"language"\s*"([^"]+)"', text, re.IGNORECASE)
|
||||
return found.group(1) if found else os.environ.get("DD_STEAM_LANGUAGE", "")
|
||||
|
||||
|
||||
def steam_ea_locale(available, language):
|
||||
wanted = STEAM_EA_LOCALES.get(language.strip().lower(), ("en_US",))
|
||||
for want in wanted:
|
||||
exact = [l for l in available if l.casefold() == want.casefold()]
|
||||
if exact:
|
||||
return exact[0]
|
||||
prefix = lambda l: l.casefold().split("_", 1)[0]
|
||||
same = [l for l in available if prefix(l) == prefix(wanted[0])]
|
||||
english = [l for l in available if prefix(l) == "en"]
|
||||
return (same or english or ["en_US"])[0]
|
||||
|
||||
|
||||
def batch_text(value):
|
||||
return value.replace("%", "%%").replace('"', "")
|
||||
|
||||
@@ -1723,12 +1691,10 @@ def prepare_steam_ea(argv, compat_data, launch_dir):
|
||||
log("steam ea: no channel to DroidDeck, left to the EA app")
|
||||
return 0
|
||||
exe = manifest["exe"]
|
||||
appid = STEAM_EA_LINK.match(steam_ea_link(argv).strip().strip('"')).group(1)
|
||||
locale = steam_ea_locale(manifest["locales"], steam_game_language(folder, appid))
|
||||
sidecar = {"store": "ea", "id": offers[0], "title": manifest["title"],
|
||||
"extra": {"contentIds": ",".join(manifest["contentIds"]), "displayName": manifest["title"], "locale": locale}}
|
||||
"extra": {"contentIds": ",".join(manifest["contentIds"]), "displayName": manifest["title"], "locale": "en_US"}}
|
||||
steam = {"folder": str(folder), "offers": offers, "contentIds": manifest["contentIds"], "title": manifest["title"],
|
||||
"version": manifest["version"], "locale": locale, "exe": str(exe.relative_to(folder))}
|
||||
"version": manifest["version"], "locale": "en_US", "exe": str(exe.relative_to(folder))}
|
||||
answer = prepare_ea(folder, sidecar, compat_data, launch_dir, steam)
|
||||
env = answer.get("env") if answer and answer.get("ok") else None
|
||||
if not isinstance(env, dict):
|
||||
@@ -1746,7 +1712,7 @@ def prepare_steam_ea(argv, compat_data, launch_dir):
|
||||
except OSError as error:
|
||||
log("steam ea: launcher not written (%s), left to the EA app" % type(error).__name__)
|
||||
return 0
|
||||
log("steam ea: %s starts %s directly as %s in %s" % (manifest["title"], exe.name, answer.get("id") or offers[0], locale))
|
||||
log("steam ea: %s starts %s directly as %s" % (manifest["title"], exe.name, answer.get("id") or offers[0]))
|
||||
return REPLACED
|
||||
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
"NAME=\"Xbox 360 Controller (%d)\"\n" \
|
||||
"PHYS=\"usb-fakeinput/input%d\"\n"
|
||||
|
||||
#define RING_SDL_ID 0x045e028eu
|
||||
|
||||
#define PARENT_NAME "droiddeck-input"
|
||||
#define PARENT_SYSPATH_FORMAT "/sys/devices/droiddeck%d/" PARENT_NAME "%d"
|
||||
#define EVENT_SYSPATH_FORMAT PARENT_SYSPATH_FORMAT "/event%d"
|
||||
@@ -49,6 +51,8 @@ struct pad {
|
||||
int live;
|
||||
};
|
||||
|
||||
static const char *ring_uevent_format(void);
|
||||
|
||||
static struct pad pads[PAD_MAX];
|
||||
static struct pad parents[PAD_MAX];
|
||||
static int pad_count;
|
||||
@@ -89,7 +93,7 @@ static void discover_pads(void) {
|
||||
snprintf(pad->syspath, sizeof(pad->syspath), EVENT_SYSPATH_FORMAT, (int)slot, (int)slot,
|
||||
(int)slot);
|
||||
snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%ld", slot);
|
||||
snprintf(pad->uevent, sizeof(pad->uevent), PAD_UEVENT_FORMAT, (int)slot, (int)slot);
|
||||
snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), (int)slot, (int)slot);
|
||||
pad->devnum = makedev(13, EVENT_MINOR_BASE + (unsigned int)slot);
|
||||
pad->node = (int)slot;
|
||||
pad->live = 1;
|
||||
@@ -137,6 +141,68 @@ static int any_virtual_pad(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *sdl_id_list_text(const char *list) {
|
||||
char *text = NULL;
|
||||
char *grown;
|
||||
size_t length = 0;
|
||||
size_t got;
|
||||
FILE *file;
|
||||
|
||||
if (list[0] != '@') return strdup(list);
|
||||
file = fopen(list + 1, "re");
|
||||
if (file == NULL) return NULL;
|
||||
do {
|
||||
grown = realloc(text, length + 4097);
|
||||
if (grown == NULL) {
|
||||
free(text);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
text = grown;
|
||||
got = fread(text + length, 1, 4096, file);
|
||||
length += got;
|
||||
} while (got > 0);
|
||||
fclose(file);
|
||||
text[length] = '\0';
|
||||
return text;
|
||||
}
|
||||
|
||||
static int sdl_id_list_entries(const char *list, int *has_ring) {
|
||||
char *text = sdl_id_list_text(list);
|
||||
char *spot = text;
|
||||
uint32_t entry;
|
||||
int entries = 0;
|
||||
|
||||
*has_ring = 0;
|
||||
if (text == NULL) return 0;
|
||||
while ((spot = strstr(spot, "0x")) != NULL) {
|
||||
entry = (uint32_t)(uint16_t)strtol(spot, &spot, 0) << 16;
|
||||
spot = strstr(spot, "0x");
|
||||
if (spot == NULL) break;
|
||||
entry |= (uint16_t)strtol(spot, &spot, 0);
|
||||
entries++;
|
||||
if (entry == RING_SDL_ID) *has_ring = 1;
|
||||
}
|
||||
free(text);
|
||||
return entries;
|
||||
}
|
||||
|
||||
static int sdl_bus_skips_ring_pad(void) {
|
||||
const char *steam_virtual = getenv("FAKE_EVDEV_STEAM_VIRTUAL");
|
||||
const char *except = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT");
|
||||
const char *ignore = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
int has_ring;
|
||||
|
||||
if (steam_virtual != NULL && atoi(steam_virtual) != 0) return 1;
|
||||
if (except != NULL && sdl_id_list_entries(except, &has_ring) > 0) return !has_ring;
|
||||
return ignore != NULL && sdl_id_list_entries(ignore, &has_ring) > 0 && has_ring;
|
||||
}
|
||||
|
||||
static const char *ring_uevent_format(void) {
|
||||
if (uinput_enabled() && any_virtual_pad()) return PAD_PHYSICAL_UEVENT_FORMAT;
|
||||
return sdl_bus_skips_ring_pad() ? PAD_UEVENT_FORMAT : PAD_PHYSICAL_UEVENT_FORMAT;
|
||||
}
|
||||
|
||||
static void refresh_locked(int node) {
|
||||
struct pad *pad = &pads[node];
|
||||
|
||||
@@ -167,9 +233,7 @@ static void refresh_locked(int node) {
|
||||
} else {
|
||||
snprintf(pad->devnode, sizeof(pad->devnode), "/dev/input/event%d", node);
|
||||
pad->live = 1;
|
||||
if (uinput_enabled())
|
||||
snprintf(pad->uevent, sizeof(pad->uevent),
|
||||
any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT, node, node);
|
||||
snprintf(pad->uevent, sizeof(pad->uevent), ring_uevent_format(), node, node);
|
||||
}
|
||||
}
|
||||
sync_parent(node);
|
||||
@@ -441,11 +505,48 @@ static void *next_symbol(const char *name) {
|
||||
char *dd_cached_realpath(const char *path, char *resolved, char *(*real)(const char *, char *))
|
||||
__attribute__((visibility("hidden")));
|
||||
|
||||
static int caller_is_winebus(void *caller) {
|
||||
static int caller_in_library(void *caller, const char *library) {
|
||||
Dl_info info;
|
||||
|
||||
if (dladdr(caller, &info) == 0 || info.dli_fname == NULL) return 0;
|
||||
return strstr(info.dli_fname, "winebus.so") != NULL;
|
||||
return strstr(info.dli_fname, library) != NULL;
|
||||
}
|
||||
|
||||
static int caller_is_winebus(void *caller) { return caller_in_library(caller, "winebus.so"); }
|
||||
|
||||
typedef int (*sdl_rumble_fn)(void *, uint16_t, uint16_t, uint32_t);
|
||||
static _Atomic(sdl_rumble_fn) real_sdl_rumble;
|
||||
static __thread int winebus_sdl_call;
|
||||
|
||||
static int winebus_sdl_rumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) {
|
||||
sdl_rumble_fn real = atomic_load_explicit(&real_sdl_rumble, memory_order_acquire);
|
||||
int result;
|
||||
|
||||
if (!caller_is_winebus(__builtin_return_address(0))) return real(joystick, low, high, duration);
|
||||
if (low != 0 || high != 0) duration = 0;
|
||||
winebus_sdl_call = 1;
|
||||
result = real(joystick, low, high, duration);
|
||||
winebus_sdl_call = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void *winebus_sdl_rumble_dlsym(void *handle, const char *name) {
|
||||
(void)handle;
|
||||
(void)name;
|
||||
return (void *)winebus_sdl_rumble;
|
||||
}
|
||||
|
||||
static void *sdl_rumble_target(void *handle, void *(*forward)(void *, const char *)) {
|
||||
sdl_rumble_fn expected = NULL;
|
||||
sdl_rumble_fn found;
|
||||
|
||||
if (handle == RTLD_NEXT || handle == RTLD_DEFAULT) return NULL;
|
||||
found = (sdl_rumble_fn)forward(handle, "SDL_JoystickRumble");
|
||||
if (found == NULL) return NULL;
|
||||
atomic_compare_exchange_strong_explicit(&real_sdl_rumble, &expected, found, memory_order_acq_rel,
|
||||
memory_order_acquire);
|
||||
if (atomic_load_explicit(&real_sdl_rumble, memory_order_acquire) != found) return NULL;
|
||||
return (void *)winebus_sdl_rumble_dlsym;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd,
|
||||
@@ -454,7 +555,8 @@ __attribute__((visibility("hidden"))) int dd_winebus_rumble_ioctl(int (*real)(in
|
||||
struct ff_effect *effect = arg;
|
||||
__u16 length;
|
||||
|
||||
if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE || !caller_is_winebus(caller)) return 0;
|
||||
if (request != EVIOCSFF || effect == NULL || effect->type != FF_RUMBLE) return 0;
|
||||
if (!caller_is_winebus(caller) && !(winebus_sdl_call && caller_in_library(caller, "libSDL"))) return 0;
|
||||
length = effect->replay.length;
|
||||
effect->replay.length = 0;
|
||||
*rc = real(fd, request, arg);
|
||||
@@ -1195,7 +1297,10 @@ static void *own_dlsym(void *handle, const char *name) {
|
||||
__attribute__((visibility("hidden"), used)) void *inputudev_dlsym_target(void *handle, const char *name) {
|
||||
void *forward = real_dlsym();
|
||||
|
||||
(void)handle;
|
||||
if (forward != NULL && name != NULL && strcmp(name, "SDL_JoystickRumble") == 0) {
|
||||
void *rumble = sdl_rumble_target(handle, forward);
|
||||
if (rumble != NULL) return rumble;
|
||||
}
|
||||
if (name != NULL && strncmp(name, "udev_", 5) == 0 && own_udev_symbol(name) != NULL &&
|
||||
!steam_client_process())
|
||||
return (void *)own_dlsym;
|
||||
|
||||
@@ -203,10 +203,17 @@ static void test_handle_map_null_key(void)
|
||||
map_free(&map);
|
||||
}
|
||||
|
||||
static int zink_instance_table;
|
||||
static struct object mock_zink_instance = {&zink_instance_table};
|
||||
static struct object mock_arm = {&instance_table};
|
||||
static struct object mock_zink_arm = {&zink_instance_table}, mock_zink_other = {&zink_instance_table};
|
||||
|
||||
static VkResult VKAPI_CALL mock_create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator,
|
||||
VkInstance *instance)
|
||||
{
|
||||
*instance = (VkInstance)&mock_instance;
|
||||
const VkApplicationInfo *app = info->pApplicationInfo;
|
||||
bool zink = app && app->pEngineName && !strcmp(app->pEngineName, "mesa zink");
|
||||
*instance = (VkInstance)(zink ? &mock_zink_instance : &mock_instance);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -223,6 +230,7 @@ static void VKAPI_CALL mock_features(VkPhysicalDevice physical, VkPhysicalDevice
|
||||
{
|
||||
memset(features, 0, sizeof(*features));
|
||||
features->dualSrcBlend = physical == (VkPhysicalDevice)&mock_capable;
|
||||
features->geometryShader = VK_TRUE;
|
||||
}
|
||||
|
||||
static void VKAPI_CALL mock_features2(VkPhysicalDevice physical, VkPhysicalDeviceFeatures2 *features)
|
||||
@@ -234,6 +242,8 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi
|
||||
{
|
||||
memset(properties, 0, sizeof(*properties));
|
||||
strcpy(properties->deviceName, "mock");
|
||||
bool arm = physical == (VkPhysicalDevice)&mock_arm || physical == (VkPhysicalDevice)&mock_zink_arm;
|
||||
properties->vendorID = arm ? 0x13b5 : 0;
|
||||
properties->limits.maxFragmentDualSrcAttachments = physical == (VkPhysicalDevice)&mock_capable;
|
||||
}
|
||||
|
||||
@@ -385,6 +395,50 @@ static void destroy_device(VkDevice device)
|
||||
((PFN_vkDestroyDevice)layer_gdpa(device, "vkDestroyDevice"))(device, NULL);
|
||||
}
|
||||
|
||||
static void test_geometry_shader_hidden_from_zink(void)
|
||||
{
|
||||
VkPhysicalDeviceFeatures features;
|
||||
PFN_vkGetPhysicalDeviceFeatures plain_features =
|
||||
(PFN_vkGetPhysicalDeviceFeatures)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures");
|
||||
PFN_vkGetPhysicalDeviceFeatures2 plain_features2 =
|
||||
(PFN_vkGetPhysicalDeviceFeatures2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceFeatures2");
|
||||
VkPhysicalDeviceFeatures2 queried = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2};
|
||||
plain_features((VkPhysicalDevice)&mock_lacking, &features);
|
||||
assert(features.geometryShader);
|
||||
plain_features((VkPhysicalDevice)&mock_arm, &features);
|
||||
assert(features.geometryShader);
|
||||
plain_features2((VkPhysicalDevice)&mock_arm, &queried);
|
||||
assert(queried.features.geometryShader);
|
||||
|
||||
VkApplicationInfo app = {.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO, .pEngineName = "mesa zink"};
|
||||
VkLayerInstanceLink link = {NULL, mock_gipa, NULL};
|
||||
VkLayerInstanceCreateInfo loader = {VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO, NULL, VK_LAYER_LINK_INFO, {&link}};
|
||||
VkInstanceCreateInfo info = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = &loader,
|
||||
.pApplicationInfo = &app};
|
||||
VkInstance zink;
|
||||
assert(((PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance"))(&info, NULL, &zink) == VK_SUCCESS);
|
||||
assert(zink == (VkInstance)&mock_zink_instance);
|
||||
PFN_vkGetPhysicalDeviceFeatures zink_features =
|
||||
(PFN_vkGetPhysicalDeviceFeatures)layer_gipa(zink, "vkGetPhysicalDeviceFeatures");
|
||||
PFN_vkGetPhysicalDeviceFeatures2 zink_features2 =
|
||||
(PFN_vkGetPhysicalDeviceFeatures2)layer_gipa(zink, "vkGetPhysicalDeviceFeatures2");
|
||||
zink_features((VkPhysicalDevice)&mock_zink_arm, &features);
|
||||
assert(!features.geometryShader && features.dualSrcBlend);
|
||||
zink_features2((VkPhysicalDevice)&mock_zink_arm, &queried);
|
||||
assert(!queried.features.geometryShader && queried.features.dualSrcBlend);
|
||||
zink_features((VkPhysicalDevice)&mock_zink_other, &features);
|
||||
assert(features.geometryShader);
|
||||
|
||||
setenv("DROIDDECK_MALI_COMPAT_NO_GS", "0", 1);
|
||||
zink_features((VkPhysicalDevice)&mock_zink_arm, &features);
|
||||
assert(features.geometryShader);
|
||||
setenv("DROIDDECK_MALI_COMPAT_NO_GS", "1", 1);
|
||||
plain_features((VkPhysicalDevice)&mock_lacking, &features);
|
||||
assert(!features.geometryShader);
|
||||
unsetenv("DROIDDECK_MALI_COMPAT_NO_GS");
|
||||
((PFN_vkDestroyInstance)layer_gipa(zink, "vkDestroyInstance"))(zink, NULL);
|
||||
}
|
||||
|
||||
static const VkPipelineColorBlendAttachmentState dual_attachment = {
|
||||
VK_TRUE, VK_BLEND_FACTOR_ONE, VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, VK_BLEND_OP_ADD,
|
||||
VK_BLEND_FACTOR_SRC1_ALPHA, VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA, VK_BLEND_OP_ADD, 0xf,
|
||||
@@ -575,6 +629,7 @@ int main(int argc, char **argv)
|
||||
setenv("WINEPREFIX", "/nonexistent", 1);
|
||||
unsetenv("DROIDDECK_MALI_COMPAT");
|
||||
unsetenv("DROIDDECK_MALI_COMPAT_TRACE");
|
||||
unsetenv("DROIDDECK_MALI_COMPAT_NO_GS");
|
||||
VkNegotiateLayerInterface negotiate = {LAYER_NEGOTIATE_INTERFACE_STRUCT, NULL, 2, NULL, NULL, NULL};
|
||||
assert(vkNegotiateLoaderLayerInterfaceVersion(&negotiate) == VK_SUCCESS);
|
||||
layer_gipa = negotiate.pfnGetInstanceProcAddr;
|
||||
@@ -587,6 +642,7 @@ int main(int argc, char **argv)
|
||||
PFN_vkCreateInstance create_instance = (PFN_vkCreateInstance)layer_gipa(NULL, "vkCreateInstance");
|
||||
assert(create_instance(&info, NULL, &instance) == VK_SUCCESS);
|
||||
|
||||
test_geometry_shader_hidden_from_zink();
|
||||
test_lacking_device();
|
||||
test_capable_device();
|
||||
test_depth_compare_op();
|
||||
|
||||
@@ -1741,6 +1741,94 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
(asylum / name).touch()
|
||||
self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], []))
|
||||
|
||||
def test_store_launcher_resolves_the_game_executable_from_the_sidecar(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp) / "BatmanArkhamCity"
|
||||
bin_dir = root / "Binaries/Win32"
|
||||
bin_dir.mkdir(parents=True)
|
||||
for name in ("Batman2.exe", "BatmanAC.exe"):
|
||||
(bin_dir / name).touch()
|
||||
launcher = root / ".droiddeck-launch.bat"
|
||||
launcher.touch()
|
||||
(root / ".droiddeck-store.json").write_text(json.dumps({
|
||||
"store": "epic", "id": "Egret", "title": "Batman Arkham City",
|
||||
"exe": "Binaries/Win32/Batman2.exe", "launcher": ".droiddeck-launch.bat",
|
||||
}))
|
||||
env, extra, notes = MODULE["engine_fixes"](str(launcher), [])
|
||||
self.assertEqual((env, extra), ({"FEX_X87REDUCEDPRECISION": "0"}, []))
|
||||
self.assertTrue(notes)
|
||||
|
||||
home = Path(tmp) / "home"
|
||||
config = home / ".config/droiddeck/game-environment.json"
|
||||
config.parent.mkdir(parents=True)
|
||||
config.write_text(json.dumps({"version": 1, "shared": {"FEX_X87REDUCEDPRECISION": "1"}}))
|
||||
probe = home / "proton"
|
||||
probe.write_text("#!" + sys.executable + "\nimport os, sys\n"
|
||||
"print(os.environ.get('FEX_X87REDUCEDPRECISION', ''))\n"
|
||||
"print(sys.argv[2])\n")
|
||||
probe.chmod(0o755)
|
||||
base = {k: v for k, v in os.environ.items() if not k.startswith(("FEX_", "WINE", "PROTON", "DROIDDECK", "DD_", "STEAM"))}
|
||||
base.update(HOME=str(home), STEAM_COMPAT_DATA_PATH=str(home / "compatdata/3648205350"))
|
||||
result = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "waitforexitandrun", str(launcher)],
|
||||
env=base, text=True, capture_output=True, check=True)
|
||||
self.assertEqual(result.stdout.splitlines(), ["0", str(launcher)])
|
||||
self.assertIn("Batman: Arkham City: FEX with full x87 precision", result.stderr)
|
||||
|
||||
rebirth = Path(tmp) / "FF7Rebirth"
|
||||
rebirth_exe = rebirth / "End/Binaries/Win64/ff7rebirth_.exe"
|
||||
rebirth_exe.parent.mkdir(parents=True)
|
||||
rebirth_exe.touch()
|
||||
rebirth_launcher = rebirth / ".droiddeck-launch.bat"
|
||||
rebirth_launcher.touch()
|
||||
(rebirth / ".droiddeck-store.json").write_text(json.dumps({
|
||||
"store": "epic", "id": "ff7", "title": "FF7 Rebirth",
|
||||
"exe": r"End\Binaries\Win64\ff7rebirth_.exe", "launcher": ".droiddeck-launch.bat",
|
||||
}))
|
||||
self.assertEqual(MODULE["engine_fixes"](str(rebirth_launcher), [])[0], {"VKD3D_FEATURE_LEVEL": "12_2"})
|
||||
|
||||
def test_store_launcher_ignores_missing_invalid_or_escaping_sidecar_paths(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
outside = Path(tmp) / "Outside"
|
||||
outside.mkdir()
|
||||
outside_exe = outside / "BatmanAC.exe"
|
||||
outside_exe.touch()
|
||||
|
||||
root = Path(tmp) / "Game"
|
||||
sub = root / "sub"
|
||||
sub.mkdir(parents=True)
|
||||
(root / "real.exe").touch()
|
||||
(sub / "nested.exe").touch()
|
||||
(root / "escape.exe").symlink_to(outside_exe)
|
||||
(root / "linkdir").symlink_to(outside)
|
||||
launcher = root / ".droiddeck-launch.bat"
|
||||
launcher.touch()
|
||||
sidecar = root / ".droiddeck-store.json"
|
||||
|
||||
resolve = MODULE["store_game_exe"]
|
||||
self.assertEqual(resolve(str(launcher)), str(launcher))
|
||||
|
||||
for payload in ("not-json", "[]", json.dumps({"exe": ""}), json.dumps({"exe": 123}),
|
||||
json.dumps({"exe": "missing.exe"}), json.dumps({"exe": "sub"}),
|
||||
json.dumps({"exe": "../Outside/BatmanAC.exe"}),
|
||||
json.dumps({"exe": "sub/../real.exe"}),
|
||||
json.dumps({"exe": r"sub\..\real.exe"}),
|
||||
json.dumps({"exe": "linkdir/../real.exe"}),
|
||||
json.dumps({"exe": "sub/../../Outside/BatmanAC.exe"}),
|
||||
json.dumps({"exe": str(outside_exe)}),
|
||||
json.dumps({"exe": r"C:\Windows\notepad.exe"}),
|
||||
json.dumps({"exe": "escape.exe"})):
|
||||
with self.subTest(payload=payload):
|
||||
sidecar.write_text(payload)
|
||||
self.assertEqual(resolve(str(launcher)), str(launcher))
|
||||
|
||||
sidecar.write_text(json.dumps({"exe": "real.exe"}))
|
||||
self.assertEqual(resolve(str(launcher)), str(root / "real.exe"))
|
||||
sidecar.write_text(json.dumps({"exe": "sub/nested.exe"}))
|
||||
self.assertEqual(resolve(str(launcher)), str(sub / "nested.exe"))
|
||||
other_bat = root / "custom.bat"
|
||||
other_bat.touch()
|
||||
self.assertEqual(resolve(str(other_bat)), str(other_bat))
|
||||
|
||||
def test_split_second_gets_x87_fip_unless_the_game_sets_jit_features(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = Path(tmp) / "SplitSecond"
|
||||
@@ -1762,6 +1850,76 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
config["games"] = {"297860": {"FEX_JITFEATURES": "off"}}
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "297860", env)["FEX_JITFEATURES"], "off")
|
||||
|
||||
def test_inno_setup_installers_get_the_stability_preset_over_the_default(self):
|
||||
stability = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "1", "FEX_MEMCPYSETTSOENABLED": "1",
|
||||
"FEX_HALFBARRIERTSOENABLED": "1", "FEX_X87REDUCEDPRECISION": "0", "FEX_MULTIBLOCK": "0"}
|
||||
performance_tso = {"FEX_TSOENABLED": "1", "FEX_VECTORTSOENABLED": "0", "FEX_MEMCPYSETTSOENABLED": "0",
|
||||
"FEX_HALFBARRIERTSOENABLED": "0", "FEX_X87REDUCEDPRECISION": "1", "FEX_MULTIBLOCK": "1"}
|
||||
|
||||
def loader(path, resources=b"", machine=0x14C, section=b".rsrc", legacy=False):
|
||||
dos = bytearray(0x80)
|
||||
dos[:2] = b"MZ"
|
||||
dos[0x3C:0x40] = (0x80).to_bytes(4, "little")
|
||||
if legacy:
|
||||
dos[0x30:0x34] = b"Inno"
|
||||
header = b"PE\0\0" + machine.to_bytes(2, "little") + (1).to_bytes(2, "little") + bytes(12) \
|
||||
+ (0xE0).to_bytes(2, "little") + bytes(2)
|
||||
entry = section.ljust(8, b"\0") + bytes(8) + len(resources).to_bytes(4, "little") \
|
||||
+ (0x400).to_bytes(4, "little") + bytes(16)
|
||||
path.write_bytes((bytes(dos) + header + bytes(0xE0) + entry).ljust(0x400, b"\0") + resources)
|
||||
return str(path)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
folder = Path(tmp)
|
||||
table = bytes(64) + b"rDlPtS\xcd\xe6\xd7{\x0b*" + bytes(64)
|
||||
installers = [
|
||||
loader(folder / "setup.exe", table),
|
||||
loader(folder / "setup_game_1.0.exe", bytes(64) + b"nS5W7dT\x83\xaa\x1b\x0fj"),
|
||||
loader(folder / "old_setup.exe", legacy=True),
|
||||
]
|
||||
for installer in installers:
|
||||
env, extra, notes = MODULE["engine_fixes"](installer, [])
|
||||
self.assertEqual((env, extra), (stability, []), installer)
|
||||
self.assertTrue(notes)
|
||||
config = {"version": 1, "shared": performance_tso}
|
||||
self.assertEqual({k: v for k, v in MODULE["apply_config"]({}, config, "42", env).items() if k in stability},
|
||||
stability)
|
||||
config["games"] = {"42": {"FEX_MULTIBLOCK": "1"}}
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "42", env)["FEX_MULTIBLOCK"], "1")
|
||||
|
||||
not_installers = [
|
||||
loader(folder / "Game.exe", bytes(256)),
|
||||
loader(folder / "Game64.exe", table, machine=0x8664),
|
||||
loader(folder / "Data.exe", table, section=b".data"),
|
||||
folder / "missing.exe",
|
||||
]
|
||||
(folder / "notes.exe").write_bytes(b"rDlPtS\xcd\xe6\xd7{\x0b*")
|
||||
not_installers.append(folder / "notes.exe")
|
||||
for other in not_installers:
|
||||
self.assertEqual(MODULE["engine_fixes"](str(other), []), ({}, [], []), other)
|
||||
|
||||
# The run verb skips engine_fixes; an installer started that way still gets Stability.
|
||||
probe = folder / "proton"
|
||||
probe.write_text("#!" + sys.executable + "\nimport json, os\nprint(json.dumps(dict(os.environ)))\n")
|
||||
probe.chmod(0o755)
|
||||
base = {**os.environ, **performance_tso, "HOME": tmp, "STEAM_COMPAT_DATA_PATH": str(folder / "compatdata/42")}
|
||||
|
||||
def run_verb(program):
|
||||
out = subprocess.run([sys.executable, str(BIN / "droiddeck-game-env"), str(probe), "run", program],
|
||||
env=base, text=True, capture_output=True, check=True).stdout
|
||||
return {name: value for name, value in json.loads(out).items() if name in stability}
|
||||
|
||||
self.assertEqual(run_verb(installers[0]), stability)
|
||||
self.assertEqual(run_verb(str(folder / "Game.exe")), performance_tso)
|
||||
config_path = folder / ".config/droiddeck/game-environment.json"
|
||||
config_path.parent.mkdir(parents=True)
|
||||
config_path.write_text(json.dumps({"version": 1, "shared": {"WINEESYNC": "1"}}))
|
||||
self.assertEqual(run_verb(installers[0]), stability)
|
||||
config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": "1"}}}))
|
||||
self.assertEqual(run_verb(installers[0]), {**stability, "FEX_MULTIBLOCK": "1"})
|
||||
config_path.write_text(json.dumps({"version": 1, "games": {"42": {"FEX_MULTIBLOCK": None}}}))
|
||||
self.assertNotIn("FEX_MULTIBLOCK", run_verb(installers[0]))
|
||||
|
||||
def test_d3dgear_capture_hook_beside_the_game_is_turned_off(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = Path(tmp) / "The Crew 2"
|
||||
|
||||
@@ -260,6 +260,7 @@ static void *(*next)(void *);
|
||||
static void *(*by_name)(void *, const char *);
|
||||
static const char *(*name)(void *);
|
||||
static const char *(*value)(void *);
|
||||
static const char *(*sysattr)(void *, const char *);
|
||||
|
||||
static void *sym(const char *symbol) { return dlsym(lib, symbol); }
|
||||
|
||||
@@ -463,6 +464,20 @@ static void run_every(int count, char **entries) {
|
||||
printf("pad %d real calls %d\n", pad != NULL, real_calls != NULL ? *real_calls : -1);
|
||||
}
|
||||
|
||||
static void print_product(const char *label, void *device) {
|
||||
const char *uevent = device != NULL ? sysattr(device, "uevent") : NULL;
|
||||
|
||||
printf("%s %.*s\n", label, uevent != NULL ? (int)strcspn(uevent, "\n") : 4, uevent != NULL ? uevent : "none");
|
||||
}
|
||||
|
||||
static void run_identity(void) {
|
||||
int udev;
|
||||
void *device = new_device(&udev, PAD);
|
||||
|
||||
print_product("pad", device);
|
||||
print_product("parent", device != NULL ? get_parent(device) : NULL);
|
||||
}
|
||||
|
||||
static void run_probe(void) {
|
||||
int udev;
|
||||
|
||||
@@ -539,7 +554,9 @@ int main(int argc, char **argv) {
|
||||
by_name = sym("udev_list_entry_get_by_name");
|
||||
name = sym("udev_list_entry_get_name");
|
||||
value = sym("udev_list_entry_get_value");
|
||||
sysattr = sym("udev_device_get_sysattr_value");
|
||||
if (strcmp(argv[1], "probe") == 0) run_probe();
|
||||
else if (strcmp(argv[1], "identity") == 0) run_identity();
|
||||
else if (strcmp(argv[1], "every") == 0) run_every(argc - 3, argv + 3);
|
||||
else if (strcmp(argv[1], "stable") == 0) run_stable();
|
||||
else if (strcmp(argv[1], "enumerate") == 0) run_enumerate();
|
||||
@@ -597,10 +614,13 @@ class InputUdevPreloadTest(unittest.TestCase):
|
||||
(pads / node).write_text("")
|
||||
return pads
|
||||
|
||||
def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=()):
|
||||
def run_program(self, mode, *preloads, pads=None, slots="0=/pad", program=None, args=(), extra=None):
|
||||
env = dict(os.environ, LD_PRELOAD=":".join(str(self.dir / name) for name in ("libddsession.so", *preloads)),
|
||||
FAKE_EVDEV_MEMFD_PATHS=slots, FAKE_EVDEV_DIR=str(pads or self.pads))
|
||||
env.pop("FAKE_EVDEV_UINPUT", None)
|
||||
for key in ("FAKE_EVDEV_UINPUT", "FAKE_EVDEV_STEAM_VIRTUAL", "SDL_GAMECONTROLLER_IGNORE_DEVICES",
|
||||
"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT"):
|
||||
env.pop(key, None)
|
||||
env.update(extra or {})
|
||||
result = subprocess.run([str(program or self.program), mode, str(self.udev), *args], env=env, capture_output=True, text=True,
|
||||
timeout=20)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
@@ -684,6 +704,48 @@ class InputUdevPreloadTest(unittest.TestCase):
|
||||
"nothing added scan -1",
|
||||
])
|
||||
|
||||
def identity(self, pads=None, **extra):
|
||||
return self.run_program("identity", pads=pads, extra=extra)
|
||||
|
||||
@classmethod
|
||||
def id_list(cls, name, text):
|
||||
path = cls.dir / name
|
||||
path.write_text(text)
|
||||
return "@" + str(path)
|
||||
|
||||
def test_a_pad_wine_also_reads_through_sdl_is_described_as_the_pad_sdl_sees(self):
|
||||
xbox = ["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"]
|
||||
for extra in ({}, {"FAKE_EVDEV_UINPUT": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x045e/0x028e"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "0"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-other.txt", "0x28de/0x1142\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "@" + str(self.dir / "missing.txt")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-ring.txt", "0x045E/0x028E\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x45e/0x28e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": ""},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028f"}):
|
||||
with self.subTest(**extra):
|
||||
self.assertEqual(self.identity(**extra), xbox)
|
||||
|
||||
def test_a_pad_sdl_skips_keeps_the_steam_input_identity(self):
|
||||
steam = ["pad PRODUCT=6/28de/11ff/110", "parent PRODUCT=6/28de/11ff/110"]
|
||||
for extra in ({"FAKE_EVDEV_STEAM_VIRTUAL": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142,0x045E/0x028E"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x28de/0x11ff"},
|
||||
{"FAKE_EVDEV_UINPUT": "1", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-ring.txt", "0x28de/0x1142\n0x045e/0x028e\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-other.txt", "0x28de/0x11ff\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-long.txt", "0x28de/0x1142\n" * 400 + "0x045e/0x028e\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x45e/0x28e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"}):
|
||||
with self.subTest(**extra):
|
||||
self.assertEqual(self.identity(**extra), steam)
|
||||
|
||||
def test_a_pad_under_steam_inputs_own_virtual_pad_stays_an_xbox_pad(self):
|
||||
pads = self.pad_dir("under-virtual", "event0", "event16")
|
||||
(pads / ".uinput-event16.uevent").write_text('PRODUCT=6/28de/11ff/1\nNAME="Microsoft X-Box 360 pad 0"\n')
|
||||
self.assertEqual(self.identity(pads, FAKE_EVDEV_UINPUT="1", SDL_GAMECONTROLLER_IGNORE_DEVICES="0x045e/0x028e"),
|
||||
["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"])
|
||||
|
||||
def test_a_program_that_closes_and_reopens_libudev_keeps_working(self):
|
||||
self.assertEqual(self.run_program("reload"), ["reload real0 real1"])
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from pathlib import Path
|
||||
|
||||
SESSION = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-session"
|
||||
KEYS = ("DD_VKBRIDGE_WEBHELPER_ARGS", "DD_VKBRIDGE_CEF_ANGLE", "DD_VKBRIDGE_CEF_VULKAN")
|
||||
BASE = "--no-zygote --in-process-gpu -AudioServiceOutOfProcess"
|
||||
|
||||
|
||||
def layout_function():
|
||||
@@ -27,14 +28,14 @@ class WebhelperLayoutTest(unittest.TestCase):
|
||||
|
||||
def test_angle_on_vulkan_brings_chromiums_vulkan_compositing(self):
|
||||
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan"),
|
||||
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
|
||||
def test_vulkan_compositing_can_be_left_off(self):
|
||||
def test_vulkan_compositing_can_be_left_off_without_zygotes(self):
|
||||
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_CEF_VULKAN="0"),
|
||||
"--use-gl=angle --use-angle=vulkan")
|
||||
BASE + " --use-gl=angle --use-angle=vulkan")
|
||||
|
||||
def test_other_angle_backends_get_only_the_angle_switches(self):
|
||||
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
|
||||
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
|
||||
|
||||
def test_explicit_layout_wins(self):
|
||||
self.assertEqual(self.layout(DD_VKBRIDGE_CEF_ANGLE="vulkan", DD_VKBRIDGE_WEBHELPER_ARGS="--x +Y"),
|
||||
@@ -57,10 +58,10 @@ class WebhelperLayoutTest(unittest.TestCase):
|
||||
env = {k: v for k, v in os.environ.items() if k not in KEYS}
|
||||
run = lambda **s: subprocess.run(["bash", "-c", "set -u\n" + script], env={**env, **s},
|
||||
capture_output=True, text=True, check=True).stdout.strip()
|
||||
self.assertEqual(run(), "--use-gl=angle --use-angle=vulkan")
|
||||
self.assertEqual(run(), BASE + " --use-gl=angle --use-angle=vulkan")
|
||||
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN="1"),
|
||||
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), "--use-gl=angle --use-angle=gl")
|
||||
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE="gl"), BASE + " --use-gl=angle --use-angle=gl")
|
||||
|
||||
def test_empty_settings_are_kept_as_set(self):
|
||||
script = ': "${DD_VKBRIDGE_CEF_ANGLE=vulkan}" "${DD_VKBRIDGE_CEF_VULKAN=0}"\n' + layout_function() + "dd_webhelper_layout\n"
|
||||
@@ -69,7 +70,7 @@ class WebhelperLayoutTest(unittest.TestCase):
|
||||
capture_output=True, text=True, check=True).stdout.strip()
|
||||
self.assertEqual(run(DD_VKBRIDGE_CEF_ANGLE=""), "stock")
|
||||
self.assertEqual(run(DD_VKBRIDGE_CEF_VULKAN=""),
|
||||
"--use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
BASE + " --use-gl=angle --use-angle=vulkan +Vulkan +VulkanFromANGLE +DefaultANGLEVulkan")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -515,7 +515,6 @@ class SteamEa(unittest.TestCase):
|
||||
with patch.dict(os.environ, env), patch.object(store, 'prepare_ea', side_effect=prepare):
|
||||
self.assertEqual(store.REPLACED, store.main(['steam2ea://launchgame/1237970?platform=steam&theme=tf2']))
|
||||
steam = asked[0][4]
|
||||
self.assertEqual('en_US', steam['locale'])
|
||||
self.assertEqual(['Origin.OFR.50.0001452', 'Origin.OFR.50.0001456'], steam['offers'])
|
||||
self.assertEqual(['1039093'], steam['contentIds'])
|
||||
self.assertEqual('Titanfall2.exe', steam['exe'])
|
||||
@@ -533,47 +532,6 @@ class SteamEa(unittest.TestCase):
|
||||
self.assertEqual(0, store.main(['--exited', 'steam2ea://launchgame/1237970']))
|
||||
self.assertEqual([{'op': 'ea-exited', 'store': 'ea', 'id': 'Origin.OFR.50.0001452'}], asked)
|
||||
|
||||
def launch_locale(self, root, locales, appmanifest=None, steam_language=None):
|
||||
folder, data = self.steam_copy(root)
|
||||
if locales is not None:
|
||||
text = MANIFEST.replace('<runtime>', '<installMetaData><locales>%s</locales></installMetaData>\n <runtime>' % locales)
|
||||
(folder / '__Installer/installerdata.xml').write_bytes(b'\xff\xfe' + text.encode('utf-16-le'))
|
||||
if appmanifest is not None:
|
||||
(Path(root) / 'steamapps/appmanifest_1237970.acf').write_text(appmanifest)
|
||||
asked = []
|
||||
prepare = lambda *a: asked.append(a) or {'ok': False, 'reason': 'signed-out'}
|
||||
env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data), 'DD_LAUNCH_DIR': str(Path(root) / 'session')}
|
||||
cleared = {k: v for k, v in os.environ.items() if k != 'DD_STEAM_LANGUAGE'}
|
||||
if steam_language is not None:
|
||||
cleared['DD_STEAM_LANGUAGE'] = steam_language
|
||||
with patch.dict(os.environ, dict(cleared, **env), clear=True), patch.object(store, 'prepare_ea', side_effect=prepare):
|
||||
store.main(['steam2ea://launchgame/1237970?platform=steam'])
|
||||
self.assertEqual(asked[0][1]['extra']['locale'], asked[0][4]['locale'])
|
||||
return asked[0][4]['locale']
|
||||
|
||||
def test_the_game_starts_in_the_language_steam_set_for_it(self):
|
||||
acf = '"AppState"\n{\n\t"appid"\t\t"1237970"\n\t"UserConfig"\n\t{\n\t\t"language"\t\t"french"\n\t}\n}\n'
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual('fr_FR', self.launch_locale(root, 'en_US,de_DE,fr_FR', acf, 'german'))
|
||||
|
||||
def test_without_a_language_for_the_game_steams_own_language_is_used(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual('de_DE', self.launch_locale(root, 'en_US,de_DE,fr_FR', None, 'german'))
|
||||
|
||||
def test_a_language_the_game_lacks_falls_back_to_english(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual('en_GB', self.launch_locale(root, 'en_GB,de_DE', None, 'french'))
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual('en_US', self.launch_locale(root, None, None, 'french'))
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
self.assertEqual('en_US', self.launch_locale(root, 'en_US,fr_FR', None, None))
|
||||
|
||||
def test_the_locale_prefers_the_exact_regional_variant_then_the_same_language(self):
|
||||
self.assertEqual('zh_HK', store.steam_ea_locale(['zh_CN', 'zh_HK'], 'tchinese'))
|
||||
self.assertEqual('es_ES', store.steam_ea_locale(['en_US', 'es_ES'], 'latam'))
|
||||
self.assertEqual('pt_BR', store.steam_ea_locale(['pt_PT', 'pt_BR'], 'brazilian'))
|
||||
self.assertEqual('en_US', store.steam_ea_locale(['en_US', 'fr_FR'], 'unknown'))
|
||||
|
||||
def test_the_manifests_launch_parameters_keep_their_quotes(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder, data = self.steam_copy(root)
|
||||
|
||||
@@ -47,13 +47,18 @@ static int g_dev_state, g_base_black;
|
||||
static uintptr_t g_dev = 1;
|
||||
static struct { int64_t wait_ns, wait_max_ns; unsigned waits; } g_perf;
|
||||
static VkResult answer;
|
||||
static unsigned timeouts, wait_calls;
|
||||
static unsigned destroyed, unmapped, freed_memory, forgotten, errors;
|
||||
static int64_t perf_now(void) { return 10; }
|
||||
static void perf_add(int64_t *s, int64_t *m, unsigned *c, int64_t d) { *s+=d; *m=d; ++*c; }
|
||||
static void __attribute__((unused)) droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; ++errors; }
|
||||
#define LOGE(...) droiddeck_log("error", __VA_ARGS__)
|
||||
static VkResult wait_fn(uintptr_t dev, unsigned n, const VkFence *f, int all, uint64_t timeout) {
|
||||
(void)dev; (void)n; (void)f; (void)all; (void)timeout; return answer;
|
||||
(void)dev; (void)n; (void)f; (void)all;
|
||||
++wait_calls;
|
||||
if (wait_calls > 1) assert(timeout == UINT64_MAX);
|
||||
if (timeouts) { --timeouts; return VK_TIMEOUT; }
|
||||
return answer;
|
||||
}
|
||||
static void unmap_fn(uintptr_t dev, uintptr_t mem) { (void)dev; (void)mem; ++unmapped; }
|
||||
static void destroy_fn(uintptr_t dev, uintptr_t img, void *allocator) { (void)dev; (void)img; (void)allocator; ++destroyed; }
|
||||
@@ -104,8 +109,15 @@ int main(void) {
|
||||
vkp_image_destroy(image());
|
||||
assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1);
|
||||
|
||||
g_dev_state=1; g_base_black=1; answer=VK_TIMEOUT;
|
||||
assert(timed_wait(1, 1000)==VK_TIMEOUT);
|
||||
for (unsigned delays=1; delays<=3; ++delays) {
|
||||
g_dev_state=1; g_base_black=1; answer=VK_SUCCESS;
|
||||
timeouts=delays; wait_calls=0;
|
||||
assert(timed_wait(1, 1000)==VK_SUCCESS);
|
||||
assert(g_dev_state==1 && g_base_black==1 && wait_calls==delays+1);
|
||||
}
|
||||
|
||||
g_dev_state=1; g_base_black=1; answer=VK_ERROR_UNKNOWN; wait_calls=0;
|
||||
assert(timed_wait(1, 1000)==VK_ERROR_UNKNOWN);
|
||||
assert(g_dev_state!=1 && g_dev_state!=-2); /* pending work is not DEVICE_LOST */
|
||||
struct vkp_image *pending=image();
|
||||
vkp_image_destroy(pending);
|
||||
@@ -116,14 +128,14 @@ int main(void) {
|
||||
assert(errors==first_errors); /* one terminal diagnostic, no repeated recovery */
|
||||
free(pending); /* fake GPU exists only in this test */
|
||||
|
||||
g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
g_dev_state=1; answer=VK_ERROR_OUT_OF_HOST_MEMORY; wait_calls=0; timeouts=1;
|
||||
assert(timed_wait(1, 1000)==VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
assert(g_dev_state!=1 && g_dev_state!=-2);
|
||||
pending=image(); vkp_image_destroy(pending);
|
||||
assert(destroyed==1 && unmapped==1 && freed_memory==1 && forgotten==1);
|
||||
free(pending);
|
||||
|
||||
g_dev_state=1; answer=VK_ERROR_DEVICE_LOST;
|
||||
g_dev_state=1; answer=VK_ERROR_DEVICE_LOST; wait_calls=0; timeouts=2;
|
||||
assert(timed_wait(1, 1000)==VK_ERROR_DEVICE_LOST);
|
||||
assert(g_dev_state==1); /* existing caller performs genuine device-loss cleanup */
|
||||
return 0;
|
||||
|
||||
@@ -111,15 +111,18 @@ int __android_log_print(int, const char *, const char *, ...);
|
||||
def test_later_framegen_surface_lost_idle_failure(self):
|
||||
self.run_scenario('later-surface-lost')
|
||||
|
||||
def test_finite_blit_timeout_same_size_shm_upload(self):
|
||||
self.run_scenario('shm-timeout')
|
||||
def test_blit_wait_error_same_size_shm_upload(self):
|
||||
self.run_scenario('shm-wait-error')
|
||||
|
||||
def test_finite_blit_timeout_same_size_pixel_upload(self):
|
||||
self.run_scenario('pixel-timeout')
|
||||
def test_blit_wait_error_same_size_pixel_upload(self):
|
||||
self.run_scenario('pixel-wait-error')
|
||||
|
||||
def test_lost_device_shm_upload_keeps_cpu_snapshot(self):
|
||||
self.run_scenario('lost-shm-upload')
|
||||
|
||||
def test_delayed_blit_completes_and_next_frame_renders(self):
|
||||
self.run_scenario('blit-delayed')
|
||||
|
||||
def test_normal_present(self):
|
||||
self.run_scenario('normal')
|
||||
|
||||
|
||||
@@ -40,6 +40,39 @@ void upload(unsigned short type, unsigned short length) {
|
||||
}
|
||||
"""
|
||||
|
||||
SDL = r"""
|
||||
#include <linux/input.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int SDL_JoystickRumble(void *joystick, uint16_t low, uint16_t high, uint32_t duration) {
|
||||
struct ff_effect effect;
|
||||
(void)joystick;
|
||||
printf("sdl %u %u duration %u\n", low, high, duration);
|
||||
memset(&effect, 0, sizeof(effect));
|
||||
effect.id = -1;
|
||||
effect.type = FF_RUMBLE;
|
||||
effect.replay.length = 0xffff;
|
||||
effect.u.rumble.strong_magnitude = low;
|
||||
effect.u.rumble.weak_magnitude = high;
|
||||
return ioctl(3, EVIOCSFF, &effect);
|
||||
}
|
||||
"""
|
||||
|
||||
SDL_CALLER = r"""
|
||||
#include <dlfcn.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int rumble(const char *library, uint16_t low, uint16_t high, uint32_t duration) {
|
||||
void *sdl = dlopen(library, RTLD_NOW | RTLD_LOCAL);
|
||||
int (*call)(void *, uint16_t, uint16_t, uint32_t) = (int (*)(void *, uint16_t, uint16_t, uint32_t))dlsym(sdl, "SDL_JoystickRumble");
|
||||
call(0, low, high, duration);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
PROGRAM = r"""
|
||||
#include <dlfcn.h>
|
||||
#include <linux/input.h>
|
||||
@@ -47,8 +80,21 @@ PROGRAM = r"""
|
||||
|
||||
void upload(unsigned short type, unsigned short length);
|
||||
|
||||
int rumble(const char *library, unsigned short low, unsigned short high, unsigned int duration);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
void *winebus = dlopen(argv[1], RTLD_NOW);
|
||||
if (argv[2][0] == 's') {
|
||||
int (*from_winebus)(const char *, unsigned short, unsigned short, unsigned int) =
|
||||
(int (*)(const char *, unsigned short, unsigned short, unsigned int))dlsym(winebus, "rumble");
|
||||
for (const char *step = argv[3]; *step; step++) {
|
||||
if (*step == 'w') from_winebus(argv[4], 65535, 32768, 1000);
|
||||
if (*step == 'z') from_winebus(argv[4], 0, 0, 0);
|
||||
if (*step == 'p') rumble(argv[4], 65535, 32768, 1000);
|
||||
}
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
void (*from_winebus)(unsigned short, unsigned short) = (void (*)(unsigned short, unsigned short))dlsym(winebus, "upload");
|
||||
if (argv[2][0] == 'w') from_winebus(argv[3][0] == 'r' ? FF_RUMBLE : FF_PERIODIC, 1000);
|
||||
else upload(FF_RUMBLE, 1000);
|
||||
@@ -65,7 +111,8 @@ class WinebusRumblePreloadTest(unittest.TestCase):
|
||||
cls.dir = Path(tempfile.mkdtemp())
|
||||
build = cls.dir / "build"
|
||||
build.mkdir()
|
||||
for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM)):
|
||||
for name, text in (("shim.c", SHIM), ("upload.c", UPLOAD), ("program.c", PROGRAM), ("sdl.c", SDL),
|
||||
("sdl_caller.c", SDL_CALLER)):
|
||||
(build / name).write_text(text)
|
||||
cls.lib = cls.dir / "libddsession.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(cls.lib),
|
||||
@@ -73,10 +120,13 @@ class WinebusRumblePreloadTest(unittest.TestCase):
|
||||
cls.shim = cls.dir / "libshim.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.shim), str(build / "shim.c")], check=True)
|
||||
cls.winebus = cls.dir / "winebus.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c")], check=True)
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "upload.c"),
|
||||
str(build / "sdl_caller.c"), "-ldl"], check=True)
|
||||
cls.sdl_library = cls.dir / "libSDL2-2.0.so.0"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.sdl_library), str(build / "sdl.c")], check=True)
|
||||
cls.program = cls.dir / "program"
|
||||
subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"), "-ldl"],
|
||||
check=True)
|
||||
subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "upload.c"),
|
||||
str(build / "sdl_caller.c"), "-ldl"], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -88,6 +138,21 @@ class WinebusRumblePreloadTest(unittest.TestCase):
|
||||
capture_output=True, text=True, timeout=10, check=True)
|
||||
return result.stdout.splitlines()
|
||||
|
||||
def sdl(self, steps):
|
||||
env = dict(os.environ, LD_PRELOAD="%s:%s" % (self.lib, self.shim))
|
||||
result = subprocess.run([str(self.program), str(self.winebus), "sdl", steps, str(self.sdl_library)], env=env,
|
||||
capture_output=True, text=True, timeout=10, check=True)
|
||||
return result.stdout.splitlines()
|
||||
|
||||
def test_rumble_winebus_starts_through_sdl_is_held_until_the_next_update(self):
|
||||
self.assertEqual(self.sdl("wz"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50,
|
||||
"sdl 0 0 duration 0", "shim type %d length 0" % 0x50])
|
||||
|
||||
def test_sdl_rumble_from_other_code_keeps_its_duration_and_length(self):
|
||||
self.assertEqual(self.sdl("p"), ["sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50])
|
||||
self.assertEqual(self.sdl("wp"), ["sdl 65535 32768 duration 0", "shim type %d length 0" % 0x50,
|
||||
"sdl 65535 32768 duration 1000", "shim type %d length 65535" % 0x50])
|
||||
|
||||
def test_winebus_rumble_reaches_the_shim_held_and_comes_back_unchanged(self):
|
||||
self.assertEqual(self.upload("winebus"), ["shim type %d length 0" % 0x50, "caller length 1000"])
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ struct vk_api g_vk;
|
||||
static unsigned operations, acquires, submits, markers, waits, idle_calls, resets;
|
||||
static unsigned destroys, releases, lost_notifications, presented_notifications;
|
||||
static VkResult idle_answer, fence_answer, acquire_answer, present_answer;
|
||||
static unsigned fail_acquire_at;
|
||||
static unsigned fail_acquire_at, fence_timeouts;
|
||||
static int generated;
|
||||
|
||||
/* Every work-issuing callback is an oracle: no GPU operation after a terminal
|
||||
@@ -19,7 +19,9 @@ static VkResult acquire(VkDevice d, VkSwapchainKHR s, uint64_t t, VkSemaphore a,
|
||||
}
|
||||
static VkResult idle(VkDevice d) { live(); ++idle_calls; return idle_answer; }
|
||||
static VkResult wait_fences(VkDevice d, uint32_t n, const VkFence *f, VkBool32 all, uint64_t t) {
|
||||
live(); ++waits; return fence_answer;
|
||||
live(); ++waits;
|
||||
if (fence_timeouts) { --fence_timeouts; return VK_TIMEOUT; }
|
||||
return fence_answer;
|
||||
}
|
||||
static VkResult submit(VkQueue q, uint32_t n, const VkSubmitInfo *s, VkFence f) {
|
||||
live(); ++submits; if (!s->commandBufferCount) ++markers; return VK_SUCCESS;
|
||||
@@ -235,7 +237,7 @@ static void acquire_failure(int later, VkResult result) {
|
||||
free(g_images); /* test-owned fake resources only */
|
||||
}
|
||||
|
||||
static void upload_timeout(int single_pixel) {
|
||||
static void upload_wait_error(int single_pixel) {
|
||||
setup(0);
|
||||
uint8_t bytes[48], saved[48], data[16];
|
||||
memset(bytes, 0xa5, sizeof(bytes)); memset(data, 0x3c, sizeof(data));
|
||||
@@ -251,7 +253,7 @@ static void upload_timeout(int single_pixel) {
|
||||
assert(bytes[3] == 0x3c && bytes[0] == 0xa5 && releases == 1);
|
||||
memcpy(saved, bytes, sizeof(saved));
|
||||
struct vkp_image dst = {.image = (VkImage)(uintptr_t)9, .blit_dst = 1, .w = img->w, .h = img->h};
|
||||
fence_answer = VK_TIMEOUT;
|
||||
fence_answer = VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
assert(vkp_blit_image(img, &dst, -1) == -1);
|
||||
assert(g_dev_state == -3 && submits == 1 && waits == 1);
|
||||
memset(data, 0x7e, sizeof(data));
|
||||
@@ -279,8 +281,8 @@ int main(int argc, char **argv) {
|
||||
else if (!strcmp(name, "first-surface-lost")) acquire_failure(0, VK_ERROR_SURFACE_LOST_KHR);
|
||||
else if (!strcmp(name, "later-out-of-date")) acquire_failure(1, VK_ERROR_OUT_OF_DATE_KHR);
|
||||
else if (!strcmp(name, "later-surface-lost")) acquire_failure(1, VK_ERROR_SURFACE_LOST_KHR);
|
||||
else if (!strcmp(name, "shm-timeout")) upload_timeout(0);
|
||||
else if (!strcmp(name, "pixel-timeout")) upload_timeout(1);
|
||||
else if (!strcmp(name, "shm-wait-error")) upload_wait_error(0);
|
||||
else if (!strcmp(name, "pixel-wait-error")) upload_wait_error(1);
|
||||
else if (!strcmp(name, "lost-shm-upload")) {
|
||||
setup(0);
|
||||
uint8_t bytes[64], data[16];
|
||||
@@ -295,6 +297,17 @@ int main(int argc, char **argv) {
|
||||
free(img.recovery_pixels);
|
||||
free(g_images);
|
||||
} else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); }
|
||||
else if (!strcmp(name, "blit-delayed")) {
|
||||
setup(0);
|
||||
struct vkp_image src = {.image = (VkImage)(uintptr_t)7, .w = 1, .h = 1};
|
||||
struct vkp_image dst = {.image = (VkImage)(uintptr_t)8, .w = 1, .h = 1, .blit_dst = 1};
|
||||
fence_timeouts = 3;
|
||||
assert(vkp_blit_image(&src, &dst, -1) == 0);
|
||||
assert(g_dev_state == 1 && submits == 1 && waits == 4 && destroys == 0);
|
||||
assert(vkp_blit_image(&src, &dst, -1) == 0);
|
||||
assert(g_dev_state == 1 && submits == 2 && waits == 5 && destroys == 0);
|
||||
free(g_images);
|
||||
}
|
||||
else if (!strcmp(name, "normal") || !strcmp(name, "framegen")) {
|
||||
int extra = !strcmp(name, "framegen"); setup(extra);
|
||||
assert(vkp_render(64, 64, NULL, 0) == 0 && g_dev_state == 1);
|
||||
|
||||
@@ -344,12 +344,31 @@ static void report_limits(VkPhysicalDeviceLimits *limits, uint32_t gaps)
|
||||
}
|
||||
}
|
||||
|
||||
/* Mali's driver crashes compiling Zink's geometry shaders (SIGSEGV at 0x40 in
|
||||
* cmpbe_v2_compile_multiple_shaders) and takes the render server and the application with it; a plain
|
||||
* one draws nothing. Zink draws GL_QUADS through one; without the feature Mesa splits quads into
|
||||
* triangles itself. DXVK needs the feature for D3D10 and 11, so only Zink loses it.
|
||||
* DROIDDECK_MALI_COMPAT_NO_GS=0 keeps it for Zink, =1 hides it from every application. */
|
||||
static bool hide_geometry_shader(struct instance *inst, VkPhysicalDevice physical_device)
|
||||
{
|
||||
const char *setting = getenv("DROIDDECK_MALI_COMPAT_NO_GS");
|
||||
if (setting && *setting)
|
||||
return strcmp(setting, "1") == 0;
|
||||
if (!inst->zink)
|
||||
return false;
|
||||
VkPhysicalDeviceProperties properties;
|
||||
inst->GetPhysicalDeviceProperties(physical_device, &properties);
|
||||
return properties.vendorID == 0x13b5; /* ARM */
|
||||
}
|
||||
|
||||
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures(VkPhysicalDevice physical_device,
|
||||
VkPhysicalDeviceFeatures *features)
|
||||
{
|
||||
struct instance *inst = instance_from_handle(physical_device);
|
||||
inst->GetPhysicalDeviceFeatures(physical_device, features);
|
||||
report_features(features, physical_device_gaps(inst, physical_device));
|
||||
if (hide_geometry_shader(inst, physical_device))
|
||||
features->geometryShader = VK_FALSE;
|
||||
}
|
||||
|
||||
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice physical_device,
|
||||
@@ -363,6 +382,8 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceFeatures2(VkPhysicalDevice ph
|
||||
inst->GetPhysicalDeviceFeatures2(physical_device, features);
|
||||
relink(dropped, dropped_count);
|
||||
report_features(&features->features, gaps);
|
||||
if (hide_geometry_shader(inst, physical_device))
|
||||
features->features.geometryShader = VK_FALSE;
|
||||
if (tracing()) {
|
||||
char chain[512] = "";
|
||||
size_t used = 0;
|
||||
@@ -463,6 +484,8 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateInstance(const VkInstanceCreateInfo
|
||||
inst->key = dispatch_key(*instance);
|
||||
inst->handle = *instance;
|
||||
inst->active = wanted();
|
||||
const char *engine = info->pApplicationInfo ? info->pApplicationInfo->pEngineName : NULL;
|
||||
inst->zink = engine && strcmp(engine, "mesa zink") == 0;
|
||||
inst->gipa = gipa;
|
||||
pthread_mutex_init(&inst->lock, NULL);
|
||||
#define LOAD(name) inst->name = (PFN_vk##name)gipa(*instance, "vk" #name);
|
||||
@@ -624,6 +647,9 @@ static VKAPI_ATTR VkResult VKAPI_CALL CreateDevice(VkPhysicalDevice physical_dev
|
||||
if (properties.limits.maxFragmentInputComponents < components)
|
||||
components = properties.limits.maxFragmentInputComponents;
|
||||
dev->max_varying_locations = components / 4;
|
||||
if (inst->active && hide_geometry_shader(inst, physical_device))
|
||||
layer_log("geometryShader is hidden from %s: the driver crashes compiling geometry shaders",
|
||||
inst->zink ? "Zink" : "every application");
|
||||
|
||||
pthread_mutex_lock(&global_lock);
|
||||
dev->next = devices;
|
||||
|
||||
@@ -63,6 +63,7 @@ struct instance {
|
||||
void *key;
|
||||
VkInstance handle;
|
||||
bool active;
|
||||
bool zink; /* the engine is Mesa's Zink */
|
||||
PFN_vkGetInstanceProcAddr gipa;
|
||||
PFN_vkDestroyInstance DestroyInstance;
|
||||
PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties;
|
||||
|
||||
Reference in new issue
Block a user