From 5f28d47af17eec8632ea0437066631f2353cecba Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 27 Apr 2020 13:29:49 -0700 Subject: Improved swap chain resize handling on Android --- .../src/DeviceContextGLImpl.cpp | 1 + .../GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 30 ++++++++++++++++++++-- .../GraphicsEngineVulkan/src/SwapChainVkImpl.cpp | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'Graphics') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index c64c41cd..f6308229 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -400,6 +400,7 @@ void DeviceContextGLImpl::ResetRenderTargets() { TDeviceContextBase::ResetRenderTargets(); m_IsDefaultFBOBound = false; + m_ContextState.InvalidateFBO(); } diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index 3b6ebe8e..420449fb 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -121,8 +121,34 @@ void SwapChainGLImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFOR auto* pDeviceGL = m_pRenderDevice.RawPtr(); auto& GLContext = pDeviceGL->m_GLContext; GLContext.UpdateScreenSize(); - NewWidth = GLContext.GetScreenWidth(); - NewHeight = GLContext.GetScreenHeight(); + const auto ScreenWidth = GLContext.GetScreenWidth(); + const auto ScreenHeight = GLContext.GetScreenHeight(); + + if (NewWidth == 0) + { + NewWidth = ScreenWidth; + } + else + { + if (NewWidth != ScreenWidth) + { + LOG_WARNING_MESSAGE("Requested new swap chain width (", NewWidth, ") does not match GLES surface width (", ScreenWidth, + "). This may be the result of calling Resize before the rotation has taken the effect."); + } + } + + if (NewHeight == 0) + { + NewHeight = ScreenHeight; + } + else + { + if (NewHeight != ScreenHeight) + { + LOG_WARNING_MESSAGE("Requested new swap chain height (", NewHeight, ") does not match GLES surface height (", ScreenHeight, + "). This may be the result of calling Resize before the rotation has taken the effect."); + } + } #endif TSwapChainGLBase::Resize(NewWidth, NewHeight, NewPreTransform, 0); diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp index b6337999..e0e27333 100644 --- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp @@ -248,6 +248,7 @@ void SwapChainVkImpl::CreateVulkanSwapChain() // https://community.arm.com/developer/tools-software/graphics/b/blog/posts/appropriate-use-of-surface-rotation vkPreTransform = surfCapabilities.currentTransform; m_SwapChainDesc.PreTransform = VkSurfaceTransformFlagToSurfaceTransform(vkPreTransform); + LOG_INFO_MESSAGE("Using ", GetSurfaceTransformString(m_SwapChainDesc.PreTransform), " swap chain pretransform"); } VkExtent2D swapchainExtent = {}; -- cgit v1.2.3