early-access version 3541

This commit is contained in:
pineappleEA
2023-05-03 01:52:43 +02:00
parent 0a71b96a2f
commit 0827cb1044
12 changed files with 49 additions and 7 deletions

View File

@@ -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};

View File

@@ -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;
};