Compare commits

..
Author SHA1 Message Date
The412Banner 1f55688c37 fix(frontend): keep a frontend file only for an added game on an unmounted folder
While an added games folder is unreadable, the sync kept the file of every
vanished shortcut-id game, including games removed in the app, removed Epic
or Battle.net games, and old-card games already added again from a new card.
It now keeps only added games whose folder lies on an unreadable bind, is
not removed, and has no listed added game with the same folder name.
2026-11-27 20:16:53 +00:00
The412Banner c74c20b880 fix(frontend): keep only added-game files while an added games folder is unreadable 2026-11-26 08:54:27 +00:00
The412Banner bbdec91c43 fix(frontend): game file sync keeps running when an added games folder is gone 2026-11-26 08:48:42 +00:00
52 changed files with 114 additions and 1412 deletions

No files matched your search

-1
View File
@@ -68,7 +68,6 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
- Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05.
- mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)).
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source. The fix for host stack left behind when a program leaves a signal handler without returning follows the approach suggested in [FEX-Emu/FEX#2487](https://github.com/FEX-Emu/FEX/issues/2487). The host stack fix for system calls that end a block is a backport of Ryan Houdek's [FEX-Emu/FEX#6122](https://github.com/FEX-Emu/FEX/pull/6122).
- x86-64 programs on Wayland reach the GPU through FEX's Wayland client, wayland-egl and EGL thunks. The guest `wl_list` and `wl_array` helpers follow [libwayland](https://gitlab.freedesktop.org/wayland/wayland)'s `src/wayland-util.c` (MIT). The EGL extension table comes from the [Khronos EGL registry](https://github.com/KhronosGroup/EGL-Registry) (Apache-2.0) and Mesa's `egl_other.xml` (MIT).
- x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence.
- DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence.
- x86 programs linking OpenSSL 3 use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt). x86 Linux games get the `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes.
@@ -403,6 +403,18 @@ object AddedGames {
Log.i(TAG, "games: bound $dir at $guest")
}
fun unmountedShortcuts(context: Context, listed: List<Library.SteamGame>): Set<String> {
val gone = roots(context).filter { it.host.listFiles() == null }.map { it.host.path }
if (gone.isEmpty()) return emptySet()
val removed = SessionPrefs.removedAddedGames(context).toSet()
val present = listed.filter { it.library == Library.ADDED }.mapNotNull { it.gameFiles?.name?.lowercase() }.toSet()
return AddedExes.list(context).map { File(it.folder) }
.filter { f -> f.path !in removed && gone.any { f.path == it || inside(f.path, it) } && !f.isDirectory && f.name.lowercase() !in present }
.mapNotNull { SessionPrefs.addedGameStoredAppId(context, it.path) }
.map(com.droiddeck.launcher.stores.epic.EpicClient::gameId)
.toSet()
}
private fun listedFolders(context: Context, removed: Set<String>): List<String> {
val out = ArrayList<String>()
val entries = entryFolders(context)
@@ -46,8 +46,8 @@ object GameFileSync {
check(libraryReadable(File(previousStorage))) { context.getString(R.string.game_sync_err_previous_sd) }
}
storage?.let { check(libraryReadable(File(it.path))) { context.getString(R.string.game_sync_err_game_storage) } }
AddedGames.roots(context).forEach { check(it.host.listFiles() != null) { context.getString(R.string.game_sync_err_added_games) } }
GameFiles.sync(context, folder, Library.launchableGames(context, strictRead = true))
val games = Library.launchableGames(context, strictRead = true)
GameFiles.sync(context, folder, games, keep = AddedGames.unmountedShortcuts(context, games))
prefs(context).edit().putString("storageSetting", storageSetting).putString("storagePath", storage?.path).apply()
}
@@ -144,7 +144,7 @@ object GameFiles {
if (!target.exists()) AtomicFile(target).writeBytes(art.readBytes())
}
@Synchronized fun sync(context: Context, folder: File, games: List<Library.SteamGame>) {
@Synchronized fun sync(context: Context, folder: File, games: List<Library.SteamGame>, keep: Set<String> = emptySet()) {
require(folder.isDirectory) { context.getString(R.string.gfiles_folder_unavailable) }
val inventory = child(context, folder, INVENTORY)
val previous = if (inventory.exists()) {
@@ -168,13 +168,15 @@ object GameFiles {
if (!existed || owned) next.put(file.name, game.gameIdString)
file
}
val kept = keep - unique.map { it.gameIdString }.toSet()
for (name in previous.keys()) {
val id = previous.getString(name)
if (!next.has(name) && ours(name) && GameLaunchLink.validId(id)) {
val file = child(context, folder, name)
if (matches(file, contents(id))) {
val retained = exports.any { java.nio.file.Files.isSameFile(it.toPath(), file.toPath()) }
if (!retained) check(file.delete()) { context.getString(R.string.gfiles_remove_failed, name) }
if (!retained && id in kept) next.put(name, id)
else if (!retained) check(file.delete()) { context.getString(R.string.gfiles_remove_failed, name) }
}
}
}
@@ -363,23 +363,10 @@ public final class LinuxRuntime {
};
public static String gpuStandIn(Context context) {
return gpuStandIn(path -> new File(path).exists(),
() -> maliGuestDriver(com.droiddeck.launcher.core.DeviceSupport.INSTANCE.openDriverActive(context),
() -> com.droiddeck.launcher.session.VenusComponent.wanted(context),
com.droiddeck.launcher.session.SessionState.INSTANCE.getMode()),
() -> com.droiddeck.launcher.core.DeviceSupport.INSTANCE.vkBridge(context));
}
static boolean maliGuestDriver(boolean openDriver, java.util.function.BooleanSupplier venus, String sessionMode) {
return openDriver || (com.droiddeck.launcher.session.SessionService.MODE_DESKTOP.equals(sessionMode) && venus.getAsBoolean());
}
static String gpuStandIn(java.util.function.Predicate<String> exists, java.util.function.BooleanSupplier maliGuestDriver,
java.util.function.BooleanSupplier bridge) {
if (exists.test(KGSL_DEVICE)) return KGSL_DEVICE;
if (maliGuestDriver.getAsBoolean() && exists.test(MALI_DEVICE)) return MALI_DEVICE;
if (!bridge.getAsBoolean()) return null;
return bridgeStandIn(exists);
if (new File(KGSL_DEVICE).exists()) return KGSL_DEVICE;
if (com.droiddeck.launcher.core.DeviceSupport.INSTANCE.openDriverActive(context) && new File(MALI_DEVICE).exists()) return MALI_DEVICE;
if (!com.droiddeck.launcher.core.DeviceSupport.INSTANCE.vkBridge(context)) return null;
return bridgeStandIn(path -> new File(path).exists());
}
static String bridgeStandIn(java.util.function.Predicate<String> exists) {
@@ -1066,8 +1066,8 @@ class SessionService : Service() {
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
}
guest.add("DD_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
}
if (!bridge) LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
val tuOverride = tuDebugOverride()
val tuDriver = sysmemDriver(linuxDriverId)
if (!venus && com.droiddeck.launcher.core.DeviceSupport.adreno()) (tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
-1
View File
@@ -1890,7 +1890,6 @@
<string name="game_sync_err_steam_library">مكتبة Steam غير متاحة</string>
<string name="game_sync_err_previous_sd">مكتبة SD السابقة غير متاحة</string>
<string name="game_sync_err_game_storage">مساحة تخزين الألعاب غير متاحة</string>
<string name="game_sync_err_added_games">مجلد الألعاب المضافة غير متاح</string>
<string name="game_sync_err_manifests">ملفات البيان في Steam غير متاحة</string>
<string name="content_system_many">أنظمة متعددة</string>
<string name="fm_drive_internal">التخزين الداخلي</string>
@@ -1903,7 +1903,6 @@
<string name="game_sync_err_steam_library">La biblioteca de Steam no está disponible</string>
<string name="game_sync_err_previous_sd">La biblioteca anterior de la SD no está disponible</string>
<string name="game_sync_err_game_storage">El almacenamiento de juegos no está disponible</string>
<string name="game_sync_err_added_games">La carpeta de juegos agregados no está disponible</string>
<string name="game_sync_err_manifests">Los manifiestos de Steam no están disponibles</string>
<string name="content_system_many">Varios sistemas</string>
<string name="fm_drive_internal">Interno</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Библиотеката на Steam не е достъпна</string>
<string name="game_sync_err_previous_sd">Предишната SD библиотека не е достъпна</string>
<string name="game_sync_err_game_storage">Хранилището за игри не е достъпно</string>
<string name="game_sync_err_added_games">Папката с добавени игри не е достъпна</string>
<string name="game_sync_err_manifests">Манифестите на Steam не са достъпни</string>
<string name="content_system_many">Много системи</string>
<string name="fm_drive_internal">Вътрешна</string>
-1
View File
@@ -1852,7 +1852,6 @@
<string name="game_sync_err_steam_library">Knihovna Steamu není dostupná</string>
<string name="game_sync_err_previous_sd">Předchozí knihovna na SD kartě není dostupná</string>
<string name="game_sync_err_game_storage">Úložiště her není dostupné</string>
<string name="game_sync_err_added_games">Složka přidaných her není dostupná</string>
<string name="game_sync_err_manifests">Manifesty Steamu nejsou dostupné</string>
<string name="content_system_many">Mnoho systémů</string>
<string name="fm_drive_internal">Interní</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam-biblioteket er ikke tilgængeligt</string>
<string name="game_sync_err_previous_sd">Det tidligere SD-bibliotek er ikke tilgængeligt</string>
<string name="game_sync_err_game_storage">Spillagring er ikke tilgængelig</string>
<string name="game_sync_err_added_games">Mappen med tilføjede spil er ikke tilgængelig</string>
<string name="game_sync_err_manifests">Steam-manifester er ikke tilgængelige</string>
<string name="content_system_many">Mange systemer</string>
<string name="fm_drive_internal">Intern</string>
-1
View File
@@ -1806,7 +1806,6 @@
<string name="game_sync_err_steam_library">Steam-Bibliothek ist nicht verfügbar</string>
<string name="game_sync_err_previous_sd">Vorherige SD-Bibliothek ist nicht verfügbar</string>
<string name="game_sync_err_game_storage">Spielspeicher ist nicht verfügbar</string>
<string name="game_sync_err_added_games">Ordner für hinzugefügte Spiele ist nicht verfügbar</string>
<string name="game_sync_err_manifests">Steam-Manifeste sind nicht verfügbar</string>
<string name="content_system_many">Viele Systeme</string>
<string name="fm_drive_internal">Intern</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Η βιβλιοθήκη Steam δεν είναι διαθέσιμη</string>
<string name="game_sync_err_previous_sd">Η προηγούμενη βιβλιοθήκη SD δεν είναι διαθέσιμη</string>
<string name="game_sync_err_game_storage">Ο χώρος αποθήκευσης παιχνιδιών δεν είναι διαθέσιμος</string>
<string name="game_sync_err_added_games">Ο φάκελος προστιθέμενων παιχνιδιών δεν είναι διαθέσιμος</string>
<string name="game_sync_err_manifests">Τα manifest του Steam δεν είναι διαθέσιμα</string>
<string name="content_system_many">Πολλά συστήματα</string>
<string name="fm_drive_internal">Εσωτερική</string>
-1
View File
@@ -1833,7 +1833,6 @@
<string name="game_sync_err_steam_library">La biblioteca de Steam no está disponible</string>
<string name="game_sync_err_previous_sd">La biblioteca anterior de la SD no está disponible</string>
<string name="game_sync_err_game_storage">El almacenamiento de juegos no está disponible</string>
<string name="game_sync_err_added_games">La carpeta de juegos añadidos no está disponible</string>
<string name="game_sync_err_manifests">Los manifiestos de Steam no están disponibles</string>
<string name="content_system_many">Varios sistemas</string>
<string name="fm_drive_internal">Interno</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam-kirjasto ei ole käytettävissä</string>
<string name="game_sync_err_previous_sd">Aiempi SD-kirjasto ei ole käytettävissä</string>
<string name="game_sync_err_game_storage">Pelien tallennustila ei ole käytettävissä</string>
<string name="game_sync_err_added_games">Lisättyjen pelien kansio ei ole käytettävissä</string>
<string name="game_sync_err_manifests">Steam-manifestit eivät ole käytettävissä</string>
<string name="content_system_many">Useita järjestelmiä</string>
<string name="fm_drive_internal">Sisäinen</string>
-1
View File
@@ -1832,7 +1832,6 @@
<string name="game_sync_err_steam_library">La bibliothèque Steam n\'est pas disponible</string>
<string name="game_sync_err_previous_sd">L\'ancienne bibliothèque SD n\'est pas disponible</string>
<string name="game_sync_err_game_storage">Le stockage des jeux n\'est pas disponible</string>
<string name="game_sync_err_added_games">Le dossier des jeux ajoutés n\'est pas disponible</string>
<string name="game_sync_err_manifests">Les manifestes Steam ne sont pas disponibles</string>
<string name="content_system_many">Nombreux systèmes</string>
<string name="fm_drive_internal">Interne</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam लाइब्रेरी उपलब्ध नहीं है</string>
<string name="game_sync_err_previous_sd">पिछली SD लाइब्रेरी उपलब्ध नहीं है</string>
<string name="game_sync_err_game_storage">गेम स्टोरेज उपलब्ध नहीं है</string>
<string name="game_sync_err_added_games">जोड़े गए गेम का फ़ोल्डर उपलब्ध नहीं है</string>
<string name="game_sync_err_manifests">Steam मेनिफ़ेस्ट उपलब्ध नहीं हैं</string>
<string name="content_system_many">कई सिस्टम</string>
<string name="fm_drive_internal">इंटरनल</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">A Steam-könyvtár nem elérhető</string>
<string name="game_sync_err_previous_sd">A korábbi SD-könyvtár nem elérhető</string>
<string name="game_sync_err_game_storage">A játéktárhely nem elérhető</string>
<string name="game_sync_err_added_games">A hozzáadott játékok mappája nem elérhető</string>
<string name="game_sync_err_manifests">A Steam-manifesztek nem elérhetők</string>
<string name="content_system_many">Sok rendszer</string>
<string name="fm_drive_internal">Belső</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">Pustaka Steam tidak tersedia</string>
<string name="game_sync_err_previous_sd">Pustaka SD sebelumnya tidak tersedia</string>
<string name="game_sync_err_game_storage">Penyimpanan gim tidak tersedia</string>
<string name="game_sync_err_added_games">Folder gim yang ditambahkan tidak tersedia</string>
<string name="game_sync_err_manifests">Manifes Steam tidak tersedia</string>
<string name="content_system_many">Banyak sistem</string>
<string name="fm_drive_internal">Internal</string>
-1
View File
@@ -1824,7 +1824,6 @@
<string name="game_sync_err_steam_library">La libreria di Steam non è disponibile</string>
<string name="game_sync_err_previous_sd">La libreria SD precedente non è disponibile</string>
<string name="game_sync_err_game_storage">L\'archivio dei giochi non è disponibile</string>
<string name="game_sync_err_added_games">La cartella dei giochi aggiunti non è disponibile</string>
<string name="game_sync_err_manifests">I manifest di Steam non sono disponibili</string>
<string name="content_system_many">Molti sistemi</string>
<string name="fm_drive_internal">Interna</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">Steamライブラリを利用できません</string>
<string name="game_sync_err_previous_sd">以前のSDライブラリを利用できません</string>
<string name="game_sync_err_game_storage">ゲームストレージを利用できません</string>
<string name="game_sync_err_added_games">追加したゲームのフォルダを利用できません</string>
<string name="game_sync_err_manifests">Steamのマニフェストを利用できません</string>
<string name="content_system_many">多数のシステム</string>
<string name="fm_drive_internal">内部</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">Steam 라이브러리를 사용할 수 없습니다</string>
<string name="game_sync_err_previous_sd">이전 SD 라이브러리를 사용할 수 없습니다</string>
<string name="game_sync_err_game_storage">게임 저장 공간을 사용할 수 없습니다</string>
<string name="game_sync_err_added_games">추가된 게임 폴더를 사용할 수 없습니다</string>
<string name="game_sync_err_manifests">Steam 매니페스트를 사용할 수 없습니다</string>
<string name="content_system_many">다양한 기종</string>
<string name="fm_drive_internal">내부</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">Pustaka Steam tidak tersedia</string>
<string name="game_sync_err_previous_sd">Pustaka SD terdahulu tidak tersedia</string>
<string name="game_sync_err_game_storage">Storan permainan tidak tersedia</string>
<string name="game_sync_err_added_games">Folder permainan yang ditambah tidak tersedia</string>
<string name="game_sync_err_manifests">Manifest Steam tidak tersedia</string>
<string name="content_system_many">Banyak sistem</string>
<string name="fm_drive_internal">Dalaman</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam-biblioteket er ikke tilgjengelig</string>
<string name="game_sync_err_previous_sd">Det forrige SD-biblioteket er ikke tilgjengelig</string>
<string name="game_sync_err_game_storage">Spillagringen er ikke tilgjengelig</string>
<string name="game_sync_err_added_games">Mappen for tillagte spill er ikke tilgjengelig</string>
<string name="game_sync_err_manifests">Steam-manifestene er ikke tilgjengelige</string>
<string name="content_system_many">Mange systemer</string>
<string name="fm_drive_internal">Intern</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam-bibliotheek is niet beschikbaar</string>
<string name="game_sync_err_previous_sd">Vorige SD-bibliotheek is niet beschikbaar</string>
<string name="game_sync_err_game_storage">Gameopslag is niet beschikbaar</string>
<string name="game_sync_err_added_games">Map met toegevoegde games is niet beschikbaar</string>
<string name="game_sync_err_manifests">Steam-manifesten zijn niet beschikbaar</string>
<string name="content_system_many">Veel systemen</string>
<string name="fm_drive_internal">Intern</string>
-1
View File
@@ -1852,7 +1852,6 @@
<string name="game_sync_err_steam_library">Biblioteka Steam jest niedostępna</string>
<string name="game_sync_err_previous_sd">Poprzednia biblioteka na karcie SD jest niedostępna</string>
<string name="game_sync_err_game_storage">Miejsce na gry jest niedostępne</string>
<string name="game_sync_err_added_games">Folder dodanych gier jest niedostępny</string>
<string name="game_sync_err_manifests">Manifesty Steam są niedostępne</string>
<string name="content_system_many">Wiele systemów</string>
<string name="fm_drive_internal">Wewnętrzna</string>
@@ -1838,7 +1838,6 @@
<string name="game_sync_err_steam_library">A biblioteca do Steam não está disponível</string>
<string name="game_sync_err_previous_sd">A biblioteca anterior do cartão SD não está disponível</string>
<string name="game_sync_err_game_storage">O armazenamento de jogos não está disponível</string>
<string name="game_sync_err_added_games">A pasta de jogos adicionados não está disponível</string>
<string name="game_sync_err_manifests">Os manifestos do Steam não estão disponíveis</string>
<string name="content_system_many">Vários sistemas</string>
<string name="fm_drive_internal">Interno</string>
-1
View File
@@ -1846,7 +1846,6 @@
<string name="game_sync_err_steam_library">A biblioteca do Steam não está disponível</string>
<string name="game_sync_err_previous_sd">A biblioteca anterior no cartão SD não está disponível</string>
<string name="game_sync_err_game_storage">O armazenamento de jogos não está disponível</string>
<string name="game_sync_err_added_games">A pasta de jogos adicionados não está disponível</string>
<string name="game_sync_err_manifests">Os manifestos do Steam não estão disponíveis</string>
<string name="content_system_many">Vários sistemas</string>
<string name="fm_drive_internal">Interno</string>
-1
View File
@@ -1833,7 +1833,6 @@
<string name="game_sync_err_steam_library">Biblioteca Steam nu este disponibilă</string>
<string name="game_sync_err_previous_sd">Biblioteca SD anterioară nu este disponibilă</string>
<string name="game_sync_err_game_storage">Stocarea jocurilor nu este disponibilă</string>
<string name="game_sync_err_added_games">Folderul de jocuri adăugate nu este disponibil</string>
<string name="game_sync_err_manifests">Manifestele Steam nu sunt disponibile</string>
<string name="content_system_many">Multe sisteme</string>
<string name="fm_drive_internal">Internă</string>
-1
View File
@@ -1853,7 +1853,6 @@
<string name="game_sync_err_steam_library">Библиотека Steam недоступна</string>
<string name="game_sync_err_previous_sd">Предыдущая библиотека на SD-карте недоступна</string>
<string name="game_sync_err_game_storage">Хранилище игр недоступно</string>
<string name="game_sync_err_added_games">Папка добавленных игр недоступна</string>
<string name="game_sync_err_manifests">Манифесты Steam недоступны</string>
<string name="content_system_many">Множество систем</string>
<string name="fm_drive_internal">Внутреннее хранилище</string>
-1
View File
@@ -1814,7 +1814,6 @@
<string name="game_sync_err_steam_library">Steam-biblioteket är inte tillgängligt</string>
<string name="game_sync_err_previous_sd">Det tidigare SD-biblioteket är inte tillgängligt</string>
<string name="game_sync_err_game_storage">Spellagringen är inte tillgänglig</string>
<string name="game_sync_err_added_games">Mappen för tillagda spel är inte tillgänglig</string>
<string name="game_sync_err_manifests">Steam-manifesten är inte tillgängliga</string>
<string name="content_system_many">Många system</string>
<string name="fm_drive_internal">Internt</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">ไลบรารี Steam ไม่พร้อมใช้งาน</string>
<string name="game_sync_err_previous_sd">ไลบรารี SD ก่อนหน้าไม่พร้อมใช้งาน</string>
<string name="game_sync_err_game_storage">พื้นที่จัดเก็บเกมไม่พร้อมใช้งาน</string>
<string name="game_sync_err_added_games">โฟลเดอร์เกมที่เพิ่มไม่พร้อมใช้งาน</string>
<string name="game_sync_err_manifests">ไฟล์ manifest ของ Steam ไม่พร้อมใช้งาน</string>
<string name="content_system_many">หลายระบบ</string>
<string name="fm_drive_internal">ภายใน</string>
-1
View File
@@ -1806,7 +1806,6 @@
<string name="game_sync_err_steam_library">Steam kütüphanesi kullanılamıyor</string>
<string name="game_sync_err_previous_sd">Önceki SD kütüphanesi kullanılamıyor</string>
<string name="game_sync_err_game_storage">Oyun depolama alanı kullanılamıyor</string>
<string name="game_sync_err_added_games">Eklenen oyunlar klasörü kullanılamıyor</string>
<string name="game_sync_err_manifests">Steam manifest dosyaları kullanılamıyor</string>
<string name="content_system_many">Birçok sistem</string>
<string name="fm_drive_internal">Dahili</string>
-1
View File
@@ -1852,7 +1852,6 @@
<string name="game_sync_err_steam_library">Бібліотека Steam недоступна</string>
<string name="game_sync_err_previous_sd">Попередня бібліотека на SD-карті недоступна</string>
<string name="game_sync_err_game_storage">Сховище ігор недоступне</string>
<string name="game_sync_err_added_games">Папка доданих ігор недоступна</string>
<string name="game_sync_err_manifests">Маніфести Steam недоступні</string>
<string name="content_system_many">Багато систем</string>
<string name="fm_drive_internal">Внутрішня пам’ять</string>
-1
View File
@@ -1796,7 +1796,6 @@
<string name="game_sync_err_steam_library">Thư viện Steam không khả dụng</string>
<string name="game_sync_err_previous_sd">Thư viện SD trước đó không khả dụng</string>
<string name="game_sync_err_game_storage">Lưu trữ game không khả dụng</string>
<string name="game_sync_err_added_games">Thư mục game đã thêm không khả dụng</string>
<string name="game_sync_err_manifests">Manifest của Steam không khả dụng</string>
<string name="content_system_many">Nhiều hệ máy</string>
<string name="fm_drive_internal">Nội bộ</string>
@@ -1873,7 +1873,6 @@
<string name="game_sync_err_steam_library">Steam 库不可用</string>
<string name="game_sync_err_previous_sd">之前的 SD 卡库不可用</string>
<string name="game_sync_err_game_storage">游戏存储不可用</string>
<string name="game_sync_err_added_games">已添加游戏的文件夹不可用</string>
<string name="game_sync_err_manifests">Steam 清单文件不可用</string>
<string name="content_system_many">多种平台</string>
<string name="fm_drive_internal">内部存储</string>
@@ -1795,7 +1795,6 @@
<string name="game_sync_err_steam_library">無法使用 Steam 收藏庫</string>
<string name="game_sync_err_previous_sd">無法使用先前的 SD 卡收藏庫</string>
<string name="game_sync_err_game_storage">無法使用遊戲儲存位置</string>
<string name="game_sync_err_added_games">無法使用已新增遊戲的資料夾</string>
<string name="game_sync_err_manifests">無法使用 Steam 清單檔案</string>
<string name="content_system_many">多個系統</string>
<string name="fm_drive_internal">內部</string>
@@ -1795,7 +1795,6 @@
<string name="game_sync_err_steam_library">無法使用 Steam 收藏庫</string>
<string name="game_sync_err_previous_sd">無法使用先前的 SD 卡收藏庫</string>
<string name="game_sync_err_game_storage">無法使用遊戲儲存空間</string>
<string name="game_sync_err_added_games">無法使用已新增遊戲的資料夾</string>
<string name="game_sync_err_manifests">無法使用 Steam 資訊清單</string>
<string name="content_system_many">多種主機</string>
<string name="fm_drive_internal">內部</string>
-1
View File
@@ -2054,7 +2054,6 @@
<string name="game_sync_err_steam_library">Steam library is unavailable</string>
<string name="game_sync_err_previous_sd">Previous SD library is unavailable</string>
<string name="game_sync_err_game_storage">Game storage is unavailable</string>
<string name="game_sync_err_added_games">Added games folder is unavailable</string>
<string name="game_sync_err_manifests">Steam manifests are unavailable</string>
<string name="content_system_many">Many systems</string>
<string name="fm_drive_internal">Internal</string>
@@ -72,6 +72,61 @@ class GameFileSyncTest {
GameFileSync.disable(context)
}
@Test fun unmountedAddedGamesKeepTheirFilesWithoutStoppingTheSync() {
val context = RuntimeEnvironment.getApplication()
val root = LinuxRuntime.rootDir(context)
listOf("usr/bin/gamescope", LinuxRuntime.SESSION_SCRIPT.removePrefix("/")).forEach { path ->
File(root, path).apply { parentFile!!.mkdirs(); writeText("") }
}
AddonPack.PROOT.file(context, AddonPack.COMPLETE).apply { parentFile!!.mkdirs(); writeText("") }
SessionPrefs.setGameStorage(context, SessionPrefs.GAME_STORAGE_OFF, "")
SessionPrefs.setAddedGamesDirs(context, emptyList())
val steamapps = File(root, "root/.local/share/Steam/steamapps").apply { mkdirs() }
val manifest = File(steamapps, "appmanifest_8400.acf").apply {
writeText("\"AppState\"\n{\n\"name\" \"Geometry Wars\"\n\"StateFlags\" \"4\"\n}")
}
val card = File(context.filesDir, "old-card/Games")
val solo = File(context.filesDir, "old-card/Solo")
SessionPrefs.setGameFolderBinds(context, listOf(card.path to "${AddedGames.GUEST_DIR}/Games", solo.path to "${AddedGames.GUEST_DIR}/Solo"))
val shortcuts = listOf("Card Game" to 0xC0FFEE01L, "Card Removed" to 0xC0FFEE02L, "Card Copy" to 0xC0FFEE03L, "Solo" to 0xC0FFEE04L).map { (name, appId) ->
val dir = if (name == "Solo") solo else File(card, name)
AddedExes.put(context, AddedExes.Entry(dir.path, File(dir, "game.exe").path))
SessionPrefs.addedGameAppId(context, dir.path, appId)
Library.SteamGame(0, name, null, Library.ADDED, (appId shl 32) or 0x02000000L, gameFiles = dir)
}
val (kept, removed, copied, single) = shortcuts
val folder = File(context.filesDir, "exports-added").apply { mkdirs() }
GameFileSync.enable(context, folder)
assertEquals(folder.path, GameFileSync.folder(context))
assertEquals("8400", File(folder, "Geometry Wars.steam").readText())
GameFiles.sync(context, folder, Library.launchableGames(context, strictRead = true) + shortcuts)
shortcuts.forEach { assertEquals(it.gameIdString, File(folder, "${it.name}.steam").readText()) }
SessionPrefs.setAddedGameRemoved(context, removed.gameFiles!!.path, true)
assertTrue(manifest.delete())
File(steamapps, "appmanifest_620.acf").writeText("\"AppState\"\n{\n\"name\" \"Portal 2\"\n\"StateFlags\" \"4\"\n}")
GameFileSync.syncConfigured(context)
assertEquals("620", File(folder, "Portal 2.steam").readText())
assertFalse(File(folder, "Geometry Wars.steam").exists())
assertEquals(kept.gameIdString, File(folder, "Card Game.steam").readText())
assertEquals(copied.gameIdString, File(folder, "Card Copy.steam").readText())
assertEquals(single.gameIdString, File(folder, "Solo.steam").readText())
assertFalse(File(folder, "Card Removed.steam").exists())
val copy = Library.SteamGame(0, "Card Copy", null, Library.ADDED, (0xBEEF0003L shl 32) or 0x02000000L,
gameFiles = File(context.filesDir, "new-card/Games/Card Copy"))
val steamCopy = Library.SteamGame(8400, "Card Game", null, "internal", gameFiles = File(context.filesDir, "steam/Card Game"))
assertEquals(setOf(kept.gameIdString, single.gameIdString), AddedGames.unmountedShortcuts(context, listOf(copy, steamCopy)))
assertTrue(card.mkdirs())
assertEquals(setOf(single.gameIdString), AddedGames.unmountedShortcuts(context, emptyList()))
assertTrue(solo.mkdirs())
assertEquals(emptySet<String>(), AddedGames.unmountedShortcuts(context, emptyList()))
GameFileSync.syncConfigured(context)
shortcuts.forEach { assertFalse(File(folder, "${it.name}.steam").exists()) }
assertTrue(File(folder, "Portal 2.steam").isFile)
GameFileSync.disable(context)
shortcuts.forEach { AddedExes.drop(context, it.gameFiles!!.path) }
SessionPrefs.setGameFolderBinds(context, emptyList())
}
@Test fun libraryReadableOnlyWhenListableOrNotCreatedOnPresentParent() {
val base = File(RuntimeEnvironment.getApplication().filesDir, "readable").apply { mkdirs() }
assertTrue(GameFileSync.libraryReadable(File(base, "dir").apply { mkdirs() }))
@@ -142,6 +142,35 @@ class GameFilesTest {
assertEquals("user edit", modified.readText())
}
@Test fun syncKeepsOnlyVanishedGamesItIsAskedToKeep() {
val folder = tmp.newFolder()
val steam = game()
val second = game("620", "Portal 2")
val shortcut = game(java.lang.Long.toUnsignedString((0xC0FFEE01L shl 32) or 0x02000000L), "Card Game")
val dropped = game(java.lang.Long.toUnsignedString((0xC0FFEE03L shl 32) or 0x02000000L), "Card Removed")
val moved = game(java.lang.Long.toUnsignedString((0xC0FFEE02L shl 32) or 0x02000000L), "Card Tool")
GameFiles.sync(app, folder, listOf(steam, second, shortcut, dropped, moved))
val renamed = game("620", "Portal 2 Remastered")
val third = game("1", "New install")
val movedRenamed = game(moved.gameIdString, "Card Tool Deluxe")
val keep = setOf(steam.gameIdString, shortcut.gameIdString, moved.gameIdString)
GameFiles.sync(app, folder, listOf(renamed, third, movedRenamed), keep = keep)
assertEquals("8400", File(folder, GameFiles.filename(steam)).readText())
assertEquals(shortcut.gameIdString, File(folder, GameFiles.filename(shortcut)).readText())
assertFalse(File(folder, GameFiles.filename(dropped)).exists())
assertFalse(File(folder, GameFiles.filename(second)).exists())
assertFalse(File(folder, GameFiles.filename(moved)).exists())
assertEquals("620", File(folder, GameFiles.filename(renamed)).readText())
assertEquals("1", File(folder, GameFiles.filename(third)).readText())
assertEquals(moved.gameIdString, File(folder, GameFiles.filename(movedRenamed)).readText())
GameFiles.sync(app, folder, listOf(renamed, third, movedRenamed))
assertFalse(File(folder, GameFiles.filename(steam)).exists())
assertFalse(File(folder, GameFiles.filename(shortcut)).exists())
assertTrue(File(folder, GameFiles.filename(renamed)).isFile)
assertTrue(File(folder, GameFiles.filename(third)).isFile)
assertTrue(File(folder, GameFiles.filename(movedRenamed)).isFile)
}
@Test fun failedExportDoesNotPruneOldInventoryAndNeverOverwritesCollisions() {
val folder = tmp.newFolder()
val first = game()
@@ -1,68 +0,0 @@
package com.droiddeck.launcher.runtime
import android.app.Application
import com.droiddeck.launcher.session.SessionService
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33], manifest = Config.NONE, application = Application::class)
class LinuxRuntimeGpuStandInTest {
private val kgsl = "/dev/kgsl-3d0"
private fun standIn(nodes: Set<String>, maliGuestDriver: Boolean, bridge: Boolean): String? =
LinuxRuntime.gpuStandIn({ it in nodes }, { maliGuestDriver }, { bridge })
@Test fun maliGuestDriverGetsTheMaliNode() {
assertEquals(LinuxRuntime.MALI_DEVICE, standIn(setOf(LinuxRuntime.MALI_DEVICE), maliGuestDriver = true, bridge = false))
}
@Test fun maliWithoutAGuestDriverOrBridgeGetsNoNode() {
assertNull(standIn(setOf(LinuxRuntime.MALI_DEVICE, "/dev/dri/renderD128"), maliGuestDriver = false, bridge = false))
}
@Test fun maliGuestDriverWithoutTheMaliNodeGetsNoNode() {
assertNull(standIn(setOf("/dev/dri/renderD128"), maliGuestDriver = true, bridge = false))
}
@Test fun kgslStaysTheStandInWheneverItExists() {
assertEquals(kgsl, standIn(setOf(kgsl, LinuxRuntime.MALI_DEVICE), maliGuestDriver = true, bridge = true))
assertEquals(kgsl, standIn(setOf(kgsl), maliGuestDriver = false, bridge = false))
}
@Test fun bridgeKeepsItsOwnNodeChoice() {
assertEquals("/dev/dri/renderD129", standIn(setOf("/dev/dri/renderD129"), maliGuestDriver = false, bridge = true))
assertEquals(LinuxRuntime.MALI_DEVICE, standIn(setOf(LinuxRuntime.MALI_DEVICE), maliGuestDriver = false, bridge = true))
}
@Test fun guestDriverIsNotAskedWhenKgslExists() {
var asked = false
LinuxRuntime.gpuStandIn({ it == kgsl }, { asked = true; true }, { asked = true; true })
assertEquals(false, asked)
}
@Test fun venusGetsTheMaliNodeOnlyOnDesktop() {
assertTrue(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_DESKTOP))
assertFalse(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_STEAM))
assertFalse(LinuxRuntime.maliGuestDriver(false, { true }, SessionService.MODE_RUN))
assertFalse(LinuxRuntime.maliGuestDriver(false, { false }, SessionService.MODE_DESKTOP))
}
@Test fun openDriverPairGetsTheMaliNodeInEveryMode() {
for (mode in listOf(SessionService.MODE_STEAM, SessionService.MODE_DESKTOP, SessionService.MODE_RUN)) {
assertTrue(LinuxRuntime.maliGuestDriver(true, { false }, mode))
}
}
@Test fun venusIsNotAskedOutsideDesktop() {
var asked = false
LinuxRuntime.maliGuestDriver(false, { asked = true; true }, SessionService.MODE_STEAM)
assertFalse(asked)
}
}
-8
View File
@@ -149,14 +149,6 @@ The SPIR-V version the driver gets:
only taken out where the layer emulates them. `DROIDDECK_MALI_COMPAT=0` turns both off.
- 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.
- Render node: Zink binds a GBM or DRI screen (KWin, Xwayland's glamor) to the Vulkan device
whose `VkPhysicalDeviceDrmPropertiesEXT` render node matches the screen's DRM fd. Venus over
vtest reports none, so KWin 6.8, which has no QPainter compositor, drew nothing on Desktop.
When the driver reports no render node, the layer reports the stand-in node's numbers
(`DD_DRM_STANDIN=/dev/mali0`, bound into the guest as `/dev/dri/renderD<minor>`). The
extension stays unlisted, and the layer is off in gamescope, so gamescope keeps its no-DRM path.
Venus gets the stand-in node only in Desktop sessions. Steam and program sessions keep running
without one, so their Xwayland, Zink and gamescope paths stay as they were.
Files:
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
+2 -3
View File
@@ -44,9 +44,8 @@ through `kwin_wayland_wrapper`. The package's `kwin-compositor` marker selects O
Zink for KWin 6.8, which removed QPainter. Older packages retain their software compositor.
KWin runs without Gallium's threaded context and without overlay layers. With the threaded context, KWin crashed
uploading windows' shared-memory buffers by reading past their end, and the host shows only a single buffer.
On Android the launcher explicitly selects the GPU's render node (KGSL, or `/dev/mali0` as a
stand-in for the Mali open driver, and for Venus in Desktop sessions); the nested backend can use it when the host's dmabuf
feedback cannot name a DRM device. Without one, KWin 6.8 has no compositor and the desktop stays black. Games and emulators from the menu go
On Android the launcher explicitly selects the KGSL render node; the nested backend can use it
when the host's dmabuf feedback cannot name a DRM device. Games and emulators from the menu go
through `droiddeck-gpu`, and Steam goes back to the app as a Steam session.
`kwin.env` pins the KWin version shared by the build and packaging jobs. `build-kwin.sh` builds that version's
@@ -1,982 +0,0 @@
diff --git a/Data/ThunksDB.json b/Data/ThunksDB.json
index 886379a..7844b27 100644
--- a/Data/ThunksDB.json
+++ b/Data/ThunksDB.json
@@ -49,6 +49,24 @@
"@PREFIX_LIB@/libwayland-client.so.0.20.0"
]
},
+ "EGL": {
+ "Library" : "libEGL-guest.so",
+ "Overlay": [
+ "@PREFIX_LIB@/libEGL.so",
+ "@PREFIX_LIB@/libEGL.so.1",
+ "@PREFIX_LIB@/libEGL.so.1.1.0",
+ "@PREFIX_LIB@/libGLESv2.so.2",
+ "@PREFIX_LIB@/libGLESv2.so.2.1.0"
+ ]
+ },
+ "WaylandEGL": {
+ "Library" : "libwayland-egl-guest.so",
+ "Overlay": [
+ "@PREFIX_LIB@/libwayland-egl.so",
+ "@PREFIX_LIB@/libwayland-egl.so.1",
+ "@PREFIX_LIB@/libwayland-egl.so.1.0.0"
+ ]
+ },
"cuda": {
"Library" : "libcuda-guest.so",
"Overlay": [
diff --git a/ThunkLibs/GuestLibs/CMakeLists.txt b/ThunkLibs/GuestLibs/CMakeLists.txt
index bf666d9..72b0832 100644
--- a/ThunkLibs/GuestLibs/CMakeLists.txt
+++ b/ThunkLibs/GuestLibs/CMakeLists.txt
@@ -211,6 +211,21 @@ if (BITNESS EQUAL 64)
target_include_directories_from_pkgconfig(libasound-guest-deps alsa)
add_guest_lib(asound "libasound.so.2")
+ generate(libwayland-client ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-client/libwayland-client_interface.cpp)
+ add_guest_lib(wayland-client "libwayland-client.so.0.20.0")
+ target_include_directories_from_pkgconfig(libwayland-client-guest-deps wayland-client /usr/include/wayland)
+
+ generate(libwayland-egl ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-egl/libwayland-egl_interface.cpp)
+ add_guest_lib(wayland-egl "libwayland-egl.so.1")
+ target_include_directories_from_pkgconfig(libwayland-egl-guest-deps wayland-egl /usr/include/wayland)
+
+ generate(libEGL ${CMAKE_CURRENT_SOURCE_DIR}/../libEGL/libEGL_interface.cpp)
+ target_include_directories_from_pkgconfig(libEGL-guest-deps egl)
+ add_guest_lib(EGL "libEGL.so.1")
+ target_link_libraries(EGL-guest PRIVATE GL-guest)
+ target_link_libraries(EGL-guest PRIVATE PlaceholderX11)
+ target_include_directories_from_pkgconfig(libEGL-guest-deps "xcb;x11")
+
# disabled for now, headers are platform specific
# find_package(SDL2 REQUIRED)
# generate(libSDL2)
@@ -229,10 +244,6 @@ if (BITNESS EQUAL 64)
add_guest_lib(drm "libdrm.so.2")
endif()
-generate(libwayland-client ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-client/libwayland-client_interface.cpp)
-add_guest_lib(wayland-client "libwayland-client.so.0.20.0")
-target_include_directories_from_pkgconfig(libwayland-client-guest-deps wayland-client /usr/include/wayland)
-
generate(libVDSO ${CMAKE_CURRENT_SOURCE_DIR}/../libVDSO/libVDSO_interface.cpp)
add_guest_lib(VDSO "linux-vdso.so.1")
# Can't use a stack protector because otherwise cross-compiling fails
@@ -271,11 +282,6 @@ target_include_directories_from_pkgconfig(libGL-guest-deps gl)
target_include_directories_from_pkgconfig(libGL-guest-deps "xcb;x11;xrandr;xrender")
add_guest_lib(GL "libGL.so.1")
-generate(libEGL ${CMAKE_CURRENT_SOURCE_DIR}/../libEGL/libEGL_interface.cpp)
-target_include_directories_from_pkgconfig(libEGL-guest-deps egl)
-add_guest_lib(EGL "libEGL.so.1")
-target_link_libraries(EGL-guest PRIVATE GL-guest)
-
# libGL must pull in libX11.so, so generate a placeholder libX11.so to link against
add_library(PlaceholderX11 SHARED ../libX11/libX11_NativeGuest.cpp)
target_link_options(PlaceholderX11 PRIVATE "LINKER:-soname,libX11.so.6")
diff --git a/ThunkLibs/HostLibs/CMakeLists.txt b/ThunkLibs/HostLibs/CMakeLists.txt
index 8d18d0e..c10066f 100644
--- a/ThunkLibs/HostLibs/CMakeLists.txt
+++ b/ThunkLibs/HostLibs/CMakeLists.txt
@@ -167,13 +167,19 @@ foreach(GUEST_BITNESS IN LISTS BITNESS_LIST)
target_include_directories_from_pkgconfig(libvulkan-${GUEST_BITNESS}-deps "xcb;x11;xrandr;xrender")
add_host_lib(vulkan ${GUEST_BITNESS})
- generate(libwayland-client ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-client/libwayland-client_interface.cpp ${GUEST_BITNESS})
- add_host_lib(wayland-client ${GUEST_BITNESS})
- target_include_directories_from_pkgconfig(libwayland-client-${GUEST_BITNESS}-deps wayland-client /usr/include/wayland)
-
- generate(libEGL ${CMAKE_CURRENT_SOURCE_DIR}/../libEGL/libEGL_interface.cpp ${GUEST_BITNESS})
- target_include_directories_from_pkgconfig(libEGL-${GUEST_BITNESS}-deps egl)
- add_host_lib(EGL ${GUEST_BITNESS})
+ if (GUEST_BITNESS EQUAL 64)
+ generate(libwayland-client ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-client/libwayland-client_interface.cpp ${GUEST_BITNESS})
+ add_host_lib(wayland-client ${GUEST_BITNESS})
+ target_include_directories_from_pkgconfig(libwayland-client-${GUEST_BITNESS}-deps wayland-client /usr/include/wayland)
+
+ generate(libwayland-egl ${CMAKE_CURRENT_SOURCE_DIR}/../libwayland-egl/libwayland-egl_interface.cpp ${GUEST_BITNESS})
+ add_host_lib(wayland-egl ${GUEST_BITNESS})
+ target_include_directories_from_pkgconfig(libwayland-egl-${GUEST_BITNESS}-deps wayland-egl /usr/include/wayland)
+
+ generate(libEGL ${CMAKE_CURRENT_SOURCE_DIR}/../libEGL/libEGL_interface.cpp ${GUEST_BITNESS})
+ target_include_directories_from_pkgconfig(libEGL-${GUEST_BITNESS}-deps "egl;xcb;x11")
+ add_host_lib(EGL ${GUEST_BITNESS})
+ endif()
generate(libGL ${CMAKE_CURRENT_SOURCE_DIR}/../libGL/libGL_interface.cpp ${GUEST_BITNESS})
target_include_directories_from_pkgconfig(libGL-${GUEST_BITNESS}-deps gl)
diff --git a/ThunkLibs/libEGL/libEGL_Guest.cpp b/ThunkLibs/libEGL/libEGL_Guest.cpp
index c157f00..196c7e8 100644
--- a/ThunkLibs/libEGL/libEGL_Guest.cpp
+++ b/ThunkLibs/libEGL/libEGL_Guest.cpp
@@ -5,11 +5,22 @@ desc: Depends on glXGetProcAddress thunk
$end_info$
*/
+#define EGL_EGLEXT_PROTOTYPES 1
#include <GL/glx.h>
#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <X11/Xlib.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <dlfcn.h>
#include <stdio.h>
#include <cstring>
+#include <mutex>
+#include <set>
+#include <string>
+#include <string_view>
#include "common/Guest.h"
@@ -17,12 +28,128 @@ $end_info$
typedef void voidFunc();
+static void* Self() {
+ static void* self = [] {
+ Dl_info info {};
+ return dladdr(reinterpret_cast<void*>(&Self), &info) && info.dli_fname ? dlopen(info.dli_fname, RTLD_LAZY | RTLD_NOLOAD) : nullptr;
+ }();
+ return self;
+}
+
+static constexpr std::pair<std::string_view, std::string_view> ExtensionEntrypoints[] = {
+ {"EGL_ANDROID_blob_cache", "eglSetBlobCacheFuncsANDROID"},
+ {"EGL_ANDROID_create_native_client_buffer", "eglCreateNativeClientBufferANDROID"},
+ {"EGL_ANDROID_get_frame_timestamps", "eglGetCompositorTimingSupportedANDROID eglGetCompositorTimingANDROID eglGetNextFrameIdANDROID eglGetFrameTimestampSupportedANDROID eglGetFrameTimestampsANDROID"},
+ {"EGL_ANDROID_get_native_client_buffer", "eglGetNativeClientBufferANDROID"},
+ {"EGL_ANDROID_native_fence_sync", "eglDupNativeFenceFDANDROID"},
+ {"EGL_ANDROID_presentation_time", "eglPresentationTimeANDROID"},
+ {"EGL_ANGLE_query_surface_pointer", "eglQuerySurfacePointerANGLE"},
+ {"EGL_ANGLE_sync_control_rate", "eglGetMscRateANGLE"},
+ {"EGL_EXT_client_sync", "eglClientSignalSyncEXT"},
+ {"EGL_EXT_compositor", "eglCompositorSetContextListEXT eglCompositorSetContextAttributesEXT eglCompositorSetWindowListEXT eglCompositorSetWindowAttributesEXT eglCompositorBindTexWindowEXT eglCompositorSetSizeEXT eglCompositorSwapPolicyEXT"},
+ {"EGL_EXT_device_base", "eglQueryDeviceAttribEXT eglQueryDeviceStringEXT eglQueryDevicesEXT eglQueryDisplayAttribEXT"},
+ {"EGL_EXT_device_enumeration", "eglQueryDevicesEXT"},
+ {"EGL_EXT_device_persistent_id", "eglQueryDeviceBinaryEXT"},
+ {"EGL_EXT_device_query", "eglQueryDeviceAttribEXT eglQueryDeviceStringEXT eglQueryDisplayAttribEXT"},
+ {"EGL_EXT_image_dma_buf_import_modifiers", "eglQueryDmaBufFormatsEXT eglQueryDmaBufModifiersEXT"},
+ {"EGL_EXT_output_base", "eglGetOutputLayersEXT eglGetOutputPortsEXT eglOutputLayerAttribEXT eglQueryOutputLayerAttribEXT eglQueryOutputLayerStringEXT eglOutputPortAttribEXT eglQueryOutputPortAttribEXT eglQueryOutputPortStringEXT"},
+ {"EGL_EXT_platform_base", "eglGetPlatformDisplayEXT eglCreatePlatformWindowSurfaceEXT eglCreatePlatformPixmapSurfaceEXT"},
+ {"EGL_EXT_stream_consumer_egloutput", "eglStreamConsumerOutputEXT"},
+ {"EGL_EXT_surface_compression", "eglQuerySupportedCompressionRatesEXT"},
+ {"EGL_EXT_swap_buffers_with_damage", "eglSwapBuffersWithDamageEXT"},
+ {"EGL_EXT_sync_reuse", "eglUnsignalSyncEXT"},
+ {"EGL_HI_clientpixmap", "eglCreatePixmapSurfaceHI"},
+ {"EGL_KHR_cl_event2", "eglCreateSync64KHR"},
+ {"EGL_KHR_debug", "eglDebugMessageControlKHR eglQueryDebugKHR eglLabelObjectKHR"},
+ {"EGL_KHR_display_reference", "eglQueryDisplayAttribKHR"},
+ {"EGL_KHR_fence_sync", "eglCreateSyncKHR eglDestroySyncKHR eglClientWaitSyncKHR eglGetSyncAttribKHR"},
+ {"EGL_KHR_image", "eglCreateImageKHR eglDestroyImageKHR"},
+ {"EGL_KHR_image_base", "eglCreateImageKHR eglDestroyImageKHR"},
+ {"EGL_KHR_lock_surface", "eglLockSurfaceKHR eglUnlockSurfaceKHR"},
+ {"EGL_KHR_lock_surface3", "eglLockSurfaceKHR eglUnlockSurfaceKHR eglQuerySurface64KHR"},
+ {"EGL_KHR_partial_update", "eglSetDamageRegionKHR"},
+ {"EGL_KHR_reusable_sync", "eglCreateSyncKHR eglDestroySyncKHR eglClientWaitSyncKHR eglSignalSyncKHR eglGetSyncAttribKHR"},
+ {"EGL_KHR_stream", "eglCreateStreamKHR eglDestroyStreamKHR eglStreamAttribKHR eglQueryStreamKHR eglQueryStreamu64KHR"},
+ {"EGL_KHR_stream_attrib", "eglCreateStreamAttribKHR eglSetStreamAttribKHR eglQueryStreamAttribKHR eglStreamConsumerAcquireAttribKHR eglStreamConsumerReleaseAttribKHR"},
+ {"EGL_KHR_stream_consumer_gltexture", "eglStreamConsumerGLTextureExternalKHR eglStreamConsumerAcquireKHR eglStreamConsumerReleaseKHR"},
+ {"EGL_KHR_stream_cross_process_fd", "eglGetStreamFileDescriptorKHR eglCreateStreamFromFileDescriptorKHR"},
+ {"EGL_KHR_stream_fifo", "eglQueryStreamTimeKHR"},
+ {"EGL_KHR_stream_producer_eglsurface", "eglCreateStreamProducerSurfaceKHR"},
+ {"EGL_KHR_swap_buffers_with_damage", "eglSwapBuffersWithDamageKHR"},
+ {"EGL_KHR_wait_sync", "eglWaitSyncKHR"},
+ {"EGL_MESA_drm_image", "eglCreateDRMImageMESA eglExportDRMImageMESA"},
+ {"EGL_MESA_image_dma_buf_export", "eglExportDMABUFImageQueryMESA eglExportDMABUFImageMESA"},
+ {"EGL_MESA_query_driver", "eglGetDisplayDriverConfig eglGetDisplayDriverName"},
+ {"EGL_NOK_swap_region", "eglSwapBuffersRegionNOK"},
+ {"EGL_NOK_swap_region2", "eglSwapBuffersRegion2NOK"},
+ {"EGL_NV_native_query", "eglQueryNativeDisplayNV eglQueryNativeWindowNV eglQueryNativePixmapNV"},
+ {"EGL_NV_post_sub_buffer", "eglPostSubBufferNV"},
+ {"EGL_NV_stream_consumer_eglimage", "eglStreamImageConsumerConnectNV eglQueryStreamConsumerEventNV eglStreamAcquireImageNV eglStreamReleaseImageNV"},
+ {"EGL_NV_stream_consumer_gltexture_yuv", "eglStreamConsumerGLTextureExternalAttribsNV"},
+ {"EGL_NV_stream_flush", "eglStreamFlushNV"},
+ {"EGL_NV_stream_metadata", "eglQueryDisplayAttribNV eglSetStreamMetadataNV eglQueryStreamMetadataNV"},
+ {"EGL_NV_stream_reset", "eglResetStreamNV"},
+ {"EGL_NV_stream_sync", "eglCreateStreamSyncNV"},
+ {"EGL_NV_sync", "eglCreateFenceSyncNV eglDestroySyncNV eglFenceNV eglClientWaitSyncNV eglSignalSyncNV eglGetSyncAttribNV"},
+ {"EGL_NV_system_time", "eglGetSystemTimeFrequencyNV eglGetSystemTimeNV"},
+ {"EGL_WL_bind_wayland_display", "eglBindWaylandDisplayWL eglUnbindWaylandDisplayWL eglQueryWaylandBufferWL"},
+ {"EGL_WL_create_wayland_buffer_from_image", "eglCreateWaylandBufferFromImageWL"},
+};
+
+static bool GuestHasEntrypoints(std::string_view extension) {
+ for (const auto& [name, entrypoints] : ExtensionEntrypoints) {
+ if (name != extension) {
+ continue;
+ }
+ std::string_view rest = entrypoints;
+ while (!rest.empty()) {
+ auto end = rest.find(' ');
+ if (!Self() || !dlsym(Self(), std::string {rest.substr(0, end)}.c_str())) {
+ return false;
+ }
+ rest = end == std::string_view::npos ? std::string_view {} : rest.substr(end + 1);
+ }
+ return true;
+ }
+ return true;
+}
extern "C" {
voidFunc* eglGetProcAddress(const char* procname) {
- // TODO: Fix this HACK
+ if (strncmp(procname, "egl", 3) == 0) {
+ return Self() ? reinterpret_cast<voidFunc*>(dlsym(Self(), procname)) : nullptr;
+ }
return glXGetProcAddress((const GLubyte*)procname);
}
+
+const char* eglQueryString(EGLDisplay display, EGLint name) {
+ const char* result = fexfn_pack_eglQueryString(display, name);
+ if (!result || name != EGL_EXTENSIONS) {
+ return result;
+ }
+ std::string filtered;
+ std::string_view all {result};
+ while (!all.empty()) {
+ auto end = all.find(' ');
+ auto extension = all.substr(0, end);
+ if (!extension.empty() && GuestHasEntrypoints(extension)) {
+ if (!filtered.empty()) {
+ filtered += ' ';
+ }
+ filtered += extension;
+ }
+ all = end == std::string_view::npos ? std::string_view {} : all.substr(end + 1);
+ }
+ static std::mutex mutex;
+ static std::set<std::string> strings;
+ std::lock_guard lock(mutex);
+ return strings.insert(std::move(filtered)).first->c_str();
+}
+}
+
+static void OnInit() {
+ fexfn_pack_EGL_SetGuestXSync((uintptr_t)XSync, (uintptr_t)CallbackUnpack<decltype(XSync)>::Unpack);
+ fexfn_pack_EGL_SetGuestXDisplayString((uintptr_t)XDisplayString, (uintptr_t)CallbackUnpack<decltype(XDisplayString)>::Unpack);
}
-LOAD_LIB(libEGL)
+LOAD_LIB_INIT(libEGL, OnInit)
diff --git a/ThunkLibs/libEGL/libEGL_Host.cpp b/ThunkLibs/libEGL/libEGL_Host.cpp
index ac8a87e..9b154b8 100644
--- a/ThunkLibs/libEGL/libEGL_Host.cpp
+++ b/ThunkLibs/libEGL/libEGL_Host.cpp
@@ -4,14 +4,163 @@ tags: thunklibs|EGL
$end_info$
*/
+#include <atomic>
#include <cstdio>
+#include <cstdlib>
#include <dlfcn.h>
+#include <mutex>
+#include <string_view>
+#include <unordered_map>
+#define EGL_EGLEXT_PROTOTYPES 1
#include <EGL/egl.h>
+#include <EGL/eglext.h>
#include "common/Host.h"
-#include <dlfcn.h>
+#include <X11/Xutil.h>
+#include "common/X11Manager.h"
+
+static X11Manager x11_manager;
+static std::mutex x11_displays_mutex;
+static std::unordered_map<EGLDisplay, _XDisplay*> x11_displays;
+
+static void* fex_egl_get_proc_address(void* so, const char* name) {
+ static auto get_proc_address = reinterpret_cast<void* (*)(const char*)>(dlsym(so, "eglGetProcAddress"));
+ return get_proc_address ? get_proc_address(name) : nullptr;
+}
+
+static void fexfn_impl_libEGL_EGL_SetGuestXSync(uintptr_t GuestTarget, uintptr_t GuestUnpacker) {
+ MakeHostTrampolineForGuestFunctionAt(GuestTarget, GuestUnpacker, &x11_manager.GuestXSync);
+}
+
+static void fexfn_impl_libEGL_EGL_SetGuestXDisplayString(uintptr_t GuestTarget, uintptr_t GuestUnpacker) {
+ MakeHostTrampolineForGuestFunctionAt(GuestTarget, GuestUnpacker, &x11_manager.GuestXDisplayString);
+}
#include "thunkgen_host_libEGL.inl"
+static bool IsWaylandDisplay(void* native) {
+ static std::atomic<void*> cached_interface {nullptr};
+ void* wl_display_interface = cached_interface.load(std::memory_order_acquire);
+ if (!wl_display_interface) {
+ if (void* so = dlopen("libwayland-client.so.0", RTLD_LAZY | RTLD_NOLOAD)) {
+ wl_display_interface = dlsym(so, "wl_display_interface");
+ dlclose(so);
+ cached_interface.store(wl_display_interface, std::memory_order_release);
+ }
+ }
+ return wl_display_interface && *reinterpret_cast<void**>(native) == wl_display_interface;
+}
+
+static std::string_view EnvPlatform() {
+ const char* name = getenv("EGL_PLATFORM");
+ if (!name || !*name) {
+ name = getenv("EGL_DISPLAY");
+ }
+ return name ? std::string_view {name} : std::string_view {};
+}
+
+static void* HostNativeDisplay(EGLenum platform, void* native, _XDisplay** guest_x11) {
+ if (!native) {
+ return nullptr;
+ }
+ switch (platform) {
+ case EGL_PLATFORM_X11_KHR: break;
+#ifdef EGL_PLATFORM_XCB_EXT
+ case EGL_PLATFORM_XCB_EXT: return x11_manager.GuestToHostConnection(static_cast<xcb_connection_t*>(native));
+#endif
+ case 0:
+ if (auto env = EnvPlatform(); !env.empty()) {
+ if (env == "xcb") {
+ return x11_manager.GuestToHostConnection(static_cast<xcb_connection_t*>(native));
+ }
+ if (env != "x11") {
+ return native;
+ }
+ break;
+ }
+ if (IsWaylandDisplay(native)) {
+ return native;
+ }
+ break;
+ default: return native;
+ }
+ *guest_x11 = static_cast<_XDisplay*>(native);
+ return x11_manager.GuestToHostDisplay(*guest_x11);
+}
+
+static EGLDisplay TrackDisplay(EGLDisplay display, _XDisplay* guest_x11) {
+ if (display != EGL_NO_DISPLAY && guest_x11) {
+ std::lock_guard lock(x11_displays_mutex);
+ x11_displays[display] = guest_x11;
+ }
+ return display;
+}
+
+static void SyncGuestDisplay(EGLDisplay display) {
+ _XDisplay* guest_x11 = nullptr;
+ {
+ std::lock_guard lock(x11_displays_mutex);
+ if (auto it = x11_displays.find(display); it != x11_displays.end()) {
+ guest_x11 = it->second;
+ }
+ }
+ if (guest_x11) {
+ x11_manager.GuestXSync(guest_x11, 0);
+ }
+}
+
+EGLDisplay fexfn_impl_libEGL_eglGetDisplay(guest_layout<EGLNativeDisplayType> native) {
+ _XDisplay* guest_x11 = nullptr;
+ auto host = HostNativeDisplay(0, native.force_get_host_pointer(), &guest_x11);
+ return TrackDisplay(fexldr_ptr_libEGL_eglGetDisplay(static_cast<EGLNativeDisplayType>(host)), guest_x11);
+}
+
+EGLDisplay fexfn_impl_libEGL_eglGetPlatformDisplay(EGLenum platform, void* native, const EGLAttrib* attribs) {
+ _XDisplay* guest_x11 = nullptr;
+ auto host = HostNativeDisplay(platform, native, &guest_x11);
+ return TrackDisplay(fexldr_ptr_libEGL_eglGetPlatformDisplay(platform, host, attribs), guest_x11);
+}
+
+EGLDisplay fexfn_impl_libEGL_eglGetPlatformDisplayEXT(EGLenum platform, void* native, const EGLint* attribs) {
+ _XDisplay* guest_x11 = nullptr;
+ auto host = HostNativeDisplay(platform, native, &guest_x11);
+ return TrackDisplay(fexldr_ptr_libEGL_eglGetPlatformDisplayEXT(platform, host, attribs), guest_x11);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreateWindowSurface(EGLDisplay display, EGLConfig config, EGLNativeWindowType window, const EGLint* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreateWindowSurface(display, config, window, attribs);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreatePixmapSurface(EGLDisplay display, EGLConfig config, EGLNativePixmapType pixmap, const EGLint* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreatePixmapSurface(display, config, pixmap, attribs);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreatePlatformWindowSurface(EGLDisplay display, EGLConfig config, void* window, const EGLAttrib* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreatePlatformWindowSurface(display, config, window, attribs);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreatePlatformPixmapSurface(EGLDisplay display, EGLConfig config, void* pixmap, const EGLAttrib* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreatePlatformPixmapSurface(display, config, pixmap, attribs);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreatePlatformWindowSurfaceEXT(EGLDisplay display, EGLConfig config, void* window, const EGLint* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreatePlatformWindowSurfaceEXT(display, config, window, attribs);
+}
+
+EGLSurface fexfn_impl_libEGL_eglCreatePlatformPixmapSurfaceEXT(EGLDisplay display, EGLConfig config, void* pixmap, const EGLint* attribs) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCreatePlatformPixmapSurfaceEXT(display, config, pixmap, attribs);
+}
+
+EGLBoolean fexfn_impl_libEGL_eglCopyBuffers(EGLDisplay display, EGLSurface surface, EGLNativePixmapType pixmap) {
+ SyncGuestDisplay(display);
+ return fexldr_ptr_libEGL_eglCopyBuffers(display, surface, pixmap);
+}
+
EXPORTS(libEGL)
diff --git a/ThunkLibs/libEGL/libEGL_interface.cpp b/ThunkLibs/libEGL/libEGL_interface.cpp
index 27de16d..19f8b86 100644
--- a/ThunkLibs/libEGL/libEGL_interface.cpp
+++ b/ThunkLibs/libEGL/libEGL_interface.cpp
@@ -1,51 +1,170 @@
#include <common/GeneratorInterface.h>
+#define EGL_EGLEXT_PROTOTYPES 1
#include <EGL/egl.h>
+#include <EGL/eglext.h>
+#include <X11/Xlib.h>
template<auto>
struct fex_gen_config {
unsigned version = 1;
};
-// Function, parameter index, parameter type [optional]
template<auto, int, typename = void>
struct fex_gen_param {};
+template<typename>
+struct fex_gen_type {};
+
+template<>
+struct fex_gen_type<void> : fexgen::opaque_type {};
+template<>
+struct fex_gen_type<_XDisplay> : fexgen::opaque_type {};
+
+void EGL_SetGuestXSync(uintptr_t, uintptr_t);
+void EGL_SetGuestXDisplayString(uintptr_t, uintptr_t);
+template<>
+struct fex_gen_config<EGL_SetGuestXSync> : fexgen::custom_guest_entrypoint, fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<EGL_SetGuestXDisplayString> : fexgen::custom_guest_entrypoint, fexgen::custom_host_impl {};
+
template<>
struct fex_gen_config<eglBindAPI> {};
template<>
+struct fex_gen_config<eglBindTexImage> {};
+template<>
struct fex_gen_config<eglChooseConfig> {};
template<>
+struct fex_gen_config<eglClientWaitSync> {};
+template<>
+struct fex_gen_config<eglCreateContext> {};
+template<>
+struct fex_gen_config<eglCreateImage> {};
+template<>
+struct fex_gen_config<eglCreatePbufferFromClientBuffer> {};
+template<>
+struct fex_gen_config<eglCreatePbufferSurface> {};
+template<>
+struct fex_gen_config<eglCreateSync> {};
+template<>
struct fex_gen_config<eglDestroyContext> {};
template<>
+struct fex_gen_config<eglDestroyImage> {};
+template<>
struct fex_gen_config<eglDestroySurface> {};
template<>
+struct fex_gen_config<eglDestroySync> {};
+template<>
+struct fex_gen_config<eglGetConfigAttrib> {};
+template<>
+struct fex_gen_config<eglGetConfigs> {};
+template<>
+struct fex_gen_config<eglGetCurrentContext> {};
+template<>
+struct fex_gen_config<eglGetCurrentDisplay> {};
+template<>
+struct fex_gen_config<eglGetCurrentSurface> {};
+template<>
+struct fex_gen_config<eglGetError> {};
+template<>
+struct fex_gen_config<eglGetSyncAttrib> {};
+template<>
struct fex_gen_config<eglInitialize> {};
template<>
struct fex_gen_config<eglMakeCurrent> {};
template<>
+struct fex_gen_config<eglQueryAPI> {};
+template<>
+struct fex_gen_config<eglQueryContext> {};
+template<>
+struct fex_gen_config<eglQueryString> : fexgen::custom_guest_entrypoint {};
+template<>
struct fex_gen_config<eglQuerySurface> {};
template<>
+struct fex_gen_config<eglReleaseTexImage> {};
+template<>
+struct fex_gen_config<eglReleaseThread> {};
+template<>
struct fex_gen_config<eglSurfaceAttrib> {};
template<>
struct fex_gen_config<eglSwapBuffers> {};
template<>
+struct fex_gen_config<eglSwapInterval> {};
+template<>
struct fex_gen_config<eglTerminate> {};
template<>
-struct fex_gen_config<eglGetError> {};
+struct fex_gen_config<eglWaitClient> {};
template<>
-struct fex_gen_config<eglCreateContext> {};
+struct fex_gen_config<eglWaitGL> {};
template<>
-struct fex_gen_config<eglCreateWindowSurface> {};
+struct fex_gen_config<eglWaitNative> {};
template<>
-struct fex_gen_config<eglGetCurrentContext> {};
+struct fex_gen_config<eglWaitSync> {};
template<>
-struct fex_gen_config<eglGetCurrentDisplay> {};
+struct fex_gen_config<eglGetDisplay> : fexgen::custom_host_impl {};
template<>
-struct fex_gen_config<eglGetCurrentSurface> {};
+struct fex_gen_config<eglGetPlatformDisplay> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCreateWindowSurface> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCreatePixmapSurface> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCreatePlatformWindowSurface> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCreatePlatformPixmapSurface> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCopyBuffers> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_param<eglGetDisplay, 0, EGLNativeDisplayType> : fexgen::ptr_passthrough {};
+
+namespace ext {
+template<auto>
+struct fex_gen_config {
+ const char* load_host_endpoint_via = "fex_egl_get_proc_address";
+};
-// EGLNativeDisplayType is a pointer to opaque data (wl_display/(X)Display/...)
template<>
-struct fex_gen_config<eglGetDisplay> {};
+struct fex_gen_config<eglSwapBuffersWithDamageKHR> {};
+template<>
+struct fex_gen_config<eglSwapBuffersWithDamageEXT> {};
+template<>
+struct fex_gen_config<eglSetDamageRegionKHR> {};
+template<>
+struct fex_gen_config<eglCreateImageKHR> {};
+template<>
+struct fex_gen_config<eglDestroyImageKHR> {};
+template<>
+struct fex_gen_config<eglCreateSyncKHR> {};
+template<>
+struct fex_gen_config<eglDestroySyncKHR> {};
+template<>
+struct fex_gen_config<eglClientWaitSyncKHR> {};
+template<>
+struct fex_gen_config<eglGetSyncAttribKHR> {};
+template<>
+struct fex_gen_config<eglWaitSyncKHR> {};
+template<>
+struct fex_gen_config<eglDupNativeFenceFDANDROID> {};
+template<>
+struct fex_gen_config<eglQueryDmaBufFormatsEXT> {};
+template<>
+struct fex_gen_config<eglQueryDmaBufModifiersEXT> {};
+template<>
+struct fex_gen_config<eglExportDMABUFImageMESA> {};
+template<>
+struct fex_gen_config<eglExportDMABUFImageQueryMESA> {};
+template<>
+struct fex_gen_config<eglQueryDisplayAttribEXT> {};
+template<>
+struct fex_gen_config<eglQueryDeviceStringEXT> {};
+template<>
+struct fex_gen_config<eglQueryDeviceAttribEXT> {};
+template<>
+struct fex_gen_config<eglQueryDevicesEXT> {};
+template<>
+struct fex_gen_config<eglGetPlatformDisplayEXT> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_config<eglCreatePlatformWindowSurfaceEXT> : fexgen::custom_host_impl {};
template<>
-struct fex_gen_param<eglGetDisplay, 0, EGLNativeDisplayType> : fexgen::assume_compatible_data_layout {};
+struct fex_gen_config<eglCreatePlatformPixmapSurfaceEXT> : fexgen::custom_host_impl {};
+}
diff --git a/ThunkLibs/libwayland-client/Guest.cpp b/ThunkLibs/libwayland-client/Guest.cpp
index 2f887a6..8fa6476 100644
--- a/ThunkLibs/libwayland-client/Guest.cpp
+++ b/ThunkLibs/libwayland-client/Guest.cpp
@@ -42,8 +42,11 @@ extern "C" const wl_interface wl_subsurface_interface {};
#include <charconv>
#include <cstdio>
#include <cstdarg>
+#include <cstdint>
+#include <cstdlib>
#include <cstring>
#include <string>
+#include <utility>
#include "common/Guest.h"
@@ -92,18 +95,39 @@ static uint64_t WaylandAllocateHostTrampolineForGuestListener(void (*callback)()
}
#define WL_CLOSURE_MAX_ARGS 20
+#define WAYLAND_UNIFORM_MAX_ARGS 17
+
+template<std::size_t... I>
+static uint64_t WaylandAllocateUniformHostTrampoline(void (*callback)(), std::index_sequence<I...>) {
+ using cb = void(void*, wl_proxy*, std::conditional_t<true, uintptr_t, std::integral_constant<std::size_t, I>>...);
+ return (uint64_t)(uintptr_t)(void*)AllocateHostTrampolineForGuestFunction((cb*)callback);
+}
+
+template<std::size_t... Counts>
+static uint64_t WaylandAllocateUniformHostTrampoline(void (*callback)(), std::size_t count, std::index_sequence<Counts...>) {
+ using allocator = uint64_t (*)(void (*)());
+ static constexpr allocator allocators[] = {
+ [](void (*cb)()) { return WaylandAllocateUniformHostTrampoline(cb, std::make_index_sequence<Counts> {}); }...};
+ return allocators[count](callback);
+}
extern "C" int wl_proxy_add_listener(wl_proxy* proxy, void (**callback)(void), void* data) {
// Replace guest-provided callback table with host-callable function pointers
// NOTE: A reference to this table is stored in the wl_proxy, so the data
// must remain valid until the proxy is destroyed (or another listener
// is added)
- delete[] (uint64_t*)wl_proxy_get_listener(proxy); // Delete previous substitute, if any
- auto host_callbacks = new uint64_t[WL_CLOSURE_MAX_ARGS];
+ if (wl_proxy_get_listener(proxy)) {
+ fprintf(stderr, "proxy %p already has listener\n", proxy);
+ return -1;
+ }
+ auto host_callbacks = new uint64_t[std::max(fex_wl_get_interface_event_count(proxy), WL_CLOSURE_MAX_ARGS)];
for (int i = 0; i < fex_wl_get_interface_event_count(proxy); ++i) {
- char event_signature[16];
- fex_wl_get_interface_event_signature(proxy, i, event_signature);
+ char event_signature[64];
+ if (fex_wl_get_interface_event_signature(proxy, i, event_signature, sizeof(event_signature)) >= sizeof(event_signature)) {
+ fprintf(stderr, "TODO: Unknown wayland event signature descriptor %s\n", event_signature);
+ std::abort();
+ }
auto signature2 = std::string_view {event_signature};
// A leading number indicates the minimum protocol version
@@ -227,13 +251,19 @@ extern "C" int wl_proxy_add_listener(wl_proxy* proxy, void (**callback)(void), v
} else if (signature == "sii") {
// E.g. zwp_text_input_v3::preedit_string
host_callbacks[i] = WaylandAllocateHostTrampolineForGuestListener<'s', 'i', 'i'>(callback[i]);
+ } else if (signature.size() <= WAYLAND_UNIFORM_MAX_ARGS) {
+ host_callbacks[i] = WaylandAllocateUniformHostTrampoline(callback[i], signature.size(), std::make_index_sequence<WAYLAND_UNIFORM_MAX_ARGS + 1> {});
} else {
fprintf(stderr, "TODO: Unknown wayland event signature descriptor %s\n", signature.data());
std::abort();
}
}
- return fexfn_pack_wl_proxy_add_listener(proxy, (void (**)())host_callbacks, data);
+ int result = fexfn_pack_wl_proxy_add_listener(proxy, (void (**)())host_callbacks, data);
+ if (result != 0) {
+ delete[] host_callbacks;
+ }
+ return result;
}
extern "C" void wl_proxy_destroy(wl_proxy* proxy) {
@@ -353,6 +383,92 @@ extern "C" void wl_log_set_handler_client(wl_log_func_t handler) {
// Ignore
}
+extern "C" void wl_list_init(wl_list* list) {
+ list->prev = list;
+ list->next = list;
+}
+
+extern "C" void wl_list_insert(wl_list* list, wl_list* elm) {
+ elm->prev = list;
+ elm->next = list->next;
+ list->next = elm;
+ elm->next->prev = elm;
+}
+
+extern "C" void wl_list_remove(wl_list* elm) {
+ elm->prev->next = elm->next;
+ elm->next->prev = elm->prev;
+ elm->next = nullptr;
+ elm->prev = nullptr;
+}
+
+extern "C" int wl_list_length(const wl_list* list) {
+ int count = 0;
+ for (auto e = list->next; e != list; e = e->next) {
+ ++count;
+ }
+ return count;
+}
+
+extern "C" int wl_list_empty(const wl_list* list) {
+ return list->next == list;
+}
+
+extern "C" void wl_list_insert_list(wl_list* list, wl_list* other) {
+ if (wl_list_empty(other)) {
+ return;
+ }
+ other->next->prev = list;
+ other->prev->next = list->next;
+ list->next->prev = other->prev;
+ list->next = other->next;
+}
+
+extern "C" void wl_array_init(wl_array* array) {
+ memset(array, 0, sizeof(*array));
+}
+
+extern "C" void wl_array_release(wl_array* array) {
+ free(array->data);
+ array->data = (void*)4;
+}
+
+extern "C" void* wl_array_add(wl_array* array, size_t size) {
+ if (size > SIZE_MAX - array->size) {
+ return nullptr;
+ }
+ size_t needed = array->size + size;
+ size_t alloc = array->alloc > 0 ? array->alloc : 16;
+ while (alloc < needed) {
+ alloc = alloc > SIZE_MAX / 2 ? needed : alloc * 2;
+ }
+ if (array->alloc < alloc) {
+ void* data = array->alloc > 0 ? realloc(array->data, alloc) : malloc(alloc);
+ if (!data) {
+ return nullptr;
+ }
+ array->data = data;
+ array->alloc = alloc;
+ }
+ void* p = (char*)array->data + array->size;
+ array->size += size;
+ return p;
+}
+
+extern "C" int wl_array_copy(wl_array* array, wl_array* source) {
+ if (array->size < source->size) {
+ if (!wl_array_add(array, source->size - array->size)) {
+ return -1;
+ }
+ } else {
+ array->size = source->size;
+ }
+ if (source->size > 0) {
+ memcpy(array->data, source->data, source->size);
+ }
+ return 0;
+}
+
void OnInit() {
fex_wl_exchange_interface_pointer(const_cast<wl_interface*>(&wl_output_interface), "wl_output_interface");
diff --git a/ThunkLibs/libwayland-client/Host.cpp b/ThunkLibs/libwayland-client/Host.cpp
index 68c2ded..25f964c 100644
--- a/ThunkLibs/libwayland-client/Host.cpp
+++ b/ThunkLibs/libwayland-client/Host.cpp
@@ -22,6 +22,7 @@ $end_info$
#include <map>
#include <span>
#include <string>
+#include <utility>
#include <ranges>
@@ -166,6 +167,7 @@ static wl_proxy* fexfn_impl_libwayland_client_wl_proxy_create(wl_proxy* proxy, g
}
#define WL_CLOSURE_MAX_ARGS 20
+#define WAYLAND_UNIFORM_MAX_ARGS 17
static auto fex_wl_remap_argument_list(guest_layout<wl_argument*> args, const wl_message& message) {
#ifndef IS_32BIT_THUNK
// Cast to host layout and return as std::span
@@ -309,6 +311,21 @@ static void WaylandFinalizeHostTrampolineForGuestListener(void (*callback)()) {
FinalizeHostTrampolineForGuestFunction((cb*)callback);
}
+
+template<std::size_t... I>
+static void WaylandFinalizeUniformHostTrampoline(void (*callback)(), std::index_sequence<I...>) {
+ using cb = void(void*, wl_proxy*, std::conditional_t<true, uint64_t, std::integral_constant<std::size_t, I>>...);
+ FinalizeHostTrampolineForGuestFunction((cb*)callback);
+}
+
+template<std::size_t... Counts>
+static void WaylandFinalizeUniformHostTrampoline(void (*callback)(), std::size_t count, std::index_sequence<Counts...>) {
+ using finalizer = void (*)(void (*)());
+ static constexpr finalizer finalizers[] = {
+ [](void (*cb)()) { WaylandFinalizeUniformHostTrampoline(cb, std::make_index_sequence<Counts> {}); }...};
+ finalizers[count](callback);
+}
+
extern "C" int
fexfn_impl_libwayland_client_wl_proxy_add_listener(struct wl_proxy* proxy, guest_layout<void (**)(void)> callback_table_raw, void* data) {
auto interface = get_proxy_interface(proxy);
@@ -446,6 +463,8 @@ fexfn_impl_libwayland_client_wl_proxy_add_listener(struct wl_proxy* proxy, guest
WaylandFinalizeHostTrampolineForGuestListener<'s', 'i', 'i'>(callback);
} else if (signature == "ss") {
WaylandFinalizeHostTrampolineForGuestListener<'s', 's'>(callback);
+ } else if (signature.size() <= WAYLAND_UNIFORM_MAX_ARGS) {
+ WaylandFinalizeUniformHostTrampoline(callback, signature.size(), std::make_index_sequence<WAYLAND_UNIFORM_MAX_ARGS + 1> {});
} else {
fprintf(stderr, "TODO: Unknown wayland event signature descriptor %s\n", signature.data());
std::abort();
@@ -514,8 +533,35 @@ void fexfn_impl_libwayland_client_fex_wl_get_interface_event_name(wl_proxy* prox
strcpy(out, get_proxy_interface(proxy)->events[i].name);
}
-void fexfn_impl_libwayland_client_fex_wl_get_interface_event_signature(wl_proxy* proxy, int i, char* out) {
- strcpy(out, get_proxy_interface(proxy)->events[i].signature);
+size_t fexfn_impl_libwayland_client_fex_wl_get_interface_event_signature(wl_proxy* proxy, int i, char* out, size_t size) {
+ const char* signature = get_proxy_interface(proxy)->events[i].signature;
+ size_t length = strlen(signature);
+ if (size > 0) {
+ size_t copied = std::min(length, size - 1);
+ memcpy(out, signature, copied);
+ out[copied] = '\0';
+ }
+ return length;
+}
+
+uint32_t fexfn_impl_libwayland_client_wl_display_get_protocol_error(wl_display* display, guest_layout<const wl_interface**> guest_interface,
+ uint32_t* id) {
+ const wl_interface* host_interface = nullptr;
+ auto code = fexldr_ptr_libwayland_client_wl_display_get_protocol_error(display, &host_interface, id);
+ if (!guest_interface.force_get_host_pointer()) {
+ return code;
+ }
+ uintptr_t result = 0;
+ for (auto& [guest, host] : guest_to_host_interface) {
+ if (host == host_interface) {
+ result = reinterpret_cast<uintptr_t>(guest);
+ }
+ }
+ if (!result) {
+ result = reinterpret_cast<uintptr_t>(host_interface);
+ }
+ guest_interface.get_pointer()->data = result;
+ return code;
}
EXPORTS(libwayland_client)
diff --git a/ThunkLibs/libwayland-client/libwayland-client_interface.cpp b/ThunkLibs/libwayland-client/libwayland-client_interface.cpp
index 575d2e1..9723a3c 100644
--- a/ThunkLibs/libwayland-client/libwayland-client_interface.cpp
+++ b/ThunkLibs/libwayland-client/libwayland-client_interface.cpp
@@ -83,6 +83,16 @@ struct fex_gen_config<wl_display_get_fd> {};
template<>
struct fex_gen_config<wl_event_queue_destroy> {};
+template<>
+struct fex_gen_config<wl_event_queue_get_name> {};
+template<>
+struct fex_gen_config<wl_display_create_queue_with_name> {};
+template<>
+struct fex_gen_config<wl_display_set_max_buffer_size> {};
+template<>
+struct fex_gen_config<wl_display_get_protocol_error> : fexgen::custom_host_impl {};
+template<>
+struct fex_gen_param<wl_display_get_protocol_error, 1, const wl_interface**> : fexgen::ptr_passthrough {};
template<>
struct fex_gen_config<wl_proxy_add_listener> : fexgen::custom_host_impl, fexgen::custom_guest_entrypoint {};
@@ -101,6 +111,10 @@ struct fex_gen_config<wl_proxy_create_wrapper> {};
template<>
struct fex_gen_config<wl_proxy_get_class> {};
template<>
+struct fex_gen_config<wl_proxy_get_display> {};
+template<>
+struct fex_gen_config<wl_proxy_get_queue> {};
+template<>
struct fex_gen_config<wl_proxy_get_id> {};
template<>
struct fex_gen_config<wl_proxy_get_listener> {};
@@ -164,6 +178,6 @@ struct fex_gen_config<fex_wl_get_interface_event_count> : fexgen::custom_host_im
void fex_wl_get_interface_event_name(wl_proxy*, int, char*);
template<>
struct fex_gen_config<fex_wl_get_interface_event_name> : fexgen::custom_host_impl {};
-void fex_wl_get_interface_event_signature(wl_proxy*, int, char*);
+size_t fex_wl_get_interface_event_signature(wl_proxy*, int, char*, size_t);
template<>
struct fex_gen_config<fex_wl_get_interface_event_signature> : fexgen::custom_host_impl {};
diff --git a/ThunkLibs/libwayland-egl/Guest.cpp b/ThunkLibs/libwayland-egl/Guest.cpp
new file mode 100644
index 0000000..300a8fc
--- /dev/null
+++ b/ThunkLibs/libwayland-egl/Guest.cpp
@@ -0,0 +1,7 @@
+#include <wayland-egl.h>
+
+#include "common/Guest.h"
+
+#include "thunkgen_guest_libwayland-egl.inl"
+
+LOAD_LIB(libwayland-egl)
diff --git a/ThunkLibs/libwayland-egl/Host.cpp b/ThunkLibs/libwayland-egl/Host.cpp
new file mode 100644
index 0000000..81ad83b
--- /dev/null
+++ b/ThunkLibs/libwayland-egl/Host.cpp
@@ -0,0 +1,8 @@
+#include <wayland-egl.h>
+
+#include "common/Host.h"
+#include <dlfcn.h>
+
+#include "thunkgen_host_libwayland-egl.inl"
+
+EXPORTS(libwayland_egl)
diff --git a/ThunkLibs/libwayland-egl/libwayland-egl_interface.cpp b/ThunkLibs/libwayland-egl/libwayland-egl_interface.cpp
new file mode 100644
index 0000000..bc5d743
--- /dev/null
+++ b/ThunkLibs/libwayland-egl/libwayland-egl_interface.cpp
@@ -0,0 +1,25 @@
+#include <common/GeneratorInterface.h>
+
+#include <wayland-egl.h>
+
+template<auto>
+struct fex_gen_config {
+ unsigned version = 1;
+};
+
+template<typename>
+struct fex_gen_type {};
+
+template<>
+struct fex_gen_type<wl_egl_window> : fexgen::opaque_type {};
+template<>
+struct fex_gen_type<wl_surface> : fexgen::opaque_type {};
+
+template<>
+struct fex_gen_config<wl_egl_window_create> {};
+template<>
+struct fex_gen_config<wl_egl_window_destroy> {};
+template<>
+struct fex_gen_config<wl_egl_window_resize> {};
+template<>
+struct fex_gen_config<wl_egl_window_get_attached_size> {};
@@ -71,7 +71,6 @@ RUNTIME_LIBRARIES = (("libc.so.6", b"GLIBC_"), ("libstdc++.so.6", b"GLIBCXX_"))
VERSION_NAME = re.compile(rb"GLIBC(?:XX)?_[0-9][0-9.]*[0-9]")
BUNDLE_DEPTH = 3
THUNKS = {"GL": 1, "Vulkan": 1}
WAYLAND_THUNKS = {"WaylandClient": "libwayland-client-guest.so", "EGL": "libEGL-guest.so", "WaylandEGL": "libwayland-egl-guest.so"}
X86 = {3: "i386", 62: "x86_64"}
ARM = {40: "arm", 183: "arm64"}
SCAN_DEPTH = 4
@@ -449,20 +448,13 @@ def install_preloads(root):
write_if_changed(os.path.join(root, "etc", "asound.conf"), ASOUND_CONF)
def enabled_thunks(fex):
thunks = dict(THUNKS)
if all(os.path.isfile(os.path.join(fex["guest_thunks"], name)) for name in WAYLAND_THUNKS.values()):
thunks.update(dict.fromkeys(WAYLAND_THUNKS, 1))
return thunks
def write_config(fex, root):
config = {"Config": {"RootFS": root}}
if fex["host_thunks"] and fex["guest_thunks"] and fex["thunks_db"]:
config["Config"]["ThunkHostLibs"] = fex["host_thunks"]
config["Config"]["ThunkGuestLibs"] = fex["guest_thunks"]
config["ThunksDB"] = enabled_thunks(fex)
write_if_changed(os.path.join(CONFIG_DIR, "ThunksConfig.json"), json.dumps({"ThunksDB": config["ThunksDB"]}, indent=2) + "\n")
config["ThunksDB"] = dict(THUNKS)
write_if_changed(os.path.join(CONFIG_DIR, "ThunksConfig.json"), json.dumps({"ThunksDB": dict(THUNKS)}, indent=2) + "\n")
write_if_changed(os.path.join(CONFIG_DIR, "Config.json"), json.dumps(config, indent=2) + "\n")
@@ -29,19 +29,14 @@ fex_install() {
return 1
fi
(cd "$tmp/root" && find . ! -type d) > "$tmp/files"
for d in usr/local/share/fex-emu/GuestThunks usr/local/share/fex-emu/GuestThunks_32 usr/local/lib/fex-emu/HostThunks usr/local/lib/fex-emu/HostThunks_32; do
[ -d "$tmp/root/$d" ] && [ -d "$dst$d" ] || continue
(cd "$dst" && find "$d" ! -type d) | while IFS= read -r f; do grep -qxF "./$f" "$tmp/files" || echo "$f"; done
done > "$tmp/stale"
mkdir "$tmp/old"
while IFS= read -r f; do
f=${f#./}
if [ -e "$dst$f" ] || [ -L "$dst$f" ]; then
cp -a --parents "$dst$f" "$tmp/old" || { echo "== FEX $tag: could not keep $dst$f aside" >&2; rm -rf "$tmp"; return 1; }
fi
done < <(cat "$tmp/files" "$tmp/stale")
if tar -C "$tmp/root" -c . | tar -C "$dst" -x &&
( while IFS= read -r f; do rm -f "$dst$f" || exit 1; done < "$tmp/stale" ) && fex_loads "$dst" &&
done < "$tmp/files"
if tar -C "$tmp/root" -c . | tar -C "$dst" -x && fex_loads "$dst" &&
mkdir -p "${dst}usr/local/share/fex-emu" && echo "$tag" > "${dst}usr/local/share/fex-emu/.droiddeck-tag"; then
rm -rf "$tmp"
return 0
-53
View File
@@ -5,8 +5,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *interface);
@@ -242,16 +240,6 @@ static void VKAPI_CALL mock_properties(VkPhysicalDevice physical, VkPhysicalDevi
static void VKAPI_CALL mock_properties2(VkPhysicalDevice physical, VkPhysicalDeviceProperties2 *properties)
{
mock_properties(physical, &properties->properties);
for (VkBaseOutStructure *s = properties->pNext; s; s = s->pNext) {
if (s->sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT)
continue;
VkPhysicalDeviceDrmPropertiesEXT *drm = (VkPhysicalDeviceDrmPropertiesEXT *)s;
bool own = physical == (VkPhysicalDevice)&mock_capable;
drm->hasPrimary = drm->hasRender = own;
drm->primaryMajor = drm->renderMajor = own ? 226 : 0;
drm->primaryMinor = 0;
drm->renderMinor = own ? 128 : 0;
}
}
static void VKAPI_CALL mock_memory_properties(VkPhysicalDevice physical, VkPhysicalDeviceMemoryProperties *properties)
@@ -579,46 +567,6 @@ static void test_depth_compare_op(void)
destroy_device(device);
}
static VkPhysicalDeviceDrmPropertiesEXT query_drm(VkPhysicalDevice physical)
{
VkPhysicalDeviceDrmPropertiesEXT drm = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT};
VkPhysicalDeviceProperties2 properties = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, &drm, {0}};
((PFN_vkGetPhysicalDeviceProperties2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties2"))(
physical, &properties);
return drm;
}
static void test_render_node(void)
{
VkPhysicalDevice lacking = (VkPhysicalDevice)&mock_lacking, capable = (VkPhysicalDevice)&mock_capable;
struct stat node;
assert(stat("/dev/null", &node) == 0 && S_ISCHR(node.st_mode));
unsetenv("DD_DRM_STANDIN");
VkPhysicalDeviceDrmPropertiesEXT drm = query_drm(lacking);
assert(!drm.hasRender && !drm.renderMajor && !drm.renderMinor);
setenv("DD_DRM_STANDIN", "/dev/null", 1);
drm = query_drm(lacking);
assert(drm.hasRender && !drm.hasPrimary);
assert(drm.renderMajor == (int64_t)major(node.st_rdev) && drm.renderMinor == (int64_t)minor(node.st_rdev));
drm = query_drm(capable);
assert(drm.hasRender && drm.hasPrimary && drm.renderMajor == 226 && drm.renderMinor == 128);
VkPhysicalDeviceProperties2 plain = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, NULL, {0}};
((PFN_vkGetPhysicalDeviceProperties2)layer_gipa((VkInstance)&mock_instance, "vkGetPhysicalDeviceProperties2"))(
lacking, &plain);
const char *not_devices[] = {"", "/", "/nonexistent/renderD128"};
for (size_t i = 0; i < sizeof(not_devices) / sizeof(not_devices[0]); i++) {
setenv("DD_DRM_STANDIN", not_devices[i], 1);
drm = query_drm(lacking);
assert(!drm.hasRender && !drm.renderMajor && !drm.renderMinor);
}
unsetenv("DD_DRM_STANDIN");
}
int main(int argc, char **argv)
{
test_spirv(argc > 1 ? argv[1] : NULL);
@@ -642,7 +590,6 @@ int main(int argc, char **argv)
test_lacking_device();
test_capable_device();
test_depth_compare_op();
test_render_node();
((PFN_vkDestroyInstance)layer_gipa(instance, "vkDestroyInstance"))(instance, NULL);
free(driver_code);
-16
View File
@@ -1188,22 +1188,6 @@ class LaunchTest(FexTestCase):
thunks = json.loads((self.home / ".local/share/droiddeck-fex/config/ThunksConfig.json").read_text())
self.assertEqual(thunks, {"ThunksDB": {"GL": 1, "Vulkan": 1}})
def test_wayland_and_egl_thunks_turn_on_only_when_the_build_ships_all_of_them(self):
guest = self.tmp / "guest-thunks"
guest.mkdir()
fex = {"host_thunks": "/h", "guest_thunks": str(guest), "thunks_db": "/db"}
thunks_file = self.home / ".local/share/droiddeck-fex/config/ThunksConfig.json"
for name in ("libwayland-client-guest.so", "libEGL-guest.so"):
(guest / name).write_bytes(b"")
FEX["write_config"](fex, "/root")
self.assertEqual({"GL": 1, "Vulkan": 1}, json.loads(thunks_file.read_text())["ThunksDB"])
(guest / "libwayland-egl-guest.so").write_bytes(b"")
FEX["write_config"](fex, "/root")
expected = {"GL": 1, "Vulkan": 1, "WaylandClient": 1, "EGL": 1, "WaylandEGL": 1}
self.assertEqual(expected, json.loads(thunks_file.read_text())["ThunksDB"])
config = json.loads((self.home / ".local/share/droiddeck-fex/config/Config.json").read_text())
self.assertEqual(expected, config["ThunksDB"])
def test_host_libc_tunables_stay_on_the_host(self):
guest = FEX["guest_environment"]({"portable": True}, {"GLIBC_TUNABLES": "glibc.pthread.rseq=0"})
self.assertNotIn("GLIBC_TUNABLES", guest)
+1 -39
View File
@@ -11,7 +11,6 @@ SOURCE = SCRIPT.read_text()
START = SOURCE.index("fex_install() {")
END = SOURCE.index("\n}\n", START) + 3
FEX_INSTALL = SOURCE[START:END]
THUNK_DIRS = (("share/fex-emu/GuestThunks_32", "libGL-guest.so"), ("lib/fex-emu/HostThunks_32", "libGL-host.so"))
HARNESS = textwrap.dedent("""\
set -eu
@@ -38,25 +37,9 @@ class FexInstallTest(unittest.TestCase):
(new / "lib").mkdir()
(new / "lib/libxxhash.so.0").write_text("lib\n")
self.pkg = base / "fex.tzst"
self.pack()
def pack(self):
base = Path(self.temp.name)
subprocess.run(f"tar -C '{base / 'pkg'}' -c . | zstd -q -f -o '{self.pkg}'", shell=True, check=True)
subprocess.run(f"tar -C '{base / 'pkg'}' -c . | zstd -q -o '{self.pkg}'", shell=True, check=True)
self.sha = hashlib.sha256(self.pkg.read_bytes()).hexdigest()
def add_old_thunks(self):
old, new = self.root / "usr/local", Path(self.temp.name) / "pkg/usr/local"
for side, name in THUNK_DIRS:
(new / side).mkdir(parents=True)
(new / side / name).write_text("new thunk\n")
(old / side).mkdir(parents=True)
(old / side / name).write_text("old thunk\n")
(old / side / "libwayland-client-thunk.so").write_text("stale\n")
(old / "share/fex-emu/GuestThunks").mkdir()
(old / "share/fex-emu/GuestThunks/libkept-guest.so").write_text("kept\n")
self.pack()
def install(self, installed_loads, sha=None):
body = FEX_INSTALL.replace("local tag=$1 sha=$2 urls=$3 dst=/ ", "local tag=$1 sha=$2 urls=$3 dst=$ROOT/ ")
self.assertNotEqual(body, FEX_INSTALL)
@@ -96,27 +79,6 @@ class FexInstallTest(unittest.TestCase):
self.assertEqual("old FEX\n", (self.root / "usr/local/bin/FEX").read_text())
self.assertFalse((self.root / "usr/local/lib/libxxhash.so.0").exists())
def test_thunks_the_new_build_no_longer_ships_are_removed(self):
self.add_old_thunks()
self.assertEqual("OK", self.install(installed_loads=True)[0])
for side, name in THUNK_DIRS:
with self.subTest(side=side):
self.assertEqual("new thunk\n", (self.root / "usr/local" / side / name).read_text())
self.assertFalse((self.root / "usr/local" / side / "libwayland-client-thunk.so").exists())
def test_a_thunk_folder_the_new_build_does_not_ship_is_left_alone(self):
self.add_old_thunks()
self.assertEqual("OK", self.install(installed_loads=True)[0])
self.assertEqual("kept\n", (self.root / "usr/local/share/fex-emu/GuestThunks/libkept-guest.so").read_text())
def test_a_failed_install_puts_removed_thunks_back(self):
self.add_old_thunks()
self.assertEqual("FAILED", self.install(installed_loads=False)[0])
for side, name in THUNK_DIRS:
with self.subTest(side=side):
self.assertEqual("old thunk\n", (self.root / "usr/local" / side / name).read_text())
self.assertEqual("stale\n", (self.root / "usr/local" / side / "libwayland-client-thunk.so").read_text())
def test_an_archive_that_does_not_match_installs_nothing(self):
result, err = self.install(installed_loads=True, sha="0" * 64)
self.assertEqual("FAILED", result)
-151
View File
@@ -1,151 +0,0 @@
import re
import runpy
import unittest
from pathlib import Path
REPO = Path(__file__).resolve().parents[2]
PATCH = REPO / "tools/fex/patches/0019-wayland-and-egl-thunks-for-64-bit-guests.patch"
LAUNCHER = REPO / "tools/linuxfs/overlay/usr/local/bin/droiddeck-fex"
THUNKS = {"WaylandClient": "wayland-client", "EGL": "EGL", "WaylandEGL": "wayland-egl"}
def blocks():
return {re.match(r"a/(\S+) ", block).group(1): block
for block in re.split(r"^diff --git ", PATCH.read_text(), flags=re.M)[1:]}
def files():
return {name: [line[1:] for line in block.splitlines() if line.startswith("+") and not line.startswith("+++")]
for name, block in blocks().items()}
def built_libs(block):
out, base, stack = set(), False, []
for line in block.splitlines():
if line.startswith("@@"):
base, stack = "BITNESS EQUAL 64" in line, []
continue
if line[:1] == "-":
continue
text = line[1:].strip()
if text.startswith("if ("):
stack.append("gate" if "BITNESS EQUAL 64" in text else "other")
elif text.startswith("else"):
if stack:
stack[-1] = {"gate": "inverted", "inverted": "gate"}.get(stack[-1], stack[-1])
else:
base = False
elif text == "endif()":
if stack:
stack.pop()
else:
base = False
found = re.match(r"add_(?:guest|host)_lib\(([\w-]+)", text)
if found and line[:1] == "+":
out.add((found.group(1), "inverted" not in stack and (base or "gate" in stack)))
return out
def database():
entries, name = {}, None
for line in blocks()["Data/ThunksDB.json"].splitlines():
if line[:1] == "-":
continue
found = re.match(r'[ +]\s*"(\w+)": \{', line)
if found:
name = found.group(1)
found = re.search(r'"Library" : "([^"]+)"', line)
if found and name:
entries[name] = found.group(1)
return entries
class FexWaylandEglThunksTest(unittest.TestCase):
def test_only_thunk_sources_and_the_thunk_database_change(self):
for name in files():
with self.subTest(name=name):
self.assertTrue(name == "Data/ThunksDB.json" or name.startswith("ThunkLibs/"))
def test_each_enabled_thunk_maps_to_the_guest_library_the_build_ships(self):
launcher = runpy.run_path(str(LAUNCHER), run_name="droiddeck_fex")["WAYLAND_THUNKS"]
self.assertEqual(set(THUNKS), set(launcher))
built = {name for name, _ in built_libs(blocks()["ThunkLibs/GuestLibs/CMakeLists.txt"])}
entries = database()
for name, lib in THUNKS.items():
with self.subTest(name=name):
self.assertIn(lib, built)
self.assertEqual(f"lib{lib}-guest.so", launcher[name])
if name in entries:
self.assertEqual(launcher[name], entries[name])
self.assertEqual({"EGL", "WaylandEGL"}, set(entries) & set(THUNKS))
def test_the_upstream_wayland_client_entry_is_left_unchanged(self):
changed = [line for line in blocks()["Data/ThunksDB.json"].splitlines()
if line[:1] in "+-" and not line.startswith(("+++", "---"))]
self.assertFalse([line for line in changed if "WaylandClient" in line or "wayland-client" in line])
def test_an_extension_is_advertised_only_with_every_entrypoint(self):
guest = "\n".join(files()["ThunkLibs/libEGL/libEGL_Guest.cpp"])
table = dict(re.findall(r'\{"(EGL_\w+)", "([\w ]+)"\}', guest))
self.assertEqual("eglQueryNativeDisplayNV eglQueryNativeWindowNV eglQueryNativePixmapNV",
table["EGL_NV_native_query"])
self.assertIn("eglSignalSyncKHR", table["EGL_KHR_reusable_sync"].split())
self.assertIn("eglCreateSyncKHR", table["EGL_KHR_reusable_sync"].split())
body = re.search(r"static bool GuestHasEntrypoints\(.*?\n\}", guest, re.S).group(0)
self.assertRegex(body, r"while \(!rest\.empty\(\)\)")
self.assertRegex(body, r"dlsym\(Self\(\), .*rest\.substr\(0, end\)")
def test_a_legacy_display_follows_the_platform_mesa_would_pick(self):
host = "\n".join(files()["ThunkLibs/libEGL/libEGL_Host.cpp"])
env = re.search(r"static std::string_view EnvPlatform\(\) \{.*?\n\}", host, re.S).group(0)
self.assertLess(env.index('getenv("EGL_PLATFORM")'), env.index('getenv("EGL_DISPLAY")'))
legacy = re.search(r"case 0:\n(.*?)\n default:", host, re.S).group(1)
self.assertLess(legacy.index("EnvPlatform()"), legacy.index("IsWaylandDisplay(native)"))
self.assertIn('env == "xcb"', legacy)
self.assertIn('env != "x11"', legacy)
self.assertNotIn("IsHostDevice", host)
def test_gles_is_overlaid_only_by_the_64_bit_egl_thunk(self):
overlays, name = {}, None
for line in blocks()["Data/ThunksDB.json"].splitlines():
found = re.match(r'[ +]\s*"(\w+)": \{', line)
if found:
name = found.group(1)
if "libGLESv2" in line:
overlays.setdefault(line[:1], set()).add(name)
self.assertEqual({"EGL"}, overlays.get("+"))
self.assertNotIn("-", overlays)
def test_guest_and_host_libraries_are_built_for_64_bit_guests_only(self):
changed = blocks()
for side in ("GuestLibs", "HostLibs"):
built = built_libs(changed[f"ThunkLibs/{side}/CMakeLists.txt"])
for lib in THUNKS.values():
with self.subTest(side=side, lib=lib):
self.assertEqual({(lib, True)}, {entry for entry in built if entry[0] == lib})
def test_listener_trampolines_stay_inside_the_packed_argument_limit(self):
guest = "\n".join(files()["ThunkLibs/libwayland-client/Guest.cpp"])
limit = int(re.search(r"#define WAYLAND_UNIFORM_MAX_ARGS (\d+)", guest).group(1))
self.assertLessEqual(limit + 2, 19)
def test_the_guest_provides_the_inline_list_and_array_helpers(self):
guest = "\n".join(files()["ThunkLibs/libwayland-client/Guest.cpp"])
for name in ("wl_list_init", "wl_list_insert", "wl_list_remove", "wl_list_length", "wl_list_empty",
"wl_list_insert_list", "wl_array_init", "wl_array_release", "wl_array_add", "wl_array_copy"):
with self.subTest(name=name):
self.assertRegex(guest, rf"\b{name}\(")
def test_the_inverse_branch_of_the_bitness_gate_is_not_64_bit_only(self):
block = "@@ -1 +1 @@\n+if (GUEST_BITNESS EQUAL 64)\n+else()\n+ add_host_lib(EGL ${GUEST_BITNESS})\n+endif()\n"
self.assertEqual({("EGL", False)}, built_libs(block))
def test_no_comments_are_added(self):
for name, lines in files().items():
for line in lines:
with self.subTest(name=name, line=line):
self.assertNotRegex(line, r"(^|\s)(//|/\*)|\$info\$")
if __name__ == "__main__":
unittest.main()
-19
View File
@@ -6,8 +6,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#define LAYER_NAME "VK_LAYER_DROIDDECK_mali_compat"
@@ -391,29 +389,12 @@ static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties(VkPhysicalDevice p
report_limits(&properties->limits, physical_device_gaps(inst, physical_device));
}
static void report_render_node(VkPhysicalDeviceProperties2 *properties)
{
VkPhysicalDeviceDrmPropertiesEXT *drm = NULL;
for (VkBaseOutStructure *s = properties->pNext; s && !drm; s = s->pNext) {
if (s->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT)
drm = (VkPhysicalDeviceDrmPropertiesEXT *)s;
}
const char *node = getenv("DD_DRM_STANDIN");
struct stat st;
if (!drm || drm->hasRender || !node || !*node || stat(node, &st) != 0 || !S_ISCHR(st.st_mode))
return;
drm->hasRender = VK_TRUE;
drm->renderMajor = major(st.st_rdev);
drm->renderMinor = minor(st.st_rdev);
}
static VKAPI_ATTR void VKAPI_CALL GetPhysicalDeviceProperties2(VkPhysicalDevice physical_device,
VkPhysicalDeviceProperties2 *properties)
{
struct instance *inst = instance_from_handle(physical_device);
inst->GetPhysicalDeviceProperties2(physical_device, properties);
report_limits(&properties->properties.limits, physical_device_gaps(inst, physical_device));
report_render_node(properties);
if (tracing())
layer_log("trace: vkGetPhysicalDeviceProperties2: %s, Vulkan %u.%u.%u, type %d", properties->properties.deviceName,
VK_API_VERSION_MAJOR(properties->properties.apiVersion), VK_API_VERSION_MINOR(properties->properties.apiVersion),