mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-04 20:15:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
332bd81524 | ||
|
|
c986594aa9 |
No files matched your search
@@ -2844,9 +2844,10 @@ 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() && !framegen && !cardboard && !cursor_on &&
|
||||
if (hdr_route == 0 && vkp_quest_layer_presentation() && !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,15 +3013,24 @@ 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_framegen_active() && !vkp_cardboard_active()) {
|
||||
if (vkp_quest_layer_presentation() && !vkp_cardboard_active()) {
|
||||
vkp_apply_window_request();
|
||||
sc_layer_hide_overlay();
|
||||
if (n > 0) {
|
||||
if (sc_layer_present_pass(draws, n, scene_w, scene_h) != 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) {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
object DeviceReport {
|
||||
private const val TAG = "DeviceReport"
|
||||
@@ -37,10 +36,6 @@ object DeviceReport {
|
||||
.map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") }
|
||||
.filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" }
|
||||
|
||||
internal fun buildDate(millis: Long): String? = millis.takeIf { it > 0 }?.let {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }.format(Date(it))
|
||||
}
|
||||
|
||||
fun write(context: Context, target: File, mode: String) {
|
||||
try {
|
||||
target.writeText(build(context, mode))
|
||||
@@ -134,7 +129,6 @@ object DeviceReport {
|
||||
k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
|
||||
k("Security patch", Build.VERSION.SECURITY_PATCH)
|
||||
k("Build", Build.DISPLAY)
|
||||
k("Build date", buildDate(Build.TIME))
|
||||
k("Fingerprint", Build.FINGERPRINT)
|
||||
k("Kernel", System.getProperty("os.version"))
|
||||
k("ABIs", Build.SUPPORTED_ABIS.joinToString(", "))
|
||||
|
||||
@@ -59,18 +59,13 @@ object GameStorage {
|
||||
return when {
|
||||
pref == SessionPrefs.GAME_STORAGE_OFF -> null
|
||||
pref.isEmpty() -> options(context).firstOrNull()?.let { Option(it.name, it.path) }
|
||||
else -> reachable(pref).let { path -> Option(SessionPrefs.gameStorageLabel(context), path).takeIf { attached(File(path)) } }
|
||||
else -> Option(SessionPrefs.gameStorageLabel(context), pref).takeIf { attached(File(pref)) }
|
||||
}
|
||||
}
|
||||
|
||||
fun disconnected(context: Context): Boolean {
|
||||
val pref = SessionPrefs.gameStorage(context)
|
||||
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
|
||||
return pref.isNotEmpty() && pref != SessionPrefs.GAME_STORAGE_OFF && !attached(File(pref))
|
||||
}
|
||||
|
||||
internal fun attached(
|
||||
|
||||
@@ -46,16 +46,7 @@ object SecondaryLibrary {
|
||||
}
|
||||
|
||||
fun privateRoot(files: File, library: File): File {
|
||||
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())
|
||||
val digest = MessageDigest.getInstance("SHA-256").digest(library.canonicalPath.toByteArray())
|
||||
.joinToString("") { "%02x".format(it.toInt() and 255) }
|
||||
return File(files, "steam-libraries/$digest")
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ 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
|
||||
@@ -131,13 +130,13 @@ object BattleNetClient {
|
||||
StoresState.post { opener?.invoke(args) }
|
||||
}
|
||||
|
||||
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()
|
||||
fun library(context: Context, root: File = preferred(context)): List<String> =
|
||||
AddedGames.guestPath(context, StoreInstallRoot.storeDir(root, 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).takeIf { second == null && !GameStorage.disconnected(context) }
|
||||
?: StoreInstallRoot.internalRoot(context)
|
||||
}
|
||||
|
||||
fun installGame(context: Context, uid: String, root: File) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class DeviceReportBuildDateTest {
|
||||
@Test fun theFirmwareBuildTimeIsShownInUtc() {
|
||||
assertEquals("2024-11-08 17:47 UTC", DeviceReport.buildDate(1_731_088_027_000L))
|
||||
}
|
||||
|
||||
@Test fun anUnsetBuildTimeIsUnknown() {
|
||||
assertNull(DeviceReport.buildDate(0L))
|
||||
assertNull(DeviceReport.buildDate(-1L))
|
||||
}
|
||||
}
|
||||
@@ -114,19 +114,6 @@ 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,24 +21,6 @@ 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")
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
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())
|
||||
}
|
||||
}
|
||||
@@ -350,17 +350,6 @@ def keeps_open(root):
|
||||
return isinstance(client, dict) and LAUNCH_BEHAVIOR[0] in client and client[LAUNCH_BEHAVIOR[0]] != LAUNCH_BEHAVIOR[1]
|
||||
|
||||
|
||||
def chosen_folder(root, current, library):
|
||||
current = current.strip()
|
||||
folder = windows_path(root, current) if current else None
|
||||
if not folder or rootfs_drive(root, current) or not os.path.isdir(folder):
|
||||
return False
|
||||
try:
|
||||
return volume_root(os.path.realpath(folder)) == volume_root(os.path.realpath(library))
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def write_config(root, library=None):
|
||||
path = os.path.join(drive_c(root), *CONFIG)
|
||||
key, value = LAUNCH_BEHAVIOR
|
||||
@@ -385,7 +374,6 @@ def write_config(root, library=None):
|
||||
client["HardwareAcceleration"] = "false"
|
||||
changes.append("acceleration")
|
||||
if library and isinstance(client.setdefault("Install", {}), dict) \
|
||||
and not chosen_folder(root, str(client["Install"].get("DefaultInstallPath", "")), library) \
|
||||
and str(client["Install"].get("DefaultInstallPath", "")).rstrip("/\\") != install_path(root, library).rstrip("\\"):
|
||||
client["Install"]["DefaultInstallPath"] = install_path(root, library)
|
||||
changes.append("library")
|
||||
|
||||
@@ -739,8 +739,10 @@ char *getcwd(char *buf, size_t size) {
|
||||
static char *(*orig_getcwd)(char *, size_t) = NULL;
|
||||
if (!orig_getcwd) orig_getcwd = (char *(*)(char *, size_t))dlsym(RTLD_NEXT, "getcwd");
|
||||
char *res = orig_getcwd ? orig_getcwd(buf, size) : NULL;
|
||||
if (res && !buf) return guest_path_of_allocated_mount_source(res);
|
||||
if (res) guest_path_of_mount_source(res, strlen(res), size, NULL);
|
||||
if (res) {
|
||||
size_t len = strlen(res);
|
||||
guest_path_of_mount_source(res, len, buf ? size : len + 1, NULL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -788,8 +790,7 @@ char *realpath(const char *path, char *resolved_path) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (res && !resolved_path) return guest_path_of_allocated_mount_source(res);
|
||||
if (res) guest_path_of_mount_source(res, strlen(res), PATH_MAX, NULL);
|
||||
if (res) guest_path_of_mount_source(res, strlen(res), resolved_path ? PATH_MAX : strlen(res) + 1, NULL);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -975,20 +975,6 @@ static size_t guest_path_of_mount_source(char *buf, size_t len, size_t cap, int
|
||||
return best->dst_len + rest;
|
||||
}
|
||||
|
||||
static char *guest_path_of_allocated_mount_source(char *res) {
|
||||
size_t len = strlen(res);
|
||||
char tmp[PATH_MAX];
|
||||
if (len >= sizeof(tmp)) return res;
|
||||
memcpy(tmp, res, len + 1);
|
||||
int converted = 0;
|
||||
size_t n = guest_path_of_mount_source(tmp, len, sizeof(tmp), &converted);
|
||||
if (!converted) return res;
|
||||
char *grown = realloc(res, n + 1);
|
||||
if (!grown) return res;
|
||||
memcpy(grown, tmp, n + 1);
|
||||
return grown;
|
||||
}
|
||||
|
||||
static ssize_t postprocess_readlink(const char *linkpath, char *buf, ssize_t ret, size_t bufsiz) {
|
||||
if (ret <= 0) return ret;
|
||||
if ((size_t)ret < bufsiz) {
|
||||
|
||||
+101
-11
@@ -3,8 +3,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
struct vkp_draw { int unused; };
|
||||
static int quest, framegen, cardboard, pass_result, base_result, pass_shown;
|
||||
static int first_frames, pass_calls, base_calls, fallback_calls;
|
||||
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 vkp_quest_layer_presentation(void) { return quest; }
|
||||
static int vkp_framegen_active(void) { return framegen; }
|
||||
static int vkp_cardboard_active(void) { return cardboard; }
|
||||
@@ -19,26 +23,46 @@ 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;
|
||||
framegen = cardboard = pass_result = base_result = pass_shown = 0;
|
||||
first_frames = pass_calls = base_calls = fallback_calls = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
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 && first_frames == 0);
|
||||
assert(base_calls == 3 && pass_calls == 0 && gen_calls == 0 && first_frames == 0);
|
||||
|
||||
reset();
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
assert(pass_calls == 1 && base_calls == 1 && first_frames == 0);
|
||||
assert(pass_calls == 1 && gen_calls == 0 && base_calls == 1 && first_frames == 0);
|
||||
|
||||
reset(); pass_shown = 1;
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 0);
|
||||
@@ -53,15 +77,81 @@ int main(void) {
|
||||
assert(vkp_render(1280, 720, NULL, 0) == -1);
|
||||
assert(first_frames == 0);
|
||||
|
||||
for (int mode = 0; mode < 3; mode++) {
|
||||
for (int mode = 0; mode < 4; mode++) {
|
||||
reset();
|
||||
if (mode == 0) quest = 0;
|
||||
if (mode == 1) framegen = 1;
|
||||
if (mode == 2) cardboard = 1;
|
||||
if (mode == 1) cardboard = 1;
|
||||
if (mode == 2) { quest = 0; framegen = 1; }
|
||||
if (mode == 3) { framegen = 1; cardboard = 1; }
|
||||
assert(vkp_render(1280, 720, &draw, 1) == 17);
|
||||
assert(fallback_calls == 1 && pass_calls == 0 && base_calls == 0);
|
||||
assert(fallback_calls == 1 && pass_calls == 0 && gen_calls == 0 && base_calls == 0);
|
||||
assert(first_frames == 0);
|
||||
}
|
||||
puts("PASS: Quest first-frame notification waits for client content");
|
||||
|
||||
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");
|
||||
return 0;
|
||||
}
|
||||
@@ -295,37 +295,6 @@ class DriveTest(Temp):
|
||||
self.assertEqual(BNET["install_path"](self.root, str(self.card)), "D:\\")
|
||||
self.assertEqual(sorted(os.listdir(self.devices)), ["d:"])
|
||||
|
||||
def test_a_folder_chosen_in_battlenet_on_the_library_drive_is_kept(self):
|
||||
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
|
||||
BNET["write_config"](self.root)
|
||||
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
|
||||
(self.card / "Battle.net").mkdir()
|
||||
config = json.loads(path.read_text())
|
||||
config["Client"]["Install"]["DefaultInstallPath"] = "D:\\Battle.net"
|
||||
path.write_text(json.dumps(config))
|
||||
self.assertIsNone(BNET["write_config"](self.root, str(self.library)))
|
||||
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Battle.net")
|
||||
|
||||
def test_a_chosen_folder_inside_the_native_rootfs_is_not_kept_whatever_its_spacing(self):
|
||||
BNET["write_config"](self.root, str(self.library))
|
||||
rootfs = self.card / "files/linuxfs"
|
||||
(rootfs / "Games").mkdir(parents=True)
|
||||
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
|
||||
for current in ("D:\\files\\linuxfs\\Games", " D:\\files\\linuxfs\\Games"):
|
||||
self.assertFalse(BNET["chosen_folder"](self.root, current, str(self.library)))
|
||||
|
||||
def test_a_folder_on_another_drive_or_missing_moves_to_the_library(self):
|
||||
path = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
|
||||
BNET["write_config"](self.root, str(self.library))
|
||||
internal = self.tmp / "root/Games/Stores/Battle.net"
|
||||
internal.mkdir(parents=True)
|
||||
for current in ("Z:" + str(internal), "D:\\Gone"):
|
||||
config = json.loads(path.read_text())
|
||||
config["Client"]["Install"]["DefaultInstallPath"] = current
|
||||
path.write_text(json.dumps(config))
|
||||
self.assertEqual(BNET["write_config"](self.root, str(self.library)), "library")
|
||||
self.assertEqual(json.loads(path.read_text())["Client"]["Install"]["DefaultInstallPath"], "D:\\Games\\Battle.net")
|
||||
|
||||
def test_drives_in_use_and_the_ones_proton_owns_are_left_alone(self):
|
||||
self.devices.mkdir(parents=True)
|
||||
os.symlink("/somewhere/else", self.devices / "d:")
|
||||
|
||||
@@ -88,18 +88,6 @@ int main(int argc, char **argv) {
|
||||
printf("%s\t%s\n", argv[i], ok ? cwd : "-");
|
||||
continue;
|
||||
}
|
||||
if (strncmp(argv[i], "cdnull:", 7) == 0) {
|
||||
char *got = chdir(argv[i] + 7) == 0 ? getcwd(NULL, 0) : NULL;
|
||||
printf("%s\t%s\n", argv[i], got ? got : "-");
|
||||
free(got);
|
||||
continue;
|
||||
}
|
||||
if (strncmp(argv[i], "realnull:", 9) == 0) {
|
||||
char *got = realpath(argv[i] + 9, NULL);
|
||||
printf("%s\t%s\n", argv[i], got ? got : "-");
|
||||
free(got);
|
||||
continue;
|
||||
}
|
||||
if (strncmp(argv[i], "lstat:", 6) == 0) {
|
||||
int ok = lstat(argv[i] + 6, &st) == 0;
|
||||
printf("%s\t%d\t%d\n", argv[i], ok, ok && S_ISLNK(st.st_mode));
|
||||
@@ -336,19 +324,6 @@ class NativeHookMountTest(unittest.TestCase):
|
||||
arg = f"cd:/pfx/native/dosdevices/z:{GAME}/"
|
||||
self.assertEqual(self.run_probe(arg)[arg], [GAME])
|
||||
|
||||
def test_allocated_working_directory_and_real_path_name_a_longer_guest_mount(self):
|
||||
guest = "/root/Games/" + "g" * len(str(self.library))
|
||||
binds = f"{self.library}:{guest}"
|
||||
args = [f"cd:{guest}/Some Game", f"cdnull:{guest}/Some Game", f"realnull:{guest}/Some Game/game.txt"]
|
||||
result = self.run_probe(*args, binds=binds)
|
||||
self.assertEqual(result[args[0]], [f"{guest}/Some Game"])
|
||||
self.assertEqual(result[args[1]], [f"{guest}/Some Game"])
|
||||
self.assertEqual(result[args[2]], [f"{guest}/Some Game/game.txt"])
|
||||
|
||||
def test_allocated_working_directory_names_a_shorter_guest_mount(self):
|
||||
arg = f"cdnull:{GAME}"
|
||||
self.assertEqual(self.run_probe(arg)[arg], [GAME])
|
||||
|
||||
def test_rootfs_path_under_a_mount_point_reaches_the_mount(self):
|
||||
path = f"{self.root}{GAME}/game.txt"
|
||||
self.assertEqual(self.run_probe(path)[path], ["1", "library"])
|
||||
|
||||
@@ -16,6 +16,11 @@ 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}',
|
||||
@@ -55,6 +60,20 @@ 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