what is the use of rectangular textures if we have mipmap supporting NPOT textures? Is there any performance related or quality of image related improvement? Also, i think, mipmapping would take large amount of memory as it creates for every level. So, isn' it better to use rectangular textures?
Rectangle textures:
#1 isn't that important, as you can achieve the same effect by just using glTexStorage2D and setting the number of mipmap levels to 1, or by setting the base/max level of the texture properly and/or using min filtering parameters that don't use mipmaps.
#2 is harder to emulate. The texelFetch function works in texture space, but this uses integer texture coordinates. Rectangle texture coordinates are floating-point values. This allows them to employ bilinear and even anisotropic filtering. You can't do that with texelFetch
.
You can emulate rectangle textures by normalizing a texel-space texture coordinate. But this requires manual work: you have to either query the texture's size with textureSize
or pass the size in a uniform
to the shader. Then you have to do a division to normalize the coordinate. This may be what modern hardware does behind the scenes (especially since newer APIs like Vulkan don't have them), but if there's explicit support for rectangle textures, manual work will likely bypass it.
#2 is really the main reason you would ever use rectangle textures these days. They're great for render targets, because you can fetch values from them using window-space coordinates without needing to normalize the texture coordinates. But in general, they're very special-case texture types.
Questions of performance are purely speculative and hardware-specific.