Search code examples
performanceopengltexturesgpuhardware

What is the performance of GL_TEXTURE_2D for "non power of 2 textures"?


In theory, OpenGL has GL_TEXTURE_2D for "power of 2" textures and GL_TEXTURE_RECTANGLE for "non power of 2 textures".

I would like to know if modern GPUs still care about this difference or if this is only a problem of the past. In other words, if I use GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE for "a non power of 2" texture, will I have loss of performance is modern video cards?


Solution

  • See https://www.opengl.org/wiki/NPOT_Texture

    Any hardware that's at least OpenGL 2.0 core complient (and recent hw is most likely OpenGL 4.4 compliant) MUST supports non-power-of-two (NPOT) textures with GL_TEXTURE_2D.

    As for performance compared to GL_TEXTURE_RECTANGLE ... it's not specified, but if the hw supports it (and it has to), I don't see why one would be slower than the other.

    And for performance compared to using power-of-two textures. I'd expect some overhead (both in time and memory size), just because hw naturally deals with power of twos and some care has to be taken. How much ? Well it's impossible to tell without testing ... however given the power of moderns GPUs, I wouldn't worry about it too much if you _have_to_ use NPOT. But if converting to using NPOT is trivial in your application and easily done as an 'init' step, then I'd do it, just to be sure.