From d0c4332d99b77d0869f4f9dc23a77452d0cbb381 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 9 Dec 2012 19:22:21 +0100 Subject: [PATCH] don't update vbo, if there are no changes in Renderer::Swap Signed-off-by: Ryan Houdek --- Source/Core/Common/Src/MathUtil.h | 2 + Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 51 ++++++++++++------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Source/Core/Common/Src/MathUtil.h b/Source/Core/Common/Src/MathUtil.h index a6290ff602..c5f613ada1 100644 --- a/Source/Core/Common/Src/MathUtil.h +++ b/Source/Core/Common/Src/MathUtil.h @@ -117,6 +117,8 @@ struct Rectangle Rectangle(T theLeft, T theTop, T theRight, T theBottom) : left(theLeft), top(theTop), right(theRight), bottom(theBottom) { } + + bool operator==(const Rectangle& r) { return left==r.left && top==r.top && right==r.right && bottom==r.bottom; } T GetWidth() const { return abs(right - left); } T GetHeight() const { return abs(bottom - top); } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index 9350b4ca46..8df239700e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -109,6 +109,7 @@ namespace OGL static int s_fps = 0; static GLuint s_ShowEFBCopyRegions_VBO = 0; static GLuint s_Swap_VBO = 0; +static TargetRectangle s_old_targetRc; static RasterFont* s_pfont = NULL; @@ -254,6 +255,13 @@ Renderer::Renderer() s_ShowEFBCopyRegions_VBO = 0; s_Swap_VBO = 0; s_blendMode = 0; + + // should be invalid, so there will be an upload on the first call + s_old_targetRc.bottom = -1; + s_old_targetRc.top = -1; + s_old_targetRc.left = -1; + s_old_targetRc.right = -1; + InitFPSCounter(); @@ -1221,26 +1229,33 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture); - GLfloat vertices[] = { - -1.0f, -1.0f, 1.0f, - (GLfloat)targetRc.left, (GLfloat)targetRc.bottom, - 0.0f, 0.0f, + if(!(s_old_targetRc == targetRc)) { + GLfloat vertices[] = { + -1.0f, -1.0f, 1.0f, + (GLfloat)targetRc.left, (GLfloat)targetRc.bottom, + 0.0f, 0.0f, + + -1.0f, 1.0f, 1.0f, + (GLfloat)targetRc.left, (GLfloat)targetRc.top, + 0.0f, 1.0f, + + 1.0f, 1.0f, 1.0f, + (GLfloat)targetRc.right, (GLfloat)targetRc.top, + 1.0f, 1.0f, + + 1.0f, -1.0f, 1.0f, + (GLfloat)targetRc.right, (GLfloat)targetRc.bottom, + 1.0f, 0.0f + }; - -1.0f, 1.0f, 1.0f, - (GLfloat)targetRc.left, (GLfloat)targetRc.top, - 0.0f, 1.0f, + glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO); + glBufferData(GL_ARRAY_BUFFER, 4*7*sizeof(GLfloat), vertices, GL_STREAM_DRAW); - 1.0f, 1.0f, 1.0f, - (GLfloat)targetRc.right, (GLfloat)targetRc.top, - 1.0f, 1.0f, - - 1.0f, -1.0f, 1.0f, - (GLfloat)targetRc.right, (GLfloat)targetRc.bottom, - 1.0f, 0.0f - }; - - glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO); - glBufferData(GL_ARRAY_BUFFER, 4*7*sizeof(GLfloat), vertices, GL_STREAM_DRAW); + s_old_targetRc = targetRc; + } else { + // TODO: remove this after switch to VAO + glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO); + } // disable all pointer, TODO: use VAO glEnableClientState(GL_VERTEX_ARRAY);