From 59ab65919f9292b9aa324d1406033786c34cf4ce Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 11 Dec 2015 01:55:33 +0300 Subject: In mobileopengl2graphics update texture size uniform only if size changed. --- src/render/mobileopengl2graphics.cpp | 15 +++++++++++---- src/render/mobileopengl2graphics.h | 5 ++++- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src/render') diff --git a/src/render/mobileopengl2graphics.cpp b/src/render/mobileopengl2graphics.cpp index 668734845..8e34cbbe5 100644 --- a/src/render/mobileopengl2graphics.cpp +++ b/src/render/mobileopengl2graphics.cpp @@ -77,6 +77,8 @@ GLuint MobileOpenGL2Graphics::mTextureBinded = 0U; GLuint MobileOpenGL2Graphics::mTextureSizeUniform = 0U; +int MobileOpenGL2Graphics::mTextureWidth = 1; +int MobileOpenGL2Graphics::mTextureHeight = 1; #ifdef DEBUG_DRAW_CALLS unsigned int MobileOpenGL2Graphics::mDrawCalls = 0U; unsigned int MobileOpenGL2Graphics::mLastDrawCalls = 0U; @@ -1118,10 +1120,15 @@ void MobileOpenGL2Graphics::bindTexture2(const GLenum target, { mTextureBinded = texture; glBindTexture(target, texture); - // need check sizes before update uniform - mglUniform2f(mTextureSizeUniform, - image->mTexWidth, - image->mTexHeight); + if (mTextureWidth != image->mTexWidth || + mTextureHeight != image->mTexHeight) + { + mTextureWidth = image->mTexWidth; + mTextureHeight = image->mTexHeight; + mglUniform2f(mTextureSizeUniform, + image->mTexWidth, + image->mTexHeight); + } } } diff --git a/src/render/mobileopengl2graphics.h b/src/render/mobileopengl2graphics.h index 1a9ce3284..0a5edc564 100644 --- a/src/render/mobileopengl2graphics.h +++ b/src/render/mobileopengl2graphics.h @@ -108,6 +108,10 @@ class MobileOpenGL2Graphics final : public Graphics static void bindTexture2(const GLenum target, const Image *const image); + static GLuint mTextureSizeUniform; + static int mTextureWidth; + static int mTextureHeight; + GLfloat *mFloatArray A_NONNULLPOINTER; GLfloat *mFloatArrayCached A_NONNULLPOINTER; ShaderProgram *mProgram; @@ -118,7 +122,6 @@ class MobileOpenGL2Graphics final : public Graphics int mMaxVertices; GLuint mProgramId; GLuint mSimpleColorUniform; - static GLuint mTextureSizeUniform; GLint mPosAttrib; GLint mTextureColorUniform; GLuint mScreenUniform; -- cgit v1.2.3-60-g2f50