-
Notifications
You must be signed in to change notification settings - Fork 6k
Enabled metal on ios simulator #17881
Changes from 3 commits
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 |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| #include "flutter/shell/platform/darwin/ios/ios_surface_gl.h" | ||
| #include "flutter/shell/platform/darwin/ios/ios_surface_software.h" | ||
|
|
||
| #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h" | ||
|
|
||
| #if FLUTTER_SHELL_ENABLE_METAL | ||
| #include "flutter/shell/platform/darwin/ios/ios_surface_metal.h" | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
|
|
@@ -39,13 +41,15 @@ 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 (@available(iOS kMetalOSVersionBaseline, *)) { | ||
| 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 | ||
| ); | ||
| } | ||
|
Member
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 |
||
| } | ||
| #endif // FLUTTER_SHELL_ENABLE_METAL | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ 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 (@available(iOS 10.0, *)) { | ||
| if (@available(iOS kMetalOSVersionBaseline, *)) { | ||
| auto device = MTLCreateSystemDefaultDevice(); | ||
| ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; | ||
| } | ||
|
|
@@ -30,17 +30,20 @@ bool ShouldUseMetalRenderer() { | |
| #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 | ||
|
|
||
| // OpenGL will be emulated using software rendering by Apple on the simulator, so we use the | ||
| // Skia software rendering since it performs a little better than the emulated OpenGL. | ||
| #if TARGET_IPHONE_SIMULATOR | ||
| return IOSRenderingAPI::kSoftware; | ||
|
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,10 +52,12 @@ Class GetCoreAnimationLayerClassForRenderingAPI(IOSRenderingAPI rendering_api) { | |
| return [CALayer class]; | ||
| case IOSRenderingAPI::kOpenGLES: | ||
| return [CAEAGLLayer class]; | ||
| #if !TARGET_IPHONE_SIMULATOR | ||
| case IOSRenderingAPI::kMetal: | ||
| return [CAMetalLayer class]; | ||
| #endif // !TARGET_IPHONE_SIMULATOR | ||
| if (@available(iOS kMetalOSVersionBaseline, *)) { | ||
| return [CAMetalLayer class]; | ||
| } | ||
Kavantix marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| FML_CHECK(false) << "Metal availability should already have been checked"; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.