[Mesa-dev] [PATCH 08/14] mesa: Add a helper function _mesa_unpack_format_to_base_format()
Iago Toral
itoral at igalia.com
Tue Jul 21 01:06:18 PDT 2015
On Tue, 2015-06-16 at 11:15 -0700, Anuj Phogat wrote:
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
> src/mesa/main/glformats.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> src/mesa/main/glformats.h | 3 +++
> 2 files changed, 47 insertions(+)
>
> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
> index ac69fab..cac243c 100644
> --- a/src/mesa/main/glformats.c
> +++ b/src/mesa/main/glformats.c
> @@ -1278,6 +1278,50 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format)
> }
> }
>
> +/**
> + * Convert various unpack formats to the corresponding base format.
> + */
> +GLenum
> +_mesa_unpack_format_to_base_format(GLenum format)
> +{
> + switch(format) {
> + case GL_RED_INTEGER:
> + return GL_RED;
> + case GL_GREEN_INTEGER:
> + return GL_GREEN;
> + case GL_BLUE_INTEGER:
> + return GL_BLUE;
> + case GL_RG_INTEGER:
> + return GL_RG;
> + case GL_RGB_INTEGER:
> + return GL_RGB;
> + case GL_RGBA_INTEGER:
> + return GL_RGBA;
> + case GL_BGR_INTEGER:
> + return GL_BGR;
> + case GL_BGRA_INTEGER:
> + return GL_BGRA;
> + case GL_ALPHA_INTEGER:
> + return GL_ALPHA;
I would probably move the GL_ALPHA_INTEGER case together with the other
single component formats, at first I thought you had missed it. Either
way:
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
> + case GL_LUMINANCE_INTEGER_EXT:
> + return GL_LUMINANCE;
> + case GL_LUMINANCE_ALPHA_INTEGER_EXT:
> + return GL_LUMINANCE_ALPHA;
> + case GL_RED:
> + case GL_GREEN:
> + case GL_BLUE:
> + case GL_RG:
> + case GL_RGB:
> + case GL_RGBA:
> + case GL_BGR:
> + case GL_BGRA:
> + case GL_ALPHA:
> + case GL_LUMINANCE:
> + case GL_LUMINANCE_ALPHA:
> + default:
> + return format;
> + }
> +}
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
> /**
> * Convert various base formats to the cooresponding integer format.
> diff --git a/src/mesa/main/glformats.h b/src/mesa/main/glformats.h
> index 8881cb7..419955a 100644
> --- a/src/mesa/main/glformats.h
> +++ b/src/mesa/main/glformats.h
> @@ -101,6 +101,9 @@ _mesa_is_compressed_format(const struct gl_context *ctx, GLenum format);
> extern GLenum
> _mesa_base_format_to_integer_format(GLenum format);
>
> +extern GLenum
> +_mesa_unpack_format_to_base_format(GLenum format);
> +
> extern GLboolean
> _mesa_base_format_has_channel(GLenum base_format, GLenum pname);
>
More information about the mesa-dev
mailing list