Jump to content
  • Advertisement
Sign in to follow this  
Tar

Updating Index Buffer

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

Hello, I created a bunch of meshes that are fairly similar to each other. In fact their indices are all the same except the first quad. I would like to load the indices to the Index Buffer just once, and then reuse them during the rendering phase. Here is a dilemma: - I could change the first quad for each mesh during the rendering phase. It involves locking the Index Buffer, updating six indices, and unlocking the buffer. I would have to repeat all these steps for each mesh. It adds obvious overhead and messes up the code as I need to update the buffer during the rendering phase instead of keeping all updates to the scene separately. -or- - I would load the Index Buffer with a complete set of indices for each mesh during the scene update. The indices would be very repetitive as only the first quad is different for each mesh. This way I would lose the opportunity to reuse the indices and increase the size of the Index Buffer significantly. Which way to go? Is there any other way to solve this problem which I don't know about? Thanks in advance, Tar

Share this post


Link to post
Share on other sites
Advertisement
Unless you are *extremely* limited in video memory, avoid updating the buffers. Locking a vertex/index buffer before each draw call is guaranteed to be far slower than drawing directly from the buffer.

Share this post


Link to post
Share on other sites
Thanks swiftcoder for your reply.

It seems that I should go for the option #2 - "Loading the Index Buffer with a complete set of indices for each mesh during the scene update".
I understand that it is a trade-off: I sacrifice memory by keeping repetitive data in the Index Buffer, but I improve performace, as I don't have to lock/unlock the buffer before each draw call.

There is no other option?

Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by Tar
I understand that it is a trade-off: I sacrifice memory by keeping repetitive data in the Index Buffer, but I improve performace, as I don't have to lock/unlock the buffer before each draw call.
It isn't even worth considering unless you are running on embedded hardware (such as a mobile phone). With 512 MB video cards in the midrange these days, an extra 4 KB of VRAM per model for indices isn't going to break the bank.
Quote:
There is no other option?
There is, but it isn't worth it: reorder your meshes so as to use the same index buffer.

Share this post


Link to post
Share on other sites
OK. Thanks again. Yep, it's difficult to find on the market any graphics cards with less than 128MB these days. I just wanted to know if there is any more optimal solution.

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!