Behind Coherent GT’s performance excellence

by Billy December. 12, 14 0 Comment

In our last post, Nikola made some performance testing in Unreal Engine 4 and compared Coherent GT and Unreal’s in-house UI solution, called Unreal Motion Graphics (UMG) in a heavy UI situation. You can see the results here. Spoiler alert: Coherent GT was much faster.

In this entry I want to give more information about how Coherent GT works and why it outperforms other UI solutions. In no way do I want to bash UMG, it is a very good solution for simple interfaces and is obviously fast too (in most cases anyway). I haven’t really dug into UMG’s implementation, so I’ll only talk about how Coherent GT does things.

How to look at UI performance

There are two aspects involved when estimating the performance of a modern UI system. On the one hand, you have rendered. This is fairly obvious – most UI systems try to draw in the fastest possible way.On the other hand, which is very often neglected, is the performance of the scripting system. All modern UI systems have some logic that drives them. It is usually implemented at least in some part in a scripting language.

UMG uses Blueprints, which is a visual scripting system used throughout Unreal Engine. While Coherent GT uses JavaScript on all platforms, it also has a deep integration with Blueprints for UE4.

nameplate_showcase

As you can see from the screenshot, Nikola’s test consisted of an UI that can usually be found in MMOs or RPGs. There is a chat window, inventory and dozens of nameplates (elements with player data, name, health etc.) that move on-screen. This is a fairly heavy scene UI-wise and was chosen so that we could test all aspects of the system. There are a lot of things to draw that move constantly, so a lot of rendering, images, texts, vector elements. The movement has to be driven each frame, for every nameplate, so there is also a lot of scripting going on.

Rendering

First, let’s take a closer look in GT’s rendering. As stated in Nikola’s post, the test we made is in many aspects a ‘worst-case’ scenario for GT. The reason is that the rendering engine in the library keeps track on each frame of the UI parts that have changed and re-draws only them. Interfaces for the most part are static, with only a fraction of the whole screen changing each frame. Even in highly animated and dynamic interfaces the relative change frame-by-frame is often quite low. This optimization allows Coherent GT to save a lot of GPU work.

The sample we did moved almost everything on each frame in order for the comparison to be fair compared to UMG.

Coherent GT uses the GPU for all of its rendering. This puts many engineering challenges. Complex 2D rendering is difficult to do efficiently on GPUs, as they are for the most part optimized for 3D rendering.

Coherent GT has a set of highly optimized shaders that perform all the special effects (think of blurs, gradients etc.). The runtime tries to batch as many draws as possible together to minimize the graphics API overhead. We also cache intermediate results for re-use in subsequent draws. This cache is runtime configurable by the user and proves highly effective.All this achieves sub-millisecond rendering times of even the most complex interface systems.

Scripting

The second important aspect is the logic behind the UI. The Coherent GT core is written entirely in C++, but UI developers can use JavaScript to drive their interface and execute complex logic. Within GT there is a highly-optimized JS interpreter we use across all platforms.

In modern game UI it is quite common for developers to put a lot of logic in the UI scripts which might adversely influence performance. Nikola’s test shows that a huge part of UMG’s slowdown is due to the Blueprints code.

Coherent GT tries to offer the best possible scripting performance in 3 ways:
  • The interpreter is very fast and we continue to work on optimizing it further.
  • We provide ready-made frameworks that can be used directly by developers in their applications and are heavily optimized. Our JavaScript animation library, for instance, outperforms jQuery animations by an order of magnitude.
  • The Coherent GT Inspector has dedicated facilities for profiling. Users can view exactly what gets executed each frame and how much time it takes. Every event sent from the game is also logged and users can see how much time it took.

As much as scripting languages get optimized, the developer is the one in control. Having tools that allow you to see exactly what is going on each frame and where the milliseconds go is the only way to have a fast system with reliable performance. The Coherent GT Inspector does that – it was an invaluable tool during the optimization phase of the nameplates test.

A look in the future

We are working on a new rendering backend for Unreal Engine 4 based on the same backbone we use for our consoles ports. The new backend will provide even better performance and the first beta will arrive by the end of the month to all Coherent GT users.

Stoyan is the Software Architect of Coherent GT. Follow him on Twitter

Read more about Coherent GT here

Tags:
Social Shares

Related Articles

Leave a Comment

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