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.
This commit is contained in:
Steveice10 2023-08-07 03:18:35 -07:00 committed by GPUCode
parent 59549a2eb6
commit 89226eea2a
2 changed files with 18 additions and 14 deletions

View file

@ -229,20 +229,10 @@ class RenderWidget : public QWidget {
public: public:
RenderWidget(GRenderWindow* parent) : QWidget(parent) { RenderWidget(GRenderWindow* parent) : QWidget(parent) {
setMouseTracking(true); setMouseTracking(true);
}
virtual ~RenderWidget() = default;
virtual void Present() {}
void paintEvent(QPaintEvent* event) override {
Present();
update(); update();
} }
std::pair<unsigned, unsigned> GetSize() const { virtual ~RenderWidget() = default;
return std::make_pair(width(), height());
}
}; };
#ifdef HAS_OPENGL #ifdef HAS_OPENGL
@ -262,7 +252,7 @@ public:
context = std::move(context_); context = std::move(context_);
} }
void Present() override { void Present() {
if (!isVisible()) { if (!isVisible()) {
return; return;
} }
@ -278,6 +268,11 @@ public:
glFinish(); glFinish();
} }
void paintEvent(QPaintEvent* event) override {
Present();
update();
}
QPaintEngine* paintEngine() const override { QPaintEngine* paintEngine() const override {
return nullptr; return nullptr;
} }
@ -309,7 +304,7 @@ struct SoftwareRenderWidget : public RenderWidget {
explicit SoftwareRenderWidget(GRenderWindow* parent, Core::System& system_) explicit SoftwareRenderWidget(GRenderWindow* parent, Core::System& system_)
: RenderWidget(parent), system(system_) {} : RenderWidget(parent), system(system_) {}
void Present() override { void Present() {
if (!isVisible()) { if (!isVisible()) {
return; return;
} }
@ -339,6 +334,11 @@ struct SoftwareRenderWidget : public RenderWidget {
painter.end(); painter.end();
} }
void paintEvent(QPaintEvent* event) override {
Present();
update();
}
QImage LoadFramebuffer(VideoCore::ScreenId screen_id) { QImage LoadFramebuffer(VideoCore::ScreenId screen_id) {
const auto& renderer = static_cast<SwRenderer::RendererSoftware&>(system.Renderer()); const auto& renderer = static_cast<SwRenderer::RendererSoftware&>(system.Renderer());
const auto& info = renderer.Screen(screen_id); const auto& info = renderer.Screen(screen_id);

View file

@ -330,7 +330,11 @@ void PresentWindow::NotifySurfaceChanged() {
} }
void PresentWindow::CopyToSwapchain(Frame* frame) { 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 #ifdef ANDROID
std::unique_lock lock{recreate_surface_mutex}; std::unique_lock lock{recreate_surface_mutex};