📜 ⬆️ ⬇️

Fast zombies

This is a translation of the new post from the Valve Linux blog.

One of the factors of a pleasant game is the speed of its work. In this post I will tell about what we learned about the graphics performance of our games running on Linux.
Any developer will say that productivity is a very tangled thing. Therefore, for simplicity of narration, we will focus on the following top configuration:


Iron

Soft

')
Do not worry, we use 32-bit versions of Linux temporarily, the release will work on a 64-bit architecture.
Launching Left 4 Dead 2 on Windows 7 with Direct3D driver, we get a value of 270.6 FPS. The data is generated using our internal tests.

When we started working with Linux, the first running version worked with 6 FPS. This is normal for the initial stage of porting the game to a new platform.
Performance improvements were mainly implemented in three ways:


For example, to improve the interaction with the kernel, we changed our memory allocation mechanism so that it uses more permissible functions for Linux. We also reduced the number of unnecessary calls to OpenGL and expanded the interface of our graphics engine to better interact with OpenGL and Direct3d.
The third point is especially interesting, as it includes working with hardware manufacturers to identify weaknesses in their drivers, and, as a result, improving them, which will positively affect the rest of Linux games. The study of driver delays and the addition of multi-threading support to it are two examples of changes that resulted from the joint work of our teams.

After all the work done, Left 4 Dead 2 runs on 315 FPS on Linux. The great performance in Linux compared to Windows (270.6), at first glance, looks a bit unintelligent, considering the amount of time spent on porting. However, this indicates the potential of the capabilities behind the kernel and OpenGL. By the way, in the process of working with equipment manufacturers, we also accelerated the implementation of OpenGL for Windows. Left 4 Dead 2 runs on 303.4 FPS in this configuration.

OpenGL vs. Direct3D on Windows 7


All this leads to the question: why is the OpenGL version of our game faster than the Direct3D version on Windows 7? This does not seem to apply to multithreading. We conducted a fairly honest analysis and found a small delay (several microseconds) for each batch in Direct3D, which does not affect OpenGL. Now we know that the hardware can do more, and we will figure out how to reach the new limit using Direct3D.

Work with video card manufacturers


We worked with NVIDIA, AMD and Intel in order to improve the performance of Linux drivers. Together we did a great job, it was very nice to see how our developers work together with them, carefully analyzing the data received. Each open bug was a discovery, and it’s simply priceless to be close to people who understand the game, the renderer, the driver, the hardware, and work with them side by side, attacking performance problems.

This is an excellent example of the benefits of close collaboration between software and hardware developers, and this collaboration should make a great contribution to the Linux community.

Source: https://habr.com/ru/post/148933/


All Articles