From 04e90bee85d815ed2c5cc294a5184e00d16c5717 Mon Sep 17 00:00:00 2001 From: matto Date: Sat, 21 May 2016 22:54:53 -0400 Subject: [PATCH] Fix multisampling when the VI origin is not 0 This happens with Beetle Adventure Racing when the movie reel effect is at work. It threw up a whole bunch of errors without taking into account whether or not the framebuffer is multi-sampled. --- src/FrameBuffer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 78050b99..ac5a10d8 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -1004,13 +1004,19 @@ void FrameBufferList::renderBuffer(u32 _address) const u32 size = *REG.VI_STATUS & 3; pBuffer = findBuffer(_address + (((*REG.VI_WIDTH)*VI.height)<>1)); if (pBuffer != NULL) { + pFilteredBuffer = PostProcessor::get().doBlur(PostProcessor::get().doGammaCorrection(pBuffer)); srcY0 = 0; srcY1 = srcPartHeight; dstY0 = dstY1; dstY1 = dstY0 + dstPartHeight; - glBindFramebuffer(GL_READ_FRAMEBUFFER, pBuffer->m_FBO); + if (pFilteredBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) { + pFilteredBuffer->resolveMultisampledTexture(); + glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_resolveFBO); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + } else + glBindFramebuffer(GL_READ_FRAMEBUFFER, pFilteredBuffer->m_FBO); glBlitFramebuffer( - 0, (GLint)(srcY0*srcScaleY), Xwidth, min((GLint)(srcY1*srcScaleY), (GLint)pBuffer->m_pTexture->realHeight), + 0, (GLint)(srcY0*srcScaleY), Xwidth, min((GLint)(srcY1*srcScaleY), (GLint)pFilteredBuffer->m_pTexture->realHeight), hOffset, vOffset + (GLint)(dstY0*dstScaleY), hOffset + X1, vOffset + (GLint)(dstY1*dstScaleY), GL_COLOR_BUFFER_BIT, filter );