From 07854d38579bd2cff1ff19eb6365820eb2312c16 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Thu, 23 Jun 2016 16:15:27 +0600 Subject: [PATCH] Use OGLRender::copyTexturedRect in ColorBufferToRDRAM::_prepareCopy. Enable color buffer copy for GLES2. --- src/BufferCopy/ColorBufferToRDRAM.cpp | 23 ++++++++++------------- src/FrameBuffer.cpp | 15 +-------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/BufferCopy/ColorBufferToRDRAM.cpp b/src/BufferCopy/ColorBufferToRDRAM.cpp index 0837e25d..dd54eda0 100644 --- a/src/BufferCopy/ColorBufferToRDRAM.cpp +++ b/src/BufferCopy/ColorBufferToRDRAM.cpp @@ -30,8 +30,6 @@ ColorBufferToRDRAM::~ColorBufferToRDRAM() { } -#ifndef GLES2 - void ColorBufferToRDRAM::init() { // generate a framebuffer @@ -160,15 +158,14 @@ bool ColorBufferToRDRAM::_prepareCopy(u32 _startAddress) width = m_pCurFrameBuffer->m_pTexture->realWidth; height = m_pCurFrameBuffer->m_pTexture->realHeight; } - glDisable(GL_SCISSOR_TEST); - glBlitFramebuffer( - x0, 0, x0 + width, height, - 0, 0, VI.width, VI.height, - GL_COLOR_BUFFER_BIT, GL_NEAREST - ); - glEnable(GL_SCISSOR_TEST); + + CachedTexture * pInputTexture = frameBufferList().getCurrent()->m_pTexture; + ogl.getRender().copyTexturedRect(x0, 0, x0 + width, height, + pInputTexture->realWidth, pInputTexture->realHeight, pInputTexture->glName, + 0, 0, VI.width, VI.height, + m_pTexture->realWidth, m_pTexture->realHeight, GL_NEAREST); + glBindFramebuffer(GL_READ_FRAMEBUFFER, m_FBO); - frameBufferList().setCurrentDrawBuffer(); } m_frameCount = curFrame; @@ -209,7 +206,9 @@ void ColorBufferToRDRAM::_copy(u32 _startAddress, u32 _endAddress, bool _sync) const GLint y1 = max_height - (_startAddress - m_pCurFrameBuffer->m_startAddress) / stride; const GLsizei height = std::min(max_height, 1u + y1 - y0); - if (!_readPixels(x0, y0, width, height, m_pCurFrameBuffer->m_size, _sync)) + const bool pixelsRead = _readPixels(x0, y0, width, height, m_pCurFrameBuffer->m_size, _sync); + frameBufferList().setCurrentDrawBuffer(); + if (!pixelsRead) return; if (m_pCurFrameBuffer->m_size == G_IM_SIZ_32b) { @@ -263,8 +262,6 @@ void ColorBufferToRDRAM::copyChunkToRDRAM(u32 _address) _copy(_address, _address + 0x1000, true); } -#endif // GLES2 - void copyWhiteToRDRAM(FrameBuffer * _pBuffer) { if (_pBuffer->m_size == G_IM_SIZ_32b) { diff --git a/src/FrameBuffer.cpp b/src/FrameBuffer.cpp index 0c60066f..ac3bb497 100644 --- a/src/FrameBuffer.cpp +++ b/src/FrameBuffer.cpp @@ -746,8 +746,8 @@ void FrameBuffer_Init() { frameBufferList().init(); if (config.frameBufferEmulation.enable != 0) { -#ifndef GLES2 ColorBufferToRDRAM::get().init(); +#ifndef GLES2 DepthBufferToRDRAM::get().init(); #endif RDRAMtoColorBuffer::get().init(); @@ -941,25 +941,12 @@ void FrameBuffer_ActivateBufferTextureBG(u32 t, FrameBuffer *pBuffer ) void FrameBuffer_CopyToRDRAM(u32 _address, bool _sync) { -#ifndef GLES2 ColorBufferToRDRAM::get().copyToRDRAM(_address, _sync); -#else - if ((config.generalEmulation.hacks & hack_subscreen) == 0) - return; - if (VI.width == 0 || frameBufferList().getCurrent() == nullptr) - return; - FrameBuffer *pBuffer = frameBufferList().findBuffer(_address); - if (pBuffer == nullptr || pBuffer->m_width < VI.width || pBuffer->m_isOBScreen) - return; - copyWhiteToRDRAM(pBuffer); -#endif } void FrameBuffer_CopyChunkToRDRAM(u32 _address) { -#ifndef GLES2 ColorBufferToRDRAM::get().copyChunkToRDRAM(_address); -#endif } bool FrameBuffer_CopyDepthBuffer( u32 address )