Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Metal on iOS by default. #17431

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions shell/platform/darwin/ios/rendering_api_selection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,17 @@

namespace flutter {

bool ShouldUseSoftwareRenderer() {
return [[[NSProcessInfo processInfo] arguments] containsObject:@"--force-software"];
}

Comment on lines -18 to -21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we dropping this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only added recently so I could check all three variants in one build. There is no reason to support software rendering on iOS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's set somewhere else for simulator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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
// on an application that has otherwise opted into Metal on an iOS version that supports it.
if ([[[NSProcessInfo processInfo] arguments] containsObject:@"--disable-metal"]) {
return false;
}

// If the application wants to use metal on a per run basis with disregard for version checks or
// plist based opt ins, respect that opinion. This allows selectively testing features on older
// version of iOS than those explicitly stated as being supported.
if ([[[NSProcessInfo processInfo] arguments] containsObject:@"--force-metal"]) {
return true;
}

// Flutter supports Metal on all devices with Apple A7 SoC or above that have been update to or
// Flutter supports Metal on all devices with Apple A7 SoC or above that have been updated 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;
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.
bool application_opts_into_metal =
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"io.flutter.metal_preview"] boolValue];

return ios_version_supports_metal && application_opts_into_metal;
return ios_version_supports_metal;
}
#endif // FLUTTER_SHELL_ENABLE_METAL

Expand All @@ -58,10 +35,6 @@ IOSRenderingAPI GetRenderingAPIForProcess() {
#endif // TARGET_IPHONE_SIMULATOR

#if FLUTTER_SHELL_ENABLE_METAL
static bool should_use_software = ShouldUseSoftwareRenderer();
if (should_use_software) {
return IOSRenderingAPI::kSoftware;
}
static bool should_use_metal = ShouldUseMetalRenderer();
if (should_use_metal) {
return IOSRenderingAPI::kMetal;
Expand Down