• Advertisement
Sign in to follow this  

DrawPrimitive or SetStreamSource?

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm currently desiging a GUI for DirectX that stores 3 vertex buffers for storing the GUI control graphics. I have a set of graphic rendering routines such as: DrawRect - This draws into locked VB 1 DrawLine - This draws into locked VB 2 DrawTexturedRect - This draws into locked VB 3 At the start of rendering, I'll do GUIBase::BeginDraw(); and when I'm done, GUIBase::EndDraw(); to flush the vertex buffers. When I flush, I set VB1 and do DrawPrimitive, then set VB2 and DrawPrimitive, and the same for VB 3. Would it be more efficient to store 1 vertex buffer and when each of the graphics rendering function is called, store the vertices and a sort of render set info, so that when you flush, you set the ONE VB but could be making calls to DrawPrimitive about 50-100 times per-frame. Or is it more efficient doing 3 VB's and 3 DrawPrimitive? Thanks. MeshMan

Share this post


Link to post
Share on other sites
Advertisement
One more instance:

Consider using 1 vertex buffer, split it into 3 sub-sections and doing 1 VB and 3 DrawPrimitive?

Or 1 VB, sort it before rendering, and do 3 DrawPrimitive calls?

Share this post


Link to post
Share on other sites
First off, I'm not too sure keeping a VB locked for a long time is a good idea. I'm not sure it's a bad one, but I can think of many posibilities for errors.

Also, you might consider adding the possibility to keep some GUI static, and hence leave the VB "As is", at least partially. This would save time, since locking only part of the buffer would be less costly, though you'd have to have the static object at one side (start or end) of the buffer, so you're not forced to lock them or lock more than once.

All in all, I'd recommend creating temp home-made "VBs" which you'd stuff all the data into, and only when flush is called, you'd lock the buffers and start pumping data to the GPU. This would also allow you to keep some static data in the begining of the buffer and would allow you to use one buffer with no need to sort the data (vertices would be in 3 groups, from your 3 simulated VBs).

This would save you 2 lock calls and 2 SetStream calls, which are both costly.

Finally, I'd recommend looking into the D3DXSprite interface, assuming you're using DX9 and it's a viable option.

Anywho, good luck :).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement