mesa/genmipmap: Added a function to validate the internalformat
authorAntia Puentes <apuentes@igalia.com>
Thu, 26 Nov 2015 14:20:24 +0000 (15:20 +0100)
committerEduardo Lima Mitev <elima@igalia.com>
Thu, 3 Mar 2016 14:14:06 +0000 (15:14 +0100)
It will be used by the ARB_internalformat_query2 implementation to
implement mipmap related queries.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/mesa/main/genmipmap.c
src/mesa/main/genmipmap.h

index efbb1cfea1996129a734cb265b529132d3a76221..f9ef2d14664dcb089989e5d8fc21cbd132df429e 100644 (file)
@@ -75,6 +75,16 @@ _mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
    return (error != GL_TRUE);
 }
 
+bool
+_mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx,
+                                                      GLenum internalformat)
+{
+   return (!_mesa_is_enum_format_integer(internalformat) &&
+           !_mesa_is_depthstencil_format(internalformat) &&
+           !_mesa_is_astc_format(internalformat) &&
+           !_mesa_is_stencil_format(internalformat));
+}
+
 /**
  * Implements glGenerateMipmap and glGenerateTextureMipmap.
  * Generates all the mipmap levels below the base level.
@@ -117,10 +127,8 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,
       return;
    }
 
-   if (_mesa_is_enum_format_integer(srcImage->InternalFormat) ||
-       _mesa_is_depthstencil_format(srcImage->InternalFormat) ||
-       _mesa_is_astc_format(srcImage->InternalFormat) ||
-       _mesa_is_stencil_format(srcImage->InternalFormat)) {
+   if (!_mesa_is_valid_generate_texture_mipmap_internalformat(ctx,
+                                                              srcImage->InternalFormat)) {
       _mesa_unlock_texture(ctx, texObj);
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "glGenerate%sMipmap(invalid internal format)", suffix);
index 843eeace30a544325298946b66f4ad537ac0ddf2..40b7f3636aa29508d047b91720b5f6c3a43b0a0d 100644 (file)
@@ -35,6 +35,9 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,
 bool
 _mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
                                               GLenum target);
+bool
+_mesa_is_valid_generate_texture_mipmap_internalformat(struct gl_context *ctx,
+                                                      GLenum internalformat);
 
 extern void GLAPIENTRY
 _mesa_GenerateMipmap(GLenum target);