Vulkan: Enable robust buffer access.

This is not a complete implementation because it does not have the
ability to disable the physical device feature. It does pass the
current set of robust access tests. But there could be a performance
regression on platforms that have a slower impelmentation. We would
want the ability to support cases with bufer robustness on or off.

Bug: angleproject:3062
Change-Id: I7d6eb889debcbd32f6ed809b526677123f872726
Reviewed-on: https://chromium-review.googlesource.com/c/1403967
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 3f131c3..e48893e 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -843,6 +843,7 @@
     // Select additional features to be enabled
     VkPhysicalDeviceFeatures enabledFeatures = {};
     enabledFeatures.inheritedQueries         = mPhysicalDeviceFeatures.inheritedQueries;
+    enabledFeatures.robustBufferAccess       = mPhysicalDeviceFeatures.robustBufferAccess;
 
     VkDeviceQueueCreateInfo queueCreateInfo = {};
 
diff --git a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
index 378321c..af63f40 100644
--- a/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
+++ b/src/libANGLE/renderer/vulkan/VertexArrayVk.cpp
@@ -450,11 +450,23 @@
             }
             else
             {
-                mCurrentArrayBuffers[attribIndex] = &bufferVk->getBuffer();
-                mCurrentArrayBufferHandles[attribIndex] =
-                    bufferVk->getBuffer().getBuffer().getHandle();
-                mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset();
-                mCurrentArrayBufferStrides[attribIndex] = binding.getStride();
+                if (bufferVk->getSize() == 0)
+                {
+                    mCurrentArrayBuffers[attribIndex] = nullptr;
+                    mCurrentArrayBufferHandles[attribIndex] =
+                        mTheNullBuffer.getBuffer().getHandle();
+                    mCurrentArrayBufferOffsets[attribIndex] = 0;
+                    mCurrentArrayBufferStrides[attribIndex] = 0;
+                }
+                else
+                {
+                    mCurrentArrayBuffers[attribIndex] = &bufferVk->getBuffer();
+                    mCurrentArrayBufferHandles[attribIndex] =
+                        bufferVk->getBuffer().getBuffer().getHandle();
+                    mCurrentArrayBufferOffsets[attribIndex] = binding.getOffset();
+                    mCurrentArrayBufferStrides[attribIndex] = binding.getStride();
+                }
+
                 ensureConversionReleased(renderer, attribIndex);
             }
         }
diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
index 48043fd..c27563d 100644
--- a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
@@ -50,6 +50,9 @@
     outExtensions->textureBorderClamp     = false;  // not implemented yet
     outExtensions->translatedShaderSource = true;
 
+    // Only expose robust buffer access if the physical device supports it.
+    outExtensions->robustBufferAccessBehavior = physicalDeviceFeatures.robustBufferAccess;
+
     // We use secondary command buffers almost everywhere and they require a feature to be
     // able to execute in the presence of queries.  As a result, we won't support queries
     // unless that feature is available.