diff options
author | Marek Olšák <[email protected]> | 2012-11-11 15:22:32 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2012-11-12 21:36:56 +0100 |
commit | 8111342e814304730bed34446ea816cbc17a5775 (patch) | |
tree | 90260b9415bd64076d679125fd8adfd75c787ea3 /src/mesa/main/teximage.c | |
parent | 26097c4855b97ee6e362c19df11d51fb7fd42192 (diff) |
mesa: add MaxNumLevels to gl_texture_image, remove MaxLog2
MaxLog2 led to bugs, because it didn't work well with 1D and 3D textures.
NOTE: This is a candidate for the stable branches.
v2: correct the comment at MaxNumlevels
Reviewed-by: Brian Paul <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r-- | src/mesa/main/teximage.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 678833ec5ee..0850ef1110c 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -1027,6 +1027,43 @@ _mesa_get_texture_dimensions(GLenum target) } +/** + * Return the maximum number of mipmap levels for the given target + * and the dimensions. + * The dimensions are expected not to include the border. + */ +GLsizei +_mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height, + GLsizei depth) +{ + GLsizei size; + + switch (target) { + case GL_TEXTURE_1D: + case GL_TEXTURE_1D_ARRAY: + size = width; + break; + case GL_TEXTURE_CUBE_MAP: + case GL_TEXTURE_CUBE_MAP_ARRAY: + ASSERT(width == height); + size = width; + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_2D_ARRAY: + size = MAX2(width, height); + break; + case GL_TEXTURE_3D: + size = MAX3(width, height, depth); + break; + case GL_TEXTURE_RECTANGLE: + return 1; + default: + assert(0); + return 1; + } + + return _mesa_logbase2(size) + 1; +} #if 000 /* not used anymore */ @@ -1214,7 +1251,9 @@ _mesa_init_teximage_fields(struct gl_context *ctx, target); } - img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); + img->MaxNumLevels = + _mesa_get_tex_max_num_levels(target, + img->Width2, img->Height2, img->Depth2); img->TexFormat = format; } |