[Mesa-dev] [PATCH v3 01/18] mesa/formats: define the 2D ASTC formats

Nanley Chery nanleychery at gmail.com
Mon Jun 22 16:02:07 PDT 2015


From: Nanley Chery <nanley.g.chery at intel.com>

Includes definition of the formats, updates to functions likely to be used, as
well as changes necessary for compilation.

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Signed-off-by: Nanley Chery <nanley.g.chery at intel.com>
---
 src/mesa/main/format_info.py |   3 +
 src/mesa/main/formats.c      | 130 +++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/formats.csv    |  31 +++++++++++
 src/mesa/main/formats.h      |  30 ++++++++++
 src/mesa/swrast/s_texfetch.c |  32 ++++++++++-
 5 files changed, 225 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/format_info.py b/src/mesa/main/format_info.py
index 3bae57e..40104a2 100644
--- a/src/mesa/main/format_info.py
+++ b/src/mesa/main/format_info.py
@@ -130,6 +130,9 @@ def get_channel_bits(fmat, chan_name):
       elif fmat.layout == 'bptc':
          bits = 16 if fmat.name.endswith('_FLOAT') else 8
          return bits if fmat.has_channel(chan_name) else 0
+      elif fmat.layout == 'astc':
+         bits = 16 if fmat.name.endswith('_RGBA') else 8
+         return bits if fmat.has_channel(chan_name) else 0
       else:
          assert False
    else:
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index baeb1bf..745fd8c 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -667,6 +667,48 @@ _mesa_get_srgb_format_linear(mesa_format format)
    case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
       format = MESA_FORMAT_BPTC_RGBA_UNORM;
       break;
+   case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_4x4_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_5x4_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_5x5_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_6x5_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_6x6_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_8x5_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_8x6_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_8x8_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_10x5_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_10x6_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_10x8_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_10x10_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_12x10_RGBA;
+      break;
+   case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8:
+      format = MESA_FORMAT_ASTC_12x12_RGBA;
+      break;
    case MESA_FORMAT_B8G8R8X8_SRGB:
       format = MESA_FORMAT_B8G8R8X8_UNORM;
       break;
@@ -741,6 +783,36 @@ _mesa_get_uncompressed_format(mesa_format format)
    case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
    case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
       return MESA_FORMAT_RGB_FLOAT32;
+   case MESA_FORMAT_ASTC_4x4_RGBA:
+   case MESA_FORMAT_ASTC_5x4_RGBA:
+   case MESA_FORMAT_ASTC_5x5_RGBA:
+   case MESA_FORMAT_ASTC_6x5_RGBA:
+   case MESA_FORMAT_ASTC_6x6_RGBA:
+   case MESA_FORMAT_ASTC_8x5_RGBA:
+   case MESA_FORMAT_ASTC_8x6_RGBA:
+   case MESA_FORMAT_ASTC_8x8_RGBA:
+   case MESA_FORMAT_ASTC_10x5_RGBA:
+   case MESA_FORMAT_ASTC_10x6_RGBA:
+   case MESA_FORMAT_ASTC_10x8_RGBA:
+   case MESA_FORMAT_ASTC_10x10_RGBA:
+   case MESA_FORMAT_ASTC_12x10_RGBA:
+   case MESA_FORMAT_ASTC_12x12_RGBA:
+	return MESA_FORMAT_RGBA_FLOAT16;
+   case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8:
+	return MESA_FORMAT_A8B8G8R8_SRGB;
    default:
 #ifdef DEBUG
       assert(!_mesa_is_format_compressed(format));
