From 89226eea2a0bda76cb5033e8d1878e0ca3ebe374 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Mon, 7 Aug 2023 03:18:35 -0700 Subject: [PATCH] qt: Fix fullscreen and resize issues on macOS. (#47) * qt: Fix bugged macOS full screen transition. * renderer/vulkan: Fix swapchain recreation destroying in-use semaphore. --- src/citra_qt/bootmanager.cpp | 26 +++++++++---------- .../renderer_vulkan/vk_present_window.cpp | 6 ++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 663992586..e055332fe 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -229,20 +229,10 @@ class RenderWidget : public QWidget { public: RenderWidget(GRenderWindow* parent) : QWidget(parent) { setMouseTracking(true); - } - - virtual ~RenderWidget() = default; - - virtual void Present() {} - - void paintEvent(QPaintEvent* event) override { - Present(); update(); } - std::pair GetSize() const { - return std::make_pair(width(), height()); - } + virtual ~RenderWidget() = default; }; #ifdef HAS_OPENGL @@ -262,7 +252,7 @@ public: context = std::move(context_); } - void Present() override { + void Present() { if (!isVisible()) { return; } @@ -278,6 +268,11 @@ public: glFinish(); } + void paintEvent(QPaintEvent* event) override { + Present(); + update(); + } + QPaintEngine* paintEngine() const override { return nullptr; } @@ -309,7 +304,7 @@ struct SoftwareRenderWidget : public RenderWidget { explicit SoftwareRenderWidget(GRenderWindow* parent, Core::System& system_) : RenderWidget(parent), system(system_) {} - void Present() override { + void Present() { if (!isVisible()) { return; } @@ -339,6 +334,11 @@ struct SoftwareRenderWidget : public RenderWidget { painter.end(); } + void paintEvent(QPaintEvent* event) override { + Present(); + update(); + } + QImage LoadFramebuffer(VideoCore::ScreenId screen_id) { const auto& renderer = static_cast(system.Renderer()); const auto& info = renderer.Screen(screen_id); diff --git a/src/video_core/renderer_vulkan/vk_present_window.cpp b/src/video_core/renderer_vulkan/vk_present_window.cpp index 785600d6e..5d4754526 100644 --- a/src/video_core/renderer_vulkan/vk_present_window.cpp +++ b/src/video_core/renderer_vulkan/vk_present_window.cpp @@ -330,7 +330,11 @@ void PresentWindow::NotifySurfaceChanged() { } void PresentWindow::CopyToSwapchain(Frame* frame) { - const auto recreate_swapchain = [&] { swapchain.Create(frame->width, frame->height, surface); }; + const auto recreate_swapchain = [&] { + std::scoped_lock submit_lock{scheduler.submit_mutex}; + graphics_queue.waitIdle(); + swapchain.Create(frame->width, frame->height, surface); + }; #ifdef ANDROID std::unique_lock lock{recreate_surface_mutex};