At their APU13 conference held in San Jose, California on 13 November 2013, AMD revealed more details about its new Mantle API and DICE lead engine programmer, Johan Andersson, was on stage to talk the audience through the benefits of his creation.
The first titbit about Mantle that was revealed was that Andersson took the concepts for a new low-level API and approached AMD, Intel, and Nvidia with the software, with the goal to have a company evangelise it and eventually turn it into a software standard. Only AMD was eager to adopt it and eventually called it Mantle to tie into their reveal for the Volcanic Islands family of GPUs.
Benefits to memory management
Mantle is not for everyone, says Andersson. It offers fine-grained controls for tweaking how games run on computer hardware and it offers very similar benefits to what console developers enjoy, thanks to extra controls for memory management. Mantle is a big responsibility for a developer to take on – not only do they have to become familiar with the hardware architecture they’re targeting, but they also have to keep an eye on how their program or game accesses and handles various resources on the system.
One example is memory tiling. In DirectX 11.2, Microsoft has added in support for tiled memory, in which the GPU and CPU can both access each other’s memory sets in system RAM. DirectX has a generic way of doing this and while it works, it has a lot of performance overhead and offers no way of tweaking how memory is accessed and categorised.
With Mantle you can set where resources should preferably be stored in the tiled memory pool and the API will do exactly what you want, store it where you want and how you want it ordered. Crucially though, you have to keep in mind where all this information is going and stored, and you have to manually specify when it must be discarded or re-used.
Compared to DirectX, Andersson says the memory savings are significant and could vary between 30% to 60% lower memory use.
Benefits to multiple CPU cores
Another benefit to developers is that Mantle allows for massive scaling as more cores are added into a system. In modern APIs the batches of draw calls are organised by the CPU for the most part and the way threads are organised cannot be done on more than a handful of CPU cores. The way things are currently done leaves some cores inactive and this leads to developers optimising for single-threaded performance, leaving AMD’s processors twiddling their digital thumbs.
Mantle, with its large 100,000 draw call limit, can scale beyond just a few cores and Andersson says they see the most benefits with six to eight cores, topping out at 16. After that point, the performance returns are minimal. This also means that stronger GPUs paired to weaker CPUs are less bottlenecked by the processor, as traditionally weaker CPUs wouldn’t be able to feed the GPU information at the required rate.
Interestingly, EA’s studios will be applying the same render techniques from the consoles into the Mantle versions of their games – which means that upgrading your CPU and adding in more cores, for the first time in ages, will actually improve performance noticeably (and possibly in a linear fashion too).
Benefits to GPU performance
“Mantle is a more elegant way to program a game and its engine”, says Andersson, “so there’s no need for brute force rendering, where you tell the GPU to simply spit out frames as they are needed or finished.”
The API’s low-level driver can scan through code that the GPU will be working with and organises the threads based on dependencies and what the most efficient queuing method would be. Code that needs to be run in parallel will be assigned hardware resources so that no part of the GPU is left idle when running through a workload.
In fact, the GPU can also look forward through the code it’s given to see which threads need to be immediately run and, if resources are available, which threads can be executed for future use. Mantle further allows developers to see how their code would be queued when a GPU is working with it and add in descriptors that specify if code needs to be executed now or later, in addition to what type of workload it is.
In multi-GPU systems, the GPUs can organise each other’s thread queues and the developers have tools to allow them to see how their application or game would run in a multi-GPU scenario. This allows developers to tweak how their application runs with more GPUs in a system and opens up options for alternate workloads for a system with an APU and discrete GPU inside.
Benefits to programmability
Andersson doesn’t just see Mantle being used for games, but also for high-performance computing scenarios. He spent a few minutes explaining that workstations and compute servers could use Mantle for GPGPU acceleration, using the API’s tools to run their software more efficiently with lower performance overheads.
One scenario was using multiple FirePro cards in a system with a single quad-core processor for a render farm, where the workloads wouldn’t bog down the system because the CPU was too busy feeding the GPUs with information, or a reverse scenario in which the CPU is left idle when it could be assisting with the workload.
In addition, render farm systems could have different GPUs and use the Mantle API to assign code to specific GPUs that may run through certain types of code better than others. I can see this particular feature being used for Bitcoin mining on Radeon GPUs where a system may have one large, powerful GPU along with several weaker ones.
Another example was using the Oculus Rift. Andersson actually mentions “VR headsets”, but he alluded to the Rift when he mentioned that in a dual-GPU system, one could use each GPU to draw information for the two screens in a VR headset, removing issues with Eyefinity and stuttering, while having the GPUs run in tandem with slightly varying data sets to render a game in 3D, using a shared memory pool and matching up their thread queues to allow things to run smoothly.
Benefits to multiple platforms
Andersson was concise about OS support for Mantle – it currently only runs on Windows 7 and Windows 8. AMD and Andersson would like to see the API appear on Linux and Mac OS X systems as well as systems running Android and iOS, but noted that this was a future goal that was far from completion. Windows XP and Vista may be technically capable of running Mantle, but they are older platforms that receive little support from Microsoft.
Despite the Windows dependency, DirectX and OpenGL will still be necessary for AMD and DICE to support, as not all gamers would have the right hardware to run Mantle and not all developers would take on the task of coding support for it. Andersson says that their next targeted platform could be SteamOS as in his own words, “that would be a brutally powerful combination.”
From the perspective of DICE and Electronic Arts, all games running on the Frostbite 3.0 engine will be compatible with Mantle. EA has also said before that if the adoption is reasonable among consumers that Mantle would be incorporated into their other engines as well.
Battlefield 4’s Mantle update arrives in December 2013 and Plants vs Zombies: Garden Warfare supports the API right out of the box. Andersson said that porting Battlefield to Mantle took about two months of work.
Multiple hardware vendors
The big shocker from the lecture by Andersson was that Mantle is capable of running on other modern hardware platforms. Although only GCN-based graphics hardware will benefit from this point, Mantle can run on Nvidia and Intel graphics. Andersson even said that the API would be arguably more beneficial to both companies than the same game using DirectX or OpenGL.
It doesn’t stop there. AMD’s goal is to make Mantle a software standard and offer it as an alternative to developers who want more control than DirectX offers, with all the benefits of better performance, more efficient programming methods and comprehensive documentation for the API.
It will be free for developers to implement as well and will surely see adoption in AMD’s Gaming Evolved program.