summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsalvez <[email protected]>2014-10-08 11:06:21 +0200
committerIago Toral Quiroga <[email protected]>2015-01-12 11:20:28 +0100
commitc5a5c9a7db898145774524415a3a94fe75ddb364 (patch)
tree9a2d2796d04ae8533386f2b32e9ee6a73b1fc46c
parentf8d160fc96cccb46040d47b4dead31c81375e6b6 (diff)
mesa/formats: add new mesa formats and their pack/unpack functions.
This will be used to refactor code in pack.c and support conversion to/from these types in a master convert function that will be added later. v2: - Fix autogeneration of MESA_FORMAT_A2R10G10B10_UNORM pack/unpack functions Signed-off-by: Samuel Iglesias Gonsalvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/mesa/main/format_unpack.py1
-rw-r--r--src/mesa/main/formats.c104
-rw-r--r--src/mesa/main/formats.csv13
-rw-r--r--src/mesa/main/formats.h15
-rw-r--r--src/mesa/swrast/s_texfetch.c13
5 files changed, 145 insertions, 1 deletions
diff --git a/src/mesa/main/format_unpack.py b/src/mesa/main/format_unpack.py
index f71ca359ab1..2276a1063f5 100644
--- a/src/mesa/main/format_unpack.py
+++ b/src/mesa/main/format_unpack.py
@@ -260,7 +260,6 @@ unpack_ubyte_${f.short_name()}(const void *void_src, GLubyte dst[4])
}
%endfor
-
/* integer packing functions */
%for f in rgb_formats:
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 6eb80fb575d..a2df2859d91 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -1010,6 +1010,50 @@ _mesa_format_to_type_and_comps(mesa_format format,
*comps = 1;
return;
+ case MESA_FORMAT_R3G3B2_UNORM:
+ *datatype = GL_UNSIGNED_BYTE_2_3_3_REV;
+ *comps = 3;
+ return;
+ case MESA_FORMAT_A4B4G4R4_UNORM:
+ *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
+ *comps = 4;
+ return;
+
+ case MESA_FORMAT_R4G4B4A4_UNORM:
+ *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;
+ *comps = 4;
+ return;
+ case MESA_FORMAT_A2R10G10B10_UNORM:
+ case MESA_FORMAT_A2R10G10B10_UINT:
+ *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;
*comps = 3;
@@ -1653,6 +1697,66 @@ _mesa_format_matches_format_and_type(mesa_format mesa_format,
case MESA_FORMAT_B2G3R3_UNORM:
return format == GL_RGB && type == GL_UNSIGNED_BYTE_3_3_2;
+ case MESA_FORMAT_R3G3B2_UNORM:
+ return format == GL_RGB && type == GL_UNSIGNED_BYTE_2_3_3_REV;
+
+ case MESA_FORMAT_A4B4G4R4_UNORM:
+ if (format == GL_RGBA && type == GL_UNSIGNED_SHORT_4_4_4_4 && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_4_4_4_4 && swapBytes)
+ return GL_TRUE;
+
+ return GL_FALSE;
+
+ case MESA_FORMAT_R4G4B4A4_UNORM:
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_4_4_4_4 && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_ABGR_EXT && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_SHORT_4_4_4_4_REV && !swapBytes)
+ return GL_TRUE;
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_SHORT_4_4_4_4 && swapBytes)
+ return GL_TRUE;
+
+ 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;
+
+ case MESA_FORMAT_A2B10G10R10_UINT:
+ return format == GL_RGBA_INTEGER_EXT && type == GL_UNSIGNED_INT_10_10_10_2;
+
+ case MESA_FORMAT_A2R10G10B10_UNORM:
+ return format == GL_BGRA && type == GL_UNSIGNED_INT_10_10_10_2;
+
+ 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 39bcdbdd260..09fc9b34776 100644
--- a/src/mesa/main/formats.csv
+++ b/src/mesa/main/formats.csv
@@ -88,6 +88,17 @@ MESA_FORMAT_X8_UINT_Z24_UNORM , packed, 1, 1, un24, x8 , ,
MESA_FORMAT_Z24_UNORM_S8_UINT , packed, 1, 1, u8 , un24, , , yx__, zs
MESA_FORMAT_Z24_UNORM_X8_UINT , packed, 1, 1, x8 , un24, , , y___, zs
+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
@@ -180,6 +191,8 @@ MESA_FORMAT_Z_FLOAT32 , array , 1, 1, f32 , , ,
# Packed signed/unsigned non-normalized integer formats
MESA_FORMAT_B10G10R10A2_UINT , packed, 1, 1, u10 , u10 , u10 , u2 , zyxw, rgb
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
# 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 4f83208bd4c..02afbce7c4f 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -358,6 +358,19 @@ typedef enum
MESA_FORMAT_Z24_UNORM_S8_UINT,/* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
MESA_FORMAT_Z24_UNORM_X8_UINT,/* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
+ /* Other formats */
+ 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 */
@@ -452,6 +465,8 @@ typedef enum
/* Packed signed/unsigned non-normalized integer formats */
MESA_FORMAT_B10G10R10A2_UINT, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
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 */
/* Array signed/unsigned non-normalized integer formats */
MESA_FORMAT_A_UINT8,
diff --git a/src/mesa/swrast/s_texfetch.c b/src/mesa/swrast/s_texfetch.c
index 0f6da919dae..e9bb5ebd1d5 100644
--- a/src/mesa/swrast/s_texfetch.c
+++ b/src/mesa/swrast/s_texfetch.c
@@ -180,6 +180,17 @@ texfetch_funcs[] =
fetch_texel_2d_Z24_UNORM_S8_UINT,
fetch_texel_3d_Z24_UNORM_S8_UINT
},
+ 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),
@@ -276,6 +287,8 @@ texfetch_funcs[] =
/* Packed signed/unsigned non-normalized integer formats */
FETCH_NULL(B10G10R10A2_UINT),
FETCH_NULL(R10G10B10A2_UINT),
+ FETCH_NULL(A2B10G10R10_UINT),
+ FETCH_NULL(A2R10G10B10_UINT),
/* Array signed/unsigned non-normalized integer formats */
FETCH_NULL(A_UINT8),