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
This commit is contained in:
Chinmay Garde 2020-03-15 14:35:48 -07:00 committed by GitHub
parent b23138c359
commit d8e45f9c14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,9 @@
#include <Foundation/Foundation.h>
#include <QuartzCore/CAEAGLLayer.h>
#include <QuartzCore/CAMetalLayer.h>
#if FLUTTER_SHELL_ENABLE_METAL
#include <Metal/Metal.h>
#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