[graphite] Check for Vulkan depth-stencil support before
initSampleCounts.

Fixes a crash when trying to run initSampleCounts on an invalid format.

Change-Id: Ia05dda6c5dc0c9f91a86be57a8bed46b984261bb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/705986
Auto-Submit: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Nicolette Prevost <nicolettep@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/graphite/vk/VulkanCaps.cpp b/src/gpu/graphite/vk/VulkanCaps.cpp
index 552eacc..00779ac 100644
--- a/src/gpu/graphite/vk/VulkanCaps.cpp
+++ b/src/gpu/graphite/vk/VulkanCaps.cpp
@@ -955,8 +955,10 @@
     memset(&fFormatProperties, 0, sizeof(VkFormatProperties));
     VULKAN_CALL(interface, GetPhysicalDeviceFormatProperties(physDev, format, &fFormatProperties));
 
-    VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
-    fSupportedSampleCounts.initSampleCounts(interface, physDev, properties, format, usageFlags);
+    if (this->isDepthStencilSupported(fFormatProperties.optimalTilingFeatures)) {
+        VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
+        fSupportedSampleCounts.initSampleCounts(interface, physDev, properties, format, usageFlags);
+    }
 }
 
 bool VulkanCaps::DepthStencilFormatInfo::isDepthStencilSupported(VkFormatFeatureFlags flags) const {