From 5cc8a3953c7986bec781d7c1f8a014195ca4bf6b Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 23 Apr 2020 20:55:17 -0700 Subject: Added surface pretransform parameter to swap chain desc (API 240057) --- Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.hpp | 13 +++++++++++-- Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.hpp | 2 +- Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp | 15 +++++++++++++-- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.hpp b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.hpp index 3fbd81e7..426d30ab 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.hpp @@ -55,9 +55,18 @@ public: virtual ITextureView* DILIGENT_CALL_TYPE GetDepthBufferDSV() override final { return m_pDepthStencilView; } protected: - bool Resize(Uint32 NewWidth, Uint32 NewHeight, Int32 /*To be different from virtual function*/) + bool Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform, Int32 /*To be different from virtual function*/) { - if (TSwapChainBase::Resize(NewWidth, NewHeight, 0)) + if (NewPreTransform != SURFACE_TRANSFORM_OPTIMAL && + NewPreTransform != SURFACE_TRANSFORM_IDENTITY) + { + LOG_WARNING_MESSAGE(GetSurfaceTransformString(NewPreTransform), + " is not an allowed pretransform because OpenGL swap chains only support identity transform. " + "Use SURFACE_TRANSFORM_OPTIMAL (recommended) or SURFACE_TRANSFORM_IDENTITY."); + } + NewPreTransform = SURFACE_TRANSFORM_OPTIMAL; + + if (TSwapChainBase::Resize(NewWidth, NewHeight, NewPreTransform)) { if (m_pRenderTargetView) { diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.hpp b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.hpp index f68079eb..8029df2f 100644 --- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.hpp +++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLImpl.hpp @@ -53,7 +53,7 @@ public: virtual void DILIGENT_CALL_TYPE Present(Uint32 SyncInterval) override final; /// Implementation of ISwapChain::Resize() in OpenGL backend. - virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight) override final; + virtual void DILIGENT_CALL_TYPE Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform) override final; /// Implementation of ISwapChain::SetFullscreenMode() in OpenGL backend. virtual void DILIGENT_CALL_TYPE SetFullscreenMode(const DisplayModeAttribs& DisplayMode) override final; diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp index a9af9b5d..3b6ebe8e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp @@ -29,6 +29,7 @@ #include "DeviceContextGLImpl.hpp" #include "RenderDeviceGLImpl.hpp" #include "SwapChainGLImpl.hpp" +#include "GraphicsAccessories.hpp" namespace Diligent { @@ -47,6 +48,16 @@ SwapChainGLImpl::SwapChainGLImpl(IReferenceCounters* pRefCounters, } // clang-format on { + if (m_DesiredPreTransform != SURFACE_TRANSFORM_OPTIMAL && + m_DesiredPreTransform != SURFACE_TRANSFORM_IDENTITY) + { + LOG_WARNING_MESSAGE(GetSurfaceTransformString(m_DesiredPreTransform), + " is not an allowed pretransform because OpenGL swap chains only support identity transform. " + "Use SURFACE_TRANSFORM_OPTIMAL (recommended) or SURFACE_TRANSFORM_IDENTITY."); + } + m_DesiredPreTransform = SURFACE_TRANSFORM_OPTIMAL; + m_SwapChainDesc.PreTransform = SURFACE_TRANSFORM_IDENTITY; + #if PLATFORM_WIN32 HWND hWnd = reinterpret_cast(InitAttribs.Window.hWnd); RECT rc; @@ -104,7 +115,7 @@ void SwapChainGLImpl::Present(Uint32 SyncInterval) } } -void SwapChainGLImpl::Resize(Uint32 NewWidth, Uint32 NewHeight) +void SwapChainGLImpl::Resize(Uint32 NewWidth, Uint32 NewHeight, SURFACE_TRANSFORM NewPreTransform) { #if PLATFORM_ANDROID auto* pDeviceGL = m_pRenderDevice.RawPtr(); @@ -114,7 +125,7 @@ void SwapChainGLImpl::Resize(Uint32 NewWidth, Uint32 NewHeight) NewHeight = GLContext.GetScreenHeight(); #endif - TSwapChainGLBase::Resize(NewWidth, NewHeight, 0); + TSwapChainGLBase::Resize(NewWidth, NewHeight, NewPreTransform, 0); } void SwapChainGLImpl::SetFullscreenMode(const DisplayModeAttribs& DisplayMode) -- cgit v1.2.3