115 points · by Jarlakxen · 12y ago · 42 comments
Right now there's a variety versions of OpenGL out there and they are incompatible in subtle ways. To write "portable" graphics code, you need both compile time and runtime version checks for a variety of features. Some restrictions in mobile versions make sense because of hardware requirements, others are just plain ridiculous.
And the versions of OpenGL that vendors ship is very diverse. For years, Nvidia and AMD have been the only ones to provide (at least almost) the latest version of OpenGL (but only on Windows and Linux, not Mac). Other vendors are lagging behind by several years.
I won't even start listing the obvious problems with the OpenGL API. Everyone who is working with it knows that the API is ridiculous.
I'd like to see an API clean up (ie. rewrite from scratch), a common shader compiler frontend, a common shader binary format and common tooling like benchmarking and profiling tools. Perhaps even a software emulated "gold standard" implementation.
At the moment, writing practical OpenGL applications is miserable. It's quite alright as long as you're working on a small project for your own enjoyment but once you have to start dealing with a variety of driver bugs from different vendors and whatnot, it takes a lot of time to actually ship an application.
This initiative is about one major thing: reducing overhead. It's a response to Mantle/DX12 and their low CPU overhead rendering capabilities. OpenGL risks being left behind performance-wise because drivers are too complex. Because the API hasn't evolved as fast as the capabilities of modern hardware changed, drivers today do too much automatic work "behind the scenes". Things like memory allocation, texture swizzling, parameter validation, and shader recompilation often happen implicitly, outside of the control of the application. This adds unexpected CPU overhead which varies per driver.
Mantle/DX12 change the semantics of the API to match what modern hardware actually does. Applications have more control, drivers do much less implicit automatic work and CPU overhead is greatly reduced. That's what the "Next Generation OpenGL Initiative" is hopefully going to do for OpenGL.
Whose job it would be then?
There is AMD's Mantle and Apple's Metal as well as Google's somewhat related RenderScript. As long as they're going to remain a single vendor API, they will be adapted as an universal new API.
But hopefully the work by these vendors (all of which are Khronos members) will serve as a basis for a future standard API.
Longs peak was a failure and the API was very complicated. It was definitely a failure due to design by commitee.
But in the end, there has to be an industry consortium to standardize on a new API. When we're talking about an API that is closely tied to the hardware it runs on (which is a lot more expensive to develop than APIs and software), there's no other option than to get all the big players around the same table. Right now, Khronos is the most likely candidate since all the key players are members in that group.
At some point there has to be a new API. OpenGL isn't just an API with some warts in it, it's getting more and more in the way of new development.
It's competition, but for a much much smaller piece of open gl's pie.
OpenGL code will run on billions of mobile devices, but metal will only run on iOS which is an ever-shrinking share of total smartphone sales each year.
Anyone who picks metal over opengl is picking iOS only--period. Any crossplatform game that doesn't want to write the entire game multiple times (once for apple, once for crossplatform, or heck onece for every platform) will simply not pick metal or any OS-dependent API.
The lack of up-to-date OpenGL versions on MacOS-X is not the fault of NVidia, AMD or any other GPU vendor. It's entirely Apple's fault. Apple insists on developing the MacOS-X OpenGL drivers themselves. And because OpenGL has been rooted so deep in the MacOS-X graphics stack it's virtually impossible to update without upgrading the rest of the operating system as well. Well done Apple, well done…
All of my complaints with OpenGL are related to, as jarrett mentioned, the lack of debugging tools and the fiddly cross-platform and cross-version issues.
If you look back (or remember) graphics APIs from the 1980s and 1990s (e.g. the BGL library that shipped with Borland compilers), this was a common idiom.
Rather than saying
drawLine(100, 100, 200, 250, RED);
drawLine(200, 250, 300, 300, RED);
You did setColor(RED);
movePen(100, 100);
lineTo(200, 250);
lineTo(300, 300);
The idea behind this was to minimize the number of parameters passed to function calls, because they had to be pushed to the stack and then read back. This was a major source of performance overhead back then.So basically OpenGL is modelled after a performance optimization that was relevant some 30 years ago. These days it's actually hurting performance and adding unnecessary complexity. Premature optimization of the worst kind.
You could do a little comparison on how Direct3D 10.1 and newer work. The API is simpler, lot less stateful and you get a better idea what will actually happen. If I had a choice, I would use D3D, but it doesn't run on the platforms I care about.
- Using Vertex Array Objects should be fast since it's only a single call to change the vertex data binding. But in many GL implementations they are slower then using the old way calling VertexAttribPointer and EnableVertexAttribArray
- What's the fastest way to update dynamic vertex data? Buffer orphaning? Doing double buffering yourself? BufferData or BufferSubData? It's likely that the answer is different dependent on driver or GPU
Resource binding can introduce subtle errors by screwing up the GL state (for instance to create and initialize a resource you need to 'make it current', should the creation function restore the previous binding, or keep the GL state 'dirty'?)
Some call parameters are overloaded with completely different meaning depending on GL state. For instance the 'const void* pointer' argument in VertexAttribPointer is actually an integer offset and not a pointer if an array buffer is bound.
The most important problem which the OpenGL NG initiative tries to solve is validation overhead. In current OpenGL, an app can change every state at every time in the frame, and after each change (or rather before each draw call) the entire GL state must be validated. Most games (or 3D apps in general) only create a relatively small set of 'pre-compiled' state at startup and then just switch between these state presets. With this pattern, all expensive validation can happen once at startup, and not during the render loop.
Examples illustrating what I am saying:
http://stackoverflow.com/q/6530700
Are you talking about legacy OpenGL style glBegin/glVertex/glEnd? That hasn't been the preferred way of drawing ever, and since OpenGL 1.5 (circa 1999), vertex buffers are the way to go.
If you want to share vertices between triangles, you should build and index buffer and use glDrawElements* functions.
That's the same on all 3D APIs though. I think the only exception was the Wii where you could have positions, texcoords, normals, etc... in different arrays of different sizes and index them with multiple indices per vertex. I can't image that this was efficient though...
And might I add: A debugger! For both shaders and the entire GL state. Yes, 3rd party tools exist. But more often than not, I find they won't even compile or execute on a given platform.
Even just having the common binary format there would be a huge step forward. It'd let the community take care of the rest if khronos doesn't bother with it. The software emulated standard implementation would be really nice. things like mesa's piglit would be great for using it as a test suite.
I used to be a big OpenGL fan, back in the GL 2.x / DX 8 days.
However the way OpenGL grew up is just insane, specially for the poor beginners that didn't grew up with the API.
Not to mention the basic stuff (texture loading, fonts, math, shader usage) that the API leaves out, whereas other 3D APIs offer some kind of support.
Plus the consoles never had proper support anyway.
To the point that nowadays I advise anyone just to use a rendering engine.
Leave programming OpenGL directly to learn how to build an engine.
http://www.art.net/~hopkins/Don/unix-haters/x-windows/disast...
Mantle caused MS to rapidly announce DX12. So it's the exact same direction where everyone else is going.
While DX is more pleasurable to use than OpenGL (I personally am purely OpenGL dev, yet I acknowledge it's weaknesses) it has similar limitations. Very limited threading model and massive CPU overhead in drawcalls.
The future of graphics api's is going to be mantle style command buffer generation from multiple threads and then sending those buffers to the GPU.