[Mesa-dev] [PATCH 32/41] main: Added entry point for glGenerateTextureMipmap.

Anuj Phogat anuj.phogat at gmail.com
Wed Dec 31 11:53:20 PST 2014


On Mon, Dec 15, 2014 at 5:22 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |  4 ++
>  src/mesa/main/genmipmap.c                      | 73 +++++++++++++++++++-------
>  src/mesa/main/genmipmap.h                      |  6 +++
>  3 files changed, 64 insertions(+), 19 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index f1f38d2..afc16ad 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -179,6 +179,10 @@
>        <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" />
> diff --git a/src/mesa/main/genmipmap.c b/src/mesa/main/genmipmap.c
> index 9d111ca..516d641 100644
> --- a/src/mesa/main/genmipmap.c
> +++ b/src/mesa/main/genmipmap.c
> @@ -36,22 +36,20 @@
>  #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);
> -
>     FLUSH_VERTICES(ctx, 0);
>
>     switch (target) {
> @@ -83,13 +81,12 @@ _mesa_GenerateMipmap(GLenum target)
>     }
>
>     if (error) {
> -      _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target=%s)",
> +      _mesa_error(ctx, GL_INVALID_ENUM, "glGenerate%sMipmap(target=%s)",
> +                  dsa ? "Texture" : "",
>                    _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,8 @@ _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)",
> +                  dsa ? "Texture" : "");
>        return;
>     }
>
> @@ -108,7 +106,8 @@ _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)",
> +                  dsa ? "Texture" : "");
>        return;
>     }
>
> @@ -117,19 +116,55 @@ _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)",
> +                  dsa ? "Texture" : "");
>        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,
Use 3 space indentation.
> +                      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);
> +}
> diff --git a/src/mesa/main/genmipmap.h b/src/mesa/main/genmipmap.h
> index d546a8d..f4ef859 100644
> --- a/src/mesa/main/genmipmap.h
> +++ b/src/mesa/main/genmipmap.h
> @@ -28,9 +28,15 @@
>
>  #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 */
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list