[Mesa-dev] [RFC 37/63] mesa/genmipmap: Added a function to check if the target is valid

Eduardo Lima Mitev elima at igalia.com
Tue Jan 19 08:42:17 PST 2016


From: Antia Puentes <apuentes at igalia.com>

It will be used by the ARB_internalformat_query2 implementation to
implement mipmap related queries.
---
 src/mesa/main/genmipmap.c | 34 +++++++++++++++++++++-------------
 src/mesa/main/genmipmap.h |  3 +++
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c
index 4ec8385..13ec766 100644
--- a/src/mesa/main/genmipmap.c
+++ b/src/mesa/main/genmipmap.c
@@ -38,20 +38,11 @@
 #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;
diff --git a/src/mesa/main/genmipmap.h b/src/mesa/main/genmipmap.h
index f4ef859..843eeac 100644
--- a/src/mesa/main/genmipmap.h
+++ b/src/mesa/main/genmipmap.h
@@ -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);
-- 
2.5.3



More information about the mesa-dev mailing list