diff --git a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c index eceb796398..d29b328a05 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_bridge.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_bridge.c @@ -33,7 +33,9 @@ static PFN_vkGetInstanceProcAddr g_gipa; static VkPhysicalDevice g_pd; static VkQueue g_queue; static uint32_t g_qfam; -static int g_dev_ready, g_dev_lost, g_features_enabled; +static _Atomic int g_dev_ready, g_dev_lost; +static int g_features_enabled; +static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok; static VkPhysicalDeviceMemoryProperties g_memprops; static struct { PFN_vkCreateImage CreateImage; @@ -141,9 +143,12 @@ static void mark_failed(int kind) { } int vkp_framegen_problem(void) { - if (!g_dev_ready) return -1; + if (!atomic_load(&g_dev_ready)) return -1; int kind = atomic_load(&g_kind); - if (!fge_caps_ok(kind)) return 1; + int caps_ok = kind == VKP_FG_ENGINE_DDFG + ? atomic_load(&g_caps_ddfg_ok) + : atomic_load(&g_caps_lsfg_ok); + if (!caps_ok) return 1; if (start_failed_for(kind)) return 2; if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2; return 0; @@ -179,13 +184,17 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f #undef R g_vk.GetPhysicalDeviceMemoryProperties(g_pd, &g_memprops); fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled); - g_dev_ready = vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier; + atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG)); + atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG)); + atomic_store(&g_dev_lost, 0); + atomic_store(&g_dev_ready, + vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier); FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s", fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(), fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable"); } -void vkp_framegen_device_lost(void) { g_dev_lost = 1; } +void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); } static void destroy_ring(void) { @@ -244,7 +253,12 @@ static int ensure_ring(uint32_t w, uint32_t h, VkFormat fmt, uint32_t n) { static int engine_usable(void) { int kind = atomic_load(&g_kind); - return g_dev_ready && !g_dev_lost && fge_caps_ok(kind) && !start_failed_for(kind); + int ready = atomic_load(&g_dev_ready); + int lost = atomic_load(&g_dev_lost); + int caps_ok = kind == VKP_FG_ENGINE_DDFG + ? atomic_load(&g_caps_ddfg_ok) + : atomic_load(&g_caps_lsfg_ok); + return ready && !lost && caps_ok && !start_failed_for(kind); } int vkp_framegen_format_ok(VkFormat fmt) { diff --git a/app/src/main/cpp/waylandcomp/src/framegen_jni.c b/app/src/main/cpp/waylandcomp/src/framegen_jni.c index 35c5a3de46..e5a51456ed 100644 --- a/app/src/main/cpp/waylandcomp/src/framegen_jni.c +++ b/app/src/main/cpp/waylandcomp/src/framegen_jni.c @@ -50,6 +50,12 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenCapsReason(J return (*env)->NewStringUTF(env, r ? r : ""); } +JNIEXPORT jboolean JNICALL +Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenActive(JNIEnv *env, jclass clazz) { + (void)env; (void)clazz; + return vkp_framegen_active() ? JNI_TRUE : JNI_FALSE; +} + JNIEXPORT jfloatArray JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFrameGenStats(JNIEnv *env, jclass clazz) { (void)clazz; diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 5f39d03c6c..dc87e93d04 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -452,6 +452,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { private var drawerDefaultProton by mutableStateOf(null) private val drawerComponentMenu by lazy { ComponentsMenu(this, uiHandler) } private var drawerGameProfileId by mutableStateOf(null) + private var drawerGameProfileSelectionMade = false private var fpsLimit by mutableStateOf(SessionState.fpsLimit) private fun noSteamSession(): Boolean = (SessionState.mode == SessionService.MODE_RUN && @@ -460,7 +461,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { com.droiddeck.launcher.session.NoSteamLaunch.BATTLENET, )) || SessionState.mode == SessionService.MODE_DESKTOP private val drawerGameInventory = GameProfileInventoryCache() - private var drawerGameInventoryRevision = 0L + @Volatile private var drawerGameInventoryRevision = 0L private var drawerGameFexPresetSaving by mutableStateOf(false) private var drawerGameNoSteamSaving by mutableStateOf(false) private val drawerGameProfileFollowState = GameProfileFollowState() @@ -556,8 +557,25 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { importLossless(it) } } private var frameGen by mutableStateOf(FrameGen.Mode.OFF) + private var frameGenActiveGameId by mutableStateOf(null) + private var frameGenActiveGameName by mutableStateOf(null) + private var frameGenHasGameOverride by mutableStateOf(false) private var frameGenPip = false private val frameGenRequests = java.util.concurrent.atomic.AtomicInteger() + private val frameGenActivityGeneration = synchronized(frameGenGlobalLock) { + frameGenGlobalGeneration.incrementAndGet() + } + @Volatile private var frameGenActivityActive = true + private val frameGenForcePending = java.util.concurrent.atomic.AtomicBoolean() + @Volatile private var frameGenInventoryIds: Set? = null + @Volatile private var frameGenInventoryRevision = -1L + private val frameGenInventoryLock = Any() + @Volatile private var frameGenInventoryLastAttemptAt = 0L + private val frameGenInventoryRetryScheduled = java.util.concurrent.atomic.AtomicBoolean() + private val frameGenInventoryRefreshScheduled = java.util.concurrent.atomic.AtomicBoolean() + + @Volatile private var appliedFrameGenMode: FrameGen.Mode? = null + @Volatile private var appliedFrameGenHz: Float? = null private var fexPreset by mutableStateOf("") private var suspendPolicy by mutableStateOf(SessionPrefs.SUSPEND_MANUAL) private var steamDownloadsInBackground by mutableStateOf(false) @@ -859,7 +877,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { hud.attach(root, root.childCount) memoryHud = com.droiddeck.launcher.session.MemoryHud(this) hud.onPresentingWindowChanged = { - if (FrameGen.engine(this) != FrameGen.ENGINE_OFF) CompositorHost.rearmFrameGen { applyFrameGen() } + CompositorHost.rearmFrameGen { applyFrameGen(force = true) } } if (SessionState.running && SessionState.firstFrameSeen) { loading.visible = false @@ -892,8 +910,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } } glassesScope.launch { com.droiddeck.launcher.handtracking.HandTracking.settings.collect { updateHandCamera() } } glassesScope.launch { + var lastRunGameId: String? = null while (true) { updateTrackingRecovery() + if (SessionState.mode == SessionService.MODE_RUN) { + val gameId = SessionState.gameId + ?.takeIf { it.toLongOrNull() != null } + ?: intent.getStringExtra(SessionService.EXTRA_GAME_ID) + ?.takeIf { it.toLongOrNull() != null } + if (gameId != lastRunGameId) { + lastRunGameId = gameId + if (drawerGameProfileFollowState.followsSteam) { + loadFrameGenFor(gameId?.toLongOrNull()) + } + applyFrameGen() + } + } else { + lastRunGameId = null + } kotlinx.coroutines.delay(100) } } @@ -956,7 +990,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { applyOutputPacing() if (pipUi != frameGenPip) { frameGenPip = pipUi - if (FrameGen.engine(this@SessionActivity) != FrameGen.ENGINE_OFF && ::surfaceView.isInitialized) applyFrameGen() + if (::surfaceView.isInitialized) applyFrameGen() } } androidx.compose.runtime.LaunchedEffect(AgentGuest.steamKeyboard) { updateOnScreenControls() } @@ -1032,7 +1066,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { window.setBackgroundDrawable(android.graphics.drawable.ColorDrawable(android.graphics.Color.BLACK)) }, ) - LaunchedEffect(AgentGuest.focusRevision, secondScreenDisplays.isNotEmpty()) { + LaunchedEffect(AgentGuest.focusRevision, secondScreenDisplays.isNotEmpty(), drawerGameInventoryRevision) { val nextGame = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { if (SessionState.mode == SessionService.MODE_RUN) SessionState.program?.let { "program:$it" } else { @@ -1045,11 +1079,40 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } } } + if (SessionState.mode == SessionService.MODE_STEAM) { + val target = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + val games = LibraryCache.load(this@SessionActivity) + val cachedIds = games.mapNotNull { it.profileKey.toLongOrNull() }.toSet() + val inventoryIds = synchronized(frameGenInventoryLock) { + frameGenInventoryIds + }.orEmpty() + val id = AgentGuest.activeSteamAppId( + this@SessionActivity, cachedIds + inventoryIds + ) + val name = id?.let { activeId -> + games.firstOrNull { it.profileKey == activeId.toString() }?.name + } + id to name + } + if (target.first != frameGenActiveGameId) { + frameGenActiveGameId = target.first + if (drawerGameProfileFollowState.followsSteam) { + loadFrameGenFor(target.first) + } + } + frameGenActiveGameName = target.second + } if (nextGame != gestureGame) { if (nextGame != null) gameStarts++ gestureGame = nextGame refreshGestureConfig() } + if ( + SessionState.mode == SessionService.MODE_STEAM && + CompositorHost.isStarted + ) { + applyFrameGen() + } if (secondScreenDisplays.isNotEmpty()) kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { runCatching { com.droiddeck.launcher.session.TelemetryOutput.applyAutomatic(this@SessionActivity, nextGame) } } @@ -1234,6 +1297,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { textureAnisotropy = if (drawerGameProfileId == null) textureAnisotropy else drawerTextureAnisotropy, textureLodBias = if (drawerGameProfileId == null) textureLodBias else drawerTextureLodBias, frameGen = frameGen, + frameGenTargetGameId = frameGenTargetGameId()?.toString(), + frameGenTargetGameName = when { + !drawerGameProfileFollowState.followsSteam -> + drawerGameProfileRefresh.data?.profiles + ?.firstOrNull { it.first == frameGenTargetGameId() }?.second + SessionState.mode == SessionService.MODE_STEAM -> frameGenActiveGameName + SessionState.mode == SessionService.MODE_RUN -> + com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) + else -> drawerGameProfileRefresh.data?.profiles + ?.firstOrNull { it.first == frameGenTargetGameId() }?.second + }, + hasGameOverride = frameGenHasGameOverride, lossless = lossless, oscMode = oscMode, suspendPolicy = suspendPolicy, steamDownloadsInBackground = steamDownloadsInBackground, touchMode = touchMode, @@ -1293,9 +1368,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { applyOutputPacing() }, onFrameGenPick = { mode -> - FrameGen.set(this@SessionActivity, mode) + val appId = frameGenTargetGameId() + + if (appId == null) FrameGen.set(this@SessionActivity, mode) + else FrameGen.setForGame(this@SessionActivity, appId.toString(), mode) + loadFrameGenFor(appId) readPrefs() - applyFrameGen() + applyFrameGen(force = true) + }, + onFrameGenReset = { + val appId = frameGenTargetGameId() + + if (appId == null) FrameGen.clearGlobal(this@SessionActivity) + else FrameGen.clearGame(this@SessionActivity, appId.toString()) + loadFrameGenFor(appId) + readPrefs() + applyFrameGen(force = true) }, onImportLossless = { pickLossless.launch(InAppFilePicker.buildIntent( @@ -1628,9 +1716,35 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { }, "drawer-components").start() } + private fun frameGenTargetGameId(): Long? { + if (!drawerGameProfileFollowState.followsSteam) { + return drawerGameProfileId + } + if (SessionState.mode == SessionService.MODE_RUN) { + return ( + SessionState.gameId?.toLongOrNull() + ?: intent.getStringExtra(SessionService.EXTRA_GAME_ID)?.toLongOrNull() + ) + } + if (SessionState.mode == SessionService.MODE_STEAM) { + return frameGenActiveGameId + } + return drawerGameProfileId + } + + private fun loadFrameGenFor(appId: Long?) { + val profileId = appId?.toString() + frameGen = FrameGen.mode(this, profileId) + frameGenHasGameOverride = appId?.let { + FrameGen.hasGameOverride(this, it.toString()) + } == true + } + private fun selectDrawerGameProfile(appId: Long?) { drawerGameProfileFollowState.selectManually() + drawerGameProfileSelectionMade = true drawerGameProfileId = appId + loadFrameGenFor(frameGenTargetGameId()) drawerGameProfileRefresh = drawerGameProfileRefresh.retrying() readDrawerTextureFiltering(appId) refreshDrawerGameProfile() @@ -1703,6 +1817,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (refresh.followsSteam) { if (drawerGameProfileFollowState.followsSteam) { drawerGameProfileId = result.selectedAppId + loadFrameGenFor(result.selectedAppId) readDrawerTextureFiltering(result.selectedAppId) } } @@ -1727,6 +1842,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { gameProtonId = ProtonDefault.gameSelectedId(this, game.profileKey, protons), gameComponents = ComponentsManager.gameComponents(this, game.profileKey), gameWindowsComponents = WinComponents.picks(this, game.profileKey), + frameGenMode = FrameGen.mode(this, game.profileKey), + frameGenInherited = !FrameGen.hasGameOverride(this, game.profileKey), ) } @@ -1970,7 +2087,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (routedTouchMode != nextRoutedTouchMode) gestureTouchStreamGate.reset() routedTouchMode = nextRoutedTouchMode requestRelativeMouse() - frameGen = FrameGen.mode(this) + loadFrameGenFor(frameGenTargetGameId()) fexPreset = SessionPrefs.fexPreset(this) suspendPolicy = SessionPrefs.suspendPolicy(this, SessionState.mode) steamDownloadsInBackground = SessionPrefs.steamDownloadsInBackground(this) @@ -2257,7 +2374,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { if (resized) { cancelTouchGestures() Log.i(TAG, "surface resized to ${width}x$height - rebinding the compositor") - CompositorHost.resize(holder.surface) { applyFrameGen() } + CompositorHost.resize(holder.surface) { applyFrameGen(force = true) } resizeOutputForWindow(width, height) } } @@ -2398,17 +2515,161 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } } - private fun applyFrameGen() { + private fun frameGenModeForActiveGame(request: Int): FrameGen.Mode { + if (SessionState.mode == SessionService.MODE_RUN) { + val activeAppId = ( + SessionState.gameId?.takeIf { it.toLongOrNull() != null } + ?: intent.getStringExtra(SessionService.EXTRA_GAME_ID) + )?.toLongOrNull() + return FrameGen.mode(this, activeAppId?.toString()) + } + + val cachedIds = LibraryCache.load(this) + .mapNotNull { it.profileKey.toLongOrNull() } + .toSet() + + var inventoryRevision = drawerGameInventoryRevision + var ids = synchronized(frameGenInventoryLock) { + if (frameGenInventoryRevision != inventoryRevision) { + frameGenInventoryIds = null + frameGenInventoryRevision = inventoryRevision + frameGenInventoryLastAttemptAt = 0L + } + frameGenInventoryIds + } + if (ids == null) { + val now = SystemClock.elapsedRealtime() + val shouldScan = synchronized(frameGenInventoryLock) { + val currentRevision = drawerGameInventoryRevision + if (frameGenInventoryRevision != currentRevision) { + frameGenInventoryIds = null + frameGenInventoryRevision = currentRevision + frameGenInventoryLastAttemptAt = 0L + } + inventoryRevision = currentRevision + if (frameGenInventoryIds != null) { + false + } else if ( + frameGenInventoryLastAttemptAt != 0L && + now - frameGenInventoryLastAttemptAt < 15_000L + ) { + false + } else { + frameGenInventoryLastAttemptAt = now + true + } + } + + if (shouldScan) { + val currentIds = runCatching { + Library.launchableGames(this, strictRead = true) + .mapNotNull { it.profileKey.toLongOrNull() } + .toSet() + }.getOrNull() + + if (currentIds == null) { + if (frameGenInventoryRetryScheduled.compareAndSet(false, true)) { + uiHandler.postDelayed({ + frameGenInventoryRetryScheduled.set(false) + val retry = synchronized(frameGenInventoryLock) { + frameGenInventoryIds == null + } + if (retry && !isFinishing && !isDestroyed) { + applyFrameGen() + } + }, 15_000L) + } + } else { + var published = false + synchronized(frameGenInventoryLock) { + if (drawerGameInventoryRevision == inventoryRevision && + frameGenInventoryRevision == inventoryRevision + ) { + ids = cachedIds + currentIds + frameGenInventoryIds = ids + published = true + } + } + if (published) { + if (frameGenInventoryRefreshScheduled.compareAndSet(false, true)) { + uiHandler.postDelayed({ + frameGenInventoryRefreshScheduled.set(false) + if (frameGenActivityActive && !isFinishing && !isDestroyed) { + synchronized(frameGenInventoryLock) { + frameGenInventoryIds = null + frameGenInventoryLastAttemptAt = 0L + } + applyFrameGen() + } + }, 15_000L) + } + if (frameGenRequests.get() != request) { + applyFrameGen() + } + } + } + } + + if (ids == null) { + ids = synchronized(frameGenInventoryLock) { + frameGenInventoryIds + } ?: emptySet() + } + } + + val activeAppId = AgentGuest.activeSteamAppId( + this, cachedIds + (ids ?: emptySet()) + ) + if (activeAppId == null) return FrameGen.Mode.OFF + return FrameGen.mode(this, activeAppId.toString()) + } + + private fun applyFrameGen(force: Boolean = false) { + val request = synchronized(frameGenGlobalLock) { + if (force) frameGenForcePending.set(true) + frameGenRequests.incrementAndGet() + } val hz = refreshHz() val pip = pipUi && mirrorRefreshLimit() <= 0 - val request = frameGenRequests.incrementAndGet() Thread({ - val problem = synchronized(frameGenRequests) { + val mode = if (pip) FrameGen.Mode.OFF else frameGenModeForActiveGame(request) + val needsApply = synchronized(frameGenGlobalLock) { + if (frameGenActivityGeneration != frameGenGlobalGeneration.get()) return@Thread if (request != frameGenRequests.get()) return@Thread - if (pip) FrameGen.apply(this, FrameGen.Mode.OFF, hz) else FrameGen.apply(this, hz) + if (!frameGenActivityActive || isFinishing || isDestroyed) return@Thread + val lastAppliedHz = appliedFrameGenHz + frameGenForcePending.get() || appliedFrameGenMode == null || + mode != appliedFrameGenMode || lastAppliedHz == null || + kotlin.math.abs(lastAppliedHz - hz) > 0.1f + } + val prepared = if (needsApply) FrameGen.prepareApply(this, mode) else null + val problem = synchronized(frameGenGlobalLock) { + if (frameGenActivityGeneration != frameGenGlobalGeneration.get()) return@Thread + if (request != frameGenRequests.get()) return@Thread + if (!frameGenActivityActive || isFinishing || isDestroyed) return@Thread + val forcePending = frameGenForcePending.get() + val lastAppliedHz = appliedFrameGenHz + if (!forcePending && appliedFrameGenMode != null && mode == appliedFrameGenMode && + lastAppliedHz != null && kotlin.math.abs(lastAppliedHz - hz) <= 0.1f + ) { + null + } else { + val ready = prepared ?: return@Thread + frameGenForcePending.set(false) + FrameGen.applyPrepared(this, ready, hz).also { problem -> + if (problem == null) { + appliedFrameGenMode = mode + appliedFrameGenHz = hz + } else { + appliedFrameGenMode = null + appliedFrameGenHz = null + } + } + } } val state = Lossless.state(this) runOnUiThread { + if (frameGenActivityGeneration != frameGenGlobalGeneration.get()) return@runOnUiThread lossless = state if (problem != null) Toast.makeText(this, problem, Toast.LENGTH_LONG).show() } @@ -2425,12 +2686,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { private fun importLossless(dll: File) { Thread({ - val message = Lossless.message(this, Lossless.import(this, dll)) + val result = Lossless.import(this, dll) + val message = Lossless.message(this, result) val state = Lossless.state(this) runOnUiThread { lossless = state Toast.makeText(this, message, Toast.LENGTH_LONG).show() - if (FrameGen.engine(this) == FrameGen.ENGINE_LSFG) applyFrameGen() + applyFrameGen(force = result == Lossless.ImportResult.UPDATED) } }, "lossless-import").start() } @@ -4708,12 +4970,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { override fun onResume() { super.onResume() + drawerGameInventoryRevision++ com.droiddeck.launcher.input.SystemKeyCapture.attach(this, { hasWindowFocus() && !appUiOwnsPointer() && CompositorHost.isStarted }) { event -> com.droiddeck.launcher.input.GuestKeys.send(event) { code, down -> sendGuestKey(code, down, 8) } } if (refreshActivityDisplayId() && started) { SessionService.setActivityDisplay(this, sessionActivityDisplayId) } + if (CompositorHost.isStarted) applyFrameGen(force = true) applyFollowOrientation(resources.configuration) if (runtimeRemovalBlocked) return if (!SessionState.suspended) pausedFrame = null @@ -5391,6 +5655,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } override fun onDestroy() { + synchronized(frameGenGlobalLock) { + frameGenActivityActive = false + frameGenRequests.incrementAndGet() + } if (AgentGuest.readyListener === agentReadyListener) AgentGuest.readyListener = null com.droiddeck.launcher.input.HomeButtonShortcuts.detach(this) relativeMouseRequests.shutdownNow() @@ -5505,6 +5773,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { private const val BOTTOM_RECOVERY_MS = 1_000L private const val BOTTOM_RECOVERY_TRIES = 3 private const val TAG = "SessionActivity" + private val frameGenGlobalLock = Any() + private val frameGenGlobalGeneration = java.util.concurrent.atomic.AtomicLong(0L) private var startedScreens = 0 @Volatile private var activeInstallWorker: Any? = null private const val FEX_MISSING = "droiddeck-fex: x86 Linux programs need" diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index b303ecc71e..99732653b6 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -126,6 +126,7 @@ object Library { fun steamGames( context: Context, strictRead: Boolean = false, arch: String = SessionPrefs.activeSteamClientArch(context), withShared: Boolean = true, + onlyAppIds: Set? = null, ): List { val root = SessionPrefs.steamRoot(context, arch) val cache = File(root, "appcache/librarycache") @@ -138,7 +139,9 @@ object Library { if (strictRead && steamapps.isDirectory) check(manifests != null) { context.getString(R.string.game_sync_err_manifests) } manifests?.sortedBy { it.name }?.forEach { manifest -> val appId = manifest.name.removePrefix("appmanifest_").removeSuffix(".acf").toIntOrNull() ?: return@forEach - if (appId in NOT_GAMES || out.containsKey(appId)) return@forEach + if (appId in NOT_GAMES || out.containsKey(appId) || + (onlyAppIds != null && appId !in onlyAppIds) + ) return@forEach val text = try { manifest.readText() } catch (e: Exception) { if (strictRead) throw e; return@forEach } val name = NAME.find(text)?.groupValues?.get(1)?.trim().orEmpty() val flags = STATE.find(text)?.groupValues?.get(1)?.toIntOrNull() ?: 0 @@ -161,16 +164,41 @@ object Library { } if (withShared) { val other = if (arch == "x86_64") "arm64" else "x86_64" - val shared = sharedApps(context, arch) - out.keys - if (shared.isNotEmpty()) runCatching { steamGames(context, arch = other, withShared = false) }.getOrDefault(emptyList()) - .filter { it.appId in shared }.forEach { out[it.appId] = it } + val shared = try { + sharedApps(context, arch) - out.keys + } catch (e: IllegalStateException) { + if (strictRead) throw e + emptySet() + } + if (shared.isNotEmpty()) { + val otherGames = try { + steamGames( + context, + strictRead = strictRead, + arch = other, + withShared = false, + onlyAppIds = shared, + ) + } catch (e: Exception) { + if (strictRead) throw e + emptyList() + } + otherGames.forEach { out[it.appId] = it } + } } return out.values.toList() } internal fun sharedApps(context: Context, arch: String): Set { val view = File(LinuxRuntime.rootDir(context), "root/.droiddeck-x64/shared/${if (arch == "x86_64") "arm64" else "x86-64"}/steamapps") - return view.list().orEmpty().mapNotNull { Regex("appmanifest_(\\d+)\\.acf").matchEntire(it)?.groupValues?.get(1)?.toIntOrNull() }.toSet() + val entries = view.list() + if (entries == null) { + if (!view.exists()) return emptySet() + throw IllegalStateException("Unable to read the shared Steam library.") + } + return entries.mapNotNull { + Regex("appmanifest_(\\d+)\\.acf").matchEntire(it)?.groupValues?.get(1)?.toIntOrNull() + }.toSet() } fun steamLibraryArt(context: Context): List> { diff --git a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt index c31cd348e8..1623c10106 100644 --- a/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt +++ b/app/src/main/java/com/droiddeck/launcher/gpu/FrameGen.kt @@ -28,12 +28,38 @@ object FrameGen { fun engine(context: Context): String = mode(context).engine - fun mode(context: Context): Mode { + fun mode(context: Context): Mode = mode(context, null) + + fun mode(context: Context, appId: String?): Mode { val prefs = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE) - val engine = prefs.getString("engine", ENGINE_OFF).let { if (it == LEGACY_ENGINE_WINFG) ENGINE_DDFG else it ?: ENGINE_OFF } - val target = prefs.getInt("target", 0) + val gamePrefix = appId?.takeIf { it.isNotBlank() }?.let { "game.$it." } + ?.takeIf { prefs.contains(it + "engine") } ?: "" + val engine = prefs.getString(gamePrefix + "engine", ENGINE_OFF) + .let { if (it == LEGACY_ENGINE_WINFG) ENGINE_DDFG else it ?: ENGINE_OFF } + val target = prefs.getInt(gamePrefix + "target", 0) if (engine == ENGINE_LSFG && target in ADAPTIVE_TARGETS) return Mode(engine, target = target) - return Mode(engine, prefs.getInt("multiplier", 2).coerceIn(2, 4)) + return Mode(engine, prefs.getInt(gamePrefix + "multiplier", 2).coerceIn(2, 4)) + } + + fun hasGameOverride(context: Context, appId: String): Boolean = + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).contains("game.$appId.engine") + + fun setForGame(context: Context, appId: String, mode: Mode) { + val prefix = "game.$appId." + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() + .putString(prefix + "engine", mode.engine) + .putInt(prefix + "multiplier", mode.multiplier) + .putInt(prefix + "target", mode.target) + .apply() + } + + fun clearGame(context: Context, appId: String) { + val prefix = "game.$appId." + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() + .remove(prefix + "engine") + .remove(prefix + "multiplier") + .remove(prefix + "target") + .apply() } fun set(context: Context, mode: Mode) { @@ -41,6 +67,11 @@ object FrameGen { .putString("engine", mode.engine).putInt("multiplier", mode.multiplier).putInt("target", mode.target).apply() } + fun clearGlobal(context: Context) { + context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit() + .remove("engine").remove("multiplier").remove("target").apply() + } + fun label(context: Context): String = label(context, mode(context)) fun label(context: Context, mode: Mode): String = when { @@ -50,14 +81,32 @@ object FrameGen { else -> context.getString(R.string.frame_gen_off) } - fun apply(context: Context, refreshHz: Float): String? = apply(context, mode(context), refreshHz) + data class PreparedApply internal constructor( + val mode: Mode, + internal val lsfgStatus: Int? = null, + internal val lsfgCachePath: String? = null, + ) - fun apply(context: Context, mode: Mode, refreshHz: Float): String? { + fun prepareApply(context: Context, mode: Mode): PreparedApply { + if (mode.engine != ENGINE_LSFG) return PreparedApply(mode) + val status = Lossless.sync(context) + val cachePath = Lossless.cacheFile(context)?.absolutePath + return PreparedApply(mode, status, cachePath) + } + + fun apply(context: Context, refreshHz: Float): String? = + apply(context, mode(context), refreshHz) + + fun apply(context: Context, mode: Mode, refreshHz: Float): String? = + applyPrepared(context, prepareApply(context, mode), refreshHz) + + fun applyPrepared(context: Context, prepared: PreparedApply, refreshHz: Float): String? { + val mode = prepared.mode when (mode.engine) { ENGINE_LSFG -> { - val status = Lossless.sync(context) - val cache = Lossless.cacheFile(context) - if (status != LsfgNative.STATUS_OK || cache == null) { + val status = prepared.lsfgStatus ?: LsfgNative.STATUS_NOT_INSTALLED + val cachePath = prepared.lsfgCachePath + if (status != LsfgNative.STATUS_OK || cachePath == null) { WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0) val problem = context.getString( if (status == LsfgNative.STATUS_NOT_INSTALLED) R.string.lsfg_problem_missing else R.string.lsfg_problem_failed, @@ -66,7 +115,7 @@ object FrameGen { return problem } WaylandCompositor.nativeSetFrameGenEngine(WaylandCompositor.FG_ENGINE_LSFG) - WaylandCompositor.nativeSetLsfgCachePath(cache.absolutePath) + WaylandCompositor.nativeSetLsfgCachePath(cachePath) WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_LSFG, refreshHz) WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, mode.target) } diff --git a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt index f612477f33..014fc0b4e7 100644 --- a/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/hud/DroidDeckHudHost.kt @@ -10,7 +10,6 @@ import android.view.View import android.view.animation.PathInterpolator import android.view.ViewGroup import android.widget.FrameLayout -import com.droiddeck.launcher.gpu.FrameGen import com.droiddeck.launcher.gpu.GpuInfo import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.SessionPrefs @@ -238,8 +237,13 @@ class DroidDeckHudHost(context: Context) { } private fun presentedFps(): Float { - if (FrameGen.mode(context).engine == FrameGen.ENGINE_OFF) return 0f - val stats = runCatching { WaylandCompositor.nativeFrameGenStats() }.getOrNull() ?: return 0f + if (!runCatching { WaylandCompositor.nativeFrameGenActive() } + .getOrDefault(false)) return 0f + + val stats = runCatching { + WaylandCompositor.nativeFrameGenStats() + }.getOrNull() ?: return 0f + return if (stats.size > 3 && stats[3] > 1f) stats[3] else 0f } diff --git a/app/src/main/java/com/droiddeck/launcher/session/SelectedGameProfile.kt b/app/src/main/java/com/droiddeck/launcher/session/SelectedGameProfile.kt index 41eeac38f6..cdcc617a61 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SelectedGameProfile.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SelectedGameProfile.kt @@ -3,6 +3,7 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.core.FexPreset import com.droiddeck.launcher.core.GameEnvironment import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.gpu.FrameGen data class ProfileValue(val value: String, val inherited: Boolean) @@ -17,6 +18,8 @@ data class SelectedGameProfile( val environmentOverrides: Int, val windowsComponentNames: List, val startWithoutSteam: Boolean = false, + val frameGen: FrameGen.Mode = FrameGen.Mode.OFF, + val frameGenInherited: Boolean = true, ) { val hasOverrides: Boolean get() = !fexPreset.inherited || @@ -24,7 +27,8 @@ data class SelectedGameProfile( components.values.any { !it.inherited } || environmentOverrides > 0 || windowsComponentNames.isNotEmpty() || - startWithoutSteam + startWithoutSteam || + !frameGenInherited companion object { fun resolve( @@ -38,6 +42,8 @@ data class SelectedGameProfile( gameProtonId: String?, gameComponents: Map, gameWindowsComponents: List, + frameGenMode: FrameGen.Mode = FrameGen.Mode.OFF, + frameGenInherited: Boolean = true, ): SelectedGameProfile? { val game = games.firstOrNull { it.profileKey == selectedAppId.toString() } ?: return null val fexOverride = GameEnvironment.gameFexPreset(environment, game.profileKey) @@ -68,6 +74,8 @@ data class SelectedGameProfile( environmentOverrides = otherEnvironment.size, windowsComponentNames = gameWindowsComponents.map(WinComponentNames::of), startWithoutSteam = GameEnvironment.gameNoSteam(environment, game.profileKey), + frameGen = frameGenMode, + frameGenInherited = frameGenInherited, ) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt index bac30bd3b8..83f2e05436 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrameGenMenu.kt @@ -13,6 +13,9 @@ internal fun FrameGenMenu( host: MenuHost, mode: FrameGen.Mode, lossless: Lossless.State, onPick: (FrameGen.Mode) -> Unit, onImportLossless: () -> Unit, + gameProfileId: String? = null, + hasGameOverride: Boolean = false, + onResetGame: () -> Unit = {}, ) { val context = LocalContext.current AnchoredMenu(host.open == "fg", onDismiss = { if (host.open == "fg") host.open = null }, title = stringResource(R.string.frame_gen_title)) { firstItemFocus -> @@ -27,6 +30,12 @@ internal fun FrameGenMenu( onPick(m); host.open = null } item(FrameGen.Mode.OFF, focus = firstItemFocus) + if (gameProfileId != null) { + MenuItem(stringResource(R.string.comp_game_use_general), checked = !hasGameOverride) { + onResetGame() + host.open = null + } + } for (m in 2..4) item(FrameGen.Mode(FrameGen.ENGINE_DDFG, m)) val lsfg = (2..4).map { FrameGen.Mode(FrameGen.ENGINE_LSFG, it) } + FrameGen.ADAPTIVE_TARGETS.map { FrameGen.Mode(FrameGen.ENGINE_LSFG, target = it) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index bfdbd7ecef..3354839a7d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -749,6 +749,17 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost val context = androidx.compose.ui.platform.LocalContext.current val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current val wincompKey = game?.takeIf { it.library == com.droiddeck.launcher.frontend.Library.ADDED || it.appId > 0 }?.profileKey + val frameGenProfileKey = game?.profileKey?.takeIf { it.isNotBlank() } + var gameFrameGenMode by remember(frameGenProfileKey) { + mutableStateOf(frameGenProfileKey?.let { + com.droiddeck.launcher.gpu.FrameGen.mode(context, it) + } ?: s.frameGen) + } + var gameFrameGenOverride by remember(frameGenProfileKey) { + mutableStateOf(frameGenProfileKey?.let { + com.droiddeck.launcher.gpu.FrameGen.hasGameOverride(context, it) + } ?: false) + } var wincompOpen by remember(wincompKey) { mutableStateOf(null) } val wincompPicks = remember(wincompKey, wincompOpen) { wincompKey?.let { com.droiddeck.launcher.session.WinComponents.picks(context, it) }.orEmpty() } val steamScope = game?.let { com.droiddeck.launcher.session.NoSteamLaunch.scope(it) } @@ -767,10 +778,42 @@ internal fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost } add { m -> Box(m) { - SettingCard(stringResource(R.string.frame_gen_title), s.frameGenLabel, "card:fg", Modifier.fillMaxSize()) { + SettingCard( + stringResource(R.string.frame_gen_title), + if (frameGenProfileKey != null) + com.droiddeck.launcher.gpu.FrameGen.label(context, gameFrameGenMode) + else s.frameGenLabel, + "card:fg", Modifier.fillMaxSize() + ) { host.open = if (host.open == "fg") null else "fg" } - FrameGenMenu(s, a, host) + FrameGenMenu( + host = host, + mode = if (frameGenProfileKey != null) gameFrameGenMode else s.frameGen, + lossless = s.lossless, + onPick = { mode -> + val key = frameGenProfileKey + if (key == null) { + a.onFrameGenPick(mode) + } else { + com.droiddeck.launcher.gpu.FrameGen.setForGame(context, key, mode) + gameFrameGenMode = mode + gameFrameGenOverride = true + } + }, + onImportLossless = a.onImportLossless, + gameProfileId = frameGenProfileKey, + hasGameOverride = gameFrameGenOverride, + onResetGame = { + val key = frameGenProfileKey + if (key != null) { + com.droiddeck.launcher.gpu.FrameGen.clearGame(context, key) + gameFrameGenMode = + com.droiddeck.launcher.gpu.FrameGen.mode(context) + gameFrameGenOverride = false + } + } + ) } } if (controller != null) add { m -> SettingCard(stringResource(R.string.setup_card_controls), stringResource(R.string.setup_card_controls_hint), "card:controls", m, controller.onMapping) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index e140ffa1ad..94f4ff1a3c 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -220,6 +220,9 @@ class DrawerActions( val hudOn: Boolean, val hudConfig: Map = emptyMap(), val frameGen: FrameGen.Mode, + val frameGenTargetGameId: String? = null, + val frameGenTargetGameName: String? = null, + val hasGameOverride: Boolean = false, val lossless: Lossless.State, val oscMode: String, val suspendPolicy: String, @@ -262,6 +265,7 @@ class DrawerActions( val onHudReset: () -> Unit = {}, val onHudExport: () -> Unit = {}, val onFrameGenPick: (FrameGen.Mode) -> Unit, + val onFrameGenReset: () -> Unit = {}, val fpsLimit: Int = 0, val onFpsLimit: (Int) -> Unit = {}, val onImportLossless: () -> Unit, @@ -569,10 +573,21 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont val fgOpen = host.open == "fg" val offLabel = stringResource(R.string.frame_gen_off) val fgLabel = FrameGen.label(LocalContext.current, a.frameGen) - SettingsRow(stringResource(R.string.frame_gen_title), null, highlighted = fgOpen) { + SettingsRow( + stringResource(R.string.frame_gen_title), + if (a.frameGenTargetGameId != null) + "${stringResource(R.string.frame_gen_scope_game)} · ${a.frameGenTargetGameName ?: "ID ${a.frameGenTargetGameId}"}" + else stringResource(R.string.frame_gen_scope_global), + highlighted = fgOpen + ) { Box { ValueChip(fgLabel, fgOpen, modifier = focus.track(page, "fg")) { host.open = if (fgOpen) null else "fg" } - FrameGenMenu(host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless) + FrameGenMenu( + host, a.frameGen, a.lossless, a.onFrameGenPick, a.onImportLossless, + gameProfileId = a.frameGenTargetGameId, + hasGameOverride = a.hasGameOverride, + onResetGame = a.onFrameGenReset, + ) } } if (a.direct) SliderRow( @@ -1352,6 +1367,12 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S if (!profile.fexPreset.inherited) { ProfileSummaryRow(stringResource(R.string.comp_game_fex), fexProfileLabel(profile.fexPreset)) } + if (!profile.frameGenInherited) { + ProfileSummaryRow( + stringResource(R.string.frame_gen_title), + FrameGen.label(LocalContext.current, profile.frameGen), + ) + } if (!profile.proton.inherited) { ProfileSummaryRow(stringResource(R.string.comp_proton), profileValueLabel(profile.proton)) } diff --git a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java index 995f512471..10735a1710 100644 --- a/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java +++ b/app/src/main/java/com/droiddeck/launcher/wayland/WaylandCompositor.java @@ -340,6 +340,7 @@ public final class WaylandCompositor { public static native int nativeFrameGenProblem(); public static native String nativeFrameGenCapsReason(); + public static native boolean nativeFrameGenActive(); public static native float[] nativeFrameGenStats(); public static native long nativeHudFrameTimes(float[] out); diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index ad939d9696..e6cb1ab87c 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -28,6 +28,8 @@ تعليق الآن إيقاف الجلسة توليد الإطارات + إعدادات هذه اللعبة + الإعدادات الافتراضية اختر وضع توليد الإطارات إيقاف DD-FG %1$d× diff --git a/app/src/main/res/values-b+es+419/strings.xml b/app/src/main/res/values-b+es+419/strings.xml index d3c6e048aa..6f98b6bff0 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -28,6 +28,8 @@ Suspender ahora Detener sesión Generación de fotogramas + Ajustes para este juego + Ajustes predeterminados Elige el modo de generación de fotogramas Desactivada DD-FG %1$d× diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 6d9aaa5d32..5aeb1e2e9a 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -28,6 +28,8 @@ Приспи сега Спри сесията Генериране на кадри + Настройки за тази игра + Настройки по подразбиране Изберете режима на генериране на кадри Изключено DD-FG %1$d× diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 302d2b5fd5..6011f2fe39 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -28,6 +28,8 @@ Pozastavit teď Ukončit relaci Generování snímků + Nastavení pro tuto hru + Výchozí nastavení Vyberte režim generování snímků Vypnuto DD-FG %1$d× diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 3c8fe48493..f443c3346e 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -28,6 +28,8 @@ Sæt på pause nu Afslut session Billedgenerering + Indstillinger for dette spil + Standardindstillinger Vælg metode til billedgenerering Fra DD-FG %1$d× diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index a81afbdbd5..d16437026e 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -28,6 +28,8 @@ Jetzt anhalten Sitzung beenden Frame-Generierung + Einstellungen für dieses Spiel + Standardeinstellungen Modus der Frame-Generierung auswählen Aus DD-FG %1$d× diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index c6be6d3824..e64a289085 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -28,6 +28,8 @@ Αναστολή τώρα Διακοπή συνεδρίας Δημιουργία καρέ + Ρυθμίσεις για αυτό το παιχνίδι + Προεπιλεγμένες ρυθμίσεις Επιλέξτε τη λειτουργία δημιουργίας καρέ Ανενεργό DD-FG %1$d× diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index f3632dce18..c9fbd09fa9 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -28,6 +28,8 @@ Suspender ahora Detener sesión Generación de fotogramas + Ajustes para este juego + Ajustes predeterminados Elige el modo de generación de fotogramas Desactivada DD-FG %1$d× diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 49ef50fa3a..27acadee4a 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -28,6 +28,8 @@ Keskeytä nyt Lopeta istunto Kehysten generointi + Tämän pelin asetukset + Oletusasetukset Valitse kehysten generoinnin tila Pois DD-FG %1$d× diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index dd2043ac1e..fd6bd7a654 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -28,6 +28,8 @@ Mettre en pause maintenant Terminer cette session Génération d\'images + Paramètres pour ce jeu + Paramètres par défaut Sélectionnez le mode de génération d\'images à utiliser Désactivé DD-FG %1$d× diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 5c39c28c16..1f48a5adef 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -28,6 +28,8 @@ अभी सस्पेंड करें सेशन बंद करें फ़्रेम जनरेशन + इस गेम की सेटिंग + डिफ़ॉल्ट सेटिंग फ़्रेम जनरेशन मोड चुनें बंद DD-FG %1$d× diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 383658e191..b855f4a1ca 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -28,6 +28,8 @@ Felfüggesztés most Munkamenet leállítása Képkocka-generálás + A játék beállításai + Alapértelmezett beállítások Válassza ki a képkocka-generálás módját Ki DD-FG %1$d× diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 7efa53767f..7920ebc122 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -28,6 +28,8 @@ Jeda sekarang Hentikan sesi Pembuatan frame + Pengaturan untuk game ini + Pengaturan bawaan Pilih mode pembuatan frame Nonaktif DD-FG %1$d× diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index bff0619db4..dfcf569d61 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -28,6 +28,8 @@ Sospendi ora Termina sessione Generazione di frame + Impostazioni per questo gioco + Impostazioni predefinite Seleziona la modalità di generazione di frame Disattivata DD-FG %1$d× diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 1c9b9d6f4e..3dee08d37a 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -28,6 +28,8 @@ 今すぐ一時停止 セッションを終了 フレーム生成 + このゲームの設定 + デフォルト設定 使用するフレーム生成モードを選択してください オフ DD-FG %1$d× diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index f75ed9bf91..b0b023b482 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -28,6 +28,8 @@ 지금 일시 중지 세션 종료 프레임 생성 + 이 게임의 설정 + 기본 설정 사용할 프레임 생성 모드를 선택하세요 끔 DD-FG %1$d× diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index 006abdf4bf..89a213972f 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -28,6 +28,8 @@ Gantung sekarang Hentikan sesi Penjanaan bingkai + Tetapan untuk permainan ini + Tetapan lalai Pilih mod penjanaan bingkai Mati DD-FG %1$d× diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index c305b9387a..7a67d2317b 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -28,6 +28,8 @@ Sett på pause nå Avslutt sesjon Bildegenerering + Innstillinger for dette spillet + Standardinnstillinger Velg modus for bildegenerering Av DD-FG %1$d× diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 625992011f..2aa326714f 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -28,6 +28,8 @@ Nu onderbreken Sessie stoppen Framegeneratie + Instellingen voor dit spel + Standaardinstellingen Kies de modus voor framegeneratie Uit DD-FG %1$d× diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index fa5dcd2c03..fbca1d88dd 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -28,6 +28,8 @@ Wstrzymaj teraz Zatrzymaj sesję Generowanie klatek + Ustawienia tej gry + Ustawienia domyślne Wybierz tryb generowania klatek Wył. DD-FG %1$d× diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 3c94b532eb..2d09f7127a 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -28,6 +28,8 @@ Suspender agora Terminar sessão Geração de fotogramas + Definições para este jogo + Definições predefinidas Selecione o modo de geração de fotogramas Desligado DD-FG %1$d× diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 14bed70758..768753c6e6 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -28,6 +28,8 @@ Suspender agora Encerrar sessão Geração de quadros + Configurações para este jogo + Configurações padrão Selecione o modo de geração de quadros Desativada DD-FG %1$d× diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 672122d817..fac1699e94 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -28,6 +28,8 @@ Suspendă acum Oprește sesiunea Generare de cadre + Setări pentru acest joc + Setări implicite Selectează modul de generare a cadrelor Dezactivat DD-FG %1$d× diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1449384134..cf3266525b 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -28,6 +28,8 @@ Приостановить сейчас Остановить сессию Генерация кадров + Настройки этой игры + Настройки по умолчанию Выберите режим генерации кадров Выкл. DD-FG %1$d× diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 7a5120525c..e64a59dc88 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -28,6 +28,8 @@ Pausa nu Stoppa sessionen Bildrutegenerering + Inställningar för det här spelet + Standardinställningar Välj läge för bildrutegenerering Av DD-FG %1$d× diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index 38b62c9fce..1a778803c1 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -28,6 +28,8 @@ หยุดชั่วคราวตอนนี้ หยุดเซสชัน การสร้างเฟรม + การตั้งค่าสำหรับเกมนี้ + การตั้งค่าเริ่มต้น เลือกโหมดการสร้างเฟรม ปิด DD-FG %1$d× diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index df596656d4..d4495911e0 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -28,6 +28,8 @@ Şimdi askıya al Oturumu durdur Kare oluşturma + Bu oyunun ayarları + Varsayılan ayarlar Kare oluşturma modunu seçin Kapalı DD-FG %1$d× diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 2ee9ab4e36..77c5b4067e 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -28,6 +28,8 @@ Призупинити зараз Завершити сеанс Генерація кадрів + Налаштування цієї гри + Типові налаштування Виберіть режим генерації кадрів Вимк. DD-FG %1$d× diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index a4414e038f..2ebccba807 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -28,6 +28,8 @@ Tạm dừng ngay Dừng phiên Tạo khung hình + Cài đặt cho trò chơi này + Cài đặt mặc định Chọn chế độ tạo khung hình Tắt DD-FG %1$d× diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 100352717d..358546b076 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -28,6 +28,8 @@ 立即暂停 停止会话 帧生成 + 此游戏的设置 + 默认设置 选择帧生成模式 关闭 DD-FG %1$d× diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 729bf26c23..8510ce17d0 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -28,6 +28,8 @@ 立即暫停 結束會話 幀生成 + 此遊戲的設定 + 預設設定 選擇幀生成模式 關閉 DD-FG %1$d× diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 15d43fc4f0..dc2ebfe803 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -28,6 +28,8 @@ 立即暫停 結束此工作階段 影格生成 + 此遊戲的設定 + 預設設定 請選擇你要使用的影格生成模式 關閉 DD-FG %1$d× diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 87271de25e..cc7c632ddb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -55,6 +55,8 @@ Suspend now Stop session Frame generation + Settings for this game + Default settings Select the frame generation mode Off DD-FG %1$d× diff --git a/app/src/test/java/com/droiddeck/launcher/gpu/FrameGenTest.kt b/app/src/test/java/com/droiddeck/launcher/gpu/FrameGenTest.kt index f4c3b79ea0..5afd7f83a9 100644 --- a/app/src/test/java/com/droiddeck/launcher/gpu/FrameGenTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/gpu/FrameGenTest.kt @@ -2,6 +2,8 @@ package com.droiddeck.launcher.gpu import android.content.Context import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -45,4 +47,22 @@ class FrameGenTest { .putString("engine", "winfg").putInt("multiplier", 2).commit() assertEquals(FrameGen.Mode(FrameGen.ENGINE_DDFG, 2), FrameGen.mode(context)) } + + @Test fun perGameOverrideIsIsolatedFromGlobalMode() { + val global = FrameGen.Mode(FrameGen.ENGINE_LSFG, target = 90) + val game = FrameGen.Mode(FrameGen.ENGINE_DDFG, 3) + + FrameGen.set(context, global) + FrameGen.setForGame(context, "12345", game) + + assertEquals(global, FrameGen.mode(context)) + assertEquals(game, FrameGen.mode(context, "12345")) + assertTrue(FrameGen.hasGameOverride(context, "12345")) + + FrameGen.clearGame(context, "12345") + + assertFalse(FrameGen.hasGameOverride(context, "12345")) + assertEquals(global, FrameGen.mode(context, "12345")) + } + } diff --git a/app/src/test/java/com/droiddeck/launcher/session/SelectedGameProfileTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SelectedGameProfileTest.kt index 7955fde23b..d02d76d3db 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SelectedGameProfileTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SelectedGameProfileTest.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.core.GameEnvironment import com.droiddeck.launcher.frontend.Library +import com.droiddeck.launcher.gpu.FrameGen import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -116,6 +117,17 @@ class SelectedGameProfileTest { assertEquals(ProfileValue("PERFORMANCE_TSO", true), resolve(environment = inherited)!!.fexPreset) } + @Test fun frameGenOverrideMakesProfileCustom() { + val profile = resolve( + frameGenMode = FrameGen.Mode.OFF, + frameGenInherited = false, + ) + + assertEquals(FrameGen.Mode.OFF, profile!!.frameGen) + assertFalse(profile.frameGenInherited) + assertTrue(profile.hasOverrides) + } + private fun resolve( selectedAppId: Long = 3180310, games: List = listOf(game), @@ -123,6 +135,8 @@ class SelectedGameProfileTest { gameChoice: ProtonDefault.GameChoice? = null, gameComponents: Map = emptyMap(), gameWindowsComponents: List = emptyList(), + frameGenMode: FrameGen.Mode = FrameGen.Mode.OFF, + frameGenInherited: Boolean = true, ) = SelectedGameProfile.resolve( selectedAppId = selectedAppId, games = games, @@ -134,6 +148,8 @@ class SelectedGameProfileTest { gameProtonId = "p1", gameComponents = gameComponents, gameWindowsComponents = gameWindowsComponents, + frameGenMode = frameGenMode, + frameGenInherited = frameGenInherited, ) private fun component(label: String) =