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/common/settings.cpp | 3 +- src/common/settings.h | 9 +++- src/core/telemetry_session.cpp | 15 ++++++- src/video_core/renderer_vulkan/vk_swapchain.cpp | 27 ++++++------ src/yuzu/bootmanager.cpp | 13 +++++- src/yuzu/configuration/config.cpp | 10 ++++- src/yuzu/configuration/configure_graphics.cpp | 9 ++++ src/yuzu/configuration/configure_graphics.ui | 49 +++++++++++++++++++++- .../configuration/configure_graphics_advanced.cpp | 5 --- .../configuration/configure_graphics_advanced.ui | 10 ----- src/yuzu_cmd/config.cpp | 2 +- 11 files changed, 115 insertions(+), 37 deletions(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 77ff21128..92794f4a2 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -60,7 +60,7 @@ void LogSettings() { log_setting("Renderer_NvdecEmulation", values.nvdec_emulation.GetValue()); log_setting("Renderer_AccelerateASTC", values.accelerate_astc.GetValue()); log_setting("Renderer_AsyncASTC", values.async_astc.GetValue()); - log_setting("Renderer_UseVsync", values.use_vsync.GetValue()); + log_setting("Renderer_UseVsync", values.vsync_mode.GetValue()); log_setting("Renderer_ShaderBackend", values.shader_backend.GetValue()); log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue()); log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue()); @@ -222,7 +222,6 @@ void RestoreGlobalState(bool is_powered_on) { values.nvdec_emulation.SetGlobal(true); values.accelerate_astc.SetGlobal(true); values.async_astc.SetGlobal(true); - values.use_vsync.SetGlobal(true); values.shader_backend.SetGlobal(true); values.use_asynchronous_shaders.SetGlobal(true); values.use_fast_gpu_time.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index 5379d0dd5..2371495e4 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -16,6 +16,12 @@ namespace Settings { +enum class VSyncMode : u32 { + Immediate, + FIFO, + Mailbox, +}; + enum class RendererBackend : u32 { OpenGL = 0, Vulkan = 1, @@ -455,7 +461,8 @@ struct Values { SwitchableSetting nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; SwitchableSetting accelerate_astc{true, "accelerate_astc"}; SwitchableSetting async_astc{false, "async_astc"}; - SwitchableSetting use_vsync{true, "use_vsync"}; + Setting vsync_mode{VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::Mailbox, + "use_vsync"}; SwitchableSetting shader_backend{ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, "shader_backend"}; SwitchableSetting use_asynchronous_shaders{false, "use_asynchronous_shaders"}; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 9178b00ca..6ec8e440c 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -85,6 +85,18 @@ static const char* TranslateNvdecEmulation(Settings::NvdecEmulation backend) { return "Unknown"; } +constexpr const char* TranslateVSyncMode(Settings::VSyncMode mode) { + switch (mode) { + case Settings::VSyncMode::Immediate: + return "Immediate"; + case Settings::VSyncMode::FIFO: + return "FIFO"; + case Settings::VSyncMode::Mailbox: + return "Mailbox"; + } + return "Unknown"; +} + u64 GetTelemetryId() { u64 telemetry_id{}; const auto filename = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ConfigDir) / "telemetry_id"; @@ -241,7 +253,8 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader, AddField(field_type, "Renderer_NvdecEmulation", TranslateNvdecEmulation(Settings::values.nvdec_emulation.GetValue())); AddField(field_type, "Renderer_AccelerateASTC", Settings::values.accelerate_astc.GetValue()); - AddField(field_type, "Renderer_UseVsync", Settings::values.use_vsync.GetValue()); + AddField(field_type, "Renderer_UseVsync", + TranslateVSyncMode(Settings::values.vsync_mode.GetValue())); AddField(field_type, "Renderer_ShaderBackend", static_cast(Settings::values.shader_backend.GetValue())); AddField(field_type, "Renderer_UseAsynchronousShaders", diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 23bbea7f1..08d82769c 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -34,21 +34,22 @@ VkSurfaceFormatKHR ChooseSwapSurfaceFormat(vk::Span formats) } VkPresentModeKHR ChooseSwapPresentMode(vk::Span modes) { - // Mailbox (triple buffering) doesn't lock the application like fifo (vsync), - // prefer it if vsync option is not selected - const auto found_mailbox = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR); - if (Settings::values.fullscreen_mode.GetValue() == Settings::FullscreenMode::Borderless && - found_mailbox != modes.end() && !Settings::values.use_vsync.GetValue()) { + // Mailbox (triple buffering) doesn't lock the application like FIFO (vsync) + // FIFO present mode locks the framerate to the monitor's refresh rate + const bool has_mailbox = + std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR) != modes.end(); + const bool has_imm = + std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR) != modes.end(); + const Settings::VSyncMode mode = Settings::values.vsync_mode.GetValue(); + + if (mode == Settings::VSyncMode::Immediate && has_imm) { + LOG_INFO(Render_Vulkan, "Using swap present mode Immediate"); + return VK_PRESENT_MODE_IMMEDIATE_KHR; + } else if (mode == Settings::VSyncMode::Mailbox && has_mailbox) { + LOG_INFO(Render_Vulkan, "Using swap present mode Mailbox"); return VK_PRESENT_MODE_MAILBOX_KHR; } - if (!Settings::values.use_speed_limit.GetValue()) { - // FIFO present mode locks the framerate to the monitor's refresh rate, - // Find an alternative to surpass this limitation if FPS is unlocked. - const auto found_imm = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR); - if (found_imm != modes.end()) { - return VK_PRESENT_MODE_IMMEDIATE_KHR; - } - } + LOG_INFO(Render_Vulkan, "Using swap present mode FIFO"); return VK_PRESENT_MODE_FIFO_KHR; } 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); diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 305891d18..4a8436e5c 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -6,6 +6,7 @@ #include #include "common/fs/fs.h" #include "common/fs/path_util.h" +#include "common/settings.h" #include "core/core.h" #include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/hid/controllers/npad.h" @@ -709,7 +710,6 @@ void Config::ReadRendererValues() { ReadGlobalSetting(Settings::values.nvdec_emulation); ReadGlobalSetting(Settings::values.accelerate_astc); ReadGlobalSetting(Settings::values.async_astc); - ReadGlobalSetting(Settings::values.use_vsync); ReadGlobalSetting(Settings::values.shader_backend); ReadGlobalSetting(Settings::values.use_asynchronous_shaders); ReadGlobalSetting(Settings::values.use_fast_gpu_time); @@ -720,6 +720,10 @@ void Config::ReadRendererValues() { ReadGlobalSetting(Settings::values.bg_blue); if (global) { + Settings::values.vsync_mode.SetValue(static_cast( + ReadSetting(QString::fromStdString(Settings::values.vsync_mode.GetLabel()), + static_cast(Settings::values.vsync_mode.GetDefault())) + .value())); ReadBasicSetting(Settings::values.renderer_debug); ReadBasicSetting(Settings::values.renderer_shader_feedback); ReadBasicSetting(Settings::values.enable_nsight_aftermath); @@ -1352,7 +1356,6 @@ void Config::SaveRendererValues() { Settings::values.nvdec_emulation.UsingGlobal()); WriteGlobalSetting(Settings::values.accelerate_astc); WriteGlobalSetting(Settings::values.async_astc); - WriteGlobalSetting(Settings::values.use_vsync); WriteSetting(QString::fromStdString(Settings::values.shader_backend.GetLabel()), static_cast(Settings::values.shader_backend.GetValue(global)), static_cast(Settings::values.shader_backend.GetDefault()), @@ -1366,6 +1369,9 @@ void Config::SaveRendererValues() { WriteGlobalSetting(Settings::values.bg_blue); if (global) { + WriteSetting(QString::fromStdString(Settings::values.vsync_mode.GetLabel()), + static_cast(Settings::values.vsync_mode.GetValue()), + static_cast(Settings::values.vsync_mode.GetDefault())); WriteBasicSetting(Settings::values.renderer_debug); WriteBasicSetting(Settings::values.renderer_shader_feedback); WriteBasicSetting(Settings::values.enable_nsight_aftermath); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index e9388daad..17a54f0f4 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -99,6 +99,7 @@ void ConfigureGraphics::SetConfiguration() { ui->nvdec_emulation_widget->setEnabled(runtime_lock); ui->resolution_combobox->setEnabled(runtime_lock); ui->accelerate_astc->setEnabled(runtime_lock); + ui->vsync_mode_combobox->setEnabled(runtime_lock); ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue()); ui->use_asynchronous_gpu_emulation->setChecked( Settings::values.use_asynchronous_gpu_emulation.GetValue()); @@ -118,6 +119,9 @@ void ConfigureGraphics::SetConfiguration() { ui->fsr_sharpening_slider->setValue(Settings::values.fsr_sharpening_slider.GetValue()); ui->anti_aliasing_combobox->setCurrentIndex( static_cast(Settings::values.anti_aliasing.GetValue())); + + ui->vsync_mode_combobox->setCurrentIndex( + static_cast(Settings::values.vsync_mode.GetValue())); } else { ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); ConfigurationShared::SetHighlight(ui->api_widget, @@ -232,6 +236,9 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.anti_aliasing.SetValue(anti_aliasing); } Settings::values.fsr_sharpening_slider.SetValue(ui->fsr_sharpening_slider->value()); + + Settings::values.vsync_mode.SetValue( + static_cast(ui->vsync_mode_combobox->currentIndex())); } else { if (ui->resolution_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { Settings::values.resolution_setup.SetGlobal(true); @@ -465,4 +472,6 @@ void ConfigureGraphics::SetupPerGameUI() { ui->api, static_cast(Settings::values.renderer_backend.GetValue(true))); ConfigurationShared::InsertGlobalItem( ui->nvdec_emulation, static_cast(Settings::values.nvdec_emulation.GetValue(true))); + + ui->vsync_mode_layout->setVisible(false); } diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index a45ec69ec..4c241e247 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -188,6 +188,53 @@ + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + VSync Mode + + + + + + + Off (Immediate) + + + + Off (Immediate) + + + + + Double Buffering (FIFO) + + + + + Triple Buffering (Mailbox) + + + + + + + @@ -366,7 +413,7 @@ - 1.5X (1080p/1620p) [EXPERIMENTAL] + 1.5X (1080p/1620p) [EXPERIMENTAL] diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 7f7bf0e4d..4072ce145 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -21,7 +21,6 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; void ConfigureGraphicsAdvanced::SetConfiguration() { const bool runtime_lock = !system.IsPoweredOn(); - ui->use_vsync->setEnabled(runtime_lock); ui->async_present->setEnabled(runtime_lock); ui->renderer_force_max_clock->setEnabled(runtime_lock); ui->async_astc->setEnabled(runtime_lock); @@ -30,7 +29,6 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { ui->async_present->setChecked(Settings::values.async_presentation.GetValue()); ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue()); - ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); ui->async_astc->setChecked(Settings::values.async_astc.GetValue()); ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue()); ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue()); @@ -63,7 +61,6 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() { renderer_force_max_clock); ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy, ui->anisotropic_filtering_combobox); - ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync); ConfigurationShared::ApplyPerGameSetting(&Settings::values.async_astc, ui->async_astc, async_astc); ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_asynchronous_shaders, @@ -97,7 +94,6 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { ui->async_present->setEnabled(Settings::values.async_presentation.UsingGlobal()); ui->renderer_force_max_clock->setEnabled( Settings::values.renderer_force_max_clock.UsingGlobal()); - ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); ui->async_astc->setEnabled(Settings::values.async_astc.UsingGlobal()); ui->use_asynchronous_shaders->setEnabled( Settings::values.use_asynchronous_shaders.UsingGlobal()); @@ -117,7 +113,6 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock, Settings::values.renderer_force_max_clock, renderer_force_max_clock); - ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync); ConfigurationShared::SetColoredTristate(ui->async_astc, Settings::values.async_astc, async_astc); ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders, diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index d7ec18939..134023032 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -86,16 +86,6 @@ - - - - VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference. - - - Use VSync - - - diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index fa347fb8c..a692ef809 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -320,7 +320,7 @@ void Config::ReadValues() { ReadSetting("Renderer", Settings::values.use_disk_shader_cache); ReadSetting("Renderer", Settings::values.gpu_accuracy); ReadSetting("Renderer", Settings::values.use_asynchronous_gpu_emulation); - ReadSetting("Renderer", Settings::values.use_vsync); + ReadSetting("Renderer", Settings::values.vsync_mode); ReadSetting("Renderer", Settings::values.shader_backend); ReadSetting("Renderer", Settings::values.use_asynchronous_shaders); ReadSetting("Renderer", Settings::values.nvdec_emulation); -- cgit v1.2.3 From 66ed1c187202e9d914f8a8d5bb64d672b05f45bb Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 15:46:44 -0400 Subject: default_ini: Update V-Sync description default_ini: Update vsync text default_ini: Add tooltip from configure_graphics --- src/yuzu_cmd/default_ini.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index c0c89fbb9..1990c0707 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -325,8 +325,14 @@ aspect_ratio = # 0: Default, 1: 2x, 2: 4x, 3: 8x, 4: 16x max_anisotropy = -# Whether to enable V-Sync (caps the framerate at 60FPS) or not. -# 0 (default): Off, 1: On +# Whether to enable VSync or not. +# OpenGL: Values other than 0 enable VSync +# Vulkan: FIFO is selected if the requested mode is not supported by the driver. +# FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen refresh rate. +# FIFO Relaxed is similar to FIFO but allows tearing as it recovers from a slow down. +# Mailbox can have lower latency than FIFO and does not tear but may drop frames. +# Immediate (no synchronization) just presents whatever is available and can exhibit tearing. +# 0: Immediate (Off), 1: Mailbox, 2 (Default): FIFO (On), 3: FIFO Relaxed use_vsync = # Selects the OpenGL shader backend. NV_gpu_program5 is required for GLASM. If NV_gpu_program5 is -- cgit v1.2.3 From 41a103c0fc0e2fbcef482b58b606dac5424fd429 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 15:48:20 -0400 Subject: configure_graphics: Fix typo --- src/yuzu/configuration/configure_graphics.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 4c241e247..2856b3bd0 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -206,7 +206,7 @@ - VSync Mode + V-Sync Mode -- 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(+) 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 40f062f7496c916086c4e7e49adc4fb8eb9540d1 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 19:03:37 -0400 Subject: telemetry_session: Make translate function static Addresses review feedback Co-authored-by: Lioncash --- src/core/telemetry_session.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 6ec8e440c..1e60478e2 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -85,7 +85,7 @@ static const char* TranslateNvdecEmulation(Settings::NvdecEmulation backend) { return "Unknown"; } -constexpr const char* TranslateVSyncMode(Settings::VSyncMode mode) { +static constexpr const char* TranslateVSyncMode(Settings::VSyncMode mode) { switch (mode) { case Settings::VSyncMode::Immediate: return "Immediate"; -- cgit v1.2.3 From 6b973c5986ffdbb4c73edf5a18c6eaf8b02d7f32 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 30 Apr 2023 22:28:53 -0400 Subject: configure_graphics: Fix another typo --- src/yuzu/configuration/configure_graphics.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 2856b3bd0..9ad1c88a7 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -206,7 +206,7 @@ - V-Sync Mode + V-Sync Mode: -- cgit v1.2.3 From 2528cf7c5416573fc8bf2e9316a3acc5a2395b79 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:22:37 -0400 Subject: settings: Enable FIFO relaxed Not entirely sure if we need this, but there's also no reason not to support it. settings: Give VSyncMode values --- src/common/settings.h | 11 ++++++----- src/core/telemetry_session.cpp | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/common/settings.h b/src/common/settings.h index 2371495e4..c0faa7406 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -17,9 +17,10 @@ namespace Settings { enum class VSyncMode : u32 { - Immediate, - FIFO, - Mailbox, + Immediate = 0, + Mailbox = 1, + FIFO = 2, + FIFORelaxed = 3, }; enum class RendererBackend : u32 { @@ -461,8 +462,8 @@ struct Values { SwitchableSetting nvdec_emulation{NvdecEmulation::GPU, "nvdec_emulation"}; SwitchableSetting accelerate_astc{true, "accelerate_astc"}; SwitchableSetting async_astc{false, "async_astc"}; - Setting vsync_mode{VSyncMode::FIFO, VSyncMode::Immediate, VSyncMode::Mailbox, - "use_vsync"}; + Setting vsync_mode{VSyncMode::FIFO, VSyncMode::Immediate, + VSyncMode::FIFORelaxed, "use_vsync"}; SwitchableSetting shader_backend{ShaderBackend::GLSL, ShaderBackend::GLSL, ShaderBackend::SPIRV, "shader_backend"}; SwitchableSetting use_asynchronous_shaders{false, "use_asynchronous_shaders"}; diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 1e60478e2..7a2f3c90a 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -89,10 +89,12 @@ static constexpr const char* TranslateVSyncMode(Settings::VSyncMode mode) { switch (mode) { case Settings::VSyncMode::Immediate: return "Immediate"; - case Settings::VSyncMode::FIFO: - return "FIFO"; case Settings::VSyncMode::Mailbox: return "Mailbox"; + case Settings::VSyncMode::FIFO: + return "FIFO"; + case Settings::VSyncMode::FIFORelaxed: + return "FIFO Relaxed"; } return "Unknown"; } -- cgit v1.2.3 From c6c11c1553675bc48a80acf6c966134eb32b5364 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:25:53 -0400 Subject: vulkan_surface: Pass only window info for surface creation We don't need the whole EmuWindow when creating a surface, and it creates onerous requirements outside of typical usage for creating a surface elsewhere. --- src/video_core/renderer_vulkan/renderer_vulkan.cpp | 2 +- src/video_core/vulkan_common/vulkan_surface.cpp | 6 +++--- src/video_core/vulkan_common/vulkan_surface.h | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 69dc76180..94ae2a2f8 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -88,7 +88,7 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_, instance(CreateInstance(library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type, Settings::values.renderer_debug.GetValue())), debug_callback(Settings::values.renderer_debug ? CreateDebugCallback(instance) : nullptr), - surface(CreateSurface(instance, render_window)), + surface(CreateSurface(instance, render_window.GetWindowInfo())), device(CreateDevice(instance, dld, *surface)), memory_allocator(device, false), state_tracker(), scheduler(device, state_tracker), swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width, diff --git a/src/video_core/vulkan_common/vulkan_surface.cpp b/src/video_core/vulkan_common/vulkan_surface.cpp index fa9bafa20..c34599365 100644 --- a/src/video_core/vulkan_common/vulkan_surface.cpp +++ b/src/video_core/vulkan_common/vulkan_surface.cpp @@ -23,10 +23,10 @@ namespace Vulkan { -vk::SurfaceKHR CreateSurface(const vk::Instance& instance, - const Core::Frontend::EmuWindow& emu_window) { +vk::SurfaceKHR CreateSurface( + const vk::Instance& instance, + [[maybe_unused]] const Core::Frontend::EmuWindow::WindowSystemInfo& window_info) { [[maybe_unused]] const vk::InstanceDispatch& dld = instance.Dispatch(); - [[maybe_unused]] const auto& window_info = emu_window.GetWindowInfo(); VkSurfaceKHR unsafe_surface = nullptr; #ifdef _WIN32 diff --git a/src/video_core/vulkan_common/vulkan_surface.h b/src/video_core/vulkan_common/vulkan_surface.h index 5725143e6..5e18c06c4 100644 --- a/src/video_core/vulkan_common/vulkan_surface.h +++ b/src/video_core/vulkan_common/vulkan_surface.h @@ -3,15 +3,12 @@ #pragma once +#include "core/frontend/emu_window.h" #include "video_core/vulkan_common/vulkan_wrapper.h" -namespace Core::Frontend { -class EmuWindow; -} - namespace Vulkan { -[[nodiscard]] vk::SurfaceKHR CreateSurface(const vk::Instance& instance, - const Core::Frontend::EmuWindow& emu_window); +[[nodiscard]] vk::SurfaceKHR CreateSurface( + const vk::Instance& instance, const Core::Frontend::EmuWindow::WindowSystemInfo& window_info); } // namespace Vulkan -- 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/CMakeLists.txt | 2 ++ src/yuzu/bootmanager.cpp | 47 +++-------------------------------------- src/yuzu/qt_common.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ src/yuzu/qt_common.h | 15 +++++++++++++ 4 files changed, 75 insertions(+), 44 deletions(-) create mode 100644 src/yuzu/qt_common.cpp create mode 100644 src/yuzu/qt_common.h diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 0f8c1e6a6..2d7b9ab65 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -189,6 +189,8 @@ add_executable(yuzu multiplayer/state.h multiplayer/validation.h precompiled_headers.h + qt_common.cpp + qt_common.h startup_checks.cpp startup_checks.h uisettings.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); diff --git a/src/yuzu/qt_common.cpp b/src/yuzu/qt_common.cpp new file mode 100644 index 000000000..1b533ee40 --- /dev/null +++ b/src/yuzu/qt_common.cpp @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include +#include +#include +#include "common/logging/log.h" +#include "core/frontend/emu_window.h" +#include "yuzu/qt_common.h" + +#ifdef __linux__ +#include +#endif + +namespace YuzuQtCommon { +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; +} // namespace Core::Frontend::WindowSystemType + +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; +} +} // namespace YuzuQtCommon diff --git a/src/yuzu/qt_common.h b/src/yuzu/qt_common.h new file mode 100644 index 000000000..b366adee6 --- /dev/null +++ b/src/yuzu/qt_common.h @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: 2023 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include "core/frontend/emu_window.h" + +namespace YuzuQtCommon { + +Core::Frontend::WindowSystemType GetWindowSystemType(); + +Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window); + +} // namespace YuzuQtCommon -- 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 ++----------- src/yuzu/bootmanager.h | 1 + 2 files changed, 3 insertions(+), 11 deletions(-) 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); diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index bb4eca07f..8a69cf973 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -14,6 +14,7 @@ #include #include +#include "common/logging/log.h" #include "common/polyfill_thread.h" #include "common/thread.h" #include "core/frontend/emu_window.h" -- cgit v1.2.3 From 952b2710920fdeef705a357762a7925483d27d20 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:31:22 -0400 Subject: vk_swapchain: Use certain modes for unlocked Uses mailbox, then immediate for unlocked framerate depending on support for either. Also adds support for FIFO_RELAXED. This function now assumes vsync_mode was originially configured to a value that the driver supports. vk_swapchain: ChooseSwapPresentMode determines updates Simplifies swapchain a bit and allows us to change the present mode during guest runtime. vk_swapchain: Fix MSVC error vk_swapchain: Enforce available present modes Some frontends don't check the value of vsync_mode before comitting it. Just as well, since a driver update or misconfiguration could problems in the swap chain. vk_swapchain: Silence warnings Silences GCC warnings implicit-fallthrough and shadow, which apparently are not enabled on clang. --- src/video_core/renderer_vulkan/vk_swapchain.cpp | 70 +++++++++++++++++-------- src/video_core/renderer_vulkan/vk_swapchain.h | 6 +-- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp index 08d82769c..1e80ce463 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.cpp +++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp @@ -14,6 +14,7 @@ #include "video_core/renderer_vulkan/vk_swapchain.h" #include "video_core/vulkan_common/vulkan_device.h" #include "video_core/vulkan_common/vulkan_wrapper.h" +#include "vulkan/vulkan_core.h" namespace Vulkan { @@ -33,24 +34,47 @@ VkSurfaceFormatKHR ChooseSwapSurfaceFormat(vk::Span formats) return found != formats.end() ? *found : formats[0]; } -VkPresentModeKHR ChooseSwapPresentMode(vk::Span modes) { - // Mailbox (triple buffering) doesn't lock the application like FIFO (vsync) +static constexpr VkPresentModeKHR ChooseSwapPresentMode(bool has_imm, bool has_mailbox, + bool has_fifo_relaxed) { + // Mailbox doesn't lock the application like FIFO (vsync) // FIFO present mode locks the framerate to the monitor's refresh rate - const bool has_mailbox = - std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR) != modes.end(); - const bool has_imm = - std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_IMMEDIATE_KHR) != modes.end(); - const Settings::VSyncMode mode = Settings::values.vsync_mode.GetValue(); + Settings::VSyncMode setting = [has_imm, has_mailbox]() { + // Choose Mailbox or Immediate if unlocked and those modes are supported + const auto mode = Settings::values.vsync_mode.GetValue(); + if (Settings::values.use_speed_limit.GetValue()) { + return mode; + } + switch (mode) { + case Settings::VSyncMode::FIFO: + case Settings::VSyncMode::FIFORelaxed: + if (has_mailbox) { + return Settings::VSyncMode::Mailbox; + } else if (has_imm) { + return Settings::VSyncMode::Immediate; + } + [[fallthrough]]; + default: + return mode; + } + }(); + if ((setting == Settings::VSyncMode::Mailbox && !has_mailbox) || + (setting == Settings::VSyncMode::Immediate && !has_imm) || + (setting == Settings::VSyncMode::FIFORelaxed && !has_fifo_relaxed)) { + setting = Settings::VSyncMode::FIFO; + } - if (mode == Settings::VSyncMode::Immediate && has_imm) { - LOG_INFO(Render_Vulkan, "Using swap present mode Immediate"); + switch (setting) { + case Settings::VSyncMode::Immediate: return VK_PRESENT_MODE_IMMEDIATE_KHR; - } else if (mode == Settings::VSyncMode::Mailbox && has_mailbox) { - LOG_INFO(Render_Vulkan, "Using swap present mode Mailbox"); + case Settings::VSyncMode::Mailbox: return VK_PRESENT_MODE_MAILBOX_KHR; + case Settings::VSyncMode::FIFO: + return VK_PRESENT_MODE_FIFO_KHR; + case Settings::VSyncMode::FIFORelaxed: + return VK_PRESENT_MODE_FIFO_RELAXED_KHR; + default: + return VK_PRESENT_MODE_FIFO_KHR; } - LOG_INFO(Render_Vulkan, "Using swap present mode FIFO"); - return VK_PRESENT_MODE_FIFO_KHR; } VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, u32 width, u32 height) { @@ -168,11 +192,17 @@ void Swapchain::Present(VkSemaphore render_semaphore) { void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, bool srgb) { const auto physical_device{device.GetPhysical()}; const auto formats{physical_device.GetSurfaceFormatsKHR(surface)}; - const auto present_modes{physical_device.GetSurfacePresentModesKHR(surface)}; + const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface); + has_mailbox = std::find(present_modes.begin(), present_modes.end(), + VK_PRESENT_MODE_MAILBOX_KHR) != present_modes.end(); + has_imm = std::find(present_modes.begin(), present_modes.end(), + VK_PRESENT_MODE_IMMEDIATE_KHR) != present_modes.end(); + has_fifo_relaxed = std::find(present_modes.begin(), present_modes.end(), + VK_PRESENT_MODE_FIFO_RELAXED_KHR) != present_modes.end(); const VkCompositeAlphaFlagBitsKHR alpha_flags{ChooseAlphaFlags(capabilities)}; surface_format = ChooseSwapSurfaceFormat(formats); - present_mode = ChooseSwapPresentMode(present_modes); + present_mode = ChooseSwapPresentMode(has_imm, has_mailbox, has_fifo_relaxed); u32 requested_image_count{capabilities.minImageCount + 1}; // Ensure Triple buffering if possible. @@ -233,7 +263,6 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities, bo extent = swapchain_ci.imageExtent; current_srgb = srgb; - current_fps_unlocked = !Settings::values.use_speed_limit.GetValue(); images = swapchain.GetImages(); image_count = static_cast(images.size()); @@ -255,14 +284,9 @@ void Swapchain::Destroy() { swapchain.reset(); } -bool Swapchain::HasFpsUnlockChanged() const { - return current_fps_unlocked != !Settings::values.use_speed_limit.GetValue(); -} - bool Swapchain::NeedsPresentModeUpdate() const { - // Mailbox present mode is the ideal for all scenarios. If it is not available, - // A different present mode is needed to support unlocked FPS above the monitor's refresh rate. - return present_mode != VK_PRESENT_MODE_MAILBOX_KHR && HasFpsUnlockChanged(); + const auto requested_mode = ChooseSwapPresentMode(has_imm, has_mailbox, has_fifo_relaxed); + return present_mode != requested_mode; } } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_swapchain.h b/src/video_core/renderer_vulkan/vk_swapchain.h index 419742586..bf1ea7254 100644 --- a/src/video_core/renderer_vulkan/vk_swapchain.h +++ b/src/video_core/renderer_vulkan/vk_swapchain.h @@ -116,8 +116,6 @@ private: void Destroy(); - bool HasFpsUnlockChanged() const; - bool NeedsPresentModeUpdate() const; const VkSurfaceKHR surface; @@ -142,9 +140,11 @@ private: VkExtent2D extent{}; VkPresentModeKHR present_mode{}; VkSurfaceFormatKHR surface_format{}; + bool has_imm{false}; + bool has_mailbox{false}; + bool has_fifo_relaxed{false}; bool current_srgb{}; - bool current_fps_unlocked{}; bool is_outdated{}; bool is_suboptimal{}; }; -- cgit v1.2.3 From a546ecbb1241a28b808d3a9ebe1a55f001c267ed Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 1 May 2023 20:36:23 -0400 Subject: configure_graphics: Actively find present modes When Vulkan devices are enumerated, this also determines the available present modes for each device, maps them to a vector, and gives those options to the user. OpenGL options are limited to On/Off. Required creating a VkSurfaceKHR during device enumeration, which may or may not be desireable. For the sake of a less confusing UI. Also fixes a bug where if a graphics device disappears on the host, we don't try and select the non-existant devices. configure_graphics: Remove vsync runtime lock for Vulkan configure_graphics: Recommend Mailbox present mode configure_graphics: Fix type-limits warning configure_graphics: Clean up includes configure_graphics: Add tooltip --- src/yuzu/configuration/configure_graphics.cpp | 155 ++++++++++++++++++++++++-- src/yuzu/configuration/configure_graphics.h | 10 ++ src/yuzu/configuration/configure_graphics.ui | 23 ++-- 3 files changed, 161 insertions(+), 27 deletions(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 17a54f0f4..3e3398f42 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -4,20 +4,62 @@ // Include this early to include Vulkan headers how we want to #include "video_core/vulkan_common/vulkan_wrapper.h" +#include #include +#include #include +#include +#include +#include "bootmanager.h" #include "common/common_types.h" #include "common/logging/log.h" #include "common/settings.h" #include "core/core.h" +#include "core/frontend/emu_window.h" #include "ui_configure_graphics.h" #include "video_core/vulkan_common/vulkan_instance.h" #include "video_core/vulkan_common/vulkan_library.h" +#include "video_core/vulkan_common/vulkan_surface.h" #include "yuzu/configuration/configuration_shared.h" #include "yuzu/configuration/configure_graphics.h" +#include "yuzu/qt_common.h" #include "yuzu/uisettings.h" +static const std::vector default_present_modes{VK_PRESENT_MODE_IMMEDIATE_KHR, + VK_PRESENT_MODE_FIFO_KHR}; + +// Converts a setting to a present mode (or vice versa) +static constexpr VkPresentModeKHR VSyncSettingToMode(Settings::VSyncMode mode) { + switch (mode) { + case Settings::VSyncMode::Immediate: + return VK_PRESENT_MODE_IMMEDIATE_KHR; + case Settings::VSyncMode::Mailbox: + return VK_PRESENT_MODE_MAILBOX_KHR; + case Settings::VSyncMode::FIFO: + return VK_PRESENT_MODE_FIFO_KHR; + case Settings::VSyncMode::FIFORelaxed: + return VK_PRESENT_MODE_FIFO_RELAXED_KHR; + default: + return VK_PRESENT_MODE_FIFO_KHR; + } +} + +static constexpr Settings::VSyncMode PresentModeToSetting(VkPresentModeKHR mode) { + switch (mode) { + case VK_PRESENT_MODE_IMMEDIATE_KHR: + return Settings::VSyncMode::Immediate; + case VK_PRESENT_MODE_MAILBOX_KHR: + return Settings::VSyncMode::Mailbox; + case VK_PRESENT_MODE_FIFO_KHR: + return Settings::VSyncMode::FIFO; + case VK_PRESENT_MODE_FIFO_RELAXED_KHR: + return Settings::VSyncMode::FIFORelaxed; + default: + return Settings::VSyncMode::FIFO; + } +} + ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* parent) : QWidget(parent), ui{std::make_unique()}, system{system_} { vulkan_device = Settings::values.vulkan_device.GetValue(); @@ -39,13 +81,16 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren connect(ui->api, qOverload(&QComboBox::currentIndexChanged), this, [this] { UpdateAPILayout(); + PopulateVSyncModeSelection(); if (!Settings::IsConfiguringGlobal()) { ConfigurationShared::SetHighlight( ui->api_widget, ui->api->currentIndex() != ConfigurationShared::USE_GLOBAL_INDEX); } }); - connect(ui->device, qOverload(&QComboBox::activated), this, - [this](int device) { UpdateDeviceSelection(device); }); + connect(ui->device, qOverload(&QComboBox::activated), this, [this](int device) { + UpdateDeviceSelection(device); + PopulateVSyncModeSelection(); + }); connect(ui->backend, qOverload(&QComboBox::activated), this, [this](int backend) { UpdateShaderBackendSelection(backend); }); @@ -70,6 +115,43 @@ ConfigureGraphics::ConfigureGraphics(const Core::System& system_, QWidget* paren ui->fsr_sharpening_label->setVisible(Settings::IsConfiguringGlobal()); } +void ConfigureGraphics::PopulateVSyncModeSelection() { + const Settings::RendererBackend backend{GetCurrentGraphicsBackend()}; + if (backend == Settings::RendererBackend::Null) { + ui->vsync_mode_combobox->setEnabled(false); + return; + } + ui->vsync_mode_combobox->setEnabled(true); + + const int current_index = //< current selected vsync mode from combobox + ui->vsync_mode_combobox->currentIndex(); + const auto current_mode = //< current selected vsync mode as a VkPresentModeKHR + current_index == -1 ? VSyncSettingToMode(Settings::values.vsync_mode.GetValue()) + : vsync_mode_combobox_enum_map[current_index]; + int index{}; + const int device{ui->device->currentIndex()}; //< current selected Vulkan device + const auto& present_modes = //< relevant vector of present modes for the selected device or API + backend == Settings::RendererBackend::Vulkan ? device_present_modes[device] + : default_present_modes; + + ui->vsync_mode_combobox->clear(); + vsync_mode_combobox_enum_map.clear(); + vsync_mode_combobox_enum_map.reserve(present_modes.size()); + for (const auto present_mode : present_modes) { + const auto mode_name = TranslateVSyncMode(present_mode, backend); + if (mode_name.isEmpty()) { + continue; + } + + ui->vsync_mode_combobox->insertItem(index, mode_name); + vsync_mode_combobox_enum_map.push_back(present_mode); + if (present_mode == current_mode) { + ui->vsync_mode_combobox->setCurrentIndex(index); + } + index++; + } +} + void ConfigureGraphics::UpdateDeviceSelection(int device) { if (device == -1) { return; @@ -99,7 +181,9 @@ void ConfigureGraphics::SetConfiguration() { ui->nvdec_emulation_widget->setEnabled(runtime_lock); ui->resolution_combobox->setEnabled(runtime_lock); ui->accelerate_astc->setEnabled(runtime_lock); - ui->vsync_mode_combobox->setEnabled(runtime_lock); + ui->vsync_mode_layout->setEnabled(runtime_lock || + Settings::values.renderer_backend.GetValue() == + Settings::RendererBackend::Vulkan); ui->use_disk_shader_cache->setChecked(Settings::values.use_disk_shader_cache.GetValue()); ui->use_asynchronous_gpu_emulation->setChecked( Settings::values.use_asynchronous_gpu_emulation.GetValue()); @@ -119,9 +203,6 @@ void ConfigureGraphics::SetConfiguration() { ui->fsr_sharpening_slider->setValue(Settings::values.fsr_sharpening_slider.GetValue()); ui->anti_aliasing_combobox->setCurrentIndex( static_cast(Settings::values.anti_aliasing.GetValue())); - - ui->vsync_mode_combobox->setCurrentIndex( - static_cast(Settings::values.vsync_mode.GetValue())); } else { ConfigurationShared::SetPerGameSetting(ui->api, &Settings::values.renderer_backend); ConfigurationShared::SetHighlight(ui->api_widget, @@ -174,7 +255,24 @@ void ConfigureGraphics::SetConfiguration() { Settings::values.bg_green.GetValue(), Settings::values.bg_blue.GetValue())); UpdateAPILayout(); + PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout SetFSRIndicatorText(ui->fsr_sharpening_slider->sliderPosition()); + + // V-Sync setting needs to be determined after populating the V-Sync combobox + if (Settings::IsConfiguringGlobal()) { + const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue(); + const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting); + int index{}; + for (const auto mode : vsync_mode_combobox_enum_map) { + if (mode == vsync_mode) { + break; + } + index++; + } + if (static_cast(index) < vsync_mode_combobox_enum_map.size()) { + ui->vsync_mode_combobox->setCurrentIndex(index); + } + } } void ConfigureGraphics::SetFSRIndicatorText(int percentage) { @@ -182,6 +280,27 @@ void ConfigureGraphics::SetFSRIndicatorText(int percentage) { tr("%1%", "FSR sharpening percentage (e.g. 50%)").arg(100 - (percentage / 2))); } +const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, + Settings::RendererBackend backend) const { + switch (mode) { + case VK_PRESENT_MODE_IMMEDIATE_KHR: + return backend == Settings::RendererBackend::OpenGL + ? tr("Off") + : QStringLiteral("Immediate (%1)").arg(tr("V-Sync Off")); + case VK_PRESENT_MODE_MAILBOX_KHR: + return QStringLiteral("Mailbox (%1)").arg(tr("Recommended")); + case VK_PRESENT_MODE_FIFO_KHR: + return backend == Settings::RendererBackend::OpenGL + ? tr("On") + : QStringLiteral("FIFO (%1)").arg(tr("V-Sync On")); + case VK_PRESENT_MODE_FIFO_RELAXED_KHR: + return QStringLiteral("FIFO Relaxed"); + default: + return {}; + break; + } +} + void ConfigureGraphics::ApplyConfiguration() { const auto resolution_setup = static_cast( ui->resolution_combobox->currentIndex() - @@ -237,8 +356,9 @@ void ConfigureGraphics::ApplyConfiguration() { } Settings::values.fsr_sharpening_slider.SetValue(ui->fsr_sharpening_slider->value()); - Settings::values.vsync_mode.SetValue( - static_cast(ui->vsync_mode_combobox->currentIndex())); + const auto mode = vsync_mode_combobox_enum_map[ui->vsync_mode_combobox->currentIndex()]; + const auto vsync_mode = PresentModeToSetting(mode); + Settings::values.vsync_mode.SetValue(vsync_mode); } else { if (ui->resolution_combobox->currentIndex() == ConfigurationShared::USE_GLOBAL_INDEX) { Settings::values.resolution_setup.SetGlobal(true); @@ -352,7 +472,9 @@ void ConfigureGraphics::UpdateAPILayout() { ui->backend_widget->setVisible(true); break; case Settings::RendererBackend::Vulkan: - ui->device->setCurrentIndex(vulkan_device); + if (static_cast(vulkan_device) < ui->device->count()) { + ui->device->setCurrentIndex(vulkan_device); + } ui->device_widget->setVisible(true); ui->backend_widget->setVisible(false); break; @@ -370,16 +492,27 @@ void ConfigureGraphics::RetrieveVulkanDevices() try { using namespace Vulkan; + auto* window = this->window()->windowHandle(); + auto wsi = YuzuQtCommon::GetWindowSystemInfo(window); + vk::InstanceDispatch dld; const Common::DynamicLibrary library = OpenLibrary(); - const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1); + const vk::Instance instance = CreateInstance(library, dld, VK_API_VERSION_1_1, wsi.type); const std::vector physical_devices = instance.EnumeratePhysicalDevices(); + vk::SurfaceKHR surface = //< needed to view present modes for a device + CreateSurface(instance, wsi); vulkan_devices.clear(); vulkan_devices.reserve(physical_devices.size()); + device_present_modes.clear(); + device_present_modes.reserve(physical_devices.size()); for (const VkPhysicalDevice device : physical_devices) { - const std::string name = vk::PhysicalDevice(device, dld).GetProperties().deviceName; + const auto physical_device = vk::PhysicalDevice(device, dld); + const std::string name = physical_device.GetProperties().deviceName; + const std::vector present_modes = + physical_device.GetSurfacePresentModesKHR(*surface); vulkan_devices.push_back(QString::fromStdString(name)); + device_present_modes.push_back(present_modes); } } catch (const Vulkan::vk::Exception& exception) { LOG_ERROR(Frontend, "Failed to enumerate devices with error: {}", exception.what()); diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index d98d6624e..6d8002de2 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "common/settings.h" namespace Core { @@ -35,6 +36,7 @@ private: void changeEvent(QEvent* event) override; void RetranslateUI(); + void PopulateVSyncModeSelection(); void UpdateBackgroundColorButton(QColor color); void UpdateAPILayout(); void UpdateDeviceSelection(int device); @@ -43,6 +45,10 @@ private: void RetrieveVulkanDevices(); void SetFSRIndicatorText(int percentage); + /* Turns a Vulkan present mode into a textual string for a UI + * (and eventually for a human to read) */ + const QString TranslateVSyncMode(VkPresentModeKHR mode, + Settings::RendererBackend backend) const; void SetupPerGameUI(); @@ -58,6 +64,10 @@ private: ConfigurationShared::CheckState use_asynchronous_gpu_emulation; std::vector vulkan_devices; + std::vector> device_present_modes; + std::vector + vsync_mode_combobox_enum_map; //< Keeps track of which present mode corresponds to which + // selection in the combobox u32 vulkan_device{}; Settings::ShaderBackend shader_backend{}; diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 9ad1c88a7..94eba6c7e 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -212,24 +212,15 @@ + + FIFO (V-Sync) does not drop frames or exhibit tearing but is limited by the screen refresh rate. +FIFO Relaxed is similar to FIFO but allows tearing as it recovers from a slow down. +Mailbox can have lower latency than FIFO and does not tear but may drop frames. +Immediate (no synchronization) just presents whatever is available and can exhibit tearing. + - Off (Immediate) + - - - Off (Immediate) - - - - - Double Buffering (FIFO) - - - - - Triple Buffering (Mailbox) - - -- 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 +++++++++++++++++++++++++++++----------- src/yuzu/bootmanager.h | 25 +++++++++++++++++++++---- 2 files changed, 50 insertions(+), 15 deletions(-) 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; diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index 8a69cf973..4276be82b 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h @@ -5,28 +5,46 @@ #include #include +#include #include #include +#include +#include +#include +#include #include +#include +#include +#include #include #include -#include #include +#include +#include +#include +#include "common/common_types.h" #include "common/logging/log.h" #include "common/polyfill_thread.h" #include "common/thread.h" #include "core/frontend/emu_window.h" -class GRenderWindow; class GMainWindow; class QCamera; class QCameraImageCapture; +class QCloseEvent; +class QFocusEvent; class QKeyEvent; +class QMouseEvent; +class QObject; +class QResizeEvent; +class QShowEvent; +class QTimer; +class QTouchEvent; +class QWheelEvent; namespace Core { -enum class SystemResultStatus : u32; class System; } // namespace Core @@ -41,7 +59,6 @@ enum class TasState; namespace VideoCore { enum class LoadCallbackStage; -class RendererBase; } // namespace VideoCore class EmuThread final : public QThread { -- cgit v1.2.3 From cd2981ee125bb4fac48b8acd31a3bd921cc362c4 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 2 May 2023 16:54:32 -0400 Subject: configure_graphics: Clean up includes [IWYU] --- src/yuzu/configuration/configure_graphics.cpp | 24 +++++++++++++++++++----- src/yuzu/configuration/configure_graphics.h | 13 ++++++++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 3e3398f42..4a4a7bb0b 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -4,19 +4,33 @@ // Include this early to include Vulkan headers how we want to #include "video_core/vulkan_common/vulkan_wrapper.h" +#include +#include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include "bootmanager.h" #include "common/common_types.h" +#include "common/dynamic_library.h" #include "common/logging/log.h" #include "common/settings.h" #include "core/core.h" -#include "core/frontend/emu_window.h" #include "ui_configure_graphics.h" #include "video_core/vulkan_common/vulkan_instance.h" #include "video_core/vulkan_common/vulkan_library.h" diff --git a/src/yuzu/configuration/configure_graphics.h b/src/yuzu/configuration/configure_graphics.h index 6d8002de2..901f604a5 100644 --- a/src/yuzu/configuration/configure_graphics.h +++ b/src/yuzu/configuration/configure_graphics.h @@ -5,10 +5,21 @@ #include #include +#include #include #include +#include #include -#include "common/settings.h" +#include "common/common_types.h" + +class QEvent; +class QObject; + +namespace Settings { +enum class NvdecEmulation : u32; +enum class RendererBackend : u32; +enum class ShaderBackend : u32; +} // namespace Settings namespace Core { class System; -- cgit v1.2.3 From d82cad3fb3c03e678a5f1b34ab4a97b70611b081 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 2 May 2023 18:49:18 -0400 Subject: configure_input_player: Add missing include Cleaning up includes in bootmanager and configure_graphics has exposed a missing include here. --- src/yuzu/configuration/configure_input_player.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 50b62293e..a21a3eaa9 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "common/assert.h" #include "common/param_package.h" -- cgit v1.2.3 From 35e7f36a39775c48ba2c8ed6b5a52dcbbe381a19 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Tue, 2 May 2023 19:22:54 -0400 Subject: configure_graphics: No there isn't a hyphen in VSync Most sources seem to suggest VSync and not V-Sync --- src/yuzu/configuration/configure_graphics.cpp | 6 +++--- src/yuzu/configuration/configure_graphics.ui | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 4a4a7bb0b..6f5bc8d90 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -272,7 +272,7 @@ void ConfigureGraphics::SetConfiguration() { PopulateVSyncModeSelection(); //< must happen after UpdateAPILayout SetFSRIndicatorText(ui->fsr_sharpening_slider->sliderPosition()); - // V-Sync setting needs to be determined after populating the V-Sync combobox + // VSync setting needs to be determined after populating the VSync combobox if (Settings::IsConfiguringGlobal()) { const auto vsync_mode_setting = Settings::values.vsync_mode.GetValue(); const auto vsync_mode = VSyncSettingToMode(vsync_mode_setting); @@ -300,13 +300,13 @@ const QString ConfigureGraphics::TranslateVSyncMode(VkPresentModeKHR mode, case VK_PRESENT_MODE_IMMEDIATE_KHR: return backend == Settings::RendererBackend::OpenGL ? tr("Off") - : QStringLiteral("Immediate (%1)").arg(tr("V-Sync Off")); + : QStringLiteral("Immediate (%1)").arg(tr("VSync Off")); case VK_PRESENT_MODE_MAILBOX_KHR: return QStringLiteral("Mailbox (%1)").arg(tr("Recommended")); case VK_PRESENT_MODE_FIFO_KHR: return backend == Settings::RendererBackend::OpenGL ? tr("On") - : QStringLiteral("FIFO (%1)").arg(tr("V-Sync On")); + : QStringLiteral("FIFO (%1)").arg(tr("VSync On")); case VK_PRESENT_MODE_FIFO_RELAXED_KHR: return QStringLiteral("FIFO Relaxed"); default: diff --git a/src/yuzu/configuration/configure_graphics.ui b/src/yuzu/configuration/configure_graphics.ui index 94eba6c7e..39f70e406 100644 --- a/src/yuzu/configuration/configure_graphics.ui +++ b/src/yuzu/configuration/configure_graphics.ui @@ -206,14 +206,14 @@ - V-Sync Mode: + VSync Mode: - FIFO (V-Sync) does not drop frames or exhibit tearing but is limited by the screen refresh rate. + FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen refresh rate. FIFO Relaxed is similar to FIFO but allows tearing as it recovers from a slow down. Mailbox can have lower latency than FIFO and does not tear but may drop frames. Immediate (no synchronization) just presents whatever is available and can exhibit tearing. -- 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 ++-- src/yuzu/configuration/configure_graphics.cpp | 2 +- src/yuzu/qt_common.cpp | 4 ++-- src/yuzu/qt_common.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) 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); diff --git a/src/yuzu/configuration/configure_graphics.cpp b/src/yuzu/configuration/configure_graphics.cpp index 6f5bc8d90..76e5b7499 100644 --- a/src/yuzu/configuration/configure_graphics.cpp +++ b/src/yuzu/configuration/configure_graphics.cpp @@ -507,7 +507,7 @@ void ConfigureGraphics::RetrieveVulkanDevices() try { using namespace Vulkan; auto* window = this->window()->windowHandle(); - auto wsi = YuzuQtCommon::GetWindowSystemInfo(window); + auto wsi = QtCommon::GetWindowSystemInfo(window); vk::InstanceDispatch dld; const Common::DynamicLibrary library = OpenLibrary(); diff --git a/src/yuzu/qt_common.cpp b/src/yuzu/qt_common.cpp index 1b533ee40..5ac9fe310 100644 --- a/src/yuzu/qt_common.cpp +++ b/src/yuzu/qt_common.cpp @@ -12,7 +12,7 @@ #include #endif -namespace YuzuQtCommon { +namespace QtCommon { Core::Frontend::WindowSystemType GetWindowSystemType() { // Determine WSI type based on Qt platform. QString platform_name = QGuiApplication::platformName(); @@ -52,4 +52,4 @@ Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window) return wsi; } -} // namespace YuzuQtCommon +} // namespace QtCommon diff --git a/src/yuzu/qt_common.h b/src/yuzu/qt_common.h index b366adee6..9c63f08f3 100644 --- a/src/yuzu/qt_common.h +++ b/src/yuzu/qt_common.h @@ -6,10 +6,10 @@ #include #include "core/frontend/emu_window.h" -namespace YuzuQtCommon { +namespace QtCommon { Core::Frontend::WindowSystemType GetWindowSystemType(); Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow* window); -} // namespace YuzuQtCommon +} // namespace QtCommon -- cgit v1.2.3