From 8b980475020b734e12136ab0669bcb86b191acfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 22 Jun 2020 00:54:51 +0200 Subject: [PATCH] Finish the Linux part of this change --- SDL/SDLVulkanGraphicsContext.cpp | 19 +++++++++++++++++++ SDL/SDLVulkanGraphicsContext.h | 13 ++++++------- UI/NativeApp.cpp | 1 + 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index 60c05583e4..389030d594 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -4,6 +4,7 @@ #include "base/display.h" #include "thin3d/thin3d.h" #include "thin3d/thin3d_create.h" +#include "thin3d/VulkanRenderManager.h" #include "util/text/parsers.h" #include "Core/System.h" @@ -103,6 +104,9 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, assert(success); draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); + renderManager_ = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); + renderManager_->SetInflightFrames(g_Config.iInflightFrames); + return true; } @@ -119,3 +123,18 @@ void SDLVulkanGraphicsContext::Shutdown() { vulkan_ = nullptr; finalize_glslang(); } + +void SDLVulkanGraphicsContext::Resize() { + draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); + vulkan_->DestroyObjects(); + vulkan_->ReinitSurface(); + vulkan_->InitObjects(); + draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); +} + +void SDLVulkanGraphicsContext::Poll() { + // Check for existing swapchain to avoid issues during shutdown. + if (vulkan_->GetSwapchain() && renderManager_->NeedsSwapchainRecreate()) { + Resize(); + } +} \ No newline at end of file diff --git a/SDL/SDLVulkanGraphicsContext.h b/SDL/SDLVulkanGraphicsContext.h index 533406560e..02e5f496e4 100644 --- a/SDL/SDLVulkanGraphicsContext.h +++ b/SDL/SDLVulkanGraphicsContext.h @@ -7,6 +7,8 @@ #include "thin3d/thin3d.h" +class VulkanRenderManager; + class SDLVulkanGraphicsContext : public GraphicsContext { public: SDLVulkanGraphicsContext() {} @@ -22,13 +24,9 @@ public: // We don't do it this way. } - void Resize() override { - draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); - vulkan_->DestroyObjects(); - vulkan_->ReinitSurface(); - vulkan_->InitObjects(); - draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); - } + void Resize() override; + + void Poll() override; void SwapInterval(int interval) override { } @@ -42,4 +40,5 @@ public: private: Draw::DrawContext *draw_ = nullptr; VulkanContext *vulkan_ = nullptr; + VulkanRenderManager *renderManager_ = nullptr; }; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index e6fca738f3..f2cd00a812 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1096,6 +1096,7 @@ void NativeRender(GraphicsContext *graphicsContext) { } #endif } else { + // ILOG("Polling graphics context"); graphicsContext->Poll(); }