ES31: Refactor VertexArray for Vertex Attrib Binding

OpenGL ES3.1 feature Vertex Attrib Binding requires vertex arrays should
be split into two arrays:
1. an array of vertex buffer binding points, each of which specifies:
  - a bound buffer object,
  - a starting offset for vertex attribute data in that buffer object,
  - a stride used by all attributes using that binding point,
  - a frequency divisor used by all attributes using that binding point.
2. an array of generic vertex attribute format information records, each
of which specifies:
  - a reference to one of the new buffer binding points above,
  - a component count and format, and a normalization flag for the
    attribute data,
  - the offset of the attribute data relative to the base offset of each
    vertex found at the associated binding point.

Current ANGLE implementation simply uses a struct to represent a vertex
attribute object, which does not meet the requirements above.

This patch aims to be the the basis of the implementation of all ES3.1
Vertex Attrib Binding APIs by refactoring the struct VertexAttribute and
the class VertexArray to fit the new data layout and ensuring all current
functionality is retained.

BUG=angleproject:1593

TEST=angle_unittests, angle_end2end_tests, gpu_unittests

Change-Id: Ieb41f1bf503f815fd0476d2ea045dcb863465254
Reviewed-on: https://chromium-review.googlesource.com/418880
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 24781c1..4f9936e 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -26,6 +26,7 @@
 #include "libANGLE/Path.h"
 #include "libANGLE/Program.h"
 #include "libANGLE/Query.h"
+#include "libANGLE/queryutils.h"
 #include "libANGLE/Renderbuffer.h"
 #include "libANGLE/ResourceManager.h"
 #include "libANGLE/Sampler.h"
@@ -2079,7 +2080,8 @@
     VertexArray *vertexArray = getVertexArray(vertexArrayHandle);
     if (!vertexArray)
     {
-        vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle, MAX_VERTEX_ATTRIBS);
+        vertexArray = new VertexArray(mImplementation.get(), vertexArrayHandle,
+                                      mCaps.maxVertexAttributes, mCaps.maxVertexAttribBindings);
 
         mVertexArrayMap[vertexArrayHandle] = vertexArray;
     }
@@ -2455,6 +2457,11 @@
 
     // Apply implementation limits
     mCaps.maxVertexAttributes = std::min<GLuint>(mCaps.maxVertexAttributes, MAX_VERTEX_ATTRIBS);
+    mCaps.maxVertexAttribBindings =
+        getClientVersion() < ES_3_1
+            ? mCaps.maxVertexAttributes
+            : std::min<GLuint>(mCaps.maxVertexAttribBindings, MAX_VERTEX_ATTRIB_BINDINGS);
+
     mCaps.maxVertexUniformBlocks = std::min<GLuint>(mCaps.maxVertexUniformBlocks, IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS);
     mCaps.maxVertexOutputComponents = std::min<GLuint>(mCaps.maxVertexOutputComponents, IMPLEMENTATION_MAX_VARYING_VECTORS * 4);
 
@@ -3513,6 +3520,48 @@
     mGLState.setVertexAttribu(index, v);
 }
 
+void Context::getVertexAttribiv(GLuint index, GLenum pname, GLint *params)
+{
+    const VertexAttribCurrentValueData &currentValues =
+        getGLState().getVertexAttribCurrentValue(index);
+    const VertexArray *vao = getGLState().getVertexArray();
+    QueryVertexAttribiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
+                        currentValues, pname, params);
+}
+
+void Context::getVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
+{
+    const VertexAttribCurrentValueData &currentValues =
+        getGLState().getVertexAttribCurrentValue(index);
+    const VertexArray *vao = getGLState().getVertexArray();
+    QueryVertexAttribfv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
+                        currentValues, pname, params);
+}
+
+void Context::getVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
+{
+    const VertexAttribCurrentValueData &currentValues =
+        getGLState().getVertexAttribCurrentValue(index);
+    const VertexArray *vao = getGLState().getVertexArray();
+    QueryVertexAttribIiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
+                         currentValues, pname, params);
+}
+
+void Context::getVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
+{
+    const VertexAttribCurrentValueData &currentValues =
+        getGLState().getVertexAttribCurrentValue(index);
+    const VertexArray *vao = getGLState().getVertexArray();
+    QueryVertexAttribIuiv(vao->getVertexAttribute(index), vao->getBindingFromAttribIndex(index),
+                          currentValues, pname, params);
+}
+
+void Context::getVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
+{
+    const VertexAttribute &attrib = getGLState().getVertexArray()->getVertexAttribute(index);
+    QueryVertexAttribPointerv(attrib, pname, pointer);
+}
+
 void Context::debugMessageControl(GLenum source,
                                   GLenum type,
                                   GLenum severity,