mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-30 18:15:42 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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())
|
||||
}
|
||||
}
|
||||
@@ -3,10 +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 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; }
|
||||
@@ -21,15 +19,6 @@ 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; }
|
||||
|
||||
@@ -37,19 +26,19 @@ static int render_impl(int w, int h, const struct vkp_draw *draws, int n,
|
||||
|
||||
static void reset(void) {
|
||||
quest = 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);
|
||||
@@ -64,36 +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);
|
||||
puts("PASS: Quest first-frame notification and display-layer frame generation");
|
||||
puts("PASS: Quest first-frame notification waits for client content");
|
||||
return 0;
|
||||
}
|
||||
@@ -55,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