diff --git a/tools/gamescope/patches/0120-nested-refresh-follows-host.patch b/tools/gamescope/patches/0120-nested-refresh-follows-host.patch index 5505ff3f6b..83ed73b74b 100644 --- a/tools/gamescope/patches/0120-nested-refresh-follows-host.patch +++ b/tools/gamescope/patches/0120-nested-refresh-follows-host.patch @@ -1,8 +1,8 @@ diff --git a/src/Backends/WaylandBackend.cpp b/src/Backends/WaylandBackend.cpp -index 40164ba..cc04fa7 100644 +index 40164ba..1b85e63 100644 --- a/src/Backends/WaylandBackend.cpp +++ b/src/Backends/WaylandBackend.cpp -@@ -1698,6 +1698,49 @@ namespace gamescope +@@ -1698,6 +1698,52 @@ namespace gamescope } } @@ -21,6 +21,7 @@ index 40164ba..cc04fa7 100644 + + // 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. ++ // Until then gamescope keeps presenting, so a still screen also gets the feedback that takes it. + static bool HostRefreshChanged( int32_t nRefreshmHz, uint64_t ulPresentedNs ) + { + static int32_t s_nPendingmHz = 0; @@ -36,9 +37,11 @@ index 40164ba..cc04fa7 100644 + { + s_nPendingmHz = nRefreshmHz; + s_ulPendingSinceNs = ulPresentedNs; -+ return false; + } -+ return ulPresentedNs - s_ulPendingSinceNs >= 300'000'000ul; ++ if ( ulPresentedNs - s_ulPendingSinceNs >= 300'000'000ul ) ++ return true; ++ force_repaint(); ++ return false; + } + + static void FollowHostRefresh( int32_t nRefreshmHz ) @@ -52,7 +55,7 @@ index 40164ba..cc04fa7 100644 void CWaylandPlane::UpdateVRRRefreshRate() { if ( m_pParent ) -@@ -1724,6 +1767,7 @@ namespace gamescope +@@ -1724,6 +1770,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; @@ -60,7 +63,7 @@ index 40164ba..cc04fa7 100644 } } -@@ -1794,10 +1838,11 @@ namespace gamescope +@@ -1794,10 +1841,11 @@ namespace gamescope if ( uRefreshCycle ) { int32_t nRefresh = RefreshCycleTomHz( uRefreshCycle ); @@ -73,6 +76,16 @@ index 40164ba..cc04fa7 100644 } m_pConnector->SetHostCompositorIsCurrentlyVRR( false ); +@@ -2636,6 +2684,9 @@ namespace gamescope + } + void CWaylandBackend::Wayland_Output_Mode( wl_output *pOutput, uint32_t uFlags, int32_t nWidth, int32_t nHeight, int32_t nRefresh ) + { ++ // The followed rate comes from presentation feedback, so a still screen presents once for it. ++ if ( NestedRefreshFollowsHost() && m_pOutputs[ pOutput ].nRefresh != nRefresh ) ++ force_repaint(); + m_pOutputs[ pOutput ].nRefresh = nRefresh; + } + void CWaylandBackend::Wayland_Output_Done( wl_output *pOutput ) diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 6c9299d..5fb9086 100644 --- a/src/steamcompmgr.cpp diff --git a/tools/gamescope/release.env b/tools/gamescope/release.env index 611dd0c860..676a020370 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-p15 -GAMESCOPE_SHA256=ee592bc7d000db86b12adaecb1aee5d25f8d6565c3584e55975ef1078d7a8e52 +GAMESCOPE_TAG=gamescope-3.16.29-p16 +GAMESCOPE_SHA256=8ae783d730d910de9a44ddb98dd567643e9cf7987f16ef261fe08cd2c4a7ba5c diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 1d8e3992f8..ee24ff5829 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -272,14 +272,14 @@ FRAME_LIMIT_JS = r""" service = null; } if (!service || !settings?.clientSettings || typeof SteamClient.Settings?.SetSetting !== "function") return "unavailable"; - const self = { choices: null, timer: null }; + const self = { 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))); + return SteamClient.Settings.SetSetting(btoa(String.fromCharCode(...bytes))); }; self.check = async () => { let rates; @@ -291,12 +291,12 @@ FRAME_LIMIT_JS = r""" 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)); + try { + await write(Math.max(...rates)); + } catch (e) { + } }; self.schedule = () => { clearTimeout(self.timer); diff --git a/tools/tests/test_frame_limit_sync.py b/tools/tests/test_frame_limit_sync.py index ca89c203aa..0cbdc18fb9 100644 --- a/tools/tests/test_frame_limit_sync.py +++ b/tools/tests/test_frame_limit_sync.py @@ -76,6 +76,27 @@ const change = async next => { rates = next; notify.forEach(callback => callback await change([36, 48, 144]); await fire(); assert.deepStrictEqual(writes, [144, 120], 'nothing changes while Steam has the frame limit turned off'); + settingsStore.clientSettings.gamescope_enable_app_target_framerate = true; + window.__droiddeckFrameLimit.schedule(); + await fire(); + assert.deepStrictEqual(writes, [144, 120, 144], 'turning the limit on after a rate change moves an unoffered value'); + settingsStore.clientSettings.gamescope_app_target_framerate = 72; + const setSetting = SteamClient.Settings.SetSetting; + SteamClient.Settings.SetSetting = () => { throw new Error('busy'); }; + window.__droiddeckFrameLimit.schedule(); + await fire(); + SteamClient.Settings.SetSetting = setSetting; + window.__droiddeckFrameLimit.schedule(); + await fire(); + assert.deepStrictEqual(writes, [144, 120, 144, 144], 'a failed write is tried again on the next check'); + settingsStore.clientSettings.gamescope_app_target_framerate = 72; + SteamClient.Settings.SetSetting = () => Promise.reject(new Error('busy')); + window.__droiddeckFrameLimit.schedule(); + await fire(); + SteamClient.Settings.SetSetting = setSetting; + window.__droiddeckFrameLimit.schedule(); + await fire(); + assert.deepStrictEqual(writes, [144, 120, 144, 144, 144], 'a rejected write is caught and tried again'); delete window.__droiddeckFrameLimit; webpackChunksteamui.push = ([, , callback]) => callback(webpack({ 1: modules[1], 2: modules[2] })); assert.strictEqual(eval(script), 'unavailable');