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/queryutils.cpp b/src/libANGLE/queryutils.cpp
index a53ee22..ca05348 100644
--- a/src/libANGLE/queryutils.cpp
+++ b/src/libANGLE/queryutils.cpp
@@ -349,8 +349,10 @@
     return iround<GLint>(currentValue);
 }
 
+// Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
 template <typename ParamType, typename CurrentDataType, size_t CurrentValueCount>
 void QueryVertexAttribBase(const VertexAttribute &attrib,
+                           const VertexBinding &binding,
                            const CurrentDataType (&currentValueData)[CurrentValueCount],
                            GLenum pname,
                            ParamType *params)
@@ -370,7 +372,7 @@
             *params = ConvertFromGLuint<ParamType>(attrib.size);
             break;
         case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
-            *params = ConvertFromGLuint<ParamType>(attrib.stride);
+            *params = ConvertFromGLuint<ParamType>(attrib.vertexAttribArrayStride);
             break;
         case GL_VERTEX_ATTRIB_ARRAY_TYPE:
             *params = ConvertFromGLenum<ParamType>(attrib.type);
@@ -379,10 +381,10 @@
             *params = ConvertFromGLboolean<ParamType>(attrib.normalized);
             break;
         case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
-            *params = ConvertFromGLuint<ParamType>(attrib.buffer.id());
+            *params = ConvertFromGLuint<ParamType>(binding.buffer.id());
             break;
         case GL_VERTEX_ATTRIB_ARRAY_DIVISOR:
-            *params = ConvertFromGLuint<ParamType>(attrib.divisor);
+            *params = ConvertFromGLuint<ParamType>(binding.divisor);
             break;
         case GL_VERTEX_ATTRIB_ARRAY_INTEGER:
             *params = ConvertFromGLboolean<ParamType>(attrib.pureInteger);
@@ -719,19 +721,21 @@
 }
 
 void QueryVertexAttribfv(const VertexAttribute &attrib,
+                         const VertexBinding &binding,
                          const VertexAttribCurrentValueData &currentValueData,
                          GLenum pname,
                          GLfloat *params)
 {
-    QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params);
+    QueryVertexAttribBase(attrib, binding, currentValueData.FloatValues, pname, params);
 }
 
 void QueryVertexAttribiv(const VertexAttribute &attrib,
+                         const VertexBinding &binding,
                          const VertexAttribCurrentValueData &currentValueData,
                          GLenum pname,
                          GLint *params)
 {
-    QueryVertexAttribBase(attrib, currentValueData.FloatValues, pname, params);
+    QueryVertexAttribBase(attrib, binding, currentValueData.FloatValues, pname, params);
 }
 
 void QueryVertexAttribPointerv(const VertexAttribute &attrib, GLenum pname, GLvoid **pointer)
@@ -749,19 +753,21 @@
 }
 
 void QueryVertexAttribIiv(const VertexAttribute &attrib,
+                          const VertexBinding &binding,
                           const VertexAttribCurrentValueData &currentValueData,
                           GLenum pname,
                           GLint *params)
 {
-    QueryVertexAttribBase(attrib, currentValueData.IntValues, pname, params);
+    QueryVertexAttribBase(attrib, binding, currentValueData.IntValues, pname, params);
 }
 
 void QueryVertexAttribIuiv(const VertexAttribute &attrib,
+                           const VertexBinding &binding,
                            const VertexAttribCurrentValueData &currentValueData,
                            GLenum pname,
                            GLuint *params)
 {
-    QueryVertexAttribBase(attrib, currentValueData.UnsignedIntValues, pname, params);
+    QueryVertexAttribBase(attrib, binding, currentValueData.UnsignedIntValues, pname, params);
 }
 
 void QueryActiveUniformBlockiv(const Program *program,