Benefit in using DX structures?

Started by
3 comments, last by circlesoft 19 years, 5 months ago
What is the benefit in using DX structures like VertexBuffers as opposed to passing arrays of vertices and indices?
Advertisement
They're much lower level than can be reached by using arrays and/or pointers. You can easily command the VBs or IBs to go to system memory or let DX manage it, in other words, performance is much better with the VBs, plus drawing is a snap with VBs/IBs.
I WISH SOMEONE WOULD FIX THE DAMNED LOGIN!
How about the preformance between a dynamic VertexBufffer\IndexBuffer to an array of vertices and indices?
Quote:Original post by PumpkinPieman
How about the preformance between a dynamic VertexBufffer\IndexBuffer to an array of vertices and indices?


Like a lot of computer science-related ideas, it depends on what application. If you use it for drawing a simple sphere, cube, pyramid, etc, with no textures, no UV, no anything, then yes. But, if you want to do anything interesting, as in texturing, it is much easier if you use VBs. All you need to do is specify you want to apply textures in the FVF and in the vertex structure and you're set.
I WISH SOMEONE WOULD FIX THE DAMNED LOGIN!
To draw an array of vertices with indices, you have to use IDirect3DDevice9::DrawIndexedPrimitiveUP(). To draw a VB with an IB, you have to use IDirect3DDevice::DrawIndexedPrimitive() (after your call(s) to SetStreamSource() and SetIndices()).

With that said, DrawIndexedPrimitive() is one of the most resource-consuming functions you can call (it's necessary, of course). However, DrawIndexedPrimtitiveUP() is even worse - it should be avoided at all costs. When you call dipUP(), D3D actually fills all that data into a vertex and index buffer for you, then renderers with that instead. So you are actually using buffers in the end, but D3D is just doing the dirty work for you. Needless to say, dipUP (and DrawPrimitiveUP()) are unbearably slow. There is seriously no reason not to be using vertex and index buffers today, since all mainstream graphics cards support them.

Also, when you have an array of vertices and indices, all of that data is stored in system memory. Vertex and index buffers can be created on the GPU, utilizing all of this wonderful memory we have on the graphics card. Rendering vertex buffers that reside in video memory is much faster than rendering VBs that are in system memory, since all of that data doesn't have to be transferred from your system memory, through the AGP bus, to your graphics card.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement