0

If we generate mipmaps for a texture using GL_GENERATE_MIPMAP (or glGenerateMipmap), how big can the original texture be? Is it the size returned by GL_MAX_TEXTURE_SIZE, or half of it?

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149

1 Answers1

1

From OpenGL specs:

the maximum allowable width of a texel array for a one- or two-dimensional, one- or two-dimensional array, two-dimensional multisample, or two-dimensional multisample array texture, and the maximum allowable height of a two-dimensional, two-dimensional array, two-dimensional multisample, or two dimensional multisample array texture, must be at least 2^(k-lod) + 2bt for image arrays of level 0 through k, where k is the log base 2 of MAX_TEXTURE_SIZE.

This means that max size depends on mip level number you want, actually it also depends on format if you want something like RGBA16 you might end with half the size from what constant suggests.

In reality this value is not trustworthy.

Vasaka
  • 1,953
  • 1
  • 19
  • 30
  • So any idea how to prepare? I've checked that all the devices I want to support do have at least 2048, but I assume I won't be able to mipmap that texture? – Kornel Kisielewicz Jul 01 '13 at 21:02
  • @KornelKisielewicz you can calculate target size by this formula to be on the safe side. Another solution is to try get memory for texture starting from big and repeat process until it succseed. – Vasaka Jul 01 '13 at 21:42