From 09274e2483abd7ea0ae26daa32f9cf3f7a3e2b16 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 12 Dec 2012 16:57:00 +0100 Subject: [PATCH] Check texture params before updateing them Signed-off-by: Ryan Houdek --- Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp | 4 ---- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.cpp | 9 ++++++++- Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp index 29166e4bc0..e3575eef4e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/RasterFont.cpp @@ -17,8 +17,6 @@ #include "GLUtil.h" -#include - #include "RasterFont.h" // globals @@ -150,7 +148,6 @@ static const char *s_fragment_shader = RasterFont::RasterFont() { // generate the texture - glEnable(GL_TEXTURE_RECTANGLE); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_RECTANGLE, texture); u32* texture_data = new u32[char_width*char_count*char_height]; @@ -281,7 +278,6 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_RECTANGLE, texture); - glEnable(GL_TEXTURE_RECTANGLE); glDrawArrays(GL_TRIANGLES, 0, usage/4); glUseProgram(0); 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; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h index 91245237d9..dc560e098b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureCache.h @@ -67,6 +67,8 @@ private: private: void SetTextureParameters(const TexMode0 &newmode, const TexMode1 &newmode1); + TexMode0 currmode; + TexMode1 currmode1; }; ~TextureCache();