From 5d9fbd889b4d45581a6e28e593865ce5fabbf156 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 10 Nov 2019 16:56:07 -0800 Subject: OpenGL backend: fixed setting RTV and DSV from the swap chain --- .../src/DeviceContextGLImpl.cpp | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 898f0fb1..bdac5e7c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -331,7 +331,16 @@ namespace Diligent TextureViewGLImpl* pBoundRTVs[MaxRenderTargets] = {}; for (Uint32 rt = 0; rt < NumRenderTargets; ++rt) + { pBoundRTVs[rt] = m_pBoundRenderTargets[rt]; + DEV_CHECK_ERR(!pBoundRTVs[rt] || pBoundRTVs[rt]->GetTexture()->GetGLHandle(), + "Color buffer of the default framebuffer can only be bound with the default framebuffer's depth buffer " + "and cannot be combined with any other render target or depth buffer in OpenGL backend."); + } + + DEV_CHECK_ERR(!m_pBoundDepthStencil || m_pBoundDepthStencil->GetTexture()->GetGLHandle(), + "Depth buffer of the default framebuffer can only be bound with the default framebuffer's color buffer " + "and cannot be combined with any other render target in OpenGL backend."); auto CurrentNativeGLContext = m_ContextState.GetCurrentGLContext(); auto& FBOCache = m_pDevice->GetFBOCache(CurrentNativeGLContext); @@ -351,7 +360,25 @@ namespace Diligent RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) { if (TDeviceContextBase::SetRenderTargets( NumRenderTargets, ppRenderTargets, pDepthStencil)) + { + if (!m_IsDefaultFramebufferBound) + { + if (m_NumBoundRenderTargets == 1 && m_pBoundRenderTargets[0] && m_pBoundRenderTargets[0]->GetTexture()->GetGLHandle() == 0) + { + DEV_CHECK_ERR(!m_pBoundDepthStencil || m_pBoundDepthStencil->GetTexture()->GetGLHandle() == 0, + "Attempting to bind texture '", m_pBoundDepthStencil->GetTexture()->GetDesc().Name, "' as depth buffer with the " + "default framebuffer's color buffer: color buffer of the default framebuffer can only be bound with the default " + "framebuffer's depth buffer and cannot be combined with any other depth buffer in OpenGL backend."); + m_IsDefaultFramebufferBound = true; + } + else if (m_NumBoundRenderTargets == 0 && m_pBoundDepthStencil && m_pBoundDepthStencil->GetTexture()->GetGLHandle() == 0) + { + m_IsDefaultFramebufferBound = true; + } + } + CommitRenderTargets(); + } } void DeviceContextGLImpl::BindProgramResources(Uint32& NewMemoryBarriers, IShaderResourceBinding* pResBinding) -- cgit v1.2.3