summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-04-27 22:59:35 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-04-27 22:59:35 +0000
commit19a03ad88b5b8ea072d62ace99cecc77956c8144 (patch)
tree2b94269ab0eca14e256fb776aab8384b29add104 /Graphics/GraphicsEngineVulkan
parentImproved swap chain resize handling on Android (diff)
downloadDiligentCore-19a03ad88b5b8ea072d62ace99cecc77956c8144.tar.gz
DiligentCore-19a03ad88b5b8ea072d62ace99cecc77956c8144.zip
Vulkan swap chain: auto-detecting surface rotation on Android
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index e0e27333..732c47e5 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -845,10 +845,38 @@ void SwapChainVkImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR
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)
+
+ if (NewWidth == 0 || NewHeight == 0)
+ {
+ NewWidth = m_SurfaceIdentityExtent.width;
+ NewHeight = m_SurfaceIdentityExtent.height;
+
+ if ((surfCapabilities.currentTransform & Rotate90TransformFlags) != 0)
+ {
+ // Swap to get logical dimensions as input NewWidth and NewHeight are
+ // expected to be logical sizes.
+ std::swap(NewWidth, NewHeight);
+ }
+ }
+
+ if (NewPreTransform == SURFACE_TRANSFORM_OPTIMAL)
{
- // The surface is rotated 90/270 degrees - swap width and height
- std::swap(NewWidth, NewHeight);
+ if ((surfCapabilities.currentTransform & Rotate90TransformFlags) != 0)
+ {
+ // Swap to get physical dimensions
+ std::swap(NewWidth, NewHeight);
+ }
+ }
+ else
+ {
+ // Swap if necessary to get desired sizes after pre-transform
+ if (NewPreTransform == SURFACE_TRANSFORM_ROTATE_90 ||
+ NewPreTransform == SURFACE_TRANSFORM_ROTATE_270 ||
+ NewPreTransform == SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90 ||
+ NewPreTransform == SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270)
+ {
+ std::swap(NewWidth, NewHeight);
+ }
}
}
else