From 1d90610782343ad965c4cfdc2ffc1a8dc39256bc Mon Sep 17 00:00:00 2001 From: fzurita Date: Sun, 18 Apr 2021 10:40:35 -0400 Subject: [PATCH] Fix EGL image being broken at 1x native resolution factor --- src/BufferCopy/ColorBufferToRDRAM.cpp | 72 +++++++++++++-------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/src/BufferCopy/ColorBufferToRDRAM.cpp b/src/BufferCopy/ColorBufferToRDRAM.cpp index c051e457..b1d1a61d 100644 --- a/src/BufferCopy/ColorBufferToRDRAM.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM.cpp @@ -87,47 +87,43 @@ bool ColorBufferToRDRAM::_prepareCopy(u32& _startAddress) readBuffer = m_pCurFrameBuffer->m_FBO; } - if (m_pCurFrameBuffer->m_scale != 1.0f) { - u32 x0 = 0; - u32 width; - if (config.frameBufferEmulation.nativeResFactor == 0) { - const u32 screenWidth = wnd.getWidth(); - width = screenWidth; - if (wnd.isAdjustScreen()) { - width = static_cast(screenWidth*wnd.getAdjustScale()); - x0 = (screenWidth - width) / 2; - } - } else { - width = m_pCurFrameBuffer->m_pTexture->width; + u32 x0 = 0; + u32 width; + if (config.frameBufferEmulation.nativeResFactor == 0) { + const u32 screenWidth = wnd.getWidth(); + width = screenWidth; + if (wnd.isAdjustScreen()) { + width = static_cast(screenWidth*wnd.getAdjustScale()); + x0 = (screenWidth - width) / 2; } - u32 height = (u32)(bufferHeight * m_pCurFrameBuffer->m_scale); - - CachedTexture * pInputTexture = m_pCurFrameBuffer->m_pTexture; - GraphicsDrawer::BlitOrCopyRectParams blitParams; - blitParams.srcX0 = x0; - blitParams.srcY0 = 0; - blitParams.srcX1 = x0 + width; - blitParams.srcY1 = height; - blitParams.srcWidth = pInputTexture->width; - blitParams.srcHeight = pInputTexture->height; - blitParams.dstX0 = 0; - blitParams.dstY0 = 0; - blitParams.dstX1 = m_pCurFrameBuffer->m_width; - blitParams.dstY1 = bufferHeight; - blitParams.dstWidth = colorBufferTexture->width; - blitParams.dstHeight = colorBufferTexture->height; - blitParams.filter = textureParameters::FILTER_LINEAR; - blitParams.tex[0] = pInputTexture; - blitParams.combiner = CombinerInfo::get().getTexrectDownscaleCopyProgram(); - blitParams.readBuffer = readBuffer; - blitParams.drawBuffer = pBuffer->getColorFbFbo(); - blitParams.mask = blitMask::COLOR_BUFFER; - wnd.getDrawer().blitOrCopyTexturedRect(blitParams); - - gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, pBuffer->getColorFbFbo()); } else { - gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, readBuffer); + width = m_pCurFrameBuffer->m_pTexture->width; } + u32 height = (u32)(bufferHeight * m_pCurFrameBuffer->m_scale); + + CachedTexture * pInputTexture = m_pCurFrameBuffer->m_pTexture; + GraphicsDrawer::BlitOrCopyRectParams blitParams; + blitParams.srcX0 = x0; + blitParams.srcY0 = 0; + blitParams.srcX1 = x0 + width; + blitParams.srcY1 = height; + blitParams.srcWidth = pInputTexture->width; + blitParams.srcHeight = pInputTexture->height; + blitParams.dstX0 = 0; + blitParams.dstY0 = 0; + blitParams.dstX1 = m_pCurFrameBuffer->m_width; + blitParams.dstY1 = bufferHeight; + blitParams.dstWidth = colorBufferTexture->width; + blitParams.dstHeight = colorBufferTexture->height; + blitParams.filter = m_pCurFrameBuffer->m_scale == 1.0f ? textureParameters::FILTER_NEAREST : textureParameters::FILTER_LINEAR; + blitParams.tex[0] = pInputTexture; + blitParams.combiner = CombinerInfo::get().getTexrectDownscaleCopyProgram(); + blitParams.readBuffer = readBuffer; + blitParams.drawBuffer = pBuffer->getColorFbFbo(); + blitParams.mask = blitMask::COLOR_BUFFER; + wnd.getDrawer().blitOrCopyTexturedRect(blitParams); + + gfxContext.bindFramebuffer(bufferTarget::READ_FRAMEBUFFER, pBuffer->getColorFbFbo()); m_frameCount = curFrame; m_startAddress = _startAddress;