What is Metal, and what does it mean for Mac gamers? Will the Mac games market now become as successful as the iOS gaming market?
Metal is an API (Application Programming Interface) designed by Apple that makes it easy for developers to create visually impressive apps - and games in particular. It was introduced in 2014 alongside iOS 8, but at WWDC 2015 Apple announced that it was bringing Metal to Mac OS X.
This is good news, because Mac OS X has more demanding apps in general than iOS. Metal is mostly used by games developers, but builders of other visually demanding apps (such as Adobe) can also use Metal to make their apps run faster. It also makes it easier for game developers to move their games from iOS to OS X (and vice versa).
What is Metal for Mac OS X?
If you're not a programmer then the concept of an API may be a little vague. When coders develop apps they don't create everything from scratch. Instead they build apps, like games, using code developed by other people. These blocks of code fit together to make the most of an app. Sensible programmers use APIs because the code is typically optimised for best performance and it frees up the coder to think about other things.
There are all kinds of APIs made by Apple. There's an API to control the camera, another one to play music, one for Apple Maps and so on.
Metal is an API for graphics processing. The Metal API supports GPU-accelerated advanced 3D graphics rendering and data-parallel computation workloads. According to Apple, "A primary goal of Metal is to minimise the CPU overhead incurred by executing GPU workloads."
The API is designed to take graphics tasks away from being rendered as code by the CPU, and send it directly to the GPU. This is why it's called "Metal": because it sends code that needs running directly to the metal of the graphics card.
What kind of graphics performance gains will I see with Metal?
Craig Federighi, announcing Metal's debut on Mac at WWDC, claimed performance gains "up to 50 per cent faster" when rendering graphics in Metal, and a 40 per cent reduction in the CPU usage.
Apple says Metal combines the computing power of OpenCL with the graphics power of OpenGL (both APIs currently used by developers). The performance of Metal results in a higher performance from a single API.
Federighi claimed that Adobe saw an 8x performance improvement when rendering effects inside After Effects. Adobe has said that it is committed to adopting Metal in its Mac OS X apps.
Metal for OS X and iOS gaming
Federighi also announced that Metal on OS X provides up to 10x faster draw call performance.
Graphics processors are essentially giant "state machines". Picture a huge board of 1970s-style switches and dials, each labelled with a particular feature. Not all combinations of features are supported by the machine, but you're free to flip the switches anyway. The combination of switches that you've flipped and dials you've tweaked determines the "state of the system".
The job of the graphics programmer is to flip the right switches, turn the dials just so, and then feed the processor with geometry. This is the sequence that Apple is referring to when it mentions how many more "draw calls" per frame Metal is capable of.
With OpenGL, the current standard for creating graphics, programmers would flip each of these switches and tweak each of these dials individually. Each time they did so, the graphics processor would have to check that the state of the giant machine was still valid.
By using Metal, a programmer can instead define the state they need the machine to be in and then simply apply that state. Rather than tweaking each dial, flipping each switch, and jumping through the correct hoops, the process becomes more like checking off your sushi order from a menu.
From a user's perspective, none of these particular details matter. The ramifications, however, will definitely be noticed.
The magic of Metal
Metal is designed around the way that GPUs and CPUs work today, especially (and specifically) when it comes to Apple's A7. The A7 combines the GPU and CPU into one chip, and they also share a single memory pool.
Much of OpenGL is predicated on the notion that the GPU is (or could be) sitting on a separate card. By recognising the fact that the GPU and CPU can access the same memory, Metal unlocks a lot of power. Managing resources needed for drawing becomes vastly easier and faster. Many effects, such as reflections, require drawing the scene into an image and then using that image as an input in the final scene. Metal makes that far easier.
Modern GPUs and CPUs both have multiple cores - they can walk, talk, chew gum, and juggle all at the same time - and Metal provides a way to unlock all of that power by allowing for multiprocessing of graphics commands. OpenGL, by comparison, was always single-threaded and so couldn't achieve a similarly adept usage of the actual hardware.
It isn't just better graphics performance that Metal unlocks. It also supports a model of what's called "general purpose graphics unit computing" - that is, using the GPU to run software that's not necessarily graphics-related. OpenCL, which may be familiar to Mac users, is the open standard for writing software that executes on GPUs. Metal brings this kind of general purpose graphics programming ability to iOS. As the name suggests, OpenCL is very similar to OpenGL and so the design of Metal offers benefits for OpenCL similar to the ones it does for OpenGL. The baked-in idea that memory is shared between processors is a big win here too.
It's the same story for multithreaded access. With the general purpose computing capabilities of Metal we'll start to see the A7 really shine in unexpected ways. Apps like Capo will be able to leverage the GPU on iOS as it does on OS X in order to accomplish software tasks that previously hadn't been possible.
Metal on iOS: benefits for all
Which is all well and good, of course, but what does this all mean from the perspective of an iOS device user? In some ways, advancements like Metal are similar to building the Large Hadron Collider - we actually don't know exactly what kind of opportunities we'll discover, but it's a brave new world and one that's full of possibilities.
In a more practical sense there are concrete benefits that users will certainly appreciate, including faster load times (due to better resource management, pre-compiled shaders, etc.), more detailed worlds (due to the faster draw calls, more stuff can happen or be drawn), and likely a ton of applications that can use the GPU as a computational platform.
Of course, none of these apps simply appear because Metal has been introduced. Developers will need to adopt the new system and write their software specifically for it. But, the good news on that front is that the major game companies on the iOS platform have already demonstrated their commitment. Both Unreal and Unity, the two biggest game engines, have announced support for Metal. So, even without developers investing in understanding and implementing an engine with Metal, many big games that use those systems will benefit from its improvements anyway.
Taking a step back from the technical details Metal also has interesting political implications. Apple is, as it often does when it can, taking its destiny into its own hands. Rather than be tied up with The Khronos Group (the body responsible for OpenGL and OpenCL), Apple is free to make changes to Metal as quickly as it would like, in order to continue to best address its hardware.
This is a big strategic move, because it signals that the company believes it has the developer base and enough devices in the field to forge its own path. It'd be hard to argue that it's wrong about that. It also signals that Apple's taking gaming more seriously than ever before. Apple has famously never had a great platform for gaming, but with iOS that has changed - and it appears that Apple is changing too. Metal and the investment Apple's made in its development and support shows that the company's now taking gaming very seriously, indeed.
None of this is to say that OpenGL (or OpenCL) will be going away or won't serve their own purposes. There are still many, many applications for which they're perfectly well suited. But Metal is a lower level, more accurate, model of modern chips like the A7. And once we start seeing apps that use Metal we'll start to see what the A7 is really capable of.