0
\$\begingroup\$

Let's say I let a user give my library (a GUI system) multiple textures for rendering elements. What would be the performance impact of rendering with each of those textures separately versus, say, packing them all into a single texture and sampling from that as-needed?

\$\endgroup\$
3
\$\begingroup\$

Using many separate textures involve many separate state changes; state changes are costly, and can add up. Depending on the scope (the number of separate textures used by a game, in this case), this can either be a non-issue or eventually have a noticeable impact on performance. It isn't possible to say in general though.

I would recommend a hybrid approach. Choose (based on the detected hardware specs, or allow the user to specify) a texture atlas size. Pack textures into a single texture as you are given them, and when you cannot fit one into the current atlas, allocate a new one and start filling that.

This gives you the advantage of reducing state changes, but also avoids the disadvantage of one giant texture (you may not be able to allocate that much space, it may be costly to map or unmap, it may waste a ton of space depending on the inefficiency of your bin packer, et cetera).

Consider also these related questions:

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.