In a scary twist that reinforces Valve’s distaste for Windows 8, it turns out that the Source engine – the 3D engine that powers Half Life 2, Left 4 Dead, and Dota 2 – runs faster on Ubuntu 12.04 and OpenGL than Windows 7 and DirectX/Direct3D.
The Valve Linux Team breaks it down on their shiny new blog: With an Nvidia GTX 680, Intel i7-3930k, and 32GB of RAM, Windows 7 and DirectX, Left 4 Dead 2 maxes out at 270.6 fps (frames per second). With the same hardware, but different software – Ubuntu 12.04 and OpenGL – Left 4 Dead 2 (L4D2) scores 315 fps, almost 20 per cent faster than Windows.
These figures are remarkable, considering Valve has been refining the Source engine’s performance under Windows for almost 10 years, while the Valve Linux team has only been working on the Linux port of Source for just a few months. Valve attributes the speed-up to the “underlying efficiency of the [Linux] kernel and OpenGL.”
The Linux port of L4D2 didn’t start off at 315 fps, of course – the initial version actually maxed out at just 6 fps. To realise such a huge performance gain, a three-pronged approach is taken: The game is tweaked to play nicely with the Linux kernel, the game is optimised to work with OpenGL (rather than DirectX), and bugs in the Linux graphics drivers are addressed.
This last point is interesting. Valve has long-standing relationships with AMD, Nvidia, and Intel, where Valve reports driver bugs and the GPU maker fixes them in a timely fashion. Valve is carrying this relationship over to Linux, which is very important for the continued growth of Linux as a gaming platform. In this case, Valve says that the Nvidia Linux driver lacked multithreading support – and once they added it to a later version of the driver, performance increased.
But here’s the best bit: Using these new OpenGL optimisations, the OpenGL version of L4D2 on Windows is now faster than the DirectX version. With the same hardware, Windows 7/OpenGL/L4D2 clocks in at 303.4 fps – compared to Windows 7/DirectX/L4D2 at 270.6 fps. In short, OpenGL is faster than DirectX.
As to why OpenGL is faster than DirectX/Direct3D, the simple answer is that OpenGL seems to have a smoother, more efficient pipeline. At 303.4 fps, OpenGL is rendering a frame every 3.29 milliseconds; at 270.6 fps, DirectX is rendering a frame in 3.69 milliseconds. That 0.4 millisecond difference is down to how fast the DirectX pipeline can process and draw 3D data.
Why do we still use Direct3D?
Really, it all comes down to that crummy old thing we call the network effect – and, of course, monopolistic heft and marketing dollars. DirectX, because it has a cleaner API and better documentation, is easier to learn. More developers using DirectX means more DirectX games, which in turn means better driver support. This is a vicious loop that again leads to yet more DX devs, more DX games, and still better DX drivers/tools/documentation. Microsoft has relentlessly marketed DirectX, too – and who can forget the release of Windows Vista and Microsoft’s OpenGL smear campaign? Vista’s bundled version of OpenGL was completely crippled, forcing many devs to switch to DirectX.
Microsoft has good reason to hamper the progress of OpenGL, of course: While DirectX is proprietary and only runs on Windows, Xbox and Windows Phone, OpenGL is completely cross-platform. There are solid OpenGL implementations for Mac, Linux, PlayStation 3, Nintendo Wii, and just about every modern smartphone (OpenGL ES). It’s obviously in Microsoft’s best interests to ensure that the best gaming experiences are exclusive to its platforms.
Valve will be speaking about its Linux/OpenGL advancements at SIGGRAPH 2012 next week. SIGGRAPH is where we usually hear about the latest OpenGL and DirectX news, too – so stay tuned!