Vulkan: Add dynamic index buffers to graph

With DynamicBuffer outputting BufferHelper objects, these objects can
participate in the command graph, i.e. record commands.  This means they
need appropriate dependencies in the graph as well as pipeline barriers.

There are a few users of DynamicBuffer for which this change should be
applied to.  This change covers index buffers.

This commit includes a fix to BufferHelper::copyFromBuffer for WaW
hazards.

It also includes a fix for a missing pipeline barrier after
BufferVk::copyToBuffer.

Bug: angleproject:2958
Change-Id: I3e61af56936580b2da20c28c45defece552d9a39
Reviewed-on: https://chromium-review.googlesource.com/c/1352732
Reviewed-by: Tobin Ehlis <tobine@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index 3bacd45..2b2c61f 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -90,7 +90,6 @@
           INIT,
       }},
       mCurrentArrayBufferConversionCanRelease{},
-      mCurrentElementArrayBufferHandle(VK_NULL_HANDLE),
       mCurrentElementArrayBufferOffset(0),
       mCurrentElementArrayBuffer(nullptr),
       mPackedInputBindings{},
@@ -146,8 +145,9 @@
     const size_t amount = sizeof(GLushort) * indexCount;
     GLubyte *dst        = nullptr;
 
-    ANGLE_TRY(dynamicBuffer->allocate(contextVk, amount, &dst, &mCurrentElementArrayBufferHandle,
+    ANGLE_TRY(dynamicBuffer->allocate(contextVk, amount, &dst, nullptr,
                                       &mCurrentElementArrayBufferOffset, nullptr));
+    mCurrentElementArrayBuffer = dynamicBuffer->getCurrentBuffer();
     if (indexType == gl::DrawElementsType::UnsignedByte)
     {
         // Unsigned bytes don't have direct support in Vulkan so we have to expand the
@@ -272,13 +272,10 @@
                 {
                     BufferVk *bufferVk         = vk::GetImpl(bufferGL);
                     mCurrentElementArrayBuffer = &bufferVk->getBuffer();
-                    mCurrentElementArrayBufferHandle =
-                        bufferVk->getBuffer().getBuffer().getHandle();
                 }
                 else
                 {
-                    mCurrentElementArrayBuffer       = nullptr;
-                    mCurrentElementArrayBufferHandle = VK_NULL_HANDLE;
+                    mCurrentElementArrayBuffer = nullptr;
                 }
 
                 mCurrentElementArrayBufferOffset = 0;
@@ -512,7 +509,7 @@
             {
                 ANGLE_TRY(mLineLoopHelper.streamIndices(
                     contextVk, indexTypeOrInvalid, vertexOrIndexCount,
-                    reinterpret_cast<const uint8_t *>(indices), &mCurrentElementArrayBufferHandle,
+                    reinterpret_cast<const uint8_t *>(indices), &mCurrentElementArrayBuffer,
                     &mCurrentElementArrayBufferOffset));
             }
             else
@@ -522,7 +519,7 @@
                 BufferVk *elementArrayBufferVk = vk::GetImpl(elementArrayBuffer);
                 ANGLE_TRY(mLineLoopHelper.getIndexBufferForElementArrayBuffer(
                     contextVk, elementArrayBufferVk, indexTypeOrInvalid, vertexOrIndexCount, offset,
-                    &mCurrentElementArrayBufferHandle, &mCurrentElementArrayBufferOffset));
+                    &mCurrentElementArrayBuffer, &mCurrentElementArrayBufferOffset));
             }
         }
 
@@ -543,7 +540,7 @@
         mLineLoopBufferFirstIndex != firstVertex || mLineLoopBufferLastIndex != lastVertex)
     {
         ANGLE_TRY(mLineLoopHelper.getIndexBufferForDrawArrays(
-            contextVk, clampedVertexCount, firstVertex, &mCurrentElementArrayBufferHandle,
+            contextVk, clampedVertexCount, firstVertex, &mCurrentElementArrayBuffer,
             &mCurrentElementArrayBufferOffset));
 
         mLineLoopBufferFirstIndex = firstVertex;