From 21d64691cf200377074824a321a77fa89fd470f4 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Mon, 13 Mar 2017 21:45:21 +0700 Subject: [PATCH] Correct chained buffers detection in FrameBufferList::renderBuffer() --- src/FrameBuffer.cpp | 73 +++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 41b2585b..d4113c9c 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -1031,10 +1031,13 @@ void FrameBufferList::renderBuffer() srcWidth = min(rdpRes.vi_width, (rdpRes.vi_hres * rdpRes.vi_x_add) >> 10); srcHeight = rdpRes.vi_width * ((rdpRes.vi_vres*rdpRes.vi_y_add + rdpRes.vi_y_start) >> 10) / pBuffer->m_width; - u32 maxY = gDP.scissor.uly + gDP.scissor.lry; - if (maxY == 0) - maxY = vFullHeight; - if (srcY0 + srcHeight > maxY) { + + const u32 stride = pBuffer->m_width << pBuffer->m_size >> 1; + FrameBuffer *pNextBuffer = findBuffer(rdpRes.vi_origin + stride * srcHeight); + if (pNextBuffer == pBuffer) + pNextBuffer = nullptr; + + if (pNextBuffer != nullptr) { dstPartHeight = srcY0; // srcY0 = (s32)(srcY0*yScale); srcPartHeight = srcY0; @@ -1121,39 +1124,37 @@ void FrameBufferList::renderBuffer() drawer.copyTexturedRect(blitParams); - if (dstPartHeight > 0) { - const u32 size = *REG.VI_STATUS & 3; - pBuffer = findBuffer(rdpRes.vi_origin + (((*REG.VI_WIDTH)*VI.height) << size >> 1)); - if (pBuffer != nullptr) { - pFilteredBuffer = postProcessor.doBlur(postProcessor.doGammaCorrection( - postProcessor.doOrientationCorrection(pBuffer))); - srcY1 = srcPartHeight; - dstY0 = dstY1; - dstY1 = dstY0 + dstPartHeight; - if (pFilteredBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) { - pFilteredBuffer->resolveMultisampledTexture(); - readBuffer = pFilteredBuffer->m_resolveFBO; - pBufferTexture = pFilteredBuffer->m_pResolveTexture; - } else { - readBuffer = pFilteredBuffer->m_FBO; - pBufferTexture = pFilteredBuffer->m_pTexture; - } - - blitParams.srcY0 = 0; - blitParams.srcY1 = min((s32)(srcY1*srcScaleY), (s32)pFilteredBuffer->m_pTexture->realHeight); - blitParams.srcWidth = pBufferTexture->realWidth; - blitParams.srcHeight = pBufferTexture->realHeight; - blitParams.dstX0 = hOffset; - blitParams.dstY0 = vOffset + (s32)(dstY0*dstScaleY); - blitParams.dstX1 = hOffset + dstX1; - blitParams.dstY1 = vOffset + (s32)(dstY1*dstScaleY); - blitParams.dstWidth = wnd.getScreenWidth(); - blitParams.dstHeight = wnd.getScreenHeight() + wnd.getHeightOffset(); - blitParams.tex[0] = pBufferTexture; - blitParams.readBuffer = readBuffer; - - drawer.copyTexturedRect(blitParams); + if (pNextBuffer != nullptr) { + pNextBuffer->m_isMainBuffer = true; + pFilteredBuffer = postProcessor.doBlur(postProcessor.doGammaCorrection( + postProcessor.doOrientationCorrection(pNextBuffer))); + srcY1 = srcPartHeight; + dstY0 = dstY1; + dstY1 = dstY0 + dstPartHeight; + if (pFilteredBuffer->m_pTexture->frameBufferTexture == CachedTexture::fbMultiSample) { + pFilteredBuffer->resolveMultisampledTexture(); + readBuffer = pFilteredBuffer->m_resolveFBO; + pBufferTexture = pFilteredBuffer->m_pResolveTexture; } + else { + readBuffer = pFilteredBuffer->m_FBO; + pBufferTexture = pFilteredBuffer->m_pTexture; + } + + blitParams.srcY0 = 0; + blitParams.srcY1 = min((s32)(srcY1*srcScaleY), (s32)pFilteredBuffer->m_pTexture->realHeight); + blitParams.srcWidth = pBufferTexture->realWidth; + blitParams.srcHeight = pBufferTexture->realHeight; + blitParams.dstX0 = hOffset; + blitParams.dstY0 = vOffset + (s32)(dstY0*dstScaleY); + blitParams.dstX1 = hOffset + dstX1; + blitParams.dstY1 = vOffset + (s32)(dstY1*dstScaleY); + blitParams.dstWidth = wnd.getScreenWidth(); + blitParams.dstHeight = wnd.getScreenHeight() + wnd.getHeightOffset(); + blitParams.tex[0] = pBufferTexture; + blitParams.readBuffer = readBuffer; + + drawer.copyTexturedRect(blitParams); } gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, ObjectHandle::null);