From 915d3de059b7a3712b8db48e60f14fed3d589557 Mon Sep 17 00:00:00 2001 From: assiduous Date: Mon, 23 Dec 2019 15:00:54 -0800 Subject: OpenGL backend: fixed issue with copying default framebuffer --- .../GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 9b402e9e..746701f2 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -1166,9 +1166,14 @@ void DeviceContextGLImpl::CopyTexture(const CopyTextureAttribs& CopyAttribs) } else if (SrcTexDesc.Usage != USAGE_STAGING && DstTexDesc.Usage == USAGE_STAGING) { - auto CurrentNativeGLContext = m_ContextState.GetCurrentGLContext(); - auto& FBOCache = m_pDevice->GetFBOCache(CurrentNativeGLContext); - + if (pSrcTexGL->GetGLTextureHandle() == 0) + { + auto* pSwapChainGL = m_pSwapChain.RawPtr(); + GLuint DefaultFBOHandle = pSwapChainGL->GetDefaultFBO(); + glBindFramebuffer(GL_READ_FRAMEBUFFER, DefaultFBOHandle); + DEV_CHECK_GL_ERROR("Failed to bind default FBO as read framebuffer"); + } + else { TextureViewDesc SrcTexViewDesc; SrcTexViewDesc.ViewType = TEXTURE_VIEW_RENDER_TARGET; @@ -1184,8 +1189,11 @@ void DeviceContextGLImpl::CopyTexture(const CopyTextureAttribs& CopyAttribs) false // bIsDefaultView }; + auto CurrentNativeGLContext = m_ContextState.GetCurrentGLContext(); + auto& fboCache = m_pDevice->GetFBOCache(CurrentNativeGLContext); + TextureViewGLImpl* pSrcViews[] = {&SrcTexView}; - const auto& SrcFBO = FBOCache.GetFBO(1, pSrcViews, nullptr, m_ContextState); + const auto& SrcFBO = fboCache.GetFBO(1, pSrcViews, nullptr, m_ContextState); glBindFramebuffer(GL_READ_FRAMEBUFFER, SrcFBO); DEV_CHECK_GL_ERROR("Failed to bind FBO as read framebuffer"); } -- cgit v1.2.3