mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 02:30:52 +00:00
Use display scaling to improve performance on slow GPUs
This dramatically improves performance for lower resolution streams on slow GPUs when using the GL and Vulkan renderers.
This commit is contained in:
@@ -109,8 +109,10 @@ void StreamingPreferences::reload()
|
|||||||
#ifdef Q_OS_DARWIN
|
#ifdef Q_OS_DARWIN
|
||||||
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
||||||
#else
|
#else
|
||||||
// Wayland doesn't support modesetting, so use fullscreen desktop mode.
|
// Wayland doesn't support modesetting, so use fullscreen desktop mode
|
||||||
if (WMUtils::isRunningWayland()) {
|
// 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;
|
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -904,6 +904,13 @@ bool Session::initialize(QQuickWindow* qtWindow)
|
|||||||
switch (m_Preferences->windowMode)
|
switch (m_Preferences->windowMode)
|
||||||
{
|
{
|
||||||
default:
|
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:
|
case StreamingPreferences::WM_FULLSCREEN_DESKTOP:
|
||||||
// Only use full-screen desktop mode if we're running a desktop environment
|
// Only use full-screen desktop mode if we're running a desktop environment
|
||||||
if (WMUtils::isRunningDesktopEnvironment()) {
|
if (WMUtils::isRunningDesktopEnvironment()) {
|
||||||
@@ -1422,10 +1429,18 @@ void Session::updateOptimalWindowDisplayMode()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start with the native desktop resolution and try to find
|
// On devices with slow GPUs, we will try to match the display mode
|
||||||
// the highest refresh rate that our stream FPS evenly divides.
|
// 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 = desktopMode;
|
||||||
bestMode.refresh_rate = 0;
|
bestMode.refresh_rate = 0;
|
||||||
|
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++) {
|
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
|
||||||
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
|
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
|
||||||
if (mode.w == desktopMode.w && mode.h == desktopMode.h &&
|
if (mode.w == desktopMode.w && mode.h == desktopMode.h &&
|
||||||
@@ -1439,6 +1454,7 @@ void Session::updateOptimalWindowDisplayMode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we didn't find a mode that matched the current resolution and
|
// If we didn't find a mode that matched the current resolution and
|
||||||
// had a high enough refresh rate, start looking for lower resolution
|
// had a high enough refresh rate, start looking for lower resolution
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace WMUtils {
|
|||||||
bool isRunningWindowManager();
|
bool isRunningWindowManager();
|
||||||
bool isRunningDesktopEnvironment();
|
bool isRunningDesktopEnvironment();
|
||||||
QString getDrmCardOverride();
|
QString getDrmCardOverride();
|
||||||
|
bool isGpuSlow();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|||||||
15
app/wm.cpp
15
app/wm.cpp
@@ -205,6 +205,21 @@ bool WMUtils::isRunningDesktopEnvironment()
|
|||||||
#endif
|
#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()
|
QString WMUtils::getDrmCardOverride()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DRM
|
#ifdef HAVE_DRM
|
||||||
|
|||||||
Reference in New Issue
Block a user