Tips and Tricks

Shader Compilation

To improve startup time of an application is to compile all shaders and later link them. This way a graphics driver can batch-compile them, saving significant time. When using the leiaCreateProgram function, this type of optimization is not possible unless these are the last two shaders compiled, and all other application shaders are linked into programs after.

Handling all shaders together is a much better approach. In this case, compiling and linking would be done in two different steps, and the Leia shaders would be included with those from the original program.

Setup Cameras Once

In most games, the way the camera renders, as defined by its projection matrix, tends not to differ between frames. While there are plenty of scenarios where the camera may zoom in, on average the projection matrix does not change. Later, the camera will move and the projection matrix is multiplied by the camera's position matrix and you now have a scene. When using the Leia technology, you need to render the scene from each view. These extra views increase the number of matrix calculations that are necessary. Though setting up the camera matrices does not require lots of computation, it is generally more preferred to be as optimal as possible in order to minimize heat and power loss. Because of this, Leia recommends computing the matrices once or as needed instead of every frame.

UI, Menus and Text

In gaming, it is typical to find entire screens which are of 2D. Even if the buttons are lit and rounded, they still tend to be just textured as if they existed in 3D, instead of actually in 3D. For example, the start menu to most games tends to be entirely flat. In situations where the objects in the game are all rendered very near the same plane (such as menus), enabling the Leia 3D will not yield any results. While Leia does everything possible to have the best performance that is feasible, some performance impact is expected over 2D rendering. Due to this, when applications are using only 2D rendering or only rendering objects that are in a similar plane, do not enable 3D. Doing so will cause extra work to render in ¼ the resolution and will have no 3D effect, making the loss of extra power wasted.

Minimize GL draws with culling objects by area

In the average 3D application, often there are many objects in the world. One of the most costly processes in rendering with OpenGL ES is calling or similar functions.


The outcome of this is a large use of CPU computation and power. In the general case (without using the multiview extension), the Leia display requires the application to render each object for each view. This drastically increases the number of draws, and therefore also increases the CPU effort of the device. Many games implement a data structure to minimize the number of objects that are required to be drawn (KD-Tree is one example). With the number of draws doubling because of increase views, this type of data structure would pay for itself very quickly in performance.

Last updated

Copyright © 2023 Leia Inc. All Rights Reserved