@@ -1253,6 +1325,34 @@ _mesa_format_to_type_and_comps(mesa_format format,
    case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM:
    case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT:
    case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
+   case MESA_FORMAT_ASTC_4x4_RGBA:
+   case MESA_FORMAT_ASTC_5x4_RGBA:
+   case MESA_FORMAT_ASTC_5x5_RGBA:
+   case MESA_FORMAT_ASTC_6x5_RGBA:
+   case MESA_FORMAT_ASTC_6x6_RGBA:
+   case MESA_FORMAT_ASTC_8x5_RGBA:
+   case MESA_FORMAT_ASTC_8x6_RGBA:
+   case MESA_FORMAT_ASTC_8x8_RGBA:
+   case MESA_FORMAT_ASTC_10x5_RGBA:
+   case MESA_FORMAT_ASTC_10x6_RGBA:
+   case MESA_FORMAT_ASTC_10x8_RGBA:
+   case MESA_FORMAT_ASTC_10x10_RGBA:
+   case MESA_FORMAT_ASTC_12x10_RGBA:
+   case MESA_FORMAT_ASTC_12x12_RGBA:
+   case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8:
       /* XXX generate error instead? */
       *datatype = GL_UNSIGNED_BYTE;
       *comps = 0;
@@ -1869,6 +1969,36 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
    case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT:
       return GL_FALSE;
 
+   case MESA_FORMAT_ASTC_4x4_RGBA:
+   case MESA_FORMAT_ASTC_5x4_RGBA:
+   case MESA_FORMAT_ASTC_5x5_RGBA:
+   case MESA_FORMAT_ASTC_6x5_RGBA:
+   case MESA_FORMAT_ASTC_6x6_RGBA:
+   case MESA_FORMAT_ASTC_8x5_RGBA:
+   case MESA_FORMAT_ASTC_8x6_RGBA:
+   case MESA_FORMAT_ASTC_8x8_RGBA:
+   case MESA_FORMAT_ASTC_10x5_RGBA:
+   case MESA_FORMAT_ASTC_10x6_RGBA:
+   case MESA_FORMAT_ASTC_10x8_RGBA:
+   case MESA_FORMAT_ASTC_10x10_RGBA:
+   case MESA_FORMAT_ASTC_12x10_RGBA:
+   case MESA_FORMAT_ASTC_12x12_RGBA:
+   case MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8:
+   case MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8:
+      return GL_FALSE;
+
    case MESA_FORMAT_RGBA_FLOAT32:
       return format == GL_RGBA && type == GL_FLOAT && !swapBytes;
    case MESA_FORMAT_RGBA_FLOAT16:
diff --git a/src/mesa/main/formats.csv b/src/mesa/main/formats.csv
index e159e7d..215dae2 100644
--- a/src/mesa/main/formats.csv
+++ b/src/mesa/main/formats.csv
@@ -301,3 +301,34 @@ MESA_FORMAT_BPTC_RGBA_UNORM               , bptc  , 4, 4, x128,     ,     ,
 MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM         , bptc  , 4, 4, x128,     ,     ,     , xyzw, srgb
 MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT         , bptc  , 4, 4, x128,     ,     ,     , xyz1, rgb
 MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT       , bptc  , 4, 4, x128,     ,     ,     , xyz1, rgb
+
+# ASTC compressed formats
+MESA_FORMAT_ASTC_4x4_RGBA                 , astc  , 4, 4, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_5x4_RGBA                 , astc  , 5, 4, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_5x5_RGBA                 , astc  , 5, 5, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_6x5_RGBA                 , astc  , 6, 5, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_6x6_RGBA                 , astc  , 6, 6, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_8x5_RGBA                 , astc  , 8, 5, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_8x6_RGBA                 , astc  , 8, 6, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_8x8_RGBA                 , astc  , 8, 8, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_10x5_RGBA                , astc  ,10, 5, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_10x6_RGBA                , astc  ,10, 6, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_10x8_RGBA                , astc  ,10, 8, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_10x10_RGBA               , astc  ,10,10, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_12x10_RGBA               , astc  ,12,10, x128,     ,     ,     , xyzw, rgb
+MESA_FORMAT_ASTC_12x12_RGBA               , astc  ,12,12, x128,     ,     ,     , xyzw, rgb
+
+MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8         , astc  , 4, 4, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8         , astc  , 5, 4, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8         , astc  , 5, 5, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8         , astc  , 6, 5, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8         , astc  , 6, 6, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8         , astc  , 8, 5, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8         , astc  , 8, 6, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8         , astc  , 8, 8, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8        , astc  ,10, 5, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8        , astc  ,10, 6, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8        , astc  ,10, 8, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8       , astc  ,10,10, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8       , astc  ,12,10, x128,     ,     ,     , xyzw, srgb
+MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8       , astc  ,12,12, x128,     ,     ,     , xyzw, srgb
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index 7e451ca..ff95fe6 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -575,6 +575,36 @@ typedef enum
    MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT,
    MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT,
 
+   /* ASTC compressed formats */
+   MESA_FORMAT_ASTC_4x4_RGBA,
+   MESA_FORMAT_ASTC_5x4_RGBA,
+   MESA_FORMAT_ASTC_5x5_RGBA,
+   MESA_FORMAT_ASTC_6x5_RGBA,
+   MESA_FORMAT_ASTC_6x6_RGBA,
+   MESA_FORMAT_ASTC_8x5_RGBA,
+   MESA_FORMAT_ASTC_8x6_RGBA,
+   MESA_FORMAT_ASTC_8x8_RGBA,
+   MESA_FORMAT_ASTC_10x5_RGBA,
+   MESA_FORMAT_ASTC_10x6_RGBA,
+   MESA_FORMAT_ASTC_10x8_RGBA,
+   MESA_FORMAT_ASTC_10x10_RGBA,
+   MESA_FORMAT_ASTC_12x10_RGBA,
+   MESA_FORMAT_ASTC_12x12_RGBA,
+
+   MESA_FORMAT_ASTC_4x4_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_5x4_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_5x5_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_6x5_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_6x6_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_8x5_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_8x6_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_8x8_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_10x5_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_10x6_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_10x8_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_10x10_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_12x10_SRGB8_ALPHA8,
+   MESA_FORMAT_ASTC_12x12_SRGB8_ALPHA8,
    MESA_FORMAT_COUNT
 } mesa_format;
 
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index 1fe21c0..14e5293 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -551,7 +551,37 @@ texfetch_funcs[] =
       fetch_compressed,
       fetch_compressed,
       fetch_compressed
-   }
+   },
+
+   /* ASTC compressed formats */
+   FETCH_NULL(ASTC_4x4_RGBA),
+   FETCH_NULL(ASTC_5x4_RGBA),
+   FETCH_NULL(ASTC_5x5_RGBA),
+   FETCH_NULL(ASTC_6x5_RGBA),
+   FETCH_NULL(ASTC_6x6_RGBA),
+   FETCH_NULL(ASTC_8x5_RGBA),
+   FETCH_NULL(ASTC_8x6_RGBA),
+   FETCH_NULL(ASTC_8x8_RGBA),
+   FETCH_NULL(ASTC_10x5_RGBA),
+   FETCH_NULL(ASTC_10x6_RGBA),
+   FETCH_NULL(ASTC_10x8_RGBA),
+   FETCH_NULL(ASTC_10x10_RGBA),
+   FETCH_NULL(ASTC_12x10_RGBA),
+   FETCH_NULL(ASTC_12x12_RGBA),
+   FETCH_NULL(ASTC_4x4_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_5x4_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_5x5_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_6x5_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_6x6_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_8x5_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_8x6_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_8x8_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_10x5_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_10x6_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_10x8_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_10x10_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_12x10_SRGB8_ALPHA8),
+   FETCH_NULL(ASTC_12x12_SRGB8_ALPHA8)
 };
 
 
-- 
2.4.2



More information about the mesa-dev mailing list