Sign in to follow this  
MadOrcun

Confusion : Dealing with vertex buffers efficiently in big and complex scenes

Recommended Posts

Hi everyone, I am developing a graphic module for my engine and I am not an exprienced Direct3D user. My graphics module has a master render lists that contantins render lists of the primitives, which are going to draw on to screen. Each render list consist of vertex data, transformation matrices and some render flags as ussual. One a entity in the engine wants to draw some thing it creates a render list (Copies vertex data to the render list) and sends to graphic module. My problem is how I move data from render lists to vertex buffers efficiently. My procedure for rendering a frame is; 1-Find the renderlist that have biggest vertex count. 2-Create a vertex buffer with the size of biggest vertex count. (With DYNAMIC flags) 3-Draw each renderlist by using vertex buffer that you have created. (By locking render list DISCARD flag) 4-Delete the vertex buffer. Is this the way of rendering complex geometry ? Is DrawPrimitive call is a non-locking function ? If it is so I have automaticly have more than instances of the same vertex buffer for each render list. or should I use the procedure bellow. 1-Get a render list form the main render list queue. 2-Create a vertex buffer with the size of render list's vertex count. 4-Draw primitive 5-Destroy vertex buffer. 6-Goto step 1 Or should I use static vertex buffers and find a way to combine renderlist and vertex buffer ? Maybe entites should directly dump vertex data in to the vertex buffer instead of renderlist's system memory. Which means every render list is going to have its own vertex buffer. My graphics module suffers from huge performance penalty. Maybe becouse of double copying vertex buffer or maybe becouse of using an unified vertex buffer for all drawprimitive calls. Or should I try totaly some thing different ? What is your opinion about this situation ? Thank you. I feel that I can not express my self well becouse of my lack of English skills. I hope that you understand my post. If not so, I will try to explain it better.

Share this post


Link to post
Share on other sites
Some hints for you:

- avoid using dynamic vertex buffers except for when you're dealing with really dynamic data that changes per frame (e.g. particle effects); using dynamic vertex buffers is expensive

- actually creation and destruction of any DirectX resources per frame is expensive and should be avoided; just create all vertex buffers you need once when creating your world, fill them with proper vertex data and don't touch their content since then

- study some samples that come with DirectX SDK; they should be really helpful for you

Good luck.

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