From c35656e4ff1fbcf37818b40ed8d52ba329982c80 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 23 Apr 2020 23:24:55 -0700 Subject: Improved orientation change detection on Android --- Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp | 3 +++ Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp index 01cede61..ba33354a 100644 --- a/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp +++ b/Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp @@ -99,6 +99,9 @@ private: // because on Android vkGetPhysicalDeviceSurfaceCapabilitiesKHR is not reliable and // starts reporting incorrect dimensions after few rotations. VkExtent2D m_SurfaceIdentityExtent = {}; + + // Keep track of current surface transform to detect orientation changes. + VkSurfaceTransformFlagBitsKHR m_CurrentSurfaceTransform = VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR; #endif std::vector> m_ImageAcquiredSemaphores; diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index 113d1aa3..02de4dee 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -273,6 +273,7 @@ void SwapChainVkImpl::CreateVulkanSwapChain() { swapchainExtent = m_SurfaceIdentityExtent; } + m_CurrentSurfaceTransform = surfCapabilities.currentTransform; #endif swapchainExtent.width = std::max(swapchainExtent.width, 1u); @@ -765,7 +766,7 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR { auto RecreateSwapChain = TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform); -#if PLATFORM_ANDROID || PLATFORM_IOS +#if PLATFORM_ANDROID if (!RecreateSwapChain && m_VkSurface != VK_NULL_HANDLE) { // Check orinetation change @@ -778,8 +779,7 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR auto err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vkDeviceHandle, m_VkSurface, &surfCapabilities); if (err == VK_SUCCESS) { - auto CurrentTransform = VkSurfaceTransformFlagToSurfaceTransform(surfCapabilities.currentTransform); - if (CurrentTransform != m_SwapChainDesc.PreTransform) + if (m_CurrentSurfaceTransform != surfCapabilities.currentTransform) { RecreateSwapChain = true; } -- cgit v1.2.3