Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Open Source Games

Valve Open Sources Their DirectX To OpenGL Layer 130

jones_supa writes "A bit surprisingly, Valve Software has uploaded their Direct3D to OpenGL translation layer onto GitHub as open source. It is provided as-is and with no support, under the MIT license allowing you to do pretty much anything with it. Taken directly from the DOTA2 source tree, the translation layer supports limited subset of D3D 9.0c, bytecode-level HLSL to GLSL translator, and some SM3 support. It will require some tinkering to get it to compile, and there is some hardcoded Source-specific stuff included. The project might bring some value to developers who are planning to port their product from Windows to Linux."
This discussion has been archived. No new comments can be posted.

Valve Open Sources Their DirectX To OpenGL Layer

Comments Filter:
  • Winelib (Score:5, Interesting)

    by Wootery ( 1087023 ) on Tuesday March 11, 2014 @07:50AM (#46453723)

    Could this be of use to the Winelib [winehq.org] project?

    (As the name implies, it's the compile-time analogue of Wine.)

    • Re:Winelib (Score:4, Interesting)

      by Anonymous Coward on Tuesday March 11, 2014 @07:55AM (#46453743)

      Possibly, I havn't looked at the source yet. But the readme says its a subset of the DirectX 9.0c features, making it not only obsolete, but incomplete. Fortunately, its open source so a bit of wrangling could make it swallow dx10 and 11

    • Re: (Score:3, Insightful)

      by Anonymous Coward

      Could this be of use to the Winelib [winehq.org] project?

      (As the name implies, it's the compile-time analogue of Wine.)

      Probably not. The wine guys tend to be more or less anti toward anything that they didn't write and thus can assert that it's not infringement on Microsoft's source code. Accepting that much code from Valve sounds very risky for them.

      • Re:Winelib (Score:5, Insightful)

        by JDG1980 ( 2438906 ) on Tuesday March 11, 2014 @09:20AM (#46454337)

        Probably not. The wine guys tend to be more or less anti toward anything that they didn't write and thus can assert that it's not infringement on Microsoft's source code. Accepting that much code from Valve sounds very risky for them.

        Valve isn't some fly-by-night operation. They almost certainly have more exposure to legal liability than the Wine project would.

        • by bcmm ( 768152 )
          This is beside the point, unless Valves wants to indemnify users of the code they released (hint: they won't).
      • Re:Winelib (Score:5, Informative)

        by Richard_at_work ( 517087 ) on Tuesday March 11, 2014 @09:40AM (#46454469)

        Odd considering their (Wines) last copyright cockup was entirely due to an internal contributor committing decompiles of Microsoft binaries as contributed code...

        • by Anonymous Coward

          Could you point to some links stating such a cockup happened?

        • Odd considering their (Wines) last copyright cockup was entirely due to an internal contributor committing decompiles of Microsoft binaries as contributed code...

          The word you are looking for is the opposite of odd.

          Unsurprising.

          • I chose my words as I intended it to be taken - the post I was replying to intimated that the Wine people only trust code that originated internally, rather than from an external source such as Valve, because then they can guarantee its heritage. Which is ironic considering the source of the last issue was internal, and thus wouldn't have been prevented by their current stance.

    • by Kuberz ( 3568651 )
      Could this be the year of Linux Desktop?
    • Doesn't winelib already include DirectX to OpenGL translation? Isn't that half the point of Wine?
      • Indeed. I was wondering if there'd be anything to gain from another project with a similar goal.

  • by Anonymous Coward on Tuesday March 11, 2014 @07:58AM (#46453757)

    With a big company (in terms of money) like Valve pushing OpenGL there is a real chance DirectX will face serious and permanent competition. We will finally have a serious alternative to the suffocating model of forcing a new operating system down peoples throat through software. It worked great with the browser, now lets hope Valve can make it happen for games.

    • by CastrTroy ( 595695 ) on Tuesday March 11, 2014 @08:20AM (#46453899)
      I think that only worked so well for the browser because MS let IE stagnate for so long. I don't think they are doing the same with DirectX. DirectX continues to evolve and stay up to date. It's one thing to convince the non-programmer, general computer user to keep using mediocre tools, it's a whole other story to try and get developers to do the same.
      • Re: (Score:3, Insightful)

        by Anonymous Coward

        In light of the fact that OpenGL's more portable to more platforms, it's not as hard a sell as you'd think. Esp. for more casual games. Want to target iOS and Android? You'll be doing OpenGL ES 2.x. The same game will target PS3, PS4, OSX, Linux, and Steam/SteamBox with only a few modifications.

        • by DrXym ( 126579 ) on Tuesday March 11, 2014 @10:47AM (#46454949)
          OpenGL is definitely more portable than DirectX but that's not to say it's portable with a few modifications. There are various OpenGL and OpenGL ES profiles, and while they are related they can be radically different in important ways. For example OpenGL ES 1.1 and 2.0 are totally incompatible despite what you might think - 1.1. uses a fixed function pipeline and 2.0 expects you to write shaders for basically everything. OpenGL ES 2.x is roughly but not completely a subset of OpenGL 2.1. Every version of OpenGL supports a different selection of extensions.

          Aside from the differences on paper, the actual implementations can be broken, buggy or inefficient. e.g. Some older desktop drivers might not offer an ES 2.x profile, or it could be hopelessly crap.

          There is no GLU / GLUT either for ES 2.x and every platform implements its own equivalent but proprietary set of APIs. So you may discover a lot of work is required to fix that. Then you may discover that one platform or language's bindings are different from another in subtle but annoying ways, e.g. there are several OpenGL ES 2.x bindings for Java and one might return a handle in an int[] array while another expects you to supply a 1-element sized IntBuffer. Annoyances which add up.

          In summary, yes you can port code, and OpenGL is definitely one family of APIs that offers support across a wide selection of devices. But it's not guaranteed to be simple and probably won't be. The best bet is use a good third party library (e.g. libgdx) and let the library hide as much of the work as possible.

        • by metzjtm ( 801672 )
          You put the same PS3 game on a PC and it would play like it was on a PS3. I think that would be a hard sale. Look how well Battlefield 3 & 4 have done on the PC. You would really have to down grade their hit boxes and graphics to step down to a PS3 or any game only platform.
      • by Vlado ( 817879 )

        What happened to the news/rumor that there will not be another DirectX version?

        http://tech.slashdot.org/story... [slashdot.org]

      • by Lisias ( 447563 )

        It's one thing to convince the non-programmer, general computer user to keep using mediocre tools, it's a whole other story to try and get developers to do the same.

        You, obviously, don't have to earn your living using Visual Studio.

        Man, I give up accounting all the wasted hours that thing inflicts me with stupid, annoying and everlasting bugsw "features". The last update to VS2010 was a pain in the ass to install.

        • Actually, I do. And at work we're still using VS 2008. And I still like it better than anything I've seen from the open source community. Trying to do Android development in Eclipse is a pain compared to doing stuff in Visual Studio. Despite it's problems (and it does have them), I don't think there's an IDE out there that compares to Visual Studio. I haven't tried developing for iOS though, as I don't want to go out and buy a Mac just to try something out for the fun of it.
          • by Lisias ( 447563 )

            Eclipse is very good. The Android plugin is a piece of sh*t.

            I did some C++ development on Eclipse, and I found it nice. Doing JavaSE, of course, is very good also (but some functionalities for JavaEE needs some serious work). But a lot of the best Eclipse funcionalities are trimmed to Java development, I never had to do refactoring on C++ code using it.

            I did a lot of jobs using Visual Studio 6.0 a long time ago, that was very limited - but once you fill the gaps with the proper plugins, the fact is that tha

            • by Lisias ( 447563 )

              Where I wrote

              you never know what that damned thing will decide to merge with your other projects

              Please read

              you never know what that damned thing will decide to merge with your other projects' configurations

              instead.

              • The last prick it played

                I see you did not feel the need to correct this line :)

                • by Lisias ( 447563 )

                  The last prick it played

                  I see you did not feel the need to correct this line :)

                  Yep. It had hurt our feelings deeply. One colleague of mine took 2 days to be back on his seat at work. =D

                  (damn, I was certain I had type 'prank'... I don't know if this Freudian slip is mine or automatic corrector's ... =P)

          • by Lisias ( 447563 )

            XCode is not bad, but is not good neither.

            If all you ever used in your life was XCode, you will probably be happy with it as it does the job.

            But I found the thing.. weird... to use. I ended up doing C/C++ development on Eclipse on the MacOS - but I don't do COCOA apps (neither iOS).

    • Re: (Score:2, Insightful)

      by Anonymous Coward

      Since OpenGL is the only language to run on mobile, and Mac, and Linux plus it's available on all the consoles it seems kind of crazy to target anything else if your code is expected to survive for any length of time given the decline of the Windows PC market.

    • by LoRdTAW ( 99712 ) on Tuesday March 11, 2014 @09:42AM (#46454475)

      OpenGL is pretty much used everywhere but Microsoft targeted games (Windows and Xbox). Using DirectX on Windows games allowed them to be portable between PC and the Xbox so more and more games went the D3D route to remain portable between the two.

      I believe almost all CAD and 3D modelling software are OpenGL based. Android and iOS use OpenGL ES while any non Windows OS such as Linux and OSX use OpenGL for 3D graphics. With the big push to mobile and Microsoft left in the dust, OpenGL is the dominant player.

      • I believe almost all CAD and 3D modelling software are OpenGL based.

        Most support a Direct3D rendering path on Windows (just like we used to do in the 90s when we had to support Direct3D, OpenGL, Glide, S3D, etc...). Nobody ties their application directly to one graphics API.

      • I believe almost all CAD and 3D modelling software are OpenGL based.

        Probably true. I work on software with a CAD focus and we use Direct3D only because of misinformation. The product was converted from a custom language with C (and OpenGL) to .NET, and the designers at the time were given the impression by Microsoft that OpenGL would shortly be deprecated under .NET.

        Ironically, Microsoft actually deprecated Managed DirectX so we rewrote in managed C++.

    • With a big company (in terms of money) like Valve pushing OpenGL there is a real chance DirectX will face serious and permanent competition.

      Direct3D has almost always faced serious competition from OpenGL, however completely replacing Direct3D with OpenGL and only having one player in that space would be a terrible mistake, the market would stagnate. OpenGL is a follower of Direct3D innovation, and I say this as an OpenGL developer and a staunch advocate of OpenGL. In the last few years the innovation in graphics programming has come from Direct3D with geometry shaders in DX10 (implemented in OpenGL shortly after) and the programmable tessellat

  • Will there be a performance hit ?
    • by Xest ( 935314 )

      There's bound to be some hit, but the hit will be so utterly negligible that it's not enough to care. You shouldn't let it be a concern because it's too small to matter.

      • Re:performance? (Score:5, Informative)

        by Creepy ( 93888 ) on Tuesday March 11, 2014 @08:24AM (#46453937) Journal

        Yeah, probably minimal, since it is bytecode level (what HLSL and GLSL compile into)

        The bad - this is DX 9.0c, which is analogous to OpenGL 2.0 (with extensions - note that ATI drivers didn't support extensions at the time, so more like 2.2+ for them) and in console terms, XBox 360/PS3 tech. OTOH, OpenGL went through a major paradigm shift with OpenGL 3 and 4 that make it work more like HLSL, so I expect shader conversion is much easier. When I ported a DX10 shader to OpenGL 3 it was much easier (but much harder was porting the entire OpenGL 2 project to 3).

    • Re: (Score:2, Informative)

      by Anonymous Coward

      Valves presentation on the topic http://adrienb.fr/blog/wp-content/uploads/2013/04/PortingSourceToLinux.pdf states better performance using togl for their games (togl starts at slide 18, performance is mentioned on 23).

  • Valve makes money with Steam.

    Valve has hammered out a useful content delivery platform for Linux and OS X.

    Valve makes it easier to translate DX to OGL.

    Collect profit... eventually.

    • Still want to know why their 'useful' content delivery platform won't run on my case-sensitive OSX partition ... but Linux users don't seem to have that problem.

      And no, I don't give a shit that I can make a case sensitive partition and play symlink hell games to get it to work. Its fucking ridiculous that it doesn't support case sensitive filesystems. /End Rant>

      • by Threni ( 635302 )

        Why? Because it affects 1 user who can work around it trivially; I imagine there are other priorities, given that there are limited resources and work has to be prioritized accordingly.

  • Lessons learned (Score:5, Informative)

    by jones_supa ( 887896 ) on Tuesday March 11, 2014 @08:18AM (#46453883)
    If you are interested in this stuff, the Porting Source to Linux: Valve's Lessons Learned [youtube.com] is also good watch, if you haven't seen it yet.
  • by tlambert ( 566799 ) on Tuesday March 11, 2014 @10:27AM (#46454823)

    Going the other way like Microsoft does is more interesting.

    One of the biggest issues with OpenGL is that you can get shaders that won't run in bounded time. You can see this with a number of games in Flash, or natively in OpenGL, when run on a Mac. If the shader doesn't exit, it eats a channel, and there are a limited number of channels, and once they are gone, the renderer, which is also used for the desktop, basically crashes. There are nice system log messages from the video driver about it, but besically everything ends up restarted, which is pretty useless.

    FWIW: this accounts for the majority of system instabilities in the card specific portions of both Mac OS X and Linux render pipelines.

    DirectX doesn't allow things to run in unbounded time in its OpenGL to DirectX translator; instead, it loop unrolls shaders, and if it can't do that such that they run linearly, and therefore in bounded time, it omits them from the render. So you might not get distance blurring, haze effects, fog effects, rain effect, and so on, but at least the thing doesn't crash, and if the person porting the code to the Windows platform cares about these things, they fix the code so that it'll run using DirectX. Usually, this reduced the perceived "quality" of the final render, but you get at least a crude version of your effect back.

    The other thing DirectX does is, in the video driver, keep a reserve channel for sending commands to the video hardware; the common reason for this is in-band signaling to comply with the DirectX 9 requirement that the video hardware be capable of being reset, without rebooting the system, such that a video card hang doesn't necessitate a reboot.

    While a DirectX to OpenGL translation layer is a nifty idea (I lobbied very hard for a FreeBSD emulator for Linux, rather than a Linux emulator for FreeBSD so that developers would target FreeBSD rather than Linux as their development platform), I don't think that as long as the OpenGL shader looping issues don't also get addressed at the translation layer that translating from DirectX to OpenGL will be in anyway superior to translating from OpenGL to DirectX.

    So basically, it's nice they released this, but the code is of little practical use in the real world, since there are features that will get lost in translation.

    • by Megane ( 129182 )
      Very interesting. I think that explains why Minecraft can hose OS X so thoroughly. The current version of Minecraft can reliably crash the graphics on OS X 10.6 when you simply try to change the window size. (The official "workaround, won't fix" is to upgrade to OS X 10.9!)
    • Strange, I use and code plenty of games using shaders like that, and I run KDE4 in Linux, in both GL composite and regular X11 mode, and have never experienced any crash like you describe. Is it because I use Nvidia drivers or something, or maybe because I happened to have had the luck to only play games that do it right, and had the luck to never code any shaders triggering that? Seems rather unlikely, but I am genuinely curious here.

      • Strange, I use and code plenty of games using shaders like that, and I run KDE4 in Linux, in both GL composite and regular X11 mode, and have never experienced any crash like you describe. Is it because I use Nvidia drivers or something, or maybe because I happened to have had the luck to only play games that do it right, and had the luck to never code any shaders triggering that? Seems rather unlikely, but I am genuinely curious here.

        The closed source drivers have some, but not all, workarounds for the issue. They're basically ports of the Windows drivers, and have the reserve channel because of this. You may in fact be lucky, but I'd have to have a huge amount of information in order to tell you for sure (e.g. are you running a compositing window manager, what card are you using (tells me total channels), potentially instrument the GL pipeline connections to see how many of the available ones are in use, etc.. The crashes normally h

  • At the very least this will make it possible for some excellent RAD tools to make their way to Linux much faster. Among them Gamemaker, Stencyl, Unity and Construct.

    Then there will be the inevitable FOSS equivalents, which will spinoff their own series of games, making development faster and less buggy on both PCs and mobile devices. The Linux to Android migrations in particular are going to be really exciting.

    The next chapter is going to be amazing for Linux.

    • I doubt it, ATi did this already nearly a decade ago just a couple of years after the release of DirectX 9.0c and open sourced it under the name HLSL2GLSL which was forked a few years ago to add support for OpenGL ES (mainly for porting from DirectX platforms to Android) and is already used in Unity and OGRE. Conversion of the programmable pipeline from DirectX to OpenGL has been done for many years already.
  • DirectX10 / 11 is still better than OpenGL
  • Taken directly from the DOTA2 source tree, the translation layer supports limited subset of D3D 9.0c, bytecode-level HLSL to GLSL translator, and some SM3 support. It will require some tinkering to get it to compile, and there is some hardcoded Source-specific stuff included.

    Valve declared back in 2012 that OpenGL is indeed faster than DX11 even on windows - http://www.extremetech.com/gam... [extremetech.com] "The Valve Linux Team breaks it down on their shiny new blog: With an Nvidia GTX 680, Intel i7-3930k, and 32GB

  • Why is this surprising? They need a lot more games for SteamOS.

No spitting on the Bus! Thank you, The Mgt.

Working...