[Mesa-dev] [PATCH 1/2] mesa/formats: add some formats from GL3.3

Marek Olšák maraeo at gmail.com
Thu Jul 30 01:34:36 PDT 2015


That said, it looks like the packing code has changed a lot since I
last worked with it, so I don't know.

Marek

On Thu, Jul 30, 2015 at 10:06 AM, Marek Olšák <maraeo at gmail.com> wrote:
> The spec only says we should support packing to and unpacking from
> 332, 565, 4444, 5551, but it doesn't specify any INTERNAL formats for
> those, so no new formats need to be added to Mesa. I guess the packing
> formats are only supported for convenience.
>
> Marek
>
> On Thu, Jul 30, 2015 at 3:48 AM, Dave Airlie <airlied at gmail.com> wrote:
>> From: Dave Airlie <airlied at redhat.com>
>>
>> GL3.3 added GL_ARB_texture_rgb10_a2ui, which specifies
>> a lot more things than just rgb10/a2ui.
>>
>> While playing with ogl conform one of the tests must
>> attempted all valid formats for GL3.3 and hits the
>> unreachable here.
>>
>> This adds the first chunk of formats that hit the
>> assert.
>>
>> Signed-off-by: Dave Airlie <airlied at redhat.com>
>> ---
>>  src/mesa/main/formats.c   | 63 +++++++++++++++++++++++++++++++++++++++++++++++
>>  src/mesa/main/formats.csv | 12 +++++++++
>>  src/mesa/main/formats.h   | 12 +++++++++
>>  src/mesa/main/glformats.c | 24 ++++++++++++++++++
>>  4 files changed, 111 insertions(+)
>>
>> diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
>> index baeb1bf..872f18b 100644
>> --- a/src/mesa/main/formats.c
>> +++ b/src/mesa/main/formats.c
>> @@ -1008,6 +1008,8 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>        return;
>>     case MESA_FORMAT_B5G6R5_UNORM:
>>     case MESA_FORMAT_R5G6B5_UNORM:
>> +   case MESA_FORMAT_B5G6R5_UINT:
>> +   case MESA_FORMAT_R5G6B5_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_5_6_5;
>>        *comps = 3;
>>        return;
>> @@ -1015,6 +1017,8 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>     case MESA_FORMAT_B4G4R4A4_UNORM:
>>     case MESA_FORMAT_A4R4G4B4_UNORM:
>>     case MESA_FORMAT_B4G4R4X4_UNORM:
>> +   case MESA_FORMAT_B4G4R4A4_UINT:
>> +   case MESA_FORMAT_A4R4G4B4_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
>>        *comps = 4;
>>        return;
>> @@ -1022,6 +1026,8 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>     case MESA_FORMAT_B5G5R5A1_UNORM:
>>     case MESA_FORMAT_A1R5G5B5_UNORM:
>>     case MESA_FORMAT_B5G5R5X1_UNORM:
>> +   case MESA_FORMAT_B5G5R5A1_UINT:
>> +   case MESA_FORMAT_A1R5G5B5_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
>>        *comps = 4;
>>        return;
>> @@ -1032,6 +1038,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>        return;
>>
>>     case MESA_FORMAT_A1B5G5R5_UNORM:
>> +   case MESA_FORMAT_A1B5G5R5_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_5_5_5_1;
>>        *comps = 4;
>>        return;
>> @@ -1066,19 +1073,23 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>        return;
>>
>>     case MESA_FORMAT_R3G3B2_UNORM:
>> +   case MESA_FORMAT_R3G3B2_UINT:
>>        *datatype = GL_UNSIGNED_BYTE_2_3_3_REV;
>>        *comps = 3;
>>        return;
>>     case MESA_FORMAT_A4B4G4R4_UNORM:
>> +   case MESA_FORMAT_A4B4G4R4_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
>>        *comps = 4;
>>        return;
>>
>>     case MESA_FORMAT_R4G4B4A4_UNORM:
>> +   case MESA_FORMAT_R4G4B4A4_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
>>        *comps = 4;
>>        return;
>>     case MESA_FORMAT_R5G5B5A1_UNORM:
>> +   case MESA_FORMAT_R5G5B5A1_UINT:
>>        *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
>>        *comps = 4;
>>        return;
>> @@ -1094,6 +1105,7 @@ _mesa_format_to_type_and_comps(mesa_format format,
>>        return;
>>
>>     case MESA_FORMAT_B2G3R3_UNORM:
>> +   case MESA_FORMAT_B2G3R3_UINT:
>>        *datatype = GL_UNSIGNED_BYTE_3_3_2;
>>        *comps = 3;
>>        return;
>> @@ -2123,6 +2135,57 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
>>                type == GL_UNSIGNED_INT_2_10_10_10_REV &&
>>                !swapBytes);
>>
>> +   case MESA_FORMAT_B5G6R5_UINT:
>> +      return format == GL_RGB_INTEGER && type == GL_UNSIGNED_SHORT_5_6_5;
>> +
>> +   case MESA_FORMAT_R5G6B5_UINT:
>> +      return format == GL_RGB_INTEGER && type == GL_UNSIGNED_SHORT_5_6_5_REV;
>> +
>> +   case MESA_FORMAT_B2G3R3_UINT:
>> +      return format == GL_RGB_INTEGER && type == GL_UNSIGNED_BYTE_3_3_2;
>> +
>> +   case MESA_FORMAT_R3G3B2_UINT:
>> +      return format == GL_RGB_INTEGER && type == GL_UNSIGNED_BYTE_2_3_3_REV;
>> +
>> +   case MESA_FORMAT_A4B4G4R4_UINT:
>> +      if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_4_4_4_4 && !swapBytes)
>> +         return GL_TRUE;
>> +
>> +      if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && swapBytes)
>> +         return GL_TRUE;
>> +      return GL_FALSE;
>> +
>> +   case MESA_FORMAT_R4G4B4A4_UINT:
>> +      if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && !swapBytes)
>> +         return GL_TRUE;
>> +
>> +      if (format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_4_4_4_4 && swapBytes)
>> +         return GL_TRUE;
>> +
>> +      return GL_FALSE;
>> +
>> +   case MESA_FORMAT_B4G4R4A4_UINT:
>> +      return format == GL_BGRA_INTEGER && type == GL_UNSIGNED_SHORT_4_4_4_4_REV &&
>> +         !swapBytes;
>> +
>> +   case MESA_FORMAT_A4R4G4B4_UINT:
>> +      return GL_FALSE;
>> +
>> +   case MESA_FORMAT_A1B5G5R5_UINT:
>> +      return format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_5_5_5_1 &&
>> +         !swapBytes;
>> +
>> +   case MESA_FORMAT_B5G5R5A1_UINT:
>> +      return format == GL_BGRA_INTEGER && type == GL_UNSIGNED_SHORT_1_5_5_5_REV &&
>> +         !swapBytes;
>> +
>> +   case MESA_FORMAT_A1R5G5B5_UINT:
>> +      return format == GL_BGRA_INTEGER && type == GL_UNSIGNED_SHORT_5_5_5_1 &&
>> +         !swapBytes;
>> +
>> +   case MESA_FORMAT_R5G5B5A1_UINT:
>> +      return format == GL_RGBA_INTEGER && type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
>> +
>>     case MESA_FORMAT_R9G9B9E5_FLOAT:
>>        return format == GL_RGB && type == GL_UNSIGNED_INT_5_9_9_9_REV &&
>>           !swapBytes;
>> diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv
>> index e159e7d..d30b0a9 100644
>> --- a/src/mesa/main/formats.csv
>> +++ b/src/mesa/main/formats.csv
>> @@ -190,6 +190,18 @@ MESA_FORMAT_B10G10R10A2_UINT              , packed, 1, 1, u10 , u10 , u10 , u2
>>  MESA_FORMAT_R10G10B10A2_UINT              , packed, 1, 1, u10 , u10 , u10 , u2  , xyzw, rgb
>>  MESA_FORMAT_A2B10G10R10_UINT              , packed, 1, 1, u2  , u10 , u10 , u10 , wzyx, rgb
>>  MESA_FORMAT_A2R10G10B10_UINT              , packed, 1, 1, u2  , u10 , u10 , u10 , yzwx, rgb
>> +MESA_FORMAT_B5G6R5_UINT                   , packed, 1, 1, u5  , u6  ,  u5 ,     , zyx1, rgb
>> +MESA_FORMAT_R5G6B5_UINT                   , packed, 1, 1, u5  , u6  ,  u5 ,     , xyz1, rgb
>> +MESA_FORMAT_B2G3R3_UINT                   , packed, 1, 1, u2  , u3  ,  u3 ,     , zyx1, rgb
>> +MESA_FORMAT_R3G3B2_UINT                   , packed, 1, 1, u3  , u3  ,  u2 ,     , xyz1, rgb
>> +MESA_FORMAT_A4B4G4R4_UINT                 , packed, 1, 1, u4  , u4  ,  u4 , u4  , wzyx, rgb
>> +MESA_FORMAT_R4G4B4A4_UINT                 , packed, 1, 1, u4  , u4  ,  u4 , u4  , xyzw, rgb
>> +MESA_FORMAT_B4G4R4A4_UINT                 , packed, 1, 1, u4  , u4  ,  u4 , u4  , zyxw, rgb
>> +MESA_FORMAT_A4R4G4B4_UINT                 , packed, 1, 1, u4  , u4  ,  u4 , u4  , yzwx, rgb
>> +MESA_FORMAT_A1B5G5R5_UINT                 , packed, 1, 1, u1  , u5  ,  u5 , u5  , wzyx, rgb
>> +MESA_FORMAT_B5G5R5A1_UINT                 , packed, 1, 1, u5  , u5  ,  u5 , u1  , zyxw, rgb
>> +MESA_FORMAT_A1R5G5B5_UINT                 , packed, 1, 1, u1  , u5  ,  u5 , u5  , yzwx, rgb
>> +MESA_FORMAT_R5G5B5A1_UINT                 , packed, 1, 1, u5  , u5  ,  u5 , u1  , xyzw, rgb
>>
>>  # Array signed/unsigned non-normalized integer formats
>>  MESA_FORMAT_A_UINT8                       , array , 1, 1, u8  ,     ,     ,     , 000x, rgb
>> diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
>> index 7e451ca..766c839 100644
>> --- a/src/mesa/main/formats.h
>> +++ b/src/mesa/main/formats.h
>> @@ -463,6 +463,18 @@ typedef enum
>>     MESA_FORMAT_R10G10B10A2_UINT, /* AABB BBBB BBBB GGGG GGGG GGRR RRRR RRRR */
>>     MESA_FORMAT_A2B10G10R10_UINT, /* RRRR RRRR RRGG GGGG GGGG BBBB BBBB BBAA */
>>     MESA_FORMAT_A2R10G10B10_UINT, /* BBBB BBBB BBGG GGGG GGGG RRRR RRRR RRAA */
>> +   MESA_FORMAT_B5G6R5_UINT,                          /* RRRR RGGG GGGB BBBB */
>> +   MESA_FORMAT_R5G6B5_UINT,                          /* BBBB BGGG GGGR RRRR */
>> +   MESA_FORMAT_B2G3R3_UINT,                                    /* RRRG GGBB */
>> +   MESA_FORMAT_R3G3B2_UINT,                                    /* BBGG GRRR */
>> +   MESA_FORMAT_A4B4G4R4_UINT,                        /* RRRR GGGG BBBB AAAA */
>> +   MESA_FORMAT_R4G4B4A4_UINT,                        /* AAAA BBBB GGGG RRRR */
>> +   MESA_FORMAT_B4G4R4A4_UINT,                        /* AAAA RRRR GGGG BBBB */
>> +   MESA_FORMAT_A4R4G4B4_UINT,                        /* BBBB GGGG RRRR AAAA */
>> +   MESA_FORMAT_A1B5G5R5_UINT,                        /* RRRR RGGG GGBB BBBA */
>> +   MESA_FORMAT_B5G5R5A1_UINT,                        /* ARRR RRGG GGGB BBBB */
>> +   MESA_FORMAT_A1R5G5B5_UINT,                        /* BBBB BGGG GGRR RRRA */
>> +   MESA_FORMAT_R5G5B5A1_UINT,                        /* ABBB BBGG GGGR RRRR */
>>
>>     /* Array signed/unsigned non-normalized integer formats */
>>     MESA_FORMAT_A_UINT8,
>> diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
>> index c3fd734..d1c7970 100644
>> --- a/src/mesa/main/glformats.c
>> +++ b/src/mesa/main/glformats.c
>> @@ -2726,12 +2726,16 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
>>           return MESA_FORMAT_B5G6R5_UNORM;
>>        else if (format == GL_BGR)
>>           return MESA_FORMAT_R5G6B5_UNORM;
>> +      else if (format == GL_RGB_INTEGER)
>> +         return MESA_FORMAT_B5G6R5_UINT;
>>        break;
>>     case GL_UNSIGNED_SHORT_5_6_5_REV:
>>        if (format == GL_RGB)
>>           return MESA_FORMAT_R5G6B5_UNORM;
>>        else if (format == GL_BGR)
>>           return MESA_FORMAT_B5G6R5_UNORM;
>> +      else if (format == GL_RGB_INTEGER)
>> +         return MESA_FORMAT_R5G6B5_UINT;
>>        break;
>>     case GL_UNSIGNED_SHORT_4_4_4_4:
>>        if (format == GL_RGBA)
>> @@ -2740,6 +2744,10 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
>>           return MESA_FORMAT_A4R4G4B4_UNORM;
>>        else if (format == GL_ABGR_EXT)
>>           return MESA_FORMAT_R4G4B4A4_UNORM;
>> +      else if (format == GL_RGBA_INTEGER)
>> +         return MESA_FORMAT_A4B4G4R4_UINT;
>> +      else if (format == GL_BGRA_INTEGER)
>> +         return MESA_FORMAT_A4R4G4B4_UINT;
>>        break;
>>     case GL_UNSIGNED_SHORT_4_4_4_4_REV:
>>        if (format == GL_RGBA)
>> @@ -2748,26 +2756,42 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
>>           return MESA_FORMAT_B4G4R4A4_UNORM;
>>        else if (format == GL_ABGR_EXT)
>>           return MESA_FORMAT_A4B4G4R4_UNORM;
>> +      else if (format == GL_RGBA_INTEGER)
>> +         return MESA_FORMAT_R4G4B4A4_UINT;
>> +      else if (format == GL_BGRA_INTEGER)
>> +         return MESA_FORMAT_B4G4R4A4_UINT;
>>        break;
>>     case GL_UNSIGNED_SHORT_5_5_5_1:
>>        if (format == GL_RGBA)
>>           return MESA_FORMAT_A1B5G5R5_UNORM;
>>        else if (format == GL_BGRA)
>>           return MESA_FORMAT_A1R5G5B5_UNORM;
>> +      else if (format == GL_RGBA_INTEGER)
>> +         return MESA_FORMAT_A1B5G5R5_UINT;
>> +      else if (format == GL_BGRA_INTEGER)
>> +         return MESA_FORMAT_A1R5G5B5_UINT;
>>        break;
>>     case GL_UNSIGNED_SHORT_1_5_5_5_REV:
>>        if (format == GL_RGBA)
>>           return MESA_FORMAT_R5G5B5A1_UNORM;
>>        else if (format == GL_BGRA)
>>           return MESA_FORMAT_B5G5R5A1_UNORM;
>> +      else if (format == GL_RGBA_INTEGER)
>> +         return MESA_FORMAT_R5G5B5A1_UINT;
>> +      else if (format == GL_BGRA_INTEGER)
>> +         return MESA_FORMAT_B5G5R5A1_UINT;
>>        break;
>>     case GL_UNSIGNED_BYTE_3_3_2:
>>        if (format == GL_RGB)
>>           return MESA_FORMAT_B2G3R3_UNORM;
>> +      else if (format == GL_RGB_INTEGER)
>> +         return MESA_FORMAT_B2G3R3_UINT;
>>        break;
>>     case GL_UNSIGNED_BYTE_2_3_3_REV:
>>        if (format == GL_RGB)
>>           return MESA_FORMAT_R3G3B2_UNORM;
>> +      else if (format == GL_RGB_INTEGER)
>> +         return MESA_FORMAT_R3G3B2_UINT;
>>        break;
>>     case GL_UNSIGNED_INT_5_9_9_9_REV:
>>        if (format == GL_RGB)
>> --
>> 2.4.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