[Mesa-dev] [PATCH 10/11] mesa: Add MESA_FORMAT_{A8R8G8B8, X8R8G8B8, X8B8G8R8}_SRGB

Jason Ekstrand jason at jlekstrand.net
Tue Sep 16 16:56:51 PDT 2014


Got a couple comments below.  Other than that,
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>

On Mon, Sep 15, 2014 at 11:28 PM, Dave Airlie <airlied at gmail.com> wrote:

> From: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
>
> This means that each 8888 SRGB format has a reversed counterpart,
> which is necessary for handling big-endian mesa<->gallium mappings.
>
> Signed-off-by: Richard Sandiford <rsandifo at linux.vnet.ibm.com>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/mesa/drivers/dri/i965/brw_surface_formats.c |  1 +
>  src/mesa/main/format_pack.c                     | 60
> +++++++++++++++++++++++++
>  src/mesa/main/format_unpack.c                   | 42 +++++++++++++++++
>  src/mesa/main/formats.c                         | 16 +++++++
>  src/mesa/main/formats.csv                       |  3 ++
>  src/mesa/main/formats.h                         |  3 ++
>  src/mesa/main/texformat.c                       | 10 +++++
>  src/mesa/swrast/s_texfetch.c                    |  3 ++
>  src/mesa/swrast/s_texfetch_tmp.h                | 24 ++++++++++
>  9 files changed, 162 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_surface_formats.c
> b/src/mesa/drivers/dri/i965/brw_surface_formats.c
> index b726c27..21b8adb 100644
> --- a/src/mesa/drivers/dri/i965/brw_surface_formats.c
> +++ b/src/mesa/drivers/dri/i965/brw_surface_formats.c
> @@ -517,6 +517,7 @@ brw_format_for_mesa_format(mesa_format mesa_format)
>        [MESA_FORMAT_B5G5R5X1_UNORM] = BRW_SURFACEFORMAT_B5G5R5X1_UNORM,
>        [MESA_FORMAT_R8G8B8X8_SNORM] = 0,
>        [MESA_FORMAT_R8G8B8X8_SRGB] = 0,
> +      [MESA_FORMAT_X8B8G8R8_SRGB] = 0,
>

Any particular reason you go out of your way to add X8B8G8R8_SRGB and not
the other two?


