summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/teximage.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/teximage.c')
-rw-r--r--src/mesa/main/teximage.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 7d32c7b2db9..36480348943 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -492,7 +492,7 @@ _mesa_max_texture_levels(const struct gl_context *ctx, GLenum target)
case GL_PROXY_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_PROXY_TEXTURE_2D:
- return ctx->Const.MaxTextureLevels;
+ return ffs(util_next_power_of_two(ctx->Const.MaxTextureSize));
case GL_TEXTURE_3D:
case GL_PROXY_TEXTURE_3D:
return ctx->Const.Max3DTextureLevels;
@@ -514,7 +514,7 @@ _mesa_max_texture_levels(const struct gl_context *ctx, GLenum target)
case GL_TEXTURE_2D_ARRAY_EXT:
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.EXT_texture_array
- ? ctx->Const.MaxTextureLevels : 0;
+ ? ffs(util_next_power_of_two(ctx->Const.MaxTextureSize)) : 0;
case GL_TEXTURE_CUBE_MAP_ARRAY:
case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
return _mesa_has_texture_cube_map_array(ctx)
@@ -973,8 +973,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
switch (target) {
case GL_TEXTURE_1D:
case GL_PROXY_TEXTURE_1D:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); /* level zero size */
- maxSize >>= level; /* level size */
+ maxSize = ctx->Const.MaxTextureSize >> level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
@@ -987,8 +986,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
case GL_PROXY_TEXTURE_2D:
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- maxSize >>= level;
+ maxSize = ctx->Const.MaxTextureSize >> level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)
@@ -1058,8 +1056,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_PROXY_TEXTURE_1D_ARRAY_EXT:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- maxSize >>= level;
+ maxSize = ctx->Const.MaxTextureSize >> level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 0 || height > ctx->Const.MaxArrayTextureLayers)
@@ -1074,8 +1071,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
case GL_PROXY_TEXTURE_2D_ARRAY_EXT:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
- maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
- maxSize >>= level;
+ maxSize = ctx->Const.MaxTextureSize >> level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 2 * border || height > 2 * border + maxSize)