From 4e2e9aa56c8b4045236df99ad894e4e020bc4b6f Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Mon, 11 May 2015 15:46:31 +0200 Subject: [PATCH] gsdx-ogl: always read the first attachment of the fbo --- plugins/GSdx/GLLoader.cpp | 1 + plugins/GSdx/GSDeviceOGL.cpp | 3 ++- plugins/GSdx/GSTextureOGL.cpp | 4 ---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/GSdx/GLLoader.cpp b/plugins/GSdx/GLLoader.cpp index fb38f05877..378efba5ca 100644 --- a/plugins/GSdx/GLLoader.cpp +++ b/plugins/GSdx/GLLoader.cpp @@ -217,6 +217,7 @@ namespace Emulate_DSA { void APIENTRY NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src) { gl_BindFramebuffer(fb_target, framebuffer); glReadBuffer(src); + gl_BindFramebuffer(fb_target, 0); } GLenum APIENTRY CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target) { diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 8e8d1fdb37..8be6192994 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -200,6 +200,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd) gl_GenFramebuffers(1, &m_fbo); gl_GenFramebuffers(1, &m_fbo_read); + // Always read from the first buffer + gl_NamedFramebufferReadBuffer(m_fbo_read, GL_COLOR_ATTACHMENT0); // **************************************************************** // Vertex buffer state @@ -688,7 +690,6 @@ void GSDeviceOGL::CopyRect(GSTexture* st, GSTexture* dt, const GSVector4i& r) gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sid, 0); - glReadBuffer(GL_COLOR_ATTACHMENT0); gl_CopyTextureSubImage2D(did, GL_TEX_LEVEL_0, r.x, r.y, r.x, r.y, r.width(), r.height()); diff --git a/plugins/GSdx/GSTextureOGL.cpp b/plugins/GSdx/GSTextureOGL.cpp index 737d2db0e3..4a23e20f31 100644 --- a/plugins/GSdx/GSTextureOGL.cpp +++ b/plugins/GSdx/GSTextureOGL.cpp @@ -349,7 +349,6 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r) // Bind the texture to the read framebuffer to avoid any disturbance gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_id, 0); - glReadBuffer(GL_COLOR_ATTACHMENT0); glPixelStorei(GL_PACK_ALIGNMENT, m_int_alignment); glReadPixels(0, 0, m_size.x, m_size.y, m_int_format, m_int_type, PboPool::m_gpu_texture); @@ -552,8 +551,6 @@ bool GSTextureOGL::Save(const string& fn, bool dds) bool status = true; if (IsBackbuffer()) { - //glReadBuffer(GL_BACK); - //gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); } else if(IsDss()) { gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); @@ -574,7 +571,6 @@ bool GSTextureOGL::Save(const string& fn, bool dds) gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_id, 0); - glReadBuffer(GL_COLOR_ATTACHMENT0); if (m_format == GL_RGBA8) glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); else if (m_format == GL_R16UI)