Vulkan: Use global buffer barriers.

This switches from using resource barriers for buffers to using global
barriers. This matches the general advised best practice. It also
allows us to combine multiple barriers into one. On a draw we might
combine all the vertex and index barriers into a single barrier call.

We implement this using a bit of extra state tracking in BufferHelper.

Bug: angleproject:2828
Change-Id: I196b368804ff50e60d085687a643e5566ba1c5b6
Reviewed-on: https://chromium-review.googlesource.com/c/1309977
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/CommandGraph.h b/src/libANGLE/renderer/vulkan/CommandGraph.h
index eb20678..21263f4 100644
--- a/src/libANGLE/renderer/vulkan/CommandGraph.h
+++ b/src/libANGLE/renderer/vulkan/CommandGraph.h
@@ -107,6 +107,8 @@
 
     void setQueryPool(const QueryPool *queryPool, uint32_t queryIndex);
 
+    void addGlobalMemoryBarrier(VkFlags srcAccess, VkFlags dstAccess);
+
   private:
     void setHasChildren();
 
@@ -142,6 +144,10 @@
     // Additional diagnostic information.
     CommandGraphResourceType mResourceType;
     uintptr_t mResourceID;
+
+    // For global memory barriers.
+    VkFlags mGlobalMemoryBarrierSrcAccess;
+    VkFlags mGlobalMemoryBarrierDstAccess;
 };
 
 // This is a helper class for back-end objects used in Vk command buffers. It records a serial
@@ -214,11 +220,17 @@
     // Called when 'this' object changes, but we'd like to start a new command buffer later.
     void finishCurrentCommands(RendererVk *renderer);
 
+    // Store a deferred memory barrier. Will be recorded into a primary command buffer at submit.
+    void addGlobalMemoryBarrier(VkFlags srcAccess, VkFlags dstAccess)
+    {
+        ASSERT(mCurrentWritingNode);
+        mCurrentWritingNode->addGlobalMemoryBarrier(srcAccess, dstAccess);
+    }
+
   protected:
     explicit RecordableGraphResource(CommandGraphResourceType resourceType);
 
   private:
-
     // Returns true if this node has a current writing node with no children.
     bool hasChildlessWritingNode() const
     {