diff options
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
| -rw-r--r-- | Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
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<ISwapChainGL>(); + 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"); } |
