Oh yes... Linux Gaming is happening!

So Valve has gotten the source engine to scream on Linux. Moreover they have found that OpenGL has better efficiency than Direct3D. What does this mean? Great things for Linux gaming. I might actually be able to give up Windows now! So… thanks Microsoft?

http://blogs.valvesoftware.com/linux/faster-zombies/

One factor in creating a good gaming experience is throughput.  This post discusses some of what we’ve learned about the performance of our games running on Linux.
As any software developer can tell you, performance is a complicated issue.  In the interests of simplicity, we’ll concern ourselves with the following high-end configuration:

Hardware

  • Intel Core i7 3930k
  • NVIDIA GeForce GTX 680
  • 32 GB RAM

Software

  • Windows 7 Service Pack 1 64-bit
  • Left 4 Dead 2
  • Ubuntu 12.04 32-bit

We are using a 32-bit version of Linux temporarily and will run on 64-bit Linux later.
Running Left 4 Dead 2 on Windows 7 with Direct3D drivers, we get 270.6 FPS as a baseline. The data is generated from an internal test case.

When we started with Linux, the initial version we got up and running was at 6 FPS. This is typical of an initial successful port to a new platform.
Performance improvements fall into several categories:

  • Modifying our game to work better with the kernel
  • Modifying our game to work better with OpenGL
  • Optimizing the graphics driver

An example of the first category would be changing our memory allocator to use more appropriate Linux functions. This was achieved by implementing the Source engine small block heap to work under Linux. The second category would include reducing overhead in calling OpenGL, and extending our renderer with new interfaces for better encapsulation of OpenGL and Direct3D.
The third category is especially interesting because it involves working with hardware manufacturers to identify issues in their drivers and, as a result, improving the public driver which benefits all games. Identifying driver stalls and adding multithreading support in the driver are two examples of changes that were the result of this teamwork.
After this work, Left 4 Dead 2 is running at 315 FPS on Linux. That the Linux version runs faster than the Windows version (270.6) seems a little counter-intuitive, given the greater amount of time we have spent on the Windows version. However, it does speak to the underlying efficiency of the kernel and OpenGL. Interestingly, in the process of working with hardware vendors we also sped up the OpenGL implementation on Windows. Left 4 Dead 2 is now running at 303.4 FPS with that configuration.

OpenGL versus Direct3D on Windows 7

This experience lead to the question: why does an OpenGL version of our game run faster than Direct3D on Windows 7? It appears that it’s not related to multitasking overhead. We have been doing some fairly close analysis and it comes down to a few additional microseconds overhead per batch in Direct3D which does not affect OpenGL on Windows. Now that we know the hardware is capable of more performance, we will go back and figure out how to mitigate this effect under Direct3D.

Working with hardware vendors

We’ve been working with NVIDIA, AMD, and Intel to improve graphic driver performance on Linux. They have all been great to work with and have been very committed to having engineers on-site working with our engineers, carefully analyzing the data we see. We have had very rapid turnaround on any bugs we find and it has been invaluable to have people who understand the game, the renderer, the driver, and the hardware working alongside us when attacking these performance issues.
This is a great example of the benefits that are the result of close coordination between software and hardware developers and should provide value to the Linux community at large.