diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-04-24 06:24:55 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-04-24 06:24:55 +0000 |
| commit | c35656e4ff1fbcf37818b40ed8d52ba329982c80 (patch) | |
| tree | 991df10ddd7caf7d2eae098d311466056c84da8b /Graphics/GraphicsEngineVulkan | |
| parent | VK swap chain resize: added orientation change detection (diff) | |
| download | DiligentCore-c35656e4ff1fbcf37818b40ed8d52ba329982c80.tar.gz DiligentCore-c35656e4ff1fbcf37818b40ed8d52ba329982c80.zip | |
Improved orientation change detection on Android
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/include/SwapChainVkImpl.hpp | 3 | ||||
| -rw-r--r-- | Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 6 |
2 files changed, 6 insertions, 3 deletions
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<RefCntAutoPtr<ManagedSemaphore>> 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; } |
