mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-02-16 10:40:59 +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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user