[Mesa-dev] [RFC v2 08/15] mesa/formats: store whether or not a format is sRGB in gl_format_info

Anuj Phogat anuj.phogat at gmail.com
Tue Jun 2 14:25:14 PDT 2015


On Mon, Jun 1, 2015 at 10:13 AM, Nanley Chery <nanleychery at gmail.com> wrote:
> From: Nanley Chery <nanley.g.chery at intel.com>
>
> v2: remove extra newline.
>
> Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
> ---
>  src/mesa/main/format_info.py |  2 ++
>  src/mesa/main/formats.c      | 28 ++++------------------------
>  2 files changed, 6 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
> index 40104a2..8134e8e 100644
> --- a/src/mesa/main/format_info.py
> +++ b/src/mesa/main/format_info.py
> @@ -191,6 +191,8 @@ for fmat in formats:
>     bits = [ get_channel_bits(fmat, name) for name in ['l', 'i', 'z', 's']]
>     print '      {0},'.format(', '.join(map(str, bits)))
>
> +   print '      {0:d},'.format(fmat.colorspace == 'srgb')
> +
>     print '      {0}, {1}, {2},'.format(fmat.block_width, fmat.block_height,
>                                         int(fmat.block_size() / 8))
>
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index 25606f9..1edfec8 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -65,6 +65,8 @@ struct gl_format_info
>     GLubyte DepthBits;
>     GLubyte StencilBits;
>
> +   GLboolean IsSRGBFormat;
> +
>     /**
>      * To describe compressed formats.  If not compressed, Width=Height=1.
>      */
> @@ -542,30 +544,8 @@ _mesa_is_format_color_format(mesa_format format)
>  GLenum
>  _mesa_get_format_color_encoding(mesa_format format)
>  {
> -   /* XXX this info should be encoded in gl_format_info */
> -   switch (format) {
> -   case MESA_FORMAT_BGR_SRGB8:
> -   case MESA_FORMAT_A8B8G8R8_SRGB:
> -   case MESA_FORMAT_B8G8R8A8_SRGB:
> -   case MESA_FORMAT_A8R8G8B8_SRGB:
> -   case MESA_FORMAT_R8G8B8A8_SRGB:
> -   case MESA_FORMAT_L_SRGB8:
> -   case MESA_FORMAT_L8A8_SRGB:
> -   case MESA_FORMAT_A8L8_SRGB:
> -   case MESA_FORMAT_SRGB_DXT1:
> -   case MESA_FORMAT_SRGBA_DXT1:
> -   case MESA_FORMAT_SRGBA_DXT3:
> -   case MESA_FORMAT_SRGBA_DXT5:
> -   case MESA_FORMAT_R8G8B8X8_SRGB:
> -   case MESA_FORMAT_ETC2_SRGB8:
> -   case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC:
> -   case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
> -   case MESA_FORMAT_B8G8R8X8_SRGB:
> -   case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
> -      return GL_SRGB;
> -   default:
> -      return GL_LINEAR;
> -   }
> +   const struct gl_format_info *info = _mesa_get_format_info(format);
> +   return info->IsSRGBFormat ? GL_SRGB : GL_LINEAR;
>  }
>
>
> --
> 2.4.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list