Valve Publically Releases "ToGL" Direct3D-to-OpenGL Shim
by Ryan Smith on March 11, 2014 4:00 PM ESTThough firmly rooted in the Microsoft technology camp for much of their history, in the past few years Valve has been expanding their reach to additional platforms and technologies. This started with porting their own games to OpenGL based OSes – first Mac OS X and later Linux – and of course more recently their efforts in rolling their own Linux distro with SteamOS. Throughout all of these processes Valve has been relatively open about what they’re doing and how they’re doing it, and this week they’re getting a bit more open on the API side.
Posted this week to GitHub, Valve has released the source code behind their “ToGL” shim to the public. ToGL is the translation layer Valve uses to bring OpenGL support to their games, essentially emulating a limited subset of the Direct3D 9.0c API and translating those calls to OpenGL. It is implemented within the game binary itself (this isn't an external wrapper), so this is primarily a tool for game developers. And although not particularly common, translation layers such as ToGL and even bigger full-on wrappers are often used to bring big budget multiplatform games to OpenGL platforms, as the PC ports of many games are still primarily coded against Direct3D and native OpenGL renders are sparse.
This release of ToGL comes from Valve’s latest game, DOTA2, with Valve pulling ToGL directly from said game’s source tree. Valve’s release notes, though short, give us a quick idea of just how large of a subset of Direct3D 9.0c ToGL supports. Since it’s not a full Direct3D 9.0c implementation, only part of Shader Model 3 is offered; multiple render targets (which are heavily used these days) are supported, while vertex texture fetch is not. Meanwhile we can see that Valve has been doing shader translation (HLSL-to-GLSL) at a bytecode level, rather than doing the translation at a higher level.
Finally, though Valve’s notes don’t specifically state why they’re releasing ToGL to the public at this time, it’s readily apparent from their releasing it in open source form and their choice of license that they’re looking to spur further Mac OS X and Linux ports of games. By opening up ToGL to other developers and making it free to use via a BSD-style license, developers building games targeting Direct3D 9.0c have an avenue for making the porting of the graphics layer significantly easier.
Though with that in mind, it remains to be seen just how productive it will be to release a Direct3D 9 shim at this point in time. With Windows XP’s retirement next month, all supported versions of Windows will support Direct3D 11 (feature levels not withstanding), so the number of games being written against Direct3D 9 will be low. On the other hand this would still greatly speed the porting of older games, which could help to further build up the list of games available on SteamOS.
Source: Github (via GamingOnLinux)
32 Comments
View All Comments
DanNeely - Tuesday, March 11, 2014 - link
Is DOTA2 still using a DX9 based engine, is valve doing something else to port its DX10/11 code that they haven't released yet, or are the OGL ports lagging in capability due to only having the DX9 fallback version of the graphics engine available?shivoa - Tuesday, March 11, 2014 - link
You can hear Valve talk about their current engine work and OpenGL here: http://youtu.be/45O7WTc6k2Y (no, I don't think I can condense it down into a couple of lines of explanation without taking away from the details as presented)Check the about for link to the slides.
Mondozai - Wednesday, March 12, 2014 - link
Thanks for the link! Awesome contribution.Ryan Smith - Tuesday, March 11, 2014 - link
Yes, DOTA2 is still DX9 based.Vash63 - Thursday, March 13, 2014 - link
Uh... what DX10/11 code? All indications are that they're going straight from DX9.0c to OGL. I believe they said specifically in their Steam Dev Days conferences that they were targeting OGL on all platforms, including Windows.ydeer - Tuesday, March 11, 2014 - link
I briefly installed DOTA2 on my Mac and it appears to be one of the shoddiest ports I’ve seen in quite a while, particularly on HiDPI screens. Running DOTA2 in a Windows 8.1 VM (Fusion) gave me similar if not better framerates as the OS X port.Of course this is more geared towards the Steam OS where they have full control of all layers, but still.
althaz - Tuesday, March 11, 2014 - link
The DOTA 2 port is shockingly inconsistent on Mac and Linux. Valve claim that it has better performance in Linux than in Windows - however whilst performance is often excellent, single-digit framerates (in Steam OS!) on PCs that in Windows give you well over 100fps is all too common.nevertell - Wednesday, March 12, 2014 - link
What are you on about ?I am running Archlinux with Nvidia's binary drivers and I get consistent performance all through out.
And no existing MacOS device could run Dota2 at the native HiDPI resolution without seriously sacrificing image quality at sufficient framerates. And, in the case of Dota2, because the limited field of view is actually a part of the gameplay, it actually would be hard to render everything properly at non-standard resolutions.
althaz - Wednesday, March 12, 2014 - link
Myself and plenty of others on the forums get occasionally horrifying performance in DOTA2 on Linux. As mentioned, I've stopped even trying to play it as 6fps instead of 120fps is NOT acceptable to me.skiboysteve - Tuesday, March 11, 2014 - link
Valve has stated before on the forums that they do not plan to support HiDPI on steam and considering they released a new game without HiDPI support and using DirectX 9 (which is 12 years old!!) they seem to be all about resisting change and legacy technology...