-
Notifications
You must be signed in to change notification settings - Fork 6k
Enabled metal on ios simulator #17881
Changes from 1 commit
a4fff2f
839185c
5c92d7d
ea495b7
eed65a5
63d1a38
13bd8e5
5b8e616
5bce7ab
40fb32b
db5db70
a2b792b
eaf87d0
f323636
c0a9f73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,14 +39,20 @@ bool IsIosEmbeddedViewsPreviewEnabled() { | |
| } | ||
|
|
||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| if ([layer.get() isKindOfClass:[CAMetalLayer class]]) { | ||
| return std::make_unique<IOSSurfaceMetal>( | ||
| fml::scoped_nsobject<CAMetalLayer>( | ||
| reinterpret_cast<CAMetalLayer*>([layer.get() retain])), // Metal layer | ||
| std::move(context), // context | ||
| platform_views_controller // platform views controller | ||
| ); | ||
| #if TARGET_IPHONE_SIMULATOR | ||
Kavantix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (@available(iOS 13.0, *)) { | ||
| #endif // TARGET_IPHONE_SIMULATOR | ||
| if ([layer.get() isKindOfClass:[CAMetalLayer class]]) { | ||
| return std::make_unique<IOSSurfaceMetal>( | ||
| fml::scoped_nsobject<CAMetalLayer>( | ||
| reinterpret_cast<CAMetalLayer*>([layer.get() retain])), // Metal layer | ||
| std::move(context), // context | ||
| platform_views_controller // platform views controller | ||
| ); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That doesnt make sense to me, it not being available is valid since it will use the software renderer in that case |
||
| #if TARGET_IPHONE_SIMULATOR | ||
| } | ||
| #endif // TARGET_IPHONE_SIMULATOR | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
|
|
||
| return std::make_unique<IOSSurfaceSoftware>( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,26 +21,34 @@ bool ShouldUseMetalRenderer() { | |
| // 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 TARGET_IPHONE_SIMULATOR | ||
| if (@available(iOS 13.0, *)) { | ||
Kavantix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #else | ||
| if (@available(iOS 10.0, *)) { | ||
| #endif // TARGET_IPHONE_SIMULATOR | ||
| auto device = MTLCreateSystemDefaultDevice(); | ||
| ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; | ||
| // We need to check if the device is here since an ios 13 simulator running on an older version | ||
| // of macos (below 10.15) will not actually allow metal to be used. | ||
| if (device != nil) { | ||
Kavantix marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; | ||
| } | ||
| } | ||
| return ios_version_supports_metal; | ||
| } | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
|
|
||
| IOSRenderingAPI GetRenderingAPIForProcess() { | ||
| #if TARGET_IPHONE_SIMULATOR | ||
| return IOSRenderingAPI::kSoftware; | ||
| #endif // TARGET_IPHONE_SIMULATOR | ||
|
|
||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| static bool should_use_metal = ShouldUseMetalRenderer(); | ||
| if (should_use_metal) { | ||
| return IOSRenderingAPI::kMetal; | ||
| } | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
| #if TARGET_IPHONE_SIMULATOR | ||
| return IOSRenderingAPI::kSoftware; | ||
|
Comment on lines
+39
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could have something above this if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An easy way to do this would be to add a parameter to If that's set to true, we just return |
||
| #else | ||
| return IOSRenderingAPI::kOpenGLES; | ||
| #endif // TARGET_IPHONE_SIMULATOR | ||
| } | ||
|
|
||
| Class GetCoreAnimationLayerClassForRenderingAPI(IOSRenderingAPI rendering_api) { | ||
|
|
@@ -49,8 +57,15 @@ Class GetCoreAnimationLayerClassForRenderingAPI(IOSRenderingAPI rendering_api) { | |
| return [CALayer class]; | ||
| case IOSRenderingAPI::kOpenGLES: | ||
| return [CAEAGLLayer class]; | ||
| #if !TARGET_IPHONE_SIMULATOR | ||
| case IOSRenderingAPI::kMetal: | ||
| #if TARGET_IPHONE_SIMULATOR | ||
| // This will always be true since we filter out this case when checking if the device | ||
| // supports metal. | ||
| if (@available(iOS 13.0, *)) { | ||
| return [CAMetalLayer class]; | ||
| } | ||
Kavantix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| break; | ||
| #else | ||
| return [CAMetalLayer class]; | ||
| #endif // !TARGET_IPHONE_SIMULATOR | ||
| default: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.