Wednesday, January 13, 2010

Even more on Vertex Buffers

I'm taking some time out to explain this as I came across some more "OpenGL vs D3D" posts while researching my occlusion queries woe.

DirectQ 1.8.0 beta will feature extensive use of vertex buffers (VBOs). OpenGL also features VBOs, but there are some subtle differences.

With OpenGL, you have 3 choices regarding VBOs:

  • Use VBOs and exclude everyone who's 3D card does not support them.
  • Don't use VBOs and lose your performance gains.
  • Maintain 2 code paths with all of the pain this entails.
Direct3D is not OpenGL.

With Direct3D you can completely write your code to use VBOs in a single code path. This code will work on any hardware that can run your engine. If your 3D card supports them in hardware, it will run them in hardware. If your 3D card doesn't it will run them in software, and you will be no worse off than if you hadn't used them.

Direct3D VBO code would even run on a Voodoo 2.

The very same applies to vertex shaders (though unfortunately not to pixel shaders). One code path, runs on anything, with graceful degradation to software (and still at very high performance) for devices that don't support them.

Direct3D vertex shader code would also run on a Voodoo 2.

With full Shader Model 3 support.

2 comments:

DrLabman said...

To be fair to opengl, switching between using VBO's and regular Vertex Arrays isn't that much work, since VBO's are just an extension to vertex arrays.

The differences come in how you bind your vertex arrays and its only going to be an extra line per vertex array you are using and a different draw call (offset instead of pointer) assuming your using a VBO for your indices.

mhquake said...

I'll concede that one, but you can't say the same for vertex shaders. :P