Tell the best way to store vertices....
Hi again,
I am into development of a CAD software for drawing lines, circle 2P 3P, arcs, infinite lines, dimension lines(the ones with arrows and text)
Now i create one vertexbuffer for each and every shape i draw....e.g. if there are 3 circles, 2 lines then i have 5 vertexbuffers.
and then i store them all in a single arraylist. while rendering, I loop through the full array list and render each with a drawprimitive call for each vb.
Previously all use only linestrip for each shape, Now i have also added dimension lines. they require some to be triangle list (for the arrow). and now i have a mesh for each dimension line.....generated from mesh.textfromfont... for the text denoting the length
the mesh ref, and x and y details of it are stored into a separate object, that object is added to a hash table.
Now while rendering the mesh i have to move it using translate transform matrix and render it using drawsubset for each mesh.
--
I have read in articles that if u render all primitives using minimal number of vbuffers...performance will increase
So i need a way to store all these stuff properly........cn anyone suggest some steps
The bigger problem is usually that extra VB's tend to incur extra DrawPrimitive() calls. DrawPrimitive() is slow so the less calls the better. Reducing the number of these is usually done by combining similar data into the same buffer and submit them all as a single draw call. It's often referred to as "batching" and is probably what you've come across with regards to performance improvements.
If you can group geometry by the same vertex format then you might as well stick them in the same VB. If you don't mind some added complexity there isn't anything stopping you putting mixed-format data in a VB (via "FVF-Less" buffers) but I'd personally avoid it - more complex, less intuitive and may not be so performance-friendly.
Bare in mind that sending multiple line-strips or triangle-strips per call is difficult if not impossible, thus using line-lists and triangle-lists tends to be much easier to work with. Performance differences are negligable to irrelevant if you optimize for coherancy and cache size.
Be sure to dig into "PIX for Windows" - included in the later SDK's. This tool is an absolute goldmine of high quality performance information and can really help work out what your D3D application is really doing.
hth
Jack
Thank you Mr.Jack.....that was very useful..
So you mean i can work with linelists...
so that i can put everything possible in a single vertexbuffer for all linelists and one for trianglelists.
was that what u meant.
anyway how do u do batching....plz tell me that also.
i will also check about the PIX tool....i have it in my SDK...
Thank you once again Mr.Jack.
Rajavanya wrote: |
so that i can put everything possible in a single vertexbuffer for all linelists and one for trianglelists. was that what u meant. |
|
Pretty much - but you can store different primitive types (e.g. lines and triangles) in the same VB.
Probably the two best metrics when it comes to deciding what you put in a VB are size (you don't necessarily want huge VB's, several medium sized ones may perform better than one large one) and access-level (put all read-only/static vertices in one buffer and any dynamic/changing vertices in another).
Rajavanya wrote: |
| anyway how do u do batching....plz tell me that also. |
|
Batching is a simple concept - just reduce the number of draw calls. Exactly how you implement it is up to you - it tends to be quite application specific.
A simple example is to have several objects defined as triangle lists and then to submit them all at the same time rather than issue a seperate draw call for each object. Where it gets difficult is that they must all use the same pipeline configuration.
Looking around on at.com/developer and developer.nvidia.com should yield some useful papers discussing best practices.
hth
Jack