diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index 185bdcef..e05951bc 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -109,8 +109,10 @@ void StreamingPreferences::reload() #ifdef Q_OS_DARWIN recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP; #else - // Wayland doesn't support modesetting, so use fullscreen desktop mode. - if (WMUtils::isRunningWayland()) { + // Wayland doesn't support modesetting, so use fullscreen desktop mode + // unless we have a slow GPU (which can take advantage of wp_viewporter + // to reduce GPU load with lower resolution video streams). + if (WMUtils::isRunningWayland() && !WMUtils::isGpuSlow()) { recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP; } else { diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 1f35388e..4b432960 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -904,6 +904,13 @@ bool Session::initialize(QQuickWindow* qtWindow) switch (m_Preferences->windowMode) { default: + // Normally we'd default to fullscreen desktop when starting in windowed + // mode, but in the case of a slow GPU, we want to use real fullscreen + // to allow the display to assist with the video scaling work. + if (WMUtils::isGpuSlow()) { + m_FullScreenFlag = SDL_WINDOW_FULLSCREEN; + break; + } case StreamingPreferences::WM_FULLSCREEN_DESKTOP: // Only use full-screen desktop mode if we're running a desktop environment if (WMUtils::isRunningDesktopEnvironment()) { @@ -1422,19 +1429,28 @@ void Session::updateOptimalWindowDisplayMode() return; } - // Start with the native desktop resolution and try to find - // the highest refresh rate that our stream FPS evenly divides. + // On devices with slow GPUs, we will try to match the display mode + // to the video stream to offload the scaling work to the display. + bool matchVideo; + if (!Utils::getEnvironmentVariableOverride("MATCH_DISPLAY_MODE_TO_VIDEO", &matchVideo)) { + matchVideo = WMUtils::isGpuSlow(); + } + bestMode = desktopMode; bestMode.refresh_rate = 0; - for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) { - if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) { - if (mode.w == desktopMode.w && mode.h == desktopMode.h && + if (!matchVideo) { + // Start with the native desktop resolution and try to find + // the highest refresh rate that our stream FPS evenly divides. + for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) { + if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) { + if (mode.w == desktopMode.w && mode.h == desktopMode.h && mode.refresh_rate % m_StreamConfig.fps == 0) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Found display mode with desktop resolution: %dx%dx%d", - mode.w, mode.h, mode.refresh_rate); - if (mode.refresh_rate > bestMode.refresh_rate) { - bestMode = mode; + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Found display mode with desktop resolution: %dx%dx%d", + mode.w, mode.h, mode.refresh_rate); + if (mode.refresh_rate > bestMode.refresh_rate) { + bestMode = mode; + } } } } diff --git a/app/utils.h b/app/utils.h index d703fc0a..61a0348f 100644 --- a/app/utils.h +++ b/app/utils.h @@ -13,6 +13,7 @@ namespace WMUtils { bool isRunningWindowManager(); bool isRunningDesktopEnvironment(); QString getDrmCardOverride(); + bool isGpuSlow(); } namespace Utils { diff --git a/app/wm.cpp b/app/wm.cpp index 5509483f..4a47dc86 100644 --- a/app/wm.cpp +++ b/app/wm.cpp @@ -205,6 +205,21 @@ bool WMUtils::isRunningDesktopEnvironment() #endif } +bool WMUtils::isGpuSlow() +{ + bool ret; + + if (!Utils::getEnvironmentVariableOverride("GL_IS_SLOW", &ret)) { +#ifdef GL_IS_SLOW + ret = true; +#else + ret = false; +#endif + } + + return ret; +} + QString WMUtils::getDrmCardOverride() { #ifdef HAVE_DRM