[Mesa-dev] [PATCH] mesa: Add GL_TEXTURE_CUBE_MAP to _mesa_max_texture_levels().

Kenneth Graunke kenneth at whitecape.org
Tue Jun 5 09:16:23 CEST 2012


For cube maps, _mesa_generate_mipmap() calls this with
GL_TEXTURE_CUBE_MAP_ARB (the gl_texture_object's Target) rather than one
of the faces.  This caused _mesa_max_texture_levels() to return 0, which
resulted in maxLevels == -1 and the next line's assertion to fail.

This function is called from several places.  It looks like texstorage.c
also wants this enum to be handled, while most callers don't care.
TexImage, CompressedTexImage, FramebufferTexture, and GetTexImage
already appear to filter out illegal targets, so they should be fine.

However, GetTexLevelParameter does rely on this function for filtering
out invalid targets, and does not accept GL_TEXTURE_CUBE_MAP.  Special
case this, since it apparently supports every other target.

+2 oglconforms (float-texture/mipmap.automatic and mipmap.manual)

NOTE: This is a candidate for stable release branches.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/main/teximage.c |    1 +
 src/mesa/main/texparam.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 694f6fa..e5f804c 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -936,6 +936,7 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target)
    case GL_TEXTURE_3D:
    case GL_PROXY_TEXTURE_3D:
       return ctx->Const.Max3DTextureLevels;
+   case GL_TEXTURE_CUBE_MAP:
    case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
    case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
    case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 9abc503..a1aaecd 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -917,7 +917,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
 
    /* this will catch bad target values */
    maxLevels = _mesa_max_texture_levels(ctx, target);
-   if (maxLevels == 0) {
+   if (maxLevels == 0 || target == GL_TEXTURE_CUBE_MAP) {
       _mesa_error(ctx, GL_INVALID_ENUM,
                   "glGetTexLevelParameter[if]v(target=0x%x)", target);
       return;
-- 
1.7.10.3



More information about the mesa-dev mailing list