Working With Metal On iOS 8: Know The Basics
Copyright © Teks Mobile 2023

Working With Metal On iOS 8: Know The Basics


Hussain Fakhruddin - May 29, 2015 - 0 comments

Metal is a high-end accelerated graphics rendering API, used by many iOS developers worldwide. On the iOS 8 platform, some of the key features and advantages of Metal have been highlighted here.

 

 

Till last year, iOS game developers had to be overly reliant on OpenGL ES – which served as a virtual linking tool between game elements and device processors/hardware. A common complaint against OpenGL ES was its heavy overhead, that tended to affect the performance of games and graphics-rich apps. Metal, a low-level graphics API (released with iOS 8) has emerged as a better alternative – particularly since it enables developers to bring their games directly in sync with hardware setups, and get the optimal performance from the Apple A7 and A8 chip processors. In what follows, we will take you through some key points related to using Metal for mobile game development on the iOS 8 platform:

 

  1. Device compatibility – For starters, the high-end mobile graphics features that Metal brings to the board cannot be enjoyed on all iDevices. Game developers can use the API only when creating applications for handsets that have the A7, or better still, the A8 processor. In other words, iPhone 5S, iPhone 6/6 Plus, iPad Mini 3 and iPad Air 2 are the devices compatible with Metal. A game that uses Metal can very well be downloaded on iPhone 5 or iPhone 5C – but since they run on older processors, the improvement in graphics won’t be discernible.
  2. Procedure of reducing overheads – How does OpenGL ES work? It reads and translates functions into graphics commands, and then sends the latter to the hardware of devices. This gives rise to two types of overhead. Firstly, there is the ‘engine-side overhead’, which occurs due to the need for the CPU to reiterate over the program objects, the required material parameters, lighting effects, and such tasks. On the other hand, there is the ‘Graphics API & Driver’ overhead. This is the part that Metal reduces significantly (it does not have much effect on the ‘engine-side’ overhead). The new API does not require any additional synchronization, handles explicit actions more efficiently, and all state-creation and validation is performed upfront. According to iPhone app development experts, this almost entirely does away with the ‘Graphics API & Driver’ component of overhead.
  3. Support on Unity – When Metal was initially announced (in September 2014), there was no mention of it being supported on the Unity game engine. The scenario changed with the release of Unity 4.6.3 – which, for the first time, offered complete Metal-rendering functionality. With the launch of the Unity 5.x versions, mobile game developers have been increasingly able to combine the features of the engine and the Metal API. The result, of course, has been better, faster, more engaging games and applications.
  4. Greater speed and responsiveness – In comparison with OpenGL ES on the A7 processor (in iOS 7 devices), Metal allows developers to render 3D games about ten times faster. This boost in the Draw Call rates (the pace at which scenes in 3D games are rendered) automatically makes Metal games much more responsive than earlier. For game developers who wish to add a touch of realism to the gameplay environments, the faster load time and the built-in support for precompiled shaders also works wonders. Users no longer have to patiently wait for games to load on their iDevices, and developers are more confident about delivering an immersive, engaging gameplay experience.
  5. Loading and compilation – As briefly touched upon earlier, presence of precompiled shaders is one of the high points of the Metal API tool. Those using Metal to create an iPhone/iPad game can load the shaders at runtime, after they have been compiled at the time of building the code. In fact, the shader codes can also be compiled at runtime. This, in turn, simplifies the entire process of generating program codes, while debugging becomes easier for app testers as well. Apple clearly had an eye on reducing the complexities of mobile game development, when it came up with Metal.
  6. Are Metal games console quality? – That would be a ‘Yes’. As long as end-users are not expecting games that are at par with the PlayStation 4 standard – the graphics of Metal games would more than satisfy them. The GPU power of iOS devices are utilized to the full by Metal, to render game graphics that are equally good as those viewable on the PS3. Over time, the quality of graphics rendering with Metal is expected to improve further.
  7. Prior programming expertise required – Before trying to code iOS games with Metal, new developers have to get an in-depth idea of the Objective-C programming language (well, without Obj-C and Swift, iOS apps cannot be developed anyway!). The shading language used in Metal is C++11 – which shares several features with C++. On the Metal framework, C++11 is used to perform all tasks related to coding for games – right from graphics addition, to computation and execution of programs on the GPU. In addition, coders should also have some relevant advance experience of working with OpenGL and OpenCL. LLVM and Clang come into play for implementing the shading language of Metal.
  8. Impact on battery performance – Metal extracts every bit of available juice from the A7/A8/A8X processors of iDevices. As a result, users who install Metal-powered games on their handsets might experience slightly worse battery life than before (the battery life of iPhones is nothing great in the first place). However, this effect is not drastic – and is often rather negligible – since Metal does away with the overheads of OpenGL ES, streamlines the gameplay, and lowers the total number of commands. Yes, the graphics level is higher, but that is offset to a large extent – thanks to the unified pixel-coding feature that Metal offers. The workload on the GPU gets lowered, which minimizes the risks of excessive battery drains.
  9. The advantage of building libraries – Professionals from leading iPhone app and game development companies opine that developers should create libraries during the process of building the application. This makes the entire development process more systematic than when the source codes of the Metal shaders are compiled at runtime. A library (in the .metallib format) can be created either by making use of available command line utilities, or directly inside the Xcode environment. Results from app performance surveys confirm that libraries indeed add to the performance and immersiveness of a Metal game/app.
  10. Cam Metal give a boost to Apple TV? – At present, it cannot. Apple has made Metal compatible only with devices that are powered by the 64-bit A7 or A8 chip processors. Apple TV – the Cupertino company’s much hyped digital media player and set-top box – got its latest refresh way back in January 2013 (version 3 Rev. A), and is still stuck with the old A5 processor. However, during the upcoming Apple WWDC 2015, Apple TV is expected to get an upgrade (it has been a long time coming) – and then, it might well be compatible with metal games. iOS game developers feel that Tim Cook is missing a trick by not bringing the console-quality games to the Apple TV platform.
  11. Metal does not enhance the performance of games only – Metal cleans up excess overheads from the CPU and GPU of the latest iDevices. As a result, the performance of any iOS application that uses these resources (like video-streaming apps or images apps) goes up by a couple of notches. Although the API is, of course, mainly focused on easing the process of game development, it adds to the speed and power of other apps as well.
  12. Handling computation and graphics together – This makes the job of iOS game developers that much easier. The same textures, buffers, command queues, and other data structure elements in Metal can be used for computing operations as well as the addition of graphic elements. All resources can be seamlessly shared across graphic shaders, the runtime interface(s) and the functions for computing. What’s more – the shading language also supports both graphics and computing. Developers need not worry about integrating other languages in the API framework.
  13. Good for the latest flagship devices – According to device analysts and mobile software developers, the CPU/GPU efficiency of Metal bolsters the general performance of the latest flagship iPhones. On any device running on iOS 8, Metal ensures that the speed of software operations gets a boost, and the device itself becomes more responsive. Common tasks, like taking pictures and listening to audio files, become more efficient too.
  14. What’s with the name? – According to Craig Federighi, senior VP at Apple Inc., the new API is geared to give app developers ‘metal access to the power of A7’ (A8 had not been unveiled at that time). This justifies the choice of name – Metal – for this new graphics API for making iOS games. The company probably also had the oft-used catchphrase of software programmers – ‘close to the metal’ – while deciding the name. Metal allows coders to get the most out of device hardware and processors, and avoid most of the third-party overheads (read: OpenGL ES), and that’s precisely what the name indicates.
  15. Other platforms have similar tools too – Metal offers more than a generous share of advantages to iOS developers – but it’s not like those working on other platforms do not have access to similar tools. The much-maligned Microsoft platform has Direct X 12, while Android Lollipop has the Android Extension Pack – which have roughly similar functional features to those of Metal. The Mantle technology on Advanced Micro Devices (AMD) also has several common features.

While SceneKit on iOS 8 is primarily aimed at amateur/casual game developers, Metal is the tool for professional-level, hardcore game development for iOS devices. It has been found that the performance of Metal games do not get affected in any way by the overheads of the Unity engine – a great news for developers working on games for multiple platforms. The enhanced graphic features of Metal were first showed off at last year’s WWDC, in a game called Zen Garden (by Epic). The first look indicated that Apple had something good on hand for game developers – and the surging popularity of Metal bears testimony to that!

Related posts

Post a Comment

Your email address will not be published. Required fields are marked *