mesa/genmipmap: Added a function to check if the target is valid
authorAntia Puentes <apuentes@igalia.com>
Thu, 26 Nov 2015 14:08:47 +0000 (15:08 +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 6c2d31dbcf30e78c0f4cbe597762166b0a730384..efbb1cfea1996129a734cb265b529132d3a76221 100644 (file)
 #include "texobj.h"
 #include "hash.h"
 
-/**
- * Implements glGenerateMipmap and glGenerateTextureMipmap.
- * Generates all the mipmap levels below the base level.
- */
-void
-_mesa_generate_texture_mipmap(struct gl_context *ctx,
-                              struct gl_texture_object *texObj, GLenum target,
-                              bool dsa)
+bool
+_mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
+                                              GLenum target)
 {
-   struct gl_texture_image *srcImage;
    GLboolean error;
-   const char *suffix = dsa ? "Texture" : "";
-
-   FLUSH_VERTICES(ctx, 0);
 
    switch (target) {
    case GL_TEXTURE_1D:
@@ -81,7 +72,24 @@ _mesa_generate_texture_mipmap(struct gl_context *ctx,
       error = GL_TRUE;
    }
 
-   if (error) {
+   return (error != GL_TRUE);
+}
+
+/**
+ * Implements glGenerateMipmap and glGenerateTextureMipmap.
+ * Generates all the mipmap levels below the base level.
+ */
+void
+_mesa_generate_texture_mipmap(struct gl_context *ctx,
+                              struct gl_texture_object *texObj, GLenum target,
+                              bool dsa)
+{
+   struct gl_texture_image *srcImage;
+   const char *suffix = dsa ? "Texture" : "";
+
+   FLUSH_VERTICES(ctx, 0);
+
+   if (!_mesa_is_valid_generate_texture_mipmap_target(ctx, target)) {
       _mesa_error(ctx, GL_INVALID_ENUM, "glGenerate%sMipmap(target=%s)",
                   suffix, _mesa_enum_to_string(target));
       return;
index f4ef859511e318bf5c59277b114fb16785e8876f..843eeace30a544325298946b66f4ad537ac0ddf2 100644 (file)
@@ -32,6 +32,9 @@ extern void
 _mesa_generate_texture_mipmap(struct gl_context *ctx,
                               struct gl_texture_object *texObj, GLenum target,
                               bool dsa);
+bool
+_mesa_is_valid_generate_texture_mipmap_target(struct gl_context *ctx,
+                                              GLenum target);
 
 extern void GLAPIENTRY
 _mesa_GenerateMipmap(GLenum target);