mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-04 12:05:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b2c3da358 | ||
|
|
54ca518553 |
No files matched your search
@@ -2844,10 +2844,9 @@ static void render_scene(void) {
|
||||
else if (rendered && how == 2) droiddeck_color_frame_shown(hs.color, DROIDDECK_HDR_TONEMAPPED, 0);
|
||||
else if (rendered) hdr_copy = "the HDR composition pass is unavailable on this driver";
|
||||
}
|
||||
if (hdr_route == 0 && vkp_quest_layer_presentation() && !cardboard && !cursor_on &&
|
||||
if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
||||
!ahb_only) {
|
||||
settle_unwaited();
|
||||
g_framegen_layer = framegen;
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
} else if (hdr_route == 0 || hdr_route == 3) {
|
||||
const int pass_on = fx_on || framegen;
|
||||
|
||||
@@ -3013,24 +3013,15 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
}
|
||||
|
||||
int vkp_render(int scene_w, int scene_h, const struct vkp_draw *draws, int n) {
|
||||
if (vkp_quest_layer_presentation() && !vkp_cardboard_active()) {
|
||||
if (vkp_quest_layer_presentation() && !vkp_framegen_active() && !vkp_cardboard_active()) {
|
||||
vkp_apply_window_request();
|
||||
sc_layer_hide_overlay();
|
||||
if (n > 0) {
|
||||
const int fg = vkp_framegen_active();
|
||||
const int generated = fg
|
||||
? sc_layer_present_generated(draws, n, NULL, scene_w, scene_h, 1, NULL) : 0;
|
||||
const int r = fg ? (generated >= 0 ? 0 : -1)
|
||||
: sc_layer_present_pass(draws, n, scene_w, scene_h);
|
||||
if (r != 0) {
|
||||
if (sc_layer_present_pass(draws, n, scene_w, scene_h) != 0) {
|
||||
static int said;
|
||||
if (!said) { said = 1; droiddeck_log("error", "Quest scene layer unavailable; retaining the previous frame rather than using the corrupt Android swapchain"); }
|
||||
return -1;
|
||||
}
|
||||
if (fg && generated > 0) {
|
||||
static int said;
|
||||
if (!said) { said = 1; droiddeck_log("framegen", "generated frames go on the Quest display layer"); }
|
||||
}
|
||||
} else {
|
||||
sc_layer_hide();
|
||||
}
|
||||
|
||||
@@ -59,13 +59,18 @@ object GameStorage {
|
||||
return when {
|
||||
pref == SessionPrefs.GAME_STORAGE_OFF -> null
|
||||
pref.isEmpty() -> options(context).firstOrNull()?.let { Option(it.name, it.path) }
|
||||
else -> Option(SessionPrefs.gameStorageLabel(context), pref).takeIf { attached(File(pref)) }
|
||||
else -> reachable(pref).let { path -> Option(SessionPrefs.gameStorageLabel(context), path).takeIf { attached(File(path)) } }
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnected(context: Context): Boolean {
|
||||
val pref = SessionPrefs.gameStorage(context)
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref))
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(reachable(pref)))
|
||||
}
|
||||
|
||||
internal fun reachable(path: String, usable: (File) -> Boolean = { it.isDirectory && it.canWrite() }): String {
|
||||
val alias = UsbLink.storagePath(path)
|
||||
return if (alias != path && !usable(File(path)) && usable(File(alias))) alias else path
|
||||
}
|
||||
|
||||
internal fun attached(
|
||||
|
||||
@@ -46,7 +46,16 @@ object SecondaryLibrary {
|
||||
}
|
||||
|
||||
fun privateRoot(files: File, library: File): File {
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(library.canonicalPath.toByteArray())
|
||||
val own = privateDir(files, library.canonicalPath)
|
||||
if (own.exists()) return own
|
||||
val raw = UsbLink.rawPath(library.absolutePath)
|
||||
val alias = if (raw != library.absolutePath) raw else UsbLink.storagePath(library.absolutePath)
|
||||
if (alias == library.absolutePath) return own
|
||||
return privateDir(files, runCatching { File(alias).canonicalPath }.getOrDefault(alias)).takeIf { it.exists() } ?: own
|
||||
}
|
||||
|
||||
private fun privateDir(files: File, path: String): File {
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(path.toByteArray())
|
||||
.joinToString("") { "%02x".format(it.toInt() and 255) }
|
||||
return File(files, "steam-libraries/$digest")
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.AddedGames
|
||||
import com.droiddeck.launcher.runtime.BattleNet
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.droiddeck.launcher.session.GameStorage
|
||||
import com.droiddeck.launcher.stores.CatalogItem
|
||||
import com.droiddeck.launcher.stores.InstalledStoreGame
|
||||
import com.droiddeck.launcher.stores.Store
|
||||
@@ -130,13 +131,13 @@ object BattleNetClient {
|
||||
StoresState.post { opener?.invoke(args) }
|
||||
}
|
||||
|
||||
fun library(context: Context, root: File = preferred(context)): List<String> =
|
||||
AddedGames.guestPath(context, StoreInstallRoot.storeDir(root, Store.BATTLENET))?.let { listOf("--library", it) }.orEmpty()
|
||||
fun library(context: Context, root: File? = preferred(context)): List<String> =
|
||||
root?.let { AddedGames.guestPath(context, StoreInstallRoot.storeDir(it, Store.BATTLENET)) }?.let { listOf("--library", it) }.orEmpty()
|
||||
|
||||
internal fun preferred(context: Context): File {
|
||||
internal fun preferred(context: Context): File? {
|
||||
val second = StoreInstallRoot.libraryRoot(context)?.absolutePath
|
||||
return StoreInstallRoot.targets(context).firstOrNull { it.root.absolutePath == second && (it.root.isDirectory || it.root.mkdirs()) }?.root
|
||||
?: StoreInstallRoot.internalRoot(context)
|
||||
?: StoreInstallRoot.internalRoot(context).takeIf { second == null && !GameStorage.disconnected(context) }
|
||||
}
|
||||
|
||||
fun installGame(context: Context, uid: String, root: File) {
|
||||
|
||||
@@ -114,6 +114,19 @@ class GameStorageTest {
|
||||
assertFalse(GameStorage.disconnected(app))
|
||||
}
|
||||
|
||||
@Test fun aRawCardPathTheProcessCannotUseFallsBackToItsStoragePath() {
|
||||
val usable = setOf("/storage/A042-9B16/Games")
|
||||
assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { it.path in usable })
|
||||
}
|
||||
|
||||
@Test fun aUsableRawPathAndOtherPathsAreKept() {
|
||||
assertEquals("/mnt/media_rw/A042-9B16/Games", GameStorage.reachable("/mnt/media_rw/A042-9B16/Games") { true })
|
||||
assertEquals("/mnt/media_rw/0000-0000/Games", GameStorage.reachable("/mnt/media_rw/0000-0000/Games") { false })
|
||||
assertEquals("/storage/A042-9B16/Games", GameStorage.reachable("/storage/A042-9B16/Games") { false })
|
||||
val folder = tmp.newFolder("library").path
|
||||
assertEquals(folder, GameStorage.reachable(folder) { false })
|
||||
}
|
||||
|
||||
@Test fun onlyAVfatMountCountsAsFat32() {
|
||||
val mounts = """
|
||||
/dev/fuse /storage/emulated fuse rw 0 0
|
||||
|
||||
@@ -21,6 +21,24 @@ class SecondaryLibraryTest {
|
||||
assertFalse(SecondaryLibrary.privateRoot(files, content).exists())
|
||||
}
|
||||
|
||||
@Test fun aCardReachedThroughItsOtherPathKeepsItsPrivateDirectories() {
|
||||
val files = tmp.newFolder("files")
|
||||
val raw = SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games")).apply { mkdirs() }
|
||||
assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")))
|
||||
val storage = SecondaryLibrary.privateRoot(files, File("/storage/B2BD-BCFC/Games")).apply { mkdirs() }
|
||||
assertEquals(storage, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/B2BD-BCFC/Games")))
|
||||
}
|
||||
|
||||
@Test fun aLibraryWithItsOwnPrivateDirectoriesKeepsThem() {
|
||||
val files = tmp.newFolder("files")
|
||||
val own = SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")).apply { mkdirs() }
|
||||
val raw = File(own.parentFile, SecondaryLibrary.privateRoot(tmp.newFolder("other"), File("/mnt/media_rw/A042-9B16/Games")).name)
|
||||
raw.mkdirs()
|
||||
assertEquals(own, SecondaryLibrary.privateRoot(files, File("/storage/A042-9B16/Games")))
|
||||
assertEquals(raw, SecondaryLibrary.privateRoot(files, File("/mnt/media_rw/A042-9B16/Games")))
|
||||
assertFalse(SecondaryLibrary.privateRoot(files, File("/storage/emulated/0/Games")).exists())
|
||||
}
|
||||
|
||||
@Test fun aWritableAliasIsSelectedAndItsProbeIsRemoved() {
|
||||
val library = tmp.newFolder("shared")
|
||||
val candidate = File(tmp.root, "direct")
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.droiddeck.launcher.stores.battlenet
|
||||
|
||||
import com.droiddeck.launcher.session.SessionPrefs
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class BattleNetLibraryTest {
|
||||
private val app get() = RuntimeEnvironment.getApplication()
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
@Test fun aMissingLibraryLeavesBattleNetsInstallFolderAlone() {
|
||||
SessionPrefs.setGameStorage(app, "/storage/0000-0000/Games", "SD card")
|
||||
assertTrue(BattleNetClient.library(app).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun anAttachedLibraryIsHandedToBattleNet() {
|
||||
SessionPrefs.setGameStorage(app, tmp.newFolder("card").path, "SD card")
|
||||
assertEquals("--library", BattleNetClient.library(app).firstOrNull())
|
||||
}
|
||||
|
||||
@Test fun internalStorageIsHandedToBattleNetWhenItIsTheChoice() {
|
||||
SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "")
|
||||
assertEquals("--library", BattleNetClient.library(app).firstOrNull())
|
||||
}
|
||||
}
|
||||
@@ -1121,6 +1121,11 @@ WINE_DLL_DIRS = ("/lib/wine/i386-windows", "/lib/wine/x86_64-windows", "/lib/win
|
||||
"/lib/wine/fakedlls", "/lib64/wine", "/lib64/wine/fakedlls", "/lib64/wine/x86_64-windows")
|
||||
|
||||
|
||||
WINE_BUILTIN_MARKS = (b"Wine builtin DLL", b"Wine placeholder DLL")
|
||||
WINE_LIBRARY_SUFFIXES = (".acm", ".ax", ".dll", ".drv", ".ocx")
|
||||
PREFIX_SYSTEM_DIRS = ("system32", "syswow64")
|
||||
|
||||
|
||||
FOREIGN_SUFFIX = ".foreign-arch"
|
||||
WINE_SD = "user.wine.sd"
|
||||
SHARED_DATA = "pfx/drive_c/ProgramData"
|
||||
@@ -1223,6 +1228,66 @@ def repair_foreign_system_dlls(prefix, proton, env=None):
|
||||
return repaired
|
||||
|
||||
|
||||
def is_wine_builtin(path):
|
||||
if is_wine_dll_link(path):
|
||||
return True
|
||||
try:
|
||||
with open(path, "rb") as image:
|
||||
image.seek(0x40)
|
||||
return image.read(20).startswith(WINE_BUILTIN_MARKS)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def listed_names(folder):
|
||||
try:
|
||||
return {name.lower() for name in os.listdir(folder)}
|
||||
except OSError:
|
||||
return set()
|
||||
|
||||
|
||||
def proton_library_names(proton, env=None):
|
||||
files = Path(proton).parent / "files"
|
||||
prefixes = [pfx / "drive_c/windows" for pfx in sorted((files / "share").glob("default_pfx*"))]
|
||||
if not any((windows / "system32/kernel32.dll").is_file() for windows in prefixes):
|
||||
return None
|
||||
names = set()
|
||||
for windows in prefixes:
|
||||
for folder in PREFIX_SYSTEM_DIRS:
|
||||
names |= listed_names(windows / folder)
|
||||
roots = [files / "lib/wine"]
|
||||
roots.extend(Path(entry) for entry in (env or {}).get("WINEDLLPATH", "").split(":") if entry)
|
||||
for root in roots:
|
||||
for folder in (root, *sorted(root.glob("*-windows"))):
|
||||
for name in listed_names(folder):
|
||||
names.add(name[:-2] if name.endswith("16") else name)
|
||||
return names
|
||||
|
||||
|
||||
def remove_other_wine_builtins(prefix, proton, env=None):
|
||||
names = proton_library_names(proton, env)
|
||||
if names is None:
|
||||
return []
|
||||
windows = Path(prefix) / "pfx/drive_c/windows"
|
||||
removed = []
|
||||
for folder in PREFIX_SYSTEM_DIRS:
|
||||
try:
|
||||
entries = sorted(os.listdir(windows / folder))
|
||||
except OSError:
|
||||
continue
|
||||
for name in entries:
|
||||
path = windows / folder / name
|
||||
lower = name.lower()
|
||||
if not lower.endswith(WINE_LIBRARY_SUFFIXES) or lower in names or not is_wine_builtin(path):
|
||||
continue
|
||||
try:
|
||||
os.unlink(path)
|
||||
except OSError:
|
||||
continue
|
||||
removed.append("%s/%s" % (folder, name))
|
||||
return removed
|
||||
|
||||
|
||||
def wine_user_sid():
|
||||
try:
|
||||
with open(MACHINE_ID, "rb") as handle:
|
||||
@@ -1687,6 +1752,11 @@ def main():
|
||||
except OSError as error:
|
||||
restored = fixed = []
|
||||
print("droiddeck-game-env: prefix system DLL check skipped (%s)" % error, file=sys.stderr)
|
||||
try:
|
||||
stale = remove_other_wine_builtins(prefix_path, command[0], effective_env)
|
||||
except OSError as error:
|
||||
stale = []
|
||||
print("droiddeck-game-env: prefix Wine library check skipped (%s)" % error, file=sys.stderr)
|
||||
try:
|
||||
unlocked, cleared = heal_shared_data(prefix_path)
|
||||
except OSError as error:
|
||||
@@ -1701,6 +1771,9 @@ def main():
|
||||
if fixed:
|
||||
print("droiddeck-game-env: replaced foreign-architecture system DLLs with this Proton's own: %s" % ", ".join(fixed),
|
||||
file=sys.stderr)
|
||||
if stale:
|
||||
print("droiddeck-game-env: removed Wine libraries another Proton left that this Proton does not ship: %s"
|
||||
% ", ".join(stale), file=sys.stderr)
|
||||
scripts = mark_install_scripts(command, effective_env)
|
||||
if scripts and install_scripts_done(scripts, env):
|
||||
print("droiddeck-game-env: install scripts already run in this prefix; evaluator skipped", file=sys.stderr)
|
||||
|
||||
+11
-101
@@ -3,12 +3,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct vkp_draw { int unused; };
|
||||
struct vkp_hdr_frame;
|
||||
struct droiddeck_color;
|
||||
static int quest, framegen, cardboard, pass_result, gen_result, base_result, pass_shown, gen_shown;
|
||||
static int first_frames, pass_calls, gen_calls, base_calls, fallback_calls;
|
||||
static int settled, g_framegen_layer;
|
||||
static void settle_unwaited(void) { settled++; }
|
||||
static int quest, framegen, cardboard, pass_result, base_result, pass_shown;
|
||||
static int first_frames, pass_calls, base_calls, fallback_calls;
|
||||
static int vkp_quest_layer_presentation(void) { return quest; }
|
||||
static int vkp_framegen_active(void) { return framegen; }
|
||||
static int vkp_cardboard_active(void) { return cardboard; }
|
||||
@@ -23,46 +19,26 @@ static int sc_layer_present_pass(const struct vkp_draw *draws, int n, int w, int
|
||||
if (pass_result == 0 && pass_shown) vkp_signal_first_frame();
|
||||
return pass_result;
|
||||
}
|
||||
static int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws,
|
||||
const struct vkp_hdr_frame *hf, int w, int h,
|
||||
int composed, const struct droiddeck_color *color) {
|
||||
(void)w; (void)h;
|
||||
assert(composed == 1 && hf == NULL && color == NULL);
|
||||
gen_calls++;
|
||||
if (gen_result >= 0 && gen_shown) vkp_signal_first_frame();
|
||||
return gen_result;
|
||||
}
|
||||
static int render_impl(int w, int h, const struct vkp_draw *draws, int n,
|
||||
const void *hdr, int *how) { fallback_calls++; return 17; }
|
||||
|
||||
#include "vkp_render_under_test.inc"
|
||||
|
||||
static int compositor_route(int hdr_route, int cursor_on, int ahb_only,
|
||||
const struct vkp_draw *draws) {
|
||||
const int w = 1280, h = 720;
|
||||
const struct { const struct vkp_draw *d; int n; } dl = {draws, 1};
|
||||
int rendered = -2;
|
||||
#include "quest_route_under_test.inc"
|
||||
return rendered;
|
||||
}
|
||||
|
||||
static void reset(void) {
|
||||
quest = 1;
|
||||
settled = 0;
|
||||
g_framegen_layer = -1;
|
||||
framegen = cardboard = pass_result = gen_result = base_result = pass_shown = gen_shown = 0;
|
||||
first_frames = pass_calls = gen_calls = base_calls = fallback_calls = 0;
|
||||
framegen = cardboard = pass_result = base_result = pass_shown = 0;
|
||||
first_frames = pass_calls = base_calls = fallback_calls = 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
const struct vkp_draw draw = {0};
|
||||
reset();
|
||||
for (int i = 0; i < 3; i++) assert(vkp_render(1280, 720, NULL, 0) == 0);
|
||||
assert(base_calls == 3 && pass_calls == 0 && gen_calls == 0 && first_frames == 0);
|
||||
assert(base_calls == 3 && pass_calls == 0 && first_frames == 0);
|
||||
|
||||
reset();
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(pass_calls == 1 && gen_calls == 0 && base_calls == 1 && first_frames == 0);
|
||||
assert(pass_calls == 1 && base_calls == 1 && first_frames == 0);
|
||||
|
||||
reset(); pass_shown = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
@@ -77,81 +53,15 @@ int main(void) {
|
||||
assert(vkp_render(1280, 720, NULL, 0) == -1);
|
||||
assert(first_frames == 0);
|
||||
|
||||
for (int mode = 0; mode < 4; mode++) {
|
||||
for (int mode = 0; mode < 3; mode++) {
|
||||
reset();
|
||||
if (mode == 0) quest = 0;
|
||||
if (mode == 1) cardboard = 1;
|
||||
if (mode == 2) { quest = 0; framegen = 1; }
|
||||
if (mode == 3) { framegen = 1; cardboard = 1; }
|
||||
if (mode == 1) framegen = 1;
|
||||
if (mode == 2) cardboard = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 17);
|
||||
assert(fallback_calls == 1 && pass_calls == 0 && gen_calls == 0 && base_calls == 0);
|
||||
assert(fallback_calls == 1 && pass_calls == 0 && base_calls == 0);
|
||||
assert(first_frames == 0);
|
||||
}
|
||||
|
||||
reset(); framegen = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(gen_calls == 1 && pass_calls == 0 && fallback_calls == 0 && base_calls == 1);
|
||||
|
||||
reset(); framegen = 1; gen_result = -1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == -1);
|
||||
assert(gen_calls == 1 && fallback_calls == 0 && base_calls == 0 && first_frames == 0);
|
||||
|
||||
reset(); framegen = 1; gen_shown = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(first_frames == 1);
|
||||
assert(vkp_render(1280, 720, NULL, 0) == 0);
|
||||
assert(first_frames == 1);
|
||||
|
||||
reset(); framegen = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
framegen = 0;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(gen_calls == 1 && pass_calls == 1 && fallback_calls == 0 && first_frames == 0);
|
||||
for (int count = 1; count <= 2; count++) {
|
||||
for (int shown = 0; shown <= 1; shown++) {
|
||||
reset(); framegen = 1; gen_result = count; gen_shown = shown;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(gen_calls == 1 && pass_calls == 0 && fallback_calls == 0);
|
||||
assert(base_calls == 1 && first_frames == shown);
|
||||
assert(vkp_render(1280, 720, NULL, 0) == 0);
|
||||
assert(gen_calls == 1 && base_calls == 2 && first_frames == shown);
|
||||
}
|
||||
reset(); framegen = 1; gen_result = count; gen_shown = 1; base_result = -1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == -1);
|
||||
assert(gen_calls == 1 && base_calls == 1 && first_frames == 1);
|
||||
assert(pass_calls == 0 && fallback_calls == 0);
|
||||
}
|
||||
|
||||
for (int route = 0; route <= 3; route++) {
|
||||
for (int flags = 0; flags < 32; flags++) {
|
||||
reset();
|
||||
quest = flags & 1;
|
||||
framegen = (flags >> 1) & 1;
|
||||
cardboard = (flags >> 2) & 1;
|
||||
const int cursor = (flags >> 3) & 1;
|
||||
const int ahb = (flags >> 4) & 1;
|
||||
const int selected = route == 0 && quest && !cardboard && !cursor && !ahb;
|
||||
gen_result = 2; gen_shown = pass_shown = 1;
|
||||
assert(compositor_route(route, cursor, ahb, &draw) == (selected ? 1 : -2));
|
||||
assert(settled == selected && base_calls == selected);
|
||||
assert(gen_calls == (selected && framegen));
|
||||
assert(pass_calls == (selected && !framegen));
|
||||
assert(first_frames == selected && fallback_calls == 0);
|
||||
assert(g_framegen_layer == (selected ? framegen : -1));
|
||||
assert(quest == (flags & 1));
|
||||
assert(framegen == ((flags >> 1) & 1));
|
||||
assert(cardboard == ((flags >> 2) & 1));
|
||||
}
|
||||
}
|
||||
reset(); framegen = 1; gen_result = 2;
|
||||
assert(compositor_route(0, 0, 0, &draw) == 1);
|
||||
assert(g_framegen_layer == 1);
|
||||
framegen = 0;
|
||||
assert(compositor_route(0, 0, 0, &draw) == 1);
|
||||
assert(g_framegen_layer == 0 && gen_calls == 1 && pass_calls == 1 && base_calls == 2);
|
||||
reset(); framegen = 1; gen_result = -1;
|
||||
assert(compositor_route(0, 0, 0, &draw) == 0);
|
||||
assert(settled == 1 && gen_calls == 1 && base_calls == 0 && fallback_calls == 0);
|
||||
puts("PASS: Quest first-frame notification and display-layer frame generation");
|
||||
puts("PASS: Quest first-frame notification waits for client content");
|
||||
return 0;
|
||||
}
|
||||
@@ -3935,6 +3935,101 @@ class ForeignSystemDllTest(unittest.TestCase):
|
||||
self.assertEqual([], self.run_repair(Path(tmp) / "missing", proton))
|
||||
|
||||
|
||||
def wine_image(mark=b"Wine builtin DLL"):
|
||||
return pe_image(0xAA64)[:64] + mark + pe_image(0xAA64)[64 + len(mark):]
|
||||
|
||||
|
||||
class OtherWineBuiltinTest(unittest.TestCase):
|
||||
def tool(self, root, name, libraries=("kernel32.dll", "winedmo.dll"), default_pfx=True):
|
||||
proton = Path(root) / name / "proton"
|
||||
lib = proton.parent / "files/lib/wine"
|
||||
for libdir in ("aarch64-windows", "i386-windows"):
|
||||
(lib / libdir).mkdir(parents=True)
|
||||
for library in libraries:
|
||||
(lib / libdir / library).write_bytes(wine_image())
|
||||
if default_pfx:
|
||||
for folder in ("system32", "syswow64"):
|
||||
system = proton.parent / "files/share/default_pfx_arm64/drive_c/windows" / folder
|
||||
system.mkdir(parents=True)
|
||||
for library in libraries:
|
||||
(system / library).write_bytes(wine_image())
|
||||
return proton
|
||||
|
||||
def prefix(self, tmp):
|
||||
compat = Path(tmp) / "compat"
|
||||
windows = compat / "pfx/drive_c/windows"
|
||||
for folder in ("system32", "syswow64"):
|
||||
(windows / folder).mkdir(parents=True)
|
||||
return compat, windows
|
||||
|
||||
def run_removal(self, compat, proton, env=None):
|
||||
return MODULE["remove_other_wine_builtins"](str(compat), str(proton), env)
|
||||
|
||||
def test_libraries_another_proton_left_are_removed(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton = self.tool(tmp, "DroidDeck-Proton")
|
||||
other = self.tool(tmp, "GE-Proton", ("kernel32.dll", "winedmo.dll", "mpg4c32.dll", "ir50_32.dll"))
|
||||
compat, windows = self.prefix(tmp)
|
||||
other_lib = other.parent / "files/lib/wine"
|
||||
(windows / "system32/mpg4c32.dll").write_bytes(wine_image())
|
||||
(windows / "syswow64/mpg4c32.dll").symlink_to(other_lib / "i386-windows/mpg4c32.dll")
|
||||
(windows / "system32/IR50_32.DLL").symlink_to(Path(tmp) / "removed/files/lib/wine/aarch64-windows/ir50_32.dll")
|
||||
(windows / "syswow64/ir50_32.dll").write_bytes(wine_image(b"Wine placeholder DLL"))
|
||||
self.assertEqual(["system32/IR50_32.DLL", "system32/mpg4c32.dll", "syswow64/ir50_32.dll", "syswow64/mpg4c32.dll"],
|
||||
self.run_removal(compat, proton))
|
||||
for folder in ("system32", "syswow64"):
|
||||
self.assertEqual([], os.listdir(windows / folder))
|
||||
self.assertTrue((other_lib / "i386-windows/mpg4c32.dll").is_file())
|
||||
self.assertEqual([], self.run_removal(compat, proton))
|
||||
|
||||
def test_own_native_and_unrelated_files_are_kept(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton = self.tool(tmp, "DroidDeck-Proton")
|
||||
files = proton.parent / "files"
|
||||
(files / "lib/wine/i386-windows/winsock.dll16").write_bytes(wine_image())
|
||||
(files / "share/default_pfx_arm64/drive_c/windows/syswow64/libvkd3d-1.dll").write_bytes(wine_image())
|
||||
compat, windows = self.prefix(tmp)
|
||||
kept = {
|
||||
"system32/winedmo.dll": wine_image(),
|
||||
"system32/KERNEL32.DLL": wine_image(),
|
||||
"syswow64/winsock.dll": wine_image(b"Wine placeholder DLL"),
|
||||
"syswow64/libvkd3d-1.dll": wine_image(),
|
||||
"system32/xgameruntime.dll": wine_image(b"DroidDeck native"),
|
||||
"system32/game_plugin.dll": pe_image(0x8664),
|
||||
"system32/mpg4c32.dll.foreign-arch": wine_image(),
|
||||
"system32/helper.exe": wine_image(),
|
||||
"system32/notes.txt": b"Wine builtin DLL",
|
||||
}
|
||||
for name, data in kept.items():
|
||||
(windows / name).write_bytes(data)
|
||||
(windows / "system32/d3d11.dll").symlink_to(Path(tmp) / "dxvk/x64/d3d11.dll")
|
||||
self.assertEqual([], self.run_removal(compat, proton))
|
||||
for name, data in kept.items():
|
||||
self.assertEqual(data, (windows / name).read_bytes())
|
||||
self.assertTrue((windows / "system32/d3d11.dll").is_symlink())
|
||||
|
||||
def test_libraries_on_the_wine_dll_path_are_kept(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton = self.tool(tmp, "DroidDeck-Proton")
|
||||
audio = Path(tmp) / "directaudio/lib/wine"
|
||||
(audio / "aarch64-windows").mkdir(parents=True)
|
||||
(audio / "aarch64-windows/winedirectaudio.drv").write_bytes(wine_image())
|
||||
compat, windows = self.prefix(tmp)
|
||||
link = windows / "system32/winedirectaudio.drv"
|
||||
link.symlink_to(audio / "aarch64-windows/winedirectaudio.drv")
|
||||
self.assertEqual([], self.run_removal(compat, proton, {"WINEDLLPATH": "%s:/missing" % audio}))
|
||||
self.assertTrue(link.is_symlink())
|
||||
|
||||
def test_proton_without_a_default_prefix_leaves_the_prefix_alone(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
proton = self.tool(tmp, "Unbuilt-Proton", default_pfx=False)
|
||||
compat, windows = self.prefix(tmp)
|
||||
(windows / "system32/mpg4c32.dll").write_bytes(wine_image())
|
||||
self.assertEqual([], self.run_removal(compat, proton))
|
||||
self.assertTrue((windows / "system32/mpg4c32.dll").is_file())
|
||||
self.assertEqual([], self.run_removal(Path(tmp) / "missing", self.tool(tmp, "DroidDeck-Proton")))
|
||||
|
||||
|
||||
class SharedDataHealTest(unittest.TestCase):
|
||||
CURRENT = (21, 0x1234abcd, 0x5678ef01, os.getuid(), 1000)
|
||||
STALE = (21, 0x0badf00d, 0x0ddba11, 10122, 1000)
|
||||
|
||||
@@ -16,11 +16,6 @@ class QuestBackdropTest(unittest.TestCase):
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
work = Path(folder)
|
||||
(work / 'vkp_render_under_test.inc').write_text(source[start:end])
|
||||
compositor = (ROOT / 'app/src/main/cpp/waylandcomp/src/compositor.c').read_text()
|
||||
route_start = compositor.index(' if (hdr_route == 0 && vkp_quest_layer_presentation()')
|
||||
route_end = compositor.index(' } else if (hdr_route == 0 || hdr_route == 3)', route_start)
|
||||
(work / 'quest_route_under_test.inc').write_text(
|
||||
compositor[route_start:route_end] + ' }\n')
|
||||
binary = work / 'test-first-frame'
|
||||
subprocess.run(['cc', '-std=c11', '-Wall', '-Wextra',
|
||||
'-Wno-unused-parameter', '-Wno-unused-function', f'-I{work}',
|
||||
@@ -60,20 +55,6 @@ void AHardwareBuffer_describe(const AHardwareBuffer *, AHardwareBuffer_Desc *);
|
||||
int AHardwareBuffer_lock(AHardwareBuffer *, uint64_t, int32_t, const ARect *, void **);
|
||||
int AHardwareBuffer_unlock(AHardwareBuffer *, int32_t *);
|
||||
void AHardwareBuffer_release(AHardwareBuffer *);
|
||||
''')
|
||||
vulkan = work / 'vulkan'
|
||||
vulkan.mkdir()
|
||||
(vulkan / 'vulkan.h').write_text('''#pragma once
|
||||
#include <stdint.h>
|
||||
typedef void *VkInstance;
|
||||
typedef void *VkPhysicalDevice;
|
||||
typedef void *VkDevice;
|
||||
typedef void *VkQueue;
|
||||
typedef void *VkCommandBuffer;
|
||||
typedef void *VkImage;
|
||||
typedef void *VkImageView;
|
||||
typedef int VkFormat;
|
||||
typedef void (*PFN_vkGetInstanceProcAddr)(void);
|
||||
''')
|
||||
binary = work / 'test-presentation'
|
||||
subprocess.run(['cc', '-std=c11', '-O1', '-g', '-Wall', '-Wextra',
|
||||
|
||||
Reference in new issue
Block a user