Use full-screen windowed mode to avoid having to enable V-Sync on DXVA2

This commit is contained in:
Cameron Gutman 2018-07-22 15:42:17 -07:00
parent 3bb62a82e1
commit cf3cbd627d
2 changed files with 13 additions and 11 deletions

View File

@ -13,6 +13,12 @@
#include "video/sl.h"
#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 <QtEndian>
@ -407,7 +413,7 @@ void Session::getWindowDimensions(bool fullScreen,
// comes back after the mode change until we revert the change
// by destroying the window. Possible KMS/X bug? Let's avoid
// 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)) {
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"Closest match for %dx%dx%d is %dx%dx%d",
@ -473,7 +479,7 @@ void Session::getWindowDimensions(bool fullScreen,
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;
@ -491,7 +497,7 @@ void Session::toggleFullscreen()
SDL_SetWindowSize(m_Window, width, height);
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,
height,
m_Preferences.fullScreen ?
SDL_WINDOW_FULLSCREEN : 0);
SDL_OS_FULLSCREEN_FLAG : 0);
if (!m_Window) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_CreateWindow() failed: %s",

View File

@ -360,13 +360,9 @@ bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, i
// D3DCREATE_MULTITHREADED to IDirect3D9::CreateDevice().
SDL_SetHint(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, "1");
// We want VSYNC when running in full-screen. DWM will give us
// tear-free video when running composited (windowed) without any
// extra latency waiting for VSYNC.
m_SdlRenderer = SDL_CreateRenderer(window, -1,
SDL_RENDERER_ACCELERATED |
((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) ?
SDL_RENDERER_PRESENTVSYNC : 0));
// We require full-screen desktop mode to avoid having to enable V-sync
// to synchronize frame delivery (which has a much higher latency penalty).
m_SdlRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (!m_SdlRenderer) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"SDL_CreateRenderer() failed: %s",