Sign in to follow this  
PumpkinPieman

Benefit in using DX structures?

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this