Metal: Support only macOS 10.15 and above.

This is what the current Chromium version supports. This allows
replacing usages of supportsFeatureSet with supportsFamily to fix
deprecation warning on macOS 13.0.

Bug: None
Change-Id: I24a363636890e8922276de557b0193c3d492b194
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/184161
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm
index de9968a..92b247e 100644
--- a/src/dawn/native/metal/BackendMTL.mm
+++ b/src/dawn/native/metal/BackendMTL.mm
@@ -124,8 +124,7 @@
 //
 // [device registryID] is the ID for one of the IOGraphicsAccelerator2 and we can see that
 // their parent always is an IOPCIDevice that has properties for the device and vendor IDs.
-MaybeError API_AVAILABLE(macos(10.13))
-    GetDeviceIORegistryPCIInfo(id<MTLDevice> device, PCIIDs* ids) {
+MaybeError GetDeviceIORegistryPCIInfo(id<MTLDevice> device, PCIIDs* ids) {
     // Get a matching dictionary for the IOGraphicsAccelerator2
     CFRef<CFMutableDictionaryRef> matchingDict =
         AcquireCFRef(IORegistryEntryIDMatching([device registryID]));
@@ -167,8 +166,6 @@
 }
 
 MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
-    // [device registryID] is introduced on macOS 10.13+, otherwise workaround to get vendor
-    // id by vendor name on old macOS
     auto result = GetDeviceIORegistryPCIInfo(device, ids);
     if (result.IsError()) {
         dawn::WarningLog() << "GetDeviceIORegistryPCIInfo failed: "
@@ -346,8 +343,7 @@
         {
             bool haveStoreAndMSAAResolve = false;
 #if DAWN_PLATFORM_IS(MACOS)
-            haveStoreAndMSAAResolve =
-                [*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v2];
+            haveStoreAndMSAAResolve = [*mDevice supportsFamily:MTLGPUFamilyCommon2];
 #elif DAWN_PLATFORM_IS(IOS)
 #if !defined(__IPHONE_16_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_16_0
             haveStoreAndMSAAResolve = [*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2];
@@ -490,14 +486,8 @@
             EnableFeature(Feature::Float32Filterable);
         }
 #elif DAWN_PLATFORM_IS(MACOS)
-        if (@available(macOS 10.15, *)) {
-            if ([*mDevice supportsFamily:MTLGPUFamilyMac2]) {
-                EnableFeature(Feature::Float32Filterable);
-            }
-        } else if (@available(macOS 10.14, *)) {
-            if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) {
-                EnableFeature(Feature::Float32Filterable);
-            }
+        if ([*mDevice supportsFamily:MTLGPUFamilyMac2]) {
+            EnableFeature(Feature::Float32Filterable);
         }
 #endif
 
@@ -757,18 +747,11 @@
             if ([*mDevice supportsFamily:MTLGPUFamilyApple1]) {
                 return MTLGPUFamily::Apple1;
             }
+
+            DAWN_UNREACHABLE();
         }
 
-#if DAWN_PLATFORM_IS(MACOS)
-        if (@available(macOS 10.14, *)) {
-            if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) {
-                return MTLGPUFamily::Mac2;
-            }
-        }
-        if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
-            return MTLGPUFamily::Mac1;
-        }
-#elif DAWN_PLATFORM_IS(IOS) && \
+#if DAWN_PLATFORM_IS(IOS) && \
     (!defined(__IPHONE_16_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_16_0)
         if (@available(iOS 10.11, *)) {
             if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) {
diff --git a/src/dawn/native/metal/QueueMTL.mm b/src/dawn/native/metal/QueueMTL.mm
index 21e9c71..e439d94 100644
--- a/src/dawn/native/metal/QueueMTL.mm
+++ b/src/dawn/native/metal/QueueMTL.mm
@@ -182,7 +182,7 @@
 
     TRACE_EVENT_ASYNC_BEGIN0(platform, GPUWork, "DeviceMTL::SubmitPendingCommandBuffer",
                              uint64_t(pendingSerial));
-    if (@available(macOS 10.14, *)) {
+    if (@available(macOS 10.14, iOS 12.0, *)) {
         id rawEvent = *mMtlSharedEvent;
         id<MTLSharedEvent> sharedEvent = static_cast<id<MTLSharedEvent>>(rawEvent);
         [*pendingCommands encodeSignalEvent:sharedEvent value:static_cast<uint64_t>(pendingSerial)];
diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests_apple.mm b/src/dawn/tests/white_box/SharedTextureMemoryTests_apple.mm
index b568404..33dbc5c 100644
--- a/src/dawn/tests/white_box/SharedTextureMemoryTests_apple.mm
+++ b/src/dawn/tests/white_box/SharedTextureMemoryTests_apple.mm
@@ -155,109 +155,99 @@
 
 // Test that a shared event can be imported, and then exported.
 TEST_P(SharedTextureMemoryTests, SharedFenceSuccessfulImportExport) {
-    if (@available(macOS 10.14, iOS 12.0, *)) {
-        auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
-        auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
+    auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
+    auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
 
-        wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
-        sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
+    wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
+    sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
 
-        wgpu::SharedFenceDescriptor fenceDesc;
-        fenceDesc.nextInChain = &sharedEventDesc;
+    wgpu::SharedFenceDescriptor fenceDesc;
+    fenceDesc.nextInChain = &sharedEventDesc;
 
-        wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
+    wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
 
-        // Release the Metal objects. They should be retained by the implementation.
-        mtlDevice = nil;
-        sharedEvent = nil;
+    // Release the Metal objects. They should be retained by the implementation.
+    mtlDevice = nil;
+    sharedEvent = nil;
 
-        wgpu::SharedFenceMTLSharedEventExportInfo sharedEventInfo;
-        wgpu::SharedFenceExportInfo exportInfo;
-        exportInfo.nextInChain = &sharedEventInfo;
-        fence.ExportInfo(&exportInfo);
+    wgpu::SharedFenceMTLSharedEventExportInfo sharedEventInfo;
+    wgpu::SharedFenceExportInfo exportInfo;
+    exportInfo.nextInChain = &sharedEventInfo;
+    fence.ExportInfo(&exportInfo);
 
-        // The exported event should be the same as the imported one.
-        EXPECT_EQ(sharedEventInfo.sharedEvent, sharedEventDesc.sharedEvent);
-        EXPECT_EQ(exportInfo.type, wgpu::SharedFenceType::MTLSharedEvent);
-    }
+    // The exported event should be the same as the imported one.
+    EXPECT_EQ(sharedEventInfo.sharedEvent, sharedEventDesc.sharedEvent);
+    EXPECT_EQ(exportInfo.type, wgpu::SharedFenceType::MTLSharedEvent);
 }
 
 // Test that it is an error to import a shared fence without enabling the feature.
 TEST_P(SharedTextureMemoryNoFeatureTests, SharedFenceImportWithoutFeature) {
-    if (@available(macOS 10.14, iOS 12.0, *)) {
-        auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
-        auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
+    auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
+    auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
 
-        wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
-        sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
+    wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
+    sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
 
-        wgpu::SharedFenceDescriptor fenceDesc;
-        fenceDesc.nextInChain = &sharedEventDesc;
+    wgpu::SharedFenceDescriptor fenceDesc;
+    fenceDesc.nextInChain = &sharedEventDesc;
 
-        ASSERT_DEVICE_ERROR_MSG(wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc),
-                                testing::HasSubstr("MTLSharedEvent is not enabled"));
-    }
+    ASSERT_DEVICE_ERROR_MSG(wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc),
+                            testing::HasSubstr("MTLSharedEvent is not enabled"));
 }
 
 // Test that it is an error to import a shared fence with a null MTLSharedEvent
 TEST_P(SharedTextureMemoryTests, SharedFenceImportMTLSharedEventMissing) {
-    if (@available(macOS 10.14, iOS 12.0, *)) {
-        wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
-        sharedEventDesc.sharedEvent = nullptr;
+    wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
+    sharedEventDesc.sharedEvent = nullptr;
 
-        wgpu::SharedFenceDescriptor fenceDesc;
-        fenceDesc.nextInChain = &sharedEventDesc;
+    wgpu::SharedFenceDescriptor fenceDesc;
+    fenceDesc.nextInChain = &sharedEventDesc;
 
-        ASSERT_DEVICE_ERROR_MSG(wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc),
-                                testing::HasSubstr("missing"));
-    }
+    ASSERT_DEVICE_ERROR_MSG(wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc),
+                            testing::HasSubstr("missing"));
 }
 
 // Test exporting info from a shared fence with no chained struct.
 // It should be valid and the fence type is exported.
 TEST_P(SharedTextureMemoryTests, SharedFenceExportInfoNoChainedStruct) {
-    if (@available(macOS 10.14, iOS 12.0, *)) {
-        auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
-        auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
+    auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
+    auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
 
-        wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
-        sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
+    wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
+    sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
 
-        wgpu::SharedFenceDescriptor fenceDesc;
-        fenceDesc.nextInChain = &sharedEventDesc;
+    wgpu::SharedFenceDescriptor fenceDesc;
+    fenceDesc.nextInChain = &sharedEventDesc;
 
-        wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
+    wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
 
-        // Test no chained struct.
-        wgpu::SharedFenceExportInfo exportInfo;
-        exportInfo.nextInChain = nullptr;
+    // Test no chained struct.
+    wgpu::SharedFenceExportInfo exportInfo;
+    exportInfo.nextInChain = nullptr;
 
-        fence.ExportInfo(&exportInfo);
-        EXPECT_EQ(exportInfo.type, wgpu::SharedFenceType::MTLSharedEvent);
-    }
+    fence.ExportInfo(&exportInfo);
+    EXPECT_EQ(exportInfo.type, wgpu::SharedFenceType::MTLSharedEvent);
 }
 
 // Test exporting info from a shared fence with an invalid chained struct.
 // It should not be valid, but the fence type should still be exported.
 TEST_P(SharedTextureMemoryTests, SharedFenceExportInfoInvalidChainedStruct) {
-    if (@available(macOS 10.14, iOS 12.0, *)) {
-        auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
-        auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
+    auto mtlDevice = AcquireNSPRef(MTLCreateSystemDefaultDevice());
+    auto sharedEvent = AcquireNSPRef([*mtlDevice newSharedEvent]);
 
-        wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
-        sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
+    wgpu::SharedFenceMTLSharedEventDescriptor sharedEventDesc;
+    sharedEventDesc.sharedEvent = static_cast<void*>(*sharedEvent);
 
-        wgpu::SharedFenceDescriptor fenceDesc;
-        fenceDesc.nextInChain = &sharedEventDesc;
+    wgpu::SharedFenceDescriptor fenceDesc;
+    fenceDesc.nextInChain = &sharedEventDesc;
 
-        wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
+    wgpu::SharedFence fence = device.ImportSharedFence(&fenceDesc);
 
-        wgpu::ChainedStructOut otherStruct;
-        wgpu::SharedFenceExportInfo exportInfo;
-        exportInfo.nextInChain = &otherStruct;
+    wgpu::ChainedStructOut otherStruct;
+    wgpu::SharedFenceExportInfo exportInfo;
+    exportInfo.nextInChain = &otherStruct;
 
-        ASSERT_DEVICE_ERROR(fence.ExportInfo(&exportInfo));
-    }
+    ASSERT_DEVICE_ERROR(fence.ExportInfo(&exportInfo));
 }
 
 DAWN_INSTANTIATE_PREFIXED_TEST_P(Metal,