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

Fix postprocessor when native resolution factor is used.

This commit is contained in:
Sergey Lipskiy 2016-05-13 23:29:35 +06:00
parent 71caf75b7a
commit d571587531
3 changed files with 13 additions and 11 deletions

View File

@ -944,8 +944,10 @@ void FrameBufferList::renderBuffer(u32 _address)
srcY1 = srcY0 + VI.real_height;
}
FrameBuffer * pFilteredBuffer = PostProcessor::get().doBlur(PostProcessor::get().doGammaCorrection(pBuffer));
const f32 viScaleX = _FIXED2FLOAT(_SHIFTR(*REG.VI_X_SCALE, 0, 12), 10);
const f32 srcScaleX = pBuffer->m_scaleX;
const f32 srcScaleX = pFilteredBuffer->m_scaleX;
const f32 dstScaleX = ogl.getScaleX();
const s32 h0 = (isPAL ? 128 : 108);
const s32 hx0 = max(0, hStart - h0);
@ -954,10 +956,10 @@ void FrameBufferList::renderBuffer(u32 _address)
Xwidth = (GLint)((min((f32)VI.width, (hEnd - hStart)*viScaleX)) * srcScaleX);
X1 = ogl.getWidth() - (GLint)(hx1 *viScaleX * dstScaleX);
const float srcScaleY = pBuffer->m_scaleY;
const f32 srcScaleY = pFilteredBuffer->m_scaleY;
const GLint hOffset = (ogl.getScreenWidth() - ogl.getWidth()) / 2;
const GLint vOffset = (ogl.getScreenHeight() - ogl.getHeight()) / 2 + ogl.getHeightOffset();
CachedTexture * pBufferTexture = pBuffer->m_pTexture;
CachedTexture * pBufferTexture = pFilteredBuffer->m_pTexture;
GLint srcCoord[4] = { 0, (GLint)(srcY0*srcScaleY), Xwidth, min((GLint)(srcY1*srcScaleY), (GLint)pBufferTexture->realHeight) };
if (srcCoord[2] > pBufferTexture->realWidth || srcCoord[3] > pBufferTexture->realHeight) {
removeBuffer(pBuffer->m_startAddress);
@ -969,7 +971,6 @@ void FrameBufferList::renderBuffer(u32 _address)
dstCoord[0] += 1; // workaround for Adreno's issue with glBindFramebuffer;
#endif // GLESX
FrameBuffer * pFilteredBuffer = PostProcessor::get().doBlur(PostProcessor::get().doGammaCorrection(pBuffer));
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
//glDrawBuffer( GL_BACK );
float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };

View File

@ -488,7 +488,7 @@ PostProcessor & PostProcessor::get()
return processor;
}
void _setGLState(FrameBuffer * _pBuffer) {
void PostProcessor::_setGLState() {
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
@ -509,20 +509,20 @@ void _setGLState(FrameBuffer * _pBuffer) {
glDisableVertexAttribArray(SC_NUMLIGHTS);
glDisableVertexAttribArray(SC_MODIFY);
glViewport(0, 0, video().getWidth(), video().getHeight());
glScissor(0, 0, _pBuffer->m_pTexture->realWidth, _pBuffer->m_pTexture->realHeight);
glScissor(0, 0, m_pResultBuffer->m_pTexture->realWidth, m_pResultBuffer->m_pTexture->realHeight);
gSP.changed |= CHANGED_VIEWPORT;
gDP.changed |= CHANGED_RENDERMODE | CHANGED_SCISSOR;
}
void PostProcessor::_preDraw(FrameBuffer * _pBuffer)
{
_setGLState(_pBuffer);
_setGLState();
OGLVideo & ogl = video();
m_pResultBuffer->m_width = _pBuffer->m_width;
m_pResultBuffer->m_height = _pBuffer->m_height;
m_pResultBuffer->m_scaleX = _pBuffer->m_scaleX;
m_pResultBuffer->m_scaleY = _pBuffer->m_scaleY;
m_pResultBuffer->m_scaleX = ogl.getScaleX();
m_pResultBuffer->m_scaleY = ogl.getScaleY();
#ifdef GLES2
m_pTextureOriginal = _pBuffer->m_pTexture;
#else
@ -530,8 +530,8 @@ void PostProcessor::_preDraw(FrameBuffer * _pBuffer)
glBindFramebuffer(GL_READ_FRAMEBUFFER, _pBuffer->m_FBO);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_FBO_resolved);
glBlitFramebuffer(
0, 0, ogl.getWidth(), ogl.getHeight(),
0, 0, ogl.getWidth(), ogl.getHeight(),
0, 0, _pBuffer->m_pTexture->realWidth, _pBuffer->m_pTexture->realHeight,
0, 0, m_pTextureResolved->realWidth, m_pTextureResolved->realHeight,
GL_COLOR_BUFFER_BIT, GL_LINEAR
);
m_pTextureOriginal = m_pTextureResolved;

View File

@ -24,6 +24,7 @@ private:
void _destroyGammaCorrection();
void _initBlur();
void _destroyBlur();
void _setGLState();
void _preDraw(FrameBuffer * _pBuffer);
void _postDraw();