gsdx-ogl: always read the first attachment of the fbo

This commit is contained in:
Gregory Hainaut 2015-05-11 15:46:31 +02:00
parent cb6e8a7d6a
commit 4e2e9aa56c
3 changed files with 3 additions and 5 deletions

View File

@ -217,6 +217,7 @@ namespace Emulate_DSA {
void APIENTRY NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src) { void APIENTRY NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src) {
gl_BindFramebuffer(fb_target, framebuffer); gl_BindFramebuffer(fb_target, framebuffer);
glReadBuffer(src); glReadBuffer(src);
gl_BindFramebuffer(fb_target, 0);
} }
GLenum APIENTRY CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target) { GLenum APIENTRY CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target) {

View File

@ -200,6 +200,8 @@ bool GSDeviceOGL::Create(GSWnd* wnd)
gl_GenFramebuffers(1, &m_fbo); gl_GenFramebuffers(1, &m_fbo);
gl_GenFramebuffers(1, &m_fbo_read); gl_GenFramebuffers(1, &m_fbo_read);
// Always read from the first buffer
gl_NamedFramebufferReadBuffer(m_fbo_read, GL_COLOR_ATTACHMENT0);
// **************************************************************** // ****************************************************************
// Vertex buffer state // 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_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, sid, 0); 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()); gl_CopyTextureSubImage2D(did, GL_TEX_LEVEL_0, r.x, r.y, r.x, r.y, r.width(), r.height());

View File

@ -349,7 +349,6 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
// Bind the texture to the read framebuffer to avoid any disturbance // Bind the texture to the read framebuffer to avoid any disturbance
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_id, 0); 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); 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); 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; bool status = true;
if (IsBackbuffer()) { 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); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
} else if(IsDss()) { } else if(IsDss()) {
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read); 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); gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture_id, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
if (m_format == GL_RGBA8) if (m_format == GL_RGBA8)
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image); glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
else if (m_format == GL_R16UI) else if (m_format == GL_R16UI)