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

  • clementl - Thursday, March 20, 2014 - link

    No, Clang is the de-facto C++ front-end for LLVM. And yes, this is the official compiler for the PS4 SDK.

    Also, you can't interpret mono. Mono is an open-source implementation of the C# programming language. You can make a C# compiler for LLVM (yes, a compiler, as of now LLVM has no interpreting functionality), but you can't use Mono and LLVM at the same time.
  • inighthawki - Wednesday, March 12, 2014 - link

    Another person clueless about this stuff. DX11 isn't just a couple features, it's a new API. DX11 rewrote the entire API to be more efficient, and has a feature know as hardware downleveling. The DX11 runs 100% fine on DX9 and above hardware, and provides much better CPU performance than the same game or application written in DX9. Reply
  • Despoiler - Wednesday, March 12, 2014 - link

    It's funny that you call people clueless. DX11 is a superset of DX10. DX10 was the rewrite of the API. DX9 is its own API. DX9 hardware cannot not run DX10/11 games. If it could there would be such a thing as forward compatibility in GPUs. Reply
  • inighthawki - Wednesday, March 12, 2014 - link

    Yes, DX10 was the rewrite, but nobody uses it so I simplified the argument to not bother with it.

    But you are incorrect. DX9 hardware DOES run DX9 games. DX 10.1 introduced feature levels (hardware downleveling) allowing 9_1 (DX 9.0a, shader model 2.0) hardware to target the 10.1+ API. A game can be written in 100% DX11 code and still run on DX9 hardware while taking advantage of API and performance improvements. DX11 has less overhead in a number of calls over DX9, so there is a huge advantage to using the DX11 API over the 9 API.

    You should probably learn about the thing you're referring to before trying to make a counter argument:
  • inighthawki - Wednesday, March 12, 2014 - link

    Sorry, that should read: "But you are incorrect. DX9 hardware DOES run DX11 games." Reply
  • Despoiler - Wednesday, March 12, 2014 - link

    That's not what you said. You said "DX11 runs 100% fine on DX9 and above hardware." That's if the programmers support the feature level 9_1 thru 9_3. So no it's not 100% and you are not running DX11 because that would imply DX11 functionality because you didn't specify the feature level. Reading comprehension is not your friend today. Also, if game devs support DX9, which means they support XP, which Microsoft doesn't even support, they just use their DX9 renderer. I'd love to hear examples of DX11 games that implemented DX9 feature levels. They could be out there, I'm just not aware of them. Reply
  • inighthawki - Wednesday, March 12, 2014 - link

    I think you're the one with reading comprehension problems.

    "DX11 runs 100% fine on DX9 and above hardware."
    Yes. This IS 100% true. For the 3rd time now, DX11 is an API. It is a software interface, and one that explicitly supports DX9 hardware. Therefore, DX9 cards are compatible with DX11. You are confusing the concept of the API itself and what the app developer decides to target.

    To put it in more simple terms:
    --DX9 hardware is 100% compatible with DX11.
    --DX9 hardware MAY NOT be compatible with a game written in DX11.
    See the difference?

    Also, this wasn't even my original point, you are just bringing up random things now. My point was that it is an unfair comparison to compare DX9 with an up to date version of OpenGL. Microsoft doesn't go around comparing DX11.2 to OpenGL 2.0. Would that really be shocking that a modern graphics API was faster than a legacy pipeline that drivers haven't even optimized for in a decade?

    When Valve rewrites "ToGL" on the DX11 API, then ports all their games to DX11 with the same aggressiveness in optimizations, then they will have fair numbers. Until then, their "OpenGL is faster than DirectX" claim is completely flawed and baseless.
  • RubberJohnny - Tuesday, March 18, 2014 - link

    You're an idiot!

    "--DX9 hardware is 100% compatible with DX11.
    --DX9 hardware MAY NOT be compatible with a game written in DX11.
    See the difference?"

    Well its not 100% then is it! it's a subset!
  • inighthawki - Saturday, March 22, 2014 - link

    Where exactly is the problem here? Game != API. Reply
  • Latzara - Wednesday, March 12, 2014 - link

    You are looking at the wrong product if you want DX11 no matter what the year is -- the main aspect fo Dota 2 is the community which means that it must run on what now is almost 'ancient' hardware for people who (still!) play the original DotA to be able to transition to the new without significant hardware bumps. The graphics in a game like DotA are secondary at best, it's all about gameplay mechanics and running it on as many systems as possible for the largest (and growing) player base -- and it's working... That's why DX11 is not even necessary, but making better ports to API's used in the OSes other than Windows (and not the latest ones - the same 'rule' as with DX9 applies) should be done better -- there's no excuse for that. Reply

Log in

Don't have an account? Sign up now