Jump to content
  • Advertisement
Sign in to follow this  
Grain

glBindTexture performance question

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

So I have read in a few articles and books to minimize calls to glBindTexture because you will incur performance hits if you use it to much. My question is how much of a performance issue is this and are there any alternate methods of changing which texture I am rendering with. Also is would it be worth it to sort my linked list of sprites(I am making a 2d game with sprites rendered on a quad)by the texture they use so that all the sprites that use the same texture are rendered together. Will the extra CPU cycles needed to sort the list be less of a hit that the calls to glBindTexturethat they save?

Share this post


Link to post
Share on other sites
Advertisement
changing textures does knock performance quite a lot. u can pack smaller textures together into a larger texture, this is used esp often with 2d games. eg pack the textures into a 2048x2048 sized texture/s and just chnage texture cooridnate (u might wanna stick a border around each subtexture so u dont get texture filtering artifacts)

Share this post


Link to post
Share on other sites
Another good idea is to order your geometry by texture (if possible) so that you can draw elements of the same texture in a batch- therefore minimising the number of texture changes.

Also you may want to take a look at using 'texture objects' if you are not already doing so. I haven't implemented them myself yet so I cannot comment on their performance merits, but they are said to be faster than regular texture binds.

Here's an article from the articles section which shows how to use them:
Texture objects article

Share this post


Link to post
Share on other sites
Quote:
Original post by Darragh
Another good idea is to order your geometry by texture (if possible) so that you can draw elements of the same texture in a batch- therefore minimising the number of texture changes.

Also you may want to take a look at using 'texture objects' if you are not already doing so. I haven't implemented them myself yet so I cannot comment on their performance merits, but they are said to be faster than regular texture binds.

Here's an article from the articles section which shows how to use them:
Texture objects article


Unless he's doing something very strange, he's already using Texture Objects, since he's talking about glBindTexture. Basically everybody uses texture objects I'd think. All tutorials I've seen handling texturing use them.

Share this post


Link to post
Share on other sites
i'd be very shocked if he wasnt using texture objects, they've been standard since 1.1 and apart from the very first texturing examples in the red book every example i've seen uses them.

Anyways, the advice about batching and packing is spot on. The reason it causes a hit is that on binding the texture you cause various caches on the GPU to be flushed and while there isnt anything you can do about it for the best performance you need to minimise it.

There are a couple of pdfs and videos in the forum FAQ regarding performnce, GDC04's are more relivent to this question.

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
i'd be very shocked if he wasnt using texture objects, they've been standard since 1.1 and apart from the very first texturing examples in the red book every example i've seen uses them.


(smacks head) Oh dear, it appears I am using texture objects after all! Another read of the article reveals this... Now I just feel plain silly! [grin]
Thats what happens when you flick through articles at the rate I do!!

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!