Though 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)



View All Comments

  • edzieba - Tuesday, March 11, 2014 - link

    "they seem to be all about resisting change and legacy technology"
    Apart from all that, you know, VR research and the like.
  • skiboysteve - Tuesday, March 11, 2014 - link

    Good point. Maybe I should say their PC technology is stuck in 2000s, and they seem to like it that way. They are definitely looking outside of PC technology though Reply
  • inighthawki - Tuesday, March 11, 2014 - link

    Surprise, it's what I've been telling people for months. This is a port of DX9, meaning their old "OpenGL is faster than DX" statement is at best wildly inaccurate. They use a 10 year old API for their comparison which has more overhead than DX11. Congrats to Valve on providing misleading perf statistics.

    Now Valve, how about comparing a native OpenGL port to DX11 so we can actually see the difference? It's not hard to rewrite an API on top of modern techniques and hardware to be faster than some old legacy pipeline.
  • blzd - Tuesday, March 11, 2014 - link

    Last I checked 99% of games still ran DirectX 9. DX11 support usually consists of 1 or 2 extra options, some type of bonus depth of field and tessellation. Reply
  • Friendly0Fire - Tuesday, March 11, 2014 - link

    It's changing very rapidly now that the new consoles are around. Prior to that, every multiplatform game basically required DirectX 9 anyway, since that's what the Xbox 360 supported (it's not exactly DX9, but close enough).

    Already, the new versions of CryEngine and Unreal are DX11 and DX9 versions are at best legacy, at worst entirely unavailable.
  • npz - Wednesday, March 12, 2014 - link

    By "new consoles" you mean only XBox One. The PS4 uses FreeBSD and its own API, which supports the feature set found in DirectX 11.2 and OpenGL 4.4, but it does not actually use DX11. Reply
  • nevertell - Wednesday, March 12, 2014 - link

    PS4 uses Mono (open source implementation of C#) and OpenGL. Usually, if you want to get the most out of the hardware, engine devs write a different rendering backend for each console anyway, because even if PS4 used D3D or Xbone used OpenGL, just changing the compile target would be inefficient. OpenGL makes most sense in this day and age on the PC, because it is platform independent. Reply
  • Th-z - Wednesday, March 12, 2014 - link

    In terms of graphic APIs, PS4 uses GNMX (high level) and GNM (low level). GNMX is probably much like OpenGL and DirectX for familiarity and ease of development. For GNM I will take a wild guess that it's like Mantle. Reply
  • clementl - Thursday, March 13, 2014 - link

    While it is possible to make use of mono on the PS4, the default SDK works with Clang/LLVM. Reply
  • nevertell - Thursday, March 13, 2014 - link

    Clang is not LLVM, they use a Mono "interpretor" with LLVM. Reply

Log in

Don't have an account? Sign up now