Sign in to follow this  
Grizwald

Index/Vertex Buffer Management, Materials, Renderstates and Batching

Recommended Posts

Ok, here's the scoop. What is the best method of managing all of what is in the title, while reducing the number of vertex buffers, state changes and buffer changes. What is the penalty for locking and switching index buffers vs locking and switching vertex buffers. I have a node with a list of geometry, (stored as indices to the main vertex pool), sorted by a material ID. Is it effectice to run down the list, set the renderstate/material, and render the IB, and repeat that over again (switching the renderstate/material only when needed?) I'm having a hard time with this part of my engine.

Share this post


Link to post
Share on other sites
This is a difficult question, because you can not get a "this is right" or "this is wrong" answer. The answer can only be this is worse compared to this one or vice versa and everything depends on your specific environment. I hope you see what I mean.
The best rule is measure everything and create rules for your engine.
Here is my list of rules:

1. Options for reducing or eliminating shader changes:
- Sort
- Use fewer shaders
- Use longer shaders
2. Options for reducing or eliminating constant and texture changes
- Sort
- Change fewer constants / texture atlas
- Use more shaders that don't require constant changes
3. Options for reducing or eliminating vertex declaration changes
- Sort
- Use fewer vertex declarations (must be aligned)
4. Options for increasing z-rejects
- Sort
- Generally categorize your geometry (entities, architectural occluders, portals etc.)

No. 1 is worst.

So back to your question.

>>>
What is the penalty for locking and switching index buffers vs locking and switching vertex buffers.
>>>
It depends on your enviroment. You need to measure this in your engine because it depends on more factors I can think of (size of index and vertex buffer / dynamic or static / graphics card / vertex buffer switching (e.g. five vertex buffers per model etc. ...)

>>>
I have a node with a list of geometry, (stored as indices to the main vertex pool), sorted by a material ID. Is it effectice to run down the list, set the renderstate/material, and render the IB, and repeat that over again (switching the renderstate/material only when needed?)
>>>
Again this depends on your measurements. You might follow here my simple list and try to isolate the most expensive changes.
You might use tools like the PIX tool of the DirectX 9 SDK or the HDPerf tool from NVIDIA.

- Wolf




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