Don't use a helper function to get the vertex attributes.

The overhead of the function call ended up being a hot spot for draw calls
since the attributes are iterated over many times in VertexDataManager.

BUG=angleproject:959

Change-Id: I9bbfcbd115661ad629db9ed93d683cd8d0dc9a78
Reviewed-on: https://chromium-review.googlesource.com/263102
Tested-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/d3d/VertexDataManager.cpp b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
index c051a8a..021e8e3 100644
--- a/src/libANGLE/renderer/d3d/VertexDataManager.cpp
+++ b/src/libANGLE/renderer/d3d/VertexDataManager.cpp
@@ -14,6 +14,7 @@
 #include "libANGLE/Buffer.h"
 #include "libANGLE/Program.h"
 #include "libANGLE/VertexAttribute.h"
+#include "libANGLE/VertexArray.h"
 #include "libANGLE/State.h"
 
 namespace
@@ -85,13 +86,13 @@
     }
 }
 
-void VertexDataManager::hintUnmapAllResources(const gl::State &state)
+void VertexDataManager::hintUnmapAllResources(const std::vector<gl::VertexAttribute> &vertexAttributes)
 {
     mStreamingBuffer->getVertexBuffer()->hintUnmapResource();
 
-    for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
+    for (size_t i = 0; i < vertexAttributes.size(); i++)
     {
-        const gl::VertexAttribute &attrib = state.getVertexAttribState(i);
+        const gl::VertexAttribute &attrib = vertexAttributes[i];
         if (attrib.enabled)
         {
             gl::Buffer *buffer = attrib.buffer.get();
@@ -122,25 +123,25 @@
         return gl::Error(GL_OUT_OF_MEMORY, "Internal streaming vertex buffer is unexpectedly NULL.");
     }
 
+    const gl::VertexArray *vertexArray = state.getVertexArray();
+    const std::vector<gl::VertexAttribute> &vertexAttributes = vertexArray->getVertexAttributes();
+
     // Invalidate static buffers that don't contain matching attributes
     for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
     {
         translated[attributeIndex].active = (state.getProgram()->getSemanticIndex(attributeIndex) != -1);
-        const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
-
-        if (translated[attributeIndex].active && curAttrib.enabled)
+        if (translated[attributeIndex].active && vertexAttributes[attributeIndex].enabled)
         {
-            invalidateMatchingStaticData(curAttrib, state.getVertexAttribCurrentValue(attributeIndex));
+            invalidateMatchingStaticData(vertexAttributes[attributeIndex], state.getVertexAttribCurrentValue(attributeIndex));
         }
     }
 
     // Reserve the required space in the buffers
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
-        if (translated[i].active && curAttrib.enabled)
+        if (translated[i].active && vertexAttributes[i].enabled)
         {
-            gl::Error error = reserveSpaceForAttrib(curAttrib, state.getVertexAttribCurrentValue(i), count, instances);
+            gl::Error error = reserveSpaceForAttrib(vertexAttributes[i], state.getVertexAttribCurrentValue(i), count, instances);
             if (error.isError())
             {
                 return error;
@@ -151,7 +152,7 @@
     // Perform the vertex data translations
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
+        const gl::VertexAttribute &curAttrib = vertexAttributes[i];
         if (translated[i].active)
         {
             if (curAttrib.enabled)
@@ -161,7 +162,7 @@
 
                 if (error.isError())
                 {
-                    hintUnmapAllResources(state);
+                    hintUnmapAllResources(vertexAttributes);
                     return error;
                 }
             }
@@ -177,7 +178,7 @@
                                                     mCurrentValueBuffer[i]);
                 if (error.isError())
                 {
-                    hintUnmapAllResources(state);
+                    hintUnmapAllResources(vertexAttributes);
                     return error;
                 }
             }
@@ -185,11 +186,11 @@
     }
 
     // Hint to unmap all the resources
-    hintUnmapAllResources(state);
+    hintUnmapAllResources(vertexAttributes);
 
     for (int i = 0; i < gl::MAX_VERTEX_ATTRIBS; i++)
     {
-        const gl::VertexAttribute &curAttrib = state.getVertexAttribState(i);
+        const gl::VertexAttribute &curAttrib = vertexAttributes[i];
         if (translated[i].active && curAttrib.enabled)
         {
             gl::Buffer *buffer = curAttrib.buffer.get();