Vulkan: Lineloops edge base bugfix and new tests

The dynamic buffer we are using in the LineLoopHelper wasn't able
to support switching between different allocation sizes. Fix this by
simply using a min alignment of the maximum allocation size we can
reach.

Adds 2 new tests to validate these calls in StateChangeTest.cpp

Bug: angleproject:2458

Change-Id: I9d224e7dcfcd7627010832ca30dd9e1b9eceea4e
Reviewed-on: https://chromium-review.googlesource.com/1007335
Commit-Queue: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index d0a44c2..d13e6aa 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -367,7 +367,6 @@
     }
 
     // Handle GL_LINE_LOOP drawArrays.
-    // This test may be incorrect if the draw call switches from DrawArrays/DrawElements.
     int lastVertex = drawCallParams.firstVertex() + drawCallParams.vertexCount();
     if (!mLineLoopBufferFirstIndex.valid() || !mLineLoopBufferLastIndex.valid() ||
         mLineLoopBufferFirstIndex != drawCallParams.firstVertex() ||
@@ -417,7 +416,6 @@
 
     VkIndexType indexType = gl_vk::GetIndexType(drawCallParams.type());
 
-    // This also doesn't check if the element type changed, which should trigger translation.
     if (mDirtyLineLoopTranslation)
     {
         ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer(
@@ -469,6 +467,11 @@
 
         // This forces the binding to happen if we follow a drawElement call from a drawArrays call.
         mIndexBufferDirty = true;
+
+        // If we've had a drawElements call with a line loop before, we want to make sure this is
+        // invalidated the next time drawElements is called since we use the same index buffer for
+        // both calls.
+        mDirtyLineLoopTranslation = true;
     }
 
     return gl::NoError();
@@ -507,6 +510,12 @@
                                        gl_vk::GetIndexType(drawCallParams.type()));
         updateElementArrayBufferReadDependency(drawNode, renderer->getCurrentQueueSerial());
         mIndexBufferDirty = false;
+
+        // If we've had a drawArrays call with a line loop before, we want to make sure this is
+        // invalidated the next time drawArrays is called since we use the same index buffer for
+        // both calls.
+        mLineLoopBufferFirstIndex.reset();
+        mLineLoopBufferLastIndex.reset();
     }
 
     return gl::NoError();