Will iOS automatically transfer OpenGL ES commands into Metal commands?

92 views
Skip to first unread message

Shuangshuang Zhou

unread,
Sep 5, 2019, 9:43:11 AM9/5/19
to skia-discuss
Hi, all,
         Recently I'm trying to learn about Skia on iOS(ios 12.3) platform. I write a simple Skia demo using OpenGL ES as gpu backend. But when I run my demo on real iPhone device and use instruments in Xcode to monitor some events of my demo, I notice that there are lots of events running in Metal driver level. This makes me confused.

         I have heard that Apple would deprecated OpenGL ES on iOS 12. So in my case, currently on iOS platform(mine is 12.3), does it automatically transfer my OpenGL ES commands into Metal commands and use Metal to communicative with GPU even when I have specified OpenGL ES in my demo? If this is true, so why not just use Metal API in Skia instead of OpenGL ES on iOS or OpenGL on macOS?

Thanks

Shuangshuang Zhou

unread,
Sep 5, 2019, 9:48:30 AM9/5/19
to skia-discuss
and the event name of those events collected by instruments are like"com.apple.metal.gl", their event type are "Command buffer" or "Command Encoder"

Jim Van Verth

unread,
Sep 5, 2019, 9:50:31 AM9/5/19
to skia-discuss
We believe that Apple's current OpenGL and OpenGL ES drivers are written using Metal, but don't have any firm evidence for that other than what you're seeing. That said, the quality of their OpenGL support has certainly dropped in the past few years, e.g., they're not supporting the latest features and extensions and we've noticed more crashes as well. So I'd recommend moving to Metal if you can. Skia supports it, and from our tests, our Metal backend is faster than OpenGL ES. We're in the process of adding a demo to show how to set it up for iOS.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/11af5df5-d07f-4197-88b4-e70c32ce7712%40googlegroups.com.


--

Jim Van Verth | Software Engineer | jvan...@google.com | 919-210-7664

Jim Van Verth

unread,
Sep 5, 2019, 10:01:01 AM9/5/19
to skia-discuss
An early version of the Metal demo code is here: experimental/minimal_ios_mtl_skia_app/main.mm. You can also look in tools/sk_app/ios for the code we use for our tools. One uses an MTKView, the other uses a UIView with a CAMetalLayer.

Hal Canary

unread,
Sep 5, 2019, 10:29:44 AM9/5/19
to skia-discuss

Shuangshuang Zhou

unread,
Sep 5, 2019, 9:32:46 PM9/5/19
to skia-discuss
Thanks Jim, that helps me understand why my same Skia demo is "faster" on iOS than on other platform. I will try to use the Metal backend to rewrite my demo.
Very appreciate for your answer.

Best Regards,
Shuangshuang


On Thursday, September 5, 2019 at 10:01:01 PM UTC+8, Jim Van Verth wrote:
An early version of the Metal demo code is here: experimental/minimal_ios_mtl_skia_app/main.mm. You can also look in tools/sk_app/ios for the code we use for our tools. One uses an MTKView, the other uses a UIView with a CAMetalLayer.

On Thu, Sep 5, 2019 at 9:50 AM Jim Van Verth <jvan...@google.com> wrote:
We believe that Apple's current OpenGL and OpenGL ES drivers are written using Metal, but don't have any firm evidence for that other than what you're seeing. That said, the quality of their OpenGL support has certainly dropped in the past few years, e.g., they're not supporting the latest features and extensions and we've noticed more crashes as well. So I'd recommend moving to Metal if you can. Skia supports it, and from our tests, our Metal backend is faster than OpenGL ES. We're in the process of adding a demo to show how to set it up for iOS.

On Thu, Sep 5, 2019 at 9:48 AM Shuangshuang Zhou <shuangsh...@intel.com> wrote:
and the event name of those events collected by instruments are like"com.apple.metal.gl", their event type are "Command buffer" or "Command Encoder"



On Thursday, September 5, 2019 at 9:43:11 PM UTC+8, Shuangshuang Zhou wrote:
Hi, all,
         Recently I'm trying to learn about Skia on iOS(ios 12.3) platform. I write a simple Skia demo using OpenGL ES as gpu backend. But when I run my demo on real iPhone device and use instruments in Xcode to monitor some events of my demo, I notice that there are lots of events running in Metal driver level. This makes me confused.

         I have heard that Apple would deprecated OpenGL ES on iOS 12. So in my case, currently on iOS platform(mine is 12.3), does it automatically transfer my OpenGL ES commands into Metal commands and use Metal to communicative with GPU even when I have specified OpenGL ES in my demo? If this is true, so why not just use Metal API in Skia instead of OpenGL ES on iOS or OpenGL on macOS?

Thanks

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.


--

Jim Van Verth | Software Engineer | jvan...@google.com | 919-210-7664

Shuangshuang Zhou

unread,
Sep 5, 2019, 9:37:34 PM9/5/19
to skia-discuss
Also thanks to Hal for clearly pointing the location for me~

Best Regards,
Shuangshuang

zhou

unread,
Sep 9, 2019, 11:04:16 PM9/9/19
to skia-discuss
Hi Jim, sorry for interrupt. After I set up the environment for using Metal backend in Skia, I met one problem. I use the latest Skia source code to build needed lib files. And after import all needed head files, just get below 2 errors:

屏幕快照 2019-09-10 上午10.43.17.png

屏幕快照 2019-09-10 上午10.43.28.png


Once I thought maybe SK_METAL was not defined in my Xcode project. So I add this to the first line in main.mm. Then these 2 errors disappear, another 3 errors came out:

屏幕快照 2019-09-10 上午10.40.02.png

It seems that these 3 functions are undefined symbol, but in the code, I can jump into their definition.


