mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 05:46:03 +00:00
fix: Frame Limit sync and refresh follow on a still screen (review follow-ups) (#1663)
The Steam helper checked the Frame Limit only when the offered frame rates changed. With the limit off during a refresh change, turning it back on left a value the new rate does not offer, and a failed write was not tried again. It now checks on every state change and every 5 s, and waits for Steam's settings write so a rejected write is caught and tried again on the next check. gamescope 3.16.29-p16 (0120 changed): gamescope took a new host refresh only from the presentation feedback of a frame it drew, so with nothing moving on screen it kept the old rate. It now presents once when the host's wl_output mode changes and keeps presenting while a new rate is pending, so the 300 ms check runs on a still screen too. Found by CodeRabbit in the reviews of #1650 and #1663.
This commit is contained in:
1 parent
07a0a7e344
commit
43a0ce93f9
4 files changed
+48
-14
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user