One of the other big announcements at WWDC was the introduction of Metal to the new version of OS X, El Capitan. Metal is a low level graphics API that offers awesome performance and its availability on desktop and laptop devices allows developers to use a common codebase across both classes of device.
I've been playing with Metal on iOS extensively - mainly experimenting with compute shaders for calculating particle systems and running cellular automata on the GPU. I've just been lucky enough to spend some time at WWDC with the Metal team and port my ParticleLab component from iOS to OS X.
The Metal shader code hasn't changed at all and there are only a few small changes to the Swift host component, ParticleLab. These changes aren't platform specific, so once Xcode 7 reaches general availability, I'll be moving these changes to the main project.
The main change is that the component no longer extends CAMetalLayer, it's now a subclass of MTKView. I no longer use CADisplayLink to manage timing, I simply override the MTKView's drawRect() method and add my own step() method to that:
overridefunc drawRect(dirtyRect: NSRect)
{
ifmetalReady
{
step()
}
}
The end result is a cross platform, high performance GPU based particle system.
Bear in mind, Xcode 7 and El Capitan are still in beta. The particle system does render slightly differently on different GPU targets (e.g. Intel vs. AMD) and I'm sure there's more speed to eek out of the OS X version, but I'm absolutely blown away with the ease with which we ported the code and the potential of what Metal will be able to do on OS X devices.
A million thanks to the Metal engineers in the lab at WWDC - their passion and enthusiasm to help me out was beyond the call of duty.
My OS X Metal Particles project is available at my GitHub repo here.