Context: Cache attributes masks.

This cache is updated in the following locations:

1. GLES1: clientActiveTexture.
2. GLES1: disableClientState/enableClientState.
3. Context: linkProgram/useProgram/programBinary.
4. Context: bindVertexArray.
5. Vertex Array: most state changes.

Improves performance by about 6% in the GL no-op test. Also includes
fixes for keeping the client memory attribs mask in sync. The cache
also includes a boolean if there are any enabled client attributes.

Bug: angleproject:1391
Change-Id: I93b6a2c8492355958fd5483f14b70535729091d6
Reviewed-on: https://chromium-review.googlesource.com/1147437
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index 0c4eda2..fce9d98 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -566,20 +566,15 @@
     ContextVk *contextVk                    = vk::GetImpl(context);
     const gl::State &state                  = context->getGLState();
     const gl::Program *programGL            = state.getProgram();
-    const gl::AttributesMask &clientAttribs = mState.getEnabledClientMemoryAttribsMask();
-    const gl::AttributesMask &activeAttribs = programGL->getActiveAttribLocationsMask();
+    const gl::AttributesMask &clientAttribs = context->getStateCache().getActiveClientAttribsMask();
     uint32_t maxAttrib                      = programGL->getState().getMaxActiveAttribLocation();
 
     if (clientAttribs.any())
     {
-        const gl::AttributesMask &attribsToStream = (clientAttribs & activeAttribs);
-        if (attribsToStream.any())
-        {
-            ANGLE_TRY(drawCallParams.ensureIndexRangeResolved(context));
-            ANGLE_TRY(streamVertexData(contextVk, attribsToStream, drawCallParams));
-            commandBuffer->bindVertexBuffers(0, maxAttrib, mCurrentArrayBufferHandles.data(),
-                                             mCurrentArrayBufferOffsets.data());
-        }
+        ANGLE_TRY(drawCallParams.ensureIndexRangeResolved(context));
+        ANGLE_TRY(streamVertexData(contextVk, clientAttribs, drawCallParams));
+        commandBuffer->bindVertexBuffers(0, maxAttrib, mCurrentArrayBufferHandles.data(),
+                                         mCurrentArrayBufferOffsets.data());
     }
     else if (mVertexBuffersDirty || newCommandBuffer)
     {
@@ -588,8 +583,11 @@
             commandBuffer->bindVertexBuffers(0, maxAttrib, mCurrentArrayBufferHandles.data(),
                                              mCurrentArrayBufferOffsets.data());
 
+            const gl::AttributesMask &bufferedAttribs =
+                context->getStateCache().getActiveBufferedAttribsMask();
+
             vk::CommandGraphResource *drawFramebuffer = vk::GetImpl(state.getDrawFramebuffer());
-            updateArrayBufferReadDependencies(drawFramebuffer, activeAttribs,
+            updateArrayBufferReadDependencies(drawFramebuffer, bufferedAttribs,
                                               contextVk->getRenderer()->getCurrentQueueSerial());
         }