Sign in to follow this  
Sambori

Optimal Drawing Strategy

Recommended Posts

What's the most optimal (dynamic) drawing strategy in Direct3D 9? 1) Create a big vertex buffer, and for each object/primitive drawn, fill the VB and immediately issue the drawing call: DrawPrimitive. "Draw-as-you-go" 2) Keep filling the buffer until it's full or no more complete object/primitve can be filled, and issue a sequence of consecutive drawing calls: DrawPrimitive's :) "Batched-drawing" - Drawing is dynamic and changes are almost every frame - All objects will have the same vertex data layout - All objects are subject to the same view/world/projection transforms Advice appreciated!

Share this post


Link to post
Share on other sites
What kind of changes are required on the vertices every frame? Simple transforms can be done in a shader and don't require lock-fill-unlock semantics in C++.

Optimally you should identify your basic geometry and upload that to the video card *ONCE* using D3DPOOL_DEFAULT and WRITEONLY usage.

Then use shaders to create the per-frame changes you desire.

Also try to keep your DrawIndexedPrimitive() calls as large as possible

and finally *DO* prefer indexed primitive lists over triangle strips or non-indexed lists.

Share this post


Link to post
Share on other sites
This is optimal for static geometry with transformation applied to the whole mesh as a matrix.

My stuff is completely different. It's actually many dynamic meshes that are edited/modified interactively very frequent, by changing the vertices along with topology itself.

Share this post


Link to post
Share on other sites
So you are writing a terrain editor and not a game?

Maybe you could provide more specifics for your situation, since "optimal" for one scenario is not always "optimal" for another.

For instance if all you are doing is deforming terrain through an editor, you can still bake the (x, z) values for one patch into the video card and upload the y-offsets via a second dynamic vertex stream.

Share this post


Link to post
Share on other sites
Actually it's a robust CAD application with rendered GUI. For example, a user can edit an object or change an item of the graph of objects and it affects the entire set of objects. Thus I re-create every object based on a new set of vertices and maybe topology for every user update.

There's a situation where the objects are kept intact, when the user is modifying the view transform by navigating through the scene. In this case I don't need to recreate the geometry.

However, the buffer may not be big enough (or at least geometry can grow in size) that objects cannot all fit at once and reside. Hence, the buffer is re-written/filled with existing last created object data.

I'm not sure if this is clear enough but my concern is which method is more performance optimal for drawing dynamic data. In other words, which one does not cause CPU stall or GPU-mem bandwidth travel overhead.

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