From 58c240045e0b720b7adfd5e1d73a53e6edfb8dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 7 Oct 2018 09:54:57 +0200 Subject: [PATCH] Make window resize work with Vulkan. Seems more stable now. --- SDL/SDLMain.cpp | 2 +- SDL/SDLVulkanGraphicsContext.h | 7 +------ ext/native/thin3d/VulkanRenderManager.cpp | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index ae654d4a96..7c4ae4074d 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -621,7 +621,7 @@ int main(int argc, char *argv[]) { #if !defined(MOBILE_DEVICE) case SDL_WINDOWEVENT: switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_SIZE_CHANGED: // better than RESIZED, more general { Uint32 window_flags = SDL_GetWindowFlags(window); bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN); diff --git a/SDL/SDLVulkanGraphicsContext.h b/SDL/SDLVulkanGraphicsContext.h index 42883b6700..5a29e6c3df 100644 --- a/SDL/SDLVulkanGraphicsContext.h +++ b/SDL/SDLVulkanGraphicsContext.h @@ -25,16 +25,11 @@ public: } void Resize() override { - /* draw_->HandleEvent(Draw::Event::LOST_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); vulkan_->DestroyObjects(); - // TODO: Take from real window dimensions - int width = 1024; - int height = 768; - vulkan_->ReinitSurface(width, height); + vulkan_->ReinitSurface(); vulkan_->InitObjects(); draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); - */ } void SwapInterval(int interval) override { diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index dac2b50492..5cd79d4dcb 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -865,7 +865,9 @@ void VulkanRenderManager::BeginSubmitFrame(int frame) { VkResult res = vkAcquireNextImageKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), UINT64_MAX, acquireSemaphore_, (VkFence)VK_NULL_HANDLE, &frameData.curSwapchainImage); if (res == VK_SUBOPTIMAL_KHR) { // Hopefully the resize will happen shortly. Ignore - one frame might look bad or something. + WLOG("VK_SUBOPTIMAL_KHR returned - ignoring"); } else if (res == VK_ERROR_OUT_OF_DATE_KHR) { + WLOG("VK_ERROR_OUT_OF_DATE_KHR returned - not presenting"); frameData.skipSwap = true; } else { _assert_msg_(G3D, res == VK_SUCCESS, "vkAcquireNextImageKHR failed! result=%s", VulkanResultToString(res));