Tuesday, June 3, 2014

Metal & WhirlyGlobe-Maply

I'm sure I've got users who aren't glued to the WWDC announcements this week.  But then they're not sending me email.  So let's talk Metal.

Courtesy wikipedia, CC by 3.0

Metal is Apple's replacement for OpenGL ES, just to oversimplify it.  Am I going to support it?  I'm thinking about it.

Problems With OpenGL ES


If you're not neck deep in OpenGL ES, you might not really get what this is about.  I am.  It's what you people pay me to do.  Those of you that are paying me, anyway.

Ever written any OpenGL ES code?  It's pretty annoying.  You're setting things up all over the damn place and then carefully tearing them down again.  If you get it right, it's fine.  If you don't... well OpenGL has a million ways to display nothing and you just found another one.

Will Metal fix that?  Eh, probably not, but it will help with the set up and tear down problem.

OpenGL ES also has several mechanisms for moving memory around.  But it's memory... can't we just... move it around?  We can and there are extensions to make that easier.

In Support of Metal


Extension abuse is sort of the problem.  A lot of the fast paths through OpenGL are extensions and they're kinda goofy.  Even worse, OpenGL ES is by no means easy to use and it still has some cruft from the 1.0 days.  Moreover, it's diverged from the way hardware works.  Again.

If you look at the Metal docs, you can see the outline of how experienced developers use OpenGL ES, 2.0 or later.  It just all makes sense... if you do this stuff for a living.  It's about talking to the hardware in a way it expects compatible with how we actually work.

So I'm going to support it?  Maybe.

In Not So Much Support of Metal


This is about as far from a standard as you can get and no one is going to stop supporting OpenGL ES.  Because Android.

I've spent a while porting to Android.  Quite a while.  The OpenGL ES support there is.... fine.  I've had to turn off some of my favorite extensions, but it's okay, I was expecting that.  <sigh>  But this code isn't going to go away, I'm still going to support OpenGL ES indefinitely.  So will the game engines.

Metal is obviously something of an experiment.  Apple doesn't know how this is going to work out and neither do I.  OpenGL, for its flaws, has survived its imminent demise before.  I wouldn't bet on Apple.

So Will I or Won't I?


For WhirlyGlobe-Maply rendering isn't the hard part.  It's data management.  Getting all those vertices and texels into the right places is the tricky bit.  That doesn't change with Metal.  It's still the same logic, threading, and debugging.

So sure, I'd be happy to replace OpenGL ES with Metal.  And then I might turn around and port to DirectX, assuming Microsoft can ever get any mobile market share.

Here's one thing I will be doing.  I'll be discussing it with my performance minded clients and putting together estimates.  I think the chance is quite high.

No comments:

Post a Comment