diff options
| author | 2023-05-01 23:12:28 +0300 | |
|---|---|---|
| committer | 2023-05-01 23:13:24 +0300 | |
| commit | f403d2794187bd136fb4d30fb7a6aea950145013 (patch) | |
| tree | 0e78d295ae6cbe48dc5ab76b96424044e90dad5b /src/video_core/renderer_vulkan | |
| 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/video_core/renderer_vulkan')
| -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 |
2 files changed, 17 insertions, 2 deletions
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 | ||