[Mesa-dev] [PATCH 1/3] mesa: don't use _mesa_base_tex_format for format parameter of GetTexImage

Brian Paul brian.e.paul at gmail.com
Thu Feb 7 08:26:40 PST 2013


On Thu, Feb 7, 2013 at 7:06 AM, Marek Olšák <maraeo at gmail.com> wrote:
> _mesa_base_tex_format doesn't accept GL_BGR and GL_ABGR_EXT, etc.
>
> v2: add a (now hopefully complete) helper function to deal with this
>
> NOTE: This is a candidate for the stable branches.
> ---
>  src/mesa/main/texgetimage.c |   33 ++++++++++++++++++++++++++++++++-
>  1 file changed, 32 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c
> index 3a550d9..6240054 100644
> --- a/src/mesa/main/texgetimage.c
> +++ b/src/mesa/main/texgetimage.c
> @@ -310,6 +310,37 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions,
>  }
>
>

I'd put  a comment on this function to the effect of "return a base GL
format given the user-requested format for glGetTexImage()."


> +static GLenum
> +_mesa_base_pack_format(GLenum format)
> +{
> +   switch (format) {
> +   case GL_ABGR_EXT:
> +   case GL_BGRA:
> +   case GL_BGRA_INTEGER:
> +   case GL_RGBA_INTEGER:
> +      return GL_RGBA;
> +   case GL_BGR:
> +   case GL_BGR_INTEGER:
> +   case GL_RGB_INTEGER:
> +      return GL_RGB;
> +   case GL_RED_INTEGER:
> +      return GL_RED;
> +   case GL_GREEN_INTEGER:
> +      return GL_GREEN;
> +   case GL_BLUE_INTEGER:
> +      return GL_BLUE;
> +   case GL_ALPHA_INTEGER:
> +      return GL_ALPHA;
> +   case GL_LUMINANCE_INTEGER_EXT:
> +      return GL_LUMINANCE;
> +   case GL_LUMINANCE_ALPHA_INTEGER_EXT:
> +      return GL_LUMINANCE_ALPHA;
> +   default:
> +      return format;
> +   }
> +}
> +
> +
>  /**
>   * Get an uncompressed color texture image.
>   */
> @@ -323,7 +354,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
>     const gl_format texFormat =
>        _mesa_get_srgb_format_linear(texImage->TexFormat);
>     const GLuint width = texImage->Width;
> -   const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format);
> +   GLenum destBaseFormat = _mesa_base_pack_format(format);
>     GLenum rebaseFormat = GL_NONE;
>     GLuint height = texImage->Height;
>     GLuint depth = texImage->Depth;

Otherwise, the series looks good.

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the mesa-dev mailing list