summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-04-24 06:15:37 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-04-24 06:15:37 +0000
commite167df35a6c1fb7f957cff421166918bc0d8a586 (patch)
tree487d6f4d6c6e31816c5e338b382e16669238f997 /Graphics/GraphicsEngineVulkan
parentFixed issue with infinite Vulkan swap chain growth on Android when orientatio... (diff)
downloadDiligentCore-e167df35a6c1fb7f957cff421166918bc0d8a586.tar.gz
DiligentCore-e167df35a6c1fb7f957cff421166918bc0d8a586.zip
VK swap chain resize: added orientation change detection
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index 6b577d95..113d1aa3 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -763,7 +763,35 @@ void SwapChainVkImpl::RecreateVulkanSwapchain(DeviceContextVkImpl* pImmediateCtx
void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform)
{
- if (TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform))
+ auto RecreateSwapChain = TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform);
+
+#if PLATFORM_ANDROID || PLATFORM_IOS
+ if (!RecreateSwapChain && m_VkSurface != VK_NULL_HANDLE)
+ {
+ // Check orinetation change
+ const auto* pRenderDeviceVk = m_pRenderDevice.RawPtr<const RenderDeviceVkImpl>();
+ const auto& PhysicalDevice = pRenderDeviceVk->GetPhysicalDevice();
+ const auto vkDeviceHandle = PhysicalDevice.GetVkDeviceHandle();
+
+ VkSurfaceCapabilitiesKHR surfCapabilities = {};
+
+ auto err = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(vkDeviceHandle, m_VkSurface, &surfCapabilities);
+ if (err == VK_SUCCESS)
+ {
+ auto CurrentTransform = VkSurfaceTransformFlagToSurfaceTransform(surfCapabilities.currentTransform);
+ if (CurrentTransform != m_SwapChainDesc.PreTransform)
+ {
+ RecreateSwapChain = true;
+ }
+ }
+ else
+ {
+ LOG_ERROR_MESSAGE(err, "Failed to query physical device surface capabilities");
+ }
+ }
+#endif
+
+ if (RecreateSwapChain)
{
auto pDeviceContext = m_wpDeviceContext.Lock();
VERIFY(pDeviceContext, "Immediate context has been released");