Add top-level dirty bits for texture and samplers.

These will have to be fleshed out in the back-ends.
Also currently uses a single bit for all the bindings, and we can
extend this to more fine-grained updates in the future.

This patch implements top-level updates for texture completeness.
Sampler completeness caches are removed from the Texture class, and
replaced by a cache in the gl::State class. The State class also
keeps a channel binding to the bound textures so it can be notified
when textures might change from complete <-> incomplete.

In future CLs we skip updating back-ends if texture state doesn't
change.

BUG=angleproject:1387

Change-Id: If580b4851303c86f3240e62891f5f6047eefb6a2
Reviewed-on: https://chromium-review.googlesource.com/648053
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Program.cpp b/src/libANGLE/Program.cpp
index 0c5ad19..76c25d2 100644
--- a/src/libANGLE/Program.cpp
+++ b/src/libANGLE/Program.cpp
@@ -1360,17 +1360,20 @@
     mProgram->setUniform4fv(location, clampedCount, v);
 }
 
-void Program::setUniform1iv(GLint location, GLsizei count, const GLint *v)
+Program::SetUniformResult Program::setUniform1iv(GLint location, GLsizei count, const GLint *v)
 {
     const VariableLocation &locationInfo = mState.mUniformLocations[location];
     GLsizei clampedCount                 = clampUniformCount(locationInfo, count, 1, v);
 
+    mProgram->setUniform1iv(location, clampedCount, v);
+
     if (mState.isSamplerUniformIndex(locationInfo.index))
     {
         updateSamplerUniform(locationInfo, clampedCount, v);
+        return SetUniformResult::SamplerChanged;
     }
 
-    mProgram->setUniform1iv(location, clampedCount, v);
+    return SetUniformResult::NoSamplerChange;
 }
 
 void Program::setUniform2iv(GLint location, GLsizei count, const GLint *v)
@@ -2966,15 +2969,13 @@
                                    const GLint *v)
 {
     // Invalidate the validation cache only if we modify the sampler data.
-    if (mState.isSamplerUniformIndex(locationInfo.index))
-    {
-        GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(locationInfo.index);
-        std::vector<GLuint> *boundTextureUnits =
-            &mState.mSamplerBindings[samplerIndex].boundTextureUnits;
+    ASSERT(mState.isSamplerUniformIndex(locationInfo.index));
+    GLuint samplerIndex = mState.getSamplerIndexFromUniformIndex(locationInfo.index);
+    std::vector<GLuint> *boundTextureUnits =
+        &mState.mSamplerBindings[samplerIndex].boundTextureUnits;
 
-        std::copy(v, v + clampedCount, boundTextureUnits->begin() + locationInfo.element);
-        mCachedValidateSamplersResult.reset();
-    }
+    std::copy(v, v + clampedCount, boundTextureUnits->begin() + locationInfo.element);
+    mCachedValidateSamplersResult.reset();
 }
 
 template <typename T>