[Mesa-dev] [PATCH] util/u_format: add _is_alpha()
Marek Olšák
maraeo at gmail.com
Fri Sep 12 06:07:07 PDT 2014
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Fri, Sep 12, 2014 at 2:47 PM, Rob Clark <robdclark at gmail.com> wrote:
> From: Rob Clark <robclark at freedesktop.org>
>
> Because of render-to-alpha (000x) shenanigans, freedreno needs to do
> some special handling when rendering to alpha-only formats. And I
> noticed that while we had _is_luminance(), _is_intensity(), etc, an
> _is_alpha() helper was missing. So fix that.
>
> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> ---
> src/gallium/auxiliary/util/u_format.c | 17 +++++++++++++++++
> src/gallium/auxiliary/util/u_format.h | 2 ++
> 2 files changed, 19 insertions(+)
>
> diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c
> index d53dd78..c1ce408 100644
> --- a/src/gallium/auxiliary/util/u_format.c
> +++ b/src/gallium/auxiliary/util/u_format.c
> @@ -92,6 +92,23 @@ util_format_is_luminance(enum pipe_format format)
> }
>
> boolean
> +util_format_is_alpha(enum pipe_format format)
> +{
> + const struct util_format_description *desc =
> + util_format_description(format);
> +
> + if ((desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB ||
> + desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) &&
> + desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_0 &&
> + desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_0 &&
> + desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_0 &&
> + desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) {
> + return TRUE;
> + }
> + return FALSE;
> +}
> +
> +boolean
> util_format_is_pure_integer(enum pipe_format format)
> {
> const struct util_format_description *desc = util_format_description(format);
> diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
> index df31400..621574c 100644
> --- a/src/gallium/auxiliary/util/u_format.h
> +++ b/src/gallium/auxiliary/util/u_format.h
> @@ -661,6 +661,8 @@ util_format_has_alpha(enum pipe_format format);
> boolean
> util_format_is_luminance(enum pipe_format format);
>
> +boolean
> +util_format_is_alpha(enum pipe_format format);
>
> boolean
> util_format_is_luminance_alpha(enum pipe_format format);
> --
> 1.9.3
>
> _______________________________________________
> 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