summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-04-26 02:29:32 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-04-26 02:29:32 +0000
commit2f855f30a741900396aa08e8eff9726bc20afba6 (patch)
treefe36c7585d4c969edfeebac08203def2e8462db5 /Graphics/GraphicsEngineVulkan
parentVulkan swap chain: improved swap chain destruction (diff)
downloadDiligentCore-2f855f30a741900396aa08e8eff9726bc20afba6.tar.gz
DiligentCore-2f855f30a741900396aa08e8eff9726bc20afba6.zip
Improved surface orientation change detection in Vulkan swap chain
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index fac1482f..b6337999 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -818,12 +818,12 @@ void SwapChainVkImpl::RecreateVulkanSwapchain(DeviceContextVkImpl* pImmediateCtx
void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform)
{
- auto RecreateSwapChain = TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform);
+ bool RecreateSwapChain = false;
#if PLATFORM_ANDROID
- if (!RecreateSwapChain && m_VkSurface != VK_NULL_HANDLE)
+ if (m_VkSurface != VK_NULL_HANDLE)
{
- // Check orinetation change
+ // Check orientation
const auto* pRenderDeviceVk = m_pRenderDevice.RawPtr<const RenderDeviceVkImpl>();
const auto& PhysicalDevice = pRenderDeviceVk->GetPhysicalDevice();
const auto vkDeviceHandle = PhysicalDevice.GetVkDeviceHandle();
@@ -835,8 +835,20 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR
{
if (m_CurrentSurfaceTransform != surfCapabilities.currentTransform)
{
+ // Surface orientation has changed - we need to recreate the swap chain
RecreateSwapChain = true;
}
+
+ constexpr auto Rotate90TransformFlags =
+ VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR |
+ VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR |
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR |
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR;
+ if ((surfCapabilities.currentTransform & Rotate90TransformFlags) != 0)
+ {
+ // The surface is rotated 90/270 degrees - swap width and height
+ std::swap(NewWidth, NewHeight);
+ }
}
else
{
@@ -845,6 +857,9 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR
}
#endif
+ if (TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform))
+ RecreateSwapChain = true;
+
if (RecreateSwapChain)
{
auto pDeviceContext = m_wpDeviceContext.Lock();