So is there something I forget to set?


Thanks,

Shuangshuang



On Thursday, September 5, 2019 at 10:01:01 PM UTC+8, Jim Van Verth wrote:
An early version of the Metal demo code is here: experimental/minimal_ios_mtl_skia_app/main.mm. You can also look in tools/sk_app/ios for the code we use for our tools. One uses an MTKView, the other uses a UIView with a CAMetalLayer.

On Thu, Sep 5, 2019 at 9:50 AM Jim Van Verth <jvan...@google.com> wrote:
We believe that Apple's current OpenGL and OpenGL ES drivers are written using Metal, but don't have any firm evidence for that other than what you're seeing. That said, the quality of their OpenGL support has certainly dropped in the past few years, e.g., they're not supporting the latest features and extensions and we've noticed more crashes as well. So I'd recommend moving to Metal if you can. Skia supports it, and from our tests, our Metal backend is faster than OpenGL ES. We're in the process of adding a demo to show how to set it up for iOS.

On Thu, Sep 5, 2019 at 9:48 AM Shuangshuang Zhou <shuangsh...@intel.com> wrote:
and the event name of those events collected by instruments are like"com.apple.metal.gl", their event type are "Command buffer" or "Command Encoder"



On Thursday, September 5, 2019 at 9:43:11 PM UTC+8, Shuangshuang Zhou wrote:
Hi, all,
         Recently I'm trying to learn about Skia on iOS(ios 12.3) platform. I write a simple Skia demo using OpenGL ES as gpu backend. But when I run my demo on real iPhone device and use instruments in Xcode to monitor some events of my demo, I notice that there are lots of events running in Metal driver level. This makes me confused.

         I have heard that Apple would deprecated OpenGL ES on iOS 12. So in my case, currently on iOS platform(mine is 12.3), does it automatically transfer my OpenGL ES commands into Metal commands and use Metal to communicative with GPU even when I have specified OpenGL ES in my demo? If this is true, so why not just use Metal API in Skia instead of OpenGL ES on iOS or OpenGL on macOS?

Thanks

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-d...@googlegroups.com.


--

Jim Van Verth | Software Engineer | jvan...@google.com | 919-210-7664

zhou

unread,
Sep 9, 2019, 11:16:45 PM9/9/19
to skia-discuss
I check the libskia.a for "MakeMetal", do I need to add some flags when building skia? 

zhou

unread,
Sep 9, 2019, 11:17:45 PM9/9/19
to skia-discuss
libskia.a doesn't obtain "MakeMetal"...

zhou

unread,
Sep 10, 2019, 2:28:26 AM9/10/19
to skia-discuss
Well, I add the flag "skia_use_metal=true" when using gn to generate building settings for building Skia, it seems work fine. Now I can find these functions in libskia.a

Brian Osman

unread,
Sep 10, 2019, 9:06:43 AM9/10/19
to skia-d...@googlegroups.com
Yes, the Metal code is not compiled by default. Setting 'skia_use_metal=true' in GN is the correct solution.

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/93a3ef9a-ddb5-4faa-a32d-2f814ff36519%40googlegroups.com.

zhou

unread,
Sep 10, 2019, 9:49:09 PM9/10/19
to skia-discuss
Besides using MTKView(new to me, need some time to learn), I also try to use the "main_ios.mm" in tools/sk_app/ios which uses CAMetalLayer in Xcode. But Xcode returns below errors:

屏幕快照 2019-09-11 上午9.43.31.png


Did I miss something before using sk_app?

Thanks
Message has been deleted

Jim Van Verth

unread,
Sep 11, 2019, 9:25:33 AM9/11/19
to skia-discuss
It looks like the other files in tools/sk_app/ios (Window_ios.mm in particular here) aren't included in your build. You also need to create a subclass of sk_app::Application, and define your own sk_app::Application::Create() method which will return a pointer to an instance of that class. See example/HelloWorld.cpp or tools/viewer/Viewer.cpp for an example of that. If you're looking at HelloWorld, you'll want to use kMetal_BackendType rather than kNativeGL_BackendType in fBackendType.

On Tue, Sep 10, 2019 at 9:50 PM zhou <zhous...@gmail.com> wrote:

屏幕快照 2019-09-11 上午9.43.31.png

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/18d2dc9f-4335-4732-926c-034bc41f7d46%40googlegroups.com.

Adrian Dumitru

unread,
Sep 14, 2019, 12:22:03 AM9/14/19
to skia-discuss
Hello, I'm currently trying to run the experimental MTKView example however drawInMTKView is not called by default. My understading is that this should be called on a internal timer trying to achieve 60 frames per second unless paused is set to NO.
I can see the canvas if I manually call this function in drawableSizeWillChange. Is this the expected behaviour, if yes how to achieve continuous drawing?

Hal Canary

unread,
Sep 14, 2019, 2:36:36 PM9/14/19
to skia-discuss
No, as written, it should be animated. I'm not sure what you are doing differently. 

To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/b0c71fd1-823a-4a30-ab93-4f88c6b8a8cc%40googlegroups.com.

Adrian Dumitru

unread,
Sep 15, 2019, 1:56:28 AM9/15/19
to skia-discuss
I'm not doing anything differently, I also tried to run AS IS(only main.mm) as well as integrating it in a simple single view app, I only had to add #define SK_METAL 1 to be able to compile. I'm using the GM iOS 13 and GM Xcode 11.
drawableSizeWillChange is called once but drawInMTKView is never called.

Adrian Dumitru

unread,
Sep 15, 2019, 2:23:32 AM9/15/19
to skia-discuss
Fixed by adding AppViewDelegate* viewDelegate; to the viewcontroller's instance variables.
Reply all
Reply to author
Forward
0 new messages