diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 02477724be..d84e73de52 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -268,7 +268,7 @@ static struct wl_event_source *g_fallback_timer; static int g_fallback_armed; volatile int g_fps_limit; -/* fps limit -1 (Performance mode without a limit): replaced buffers go back to the client at once instead of once per refresh. */ +/* fps limit -1 (phone output, not mirrored): replaced buffers go back to the client at once instead of once per refresh. */ volatile int g_release_unpaced; volatile int g_hide_shell; diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index a41457d92c..a8998197bf 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -461,7 +461,6 @@ class FrontEndActivity : ComponentActivity() { private var theme by mutableStateOf("graphite") private var appScale by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.DEFAULT_SCALE) private var hdrOn by mutableStateOf(false) - private var performanceMode by mutableStateOf(false) private var upscaler by mutableStateOf(0) private var upscaleSharpness by mutableStateOf(75) private var hdrReason by mutableStateOf(null) @@ -1886,7 +1885,7 @@ class FrontEndActivity : ComponentActivity() { ModeSettings( mode = mode, resolution = resolution, panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this), - hdr = hdrOn, hdrReason = hdrReason, performanceMode = performanceMode, + hdr = hdrOn, hdrReason = hdrReason, upscaler = upscaler, upscaleSharpness = upscaleSharpness, gpuDrivers = drivers.summary(), touchMode = touchMode, @@ -1935,7 +1934,6 @@ class FrontEndActivity : ComponentActivity() { onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); resolution = value }, onHdr = { on -> SessionPrefs.setHdr(this, mode, on); hdrOn = on }, onGpuDrivers = { openComponents(focusContent = true, tab = com.droiddeck.launcher.ui.GPU_TAB) }, - onPerformanceMode = { on -> SessionPrefs.setPerformanceMode(this, mode, on); performanceMode = on }, onUpscaler = { m -> SessionPrefs.setUpscaler(this, m); upscaler = m }, onUpscaleSharpness = { pct -> SessionPrefs.setUpscaleSharpness(this, pct); upscaleSharpness = pct }, onTouch = { t -> SessionPrefs.setTouchMode(this, t); touchMode = t }, @@ -2186,7 +2184,6 @@ class FrontEndActivity : ComponentActivity() { runSteamAtStartup = SessionPrefs.runSteamAtStartup(this) loadBootMovie() hdrOn = SessionPrefs.hdr(this, mode) - performanceMode = SessionPrefs.performanceMode(this, mode) upscaler = SessionPrefs.upscaler(this) upscaleSharpness = SessionPrefs.upscaleSharpness(this) hdrReason = com.droiddeck.launcher.wayland.HdrSupport.probe(this).reason diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 501024b968..6ee14aacfc 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -9,6 +9,7 @@ import android.content.Intent import android.os.Build import android.os.Bundle import android.os.Environment +import android.database.ContentObserver import android.os.Handler import android.os.Looper import android.os.SystemClock @@ -432,6 +433,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } } + // A higher refresh rate allowed in Android's settings does not change the display while this window + // still asks for a lower mode, so the mode is chosen again when the setting changes. + private val refreshSettingObserver = object : ContentObserver(Handler(Looper.getMainLooper())) { + override fun onChange(selfChange: Boolean) { + applyOutputPacing() + } + } + private fun followPanelRefresh(displayId: Int) { if (!CompositorHost.isStarted) return val output = glassesScreen?.display @@ -498,10 +507,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } com.droiddeck.launcher.gpu.SteamVrHealth.begin(this, SessionState.sessionId) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) - if (!SessionState.running) { - val prefMode = SessionPrefs.prefMode(intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM) - SessionState.performanceMode = SessionPrefs.performanceMode(this, prefMode) - } applyOutputPacing() if (!SessionState.running) SessionState.followScreen = followChoice() applyFollowOrientation(resources.configuration) @@ -1999,9 +2004,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { private fun mirrorRefreshLimit(): Int = GlassesRendering.mirrorRefreshLimit(glassesSettings, glasses, glassesScreen != null) - private fun outputFpsLimit(): Int = SessionPrefs.compositorFpsLimit( - mirrorRefreshLimit(), SessionState.performanceMode, - ) + private fun outputFpsLimit(): Int = SessionPrefs.compositorFpsLimit(mirrorRefreshLimit()) private fun applyOutputPacing() { Log.i(TAG, "perf: " + PerfMode.apply(this, outputFpsLimit(), mirrorRefreshLimit())) @@ -3210,6 +3213,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { started = true refreshActivityDisplayId() displayManager.registerDisplayListener(displayListener, Handler(Looper.getMainLooper())) + for (name in arrayOf("peak_refresh_rate", "min_refresh_rate")) { + contentResolver.registerContentObserver(android.provider.Settings.System.getUriFor(name), false, refreshSettingObserver) + } refreshSecondScreenDisplays() if (secondScreenMode != SecondScreenMode.NONE && secondScreenPresentation == null) showSecondScreen(secondScreenMode) startedScreens++ @@ -3224,6 +3230,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { started = false updateHandCamera() displayManager.unregisterDisplayListener(displayListener) + contentResolver.unregisterContentObserver(refreshSettingObserver) closeSecondScreen(reset = false) startedScreens = (startedScreens - 1).coerceAtLeast(0) updateGlassesScreen() diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index 92163226f8..592bf42cf9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -938,22 +938,15 @@ object SessionPrefs { prefs(context).edit().putBoolean("hdr.$mode", on).apply() } - /** - * Performance mode: buffers go back to the game as soon as they are replaced - * instead of once per refresh, and gamescope's WSI layer and winex11 reuse their per-present window checks. - */ - fun performanceMode(context: Context, mode: String): Boolean = prefs(context).getBoolean("performanceMode.$mode", false) - - fun setPerformanceMode(context: Context, mode: String, on: Boolean) { - prefs(context).edit().putBoolean("performanceMode.$mode", on).apply() - } - /** Compositor frame limit that releases buffers to the game unpaced. */ const val FPS_UNPACED = -1 - /** Mirroring still follows the glasses' refresh rate when Performance mode is on. */ - fun compositorFpsLimit(mirrorRefreshLimit: Int, performanceMode: Boolean): Int = - if (performanceMode && mirrorRefreshLimit <= 0) FPS_UNPACED else mirrorRefreshLimit + /** + * Buffers go back to the game as soon as they are replaced instead of once per refresh; + * Steam's Frame Limit in the Quick Access menu caps games. Mirroring still follows the glasses' refresh rate. + */ + fun compositorFpsLimit(mirrorRefreshLimit: Int): Int = + if (mirrorRefreshLimit <= 0) FPS_UNPACED else mirrorRefreshLimit val upscalerChoices = listOf( 0 to "Linear", 2 to "Nearest", 4 to "AMD FSR 1", 3 to "Snapdragon GSR", diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index be9795042a..445b2da05d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -507,16 +507,13 @@ class SessionService : Service() { guest.add("DXVK_HDR=1") Log.i(TAG, "hdr: gamescope --hdr-enabled, DXVK_HDR=1") } - // gamescope's WSI layer and winex11 reuse their per-present window checks for this long; 0 checks on every present. - val windowCheckMs = if (SessionState.performanceMode) 100 else 0 - guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=$windowCheckMs") - guest.add("WINE_OFFSCREEN_CHECK_MS=$windowCheckMs") - if (SessionState.performanceMode) { - // gamescope turns buffers around slower than an unpaced game draws; more images keep it drawing. - guest.add("GAMESCOPE_WSI_MIN_IMAGE_COUNT=8") - guest.add("GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT=1") - } - Log.i(TAG, "performance mode " + (if (SessionState.performanceMode) "on" else "off")) + // gamescope's WSI layer and winex11 reuse their per-present window checks for this long. + guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=100") + guest.add("WINE_OFFSCREEN_CHECK_MS=100") + // gamescope turns buffers around slower than an uncapped game draws; more images keep it drawing. + // The WSI layer goes back to its default count while Steam's Frame Limit holds the game. + guest.add("GAMESCOPE_WSI_MIN_IMAGE_COUNT=8") + guest.add("GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT=1") guest.add("BL_REFRESH=" + Math.round(SessionState.refreshHz)) guest.add("BL_LOG=" + sessionLog.path) guest.add("BL_DEBUG_DIR=" + sessionDir.path) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt index bb1ea39238..52544f2fc0 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt @@ -103,9 +103,6 @@ object SessionState { @Volatile var upscaleRatio: Float = 0f - @Volatile - var performanceMode = false - @Volatile var firstFrameSeen = false diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index 1e07f6c47f..9c24f551cb 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -60,7 +60,6 @@ class ModeSettings( val hdr: Boolean, val hdrReason: String?, val gpuDrivers: String? = null, - val performanceMode: Boolean = false, val upscaler: Int = 0, val upscaleSharpness: Int = 75, val touchMode: String, @@ -112,7 +111,6 @@ class ModeSettingsActions( val onResolution: (String) -> Unit, val onHdr: (Boolean) -> Unit, val onGpuDrivers: () -> Unit = {}, - val onPerformanceMode: (Boolean) -> Unit = {}, val onUpscaler: (Int) -> Unit = {}, val onUpscaleSharpness: (Int) -> Unit = {}, val onTouch: (String) -> Unit, @@ -244,10 +242,6 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras: format = { "$it%" }, onChange = a.onUpscaleSharpness, ) } - SettingsGroup(stringResource(R.string.display_frame_rate)) { - ToggleRow(host, "performance", stringResource(R.string.mode_performance), stringResource(R.string.mode_performance_hint), - s.performanceMode, onChange = a.onPerformanceMode) - } SettingsGroup(stringResource(R.string.mode_hdr)) { ToggleRow( host, "hdr", stringResource(R.string.mode_hdr10), diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 68dcfe1806..f78cf3014d 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -2025,7 +2025,6 @@ يُطبَّق فوريًا. مشترك بين Steam وسطح المكتب. تُطبَّق FSR و GSR و NIS عند تكبير صورة الجلسة. ويعمل خيار «زيادة الحدة فقط» أيضًا دون تكبير. حدّة المرشِّح - معدّل الإطارات %1$s يضبط أسلوب التكبير على %2$s. مطابقة الشاشة (%1$d×%2$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 413588da65..09e76582e9 100644 --- a/app/src/main/res/values-b+es+419/strings.xml +++ b/app/src/main/res/values-b+es+419/strings.xml @@ -1994,7 +1994,6 @@ Se aplica al instante. Compartido por Steam y Escritorio. FSR, GSR y NIS se aplican al ampliar la imagen de la sesión. Solo nitidez también funciona sin ampliar. Nitidez del filtro - Velocidad de fotogramas %1$s Cambia el escalado a %2$s. Igual a la pantalla (%1$d×%2$d) Seguir la pantalla (cambia de tamaño al plegar o desplegar) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 3429ff0ecf..314b01f305 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -1941,7 +1941,6 @@ Прилага се веднага. Общ за Steam и Desktop. FSR, GSR и NIS се прилагат при уголемяване на изображението на сесията. „Само изостряне“ работи и без уголемяване. Острота на филтъра - Честота на кадрите %1$s Задава мащабиране на %2$s. Напасване на екрана (%1$d×%2$d) Следване на екрана (преоразмерява при сгъване или разгъване) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 3c41609da3..e0278767d6 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -1983,7 +1983,6 @@ Použije se okamžitě. Sdíleno Steamem a Plochou. FSR, GSR a NIS se použijí při zvětšování obrazu relace. Jen zaostření funguje i bez zvětšení. Ostrost filtru - Snímková frekvence %1$s Nastaví škálování na %2$s. Podle obrazovky (%1$d×%2$d) Sledovat obrazovku (změní velikost při složení nebo rozložení) diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 166786e068..789cbc762d 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -1941,7 +1941,6 @@ Træder i kraft øjeblikkeligt. Deles af Steam og Desktop. FSR, GSR og NIS anvendes ved forstørrelse af sessionsbilledet. Kun skærpning virker også uden forstørrelse. Filterskarphed - Billedfrekvens %1$s Indstiller skalering til %2$s. Match skærm (%1$d×%2$d) Følg skærm (ændrer størrelse ved fold/udfold) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 76d7e59bc3..1ddc2655d3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1933,7 +1933,6 @@ Wirkt sofort. Gemeinsam für Steam und Desktop. FSR, GSR und NIS wirken beim Vergrößern des Sitzungsbilds. „Nur schärfen“ funktioniert auch ohne Vergrößerung. Filterschärfe - Bildrate %1$s Stellt die Skalierung auf %2$s. An Bildschirm anpassen (%1$d×%2$d) Bildschirm folgen (passt sich beim Auf- und Zuklappen an) diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index 266eeb6fd1..85e3befcd8 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -1941,7 +1941,6 @@ Εφαρμόζεται σε πραγματικό χρόνο. Κοινό για το Steam και την Επιφάνεια εργασίας. Τα FSR, GSR και NIS εφαρμόζονται κατά τη μεγέθυνση της εικόνας συνεδρίας. Το Μόνο όξυνση λειτουργεί και χωρίς μεγέθυνση. Οξύτητα φίλτρου - Καρέ ανά δευτερόλεπτο %1$s Ορίζει την κλιμάκωση σε %2$s. Αντιστοίχιση οθόνης (%1$d×%2$d) Ακολούθηση οθόνης (αλλάζει μέγεθος όταν διπλώνει ή ξεδιπλώνει) diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 196207fb1b..f6d49f6f92 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1964,7 +1964,6 @@ Se aplica al instante. Compartido por Steam y Escritorio. FSR, GSR y NIS se aplican al ampliar la imagen de la sesión. Solo nitidez también funciona sin ampliar. Nitidez del filtro - Velocidad de fotogramas %1$s Cambia el escalado a %2$s. Igual a la pantalla (%1$d×%2$d) Seguir la pantalla (cambia de tamaño al plegar o desplegar) diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index ffe2199025..79737e2e0f 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -1941,7 +1941,6 @@ Vaikuttaa välittömästi. Yhteinen Steamille ja Työpöydälle. FSR, GSR ja NIS vaikuttavat, kun istunnon kuvaa suurennetaan. Vain terävöinti toimii myös suurentamatta. Suodattimen terävyys - Kuvanopeus %1$s Asettaa skaalauksen tilaan %2$s. Sovita näyttöön (%1$d×%2$d) Seuraa näyttöä (koko muuttuu taitettuna tai avattuna) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 79f4a85cd9..97cb78aa59 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -1964,7 +1964,6 @@ S\'applique en direct. Partagé entre Steam et le bureau. FSR, GSR et NIS s\'appliquent lors de l\'agrandissement de l\'image de la session. « Netteté seule » fonctionne aussi sans agrandissement. Netteté du filtre - Fréquence d\'images %1$s Règle la mise à l\'échelle sur %2$s. Adapter à l\'écran (%1$d×%2$d) Suivre l\'écran (s\'adapte au pliage et au dépliage) diff --git a/app/src/main/res/values-hi/strings.xml b/app/src/main/res/values-hi/strings.xml index 858b138591..a1edf261e0 100644 --- a/app/src/main/res/values-hi/strings.xml +++ b/app/src/main/res/values-hi/strings.xml @@ -1941,7 +1941,6 @@ लाइव लागू होता है। Steam और डेस्कटॉप में साझा। FSR, GSR और NIS सेशन इमेज को बड़ा करने पर लागू होते हैं। सिर्फ़ शार्पन बिना बड़ा किए भी काम करता है। फ़िल्टर शार्पनेस - फ़्रेम रेट %1$s स्केलिंग को %2$s पर सेट करता है। स्क्रीन से मिलाएँ (%1$d×%2$d) Follow screen (खुलने या बंद होने पर आकार बदलता है) diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index b68fb6a5fd..747b7ed5c1 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -1941,7 +1941,6 @@ Élőben érvénybe lép. A Steam és az Asztal közösen használja. Az FSR, a GSR és a NIS a munkamenet képének felnagyításakor lép érvénybe. A Csak élesítés nagyítás nélkül is működik. Szűrőélesség - Képkockasebesség %1$s A méretezést erre állítja: %2$s. Képernyőhöz illesztés (%1$d×%2$d) Képernyő követése (átméreteződik össze- vagy kinyitáskor) diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index 8f2661e2ac..79291d8e70 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -1920,7 +1920,6 @@ Berlaku langsung. Digunakan bersama oleh Steam dan Desktop. FSR, GSR, dan NIS berlaku saat memperbesar gambar sesi. Hanya penajaman juga berfungsi tanpa pembesaran. Ketajaman filter - Frame rate %1$s Mengatur skala ke %2$s. Sesuaikan layar (%1$d×%2$d) Ikuti layar (ukuran berubah saat dilipat atau dibuka) diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 9c3628c8e6..bbe5351461 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -1954,7 +1954,6 @@ Si applica subito. Condiviso da Steam e Desktop. FSR, GSR e NIS si applicano quando l\'immagine della sessione viene ingrandita. Solo nitidezza funziona anche senza ingrandimento. Nitidezza del filtro - Frequenza fotogrammi %1$s Imposta il ridimensionamento su %2$s. Adatta allo schermo (%1$d×%2$d) Segui lo schermo (si ridimensiona quando lo pieghi o lo apri) diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index b75b63bc7f..19f6dbfaee 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -1922,7 +1922,6 @@ すぐに反映されます。Steamとデスクトップで共有されます。 FSR、GSR、NISはセッションの映像を拡大するときに機能します。「シャープのみ」は拡大しなくても機能します。 フィルターのシャープネス - フレームレート %1$s スケーリングを%2$sに設定します。 画面に合わせる(%1$d×%2$d) 画面に追従(開閉時にサイズを変更) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index cb0648a4ff..9163a3a7d7 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -1922,7 +1922,6 @@ 즉시 적용됩니다. Steam과 데스크톱에서 공유됩니다. FSR, GSR, NIS는 세션 이미지를 확대할 때 적용됩니다. 샤프닝 전용은 확대하지 않아도 작동합니다. 필터 선명도 - 프레임 속도 %1$s 스케일링을 %2$s(으)로 설정합니다. 화면에 맞춤(%1$d×%2$d) 화면 따라가기(접거나 펼치면 크기 변경) diff --git a/app/src/main/res/values-ms/strings.xml b/app/src/main/res/values-ms/strings.xml index 88b80ac4b7..eb41beb9b0 100644 --- a/app/src/main/res/values-ms/strings.xml +++ b/app/src/main/res/values-ms/strings.xml @@ -1920,7 +1920,6 @@ Berkuat kuasa secara langsung. Dikongsi oleh Steam dan Desktop. FSR, GSR dan NIS berkuat kuasa semasa membesarkan imej sesi. Ketajaman sahaja juga berfungsi tanpa pembesaran. Ketajaman penapis - Kadar bingkai %1$s Menetapkan penskalaan ke %2$s. Sepadan skrin (%1$d×%2$d) Ikut skrin (mengubah saiz apabila dilipat atau dibuka) diff --git a/app/src/main/res/values-nb/strings.xml b/app/src/main/res/values-nb/strings.xml index 89be0988d8..75653c225f 100644 --- a/app/src/main/res/values-nb/strings.xml +++ b/app/src/main/res/values-nb/strings.xml @@ -1941,7 +1941,6 @@ Gjelder live. Delt av Steam og Skrivebord. FSR, GSR og NIS gjelder ved forstørring av sesjonsbildet. Bare skarphet fungerer også uten forstørring. Filterskarphet - Bildefrekvens %1$s Setter skalering til %2$s. Tilpass skjerm (%1$d×%2$d) Følg skjermen (endrer størrelse ved sammenslåing eller utbretting) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 8d0891046a..53748c36ab 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -1941,7 +1941,6 @@ Wordt direct toegepast. Gedeeld door Steam en Desktop. FSR, GSR en NIS worden toegepast bij het vergroten van het sessiebeeld. Alleen verscherpen werkt ook zonder vergroting. Filterscherpte - Framerate %1$s Zet schaling op %2$s. Schermformaat (%1$d×%2$d) Scherm volgen (past formaat aan bij vouwen of uitvouwen) diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 3065d3644c..37619c513a 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -1983,7 +1983,6 @@ Działa od razu. Wspólny dla Steam i Pulpitu. FSR, GSR i NIS działają przy powiększaniu obrazu sesji. „Tylko wyostrzanie” działa też bez powiększania. Ostrość filtra - Liczba klatek %1$s Ustawia skalowanie na %2$s. Dopasuj do ekranu (%1$d×%2$d) Dopasuj do ekranu (zmienia rozmiar po złożeniu lub rozłożeniu) diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 4043426b48..177799c1a2 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -1954,7 +1954,6 @@ Aplica-se em tempo real. Partilhado pelo Steam e pelo Ambiente de trabalho. FSR, GSR e NIS aplicam-se ao ampliar a imagem da sessão. «Só nitidez» também funciona sem ampliação. Nitidez do filtro - Taxa de fotogramas %1$s Define a escala como %2$s. Igual ao ecrã (%1$d×%2$d) Seguir o ecrã (redimensiona ao dobrar ou desdobrar) diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 9f37ed2c7e..2bdda9aacd 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -1954,7 +1954,6 @@ Aplicado na hora. Compartilhado entre Steam e Área de trabalho. FSR, GSR e NIS são aplicados ao ampliar a imagem da sessão. Só nitidez também funciona sem ampliação. Nitidez do filtro - Taxa de quadros %1$s Define a escala como %2$s. Igual à tela (%1$d×%2$d) Seguir a tela (redimensiona ao dobrar ou desdobrar) diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index ddfca2fbcd..49a0503c69 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -1962,7 +1962,6 @@ Se aplică live. Partajat de Steam și Desktop. FSR, GSR și NIS se aplică la mărirea imaginii sesiunii. Doar claritate funcționează și fără mărire. Claritatea filtrului - Rata de cadre %1$s Setează scalarea la %2$s. Potrivire ecran (%1$d×%2$d) Urmărește ecranul (se redimensionează la împăturire sau desfacere) diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 040315b9aa..b4d440f2c9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -1985,7 +1985,6 @@ Применяется сразу. Общий для Steam и рабочего стола. FSR, GSR и NIS работают при увеличении изображения сессии. «Sharpen only» работает и без увеличения. Резкость фильтра - Частота кадров %1$s Устанавливает масштабирование: %2$s. По размеру экрана (%1$d×%2$d) По экрану (меняется при складывании и раскладывании) diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 8a379c5763..35c26e8f21 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -1941,7 +1941,6 @@ Tillämpas direkt. Delas av Steam och skrivbordet. FSR, GSR och NIS tillämpas när sessionens bild förstoras. Endast skärpa fungerar även utan förstoring. Filterskärpa - Bildfrekvens %1$s Ställer in skalning till %2$s. Matcha skärmen (%1$d×%2$d) Följ skärmen (ändrar storlek vid vikning) diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index d572994fb8..348740686b 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -1920,7 +1920,6 @@ มีผลทันที ใช้ร่วมกันระหว่าง Steam และเดสก์ท็อป FSR, GSR และ NIS จะมีผลเมื่อขยายภาพของเซสชัน เพิ่มความคมชัดเท่านั้นทำงานได้โดยไม่ต้องขยายภาพด้วย ความคมชัดของตัวกรอง - อัตราเฟรม %1$s ตั้งการปรับขนาดเป็น %2$s พอดีหน้าจอ (%1$d×%2$d) ตามหน้าจอ (ปรับขนาดเมื่อพับหรือกาง) diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 48a1113594..78cdc1f700 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -1935,7 +1935,6 @@ Anında uygulanır. Steam ve Masaüstü tarafından paylaşılır. FSR, GSR ve NIS, oturum görüntüsü büyütülürken uygulanır. Yalnızca keskinleştirme büyütme olmadan da çalışır. Filtre keskinliği - Kare hızı %1$s Ölçeklemeyi %2$s olarak ayarlar. Ekrana Uydur (%1$d×%2$d) Ekranı takip et (katlanıp açıldığında yeniden boyutlanır) diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index fdc4aca60d..050fd0fdcf 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -1983,7 +1983,6 @@ Застосовується відразу. Спільний для Steam і Робочого столу. FSR, GSR і NIS застосовуються під час збільшення зображення сеансу. «Лише різкість» працює і без збільшення. Різкість фільтра - Частота кадрів %1$s Встановлює масштабування на %2$s. Під екран (%1$d×%2$d) Слідувати за екраном (змінює розмір при згортанні чи розгортанні) diff --git a/app/src/main/res/values-vi/strings.xml b/app/src/main/res/values-vi/strings.xml index cf89b0ba75..9c75292d7f 100644 --- a/app/src/main/res/values-vi/strings.xml +++ b/app/src/main/res/values-vi/strings.xml @@ -1920,7 +1920,6 @@ Áp dụng ngay. Dùng chung cho Steam và Desktop. FSR, GSR và NIS áp dụng khi phóng to hình ảnh phiên. Chỉ làm nét cũng hoạt động mà không cần phóng to. Độ sắc nét bộ lọc - Tốc độ khung hình %1$s Đặt chia tỷ lệ thành %2$s. Khớp màn hình (%1$d×%2$d) Theo màn hình (đổi kích thước khi gập hoặc mở) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index d946abc578..ade2de5de3 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -2000,7 +2000,6 @@ 即时生效。由 Steam 和桌面共享。 FSR、GSR 和 NIS 在放大会话画面时生效。“仅锐化”在不放大时也可用。 滤镜锐度 - 帧率 %1$s 将缩放设为 %2$s。 匹配屏幕(%1$d×%2$d) 跟随屏幕(折叠或展开时调整大小) diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index cfd0eea3c2..94ed816a9f 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -1923,7 +1923,6 @@ 即時生效。Steam 和桌面共用。 FSR、GSR 和 NIS 會在放大會話畫面時套用。「只銳化」不放大也能使用。 濾鏡銳利度 - 幀率 %1$s 將縮放設為 %2$s。 配合螢幕(%1$d×%2$d) 跟隨螢幕(摺疊或展開時調整大小) diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d5e9d93f74..0c3257ead8 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -1923,7 +1923,6 @@ 立即生效。Steam 和桌面共用。 FSR、GSR 和 NIS 會在放大工作階段畫面時套用。「僅銳化」不放大也能使用。 濾鏡銳利度 - 影格率 %1$s 將縮放設為 %2$s。 符合螢幕(%1$d×%2$d) 跟隨螢幕(摺疊或展開時調整大小) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 661b321f64..fc6649cc86 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -258,8 +258,6 @@ Screen ratio Set by the custom resolution. Auto uses at least 16:9. - Performance mode - Lets games run without waiting for the screen and reduces repeated window checks in gamescope and Wine. Can use more power and run warmer. Use Steam\'s Quick Access menu to limit Steam games. Applies next session. HDR HDR10 output Not available: %1$s. @@ -2054,7 +2052,6 @@ Applies live. Shared by Steam and Desktop. FSR, GSR and NIS apply when enlarging the session image. Sharpen only also works without enlargement. Filter sharpness - Frame rate %1$s Sets scaling to %2$s. Match screen (%1$d×%2$d) Follow screen (resizes when folded or unfolded) diff --git a/app/src/test/java/com/droiddeck/launcher/glasses/GlassesMirrorPacingTest.kt b/app/src/test/java/com/droiddeck/launcher/glasses/GlassesMirrorPacingTest.kt index 4b97723d39..a8dff5a443 100644 --- a/app/src/test/java/com/droiddeck/launcher/glasses/GlassesMirrorPacingTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/glasses/GlassesMirrorPacingTest.kt @@ -1,12 +1,13 @@ package com.droiddeck.launcher.glasses import android.content.Context +import android.database.ContentObserver +import android.provider.Settings import android.hardware.display.DisplayManager import android.view.Display import androidx.compose.runtime.MutableState import com.droiddeck.launcher.SessionActivity import com.droiddeck.launcher.session.SessionPrefs -import com.droiddeck.launcher.session.SessionState import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before @@ -38,12 +39,10 @@ class GlassesMirrorPacingTest { val panel = Shadow.extract(activity.display) panel.supported = arrayOf(mode(1, 60f), mode(2, 90f), mode(3, 120f)) panel.current = panel.supported.last() - SessionState.performanceMode = false activity.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit() } @After fun cleanup() { - SessionState.performanceMode = false activity.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit() } @@ -53,7 +52,7 @@ class GlassesMirrorPacingTest { apply(connected, settings.copy(refreshHz = 90)) expect(2, 90f, 90) apply(GlassesState(), settings) - expect(3, 120f, 0) + expect(3, 120f, SessionPrefs.FPS_UNPACED) } @Test fun retiredSavedLimitsDoNotCapThePhoneOrMirroredOutput() { @@ -64,21 +63,22 @@ class GlassesMirrorPacingTest { apply(connected.copy(hz = 120f), settings) expect(1, 60f, 60) apply(GlassesState(), settings) - expect(3, 120f, 0) - } - - @Test fun performanceModeResumesUnpacedOutputAfterMirrorDisconnects() { - SessionState.performanceMode = true - apply(connected, settings) - expect(1, 60f, 60) - apply(GlassesState(), settings) expect(3, 120f, SessionPrefs.FPS_UNPACED) } @Test fun pacingFollowsThePanelWhenTheSystemKeepsALowerRateThanRequested() { Shadow.extract(activity.display).current = mode(2, 90f) apply(GlassesState(), settings) - expect(3, 90f, 0) + expect(3, 90f, SessionPrefs.FPS_UNPACED) + } + + @Test fun aHigherRefreshSettingChoosesTheFasterModeAgain() { + Settings.System.putFloat(activity.contentResolver, "peak_refresh_rate", 60f) + apply(GlassesState(), settings) + assertEquals(1, activity.window.attributes.preferredDisplayModeId) + Settings.System.putFloat(activity.contentResolver, "peak_refresh_rate", 120f) + ReflectionHelpers.getField(activity, "refreshSettingObserver").onChange(false) + assertEquals(3, activity.window.attributes.preferredDisplayModeId) } private fun apply(state: GlassesState, config: GlassesSettings) { diff --git a/app/src/test/java/com/droiddeck/launcher/session/OutputPacingTest.kt b/app/src/test/java/com/droiddeck/launcher/session/OutputPacingTest.kt new file mode 100644 index 0000000000..bd7dc380f5 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/OutputPacingTest.kt @@ -0,0 +1,14 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Test + +class OutputPacingTest { + @Test fun phoneOutputIsUnpaced() { + assertEquals(SessionPrefs.FPS_UNPACED, SessionPrefs.compositorFpsLimit(0)) + } + + @Test fun mirroringKeepsTheGlassesRate() { + assertEquals(60, SessionPrefs.compositorFpsLimit(60)) + } +} diff --git a/app/src/test/java/com/droiddeck/launcher/session/PerformanceModeTest.kt b/app/src/test/java/com/droiddeck/launcher/session/PerformanceModeTest.kt deleted file mode 100644 index 9805a66dec..0000000000 --- a/app/src/test/java/com/droiddeck/launcher/session/PerformanceModeTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.droiddeck.launcher.session - -import android.content.Context -import org.junit.Assert.* -import org.junit.Before -import org.junit.Test -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 PerformanceModeTest { - private val app get() = RuntimeEnvironment.getApplication() - private val session get() = app.getSharedPreferences("session", Context.MODE_PRIVATE) - - @Before fun clear() { session.edit().clear().commit() } - - @Test fun offByDefaultAndPerMode() { - assertFalse(SessionPrefs.performanceMode(app, SessionService.MODE_STEAM)) - SessionPrefs.setPerformanceMode(app, SessionService.MODE_STEAM, true) - assertTrue(SessionPrefs.performanceMode(app, SessionService.MODE_STEAM)) - assertFalse(SessionPrefs.performanceMode(app, SessionService.MODE_DESKTOP)) - } - - @Test fun offKeepsDisplayAndMirrorPacing() { - assertEquals(0, SessionPrefs.compositorFpsLimit(0, false)) - assertEquals(60, SessionPrefs.compositorFpsLimit(60, false)) - } - - @Test fun onIsUnpacedUnlessMirroring() { - assertEquals(SessionPrefs.FPS_UNPACED, SessionPrefs.compositorFpsLimit(0, true)) - assertEquals(60, SessionPrefs.compositorFpsLimit(60, true)) - } -} diff --git a/tools/gamescope/PATCHES.md b/tools/gamescope/PATCHES.md index 5ff8197a2d..a72ab6be13 100644 --- a/tools/gamescope/PATCHES.md +++ b/tools/gamescope/PATCHES.md @@ -96,8 +96,7 @@ running AIO Graphics Test uncapped, Xwayland used 24-32% of a core and the game' present thread sat about half idle. The patch can keep the result for `DROIDDECK_WSI_BYPASS_CHECK_MS` milliseconds. Unset -or 0 keeps the per-present check; the app sets 100 only in Performance mode and 0 -otherwise. With 100, a window resize or a flip/obscure change is seen up to 100 ms +or 0 keeps the per-present check; the app sets 100. With 100, a window resize or a flip/obscure change is seen up to 100 ms later than before; surface creation and capability queries still check every time. ## 0118 Wayland: preserve signed plane positions @@ -121,3 +120,39 @@ The old component lost the image in Fill and magnification. The tested executabl matches the pinned p14 archive and the locally assembled APK. Hardware checks used native Gamescope properties; the physical Back+LB shortcut was not independently confirmed. The original APK and runtime were restored after validation. + +## 0119 WSI: default image count while the frame limiter runs + +The app sets `GAMESCOPE_WSI_MIN_IMAGE_COUNT=8` so an uncapped game keeps drawing while +gamescope turns its buffers around. With Steam's Frame Limit on, gamescope forces FIFO, +and the layer always hands the driver MAILBOX, so a game with eight images could queue +up to seven frames inside gamescope before it blocked: each one adds a frame of input +latency at the limited rate. + +While the limiter forces FIFO, the layer now reports and enforces its default minimum +of 3 images instead of the raised count; with the limiter off it uses the raised count +as before. DXVK and VKD3D-Proton already recreate their swapchain when the limiter +changes (the layer returns `VK_ERROR_OUT_OF_DATE_KHR`), so their image count follows +the Quick Access menu. Other apps keep their swapchain on a limiter change; they now +get `VK_SUBOPTIMAL_KHR` while their image count no longer matches, unless the layer +marks them as not taking it (`NoSuboptimal`). + +## 0120 Wayland: nested refresh follows the host + +`-r` fixes the refresh gamescope paces at, and the frame limiter and Steam's Frame Limit +slider use the same value. The app passes the panel refresh at session start, so a +panel switched to another mode during the session (for example in the device's own +quick settings) left gamescope pacing at the old rate until the next session; only the +reported output refresh changed. + +With `GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST=1`, a refresh the host compositor reports +through presentation feedback replaces the `-r` value, so pacing and the limiter switch +with the panel. `-r` still sets the starting rate, which avoids gamescope assuming +60 Hz until the first frame is shown. When the refresh changes, gamescope also sends +its `gamescope_control` display information to Steam again; Steam otherwise reads it +only when it binds. + +A host mode switch can report a passing rate for a few frames (72 Hz between 144 and +120 Hz on the AYANEO Pocket FIT), so with following on a new rate is taken once it has +been reported for 300 ms. Without the variable the reported rate is taken at once, as +upstream does. diff --git a/tools/gamescope/patches/0119-wsi-default-images-under-limiter.patch b/tools/gamescope/patches/0119-wsi-default-images-under-limiter.patch new file mode 100644 index 0000000000..78f2837ca6 --- /dev/null +++ b/tools/gamescope/patches/0119-wsi-default-images-under-limiter.patch @@ -0,0 +1,59 @@ +diff --git a/layer/VkLayer_FROG_gamescope_wsi.cpp b/layer/VkLayer_FROG_gamescope_wsi.cpp +index ea4ba84..46d086c 100644 +--- a/layer/VkLayer_FROG_gamescope_wsi.cpp ++++ b/layer/VkLayer_FROG_gamescope_wsi.cpp +@@ -201,6 +201,13 @@ namespace GamescopeWSILayer { + return s_minImageCount; + } + ++ // The raised count keeps an uncapped game drawing while gamescope turns its buffers around. ++ // Under the frame limiter's FIFO the extra images only queue frames ahead of the screen, ++ // so a limited swapchain gets the default count. ++ static uint32_t getMinImageCount(bool forcingFifo) { ++ return forcingFifo ? std::min(getMinImageCount(), 3u) : getMinImageCount(); ++ } ++ + static bool getEnsureMinImageCount() { + static bool s_ensureMinImageCount = []() -> bool { + if (auto ensure = parseEnv("GAMESCOPE_WSI_ENSURE_MIN_IMAGE_COUNT")) { +@@ -984,7 +991,7 @@ namespace GamescopeWSILayer { + + pSurfaceCapabilities->currentExtent = rect->extent; + } +- pSurfaceCapabilities->minImageCount = getMinImageCount(); ++ pSurfaceCapabilities->minImageCount = getMinImageCount(gamescopeIsForcingFifo(gamescopeSurface->waylandObjects)); + + return VK_SUCCESS; + } +@@ -1027,7 +1034,7 @@ namespace GamescopeWSILayer { + + pSurfaceCapabilities->surfaceCapabilities.currentExtent = rect->extent; + } +- pSurfaceCapabilities->surfaceCapabilities.minImageCount = getMinImageCount(); ++ pSurfaceCapabilities->surfaceCapabilities.minImageCount = getMinImageCount(gamescopeIsForcingFifo(gamescopeSurface->waylandObjects)); + + return VK_SUCCESS; + } +@@ -1305,7 +1312,7 @@ namespace GamescopeWSILayer { + + uint32_t minImageCount = swapchainInfo.minImageCount; + if (getEnsureMinImageCount()) +- minImageCount = std::max(getMinImageCount(), minImageCount); ++ minImageCount = std::max(getMinImageCount(gamescopeIsForcingFifo(gamescopeSurface->waylandObjects)), minImageCount); + swapchainInfo.minImageCount = minImageCount; + + fprintf(stderr, "[Gamescope WSI] Creating swapchain for xid: 0x%0x - oldSwapchain: %p - provided minImageCount: %u - minImageCount: %u - format: %s - colorspace: %s - flip: %s\n", +@@ -1627,6 +1634,13 @@ namespace GamescopeWSILayer { + continue; + } + ++ // Other apps keep their swapchain when the limiter changes; ask them to recreate it so ++ // the image count follows the limiter as well. ++ if (!frameLimiterAware && gamescopeSwapchain->forceFifo != forceFifo && ++ getMinImageCount(true) != getMinImageCount(false) && ++ !(gamescopeSurface->flags & GamescopeLayerClient::Flag::NoSuboptimal)) ++ UpdateSwapchainResult(VK_SUBOPTIMAL_KHR); ++ + const bool canBypass = gamescopeSurface->canBypassXWaylandAtPresent(gamescopeSwapchain->isHdrColorspace); + if (canBypass != gamescopeSwapchain->isBypassingXWayland) { + if (canBypass) { diff --git a/tools/gamescope/patches/0120-nested-refresh-follows-host.patch b/tools/gamescope/patches/0120-nested-refresh-follows-host.patch new file mode 100644 index 0000000000..5505ff3f6b --- /dev/null +++ b/tools/gamescope/patches/0120-nested-refresh-follows-host.patch @@ -0,0 +1,95 @@ +diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp +index 40164ba..cc04fa7 100644 +--- a/src/Backends/WaylandBackend.cpp ++++ b/src/Backends/WaylandBackend.cpp +@@ -1698,6 +1698,49 @@ namespace gamescope + } + } + ++ // -r sets the refresh gamescope starts with. With GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST=1 a refresh ++ // the host compositor reports later replaces it, so pacing and the frame limiter follow a panel ++ // switched to another mode during the session. ++ static bool NestedRefreshFollowsHost() ++ { ++ static const bool s_bFollow = [] ++ { ++ const char *pszFollow = getenv( "GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST" ); ++ return pszFollow && atoi( pszFollow ) != 0; ++ }(); ++ return s_bFollow; ++ } ++ ++ // A mode switch on the host can report a passing rate for a few frames (72 Hz between 144 and ++ // 120 on an AYANEO Pocket FIT); a new rate is taken once it has been reported for 300 ms. ++ static bool HostRefreshChanged( int32_t nRefreshmHz, uint64_t ulPresentedNs ) ++ { ++ static int32_t s_nPendingmHz = 0; ++ static uint64_t s_ulPendingSinceNs = 0; ++ if ( !nRefreshmHz || nRefreshmHz == g_nOutputRefresh ) ++ { ++ s_nPendingmHz = 0; ++ return false; ++ } ++ if ( !NestedRefreshFollowsHost() ) ++ return true; ++ if ( nRefreshmHz != s_nPendingmHz ) ++ { ++ s_nPendingmHz = nRefreshmHz; ++ s_ulPendingSinceNs = ulPresentedNs; ++ return false; ++ } ++ return ulPresentedNs - s_ulPendingSinceNs >= 300'000'000ul; ++ } ++ ++ static void FollowHostRefresh( int32_t nRefreshmHz ) ++ { ++ if ( !NestedRefreshFollowsHost() || !g_nNestedRefresh || g_nNestedRefresh == nRefreshmHz ) ++ return; ++ xdg_log.infof( "Nested refresh follows the host: %.3fhz", ConvertmHzToHz( (float) nRefreshmHz ) ); ++ g_nNestedRefresh = nRefreshmHz; ++ } ++ + void CWaylandPlane::UpdateVRRRefreshRate() + { + if ( m_pParent ) +@@ -1724,6 +1767,7 @@ namespace gamescope + // TODO(strategy): We should pick the largest refresh rate. + xdg_log.infof( "Changed refresh to: %.3fhz", ConvertmHzToHz( (float) nLargestRefreshRateMhz ) ); + g_nOutputRefresh = nLargestRefreshRateMhz; ++ FollowHostRefresh( nLargestRefreshRateMhz ); + } + } + +@@ -1794,10 +1838,11 @@ namespace gamescope + if ( uRefreshCycle ) + { + int32_t nRefresh = RefreshCycleTomHz( uRefreshCycle ); +- if ( nRefresh && nRefresh != g_nOutputRefresh ) ++ if ( HostRefreshChanged( nRefresh, ulTime ) ) + { + xdg_log.infof( "Changed refresh to: %.3fhz", ConvertmHzToHz( (float) nRefresh ) ); + g_nOutputRefresh = nRefresh; ++ FollowHostRefresh( nRefresh ); + } + + m_pConnector->SetHostCompositorIsCurrentlyVRR( false ); +diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp +index 6c9299d..5fb9086 100644 +--- a/src/steamcompmgr.cpp ++++ b/src/steamcompmgr.cpp +@@ -9254,6 +9254,15 @@ void update_vrr_atoms(xwayland_ctx_t *root_ctx, bool force, bool* needs_flush = + g_nCurrentRefreshRate_CachedValue = g_nOutputRefresh; + if (needs_flush) + *needs_flush = true; ++ ++ // Steam reads the display's refresh rates from gamescope_control when it binds; send them again. ++ if ( !force ) ++ { ++ wlserver_lock(); ++ for ( const auto &control : wlserver.gamescope_controls ) ++ wlserver_send_gamescope_control( control ); ++ wlserver_unlock(); ++ } + } + + // Don't update this in-sync with DRM vrr usage. diff --git a/tools/gamescope/release.env b/tools/gamescope/release.env index 9bb47de0b3..611dd0c860 100644 --- a/tools/gamescope/release.env +++ b/tools/gamescope/release.env @@ -1,3 +1,3 @@ GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components -GAMESCOPE_TAG=gamescope-3.16.29-p14 -GAMESCOPE_SHA256=f0f2f33767c883bcfe66f28c303fddc1564f91a915fb7cedd31eb823570b254c +GAMESCOPE_TAG=gamescope-3.16.29-p15 +GAMESCOPE_SHA256=ee592bc7d000db86b12adaecb1aee5d25f8d6565c3584e55975ef1078d7a8e52 diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 0f99643ee3..ada9cba2ec 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -238,6 +238,8 @@ if [ -z "${BL_INSIDE:-}" ]; then fi if [ "${BL_REFRESH:-0}" -gt 0 ]; then args+=(-r "$BL_REFRESH") + # -r is the starting rate; gamescope follows the panel when it switches modes later. + export GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST=1 fi [ "$mode" = steam ] && [ "${BL_STEAM_UI:-}" != desktop ] && args+=(-e) if [ "$mode" = steam ] && [ "${BL_XWAYLAND_COUNT:-2}" -gt 1 ]; then diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 126afe0505..1d8e3992f8 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -241,6 +241,74 @@ TOUR_JS = r""" return "off"; })() """ +# Steam keeps the Quick Access Frame Limit as the client setting gamescope_app_target_framerate +# (CMsgClientSettings field 21002) and offers the values gamescope's display state lists in +# active_display_info.supported_frame_rates. When the panel's refresh rate changes, a remembered +# limit that is not one of the new values leaves the slider on its first value while the game runs +# at the old limit. The limit is kept when it is still offered and moved to the highest value +# otherwise. Choices are read once they have been unchanged for a moment, since a mode switch can +# report a passing rate first. +FRAME_LIMIT_JS = r""" +(() => { + if (window.__droiddeckFrameLimit) return "present"; + const settings = window.settingsStore; + let service = null; + try { + // Steam's webpack does not expose its module cache; the gamescope service client is found by + // the calls its module makes and loaded by id. + let require; + window.webpackChunksteamui.push([[Symbol("droiddeck-frame-limit")], {}, r => { require = r; }]); + for (const id of Object.keys(require.m || {})) { + const source = String(require.m[id]); + if (!source.includes("SetBlurParams") || !source.includes("RegisterForNotifyStateChanged")) continue; + let exports; + try { exports = require(id); } catch (e) { continue; } + if (!exports || typeof exports !== "object") continue; + service = Object.values(exports).find(value => value && typeof value.GetState === "function" && + typeof value.RegisterForNotifyStateChanged === "function" && typeof value.SetBlurParams === "function"); + if (service) break; + } + } catch (e) { + service = null; + } + if (!service || !settings?.clientSettings || typeof SteamClient.Settings?.SetSetting !== "function") return "unavailable"; + const self = { choices: null, timer: null }; + const write = value => { + const bytes = []; + for (let n of [21002 * 8, value]) { + while (n > 127) { bytes.push((n & 127) | 128); n = Math.floor(n / 128); } + bytes.push(n); + } + SteamClient.Settings.SetSetting(btoa(String.fromCharCode(...bytes))); + }; + self.check = async () => { + let rates; + try { + const reply = await service.GetState({}); + if (!reply.BSuccess()) return; + rates = reply.Body().toObject().state?.active_display_info?.supported_frame_rates; + } catch (e) { + return; + } + if (!Array.isArray(rates) || rates.length === 0) return; + const choices = rates.join(","); + if (choices === self.choices) return; + self.choices = choices; + const current = settings.clientSettings; + if (!current.gamescope_enable_app_target_framerate || rates.includes(current.gamescope_app_target_framerate)) return; + write(Math.max(...rates)); + }; + self.schedule = () => { + clearTimeout(self.timer); + self.timer = setTimeout(self.check, 1500); + }; + self.subscription = service.RegisterForNotifyStateChanged(self.schedule); + self.interval = setInterval(self.schedule, 5000); + self.schedule(); + window.__droiddeckFrameLimit = self; + return "installed"; +})() +""" FILE_BINDING = "droiddeckOpenFileDialog" FILE_JS = r""" (() => { @@ -680,6 +748,8 @@ class Helper: self.chooser = None self.controls_state = None self.controls_installed = False + self.frame_limit_state = None + self.frame_limit_retry = 0 def sync_controls(self): try: @@ -702,6 +772,19 @@ class Helper: except (OSError, ValueError, TypeError): pass + def sync_frame_limit(self): + # Steam can still be loading its settings and gamescope state when the helper attaches. + if self.frame_limit_state in ("installed", "present") or time.monotonic() < self.frame_limit_retry: + return + try: + state = self.page.evaluate(FRAME_LIMIT_JS) + except RuntimeError as e: + state = "failed (%s)" % e + if state != self.frame_limit_state: + say("frame limit sync: %s" % state) + self.frame_limit_state = state + self.frame_limit_retry = time.monotonic() + 10 + def open_chooser(self, payload): try: request = json.loads(payload) @@ -801,6 +884,8 @@ class Helper: self.page = page self.controls_state = None self.controls_installed = False + self.frame_limit_state = None + self.frame_limit_retry = 0 self.sync_controls() return True @@ -956,6 +1041,7 @@ class Helper: self.ensure_tools() while True: self.sync_controls() + self.sync_frame_limit() sources = [self.page.ws] + ([watcher] if watcher.fileno() >= 0 else []) if self.chooser is not None: sources.append(self.chooser[1].stdout) diff --git a/tools/tests/test_device_controls.py b/tools/tests/test_device_controls.py index 091d29a5a5..736d62acba 100644 --- a/tools/tests/test_device_controls.py +++ b/tools/tests/test_device_controls.py @@ -30,6 +30,7 @@ class DeviceControlsTest(unittest.TestCase): page.evaluate.side_effect = evaluate page.drain.side_effect = drain helper.reconcile = mock.Mock() + helper.sync_frame_limit = mock.Mock() helper.ensure_tools = mock.Mock(side_effect=[None, StopIteration]) helper.open_chooser = mock.Mock() watcher = mock.Mock() diff --git a/tools/tests/test_frame_limit_sync.py b/tools/tests/test_frame_limit_sync.py new file mode 100644 index 0000000000..ca89c203aa --- /dev/null +++ b/tools/tests/test_frame_limit_sync.py @@ -0,0 +1,118 @@ +"""The Quick Access Frame Limit follows the panel when its refresh rate changes.""" +from pathlib import Path +import runpy +import subprocess +import tempfile +import unittest +from unittest import mock + +BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" +LIVE = runpy.run_path(str(BIN / "droiddeck-steam-compat")) + +HARNESS = r""" +const assert = require('assert'); +globalThis.window = globalThis; +globalThis.btoa = text => Buffer.from(text, 'binary').toString('base64'); +let timers = new Map(), nextTimer = 0; +globalThis.setTimeout = (callback, ms) => { timers.set(++nextTimer, callback); return nextTimer; }; +globalThis.clearTimeout = id => timers.delete(id); +globalThis.setInterval = () => 0; +const fire = async () => { + const pending = [...timers.values()]; timers = new Map(); + for (const callback of pending) await callback(); +}; +let rates = [36, 48, 72, 144]; +const notify = []; +const service = { + GetState: async () => ({ BSuccess: () => true, + Body: () => ({ toObject: () => ({ state: { active_display_info: { supported_frame_rates: rates } } }) }) }), + RegisterForNotifyStateChanged(callback) { notify.push(callback); return {}; }, + SetBlurParams() {}, +}; +const writes = []; +globalThis.settingsStore = { clientSettings: { + gamescope_enable_app_target_framerate: true, gamescope_app_target_framerate: 120, gamescope_disable_framelimit: false } }; +const varints = bytes => { const out = []; let value = 0, shift = 0; + for (const b of bytes) { value += (b & 127) * 2 ** shift; shift += 7; if (b < 128) { out.push(value); value = 0; shift = 0; } } + return out; }; +globalThis.SteamClient = { Settings: { SetSetting(encoded) { + const [key, value] = varints([...Buffer.from(encoded, 'base64')]); + assert.strictEqual(key, 21002 * 8); + writes.push(value); + settingsStore.clientSettings.gamescope_app_target_framerate = value; +} } }; +const modules = { + 1: { source: () => 'RegisterForNotifyStateChanged only', exports: { other: { GetState() {} } } }, + 2: { source: () => 'n.MX.SetBlurParams(); n.MX.RegisterForNotifyStateChanged()', exports: { hooks: () => {} } }, + 3: { source: () => 'SetBlurParams RegisterForNotifyStateChanged GetState', exports: { MX: service } }, +}; +const webpack = modules => { const require = id => modules[id].exports; + require.m = Object.fromEntries(Object.entries(modules).map(([id, m]) => [id, { toString: m.source }])); + return require; }; +globalThis.webpackChunksteamui = { push([, , callback]) { callback(webpack(modules)); } }; +const script = require('fs').readFileSync(process.argv[2], 'utf8'); +const change = async next => { rates = next; notify.forEach(callback => callback()); }; +(async () => { + assert.strictEqual(eval(script), 'installed'); + assert.strictEqual(eval(script), 'present'); + await fire(); + assert.deepStrictEqual(writes, [144], 'a remembered limit the panel does not offer moves to the highest value'); + await fire(); + assert.deepStrictEqual(writes, [144], 'unchanged choices are not written again'); + settingsStore.clientSettings.gamescope_app_target_framerate = 72; + await change([24, 30, 40, 60, 120]); + await fire(); + assert.deepStrictEqual(writes, [144, 120], '72 is not offered at 120 Hz'); + settingsStore.clientSettings.gamescope_app_target_framerate = 60; + await change([12, 15, 20, 30, 60]); + await fire(); + assert.deepStrictEqual(writes, [144, 120], '60 is still offered at 60 Hz and is kept'); + await change([18, 24, 36, 72]); + await change([24, 30, 40, 60, 120]); + await fire(); + assert.deepStrictEqual(writes, [144, 120], 'a passing rate during a mode switch is not acted on'); + settingsStore.clientSettings.gamescope_enable_app_target_framerate = false; + settingsStore.clientSettings.gamescope_app_target_framerate = 72; + await change([36, 48, 144]); + await fire(); + assert.deepStrictEqual(writes, [144, 120], 'nothing changes while Steam has the frame limit turned off'); + delete window.__droiddeckFrameLimit; + webpackChunksteamui.push = ([, , callback]) => callback(webpack({ 1: modules[1], 2: modules[2] })); + assert.strictEqual(eval(script), 'unavailable'); +})().catch(error => { console.error(error); process.exit(1); }); +""" + + +class FrameLimitSyncTest(unittest.TestCase): + def test_limit_is_kept_when_offered_and_moved_to_the_highest_value_otherwise(self): + with tempfile.TemporaryDirectory() as directory: + script = Path(directory) / "frame_limit.js" + script.write_text(LIVE["FRAME_LIMIT_JS"]) + test = Path(directory) / "test.js" + test.write_text(HARNESS) + result = subprocess.run(["node", str(test), str(script)], capture_output=True, text=True, timeout=20) + self.assertEqual(result.returncode, 0, result.stderr) + + def test_install_is_retried_until_steam_is_ready_and_reported_once_per_state(self): + helper = LIVE["Helper"]("/steam", 0) + page = mock.Mock() + page.evaluate.side_effect = ["unavailable", "unavailable", "installed"] + helper.page = page + said = [] + clock = [100.0] + globals_ = LIVE["Helper"].sync_frame_limit.__globals__ + with mock.patch.dict(globals_, {"say": said.append}), mock.patch.object(globals_["time"], "monotonic", lambda: clock[0]): + helper.sync_frame_limit() + helper.sync_frame_limit() + clock[0] += 10 + helper.sync_frame_limit() + clock[0] += 10 + helper.sync_frame_limit() + clock[0] += 10 + helper.sync_frame_limit() + self.assertEqual(page.evaluate.call_count, 3) + self.assertEqual(said, ["frame limit sync: unavailable", "frame limit sync: installed"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/tools/tests/test_session_pacing.py b/tools/tests/test_session_pacing.py index e7c0df938f..84962fe9e6 100644 --- a/tools/tests/test_session_pacing.py +++ b/tools/tests/test_session_pacing.py @@ -18,16 +18,19 @@ class SessionPacingTest(unittest.TestCase): with tempfile.TemporaryDirectory() as directory: env = dict(os.environ, XDG_RUNTIME_DIR=directory, BL_REFRESH=str(refresh), BL_MANGOAPP='0', BL_FPS='0', DROIDDECK_GAME_FRAME_LIMIT='0') + env.pop('GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST', None) env.update(overrides) script = ''' set -u mode=steam pipewire_stub() { return 1; } -run_gamescope() { printf 'ARG:%s\\n' "$@"; } +run_gamescope() { printf 'ARG:%s\\n' "$@"; printf 'FOLLOW:%s\\n' "${GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST:-}"; } ''' + block result = subprocess.run(['bash', '-c', script], env=env, capture_output=True, text=True, timeout=5) self.assertEqual(0, result.returncode, result.stderr) + self.follow = [line.removeprefix('FOLLOW:') for line in result.stdout.splitlines() + if line.startswith('FOLLOW:')] return [line.removeprefix('ARG:') for line in result.stdout.splitlines() if line.startswith('ARG:')] @@ -38,6 +41,12 @@ run_gamescope() { printf 'ARG:%s\\n' "$@"; } self.assertEqual(str(refresh), args[args.index('-r') + 1]) self.assertIn('-e', args) + def test_gamescope_follows_the_panel_after_the_starting_rate(self): + self.launch(144) + self.assertEqual(['1'], self.follow) + self.launch(0) + self.assertEqual([''], self.follow) + def test_retired_cap_variables_do_not_override_the_display_rate(self): for performance in ('0', '1'): with self.subTest(performance=performance):