From d021f9e3b65f507273d0a9b8bea2db46db9f062c Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 25 Aug 2011 04:28:29 -0500 Subject: Here we go with the texture cache --- .../Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 4a9431a563..55e20c0b05 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -302,12 +302,24 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect); - glBegin(GL_QUADS); - glTexCoord2f((GLfloat)targetSource.left, (GLfloat)targetSource.bottom); glVertex2f(-1, 1); - glTexCoord2f((GLfloat)targetSource.left, (GLfloat)targetSource.top ); glVertex2f(-1, -1); - glTexCoord2f((GLfloat)targetSource.right, (GLfloat)targetSource.top ); glVertex2f( 1, -1); - glTexCoord2f((GLfloat)targetSource.right, (GLfloat)targetSource.bottom); glVertex2f( 1, 1); - glEnd(); + GL_REPORT_ERRORD(); + + GLfloat tex1[] = { + (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, + (GLfloat)targetSource.left, (GLfloat)targetSource.top, + (GLfloat)targetSource.right, (GLfloat)targetSource.top, + (GLfloat)targetSource.right, (GLfloat)targetSource.bottom + }; + GLfloat vtx1[] = { + -1, 1, 1, + -1, -1, 1, + 1, -1, 1, + 1, 1, 1 + }; + glTexCoordPointer(2, GL_FLOAT, 0, tex1); + glVertexPointer(3, GL_FLOAT, 0, vtx1); + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + GL_REPORT_ERRORD(); -- cgit v1.2.3 From fb92c338af83a56edaabaea13168696e3cf1c7c7 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Sat, 27 Oct 2012 22:50:06 -0500 Subject: Bit of cleanup and fixing of one issue that was noticeable in SMS with Mario's shadow. --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 052727e1b0..797ba39c10 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -306,23 +306,22 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect); GL_REPORT_ERRORD(); - GLfloat tex1[] = { - (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, - (GLfloat)targetSource.left, (GLfloat)targetSource.top, - (GLfloat)targetSource.right, (GLfloat)targetSource.top, - (GLfloat)targetSource.right, (GLfloat)targetSource.bottom + (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, + (GLfloat)targetSource.left, (GLfloat)targetSource.top, + (GLfloat)targetSource.right, (GLfloat)targetSource.top, + (GLfloat)targetSource.right, (GLfloat)targetSource.bottom }; GLfloat vtx1[] = { - -1, 1, 1, - -1, -1, 1, - 1, -1, 1, - 1, 1, 1 + -1.f, 1.f, + -1.f, -1.f, + 1.f, -1.f, + 1.f, 1.f }; + glTexCoordPointer(2, GL_FLOAT, 0, tex1); - glVertexPointer(3, GL_FLOAT, 0, vtx1); + glVertexPointer(2, GL_FLOAT, 0, vtx1); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - GL_REPORT_ERRORD(); -- cgit v1.2.3 From 888b5fb061363d6ce644d7ebacb76b82778801c4 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 7 Dec 2012 14:40:52 +0100 Subject: remove usage of glMultiTexCoord2f Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 797ba39c10..6827539ce8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -319,6 +319,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo 1.f, 1.f }; + glClientActiveTexture(GL_TEXTURE0); glTexCoordPointer(2, GL_FLOAT, 0, tex1); glVertexPointer(2, GL_FLOAT, 0, vtx1); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); -- cgit v1.2.3 From 6864b40e26354f6b366e8fe8c2ff4f6680f09189 Mon Sep 17 00:00:00 2001 From: degasus Date: Fri, 7 Dec 2012 21:09:48 +0100 Subject: reset glEnableClientState befor every draw should be done with VAO, but atm, this is not possible :-( this also partial revert the fix in fb92c338af83 (activating texture0 globally). Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 6827539ce8..5441a65901 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -319,6 +319,21 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo 1.f, 1.f }; + // disable all pointer, TODO: use VAO + glEnableClientState(GL_VERTEX_ARRAY); + glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableVertexAttribArray(SHADER_NORM1_ATTRIB); + glDisableVertexAttribArray(SHADER_NORM2_ATTRIB); + glDisableClientState(GL_COLOR_ARRAY); + glDisableClientState(GL_SECONDARY_COLOR_ARRAY); + glClientActiveTexture(GL_TEXTURE0); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + for(int i=1; i<8; i++) { + glClientActiveTexture(GL_TEXTURE0 + i); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + glClientActiveTexture(GL_TEXTURE0); glTexCoordPointer(2, GL_FLOAT, 0, tex1); glVertexPointer(2, GL_FLOAT, 0, vtx1); -- cgit v1.2.3 From d44228f1b7ec13db032ff558a6e3bc87e5789216 Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 8 Dec 2012 00:54:38 +0100 Subject: TextureCache::TCacheEntry::FromRenderTarget as vbo Signed-off-by: Ryan Houdek --- .../Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 47 ++++++++++++++-------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 5441a65901..30b67119df 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -57,6 +57,7 @@ namespace OGL { static u32 s_TempFramebuffer = 0; +static GLuint s_VBO = 0; static const GLint c_MinLinearFilter[8] = { GL_NEAREST, @@ -306,19 +307,20 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect); GL_REPORT_ERRORD(); - GLfloat tex1[] = { - (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, - (GLfloat)targetSource.left, (GLfloat)targetSource.top, - (GLfloat)targetSource.right, (GLfloat)targetSource.top, - (GLfloat)targetSource.right, (GLfloat)targetSource.bottom - }; - GLfloat vtx1[] = { - -1.f, 1.f, - -1.f, -1.f, - 1.f, -1.f, - 1.f, 1.f + GLfloat vertices[] = { + -1.f, 1.f, + (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, + -1.f, -1.f, + (GLfloat)targetSource.left, (GLfloat)targetSource.top, + 1.f, -1.f, + (GLfloat)targetSource.right, (GLfloat)targetSource.top, + 1.f, 1.f, + (GLfloat)targetSource.right, (GLfloat)targetSource.bottom }; + glBindBuffer(GL_ARRAY_BUFFER, s_VBO); + glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW); + // disable all pointer, TODO: use VAO glEnableClientState(GL_VERTEX_ARRAY); glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB); @@ -335,9 +337,12 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo } glClientActiveTexture(GL_TEXTURE0); - glTexCoordPointer(2, GL_FLOAT, 0, tex1); - glVertexPointer(2, GL_FLOAT, 0, vtx1); + glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2); + glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, 0); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + // TODO: this should be removed if we use vbo everywhere + glBindBuffer(GL_ARRAY_BUFFER, 0); GL_REPORT_ERRORD(); @@ -415,13 +420,21 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co (float)(1 << g_ActiveConfig.iMaxAnisotropy)); } +TextureCache::TextureCache() +{ + glGenBuffers(1, &s_VBO); +} + + TextureCache::~TextureCache() { - if (s_TempFramebuffer) + glDeleteBuffers(1, &s_VBO); + + if (s_TempFramebuffer) { - glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer); - s_TempFramebuffer = 0; - } + glDeleteFramebuffersEXT(1, (GLuint*)&s_TempFramebuffer); + s_TempFramebuffer = 0; + } } void TextureCache::DisableStage(unsigned int stage) -- cgit v1.2.3 From 34b1451fbea2798f943be7c84f0677f95a81ed84 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 9 Dec 2012 20:30:29 +0100 Subject: cache vbos in TextureCache::TCacheEntry::FromRenderTarget Signed-off-by: Ryan Houdek --- .../Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 58 ++++++++++++++++------ 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 30b67119df..6685d8a176 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -56,8 +56,13 @@ namespace OGL { +struct VBOCache { + GLuint vbo; + TargetRectangle targetSource; +}; +static std::map s_VBO; + static u32 s_TempFramebuffer = 0; -static GLuint s_VBO = 0; static const GLint c_MinLinearFilter[8] = { GL_NEAREST, @@ -305,21 +310,41 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo GL_REPORT_ERRORD(); TargetRectangle targetSource = g_renderer->ConvertEFBRectangle(srcRect); - GL_REPORT_ERRORD(); - GLfloat vertices[] = { - -1.f, 1.f, - (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, - -1.f, -1.f, - (GLfloat)targetSource.left, (GLfloat)targetSource.top, - 1.f, -1.f, - (GLfloat)targetSource.right, (GLfloat)targetSource.top, - 1.f, 1.f, - (GLfloat)targetSource.right, (GLfloat)targetSource.bottom - }; - glBindBuffer(GL_ARRAY_BUFFER, s_VBO); - glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW); + // should be unique enough, if not, vbo will "only" be uploaded to much + u32 targetSourceHash = targetSource.left<<24 | targetSource.top<<16 | targetSource.right<<8 | targetSource.bottom; + std::map::iterator vbo_it = s_VBO.find(targetSourceHash); + + if(vbo_it == s_VBO.end()) { + VBOCache item; + item.targetSource.bottom = -1; + item.targetSource.top = -1; + item.targetSource.left = -1; + item.targetSource.right = -1; + glGenBuffers(1, &item.vbo); + vbo_it = s_VBO.insert(std::pair(targetSourceHash, item)).first; + } + if(!(vbo_it->second.targetSource == targetSource)) { + GLfloat vertices[] = { + -1.f, 1.f, + (GLfloat)targetSource.left, (GLfloat)targetSource.bottom, + -1.f, -1.f, + (GLfloat)targetSource.left, (GLfloat)targetSource.top, + 1.f, -1.f, + (GLfloat)targetSource.right, (GLfloat)targetSource.top, + 1.f, 1.f, + (GLfloat)targetSource.right, (GLfloat)targetSource.bottom + }; + + glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo); + glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW); + + vbo_it->second.targetSource = targetSource; + } else { + // TODO: remove after switched to VAO + glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo); + } // disable all pointer, TODO: use VAO glEnableClientState(GL_VERTEX_ARRAY); @@ -422,13 +447,14 @@ void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, co TextureCache::TextureCache() { - glGenBuffers(1, &s_VBO); } TextureCache::~TextureCache() { - glDeleteBuffers(1, &s_VBO); + for(std::map::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) { + glGenBuffers(1, &it->second.vbo); + } if (s_TempFramebuffer) { -- cgit v1.2.3 From 5c8800968a0f8f08229ce4a59365ff9c66bc5a19 Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 9 Dec 2012 20:56:58 +0100 Subject: also check for vbo updates in EncodeToRamUsingShader Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 6685d8a176..95ddd80e94 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -455,6 +455,7 @@ TextureCache::~TextureCache() for(std::map::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) { glGenBuffers(1, &it->second.vbo); } + s_VBO.clear(); if (s_TempFramebuffer) { -- cgit v1.2.3 From c207422987a3f39032ee348fed4bde1b67a21fcc Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 9 Dec 2012 22:49:58 +0100 Subject: using of vao, warning: ARB_vertex_array_object is needed Signed-off-by: Ryan Houdek --- .../Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 45 +++++++++------------- 1 file changed, 18 insertions(+), 27 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 95ddd80e94..046ab4bcf2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -58,6 +58,7 @@ namespace OGL struct VBOCache { GLuint vbo; + GLuint vao; TargetRectangle targetSource; }; static std::map s_VBO; @@ -323,6 +324,18 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo item.targetSource.left = -1; item.targetSource.right = -1; glGenBuffers(1, &item.vbo); + glGenVertexArrays(1, &item.vao); + + glBindBuffer(GL_ARRAY_BUFFER, item.vbo); + glBindVertexArray(item.vao); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, 0); + + glClientActiveTexture(GL_TEXTURE0); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2); + vbo_it = s_VBO.insert(std::pair(targetSourceHash, item)).first; } if(!(vbo_it->second.targetSource == targetSource)) { @@ -336,38 +349,15 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo 1.f, 1.f, (GLfloat)targetSource.right, (GLfloat)targetSource.bottom }; - + glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo); glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW); vbo_it->second.targetSource = targetSource; - } else { - // TODO: remove after switched to VAO - glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo); - } - - // disable all pointer, TODO: use VAO - glEnableClientState(GL_VERTEX_ARRAY); - glDisableVertexAttribArray(SHADER_POSMTX_ATTRIB); - glDisableClientState(GL_NORMAL_ARRAY); - glDisableVertexAttribArray(SHADER_NORM1_ATTRIB); - glDisableVertexAttribArray(SHADER_NORM2_ATTRIB); - glDisableClientState(GL_COLOR_ARRAY); - glDisableClientState(GL_SECONDARY_COLOR_ARRAY); - glClientActiveTexture(GL_TEXTURE0); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - for(int i=1; i<8; i++) { - glClientActiveTexture(GL_TEXTURE0 + i); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } + } - glClientActiveTexture(GL_TEXTURE0); - glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2); - glVertexPointer(2, GL_FLOAT, sizeof(GLfloat)*4, 0); + glBindVertexArray(vbo_it->second.vao); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - - // TODO: this should be removed if we use vbo everywhere - glBindBuffer(GL_ARRAY_BUFFER, 0); GL_REPORT_ERRORD(); @@ -453,7 +443,8 @@ TextureCache::TextureCache() TextureCache::~TextureCache() { for(std::map::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) { - glGenBuffers(1, &it->second.vbo); + glDeleteBuffers(1, &it->second.vbo); + glDeleteVertexArrays(1, &it->second.vao); } s_VBO.clear(); -- cgit v1.2.3 From 23a3336f9a545e88dd7e5f2b96d363c61f9004be Mon Sep 17 00:00:00 2001 From: degasus Date: Tue, 11 Dec 2012 17:25:53 +0100 Subject: increase hash size to u64 Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 046ab4bcf2..94304f9c44 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -61,7 +61,7 @@ struct VBOCache { GLuint vao; TargetRectangle targetSource; }; -static std::map s_VBO; +static std::map s_VBO; static u32 s_TempFramebuffer = 0; @@ -314,8 +314,8 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo GL_REPORT_ERRORD(); // should be unique enough, if not, vbo will "only" be uploaded to much - u32 targetSourceHash = targetSource.left<<24 | targetSource.top<<16 | targetSource.right<<8 | targetSource.bottom; - std::map::iterator vbo_it = s_VBO.find(targetSourceHash); + u64 targetSourceHash = u64(targetSource.left)<<48 | u64(targetSource.top)<<32 | u64(targetSource.right)<<16 | u64(targetSource.bottom); + std::map::iterator vbo_it = s_VBO.find(targetSourceHash); if(vbo_it == s_VBO.end()) { VBOCache item; @@ -336,7 +336,7 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat)*4, (GLfloat*)NULL + 2); - vbo_it = s_VBO.insert(std::pair(targetSourceHash, item)).first; + vbo_it = s_VBO.insert(std::pair(targetSourceHash, item)).first; } if(!(vbo_it->second.targetSource == targetSource)) { GLfloat vertices[] = { @@ -442,7 +442,7 @@ TextureCache::TextureCache() TextureCache::~TextureCache() { - for(std::map::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) { + for(std::map::iterator it = s_VBO.begin(); it != s_VBO.end(); it++) { glDeleteBuffers(1, &it->second.vbo); glDeleteVertexArrays(1, &it->second.vao); } -- cgit v1.2.3 From 09274e2483abd7ea0ae26daa32f9cf3f7a3e2b16 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 12 Dec 2012 16:57:00 +0100 Subject: Check texture params before updateing them Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 94304f9c44..4f05ccb777 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -113,6 +113,8 @@ TextureCache::TCacheEntry::~TCacheEntry() TextureCache::TCacheEntry::TCacheEntry() { glGenTextures(1, &texture); + currmode.hex = 0; + currmode1.hex = 0; GL_REPORT_ERRORD(); } @@ -125,7 +127,9 @@ void TextureCache::TCacheEntry::Bind(unsigned int stage) // TODO: is this already done somewhere else? TexMode0 &tm0 = bpmem.tex[stage >> 2].texMode0[stage & 3]; TexMode1 &tm1 = bpmem.tex[stage >> 2].texMode1[stage & 3]; - SetTextureParameters(tm0, tm1); + + if(currmode.hex != tm0.hex || currmode1.hex != tm1.hex) + SetTextureParameters(tm0, tm1); } bool TextureCache::TCacheEntry::Save(const char filename[], unsigned int level) @@ -404,6 +408,9 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo void TextureCache::TCacheEntry::SetTextureParameters(const TexMode0 &newmode, const TexMode1 &newmode1) { + currmode = newmode; + currmode1 = newmode1; + // TODO: not used anywhere TexMode0 mode = newmode; //mode1 = newmode1; -- cgit v1.2.3 From 79a7ce4827de774bc0d454ad2e679f99e1da96fe Mon Sep 17 00:00:00 2001 From: degasus Date: Thu, 13 Dec 2012 15:48:42 +0100 Subject: move glBindBuffer and glBindVertexArray out of VertexManager Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp') diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp index 4f05ccb777..40dac17df6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp @@ -357,11 +357,17 @@ void TextureCache::TCacheEntry::FromRenderTarget(u32 dstAddr, unsigned int dstFo glBindBuffer(GL_ARRAY_BUFFER, vbo_it->second.vbo); glBufferData(GL_ARRAY_BUFFER, 4*4*sizeof(GLfloat), vertices, GL_STREAM_DRAW); + // TODO: this after merging with graphic_update + glBindBuffer(GL_ARRAY_BUFFER, 0); + vbo_it->second.targetSource = targetSource; } glBindVertexArray(vbo_it->second.vao); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + // TODO: this after merging with graphic_update + glBindVertexArray(0); GL_REPORT_ERRORD(); -- cgit v1.2.3