feat: Steam's Frame Limit decides; gamescope and the limit follow the refresh rate (#1650)

Remove the Performance mode switch. The session always runs the way
Performance mode did: replaced buffers go back to the game at once
(except while mirroring to glasses), gamescope's WSI layer and winex11
reuse their per-present window checks, and games get eight swapchain
images while uncapped. Steam's Frame Limit in the Quick Access menu is
the only limit.

gamescope 3.16.29-p15 (p14 plus two patches):
- 0119: with the Frame Limit on, gamescope forces FIFO while the WSI
  layer hands the driver MAILBOX, so a game with eight images could
  queue up to seven frames ahead of the screen. While the limiter forces
  FIFO the layer uses its default of 3 images; DXVK and VKD3D-Proton
  recreate their swapchain when the limiter changes, other apps are asked
  to with VK_SUBOPTIMAL_KHR.
- 0120: -r fixed gamescope's pacing and limiter rate for the whole
  session. With GAMESCOPE_NESTED_REFRESH_FOLLOWS_HOST=1 a rate the host
  has reported for 300 ms replaces it (a switch from 144 to 120 Hz passes
  through 72 Hz for a few frames), and Steam gets the display information
  again. The session sets it whenever it passes -r.

Steam keeps its Frame Limit as the client setting
gamescope_app_target_framerate and offers the values gamescope's display
state lists. After a refresh change, a limit the new rate does not offer
(72 at 120 Hz) left the slider on its first value while the game kept the
old limit. The Steam helper watches the offered values and, once they
settle, keeps the limit when it is still offered and moves it to the
highest value otherwise, through Steam's own setting so the slider shows
it. Steam's webpack does not expose its module cache, so the gamescope
service is found by the calls its module makes, and the helper retries
the install every 10 s until Steam is ready.

The session window asks for the fastest mode the peak refresh setting
allows and chose again only when the display changed, so after it had
asked for 60 Hz, raising Android's refresh setting left the display,
gamescope and the limit at 60. It now also chooses again when
peak_refresh_rate or min_refresh_rate changes.
This commit is contained in:
The412Banner authored and GitHub committed 2026-10-26 23:17:35 -04:00
1 parent 0e9a31ccfe
commit 4c7e59ed8b
52 files changed
+466 -133

No files matched your search

@@ -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<ModeDisplay>(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<ModeDisplay>(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<ContentObserver>(activity, "refreshSettingObserver").onChange(false)
assertEquals(3, activity.window.attributes.preferredDisplayModeId)
}
private fun apply(state: GlassesState, config: GlassesSettings) {
@@ -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))
}
}
@@ -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))
}
}