ES31: Implement Vertex Attrib Binding entry points

This patch intends to implement all entry points related to Vertex
Attrib Binding.

(1) Add entry points and validation code on following APIs:
   - VertexAttribFormat
   - VertexAttribIFormat
   - VertexAttribBinding
   - BindVertexBuffer
   - VertexBindingDivisor
(2) Add queries on following parameters:
   - VERTEX_ATTRIB_BINDING
   - VERTEX_ATTRIB_RELATIVE_OFFSET
   - VERTEX_BINDING_DIVISOR
   - VERTEX_BINDING_OFFSET
   - VERTEX_BINDING_STRIDE
   - VERTEX_BINDING_BUFFER

BUG=angleproject:1593

TEST=angle_end2end_tests
TEST=angle_unittests
TEST=dEQP-GLES31.functional.state_query.integer.max_vertex_attrib_relative_offset_*
TEST=dEQP-GLES31.functional.state_query.integer.max_vertex_attrib_bindings_*
TEST=dEQP-GLES31.functional.state_query.integer.max_vertex_attrib_stride_*
TEST=dEQP-GLES31.functional.state_query.vertex_attribute_binding.*
TEST=dEQP-GLES31.functional.debug.negative_coverage.log.vertex_array.vertex_attrib_pointer
TEST=dEQP-GLES31.functional.debug.negative_coverage.get_error.vertex_array.vertex_attrib_format
TEST=dEQP-GLES31.functional.debug.negative_coverage.get_error.vertex_array.vertex_attrib_i_format

Change-Id: I4b477a82df6aad89b89b088580a06d66963e6666
Reviewed-on: https://chromium-review.googlesource.com/446124
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/renderer/gl/VertexArrayGL.cpp b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
index c03647f..e077fcc 100644
--- a/src/libANGLE/renderer/gl/VertexArrayGL.cpp
+++ b/src/libANGLE/renderer/gl/VertexArrayGL.cpp
@@ -66,11 +66,11 @@
 
     mStateManager->deleteBuffer(mStreamingElementArrayBuffer);
     mStreamingElementArrayBufferSize = 0;
-    mStreamingElementArrayBuffer = 0;
+    mStreamingElementArrayBuffer     = 0;
 
     mStateManager->deleteBuffer(mStreamingArrayBuffer);
     mStreamingArrayBufferSize = 0;
-    mStreamingArrayBuffer = 0;
+    mStreamingArrayBuffer     = 0;
 
     mAppliedElementArrayBuffer.set(nullptr);
     for (auto &binding : mAppliedBindings)
@@ -125,10 +125,12 @@
 {
     mStateManager->bindVertexArray(mVertexArrayID, getAppliedElementArrayBufferID());
 
-    // Check if any attributes need to be streamed, determines if the index range needs to be computed
+    // Check if any attributes need to be streamed, determines if the index range needs to be
+    // computed
     bool attributesNeedStreaming = mAttributesNeedStreaming.any();
 
-    // Determine if an index buffer needs to be streamed and the range of vertices that need to be copied
+    // Determine if an index buffer needs to be streamed and the range of vertices that need to be
+    // copied
     IndexRange indexRange;
     if (type != GL_NONE)
     {
@@ -143,7 +145,7 @@
     {
         // Not an indexed call, set the range to [first, first + count - 1]
         indexRange.start = first;
-        indexRange.end = first + count - 1;
+        indexRange.end   = first + count - 1;
     }
 
     if (attributesNeedStreaming)
@@ -184,7 +186,7 @@
         if (attributesNeedStreaming)
         {
             ptrdiff_t elementArrayBufferOffset = reinterpret_cast<ptrdiff_t>(indices);
-            Error error = mData.getElementArrayBuffer()->getIndexRange(
+            Error error                        = mData.getElementArrayBuffer()->getIndexRange(
                 type, elementArrayBufferOffset, count, primitiveRestartEnabled, outIndexRange);
             if (error.isError())
             {
@@ -192,7 +194,8 @@
             }
         }
 
-        // Indices serves as an offset into the index buffer in this case, use the same value for the draw call
+        // Indices serves as an offset into the index buffer in this case, use the same value for
+        // the draw call
         *outIndices = indices;
     }
     else
@@ -222,16 +225,19 @@
         if (requiredStreamingBufferSize > mStreamingElementArrayBufferSize)
         {
             // Copy the indices in while resizing the buffer
-            mFunctions->bufferData(GL_ELEMENT_ARRAY_BUFFER, requiredStreamingBufferSize, indices, GL_DYNAMIC_DRAW);
+            mFunctions->bufferData(GL_ELEMENT_ARRAY_BUFFER, requiredStreamingBufferSize, indices,
+                                   GL_DYNAMIC_DRAW);
             mStreamingElementArrayBufferSize = requiredStreamingBufferSize;
         }
         else
         {
             // Put the indices at the beginning of the buffer
-            mFunctions->bufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, requiredStreamingBufferSize, indices);
+            mFunctions->bufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, requiredStreamingBufferSize,
+                                      indices);
         }
 
