mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-02 07:46:07 +00:00
Use full-screen windowed mode to avoid having to enable V-Sync on DXVA2
This commit is contained in:
parent
3bb62a82e1
commit
cf3cbd627d
@ -13,6 +13,12 @@
|
|||||||
#include "video/sl.h"
|
#include "video/sl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
#define SDL_OS_FULLSCREEN_FLAG SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||||
|
#else
|
||||||
|
#define SDL_OS_FULLSCREEN_FLAG SDL_WINDOW_FULLSCREEN
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
@ -407,7 +413,7 @@ void Session::getWindowDimensions(bool fullScreen,
|
|||||||
// comes back after the mode change until we revert the change
|
// comes back after the mode change until we revert the change
|
||||||
// by destroying the window. Possible KMS/X bug? Let's avoid
|
// by destroying the window. Possible KMS/X bug? Let's avoid
|
||||||
// exercising this path until we have a workaround.
|
// exercising this path until we have a workaround.
|
||||||
#ifndef Q_OS_LINUX
|
#if !defined(Q_OS_LINUX) && SDL_OS_FULLSCREEN_FLAG == SDL_WINDOW_FULLSCREEN
|
||||||
if (SDL_GetClosestDisplayMode(displayIndex, &desired, &closest)) {
|
if (SDL_GetClosestDisplayMode(displayIndex, &desired, &closest)) {
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Closest match for %dx%dx%d is %dx%dx%d",
|
"Closest match for %dx%dx%d is %dx%dx%d",
|
||||||
@ -473,7 +479,7 @@ void Session::getWindowDimensions(bool fullScreen,
|
|||||||
|
|
||||||
void Session::toggleFullscreen()
|
void Session::toggleFullscreen()
|
||||||
{
|
{
|
||||||
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & SDL_WINDOW_FULLSCREEN);
|
bool fullScreen = !(SDL_GetWindowFlags(m_Window) & SDL_OS_FULLSCREEN_FLAG);
|
||||||
|
|
||||||
int x, y, width, height;
|
int x, y, width, height;
|
||||||
|
|
||||||
@ -491,7 +497,7 @@ void Session::toggleFullscreen()
|
|||||||
SDL_SetWindowSize(m_Window, width, height);
|
SDL_SetWindowSize(m_Window, width, height);
|
||||||
|
|
||||||
if (fullScreen) {
|
if (fullScreen) {
|
||||||
SDL_SetWindowFullscreen(m_Window, SDL_WINDOW_FULLSCREEN);
|
SDL_SetWindowFullscreen(m_Window, SDL_OS_FULLSCREEN_FLAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,7 +595,7 @@ void Session::exec()
|
|||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
m_Preferences.fullScreen ?
|
m_Preferences.fullScreen ?
|
||||||
SDL_WINDOW_FULLSCREEN : 0);
|
SDL_OS_FULLSCREEN_FLAG : 0);
|
||||||
if (!m_Window) {
|
if (!m_Window) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"SDL_CreateWindow() failed: %s",
|
"SDL_CreateWindow() failed: %s",
|
||||||
|
@ -360,13 +360,9 @@ bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, i
|
|||||||
// D3DCREATE_MULTITHREADED to IDirect3D9::CreateDevice().
|
// D3DCREATE_MULTITHREADED to IDirect3D9::CreateDevice().
|
||||||
SDL_SetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, "1");
|
SDL_SetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, "1");
|
||||||
|
|
||||||
// We want VSYNC when running in full-screen. DWM will give us
|
// We require full-screen desktop mode to avoid having to enable V-sync
|
||||||
// tear-free video when running composited (windowed) without any
|
// to synchronize frame delivery (which has a much higher latency penalty).
|
||||||
// extra latency waiting for VSYNC.
|
m_SdlRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||||
m_SdlRenderer = SDL_CreateRenderer(window, -1,
|
|
||||||
SDL_RENDERER_ACCELERATED |
|
|
||||||
((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) ?
|
|
||||||
SDL_RENDERER_PRESENTVSYNC : 0));
|
|
||||||
if (!m_SdlRenderer) {
|
if (!m_SdlRenderer) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"SDL_CreateRenderer() failed: %s",
|
"SDL_CreateRenderer() failed: %s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user