Minimizes texture state changes
TRAC #12203
Signed-off-by: Nicolas Capens
Signed-off-by: Daniel Koch
Author: Shannon Woods
git-svn-id: https://angleproject.googlecode.com/svn/trunk@267 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index af5b1d7..5d6d8eb 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -40,6 +40,7 @@
mWrapT = GL_REPEAT;
mDirtyMetaData = true;
+ mDirty = true;
mIsRenderable = false;
}
@@ -63,8 +64,14 @@
case GL_LINEAR_MIPMAP_NEAREST:
case GL_NEAREST_MIPMAP_LINEAR:
case GL_LINEAR_MIPMAP_LINEAR:
- mMinFilter = filter;
- return true;
+ {
+ if (mMinFilter != filter)
+ {
+ mMinFilter = filter;
+ mDirty = true;
+ }
+ return true;
+ }
default:
return false;
}
@@ -77,8 +84,14 @@
{
case GL_NEAREST:
case GL_LINEAR:
- mMagFilter = filter;
- return true;
+ {
+ if (mMagFilter != filter)
+ {
+ mMagFilter = filter;
+ mDirty = true;
+ }
+ return true;
+ }
default:
return false;
}
@@ -92,8 +105,14 @@
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
- mWrapS = wrap;
- return true;
+ {
+ if (mWrapS != wrap)
+ {
+ mWrapS = wrap;
+ mDirty = true;
+ }
+ return true;
+ }
default:
return false;
}
@@ -107,8 +126,14 @@
case GL_REPEAT:
case GL_CLAMP_TO_EDGE:
case GL_MIRRORED_REPEAT:
- mWrapT = wrap;
- return true;
+ {
+ if (mWrapT != wrap)
+ {
+ mWrapT = wrap;
+ mDirty = true;
+ }
+ return true;
+ }
default:
return false;
}
@@ -352,6 +377,11 @@
return mBaseTexture;
}
+bool Texture::isDirty() const
+{
+ return (mDirty || mDirtyMetaData || dirtyImageData());
+}
+
// Returns the top-level texture surface as a render target
void Texture::needRenderTarget()
{
@@ -384,6 +414,7 @@
mBaseTexture = newTexture;
mDirtyMetaData = false;
mIsRenderable = renderable;
+ mDirty = true;
}