[Mesa-dev] [PATCH v2 29/29] mesa: restrict use of GL_ABGR_EXT format to allowed data types

Iago Toral Quiroga itoral at igalia.com
Mon Dec 1 03:05:22 PST 2014


From: Samuel Iglesias Gonsalvez <siglesias at igalia.com>

GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_SHORT_1_5_5_5_REV,
GL_UNSIGNED_INT_10_10_10_2, GL_UNSIGNED_INT_2_10_10_10_REV data types
are not explicitly allowed to work with GL_ABGR_EXT format neither
in GL nor GL_EXT_abgr specs.

Removed the corresponding mesa formats as there are no other functions
using them inside Mesa anymore.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias at igalia.com>
---
 src/mesa/main/formats.c      | 28 --------------------
 src/mesa/main/formats.csv    |  4 ---
 src/mesa/main/formats.h      |  5 ----
 src/mesa/main/glformats.c    | 61 +++++++++++++++++++++++++++++++++-----------
 src/mesa/swrast/s_texfetch.c |  4 ---
 5 files changed, 46 insertions(+), 56 deletions(-)

diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 87f6bf1..e2e58fc 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1023,18 +1023,10 @@ _mesa_format_to_type_and_comps(mesa_format format,
       *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
       *comps = 4;
       return;
-   case MESA_FORMAT_R1G5B5A5_UNORM:
-      *datatype = GL_UNSIGNED_SHORT_5_5_5_1;
-      *comps = 4;
-      return;
    case MESA_FORMAT_R5G5B5A1_UNORM:
       *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
       *comps = 4;
       return;
-   case MESA_FORMAT_A5B5G5R1_UNORM:
-      *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
-      *comps = 4;
-      return;
    case MESA_FORMAT_A2B10G10R10_UNORM:
    case MESA_FORMAT_A2B10G10R10_UINT:
       *datatype = GL_UNSIGNED_INT_10_10_10_2;
@@ -1045,14 +1037,6 @@ _mesa_format_to_type_and_comps(mesa_format format,
       *datatype = GL_UNSIGNED_INT_10_10_10_2;
       *comps = 4;
       return;
-   case MESA_FORMAT_R2G10B10A10_UNORM:
-      *datatype = GL_UNSIGNED_INT_10_10_10_2;
-      *comps = 4;
-      return;
-   case MESA_FORMAT_A10B10G10R2_UNORM:
-      *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
-      *comps = 4;
-      return;
 
    case MESA_FORMAT_B2G3R3_UNORM:
       *datatype = GL_UNSIGNED_BYTE_3_3_2;
@@ -1731,15 +1715,9 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
 
       return GL_FALSE;
 
-   case MESA_FORMAT_R1G5B5A5_UNORM:
-      return format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_5_5_5_1;
-
    case MESA_FORMAT_R5G5B5A1_UNORM:
       return format == GL_RGBA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
 
-   case MESA_FORMAT_A5B5G5R1_UNORM:
-      return format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_1_5_5_5_REV;
-
    case MESA_FORMAT_A2B10G10R10_UNORM:
       return format == GL_RGBA && type == GL_UNSIGNED_INT_10_10_10_2;
 
@@ -1752,12 +1730,6 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
    case MESA_FORMAT_A2R10G10B10_UINT:
       return format == GL_BGRA_INTEGER_EXT && type == GL_UNSIGNED_INT_10_10_10_2;
 
-   case MESA_FORMAT_R2G10B10A10_UNORM:
-      return format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_10_10_10_2;
-
-   case MESA_FORMAT_A10B10G10R2_UNORM:
-      return format == GL_ABGR_EXT && type == GL_UNSIGNED_INT_2_10_10_10_REV;
-
    case MESA_FORMAT_A_UNORM8:
       return format == GL_ALPHA && type == GL_UNSIGNED_BYTE;
    case MESA_FORMAT_A_UNORM16:
diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv
index 09fc9b3..15d82aa 100644
--- a/src/mesa/main/formats.csv
+++ b/src/mesa/main/formats.csv
@@ -91,13 +91,9 @@ MESA_FORMAT_Z24_UNORM_X8_UINT             , packed, 1, 1, x8  , un24,     ,
 MESA_FORMAT_R3G3B2_UNORM                  , packed, 1, 1, un3 , un3 , un2 ,     , xyz1, rgb
 MESA_FORMAT_A4B4G4R4_UNORM                , packed, 1, 1, un4 , un4 , un4 , un4 , wzyx, rgb
 MESA_FORMAT_R4G4B4A4_UNORM                , packed, 1, 1, un4 , un4 , un4 , un4 , xyzw, rgb
-MESA_FORMAT_R1G5B5A5_UNORM                , packed, 1, 1, un1 , un5 , un5 , un5 , xyzw, rgb
 MESA_FORMAT_R5G5B5A1_UNORM                , packed, 1, 1, un5 , un5 , un5 , un1 , xyzw, rgb
-MESA_FORMAT_A5B5G5R1_UNORM                , packed, 1, 1, un5 , un5 , un5 , un1 , wzyx, rgb
 MESA_FORMAT_A2B10G10R10_UNORM             , packed, 1, 1, un2 , un10, un10, un10, wzyx, rgb
 MESA_FORMAT_A2R10G10B10_UNORM             , packed, 1, 1, un2 , un10, un10, un10, yzwx, rgb
-MESA_FORMAT_R2G10B10A10_UNORM             , packed, 1, 1, un2 , un10, un10, un10, xyzw, rgb
-MESA_FORMAT_A10B10G10R2_UNORM             , packed, 1, 1, un10, un10, un10, un2 , wzyx, rgb
 
 MESA_FORMAT_YCBCR                         , other , 1, 1, x16 ,     ,     ,     , xyzw, yuv
 MESA_FORMAT_YCBCR_REV                     , other , 1, 1, x16 ,     ,     ,     , xyzw, yuv
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 944c410..a95df2a 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -292,14 +292,9 @@ typedef enum
    MESA_FORMAT_R3G3B2_UNORM,                                   /* BBGG GRRR */
    MESA_FORMAT_A4B4G4R4_UNORM,                       /* RRRR GGGG BBBB AAAA */
    MESA_FORMAT_R4G4B4A4_UNORM,                       /* AAAA BBBB GGGG RRRR */
-   MESA_FORMAT_R1G5B5A5_UNORM,                       /* AAAA ABBB BBGG GGGR */
    MESA_FORMAT_R5G5B5A1_UNORM,                       /* ABBB BBGG GGGR RRRR */
-   MESA_FORMAT_A5B5G5R1_UNORM,                       /* RGGG GGBB BBBA AAAA */
    MESA_FORMAT_A2B10G10R10_UNORM,/* RRRR RRRR RRGG GGGG GGGG BBBB BBBB BBAA */
    MESA_FORMAT_A2R10G10B10_UNORM,/* BBBB BBBB BBGG GGGG GGGG RRRR RRRR RRAA */
-   MESA_FORMAT_R2G10B10A10_UNORM,/* AAAA AAAA AABB BBBB BBBB GGGG GGGG GGRR */
-   MESA_FORMAT_A10B10G10R2_UNORM,/* RRGG GGGG GGGG BBBB BBBB BBAA AAAA AAAA */
-
 
    MESA_FORMAT_YCBCR,            /*                     YYYY YYYY UorV UorV */
    MESA_FORMAT_YCBCR_REV,        /*                     UorV UorV YYYY YYYY */
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index d3ea749..b6bb2ab 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -258,18 +258,29 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
          return -1;  /* error */
    case GL_UNSIGNED_SHORT_4_4_4_4:
    case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+      if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+          format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
+         return sizeof(GLushort);
+      else
+         return -1;
    case GL_UNSIGNED_SHORT_5_5_5_1:
    case GL_UNSIGNED_SHORT_1_5_5_5_REV:
-      if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+      if (format == GL_RGBA || format == GL_BGRA ||
           format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT)
          return sizeof(GLushort);
       else
          return -1;
    case GL_UNSIGNED_INT_8_8_8_8:
    case GL_UNSIGNED_INT_8_8_8_8_REV:
+      if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+          format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT ||
+          format == GL_RGB)
+         return sizeof(GLuint);
+      else
+         return -1;
    case GL_UNSIGNED_INT_10_10_10_2:
    case GL_UNSIGNED_INT_2_10_10_10_REV:
-      if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT ||
+      if (format == GL_RGBA || format == GL_BGRA ||
           format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT ||
           format == GL_RGB)
          return sizeof(GLuint);
@@ -1403,12 +1414,8 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
 
    case GL_UNSIGNED_SHORT_4_4_4_4:
    case GL_UNSIGNED_SHORT_4_4_4_4_REV:
-   case GL_UNSIGNED_SHORT_5_5_5_1:
-   case GL_UNSIGNED_SHORT_1_5_5_5_REV:
    case GL_UNSIGNED_INT_8_8_8_8:
    case GL_UNSIGNED_INT_8_8_8_8_REV:
-   case GL_UNSIGNED_INT_10_10_10_2:
-   case GL_UNSIGNED_INT_2_10_10_10_REV:
       if (format == GL_RGBA ||
           format == GL_BGRA ||
           format == GL_ABGR_EXT) {
@@ -1418,6 +1425,20 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
           ctx->Extensions.ARB_texture_rgb10_a2ui) {
          break; /* OK */
       }
+      return GL_INVALID_OPERATION;
+
+   case GL_UNSIGNED_SHORT_5_5_5_1:
+   case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+   case GL_UNSIGNED_INT_10_10_10_2:
+   case GL_UNSIGNED_INT_2_10_10_10_REV:
+      if (format == GL_RGBA ||
+          format == GL_BGRA) {
+         break; /* OK */
+      }
+      if ((format == GL_RGBA_INTEGER_EXT || format == GL_BGRA_INTEGER_EXT) &&
+          ctx->Extensions.ARB_texture_rgb10_a2ui) {
+         break; /* OK */
+      }
       if (type == GL_UNSIGNED_INT_2_10_10_10_REV && format == GL_RGB &&
           ctx->API == API_OPENGLES2) {
          break; /* OK by GL_EXT_texture_type_2_10_10_10_REV */
@@ -1561,7 +1582,6 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
 
       case GL_RGBA:
       case GL_BGRA:
-      case GL_ABGR_EXT:
          switch (type) {
             case GL_BYTE:
             case GL_UNSIGNED_BYTE:
@@ -1584,6 +1604,25 @@ _mesa_error_check_format_and_type(const struct gl_context *ctx,
                return GL_INVALID_ENUM;
          }
 
+      case GL_ABGR_EXT:
+         switch (type) {
+            case GL_BYTE:
+            case GL_UNSIGNED_BYTE:
+            case GL_SHORT:
+            case GL_UNSIGNED_SHORT:
+            case GL_INT:
+            case GL_UNSIGNED_INT:
+            case GL_FLOAT:
+            case GL_UNSIGNED_SHORT_4_4_4_4:
+            case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+            case GL_UNSIGNED_INT_8_8_8_8:
+            case GL_UNSIGNED_INT_8_8_8_8_REV:
+            case GL_HALF_FLOAT:
+               return GL_NO_ERROR;
+            default:
+               return GL_INVALID_ENUM;
+         }
+
       case GL_YCBCR_MESA:
          if (!ctx->Extensions.MESA_ycbcr_texture)
             return GL_INVALID_ENUM;
@@ -2380,16 +2419,12 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
          return MESA_FORMAT_A1B5G5R5_UNORM;
       else if (format == GL_BGRA)
          return MESA_FORMAT_A1R5G5B5_UNORM;
-      else if (format == GL_ABGR_EXT)
-         return MESA_FORMAT_R1G5B5A5_UNORM;
       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_ABGR_EXT)
-         return MESA_FORMAT_A5B5G5R1_UNORM;
       break;
    case GL_UNSIGNED_BYTE_3_3_2:
       if (format == GL_RGB)
@@ -2412,8 +2447,6 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
          return MESA_FORMAT_A2R10G10B10_UNORM;
       else if (format == GL_BGRA_INTEGER)
          return MESA_FORMAT_A2R10G10B10_UINT;
-      else if (format == GL_ABGR_EXT)
-         return MESA_FORMAT_R2G10B10A10_UNORM;
       break;
    case GL_UNSIGNED_INT_2_10_10_10_REV:
       if (format == GL_RGBA)
@@ -2424,8 +2457,6 @@ _mesa_format_from_format_and_type(GLenum format, GLenum type)
          return MESA_FORMAT_B10G10R10A2_UNORM;
       else if (format == GL_BGRA_INTEGER)
          return MESA_FORMAT_B10G10R10A2_UINT;
-      else if (format == GL_ABGR_EXT)
-         return MESA_FORMAT_A10B10G10R2_UNORM;
       break;
    case GL_UNSIGNED_INT_8_8_8_8:
       if (format == GL_RGBA)
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index e9bb5eb..a0f34fd 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -183,13 +183,9 @@ texfetch_funcs[] =
    FETCH_NULL(R3G3B2_UNORM),
    FETCH_NULL(A4B4G4R4_UNORM),
    FETCH_NULL(R4G4B4A4_UNORM),
-   FETCH_NULL(R1G5B5A5_UNORM),
    FETCH_NULL(R5G5B5A1_UNORM),
-   FETCH_NULL(A5B5G5R1_UNORM),
    FETCH_NULL(A2B10G10R10_UNORM),
    FETCH_NULL(A2R10G10B10_UNORM),
-   FETCH_NULL(R2G10B10A10_UNORM),
-   FETCH_NULL(A10B10G10R2_UNORM),
 
    FETCH_FUNCS(YCBCR),
    FETCH_FUNCS(YCBCR_REV),
-- 
1.9.1



More information about the mesa-dev mailing list