Jump to content
  • Advertisement
Sign in to follow this  
Grizwald

Index/Vertex Buffer Management, Materials, Renderstates and Batching

This topic is 5117 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

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!