-        // Set the index offset for the draw call to zero since the supplied index pointer is to client data
+        // Set the index offset for the draw call to zero since the supplied index pointer is to
+        // client data
         *outIndices = nullptr;
     }
 
@@ -249,11 +255,11 @@
 
     ASSERT(mAttributesNeedStreaming.any());
 
-    const auto &attribs = mData.getVertexAttributes();
+    const auto &attribs  = mData.getVertexAttributes();
     const auto &bindings = mData.getVertexBindings();
     for (auto idx : angle::IterateBitSet(mAttributesNeedStreaming & activeAttributesMask))
     {
-        const auto &attrib = attribs[idx];
+        const auto &attrib  = attribs[idx];
         const auto &binding = bindings[attrib.bindingIndex];
         ASSERT(AttributeNeedsStreaming(attrib, binding));
 
@@ -289,9 +295,9 @@
         mStreamingArrayBufferSize = 0;
     }
 
-    // If first is greater than zero, a slack space needs to be left at the beginning of the buffer so that
-    // the same 'first' argument can be passed into the draw call.
-    const size_t bufferEmptySpace = maxAttributeDataSize * indexRange.start;
+    // If first is greater than zero, a slack space needs to be left at the beginning of the buffer
+    // so that the same 'first' argument can be passed into the draw call.
+    const size_t bufferEmptySpace   = maxAttributeDataSize * indexRange.start;
     const size_t requiredBufferSize = streamingDataSize + bufferEmptySpace;
 
     mStateManager->bindBuffer(GL_ARRAY_BUFFER, mStreamingArrayBuffer);
@@ -302,9 +308,9 @@
     }
 
     // Unmapping a buffer can return GL_FALSE to indicate that the system has corrupted the data
-    // somehow (such as by a screen change), retry writing the data a few times and return OUT_OF_MEMORY
-    // if that fails.
-    GLboolean unmapResult = GL_FALSE;
+    // somehow (such as by a screen change), retry writing the data a few times and return
+    // OUT_OF_MEMORY if that fails.
+    GLboolean unmapResult     = GL_FALSE;
     size_t unmapRetryAttempts = 5;
     while (unmapResult != GL_TRUE && --unmapRetryAttempts > 0)
     {
@@ -312,11 +318,11 @@
                                                             requiredBufferSize, GL_MAP_WRITE_BIT);
         size_t curBufferOffset = bufferEmptySpace;
 
-        const auto &attribs = mData.getVertexAttributes();
+        const auto &attribs  = mData.getVertexAttributes();
         const auto &bindings = mData.getVertexBindings();
         for (auto idx : angle::IterateBitSet(mAttributesNeedStreaming & activeAttributesMask))
         {
-            const auto &attrib = attribs[idx];
+            const auto &attrib  = attribs[idx];
             const auto &binding = bindings[attrib.bindingIndex];
             ASSERT(AttributeNeedsStreaming(attrib, binding));
 
@@ -347,7 +353,7 @@
                 // Copy each vertex individually
                 for (size_t vertexIdx = 0; vertexIdx < streamedVertexCount; vertexIdx++)
                 {
-                    uint8_t *out = bufferPointer + curBufferOffset + (destStride * vertexIdx);
+                    uint8_t *out      = bufferPointer + curBufferOffset + (destStride * vertexIdx);
                     const uint8_t *in = inputPointer + sourceStride * (vertexIdx + firstIndex);
                     memcpy(out, in, destStride);
                 }