From 6f0929df82be77f116988cf16cde4ebbc5f978dc Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 15:39:00 -0400 Subject: configuration: Expose separate swap present modes Previously, yuzu would try and guess which vsync mode to use given different scenarios, but apparently we didn't always get it right. This exposes the separate modes in a drop-down the user can select. If a mode isn't available in Vulkan, it defaults to FIFO. --- src/yuzu/bootmanager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 4c7bf28d8..01dc51cff 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -154,7 +154,18 @@ public: // disable vsync for any shared contexts auto format = share_context->format(); - format.setSwapInterval(main_surface ? Settings::values.use_vsync.GetValue() : 0); + const int swap_interval = [&]() { + switch (Settings::values.vsync_mode.GetValue()) { + case Settings::VSyncMode::Immediate: + return 0; + case Settings::VSyncMode::FIFO: + return 1; + case Settings::VSyncMode::Mailbox: + return 2; + } + }(); + + format.setSwapInterval(main_surface ? swap_interval : 0); context = std::make_unique(); context->setShareContext(share_context); -- cgit v1.2.3 From 29a56496bffcec6bad5865426e0ffd7091f76667 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 16:14:38 -0400 Subject: bootmanager: Return value in impossible case The setting is ranged, so this return statement is unreachable. But GCC can't tell I guess. --- src/yuzu/bootmanager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 01dc51cff..1cf239496 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -163,6 +163,7 @@ public: case Settings::VSyncMode::Mailbox: return 2; } + return 0; }(); format.setSwapInterval(main_surface ? swap_interval : 0); -- cgit v1.2.3 From cbd79df233754113ac509bf8de034d8cd8ffd588 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:27:45 -0400 Subject: qt_common: Move window info function out of bootmanager Function is useful outside of bootmanager, so put it in a common place. qt_common: Add missing include qt_common: Add some newlines qt_common: Add trailing newline qt_common: Add trainline newline --- src/yuzu/bootmanager.cpp | 47 +++-------------------------------------------- 1 file changed, 3 insertions(+), 44 deletions(-) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 1cf239496..98161cc27 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -43,8 +43,7 @@ #include "video_core/renderer_base.h" #include "yuzu/bootmanager.h" #include "yuzu/main.h" - -static Core::Frontend::WindowSystemType GetWindowSystemType(); +#include "yuzu/qt_common.h" EmuThread::EmuThread(Core::System& system) : m_system{system} {} @@ -233,7 +232,7 @@ public: explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_PaintOnScreen); - if (GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { + if (YuzuQtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { setAttribute(Qt::WA_DontCreateNativeAncestors); } } @@ -271,46 +270,6 @@ struct NullRenderWidget : public RenderWidget { explicit NullRenderWidget(GRenderWindow* parent) : RenderWidget(parent) {} }; -static Core::Frontend::WindowSystemType GetWindowSystemType() { - // Determine WSI type based on Qt platform. - QString platform_name = QGuiApplication::platformName(); - if (platform_name == QStringLiteral("windows")) - return Core::Frontend::WindowSystemType::Windows; - else if (platform_name == QStringLiteral("xcb")) - return Core::Frontend::WindowSystemType::X11; - else if (platform_name == QStringLiteral("wayland")) - return Core::Frontend::WindowSystemType::Wayland; - else if (platform_name == QStringLiteral("wayland-egl")) - return Core::Frontend::WindowSystemType::Wayland; - else if (platform_name == QStringLiteral("cocoa")) - return Core::Frontend::WindowSystemType::Cocoa; - else if (platform_name == QStringLiteral("android")) - return Core::Frontend::WindowSystemType::Android; - - LOG_CRITICAL(Frontend, "Unknown Qt platform {}!", platform_name.toStdString()); - return Core::Frontend::WindowSystemType::Windows; -} - -static Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) { - Core::Frontend::EmuWindow::WindowSystemInfo wsi; - wsi.type = GetWindowSystemType(); - - // Our Win32 Qt external doesn't have the private API. -#if defined(WIN32) || defined(__APPLE__) - wsi.render_surface = window ? reinterpret_cast(window->winId()) : nullptr; -#else - QPlatformNativeInterface* pni = QGuiApplication::platformNativeInterface(); - wsi.display_connection = pni->nativeResourceForWindow("display", window); - if (wsi.type == Core::Frontend::WindowSystemType::Wayland) - wsi.render_surface = window ? pni->nativeResourceForWindow("surface", window) : nullptr; - else - wsi.render_surface = window ? reinterpret_cast(window->winId()) : nullptr; -#endif - wsi.render_surface_scale = window ? static_cast(window->devicePixelRatio()) : 1.0f; - - return wsi; -} - GRenderWindow::GRenderWindow(GMainWindow* parent, EmuThread* emu_thread_, std::shared_ptr input_subsystem_, Core::System& system_) @@ -916,7 +875,7 @@ bool GRenderWindow::InitRenderTarget() { } // Update the Window System information with the new render target - window_info = GetWindowSystemInfo(child_widget->windowHandle()); + window_info = YuzuQtCommon::GetWindowSystemInfo(child_widget->windowHandle()); child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); layout()->addWidget(child_widget); -- cgit v1.2.3 From a090a380be674ae001aea47434e1a2f008574a48 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:29:13 -0400 Subject: bootmanager: Remove inaccurate switch Those vulkan settings do not correspond 1:1 to the swap intervals that they set for OpenGL, so remove it. bootmanager: Add missing include I didn't add this log why did it break --- src/yuzu/bootmanager.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 98161cc27..b064c9c64 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -153,17 +153,8 @@ public: // disable vsync for any shared contexts auto format = share_context->format(); - const int swap_interval = [&]() { - switch (Settings::values.vsync_mode.GetValue()) { - case Settings::VSyncMode::Immediate: - return 0; - case Settings::VSyncMode::FIFO: - return 1; - case Settings::VSyncMode::Mailbox: - return 2; - } - return 0; - }(); + const int swap_interval = + Settings::values.vsync_mode.GetValue() == Settings::VSyncMode::Immediate ? 0 : 1; format.setSwapInterval(main_surface ? swap_interval : 0); -- cgit v1.2.3 From 0c0f5b7ccc1dcc2b223063ea75286203edb0eab0 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 2 May 2023 16:54:19 -0400 Subject: bootmanager: Clean up includes [IWYU] bootmanager: Remove system-specific headers IWYU can be too complete I suppose. --- src/yuzu/bootmanager.cpp | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index b064c9c64..d0c72b820 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -1,36 +1,48 @@ // SPDX-FileCopyrightText: 2014 Citra Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include +#include +#include +#include +#include +#include #include -#include +#include #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && YUZU_USE_QT_MULTIMEDIA +#include #include #include #endif +#include +#include +#include #include +#include +#include +#include #include -#include #include -#include -#include +#include +#include +#include +#include #include +#include #ifdef HAS_OPENGL #include #include #endif -#if !defined(WIN32) -#include -#endif - -#include - -#include "common/assert.h" #include "common/microprofile.h" +#include "common/polyfill_thread.h" #include "common/scm_rev.h" #include "common/settings.h" +#include "common/settings_input.h" +#include "common/thread.h" #include "core/core.h" #include "core/cpu_manager.h" #include "core/frontend/framebuffer_layout.h" @@ -40,11 +52,17 @@ #include "input_common/drivers/tas_input.h" #include "input_common/drivers/touch_screen.h" #include "input_common/main.h" +#include "video_core/gpu.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_base.h" #include "yuzu/bootmanager.h" #include "yuzu/main.h" #include "yuzu/qt_common.h" +class QObject; +class QPaintEngine; +class QSurface; + EmuThread::EmuThread(Core::System& system) : m_system{system} {} EmuThread::~EmuThread() = default; -- cgit v1.2.3 From a71498d163029c29285e5bef7098f2fe265196fa Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Wed, 3 May 2023 18:11:34 -0400 Subject: qt_common: Remove yuzu prefix --- src/yuzu/bootmanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/yuzu/bootmanager.cpp') diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index d0c72b820..59d226113 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -241,7 +241,7 @@ public: explicit RenderWidget(GRenderWindow* parent) : QWidget(parent), render_window(parent) { setAttribute(Qt::WA_NativeWindow); setAttribute(Qt::WA_PaintOnScreen); - if (YuzuQtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { + if (QtCommon::GetWindowSystemType() == Core::Frontend::WindowSystemType::Wayland) { setAttribute(Qt::WA_DontCreateNativeAncestors); } } @@ -884,7 +884,7 @@ bool GRenderWindow::InitRenderTarget() { } // Update the Window System information with the new render target - window_info = YuzuQtCommon::GetWindowSystemInfo(child_widget->windowHandle()); + window_info = QtCommon::GetWindowSystemInfo(child_widget->windowHandle()); child_widget->resize(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); layout()->addWidget(child_widget); -- cgit v1.2.3