From 2f0c89cbe9c2f15ff06982f82932451da46289bf Mon Sep 17 00:00:00 2001 From: RSDuck Date: Tue, 4 Oct 2022 13:15:50 +0200 Subject: [PATCH] add back vsync --- src/frontend/qt_sdl/VideoSettingsDialog.cpp | 26 +++++++++------------ src/frontend/qt_sdl/main.cpp | 9 +++++++ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/frontend/qt_sdl/VideoSettingsDialog.cpp b/src/frontend/qt_sdl/VideoSettingsDialog.cpp index 87a796d2..87129428 100644 --- a/src/frontend/qt_sdl/VideoSettingsDialog.cpp +++ b/src/frontend/qt_sdl/VideoSettingsDialog.cpp @@ -28,6 +28,11 @@ #include "ui_VideoSettingsDialog.h" +inline bool UsesGL() +{ + return (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); +} + VideoSettingsDialog* VideoSettingsDialog::currentDlg = nullptr; @@ -88,14 +93,6 @@ VideoSettingsDialog::VideoSettingsDialog(QWidget* parent) : QDialog(parent), ui( ui->cbxGLResolution->setEnabled(true); ui->cbBetterPolygons->setEnabled(true); } - - // sorry - ui->cbVSync->hide(); - ui->cbVSync->setEnabled(false); - ui->sbVSyncInterval->hide(); - ui->sbVSyncInterval->setEnabled(false); - ui->label_2->hide(); - ui->groupBox->layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } VideoSettingsDialog::~VideoSettingsDialog() @@ -112,7 +109,7 @@ void VideoSettingsDialog::on_VideoSettingsDialog_accepted() void VideoSettingsDialog::on_VideoSettingsDialog_rejected() { - bool old_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); + bool old_gl = UsesGL(); Config::_3DRenderer = oldRenderer; Config::ScreenUseGL = oldGLDisplay; @@ -122,8 +119,7 @@ void VideoSettingsDialog::on_VideoSettingsDialog_rejected() Config::GL_ScaleFactor = oldGLScale; Config::GL_BetterPolygons = oldGLBetterPolygons; - bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); - emit updateVideoSettings(old_gl != new_gl); + emit updateVideoSettings(old_gl != UsesGL()); closeDlg(); } @@ -149,8 +145,7 @@ void VideoSettingsDialog::onChange3DRenderer(int renderer) ui->cbBetterPolygons->setEnabled(true); } - bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); - emit updateVideoSettings(old_gl != new_gl); + emit updateVideoSettings(old_gl != UsesGL()); } void VideoSettingsDialog::on_cbGLDisplay_stateChanged(int state) @@ -159,8 +154,7 @@ void VideoSettingsDialog::on_cbGLDisplay_stateChanged(int state) Config::ScreenUseGL = (state != 0); - bool new_gl = (Config::ScreenUseGL != 0) || (Config::_3DRenderer != 0); - emit updateVideoSettings(old_gl != new_gl); + emit updateVideoSettings(old_gl != UsesGL()); } void VideoSettingsDialog::on_cbVSync_stateChanged(int state) @@ -168,11 +162,13 @@ void VideoSettingsDialog::on_cbVSync_stateChanged(int state) bool vsync = (state != 0); ui->sbVSyncInterval->setEnabled(vsync); Config::ScreenVSync = vsync; + emit updateVideoSettings(false); } void VideoSettingsDialog::on_sbVSyncInterval_valueChanged(int val) { Config::ScreenVSyncInterval = val; + emit updateVideoSettings(false); } void VideoSettingsDialog::on_cbSoftwareThreaded_stateChanged(int state) diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index 31fc5b9e..d9d6a332 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -426,6 +426,8 @@ void EmuThread::initOpenGL() static_cast(mainWindow->panel)->transferLayout(this); OSD::Init(true); + + oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0); } void EmuThread::deinitOpenGL() @@ -543,7 +545,9 @@ void EmuThread::run() videoRenderer = 0; } else + { videoRenderer = hasOGL ? Config::_3DRenderer : 0; + } videoSettingsDirty = false; @@ -551,6 +555,11 @@ void EmuThread::run() videoSettings.GL_ScaleFactor = Config::GL_ScaleFactor; videoSettings.GL_BetterPolygons = Config::GL_BetterPolygons; + if (hasOGL) + { + oglContext->SetSwapInterval(Config::ScreenVSync ? Config::ScreenVSyncInterval : 0); + } + GPU::SetRenderSettings(videoRenderer, videoSettings); }