diff options
author | popcornmix <popcornmix@gmail.com> | 2013-11-27 22:04:56 +0000 |
---|---|---|
committer | popcornmix <popcornmix@gmail.com> | 2013-11-28 20:31:49 +0000 |
commit | 518556b45b61de06a0bc810147cd1a6347497461 (patch) | |
tree | 7813c1b159d6ece3dedeccd68bb8eee58d2348d7 | |
parent | 037800e745c64549dc0c7887efd1a0954a6aa03e (diff) |
[GLES] Avoid getting viewport so often
GLES is generally offloaded to a GPU and fed a stream of commands.
These can be executed asynchronously by GPU and there is no need for the host to block.
Whenever a gl call requires a result back that may be affected by previous commands
the queue needs to be drained and a result returned from GPU. This acts as a bottleneck.
Looking closely at what xbmc does, there is only one call that requires a result that is
executed every frame. That is glGetIntegerv(GL_VIEWPORT).
However xbcm is perfectly capable of remembering what it set this to.
By using a cached version of this value, on a Pi, the framerate improves from 69fps to 95fps,
with vsync disabled, and RSS feed showing in home screen.
-rw-r--r-- | xbmc/rendering/gles/RenderSystemGLES.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/xbmc/rendering/gles/RenderSystemGLES.cpp b/xbmc/rendering/gles/RenderSystemGLES.cpp index 88d57a61d5..12b7c32cd0 100644 --- a/xbmc/rendering/gles/RenderSystemGLES.cpp +++ b/xbmc/rendering/gles/RenderSystemGLES.cpp @@ -395,11 +395,8 @@ void CRenderSystemGLES::SetCameraPosition(const CPoint &camera, int screenWidth, CPoint offset = camera - CPoint(screenWidth*0.5f, screenHeight*0.5f); - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - - float w = (float)viewport[2]*0.5f; - float h = (float)viewport[3]*0.5f; + float w = (float)m_viewPort[2]*0.5f; + float h = (float)m_viewPort[3]*0.5f; g_matrices.MatrixMode(MM_MODELVIEW); g_matrices.LoadIdentity(); @@ -410,7 +407,6 @@ void CRenderSystemGLES::SetCameraPosition(const CPoint &camera, int screenWidth, g_matrices.Frustum( (-w - offset.x)*0.5f, (w - offset.x)*0.5f, (-h + offset.y)*0.5f, (h + offset.y)*0.5f, h, 100*h); g_matrices.MatrixMode(MM_MODELVIEW); - glGetIntegerv(GL_VIEWPORT, m_viewPort); GLfloat* matx; matx = g_matrices.GetMatrix(MM_MODELVIEW); memcpy(m_view, matx, 16 * sizeof(GLfloat)); @@ -516,14 +512,11 @@ void CRenderSystemGLES::GetViewPort(CRect& viewPort) { if (!m_bRenderCreated) return; - - GLint glvp[4]; - glGetIntegerv(GL_VIEWPORT, glvp); - - viewPort.x1 = glvp[0]; - viewPort.y1 = m_height - glvp[1] - glvp[3]; - viewPort.x2 = glvp[0] + glvp[2]; - viewPort.y2 = viewPort.y1 + glvp[3]; + + viewPort.x1 = m_viewPort[0]; + viewPort.y1 = m_height - m_viewPort[1] - m_viewPort[3]; + viewPort.x2 = m_viewPort[0] + m_viewPort[2]; + viewPort.y2 = viewPort.y1 + m_viewPort[3]; } // FIXME make me const so that I can accept temporary objects @@ -534,6 +527,10 @@ void CRenderSystemGLES::SetViewPort(CRect& viewPort) glScissor((GLint) viewPort.x1, (GLint) (m_height - viewPort.y1 - viewPort.Height()), (GLsizei) viewPort.Width(), (GLsizei) viewPort.Height()); glViewport((GLint) viewPort.x1, (GLint) (m_height - viewPort.y1 - viewPort.Height()), (GLsizei) viewPort.Width(), (GLsizei) viewPort.Height()); + m_viewPort[0] = viewPort.x1; + m_viewPort[1] = viewPort.y1; + m_viewPort[2] = viewPort.x2; + m_viewPort[3] = viewPort.y2; } void CRenderSystemGLES::SetScissors(const CRect &rect) |