Thursday, March 13th 2014
Valve Runs a Direct3D to OpenGL Translation Layer
Digging through the source code tree of Dota 2, developers discovered Valve's latest creation, ToGL. Simply put, it's a Direct3D to OpenGL translation layer, which works to reduce duplication of effort in developing games for multiple platforms (such as Windows, Linux, and OS X). The software can translate Direct3D calls to their OpenGL analogues. So far, it can translate only certain kinds of calls within the Direct3D 9.0c API, which should fit Valve's needs adequately. It features a bytecode-level HLSL to GLSL shader language translator. It features only a limited shader model 3.0 support. ToGL is currently being provided by Valve as-is on GitHub, and is unsupported. Developers are free to incorporate it into their projects, and make modifications to it.
Source:
GitHub
22 Comments on Valve Runs a Direct3D to OpenGL Translation Layer
This is a polite warning to everyone, move along, nothing to see here!
The real question we have to ask (before we start bashing it,) is what kind of performance will we see out of this compatibility layer. Until our questions are answered we shouldn't judge it. Additionally, it's a lot more than double work to port a game from one API to another. Consider for a moment how many bugs and incompatibilities you come across between the two APIs then remember that they need to thoroughly test it once they even get it working.
This makes sense for games that were coded for DX and only DX to run in OpenGL. I don't see the problem with that. It's giving you an option where you wouldn't otherwise have one.
Don't like it? Make your own damn 3d engine. :p
This means that there is no overhead for redirected calls at runtime, but you need the source of a game to make use of it.
I'd still expect a slight performance hit compared to native OGl though. Some API-calls are normally avoided/used less in OGl due to bad performance and others from DX which are normally eluded with some effort would perform well when their OGl counterpart is used.