Why is Vulkan Better than OpenGL for X-Plane?

The creator of X-Plane, Austin Meyer, recently featured in a video from Michael Brown that explains, at a basic level, three key parts of Vulkan that work better over OpenGL.

The full 21-minute video can be watched below, but a summary is also available to read further down.

OpenGL

Essentially, the main takeaway from Austin's explanation was that "OpenGL is in a constant state of shock on what's going to happen next;" even if something happens repeatedly such as shader compiling, the rendering API - used by X-Plane for nearly two decades - has to fetch and work on something, before drawing the results on-screen.

This process of asking OpenGL to do something, then fetching the resources, then processing said resources, and finally outputting the result, is what causes stuttering.

The first part of rendering he spoke about are the shaders: In OpenGL, Meyer said that the compiling of shaders after it is requested can take a twentieth or a tenth of a second. In this time, X-Plane pauses to convert the shader from source code into executables - this is one such cause of stuttering.

When a user pans the camera around their aircraft for the first time after loading, this can be particularly bad as many shaders must be compiled in a short space of time.

Secondly are textures, which, if loaded in system memory (RAM), need to be transferred into video memory (VRAM), and other textures moved in the opposite direction.

This process also causes the simulator to pause momentarily, further contributing to stutters in X-Plane 11.41 and earlier.

Vertices and "the geometry of everything in the world" is the final puzzle the team have worked on. In this aspect, geometry must be copied from RAM to the GPU, which again introduces performance issues that lead OpenGL into a "constant state of shock."

Vulkan

Meyer described the primary idea behind Vulkan as the concept of prediction and pre-processing, and cutting out the issue of having to wait for stuff to load (i.e. stutters) whilst X-Plane is running.

Shaders are now compiled on the first start-up of X-Plane, rather than being done on the fly. Meyer described this solution by exclaiming: "I want you to compile every damn shader right NOW! And the result of that compile you fricking save it, so you are never surprised when we ask for the shader again!"

He went on to say: "We just got through every single shader load and every single shader pause before you flew frame one."

In terms of textures, Laminar Research now has more control over what textures are loaded by the simulator, by predicting where the user is flying to.

"[...] we are loading these textures before they are ever needed, on a background thread, on a multithread," said Meyer. The addition of the background thread allows textures to be loaded into VRAM without having to pause, thereby reducing stutters.

Finally, the process of rendering everything is now done more efficiently. He explained that requesting addresses and how many bytes of memory will assist in dedicating that amount of memory on the GPU, thereby speeding the simulator up.

In all three above cases, it was stated that Vulkan will simply execute what is already loaded in the VRAM without having to pause to retrieve more data.

But Meyer was not finished - he continued by outlining two short term and one long term target.

The short term targets are Virtual Reality (VR) and professional simulators. In the latter case, he said there was "tremendous interest from the military" with "plenty of six-figure dollar sims in the world," and explained a pause in one projection in multi-projector sims will introduce a break in the horizon, which Vulkan helps reduce significantly.

For the long term target, Meyer said it was for their next generation of scenery that they are working on now. Details are very thin at the moment, although it seems likely it will feature in X-Plane 12.

"[...] for us to go to ultimate high def incredible amazing scenery, we need absolute total control."


With the base simulator now running fast, a new bottleneck has appeared: plugin optimisation. Guest writer Taylor Broad went into the details of this new problem, available to read here.

To discuss Vulkan/Metal and the new challenges it presents, share your thoughts in the comments section below, or in our Discord server.

Follow us on our Socials!

COMMENT ADVISORY:
Threshold encourages informed discussion and debate - though this can only happen if all commenters remain civil when voicing their opinions.