Many small or Fewer large?

Can anyone tell me if it is better to use many small textures or a couple large ones?

For example, say you have 64 images, each 64x64. Would it improve performance to combine these into a few larger images and use coords to pull out the individual ones?

Also, must the combined form be power of 2 in width and height? (If I combine the images, I’d like to do so programatically.)

Much thanks.

It’s certainly easier not to combine ;D
I always go for the easiest, cleanest route (at least I try), until I run in performance troubles.
I seriously doubt if combining would improve performance, I could even imagine it could slow things down but then again I haven’t tried…

Maybe I’m understanding your question wrong, but as I see it a texture must always be power of 2 in width and height no matter what’s in it. Where are you looking for performance improvements? Loading, drawing?

Binding a texture is expensive. Do it as seldom as possible. Reducing the number of textures would help reducing the number of texture switches. Witch would result in better performance.

Newer cards support textures that is not power of two.

Just disabled all texture binding in cosmic trip (so it showed everything with the same texture, with funny results). Frame rate raised ~15fps. I stand corrected :-X

So, bind as few textures as possible. But as for power of two, do you know how new the card has to be to not require that?

(Perhaps I should have asked this in a different forum since these aren’t lwjgl specific questions. Sorry!)

I don’t know any stastics, but I think there are enough older cards around that you should probably stay with power-of-two textures.

It shouldn’t be that much of a big deal really - you’re dealing with power-of-two tile sizes already, so when you pack them together make sure you put 2, 4 or 16 to a side. The minimal extra work is worth it for the increased portability.

One last question on this then. Will it matter if I use a long strip (ie, all my images in one long row, padded out to be pow2 long) or is there an optimization in GL for squarish textures?

Sorry if this sounds like a dumb question, I just want to understand the best practices early on.

Some really old cards only like square texture (voodoo 1 & 2 era) but I don’t think thats much of a concern nowadays.

I suppose you might have problems with texture coord accuracy if you had really long, thin textures, but I doubt that’ll ever realistically happen.

I always thought that the cost associated with a texture bind is due to it possibly needing to be shuttled across the AGP, and possibly a whole bunch of cache misses when starting rendering. But if you’ve got many smaller textures then the actual upload is going to be smaller, and you’ll get the cache misses either way.

Assuming you can sort by texture, then I don’t know how much of a difference you’d actually see, it might be interesting to try and benchmark the two. Whether combining texture makes state sorting easier or harder might be worth thinking about though.

Hmm, I respect all the words given on this. Thanks!

[quote]Assuming you can sort by texture, then I don’t know how much of a difference you’d actually see, it might be interesting to try and benchmark the two. Whether combining texture makes state sorting easier or harder might be worth thinking about though.
[/quote]
Based on this I will let the artist have his way for the animations (cartoon style) and let him keep each image as a seperate file. The tiles for the map itself I’ll probably group into larger images.

Thanks again!

I think that’s probably a good policy. First just get things working - if all goes well and you continue with the project, move over to a “proper” texture aggregation system later.