summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2019-12-28 22:44:45 +0000
committerassiduous <assiduous@diligentgraphics.com>2019-12-28 22:44:45 +0000
commit32bef9e365ceefb5fa239c2b07aeb441d1d63371 (patch)
treee4d549db3e331ebbec7a6df619b9ccb2414068f9 /Graphics/GraphicsEngineOpenGL
parentAdded SwapChainGLBase class (diff)
downloadDiligentCore-32bef9e365ceefb5fa239c2b07aeb441d1d63371.tar.gz
DiligentCore-32bef9e365ceefb5fa239c2b07aeb441d1d63371.zip
Reworked SwapChainIOS to use SwapChainGLBase; fixed few compiler issues
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.h14
-rw-r--r--Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h13
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm45
3 files changed, 12 insertions, 60 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.h
index 54cc4616..f78eb712 100644
--- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.h
+++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLBase.h
@@ -59,9 +59,9 @@ protected:
{
if (m_pRenderTargetView)
{
- if (auto pDeviceContext = m_wpDeviceContext.Lock())
+ if (auto pDeviceContext = this->m_wpDeviceContext.Lock())
{
- auto* pImmediateCtxGL = pDeviceContext.RawPtr<DeviceContextGLImpl>();
+ auto* pImmediateCtxGL = pDeviceContext.template RawPtr<DeviceContextGLImpl>();
// Unbind the back buffer to be consistent with other backends
auto* pCurrentBackBuffer = ValidatedCast<TextureBaseGL>(m_pRenderTargetView->GetTexture());
auto RenderTargetsReset = pImmediateCtxGL->UnbindTextureFromFramebuffer(pCurrentBackBuffer, false);
@@ -73,7 +73,7 @@ protected:
}
}
- CreateDummyBuffers(m_pRenderDevice.RawPtr<RenderDeviceGLImpl>());
+ CreateDummyBuffers(this->m_pRenderDevice.template RawPtr<RenderDeviceGLImpl>());
return true;
}
@@ -85,9 +85,9 @@ protected:
TextureDesc ColorBuffDesc;
ColorBuffDesc.Type = RESOURCE_DIM_TEX_2D;
ColorBuffDesc.Name = "Main color buffer stub";
- ColorBuffDesc.Width = m_SwapChainDesc.Width;
- ColorBuffDesc.Height = m_SwapChainDesc.Height;
- ColorBuffDesc.Format = m_SwapChainDesc.ColorBufferFormat;
+ ColorBuffDesc.Width = this->m_SwapChainDesc.Width;
+ ColorBuffDesc.Height = this->m_SwapChainDesc.Height;
+ ColorBuffDesc.Format = this->m_SwapChainDesc.ColorBufferFormat;
ColorBuffDesc.BindFlags = BIND_RENDER_TARGET;
RefCntAutoPtr<ITexture> pDummyColorBuffer;
pRenderDeviceGL->CreateDummyTexture(ColorBuffDesc, RESOURCE_STATE_RENDER_TARGET, &pDummyColorBuffer);
@@ -95,7 +95,7 @@ protected:
TextureDesc DepthBuffDesc = ColorBuffDesc;
DepthBuffDesc.Name = "Main depth buffer stub";
- DepthBuffDesc.Format = m_SwapChainDesc.DepthBufferFormat;
+ DepthBuffDesc.Format = this->m_SwapChainDesc.DepthBufferFormat;
DepthBuffDesc.BindFlags = BIND_DEPTH_STENCIL;
RefCntAutoPtr<ITexture> pDummyDepthBuffer;
pRenderDeviceGL->CreateDummyTexture(DepthBuffDesc, RESOURCE_STATE_DEPTH_WRITE, &pDummyDepthBuffer);
diff --git a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
index 920b9b76..ef423930 100644
--- a/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
+++ b/Graphics/GraphicsEngineOpenGL/include/SwapChainGLIOS.h
@@ -24,7 +24,7 @@
#pragma once
#include "SwapChainGL.h"
-#include "SwapChainBase.h"
+#include "SwapChainGLBase.h"
#include "GLObjectWrapper.h"
namespace Diligent
@@ -32,10 +32,10 @@ namespace Diligent
class IMemoryAllocator;
/// Implementation of the Diligent::ISwapChainGL interface on IOS
-class SwapChainGLIOS final : public SwapChainBase<ISwapChainGL>
+class SwapChainGLIOS final : public SwapChainGLBase<ISwapChainGL>
{
public:
- typedef SwapChainBase<ISwapChainGL> TSwapChainBase;
+ using TSwapChainGLBase = SwapChainGLBase<ISwapChainGL>;
SwapChainGLIOS(IReferenceCounters* pRefCounters,
const EngineGLCreateInfo& InitAttribs,
@@ -56,15 +56,8 @@ public:
virtual GLuint GetDefaultFBO() const override final;
- virtual ITextureView* GetCurrentBackBufferRTV() override final { return m_pRenderTargetView; }
- virtual ITextureView* GetDepthBufferDSV() override final { return m_pDepthStencilView; }
-
private:
void InitRenderBuffers(bool InitFromDrawable, Uint32& Width, Uint32& Height);
- void CreateDummyBuffers(RenderDeviceGLImpl* pRenderDeviceGL);
-
- RefCntAutoPtr<TextureViewGLImpl> m_pRenderTargetView;
- RefCntAutoPtr<TextureViewGLImpl> m_pDepthStencilView;
GLObjectWrappers::GLRenderBufferObj m_ColorRenderBuffer;
GLObjectWrappers::GLRenderBufferObj m_DepthRenderBuffer;
diff --git a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm
index 0e84b408..e9fbb418 100644
--- a/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm
+++ b/Graphics/GraphicsEngineOpenGL/src/SwapChainGLIOS.mm
@@ -38,7 +38,7 @@ SwapChainGLIOS::SwapChainGLIOS(IReferenceCounters* pRefCounters,
const SwapChainDesc& SCDesc,
RenderDeviceGLImpl* pRenderDeviceGL,
DeviceContextGLImpl* pImmediateContextGL) :
- TSwapChainBase( pRefCounters, pRenderDeviceGL, pImmediateContextGL, SCDesc),
+ TSwapChainGLBase( pRefCounters, pRenderDeviceGL, pImmediateContextGL, SCDesc),
m_ColorRenderBuffer(false),
m_DepthRenderBuffer(false),
m_DefaultFBO(false)
@@ -109,51 +109,10 @@ void SwapChainGLIOS::InitRenderBuffers(bool InitFromDrawable, Uint32 &Width, Uin
}
}
-void SwapChainGLIOS::CreateDummyBuffers(RenderDeviceGLImpl* pRenderDeviceGL)
-{
- TextureDesc ColorBuffDesc;
- ColorBuffDesc.Type = RESOURCE_DIM_TEX_2D;
- ColorBuffDesc.Name = "Main color buffer stub";
- ColorBuffDesc.Width = m_SwapChainDesc.Width;
- ColorBuffDesc.Height = m_SwapChainDesc.Height;
- ColorBuffDesc.Format = m_SwapChainDesc.ColorBufferFormat;
- ColorBuffDesc.BindFlags = BIND_RENDER_TARGET;
- RefCntAutoPtr<ITexture> pDummyColorBuffer;
- pRenderDeviceGL->CreateDummyTexture(ColorBuffDesc, RESOURCE_STATE_RENDER_TARGET, &pDummyColorBuffer);
- m_pRenderTargetView = ValidatedCast<TextureViewGLImpl>(pDummyColorBuffer->GetDefaultView(TEXTURE_VIEW_RENDER_TARGET));
-
- TextureDesc DepthBuffDesc = ColorBuffDesc;
- DepthBuffDesc.Name = "Main depth buffer stub";
- DepthBuffDesc.Format = m_SwapChainDesc.DepthBufferFormat;
- DepthBuffDesc.BindFlags = BIND_DEPTH_STENCIL;
- RefCntAutoPtr<ITexture> pDummyDepthBuffer;
- pRenderDeviceGL->CreateDummyTexture(DepthBuffDesc, RESOURCE_STATE_DEPTH_WRITE, &pDummyDepthBuffer);
- m_pDepthStencilView = ValidatedCast<TextureViewGLImpl>(pDummyDepthBuffer->GetDefaultView(TEXTURE_VIEW_DEPTH_STENCIL));
-}
-
void SwapChainGLIOS::Resize( Uint32 NewWidth, Uint32 NewHeight )
{
InitRenderBuffers(false, NewWidth, NewHeight);
-
- if( TSwapChainBase::Resize( NewWidth, NewHeight ) )
- {
- CreateDummyBuffers(m_pRenderDevice.RawPtr<RenderDeviceGLImpl>());
-
- auto pDeviceContext = m_wpDeviceContext.Lock();
- VERIFY( pDeviceContext, "Immediate context has been released" );
- if( pDeviceContext )
- {
- auto* pImmediateCtxGL = pDeviceContext.RawPtr<DeviceContextGLImpl>();
- // Unbind the back buffer to be consistent with other backends
- auto* pCurrentBackBuffer = ValidatedCast<TextureBaseGL>(m_pRenderTargetView->GetTexture());
- auto RenderTargetsReset = pImmediateCtxGL->UnbindTextureFromFramebuffer(pCurrentBackBuffer, false);
- if (RenderTargetsReset)
- {
- LOG_INFO_MESSAGE_ONCE("Resizing the swap chain requires back and depth-stencil buffers to be unbound from the device context. "
- "An application should use SetRenderTargets() to restore them.");
- }
- }
- }
+ TSwapChainGLBase::Resize(NewWidth, NewHeight, 0);
}
GLuint SwapChainGLIOS::GetDefaultFBO()const