Update sampler directly on Texture change.

This saves a lot of extra work when updating a Texture.

Bug: angleproject:2763
Change-Id: I87e310ef4f847713123bd24711e1166949ff95d2
Reviewed-on: https://chromium-review.googlesource.com/c/1254043
Reviewed-by: Yuly Novikov <ynovikov@google.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
index b9f2f31..c556ea4 100644
--- a/src/libANGLE/State.cpp
+++ b/src/libANGLE/State.cpp
@@ -1067,11 +1067,19 @@
     return static_cast<unsigned int>(mActiveSampler);
 }
 
-void State::setSamplerTexture(const Context *context, TextureType type, Texture *texture)
+Error State::setSamplerTexture(const Context *context, TextureType type, Texture *texture)
 {
     mSamplerTextures[type][mActiveSampler].set(context, texture);
+
+    if (mProgram && mProgram->getActiveSamplersMask()[mActiveSampler] &&
+        mProgram->getActiveSamplerTypes()[mActiveSampler] == type)
+    {
+        ANGLE_TRY(updateActiveTexture(context, mActiveSampler, texture));
+    }
+
     mDirtyBits.set(DIRTY_BIT_TEXTURE_BINDINGS);
-    mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES);
+
+    return NoError();
 }
 
 Texture *State::getTargetTexture(TextureType type) const