Disable MSAA on older Intel GPUs w/Vulkan

This matches the logic in GrGLCaps. Note that we only run Vulkan on one
such bot (IntelHD405) and already disabled msaa testing on that bot in
test.py due to the problems it was having.

Change-Id: Ic84a1e8e5eb6deddad5c2bfe93640925a8d6ec0a
Bug: skia:9023
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/228562
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/GrUtil.h b/src/gpu/GrUtil.h
new file mode 100644
index 0000000..a9da247
--- /dev/null
+++ b/src/gpu/GrUtil.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2019 Google LLC
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef GrUtil_DEFINED
+#define GrUtil_DEFINED
+
+#include "include/core/SkTypes.h"
+
+enum GrIntelGpuFamily {
+    kUnknown_IntelGpuFamily,
+
+    // 6th gen
+    kSandyBridge_IntelGpuFamily,
+
+    // 7th gen
+    kIvyBridge_IntelGpuFamily,
+    kValleyView_IntelGpuFamily, // aka BayTrail
+    kHaswell_IntelGpuFamily,
+
+    // 8th gen
+    kCherryView_IntelGpuFamily, // aka Braswell
+    kBroadwell_IntelGpuFamily,
+
+    // 9th gen
+    kApolloLake_IntelGpuFamily,
+    kSkyLake_IntelGpuFamily,
+    kGeminiLake_IntelGpuFamily,
+    kKabyLake_IntelGpuFamily,
+    kCoffeeLake_IntelGpuFamily,
+
+    // 11th gen
+    kIceLake_IntelGpuFamily,
+
+    kFirstGen9_IntelGpuFamily = kApolloLake_IntelGpuFamily,
+};
+
+GrIntelGpuFamily GrGetIntelGpuFamily(uint32_t deviceID) {
+    // https://en.wikipedia.org/wiki/List_of_Intel_graphics_processing_units
+    uint32_t maskedID = deviceID & 0xFF00;
+    switch (maskedID) {
+        case 0x0100:
+            switch (deviceID & 0xFFF0) {
+                case 0x0100:
+                case 0x0110:
+                case 0x0120:
+                    return kSandyBridge_IntelGpuFamily;
+                case 0x0150:
+                    if (deviceID == 0x0155 || deviceID == 0x0157) {
+                        return kValleyView_IntelGpuFamily;
+                    }
+                    if (deviceID == 0x0152 || deviceID == 0x015A) {
+                        return kIvyBridge_IntelGpuFamily;
+                    }
+                    break;
+                case 0x0160:
+                    return kIvyBridge_IntelGpuFamily;
+                default:
+                    break;
+            }
+            break;
+        case 0x0F00:
+            return kValleyView_IntelGpuFamily;
+        case 0x0400:
+        case 0x0A00:
+        case 0x0D00:
+            return kHaswell_IntelGpuFamily;
+        case 0x2200:
+            return kCherryView_IntelGpuFamily;
+        case 0x1600:
+            return kBroadwell_IntelGpuFamily;
+        case 0x5A00:
+            return kApolloLake_IntelGpuFamily;
+        case 0x1900:
+            return kSkyLake_IntelGpuFamily;
+        case 0x3100:
+            return kGeminiLake_IntelGpuFamily;
+        case 0x5900:
+            return kKabyLake_IntelGpuFamily;
+        case 0x3E00:
+            return kCoffeeLake_IntelGpuFamily;
+        case 0x8A00:
+            return kIceLake_IntelGpuFamily;
+        default:
+            break;
+    }
+    return kUnknown_IntelGpuFamily;
+}
+
+#endif
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index b2796f9..355373b 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -11,6 +11,7 @@
 #include "include/gpu/vk/GrVkExtensions.h"
 #include "src/gpu/GrRenderTargetProxy.h"
 #include "src/gpu/GrShaderCaps.h"
+#include "src/gpu/GrUtil.h"
 #include "src/gpu/SkGr.h"
 #include "src/gpu/vk/GrVkCaps.h"
 #include "src/gpu/vk/GrVkInterface.h"
@@ -728,6 +729,12 @@
         // MSAA does not work on imagination
         return;
     }
+    if (kIntel_VkVendor == physProps.vendorID) {
+        // MSAA on Intel before Gen 9 is slow and/or buggy
+        if (GrGetIntelGpuFamily(physProps.deviceID) < kFirstGen9_IntelGpuFamily) {
+            return;
+        }
+    }
     if (flags & VK_SAMPLE_COUNT_2_BIT) {
         fColorSampleCounts.push_back(2);
     }