Use active textures mask in GL and Vulkan.

This also inlines a few accessors and changes the type of the texture
cache.

Bug: angleproject:2763
Change-Id: I82f3c508613f6284d835e8cb64808cfe26a56161
Reviewed-on: https://chromium-review.googlesource.com/1166142
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
index 36517e9..bb813ff 100644
--- a/src/libANGLE/State.cpp
+++ b/src/libANGLE/State.cpp
@@ -106,6 +106,8 @@
       mProgram(nullptr),
       mVertexArray(nullptr),
       mActiveSampler(0),
+      mActiveTexturesCache{},
+      mCachedTexturesInitState(InitState::MayNeedInit),
       mPrimitiveRestart(false),
       mDebug(debug),
       mMultiSampling(false),
@@ -211,7 +213,6 @@
     {
         mSamplerTextures[TextureType::External].resize(caps.maxCombinedTextureImageUnits);
     }
-    mCompleteTextureCache.resize(caps.maxCombinedTextureImageUnits, nullptr);
     mCompleteTextureBindings.reserve(caps.maxCombinedTextureImageUnits);
     mCachedTexturesInitState = InitState::MayNeedInit;
     for (uint32_t textureIndex = 0; textureIndex < caps.maxCombinedTextureImageUnits;
@@ -1091,11 +1092,6 @@
     return mSamplers[textureUnit].id();
 }
 
-Sampler *State::getSampler(GLuint textureUnit) const
-{
-    return mSamplers[textureUnit].get();
-}
-
 void State::detachSampler(const Context *context, GLuint sampler)
 {
     // [OpenGL ES 3.0.2] section 3.8.2 pages 123-124:
@@ -2662,7 +2658,7 @@
 
         Texture *texture = getSamplerTexture(textureUnitIndex, textureType);
         Sampler *sampler = getSampler(textureUnitIndex);
-        ASSERT(static_cast<size_t>(textureUnitIndex) < mCompleteTextureCache.size());
+        ASSERT(static_cast<size_t>(textureUnitIndex) < mActiveTexturesCache.size());
         ASSERT(static_cast<size_t>(textureUnitIndex) < newActiveTextures.size());
 
         ASSERT(texture);
@@ -2673,11 +2669,11 @@
             !mDrawFramebuffer->hasTextureAttachment(texture))
         {
             ANGLE_TRY(texture->syncState(context));
-            mCompleteTextureCache[textureUnitIndex] = texture;
+            mActiveTexturesCache[textureUnitIndex] = texture;
         }
         else
         {
-            mCompleteTextureCache[textureUnitIndex] = nullptr;
+            mActiveTexturesCache[textureUnitIndex] = nullptr;
         }
 
         // Bind the texture unconditionally, to recieve completeness change notifications.
@@ -2702,7 +2698,7 @@
         for (auto textureIndex : negativeMask)
         {
             mCompleteTextureBindings[textureIndex].reset();
-            mCompleteTextureCache[textureIndex] = nullptr;
+            mActiveTexturesCache[textureIndex] = nullptr;
         }
     }
 
@@ -2808,8 +2804,8 @@
     // TODO(jmadill): More fine-grained update.
     mDirtyObjects.set(DIRTY_OBJECT_PROGRAM_TEXTURES);
 
-    if (!mCompleteTextureCache[index] ||
-        mCompleteTextureCache[index]->initState() == InitState::MayNeedInit)
+    if (!mActiveTexturesCache[index] ||
+        mActiveTexturesCache[index]->initState() == InitState::MayNeedInit)
     {
         mCachedTexturesInitState = InitState::MayNeedInit;
     }
@@ -2831,7 +2827,7 @@
 
     for (auto textureIndex : mProgram->getActiveSamplersMask())
     {
-        Texture *texture = mCompleteTextureCache[textureIndex];
+        Texture *texture = mActiveTexturesCache[textureIndex];
         if (texture)
         {
             ANGLE_TRY(texture->ensureInitialized(context));