From 0827cb1044551102ac9fc116bc70a7805b6d09b6 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 3 May 2023 01:52:43 +0200 Subject: [PATCH] early-access version 3541 --- README.md | 2 +- src/CMakeLists.txt | 3 +++ src/common/settings.cpp | 1 + src/common/settings.h | 1 + .../renderer_vulkan/vk_present_manager.cpp | 16 +++++++++++++++- .../renderer_vulkan/vk_present_manager.h | 3 ++- src/yuzu/configuration/config.cpp | 2 ++ .../configure_graphics_advanced.cpp | 7 +++++++ .../configuration/configure_graphics_advanced.h | 1 + .../configuration/configure_graphics_advanced.ui | 15 +++++++++++---- src/yuzu_cmd/config.cpp | 1 + src/yuzu_cmd/default_ini.h | 4 ++++ 12 files changed, 49 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 15a63a941..f523cdb5b 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 3540. +This is the source code for early-access 3541. ## Legal Notice diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 80e32e909..f0e573327 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -113,6 +113,9 @@ else() $<$:-Wno-braced-scalar-init> $<$:-Wno-unused-private-field> + $<$:-Werror=shadow-uncaptured-local> + $<$:-Werror=implicit-fallthrough> + $<$:-Werror=type-limits> $<$:-Wno-braced-scalar-init> $<$:-Wno-unused-private-field> ) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index ed10ba1e4..bd51a8a32 100755 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -206,6 +206,7 @@ void RestoreGlobalState(bool is_powered_on) { // Renderer values.fsr_sharpening_slider.SetGlobal(true); values.renderer_backend.SetGlobal(true); + values.async_presentation.SetGlobal(true); values.renderer_force_max_clock.SetGlobal(true); values.vulkan_device.SetGlobal(true); values.fullscreen_mode.SetGlobal(true); diff --git a/src/common/settings.h b/src/common/settings.h index eb8deec25..7c772a4d6 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -423,6 +423,7 @@ struct Values { // Renderer SwitchableSetting renderer_backend{ RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"}; + SwitchableSetting async_presentation{false, "async_presentation"}; SwitchableSetting renderer_force_max_clock{false, "force_max_clock"}; Setting renderer_debug{false, "debug"}; Setting 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 100755 --- a/src/video_core/renderer_vulkan/vk_present_manager.cpp +++ b/src/video_core/renderer_vulkan/vk_present_manager.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/microprofile.h" +#include "common/settings.h" #include "common/thread.h" #include "video_core/renderer_vulkan/vk_present_manager.h" #include "video_core/renderer_vulkan/vk_scheduler.h" @@ -97,6 +98,7 @@ PresentManager::PresentManager(Core::Frontend::EmuWindow& render_window_, const : render_window{render_window_}, device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_}, blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}, + use_present_thread{Settings::values.async_presentation.GetValue()}, image_count{swapchain.GetImageCount()} { auto& dld = device.GetLogical(); @@ -126,7 +128,9 @@ PresentManager::PresentManager(Core::Frontend::EmuWindow& render_window_, const free_queue.push(&frame); } - present_thread = std::jthread([this](std::stop_token token) { PresentThread(token); }); + if (use_present_thread) { + present_thread = std::jthread([this](std::stop_token token) { PresentThread(token); }); + } } PresentManager::~PresentManager() = default; @@ -150,6 +154,12 @@ Frame* PresentManager::GetRenderFrame() { } void PresentManager::PushFrame(Frame* frame) { + if (!use_present_thread) { + CopyToSwapchain(frame); + free_queue.push(frame); + return; + } + std::unique_lock lock{queue_mutex}; present_queue.push(frame); frame_cv.notify_one(); @@ -227,6 +237,10 @@ void PresentManager::RecreateFrame(Frame* frame, u32 width, u32 height, bool is_ } void PresentManager::WaitPresent() { + if (!use_present_thread) { + return; + } + // Wait for the present queue to be empty { 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 100755 --- 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: std::mutex queue_mutex; std::mutex free_mutex; std::jthread present_thread; - bool blit_supported{}; + bool blit_supported; + bool use_present_thread; std::size_t image_count; }; diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 990ca9f4a..ce018e32e 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -692,6 +692,7 @@ void Config::ReadRendererValues() { qt_config->beginGroup(QStringLiteral("Renderer")); ReadGlobalSetting(Settings::values.renderer_backend); + ReadGlobalSetting(Settings::values.async_presentation); ReadGlobalSetting(Settings::values.renderer_force_max_clock); ReadGlobalSetting(Settings::values.vulkan_device); ReadGlobalSetting(Settings::values.fullscreen_mode); @@ -1313,6 +1314,7 @@ void Config::SaveRendererValues() { static_cast(Settings::values.renderer_backend.GetValue(global)), static_cast(Settings::values.renderer_backend.GetDefault()), Settings::values.renderer_backend.UsingGlobal()); + WriteGlobalSetting(Settings::values.async_presentation); WriteGlobalSetting(Settings::values.renderer_force_max_clock); WriteGlobalSetting(Settings::values.vulkan_device); 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 76db11020..f93d4d371 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.cpp +++ b/src/yuzu/configuration/configure_graphics_advanced.cpp @@ -22,11 +22,13 @@ 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); ui->use_asynchronous_shaders->setEnabled(runtime_lock); ui->anisotropic_filtering_combobox->setEnabled(runtime_lock); + 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()); @@ -54,6 +56,8 @@ void ConfigureGraphicsAdvanced::SetConfiguration() { void ConfigureGraphicsAdvanced::ApplyConfiguration() { ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy); + ConfigurationShared::ApplyPerGameSetting(&Settings::values.async_presentation, + ui->async_present, async_present); ConfigurationShared::ApplyPerGameSetting(&Settings::values.renderer_force_max_clock, ui->renderer_force_max_clock, renderer_force_max_clock); @@ -90,6 +94,7 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { // Disable if not global (only happens during game) if (Settings::IsConfiguringGlobal()) { ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal()); + 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()); @@ -107,6 +112,8 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() { return; } + ConfigurationShared::SetColoredTristate(ui->async_present, Settings::values.async_presentation, + async_present); ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock, Settings::values.renderer_force_max_clock, renderer_force_max_clock); diff --git a/src/yuzu/configuration/configure_graphics_advanced.h b/src/yuzu/configuration/configure_graphics_advanced.h index c758fa4e6..ac9e77b13 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.h +++ b/src/yuzu/configuration/configure_graphics_advanced.h @@ -36,6 +36,7 @@ private: std::unique_ptr ui; + ConfigurationShared::CheckState async_present; ConfigurationShared::CheckState renderer_force_max_clock; ConfigurationShared::CheckState use_vsync; ConfigurationShared::CheckState async_astc; diff --git a/src/yuzu/configuration/configure_graphics_advanced.ui b/src/yuzu/configuration/configure_graphics_advanced.ui index 501e1b74e..2ab82d03b 100755 --- a/src/yuzu/configuration/configure_graphics_advanced.ui +++ b/src/yuzu/configuration/configure_graphics_advanced.ui @@ -7,7 +7,7 @@ 0 0 404 - 321 + 376 @@ -69,6 +69,13 @@ + + + + Enable asynchronous presentation (Vulkan only) + + + @@ -112,7 +119,7 @@ - Enables Fast GPU Time. This option will force most games to run at their highest native resolution. + Enables Fast GPU Time. This option will force most games to run at their highest native resolution. Use Fast GPU Time (Hack) @@ -122,7 +129,7 @@ - Enables pessimistic buffer flushes. This option will force unmodified buffers to be flushed, which can cost performance. + Enables pessimistic buffer flushes. This option will force unmodified buffers to be flushed, which can cost performance. Use pessimistic buffer flushes (Hack) @@ -132,7 +139,7 @@ - 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. + 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. Use Vulkan pipeline cache diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 03fb1c578..4e1e6ec06 100755 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp @@ -300,6 +300,7 @@ void Config::ReadValues() { // Renderer ReadSetting("Renderer", Settings::values.renderer_backend); + ReadSetting("Renderer", Settings::values.async_presentation); ReadSetting("Renderer", Settings::values.renderer_force_max_clock); ReadSetting("Renderer", Settings::values.renderer_debug); ReadSetting("Renderer", Settings::values.renderer_shader_feedback); diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index fff3d70e2..52cc10092 100755 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -264,6 +264,10 @@ cpuopt_unsafe_ignore_global_monitor = # 0: OpenGL, 1 (default): Vulkan backend = +# Whether to enable asynchronous presentation (Vulkan only) +# 0 (default): Off, 1: On +async_presentation = + # Enable graphics API debugging mode. # 0 (default): Disabled, 1: Enabled debug =