From 4e0f78dfa0b8c7eff9490f2044eb159983f94122 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 3 Apr 2023 10:01:25 -0300 Subject: [PATCH 1/4] citra_qt: fix vsync configuration being possible while a game is running --- src/citra_qt/configuration/configure_graphics.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index 1a48e5c662..4f3dbaac5e 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -119,7 +119,8 @@ void ConfigureGraphics::SetupPerGameUI() { ui->toggle_accurate_mul->setEnabled(Settings::values.shaders_accurate_mul.UsingGlobal()); ui->toggle_disk_shader_cache->setEnabled( Settings::values.use_disk_shader_cache.UsingGlobal()); - ui->toggle_vsync_new->setEnabled(Settings::values.use_vsync_new.UsingGlobal()); + ui->toggle_vsync_new->setEnabled(ui->toggle_vsync_new->isEnabled() && + Settings::values.use_vsync_new.UsingGlobal()); return; } From 40849a8fa8196a8878d20e17cab5538c35aae552 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 3 Apr 2023 12:16:43 -0300 Subject: [PATCH 2/4] bootmanager: remove unnecessary includes --- src/citra_qt/bootmanager.cpp | 3 +-- src/citra_qt/bootmanager.h | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 3cb1c904d5..212b08b167 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -5,12 +5,11 @@ #include #include -#include #include #include #include #include -#include +#include #include "citra_qt/bootmanager.h" #include "citra_qt/main.h" #include "common/color.h" diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index d06c1ce5e8..cff01cbb9d 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -10,17 +10,12 @@ #include #include #include -#include -#include "common/thread.h" #include "core/core.h" #include "core/frontend/emu_window.h" class QKeyEvent; class QTouchEvent; -class QOffscreenSurface; -class QOpenGLContext; -class GMainWindow; class GRenderWindow; namespace VideoCore { From 5c50a26b38a3aa77ec03f6fc364c5da8dcdf4fc1 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 3 Apr 2023 12:17:09 -0300 Subject: [PATCH 3/4] bootmanager: make main_context a unique_ptr --- src/citra_qt/bootmanager.cpp | 4 ++-- src/citra_qt/bootmanager.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 212b08b167..f9070da7eb 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -386,7 +386,7 @@ static Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window return wsi; } -std::shared_ptr GRenderWindow::main_context; +std::unique_ptr GRenderWindow::main_context; GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread, bool is_secondary_) : QWidget(parent_), EmuWindow(is_secondary_), emu_thread(emu_thread) { @@ -667,7 +667,7 @@ bool GRenderWindow::InitializeOpenGL() { child_widget->windowHandle()->create(); if (!main_context) { - main_context = std::make_shared(); + main_context = std::make_unique(); } auto child_context = CreateSharedContext(); diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index cff01cbb9d..f0019886d8 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -192,7 +192,7 @@ private: /// Main context that will be shared with all other contexts that are requested. /// If this is used in a shared context setting, then this should not be used directly, but /// should instead be shared from - static std::shared_ptr main_context; + static std::unique_ptr main_context; /// Temporary storage of the screenshot taken QImage screenshot_image; From b4ef3cdeff50800393b02aac6e970236487d4853 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Mon, 3 Apr 2023 14:21:49 -0300 Subject: [PATCH 4/4] bootmanager: set the surface format based on vsync --- src/citra_qt/bootmanager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index f9070da7eb..5b3238b422 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -162,7 +162,7 @@ public: // disable vsync for any shared contexts auto format = share_context->format(); - format.setSwapInterval(main_surface ? Settings::values.use_vsync_new.GetValue() : 0); + format.setSwapInterval(0); context = std::make_unique(); context->setShareContext(share_context); @@ -673,6 +673,10 @@ bool GRenderWindow::InitializeOpenGL() { auto child_context = CreateSharedContext(); child->SetContext(std::move(child_context)); + auto format = child_widget->windowHandle()->format(); + format.setSwapInterval(Settings::values.use_vsync_new.GetValue()); + child_widget->windowHandle()->setFormat(format); + return true; #else QMessageBox::warning(this, tr("OpenGL not available!"),