From d8e45f9c14eb19b8d2c0701aa2a0967a2ce8f7bc Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Sun, 15 Mar 2020 14:35:48 -0700 Subject: [PATCH] Update the Metal backend selection to use iOS 10.0 and A7 as the version floor. (#17162) Fixes https://github.com/flutter/flutter/issues/52356 --- .../darwin/ios/rendering_api_selection.mm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/rendering_api_selection.mm b/shell/platform/darwin/ios/rendering_api_selection.mm index c6ef89c47..91b483f1d 100644 --- a/shell/platform/darwin/ios/rendering_api_selection.mm +++ b/shell/platform/darwin/ios/rendering_api_selection.mm @@ -7,6 +7,9 @@ #include #include #include +#if FLUTTER_SHELL_ENABLE_METAL +#include +#endif // FLUTTER_SHELL_ENABLE_METAL #include "flutter/fml/logging.h" @@ -16,6 +19,7 @@ bool ShouldUseSoftwareRenderer() { return [[[NSProcessInfo processInfo] arguments] containsObject:@"--force-software"]; } +#if FLUTTER_SHELL_ENABLE_METAL bool ShouldUseMetalRenderer() { // If there is a command line argument that says Metal should not be used, that takes precedence // over everything else. This allows disabling Metal on a per run basis to check for regressions @@ -31,11 +35,13 @@ bool ShouldUseMetalRenderer() { return true; } - // This is just a version we picked that is easy to support and has all necessary Metal features. + // Flutter supports Metal on all devices with Apple A7 SoC or above that have been update to or + // past iOS 10.0. The processor was selected as it is the first version at which Metal was + // supported. The iOS version floor was selected due to the availability of features used by Skia. bool ios_version_supports_metal = false; - // TODO(52356): Update this to be the version selected for release. - if (@available(iOS 11.0, *)) { - ios_version_supports_metal = true; + if (@available(iOS 10.0, *)) { + auto device = MTLCreateSystemDefaultDevice(); + ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; } // The application must opt-in by default to use Metal without command line flags. @@ -44,6 +50,7 @@ bool ShouldUseMetalRenderer() { return ios_version_supports_metal && application_opts_into_metal; } +#endif // FLUTTER_SHELL_ENABLE_METAL IOSRenderingAPI GetRenderingAPIForProcess() { #if TARGET_IPHONE_SIMULATOR -- GitLab