diff options
| author | 2023-05-01 23:12:28 +0300 | |
|---|---|---|
| committer | 2023-05-01 23:13:24 +0300 | |
| commit | f403d2794187bd136fb4d30fb7a6aea950145013 (patch) | |
| tree | 0e78d295ae6cbe48dc5ab76b96424044e90dad5b /src | |
| parent | vk_blit_screen: Recreate FSR when frame is recreated (diff) | |
| download | yuzu-f403d2794187bd136fb4d30fb7a6aea950145013.tar.gz yuzu-f403d2794187bd136fb4d30fb7a6aea950145013.tar.xz yuzu-f403d2794187bd136fb4d30fb7a6aea950145013.zip | |
vk_present_manager: Add toggle for async presentation
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.cpp | 1 | ||||
| -rw-r--r-- | src/common/settings.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_present_manager.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_present_manager.h | 3 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.cpp | 7 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.h | 1 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_graphics_advanced.ui | 15 | ||||
| -rw-r--r-- | src/yuzu_cmd/config.cpp | 1 | ||||
| -rw-r--r-- | src/yuzu_cmd/default_ini.h | 4 |
10 files changed, 45 insertions, 6 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 84955030b..77ff21128 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -205,6 +205,7 @@ void RestoreGlobalState(bool is_powered_on) { | |||
| 205 | // Renderer | 205 | // Renderer |
| 206 | values.fsr_sharpening_slider.SetGlobal(true); | 206 | values.fsr_sharpening_slider.SetGlobal(true); |
| 207 | values.renderer_backend.SetGlobal(true); | 207 | values.renderer_backend.SetGlobal(true); |
| 208 | values.async_presentation.SetGlobal(true); | ||
| 208 | values.renderer_force_max_clock.SetGlobal(true); | 209 | values.renderer_force_max_clock.SetGlobal(true); |
| 209 | values.vulkan_device.SetGlobal(true); | 210 | values.vulkan_device.SetGlobal(true); |
| 210 | values.fullscreen_mode.SetGlobal(true); | 211 | values.fullscreen_mode.SetGlobal(true); |
diff --git a/src/common/settings.h b/src/common/settings.h index b77a1580a..5379d0dd5 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -422,6 +422,7 @@ struct Values { | |||
| 422 | // Renderer | 422 | // Renderer |
| 423 | SwitchableSetting<RendererBackend, true> renderer_backend{ | 423 | SwitchableSetting<RendererBackend, true> renderer_backend{ |
| 424 | RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"}; | 424 | RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"}; |
| 425 | SwitchableSetting<bool> async_presentation{false, "async_presentation"}; | ||
| 425 | SwitchableSetting<bool> renderer_force_max_clock{false, "force_max_clock"}; | 426 | SwitchableSetting<bool> renderer_force_max_clock{false, "force_max_clock"}; |
| 426 | Setting<bool> renderer_debug{false, "debug"}; | 427 | Setting<bool> renderer_debug{false, "debug"}; |
| 427 | Setting<bool> renderer_shader_feedback{false, "shader_feedback"}; | 428 | Setting<bool> renderer_shader_feedback{false, "shader_feedback"}; |
diff --git a/src/video_core/renderer_vulkan/vk_present_manager.cpp b/src/video_core/renderer_vulkan/vk_present_manager.cpp index 0b8e8ad27..a137c66f2 100644 --- a/src/video_core/renderer_vulkan/vk_present_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/microprofile.h" | 4 | #include "common/microprofile.h" |
| 5 | #include "common/settings.h" | ||
| 5 | #include "common/thread.h" | 6 | #include "common/thread.h" |
| 6 | #include "video_core/renderer_vulkan/vk_present_manager.h" | 7 | #include "video_core/renderer_vulkan/vk_present_manager.h" |
| 7 | #include "video_core/renderer_vulkan/vk_scheduler.h" | 8 | #include "video_core/renderer_vulkan/vk_scheduler.h" |
| @@ -97,6 +98,7 @@ PresentManager::PresentManager(Core::Frontend::EmuWindow& render_window_, const | |||
| 97 | : render_window{render_window_}, device{device_}, | 98 | : render_window{render_window_}, device{device_}, |
| 98 | memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, | 99 | memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, |
| 99 | blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, | 100 | blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, |
| 101 | use_present_thread{Settings::values.async_presentation.GetValue()}, | ||
| 100 | image_count{swapchain.GetImageCount()} { | 102 | image_count{swapchain.GetImageCount()} { |
| 101 | 103 | ||
| 102 | auto& dld = device.GetLogical(); | 104 | auto& dld = device.GetLogical(); |
| @@ -126,7 +128,9 @@ PresentManager::PresentManager(Core::Frontend::EmuWindow& render_window_, const | |||
| 126 | free_queue.push(&frame); | 128 | free_queue.push(&frame); |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | present_thread = std::jthread([this](std::stop_token token) { PresentThread(token); }); | 131 | if (use_present_thread) { |
| 132 | present_thread = std::jthread([this](std::stop_token token) { PresentThread(token); }); | ||
| 133 | } | ||
| 130 | } | 134 | } |
| 131 | 135 | ||
| 132 | PresentManager::~PresentManager() = default; | 136 | PresentManager::~PresentManager() = default; |
| @@ -150,6 +154,12 @@ Frame* PresentManager::GetRenderFrame() { | |||
| 150 | } | 154 | } |
| 151 | 155 | ||
| 152 | void PresentManager::PushFrame(Frame* frame) { | 156 | void PresentManager::PushFrame(Frame* frame) { |
| 157 | if (!use_present_thread) { | ||
| 158 | CopyToSwapchain(frame); | ||
| 159 | free_queue.push(frame); | ||
| 160 | return; | ||
| 161 | } | ||
| 162 | |||
| 153 | std::unique_lock lock{queue_mutex}; | 163 | std::unique_lock lock{queue_mutex}; |
| 154 | present_queue.push(frame); | 164 | present_queue.push(frame); |
| 155 | frame_cv.notify_one(); | 165 | frame_cv.notify_one(); |
| @@ -227,6 +237,10 @@ void PresentManager::RecreateFrame(Frame* frame, u32 width, u32 height, bool is_ | |||
| 227 | } | 237 | } |
| 228 | 238 | ||
| 229 | void PresentManager::WaitPresent() { | 239 | void PresentManager::WaitPresent() { |
| 240 | if (!use_present_thread) { | ||
| 241 | return; | ||
| 242 | } | ||
| 243 | |||
| 230 | // Wait for the present queue to be empty | 244 | // Wait for the present queue to be empty |
| 231 | { | 245 | { |
| 232 | std::unique_lock queue_lock{queue_mutex}; | 246 | std::unique_lock queue_lock{queue_mutex}; |
diff --git a/src/video_core/renderer_vulkan/vk_present_manager.h b/src/video_core/renderer_vulkan/vk_present_manager.h index f5d9fc96d..9885fd7c6 100644 --- a/src/video_core/renderer_vulkan/vk_present_manager.h +++ b/src/video_core/renderer_vulkan/vk_present_manager.h | |||
| @@ -75,7 +75,8 @@ private: | |||
| 75 | std::mutex queue_mutex; | 75 | std::mutex queue_mutex; |
| 76 | std::mutex free_mutex; | 76 | std::mutex free_mutex; |
| 77 | std::jthread present_thread; | 77 | std::jthread present_thread; |
| 78 | bool blit_supported{}; | 78 | bool blit_supported; |
| 79 | bool use_present_thread; | ||
| 79 | std::size_t image_count; | 80 | std::size_t image_count; |
| 80 | }; | 81 | }; |
| 81 | 82 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index bb731276e..305891d18 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -692,6 +692,7 @@ void Config::ReadRendererValues() { | |||
| 692 | qt_config->beginGroup(QStringLiteral("Renderer")); | 692 | qt_config->beginGroup(QStringLiteral("Renderer")); |
| 693 | 693 | ||
| 694 | ReadGlobalSetting(Settings::values.renderer_backend); | 694 | ReadGlobalSetting(Settings::values.renderer_backend); |
| 695 | ReadGlobalSetting(Settings::values.async_presentation); | ||
| 695 | ReadGlobalSetting(Settings::values.renderer_force_max_clock); | 696 | ReadGlobalSetting(Settings::values.renderer_force_max_clock); |
| 696 | ReadGlobalSetting(Settings::values.vulkan_device); | 697 | ReadGlobalSetting(Settings::values.vulkan_device); |
| 697 | ReadGlobalSetting(Settings::values.fullscreen_mode); | 698 | ReadGlobalSetting(Settings::values.fullscreen_mode); |
| @@ -1313,6 +1314,7 @@ void Config::SaveRendererValues() { | |||
| 1313 | static_cast<u32>(Settings::values.renderer_backend.GetValue(global)), | 1314 | static_cast<u32>(Settings::values.renderer_backend.GetValue(global)), |
| 1314 | static_cast<u32>(Settings::values.renderer_backend.GetDefault()), | 1315 | static_cast<u32>(Settings::values.renderer_backend.GetDefault()), |
| 1315 | Settings::values.renderer_backend.UsingGlobal()); | 1316 | Settings::values.renderer_backend.UsingGlobal()); |
| 1317 | WriteGlobalSetting(Settings::values.async_presentation); | ||
| 1316 | WriteGlobalSetting(Settings::values.renderer_force_max_clock); | 1318 | WriteGlobalSetting(Settings::values.renderer_force_max_clock); |
| 1317 | WriteGlobalSetting(Settings::values.vulkan_device); | 1319 | WriteGlobalSetting(Settings::values.vulkan_device); |
| 1318 | WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()), | 1320 | WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()), |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.cpp b/src/yuzu/configuration/configure_graphics_advanced.cpp index 59fb1b334..7f7bf0e4d 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp | |||
| @@ -22,11 +22,13 @@ ConfigureGraphicsAdvanced::~ConfigureGraphicsAdvanced() = default; | |||
| 22 | void ConfigureGraphicsAdvanced::SetConfiguration() { | 22 | void ConfigureGraphicsAdvanced::SetConfiguration() { |
| 23 | const bool runtime_lock = !system.IsPoweredOn(); | 23 | const bool runtime_lock = !system.IsPoweredOn(); |
| 24 | ui->use_vsync->setEnabled(runtime_lock); | 24 | ui->use_vsync->setEnabled(runtime_lock); |
| 25 | ui->async_present->setEnabled(runtime_lock); | ||
| 25 | ui->renderer_force_max_clock->setEnabled(runtime_lock); | 26 | ui->renderer_force_max_clock->setEnabled(runtime_lock); |
| 26 | ui->async_astc->setEnabled(runtime_lock); | 27 | ui->async_astc->setEnabled(runtime_lock); |
| 27 | ui->use_asynchronous_shaders->setEnabled(runtime_lock); | 28 | ui->use_asynchronous_shaders->setEnabled(runtime_lock); |
| 28 | ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); | 29 | ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); |
| 29 | 30 | ||
| 31 | ui->async_present->setChecked(Settings::values.async_presentation.GetValue()); | ||
| 30 | ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue()); | 32 | ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue()); |
| 31 | ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); | 33 | ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue()); |
| 32 | ui->async_astc->setChecked(Settings::values.async_astc.GetValue()); | 34 | ui->async_astc->setChecked(Settings::values.async_astc.GetValue()); |
| @@ -54,6 +56,8 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { | |||
| 54 | 56 | ||
| 55 | void ConfigureGraphicsAdvanced::ApplyConfiguration() { | 57 | void ConfigureGraphicsAdvanced::ApplyConfiguration() { |
| 56 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy); | 58 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy); |
| 59 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.async_presentation, | ||
| 60 | ui->async_present, async_present); | ||
| 57 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.renderer_force_max_clock, | 61 | ConfigurationShared::ApplyPerGameSetting(&Settings::values.renderer_force_max_clock, |
| 58 | ui->renderer_force_max_clock, | 62 | ui->renderer_force_max_clock, |
| 59 | renderer_force_max_clock); | 63 | renderer_force_max_clock); |
| @@ -90,6 +94,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 90 | // Disable if not global (only happens during game) | 94 | // Disable if not global (only happens during game) |
| 91 | if (Settings::IsConfiguringGlobal()) { | 95 | if (Settings::IsConfiguringGlobal()) { |
| 92 | ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); | 96 | ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); |
| 97 | ui->async_present->setEnabled(Settings::values.async_presentation.UsingGlobal()); | ||
| 93 | ui->renderer_force_max_clock->setEnabled( | 98 | ui->renderer_force_max_clock->setEnabled( |
| 94 | Settings::values.renderer_force_max_clock.UsingGlobal()); | 99 | Settings::values.renderer_force_max_clock.UsingGlobal()); |
| 95 | ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); | 100 | ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal()); |
| @@ -107,6 +112,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { | |||
| 107 | return; | 112 | return; |
| 108 | } | 113 | } |
| 109 | 114 | ||
| 115 | ConfigurationShared::SetColoredTristate(ui->async_present, Settings::values.async_presentation, | ||
| 116 | async_present); | ||
| 110 | ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock, | 117 | ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock, |
| 111 | Settings::values.renderer_force_max_clock, | 118 | Settings::values.renderer_force_max_clock, |
| 112 | renderer_force_max_clock); | 119 | renderer_force_max_clock); |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index bf1b04749..5394ed40a 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h | |||
| @@ -36,6 +36,7 @@ private: | |||
| 36 | 36 | ||
| 37 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; | 37 | std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui; |
| 38 | 38 | ||
| 39 | ConfigurationShared::CheckState async_present; | ||
| 39 | ConfigurationShared::CheckState renderer_force_max_clock; | 40 | ConfigurationShared::CheckState renderer_force_max_clock; |
| 40 | ConfigurationShared::CheckState use_vsync; | 41 | ConfigurationShared::CheckState use_vsync; |
| 41 | ConfigurationShared::CheckState async_astc; | 42 | ConfigurationShared::CheckState async_astc; |
diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index a7dbdc18c..d7ec18939 100644 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | <x>0</x> | 7 | <x>0</x> |
| 8 | <y>0</y> | 8 | <y>0</y> |
| 9 | <width>404</width> | 9 | <width>404</width> |
| 10 | <height>321</height> | 10 | <height>376</height> |
| 11 | </rect> | 11 | </rect> |
| 12 | </property> | 12 | </property> |
| 13 | <property name="windowTitle"> | 13 | <property name="windowTitle"> |
| @@ -70,6 +70,13 @@ | |||
| 70 | </widget> | 70 | </widget> |
| 71 | </item> | 71 | </item> |
| 72 | <item> | 72 | <item> |
| 73 | <widget class="QCheckBox" name="async_present"> | ||
| 74 | <property name="text"> | ||
| 75 | <string>Enable asynchronous presentation (Vulkan only)</string> | ||
| 76 | </property> | ||
| 77 | </widget> | ||
| 78 | </item> | ||
| 79 | <item> | ||
| 73 | <widget class="QCheckBox" name="renderer_force_max_clock"> | 80 | <widget class="QCheckBox" name="renderer_force_max_clock"> |
| 74 | <property name="toolTip"> | 81 | <property name="toolTip"> |
| 75 | <string>Runs work in the background while waiting for graphics commands to keep the GPU from lowering its clock speed.</string> | 82 | <string>Runs work in the background while waiting for graphics commands to keep the GPU from lowering its clock speed.</string> |
| @@ -112,7 +119,7 @@ | |||
| 112 | <item> | 119 | <item> |
| 113 | <widget class="QCheckBox" name="use_fast_gpu_time"> | 120 | <widget class="QCheckBox" name="use_fast_gpu_time"> |
| 114 | <property name="toolTip"> | 121 | <property name="toolTip"> |
| 115 | <string>Enables Fast GPU Time. This option will force most games to run at their highest native resolution.</string> | 122 | <string>Enables Fast GPU Time. This option will force most games to run at their highest native resolution.</string> |
| 116 | </property> | 123 | </property> |
| 117 | <property name="text"> | 124 | <property name="text"> |
| 118 | <string>Use Fast GPU Time (Hack)</string> | 125 | <string>Use Fast GPU Time (Hack)</string> |
| @@ -122,7 +129,7 @@ | |||
| 122 | <item> | 129 | <item> |
| 123 | <widget class="QCheckBox" name="use_pessimistic_flushes"> | 130 | <widget class="QCheckBox" name="use_pessimistic_flushes"> |
| 124 | <property name="toolTip"> | 131 | <property name="toolTip"> |
| 125 | <string>Enables pessimistic buffer flushes. This option will force unmodified buffers to be flushed, which can cost performance.</string> | 132 | <string>Enables pessimistic buffer flushes. This option will force unmodified buffers to be flushed, which can cost performance.</string> |
| 126 | </property> | 133 | </property> |
| 127 | <property name="text"> | 134 | <property name="text"> |
| 128 | <string>Use pessimistic buffer flushes (Hack)</string> | 135 | <string>Use pessimistic buffer flushes (Hack)</string> |
| @@ -132,7 +139,7 @@ | |||
| 132 | <item> | 139 | <item> |
| 133 | <widget class="QCheckBox" name="use_vulkan_driver_pipeline_cache"> | 140 | <widget class="QCheckBox" name="use_vulkan_driver_pipeline_cache"> |
| 134 | <property name="toolTip"> | 141 | <property name="toolTip"> |
| 135 | <string>Enables GPU vendor-specific pipeline cache. This option can improve shader loading time significantly in cases where the Vulkan driver does not store pipeline cache files internally.</string> | 142 | <string>Enables GPU vendor-specific pipeline cache. This option can improve shader loading time significantly in cases where the Vulkan driver does not store pipeline cache files internally.</string> |
| 136 | </property> | 143 | </property> |
| 137 | <property name="text"> | 144 | <property name="text"> |
| 138 | <string>Use Vulkan pipeline cache</string> | 145 | <string>Use Vulkan pipeline cache</string> |
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 464da3231..fa347fb8c 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -300,6 +300,7 @@ void Config::ReadValues() { | |||
| 300 | 300 | ||
| 301 | // Renderer | 301 | // Renderer |
| 302 | ReadSetting("Renderer", Settings::values.renderer_backend); | 302 | ReadSetting("Renderer", Settings::values.renderer_backend); |
| 303 | ReadSetting("Renderer", Settings::values.async_presentation); | ||
| 303 | ReadSetting("Renderer", Settings::values.renderer_force_max_clock); | 304 | ReadSetting("Renderer", Settings::values.renderer_force_max_clock); |
| 304 | ReadSetting("Renderer", Settings::values.renderer_debug); | 305 | ReadSetting("Renderer", Settings::values.renderer_debug); |
| 305 | ReadSetting("Renderer", Settings::values.renderer_shader_feedback); | 306 | ReadSetting("Renderer", Settings::values.renderer_shader_feedback); |
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index 209cfc28a..c0c89fbb9 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h | |||
| @@ -264,6 +264,10 @@ cpuopt_unsafe_ignore_global_monitor = | |||
| 264 | # 0: OpenGL, 1 (default): Vulkan | 264 | # 0: OpenGL, 1 (default): Vulkan |
| 265 | backend = | 265 | backend = |
| 266 | 266 | ||
| 267 | # Whether to enable asynchronous presentation (Vulkan only) | ||
| 268 | # 0 (default): Off, 1: On | ||
| 269 | async_presentation = | ||
| 270 | |||
| 267 | # Enable graphics API debugging mode. | 271 | # Enable graphics API debugging mode. |
| 268 | # 0 (default): Disabled, 1: Enabled | 272 | # 0 (default): Disabled, 1: Enabled |
| 269 | debug = | 273 | debug = |