Civilization graphic engineers Josh Barczak and John Kloetzli introduce AMDs Mantle API, and explain why Firaxis is supporting Mantle with Civilization: Beyond Earth.
0. What is Mantle?
A Graphics API (Application Programming Interface) is a protocol that rendering engines use to send commands to a GPU (Graphics Processing Unit). The API provides an abstract set of commands like draw which are translated by a GPU driver into commands which a particular device can understand. At present, the two most well-known graphics APIs are DirectX and OpenGL. DirectX is dominant on Windows, and OpenGL is dominant on many other platforms.
Mantle is a new graphics API developed by AMD, and supported on all newer AMD devices beginning with the Radeon HD 7000 series.
1. What is important about Mantle?
As game developers, we want to maximize our products reach while minimizing our development costs. Why then, would we spend a great deal of time and effort in something that would benefit only a subset of our user base? The idea of a platform-specific API, while not unheard of was not often implemented. After all, why would anyone write their application twice, when they could write it once?
In software, the only numbers of significance are 0, 1, and N. Every cross-platform graphics engine that we have ever worked with has been designed around some kind of API abstraction which separates the game code on top from the graphics platform on the bottom. If the abstraction layer is well built, then the cost of maintaining two graphics platforms is not worse than the cost of one. It is also important to understand that, with the right architecture, graphics APIs are essentially a fixed cost. Mantle has required an up-front investment, but the cost for future products to continue offering it will be considerably lower.
Because Mantle is so new, and so different, the development cost is higher than normal. In order to understand why its worth it, you need to understand just how important Mantle is.
2. What does Mantle Buy You?
Simply put, Mantle is the most advanced and powerful graphics API in existence. It provides essentially the same feature set as DX11 or OpenGL, and does so at considerably lower runtime cost.
The conventional wisdom in real-time rendering is that batches, or draw calls are expensive. On the PC, with current APIs, this notion is firmly rooted in fact. This is a problem that has plagued engine and driver design since at least the DX9 era, and a large body of real-time rendering tradecraft is motivated by it (instancing, state sorting, texture atlasing, texture arrays, uber-shaders, to name a few). Civilization, it turns out, requires a significant amount of rendering to generate our view of the world, and that in turn means we are required to make many, many more draw calls than you might expect.. Our birds eye view of the world means that we have a lot more stuff on screen than is typical, and our UI (a rich source of draw calls) is considerably more complex than the average.
Mantle changes things by working at a lower level than its competitors. Much of the work that drivers used to do on an applications behalf is now the responsibility of the game engine. This means that the Mantle API is able to be backed by a very small, simple driver, which is thus considerably faster. It also means that this work, which must still be done, is done by someone with considerably more information. Because the engine knows exactly what it will do and how it will do it, it is able to make design decisions that drivers could not.
Besides being more efficient, core per core, Mantle also enables fully parallel draw submission (this has been attempted before, but never with the same degree of success). Until now, the CPU work of processing the draw calls could only by executed on one CPU core. By removing this limitation, Mantle allows us to spread the load across multiple cores and finish it that much faster.
All of this means that Mantle has, quite literally, reduced the cost of a draw call by an order of magnitude. This is an amazing technical achievement and difficult for us to exaggerate the importance of this savings. It is a disruptive technical development which will have far-reaching implications for PC gaming. It will alter the dynamics of the market. It will re-write portions of the real-time rendering book. It will change the design of future APIs and engines and greatly enhance their capabilities.
3. What Does This Mean to the Player?
By reducing the CPU cost of rendering, Mantle will result in higher frame rates on CPU-limited systems. As a result, players with high-end GPUs will have a much crisper and smoother experience than they had before, because their machines will no longer be held back by the CPU. On GPU-limited systems, performance may not improve, but there will still be a considerable drop in power consumption. This is particularly important given that many of these systems are laptops and tablets. The reduced CPU usage also means that background tasks are much less likely to interfere with the games performance, in all cases.
Finally, the smallness and simplicity of the Mantle driver means that it will not only be more efficient, but also more robust. Over time, we expect the bug rate for Mantle to be lower than D3D or OpenGL. In the long run, we expect Mantle to drive the design of future graphics APIs, and by investing in it now, we are helping to create an environment which is more favorable to us and to our customers.
4. What about these other Vendors?
At present, the benefits of Mantle extend only to those customers which can run it. We recognize that a large fraction of our customers will not have access to Mantle, and we do not intend to discriminate.
Our philosophy is to strive to use our customers machines to their fullest potential. To the extent possible, DirectX customers will see the same images as Mantle customers, and we will provide DirectX customers with the highest performance that their systems are capable of. It is precisely this motivation which impels us to offer Mantle to those customers who can use it, because their machines possess great untapped potential. By tapping that potential, we hope to drive positive changes which will eventually spread to all of our other customers.
We expect that future graphics APIs will follow Mantles lead, and become much lower-level, out of necessity. There is nothing preventing other vendors from following AMDs example and offering low-level access to their own hardware, and we are perfectly willing to support such efforts. One API is clearly better for us than many, but if having many allows us to maximize performance across the board, then that is where the future will take us.
In the irreverently paraphrased words of Sir Winston Churchill:
If we can standardize it, all drawcalls may be free, and the life of the gamers may move forward into broad, sunlit uplands.
That, dear friends, is why I Am Mantle.