Keep track of applied textures and dirty state to minimize D3D calls.

TRAC #15703
Issue=86
Signed-off-by: Daniel Koch
Author: Nicolas Capens

git-svn-id: https://angleproject.googlecode.com/svn/trunk@588 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/Texture.cpp b/src/libGLESv2/Texture.cpp
index d8d6cc1..6bc12fa 100644
--- a/src/libGLESv2/Texture.cpp
+++ b/src/libGLESv2/Texture.cpp
@@ -44,7 +44,7 @@
     mMagFilter = GL_LINEAR;
     mWrapS = GL_REPEAT;
     mWrapT = GL_REPEAT;
-    mDirtyParameters = true;
+    mDirty = true;
     
     mIsRenderable = false;
 }
@@ -74,7 +74,7 @@
             if (mMinFilter != filter)
             {
                 mMinFilter = filter;
-                mDirtyParameters = true;
+                mDirty = true;
             }
             return true;
         }
@@ -94,7 +94,7 @@
             if (mMagFilter != filter)
             {
                 mMagFilter = filter;
-                mDirtyParameters = true;
+                mDirty = true;
             }
             return true;
         }
@@ -115,7 +115,7 @@
             if (mWrapS != wrap)
             {
                 mWrapS = wrap;
-                mDirtyParameters = true;
+                mDirty = true;
             }
             return true;
         }
@@ -136,7 +136,7 @@
             if (mWrapT != wrap)
             {
                 mWrapT = wrap;
-                mDirtyParameters = true;
+                mDirty = true;
             }
             return true;
         }
@@ -846,6 +846,7 @@
         }
 
         image->dirty = true;
+        mDirty = true;
     }
 }
 
@@ -869,6 +870,7 @@
         }
 
         image->dirty = true;
+        mDirty = true;
     }
 }
 
@@ -902,6 +904,7 @@
         }
 
         image->dirty = true;
+        mDirty = true;
     }
 
     return true;
@@ -948,6 +951,7 @@
         }
 
         image->dirty = true;
+        mDirty = true;
     }
 
     return true;
@@ -1115,6 +1119,7 @@
         }
 
         image->dirty = true;
+        mDirty = true;
     }
 
     image->surface->UnlockRect();
@@ -1146,7 +1151,12 @@
 
 bool Texture::isDirty() const
 {
-    return true;//(mDirty || mDirtyMetaData || dirtyImageData());
+    return mDirty;
+}
+
+void Texture::resetDirty()
+{
+    mDirty = false;
 }
 
 GLint Texture::creationLevels(GLsizei width, GLsizei height, GLint maxlevel) const
@@ -1250,6 +1260,7 @@
         {
             mTexture->Release();
             mTexture = NULL;
+            mDirty = true;
             mIsRenderable = false;
         }
     }
@@ -1519,6 +1530,7 @@
     }
 
     mTexture = texture;
+    mDirty = true;
     mIsRenderable = false;
 }
 
@@ -1625,6 +1637,7 @@
     }
 
     mTexture = texture;
+    mDirty = true;
     mIsRenderable = true;
 }
 
@@ -1975,6 +1988,7 @@
     }
 
     mTexture = texture;
+    mDirty = true;
     mIsRenderable = false;
 }
 
@@ -2083,6 +2097,7 @@
     }
 
     mTexture = texture;
+    mDirty = true;
     mIsRenderable = true;
 }
 
@@ -2143,6 +2158,7 @@
         {
             mTexture->Release();
             mTexture = NULL;
+            mDirty = true;
             mIsRenderable = false;
         }
     }