don't update vbo, if there are no changes in Renderer::Swap
Signed-off-by: Ryan Houdek <Sonicadvance1@gmail.com>
This commit is contained in:
parent
bbcb442983
commit
d0c4332d99
|
@ -118,6 +118,8 @@ struct Rectangle
|
||||||
: left(theLeft), top(theTop), right(theRight), bottom(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 GetWidth() const { return abs(right - left); }
|
||||||
T GetHeight() const { return abs(bottom - top); }
|
T GetHeight() const { return abs(bottom - top); }
|
||||||
|
|
||||||
|
|
|
@ -109,6 +109,7 @@ namespace OGL
|
||||||
static int s_fps = 0;
|
static int s_fps = 0;
|
||||||
static GLuint s_ShowEFBCopyRegions_VBO = 0;
|
static GLuint s_ShowEFBCopyRegions_VBO = 0;
|
||||||
static GLuint s_Swap_VBO = 0;
|
static GLuint s_Swap_VBO = 0;
|
||||||
|
static TargetRectangle s_old_targetRc;
|
||||||
|
|
||||||
static RasterFont* s_pfont = NULL;
|
static RasterFont* s_pfont = NULL;
|
||||||
|
|
||||||
|
@ -255,6 +256,13 @@ Renderer::Renderer()
|
||||||
s_Swap_VBO = 0;
|
s_Swap_VBO = 0;
|
||||||
s_blendMode = 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();
|
InitFPSCounter();
|
||||||
|
|
||||||
#if defined HAVE_CG && HAVE_CG
|
#if defined HAVE_CG && HAVE_CG
|
||||||
|
@ -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
|
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // switch to the window backbuffer
|
||||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, read_texture);
|
||||||
|
|
||||||
GLfloat vertices[] = {
|
if(!(s_old_targetRc == targetRc)) {
|
||||||
-1.0f, -1.0f, 1.0f,
|
GLfloat vertices[] = {
|
||||||
(GLfloat)targetRc.left, (GLfloat)targetRc.bottom,
|
-1.0f, -1.0f, 1.0f,
|
||||||
0.0f, 0.0f,
|
(GLfloat)targetRc.left, (GLfloat)targetRc.bottom,
|
||||||
|
0.0f, 0.0f,
|
||||||
|
|
||||||
-1.0f, 1.0f, 1.0f,
|
-1.0f, 1.0f, 1.0f,
|
||||||
(GLfloat)targetRc.left, (GLfloat)targetRc.top,
|
(GLfloat)targetRc.left, (GLfloat)targetRc.top,
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
|
|
||||||
1.0f, 1.0f, 1.0f,
|
1.0f, 1.0f, 1.0f,
|
||||||
(GLfloat)targetRc.right, (GLfloat)targetRc.top,
|
(GLfloat)targetRc.right, (GLfloat)targetRc.top,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
|
|
||||||
1.0f, -1.0f, 1.0f,
|
1.0f, -1.0f, 1.0f,
|
||||||
(GLfloat)targetRc.right, (GLfloat)targetRc.bottom,
|
(GLfloat)targetRc.right, (GLfloat)targetRc.bottom,
|
||||||
1.0f, 0.0f
|
1.0f, 0.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO);
|
glBindBuffer(GL_ARRAY_BUFFER, s_Swap_VBO);
|
||||||
glBufferData(GL_ARRAY_BUFFER, 4*7*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
|
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
|
// disable all pointer, TODO: use VAO
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
Loading…
Reference in New Issue