Coffeehouse Thread

20 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

A 3D library that supports BOTH OpenGL and DirectX

Back to Forum: Coffeehouse
  • User profile image
    IDWMaster

    So. The competition between OpenGL and DirectX has been going on for quite a while. I've been working on a cross-platform solution to the question "which one is faster?". My solution was to write an abstraction layer in C# and publish it on SourceForge. Now; this is still not entirely finished (it's in pre-alpha stage), but I thought it would be interesting to run the same application in both OpenGL and DirectX and compare the performance difference. I noticed that when drawing a mesh and performing a simple rotation on my NVidia GTS 450; DirectX used 89% GPU time while rendering and OpenGL used 32% (average). However; one test case is not enough to decide which platform is faster/better, or whatever. Performance varies widely by GPU, so I figured it would make more sense to use both, and then choose one or the other based on the specific computer's performance characteristics. Here's the link to the SourceForge project (SVN), and here's the link to the project homepage. Note that this sample does not YET work on all Intel chips (specifically the ones found in Samsung netbooks).

  • User profile image
    aL_

    i think that will be very challenging, opengl and directx uses diffrent style vectors for example (row vs column) so all the algorithms will be a little diffrent. that wouldnt really cause a significant perf diffrent though, just change the order things are multiplied together.

    In practice though i dont think there will be a huge perf difference, allthough the figures you have are significant. however it might be good to have high gpu utilization if its offset by low cpu utilization. i think its more a question of optimizing for either framework rather than inheirent "speed of the framework"

    if you're writing a cross platform solution though, the awnser seems clear, go with OpenGL Smiley

  • User profile image
    Proton2

    What about C++ AMP? Doesn't that use DirectX ?

  • User profile image
    aL_

    It does, but it takes care of the generation of shader code (hlsl in that case) as well so they can to optimizations for their framework. what i mean is that it will be hard to have a single library that support both opengl and directx, atleast in a single code path.

  • User profile image
    IDWMaster

    And it now supports Windows Phone Mango/7.1/7.5 or whatever they call it now too through XNA.

  • User profile image
    W3bbo

    ,aL_ wrote

    if you're writing a cross platform solution though, the awnser seems clear, go with OpenGL

    Yep.

    You know, I haven't seen games that support both OpenGL and Direct3D in a while, it's as if the developers have to choose a graphics platform from the start.

    I think maybe writing a game to be API agnostic was easier when all 3D graphics were essentially the same: textured polygons and not much else (think: right up to 2002). They've died a death the same way as software rasterizers.

  • User profile image
    IDWMaster

    @W3bbo:Well; the basic goal seems to still be the same. We're still sending vertex buffers to the GPU with textures, and mapping them onto 3D surfaces. Only now we have geometry shaders, tesselation, lighting, etc. Just some added bonuses. Both platforms are still capable of doing all these things; so why not write a cross-platform library for it?

  • User profile image
    Minh

    @W3bbo, You haven't seen the same game released for Xbox & PS3 in a while?

  • User profile image
    aL_

    @IDWMaster:

    Yes, the high level functions are the same, but the implementation details are diffrent. Also the api:s are slightly diffrent so the level of abstraction would have to be pretty high, probably even higher than xna, since even in xna you can write shaders and OpenGL and DirectX have (similar but)diffrent shader languages.

    @Minh:

    Those games use diffrent versions of their engines for the diffrent platforms, they are not simply switching a compiler switch. usually there are completley separate teams working on the engine optimizations for the diffrent consoles. On a high level the surface of the engine is probably the same, but under the covers there will be alot of small diffrences in how the over all algorithms are implemented

  • User profile image
    Minh

    @aL_, true that they are discrete engines sitting on top of the PS3 & Xbox, but at some point they have a common source, ie, the levels. If the levels aren't 100% identical on the different versions, they must be very close... but abstracting a graphics layer isn't that hard, is it? After all, you can abstract away any problem (except the obvious Smiley )

  • User profile image
    W3bbo

    ,Minh wrote

    @aL_, true that they are discrete engines sitting on top of the PS3 & Xbox, but at some point they have a common source, ie, the levels. If the levels aren't 100% identical on the different versions, they must be very close... but abstracting a graphics layer isn't that hard, is it? After all, you can abstract away any problem (except the obviousSmiley )

    There are costs to abstraction: economic (extra man-power needed to write, maintain, and document the thing) and computational (abstraction isn't just about the Decorator design pattern).

    This isn't helped by the fact the PS3 doesn't use OpenGL, but its own 3D graphics API (whereas Direct3D developers have the benefit of DirectX on the Xbox). If you work hard enough, sure; but for mass-market cross-platform games you'll see games using a pre-made cross-platform engine or some other middleware layer, which places constraints on what you can do with a game (so it's fine for your standard racing, platformer or FPS games).

  • User profile image
    Minh

    I don't think the abstractions are so hard that devs have to pick a graphics layer over another. Evidence: the abundance of graphics engines that work on both OGL & DX

  • User profile image
    aL_

    @Minh:

    thats true Smiley yes, most (all?) of the actual game assets will probably be the same. I think the changes will start to come out around the render loop level of abstraction where the assets  are loaded by the engine, at that point they can change up the coordinate space of the models and stuff like that.

    i just think you have to put the abstraction pretty high (engine level) in order to completly abstract away the diffrences.

  • User profile image
    Proton2

    Wouldn't Ray Tracing be the best solution for the future, when heterogenious computers become ubiquitous?

  • User profile image
    Minh

    @aL_, I would think that the abstraction needs to be only as high as it has to be. At least if you're building it right. If you only need to reverse your triangle, why abstract beyond that? I'm sure that the separate engines for PS3/Xbox have a lot of common code, but since they have to abstract so many things, CPU, input, video, etc... that it might not make sense to have a common code-base... and perhaps they are sharing at the file level, instead of the .DLL level

  • User profile image
    Minh

    @W3bbo, there are costs to going cross-platform (implement abstractions) but there's a simple reason why people still do it... the payoff.

    From what I can gather, Sony used a modified version of OpenGL... and if you really know Direct3D, it's just a very thin layer to do 3D and animations. It's not like D3D provides that much more than OGL..

  • User profile image
    Minh

    @Proton2, Intel had just abandoned their raytrace initiative, so I'm wondering if our 100-cores future is going to take a bit longer to get here

  • User profile image
    magicalclick

    @Proton2:

    raytracing is still way too computationally expensive than raster. It is like movie with real sized props vs movies with smoke, mirrors, and fake tiny models. This also means, raster is always ahead of raytracing because faking it out is simply cheaper by nature. China even have fake milk, fake egg, fake rice as a terrible example.

    If you are thinking the technology might turn around, not for at least 20 years. You might be able to see real time raytraced games, but, it will look like crap comparing to other raster based games. Just a subsurface scattering is extremely expensive and difficult to implement, and we already can fake it out in this gen games. That's how much a gap it really is. I even think 50 years is still not going to turn around, but, I used 20 years as safer bet.

    Leaving WM on 5/2018 if no apps, no dedicated billboards where I drive, no Store name.
    Last modified

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.