How to call D3D9 VB and IB by Index?

Started by
4 comments, last by cgrant 8 years, 4 months ago

Like in OpenGL, I don't want to bind the vbs and ibs during render calls?

I want to bind them in advance.

BTW, if I got a std::vector of vertexes and tie them to BYTE** which points to this VB or IB,

when this vector of vertexes change, will the vb and ib change accordingly as well?

Thanks

Jack

Advertisement

Like in OpenGL, I don't want to bind the vbs and ibs during render calls?
I want to bind them in advance.

Direct3D does not work this way, nor does the actual hardware. Why the GL people thought this was a good idea, I have no clue. In all the other APIs, the vertex declaration/input layout is separate from the actual buffers in use. Changing the vertex structure is (potentially) very expensive, while changing the attached buffers is pretty much free.


BTW, if I got a std::vector of vertexes and tie them to BYTE** which points to this VB or IB,
when this vector of vertexes change, will the vb and ib change accordingly as well?

Absolutely not. You must Lock the VB/IB and update the data manually.

SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

My program went extremely slow because of the number of vertexes and indices I pass over to the renderer in every frame call.

Like 10000 vertexes and 30000 indices in every call.

In every frame past, I need to build the vb and ib all over again, the renderer gradually builds up

the vertex buffer and index buffer by iterating them one by one, if this is done by software.

And I have other stuff to do during the frame elapsed, if the renderer engaged in dealng with the buffers,

the performance will suffer. Are there any optimizations I can consider?

Thanks

Jack

Are there any optimizations I can consider?


Does the data you're pushing to the GPU need to change every frame? If not, then don't change it.

Otherwise you'll need to talk a little more about how you're updating those buffers. Are you using dynamic buffers with the no-overwrite/discard pattern or not?

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I am using the Smartbody library.

The final transformation of every vertex is reflected in a position buffer at the end of every update call.

I then have to bind them to the vertex buffer and render away.

I think the usual way is to give a transformation to the whole mesh/bone, the library seems to be vertex perfect and processing

all vertexes in a total manner.

Maybe I oversee some of the features of the library so that I don't have to process all the vertexes entirely,

and just give a transformation to each submesh instead?

Thanks

Jack

So Smartbody is tranforming the individual mesh vertices on the CPU ? The usual way is like you suggested via a bone transforming aka.skinned mesh/skinning. So I'd be surprised if the library doesn't generate some for of transform data use to do the actual vertex transformation. If that information is available along with the weights, then I would suggest uploading those per frame instead of the entire mesh. Are the meshes growing in size ? If not, why would you need to re-upload the index buffer each frame ?

This topic is closed to new replies.

Advertisement