main: Added entry point for glGenerateTextureMipmap.
authorLaura Ekstrand <laura@jlekstrand.net>
Tue, 6 Jan 2015 20:08:43 +0000 (12:08 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Thu, 8 Jan 2015 19:37:29 +0000 (11:37 -0800)
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mapi/glapi/gen/ARB_direct_state_access.xml
src/mesa/main/genmipmap.c
src/mesa/main/genmipmap.h
src/mesa/main/tests/dispatch_sanity.cpp

index f1f38d298107a755f7a4557b40e1bb9e58c1d65a..afc16ad97ed114a52fd84f95a05de902d9e62949 100644 (file)
       <param name="param" type="const GLint *" />
    </function>
 
+   <function name="GenerateTextureMipmap" offset="assign">
+      <param name="texture" type="GLuint" />
+   </function>
+
    <function name="BindTextureUnit" offset="assign">
       <param name="unit" type="GLuint" />
       <param name="texture" type="GLuint" />
index a883332bac70ac18b80e560bab9589e048f6f284..9aef090194e58dc0f5f29ededadb6760ce239463 100644 (file)
 #include "mtypes.h"
 #include "teximage.h"
 #include "texobj.h"
-
+#include "hash.h"
 
 /**
- * Generate all the mipmap levels below the base level.
- * Note: this GL function would be more useful if one could specify a
- * cube face, a set of array slices, etc.
+ * Implements glGenerateMipmap and glGenerateTextureMipmap.
+ * Generates all the mipmap levels below the base level.
  */
-void GLAPIENTRY
-_mesa_GenerateMipmap(GLenum target)
+void
+_mesa_generate_texture_mipmap(struct gl_context *ctx,
+                              struct gl_texture_object *texObj, GLenum target,
+                              bool dsa)
 {
    struct gl_texture_image *srcImage;
-   struct gl_texture_object *texObj;
    GLboolean error;
-
-   GET_CURRENT_CONTEXT(ctx);
+   const char *suffix = dsa ? "Texture" : "";
 
    FLUSH_VERTICES(ctx, 0);
 
@@ -83,13 +82,11 @@ _mesa_GenerateMipmap(GLenum target)
    }
 
    if (error) {
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)",
-                  _mesa_lookup_enum_by_nr(target));
+      _mesa_error(ctx, GL_INVALID_ENUM, "glGenerate%sMipmap(target=%s)",
+                  suffix, _mesa_lookup_enum_by_nr(target));
       return;
    }
 
-   texObj = _mesa_get_current_tex_object(ctx, target);
-
    if (texObj->BaseLevel >= texObj->MaxLevel) {
       /* nothing to do */
       return;
@@ -98,7 +95,7 @@ _mesa_GenerateMipmap(GLenum target)
    if (texObj->Target == GL_TEXTURE_CUBE_MAP &&
        !_mesa_cube_complete(texObj)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGenerateMipmap(incomplete cube map)");
+                  "glGenerate%sMipmap(incomplete cube map)", suffix);
       return;
    }
 
@@ -108,7 +105,7 @@ _mesa_GenerateMipmap(GLenum target)
    if (!srcImage) {
       _mesa_unlock_texture(ctx, texObj);
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGenerateMipmap(zero size base image)");
+                  "glGenerate%sMipmap(zero size base image)", suffix);
       return;
    }
 
@@ -117,19 +114,53 @@ _mesa_GenerateMipmap(GLenum target)
        _mesa_is_stencil_format(srcImage->InternalFormat)) {
       _mesa_unlock_texture(ctx, texObj);
       _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "glGenerateMipmap(invalid internal format)");
+                  "glGenerate%sMipmap(invalid internal format)", suffix);
       return;
    }
 
    if (target == GL_TEXTURE_CUBE_MAP) {
       GLuint face;
-      for (face = 0; face < 6; face++)
-        ctx->Driver.GenerateMipmap(ctx,
-                                   GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face,
-                                   texObj);
+      for (face = 0; face < 6; face++) {
+         ctx->Driver.GenerateMipmap(ctx,
+                      GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB + face, texObj);
+      }
    }
    else {
       ctx->Driver.GenerateMipmap(ctx, target, texObj);
    }
    _mesa_unlock_texture(ctx, texObj);
 }
+
+/**
+ * Generate all the mipmap levels below the base level.
+ * Note: this GL function would be more useful if one could specify a
+ * cube face, a set of array slices, etc.
+ */
+void GLAPIENTRY
+_mesa_GenerateMipmap(GLenum target)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
+
+   _mesa_generate_texture_mipmap(ctx, texObj, target, false);
+}
+
+/**
+ * Generate all the mipmap levels below the base level.
+ */
+void GLAPIENTRY
+_mesa_GenerateTextureMipmap(GLuint texture)
+{
+   struct gl_texture_object *texObj;
+   GET_CURRENT_CONTEXT(ctx);
+
+   texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap");
+   if (!texObj)
+      return;
+
+   _mesa_generate_texture_mipmap(ctx, texObj, texObj->Target, true);
+}
index d546a8d7b8cf2c98ffe0bf7b75832cb4fad7d7ff..f4ef859511e318bf5c59277b114fb16785e8876f 100644 (file)
 
 #include "glheader.h"
 
+extern void
+_mesa_generate_texture_mipmap(struct gl_context *ctx,
+                              struct gl_texture_object *texObj, GLenum target,
+                              bool dsa);
 
 extern void GLAPIENTRY
 _mesa_GenerateMipmap(GLenum target);
 
+extern void GLAPIENTRY
+_mesa_GenerateTextureMipmap(GLuint texture);
 
 #endif /* GENMIPMAP_H */
index afdcbd0fbc3be1488010a985269141fc7e3e2f59..0739025f1fb944ce5cb0215933bad193329cf4b5 100644 (file)
@@ -983,6 +983,7 @@ const struct function gl_core_functions_possible[] = {
    { "glCompressedTextureSubImage1D", 45, -1 },
    { "glCompressedTextureSubImage2D", 45, -1 },
    { "glCompressedTextureSubImage3D", 45, -1 },
+   { "glGenerateTextureMipmap", 45, -1 },
 
    { NULL, 0, -1 }
 };