1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00

Fix EGL image being broken at 1x native resolution factor

This commit is contained in:
fzurita 2021-04-18 10:40:35 -04:00 committed by Sergey Lipskiy
parent 43a5d16905
commit 1d90610782

View File

@ -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<u32>(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<u32>(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;