>        [MESA_FORMAT_RGBX_UINT8] = 0,
>        [MESA_FORMAT_RGBX_SINT8] = 0,
>        [MESA_FORMAT_B10G10R10X2_UNORM] =
> BRW_SURFACEFORMAT_B10G10R10X2_UNORM,
> diff --git a/src/mesa/main/format_pack.c b/src/mesa/main/format_pack.c
> index 231fd6c..15bf0e5 100644
> --- a/src/mesa/main/format_pack.c
> +++ b/src/mesa/main/format_pack.c
> @@ -1076,6 +1076,31 @@ pack_float_B8G8R8A8_SRGB(const GLfloat src[4], void
> *dst)
>  }
>
>
> +/* MESA_FORMAT_A8R8G8B8_SRGB */
> +
> +static void
> +pack_ubyte_A8R8G8B8_SRGB(const GLubyte src[4], void *dst)
> +{
> +   GLuint *d = ((GLuint *) dst);
> +   GLubyte r = util_format_linear_to_srgb_8unorm(src[RCOMP]);
> +   GLubyte g = util_format_linear_to_srgb_8unorm(src[GCOMP]);
> +   GLubyte b = util_format_linear_to_srgb_8unorm(src[BCOMP]);
> +   *d = PACK_COLOR_8888(b, g, r, src[ACOMP]);
> +}
> +
> +static void
> +pack_float_A8R8G8B8_SRGB(const GLfloat src[4], void *dst)
> +{
> +   GLuint *d = ((GLuint *) dst);
> +   GLubyte r, g, b, a;
> +   r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
> +   g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
> +   b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
> +   UNCLAMPED_FLOAT_TO_UBYTE(a, src[ACOMP]);
> +   *d = PACK_COLOR_8888(b, g, r, a);
> +}
> +
> +
>  /* MESA_FORMAT_R8G8B8A8_SRGB */
>
>  static void
> @@ -1750,6 +1775,21 @@ pack_float_R8G8B8X8_SRGB(const GLfloat src[4], void
> *dst)
>  }
>
>
> +/*
> + * MESA_FORMAT_X8B8G8R8_SRGB
> + */
> +
> +static void
> +pack_float_X8B8G8R8_SRGB(const GLfloat src[4], void *dst)
> +{
> +   GLuint *d = (GLuint *) dst;
> +   GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
> +   GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
> +   GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
> +   *d = PACK_COLOR_8888(r, g, b, 127);
>

That should be a max of 255, these aren't SNORM formats


> +}
> +
> +
>  /* MESA_FORMAT_B10G10R10X2_UNORM */
>
>  static void
> @@ -1899,6 +1939,20 @@ pack_float_B8G8R8X8_SRGB(const GLfloat src[4], void
> *dst)
>     *d = PACK_COLOR_8888(127, r, g, b);
>  }
>
> +/*
> + * MESA_FORMAT_X8R8G8B8_SRGB
> + */
> +
> +static void
> +pack_float_X8R8G8B8_SRGB(const GLfloat src[4], void *dst)
> +{
> +   GLuint *d = (GLuint *) dst;
> +   GLubyte r = util_format_linear_float_to_srgb_8unorm(src[RCOMP]);
> +   GLubyte g = util_format_linear_float_to_srgb_8unorm(src[GCOMP]);
> +   GLubyte b = util_format_linear_float_to_srgb_8unorm(src[BCOMP]);
> +   *d = PACK_COLOR_8888(b, g, r, 127);
>

Max of 255 here too


> +}
> +
>  /**
>   * Return a function that can pack a GLubyte rgba[4] color.
>   */
> @@ -1966,6 +2020,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_BGR_SRGB8] = pack_ubyte_BGR_SRGB8;
>        table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_ubyte_A8B8G8R8_SRGB;
>        table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_ubyte_B8G8R8A8_SRGB;
> +      table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_ubyte_A8R8G8B8_SRGB;
>        table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_ubyte_R8G8B8A8_SRGB;
>        table[MESA_FORMAT_L_SRGB8] = pack_ubyte_L_SRGB8;
>        table[MESA_FORMAT_L8A8_SRGB] = pack_ubyte_L8A8_SRGB;
> @@ -2040,6 +2095,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_ubyte_XRGB1555_UNORM;
>        table[MESA_FORMAT_R8G8B8X8_SNORM] = NULL;
>        table[MESA_FORMAT_R8G8B8X8_SRGB] = NULL;
> +      table[MESA_FORMAT_X8B8G8R8_SRGB] = NULL;
>        table[MESA_FORMAT_RGBX_UINT8] = NULL;
>        table[MESA_FORMAT_RGBX_SINT8] = NULL;
>        table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_ubyte_B10G10R10X2_UNORM;
> @@ -2055,6 +2111,7 @@ _mesa_get_pack_ubyte_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_R10G10B10A2_UNORM] = pack_ubyte_R10G10B10A2_UNORM;
>
>        table[MESA_FORMAT_B8G8R8X8_SRGB] = NULL;
> +      table[MESA_FORMAT_X8R8G8B8_SRGB] = NULL;
>
>        initialized = GL_TRUE;
>     }
> @@ -2131,6 +2188,7 @@ _mesa_get_pack_float_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_BGR_SRGB8] = pack_float_BGR_SRGB8;
>        table[MESA_FORMAT_A8B8G8R8_SRGB] = pack_float_A8B8G8R8_SRGB;
>        table[MESA_FORMAT_B8G8R8A8_SRGB] = pack_float_B8G8R8A8_SRGB;
> +      table[MESA_FORMAT_A8R8G8B8_SRGB] = pack_float_A8R8G8B8_SRGB;
>        table[MESA_FORMAT_R8G8B8A8_SRGB] = pack_float_R8G8B8A8_SRGB;
>        table[MESA_FORMAT_L_SRGB8] = pack_float_L_SRGB8;
>        table[MESA_FORMAT_L8A8_SRGB] = pack_float_L8A8_SRGB;
> @@ -2203,6 +2261,7 @@ _mesa_get_pack_float_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_B5G5R5X1_UNORM] = pack_float_XRGB1555_UNORM;
>        table[MESA_FORMAT_R8G8B8X8_SNORM] = pack_float_XBGR8888_SNORM;
>        table[MESA_FORMAT_R8G8B8X8_SRGB] = pack_float_R8G8B8X8_SRGB;
> +      table[MESA_FORMAT_X8B8G8R8_SRGB] = pack_float_X8B8G8R8_SRGB;
>        table[MESA_FORMAT_RGBX_UINT8] = NULL;
>        table[MESA_FORMAT_RGBX_SINT8] = NULL;
>        table[MESA_FORMAT_B10G10R10X2_UNORM] = pack_float_B10G10R10X2_UNORM;
> @@ -2221,6 +2280,7 @@ _mesa_get_pack_float_rgba_function(mesa_format
> format)
>        table[MESA_FORMAT_G16R16_SNORM] = pack_float_G16R16_SNORM;
>
>        table[MESA_FORMAT_B8G8R8X8_SRGB] = pack_float_B8G8R8X8_SRGB;
> +      table[MESA_FORMAT_X8R8G8B8_SRGB] = pack_float_X8R8G8B8_SRGB;
>
>        initialized = GL_TRUE;
>     }
> diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
> index cfa6a60..d5628a9 100644
> --- a/src/mesa/main/format_unpack.c
> +++ b/src/mesa/main/format_unpack.c
> @@ -770,6 +770,19 @@ unpack_B8G8R8A8_SRGB(const void *src, GLfloat
> dst[][4], GLuint n)
>  }
>
>  static void
> +unpack_A8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
> +{
> +   const GLuint *s = ((const GLuint *) src);
> +   GLuint i;
> +   for (i = 0; i < n; i++) {
> +      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 8) & 0xff );
> +      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 16) & 0xff );
> +      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 24) );
> +      dst[i][ACOMP] = UBYTE_TO_FLOAT( s[i] & 0xff ); /* linear! */
> +   }
> +}
> +
> +static void
>  unpack_R8G8B8A8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
>  {
>     const GLuint *s = ((const GLuint *) src);
> @@ -2132,6 +2145,19 @@ unpack_R8G8B8X8_SRGB(const void *src, GLfloat
> dst[][4], GLuint n)
>  }
>
>  static void
> +unpack_X8B8G8R8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
> +{
> +   const GLuint *s = ((const GLuint *) src);
> +   GLuint i;
> +   for (i = 0; i < n; i++) {
> +      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 24) );
> +      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 16) & 0xff );
> +      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 8) & 0xff );
> +      dst[i][ACOMP] = 1.0f;
> +   }
> +}
> +
> +static void
>  unpack_XBGR8888_UINT(const void *src, GLfloat dst[][4], GLuint n)
>  {
>     const GLbyte *s = (const GLbyte *) src;
> @@ -2326,6 +2352,19 @@ unpack_B8G8R8X8_SRGB(const void *src, GLfloat
> dst[][4], GLuint n)
>     }
>  }
>
> +static void
> +unpack_X8R8G8B8_SRGB(const void *src, GLfloat dst[][4], GLuint n)
> +{
> +   const GLuint *s = ((const GLuint *) src);
> +   GLuint i;
> +   for (i = 0; i < n; i++) {
> +      dst[i][RCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 8) & 0xff );
> +      dst[i][GCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 16) & 0xff );
> +      dst[i][BCOMP] = util_format_srgb_8unorm_to_linear_float( (s[i] >>
> 24) );
> +      dst[i][ACOMP] = 1.0F;
> +   }
> +}
> +
>  /**
>   * Return the unpacker function for the given format.
>   */
> @@ -2388,6 +2427,7 @@ get_unpack_rgba_function(mesa_format format)
>        table[MESA_FORMAT_BGR_SRGB8] = unpack_BGR_SRGB8;
>        table[MESA_FORMAT_A8B8G8R8_SRGB] = unpack_A8B8G8R8_SRGB;
>        table[MESA_FORMAT_B8G8R8A8_SRGB] = unpack_B8G8R8A8_SRGB;
> +      table[MESA_FORMAT_A8R8G8B8_SRGB] = unpack_A8R8G8B8_SRGB;
>        table[MESA_FORMAT_R8G8B8A8_SRGB] = unpack_R8G8B8A8_SRGB;
>        table[MESA_FORMAT_L_SRGB8] = unpack_L_SRGB8;
>        table[MESA_FORMAT_L8A8_SRGB] = unpack_L8A8_SRGB;
> @@ -2528,6 +2568,7 @@ get_unpack_rgba_function(mesa_format format)
>        table[MESA_FORMAT_B5G5R5X1_UNORM] = unpack_XRGB1555_UNORM;
>        table[MESA_FORMAT_R8G8B8X8_SNORM] = unpack_R8G8B8X8_SNORM;
>        table[MESA_FORMAT_R8G8B8X8_SRGB] = unpack_R8G8B8X8_SRGB;
> +      table[MESA_FORMAT_X8B8G8R8_SRGB] = unpack_X8B8G8R8_SRGB;
>        table[MESA_FORMAT_RGBX_UINT8] = unpack_XBGR8888_UINT;
>        table[MESA_FORMAT_RGBX_SINT8] = unpack_XBGR8888_SINT;
>        table[MESA_FORMAT_B10G10R10X2_UNORM] = unpack_B10G10R10X2_UNORM;
> @@ -2546,6 +2587,7 @@ get_unpack_rgba_function(mesa_format format)
>        table[MESA_FORMAT_G16R16_SNORM] = unpack_G16R16_SNORM;
>
>        table[MESA_FORMAT_B8G8R8X8_SRGB] = unpack_B8G8R8X8_SRGB;
> +      table[MESA_FORMAT_X8R8G8B8_SRGB] = unpack_X8R8G8B8_SRGB;
>
>        initialized = GL_TRUE;
>     }
> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
> index 8fd36a0..58c32e2 100644
> --- a/src/mesa/main/formats.c
> +++ b/src/mesa/main/formats.c
> @@ -357,6 +357,7 @@ _mesa_get_format_color_encoding(mesa_format 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:
> @@ -420,6 +421,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
>     case MESA_FORMAT_B8G8R8A8_SRGB:
>        format = MESA_FORMAT_B8G8R8A8_UNORM;
>        break;
> +   case MESA_FORMAT_A8R8G8B8_SRGB:
> +      format = MESA_FORMAT_A8R8G8B8_UNORM;
> +      break;
>     case MESA_FORMAT_R8G8B8A8_SRGB:
>        format = MESA_FORMAT_R8G8B8A8_UNORM;
>        break;
> @@ -447,6 +451,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
>     case MESA_FORMAT_R8G8B8X8_SRGB:
>        format = MESA_FORMAT_R8G8B8X8_UNORM;
>        break;
> +   case MESA_FORMAT_X8B8G8R8_SRGB:
> +      format = MESA_FORMAT_X8B8G8R8_UNORM;
> +      break;
>     case MESA_FORMAT_ETC2_SRGB8:
>        format = MESA_FORMAT_ETC2_RGB8;
>        break;
> @@ -462,6 +469,9 @@ _mesa_get_srgb_format_linear(mesa_format format)
>     case MESA_FORMAT_B8G8R8X8_SRGB:
>        format = MESA_FORMAT_B8G8R8X8_UNORM;
>        break;
> +   case MESA_FORMAT_X8R8G8B8_SRGB:
> +      format = MESA_FORMAT_X8R8G8B8_UNORM;
> +      break;
>     default:
>        break;
>     }
> @@ -966,6 +976,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
>        return;
>     case MESA_FORMAT_A8B8G8R8_SRGB:
>     case MESA_FORMAT_B8G8R8A8_SRGB:
> +   case MESA_FORMAT_A8R8G8B8_SRGB:
>     case MESA_FORMAT_R8G8B8A8_SRGB:
>        *datatype = GL_UNSIGNED_BYTE;
>        *comps = 4;
> @@ -1241,6 +1252,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
>        return;
>
>     case MESA_FORMAT_R8G8B8X8_SRGB:
> +   case MESA_FORMAT_X8B8G8R8_SRGB:
>     case MESA_FORMAT_RGBX_UINT8:
>        *datatype = GL_UNSIGNED_BYTE;
>        *comps = 4;
> @@ -1305,6 +1317,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
>        return;
>
>     case MESA_FORMAT_B8G8R8X8_SRGB:
> +   case MESA_FORMAT_X8R8G8B8_SRGB:
>        *datatype = GL_UNSIGNED_BYTE;
>        *comps = 4;
>        return;
> @@ -1420,6 +1433,7 @@ _mesa_format_matches_format_and_type(mesa_format
> mesa_format,
>        return GL_FALSE;
>
>     case MESA_FORMAT_A8R8G8B8_UNORM:
> +   case MESA_FORMAT_A8R8G8B8_SRGB:
>        if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8 &&
> !swapBytes)
>           return GL_TRUE;
>
> @@ -1849,6 +1863,7 @@ _mesa_format_matches_format_and_type(mesa_format
> mesa_format,
>     case MESA_FORMAT_B5G5R5X1_UNORM:
>     case MESA_FORMAT_R8G8B8X8_SNORM:
>     case MESA_FORMAT_R8G8B8X8_SRGB:
> +   case MESA_FORMAT_X8B8G8R8_SRGB:
>     case MESA_FORMAT_RGBX_UINT8:
>     case MESA_FORMAT_RGBX_SINT8:
>     case MESA_FORMAT_B10G10R10X2_UNORM:
> @@ -1875,6 +1890,7 @@ _mesa_format_matches_format_and_type(mesa_format
> mesa_format,
>           !swapBytes;
>
>     case MESA_FORMAT_B8G8R8X8_SRGB:
> +   case MESA_FORMAT_X8R8G8B8_SRGB:
>        return GL_FALSE;
>     }
>
> diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv
> index b4d16de..39bcdbd 100644
> --- a/src/mesa/main/formats.csv
> +++ b/src/mesa/main/formats.csv
> @@ -138,9 +138,12 @@ MESA_FORMAT_RGBX_SNORM16                  , array ,
> 1, 1, sn16, sn16, sn16, x16
>  # Packed sRGB formats
>  MESA_FORMAT_A8B8G8R8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , un8 , wzyx, srgb
>  MESA_FORMAT_B8G8R8A8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , un8 , zyxw, srgb
> +MESA_FORMAT_A8R8G8B8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , un8 , yzwx, srgb
>  MESA_FORMAT_B8G8R8X8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , x8  , zyx1, srgb
> +MESA_FORMAT_X8R8G8B8_SRGB                 , packed, 1, 1, x8  , un8 , un8
> , un8 , yzw1, srgb
>  MESA_FORMAT_R8G8B8A8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , un8 , xyzw, srgb
>  MESA_FORMAT_R8G8B8X8_SRGB                 , packed, 1, 1, un8 , un8 , un8
> , x8  , xyz1, srgb
> +MESA_FORMAT_X8B8G8R8_SRGB                 , packed, 1, 1, x8  , un8 , un8
> , un8 , wzy1, srgb
>  MESA_FORMAT_L8A8_SRGB                     , packed, 1, 1, un8 , un8 ,
>  ,     , xxxy, srgb
>  MESA_FORMAT_A8L8_SRGB                     , packed, 1, 1, un8 , un8 ,
>  ,     , yyyx, srgb
>
> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
> index 8671738..213ab56 100644
> --- a/src/mesa/main/formats.h
> +++ b/src/mesa/main/formats.h
> @@ -284,9 +284,12 @@ typedef enum
>     /* Packed sRGB formats */
>     MESA_FORMAT_A8B8G8R8_SRGB,    /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA
> AAAA */
>     MESA_FORMAT_B8G8R8A8_SRGB,    /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB
> BBBB */
> +   MESA_FORMAT_A8R8G8B8_SRGB,    /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA
> AAAA */
>     MESA_FORMAT_B8G8R8X8_SRGB,    /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB
> BBBB */
> +   MESA_FORMAT_X8R8G8B8_SRGB,    /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx
> xxxx */
>     MESA_FORMAT_R8G8B8A8_SRGB,    /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR
> RRRR */
>     MESA_FORMAT_R8G8B8X8_SRGB,    /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR
> RRRR */
> +   MESA_FORMAT_X8B8G8R8_SRGB,    /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx
> xxxx */
>     MESA_FORMAT_L8A8_SRGB,                            /* AAAA AAAA LLLL
> LLLL */
>     MESA_FORMAT_A8L8_SRGB,                            /* LLLL LLLL AAAA
> AAAA */
>
> diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
> index 09e307c..832e661 100644
> --- a/src/mesa/main/texformat.c
> +++ b/src/mesa/main/texformat.c
> @@ -540,6 +540,9 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum
> target,
>
>        RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_X8B8G8R8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_SRGB_ALPHA_EXT:
>     case GL_SRGB8_ALPHA8_EXT:
> @@ -547,38 +550,45 @@ _mesa_choose_tex_format(struct gl_context *ctx,
> GLenum target,
>
>        RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_SLUMINANCE_EXT:
>     case GL_SLUMINANCE8_EXT:
>        RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_SLUMINANCE_ALPHA_EXT:
>     case GL_SLUMINANCE8_ALPHA8_EXT:
>        RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_COMPRESSED_SLUMINANCE_EXT:
>        RETURN_IF_SUPPORTED(MESA_FORMAT_L_SRGB8);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
>        RETURN_IF_SUPPORTED(MESA_FORMAT_L8A8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_A8L8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_COMPRESSED_SRGB_EXT:
>        if (ctx->Mesa_DXTn)
>           RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>     case GL_COMPRESSED_SRGB_ALPHA_EXT:
>        if (ctx->Mesa_DXTn)
>           RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1,
> see spec */
>        RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB);
>        RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB);
> +      RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB);
>        break;
>
>     case GL_ALPHA8UI_EXT:
> diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
> index dfba190..0f6da91 100644
> --- a/src/mesa/swrast/s_texfetch.c
> +++ b/src/mesa/swrast/s_texfetch.c
> @@ -229,9 +229,12 @@ texfetch_funcs[] =
>     /* Packed sRGB formats */
>     FETCH_FUNCS(A8B8G8R8_SRGB),
>     FETCH_FUNCS(B8G8R8A8_SRGB),
> +   FETCH_FUNCS(A8R8G8B8_SRGB),
>     FETCH_NULL(B8G8R8X8_SRGB),
> +   FETCH_NULL(X8R8G8B8_SRGB),
>     FETCH_FUNCS(R8G8B8A8_SRGB),
>     FETCH_FUNCS(R8G8B8X8_SRGB),
> +   FETCH_FUNCS(X8B8G8R8_SRGB),
>     FETCH_FUNCS(L8A8_SRGB),
>     FETCH_FUNCS(A8L8_SRGB),
>
> diff --git a/src/mesa/swrast/s_texfetch_tmp.h
> b/src/mesa/swrast/s_texfetch_tmp.h
> index 81ae045..2873620 100644
> --- a/src/mesa/swrast/s_texfetch_tmp.h
> +++ b/src/mesa/swrast/s_texfetch_tmp.h
> @@ -769,6 +769,18 @@ FETCH(B8G8R8A8_SRGB)(const struct
> swrast_texture_image *texImage,
>
>
>  static void
> +FETCH(A8R8G8B8_SRGB)(const struct swrast_texture_image *texImage,
> +                     GLint i, GLint j, GLint k, GLfloat *texel)
> +{
> +   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
> +   texel[RCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
> +   texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
> +   texel[BCOMP] = nonlinear_to_linear( (s >> 24) );
> +   texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff ); /* linear! */
> +}
> +
> +
> +static void
>  FETCH(R8G8B8A8_SRGB)(const struct swrast_texture_image *texImage,
>                       GLint i, GLint j, GLint k, GLfloat *texel)
>  {
> @@ -793,6 +805,18 @@ FETCH(R8G8B8X8_SRGB)(const struct
> swrast_texture_image *texImage,
>
>
>  static void
> +FETCH(X8B8G8R8_SRGB)(const struct swrast_texture_image *texImage,
> +                     GLint i, GLint j, GLint k, GLfloat *texel)
> +{
> +   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
> +   texel[RCOMP] = nonlinear_to_linear( (s >> 24) );
> +   texel[GCOMP] = nonlinear_to_linear( (s >> 16) & 0xff );
> +   texel[BCOMP] = nonlinear_to_linear( (s >>  8) & 0xff );
> +   texel[ACOMP] = 1.0f;
> +}
> +
> +
> +static void
>  FETCH(L_SRGB8)(const struct swrast_texture_image *texImage,
>                 GLint i, GLint j, GLint k, GLfloat *texel)
>  {
> --
> 1.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140916/a99f512f/attachment-0001.html>


More information about the mesa-dev mailing list