aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2011-11-22 15:05:25 +0800
committerChia-I Wu <[email protected]>2011-11-27 12:43:24 +0800
commitd4fcf67a3ac78c29448000486dadc2b4b1b2a56d (patch)
treede68969c78428e72aef94a30adcd94c389bc56c4 /src/mesa/main
parent6baa5f10c04641960e0bedce664d0a5cf39e8954 (diff)
mesa: add MESA_FORMAT_RGBX8888 and MESA_FORMAT_RGBX8888_REV
MESA_FORMAT_RGBX8888_REV is one of the opaque pixel formats used on Android. Thanks to texture-from-pixmap, drivers may actually see texture images with this format on Android. MESA_FORMAT_RGBX8888 is added only for completeness. Reviewed-by: Brian Paul <[email protected]> [olv: Move the new formats after MESA_FORMAT_ARGB8888_REV in gl_format. I accidentally moved them to the wrong place when preparing the patch.]
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/format_unpack.c28
-rw-r--r--src/mesa/main/formats.c24
-rw-r--r--src/mesa/main/formats.h2
-rw-r--r--src/mesa/main/texstore.c21
4 files changed, 69 insertions, 6 deletions
diff --git a/src/mesa/main/format_unpack.c b/src/mesa/main/format_unpack.c
index 080392f2bca..2f051dfa4bc 100644
--- a/src/mesa/main/format_unpack.c
+++ b/src/mesa/main/format_unpack.c
@@ -113,6 +113,32 @@ unpack_ARGB8888_REV(const void *src, GLfloat dst[][4], GLuint n)
}
static void
+unpack_RGBX8888(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] = UBYTE_TO_FLOAT( (s[i] >> 24) );
+ dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff );
+ dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff );
+ dst[i][ACOMP] = 1.0f;
+ }
+}
+
+static void
+unpack_RGBX8888_REV(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] = UBYTE_TO_FLOAT( (s[i] ) & 0xff );
+ dst[i][GCOMP] = UBYTE_TO_FLOAT( (s[i] >> 8) & 0xff );
+ dst[i][BCOMP] = UBYTE_TO_FLOAT( (s[i] >> 16) & 0xff );
+ dst[i][ACOMP] = 1.0f;
+ }
+}
+
+static void
unpack_XRGB8888(const void *src, GLfloat dst[][4], GLuint n)
{
const GLuint *s = ((const GLuint *) src);
@@ -1405,6 +1431,8 @@ get_unpack_rgba_function(gl_format format)
table[MESA_FORMAT_RGBA8888_REV] = unpack_RGBA8888_REV;
table[MESA_FORMAT_ARGB8888] = unpack_ARGB8888;
table[MESA_FORMAT_ARGB8888_REV] = unpack_ARGB8888_REV;
+ table[MESA_FORMAT_RGBX8888] = unpack_RGBX8888;
+ table[MESA_FORMAT_RGBX8888_REV] = unpack_RGBX8888_REV;
table[MESA_FORMAT_XRGB8888] = unpack_XRGB8888;
table[MESA_FORMAT_XRGB8888_REV] = unpack_XRGB8888_REV;
table[MESA_FORMAT_RGB888] = unpack_RGB888;
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index b934bd4d8c4..b9871aec883 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -123,6 +123,24 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
1, 1, 4 /* BlockWidth/Height,Bytes */
},
{
+ MESA_FORMAT_RGBX8888, /* Name */
+ "MESA_FORMAT_RGBX8888", /* StrName */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED, /* DataType */
+ 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 4 /* BlockWidth/Height,Bytes */
+ },
+ {
+ MESA_FORMAT_RGBX8888_REV, /* Name */
+ "MESA_FORMAT_RGBX8888_REV", /* StrName */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED, /* DataType */
+ 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
+ 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
+ 1, 1, 4 /* BlockWidth/Height,Bytes */
+ },
+ {
MESA_FORMAT_XRGB8888, /* Name */
"MESA_FORMAT_XRGB8888", /* StrName */
GL_RGB, /* BaseFormat */
@@ -1987,6 +2005,8 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_RGBA8888_REV:
case MESA_FORMAT_ARGB8888:
case MESA_FORMAT_ARGB8888_REV:
+ case MESA_FORMAT_RGBX8888:
+ case MESA_FORMAT_RGBX8888_REV:
case MESA_FORMAT_XRGB8888:
case MESA_FORMAT_XRGB8888_REV:
*datatype = GL_UNSIGNED_BYTE;
@@ -2492,6 +2512,10 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
return ((format == GL_BGRA && (type == GL_UNSIGNED_INT_8_8_8_8 ||
(type == GL_UNSIGNED_BYTE && !littleEndian))));
+ case MESA_FORMAT_RGBX8888:
+ case MESA_FORMAT_RGBX8888_REV:
+ return GL_FALSE;
+
case MESA_FORMAT_XRGB8888:
case MESA_FORMAT_XRGB8888_REV:
return GL_FALSE;
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index b2cb750aa94..5f601862b32 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -63,6 +63,8 @@ typedef enum
MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
+ MESA_FORMAT_RGBX8888, /* RRRR RRRR GGGG GGGG BBBB BBBB XXXX XXXX */
+ MESA_FORMAT_RGBX8888_REV, /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */
MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
MESA_FORMAT_XRGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index aae6b4b3b9b..6deeb642ede 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1265,12 +1265,15 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_RGBA8888 ||
- dstFormat == MESA_FORMAT_RGBA8888_REV);
+ dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV);
ASSERT(texelBytes == 4);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888 &&
+ (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888) &&
baseInternalFormat == GL_RGBA &&
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
@@ -1285,7 +1288,8 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
}
else if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
- dstFormat == MESA_FORMAT_RGBA8888_REV &&
+ (dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV) &&
baseInternalFormat == GL_RGBA &&
((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8_REV) ||
(srcFormat == GL_RGBA && srcType == GL_UNSIGNED_BYTE && littleEndian) ||
@@ -1309,8 +1313,10 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
/* dstmap - how to swizzle from RGBA to dst format:
*/
- if ((littleEndian && dstFormat == MESA_FORMAT_RGBA8888) ||
- (!littleEndian && dstFormat == MESA_FORMAT_RGBA8888_REV)) {
+ if ((littleEndian && (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888)) ||
+ (!littleEndian && (dstFormat == MESA_FORMAT_RGBA8888_REV ||
+ dstFormat == MESA_FORMAT_RGBX8888_REV))) {
dstmap[3] = 0;
dstmap[2] = 1;
dstmap[1] = 2;
@@ -1351,7 +1357,8 @@ _mesa_texstore_rgba8888(TEXSTORE_PARAMS)
+ dstXoffset * texelBytes;
for (row = 0; row < srcHeight; row++) {
GLuint *dstUI = (GLuint *) dstRow;
- if (dstFormat == MESA_FORMAT_RGBA8888) {
+ if (dstFormat == MESA_FORMAT_RGBA8888 ||
+ dstFormat == MESA_FORMAT_RGBX8888) {
for (col = 0; col < srcWidth; col++) {
dstUI[col] = PACK_COLOR_8888( src[RCOMP],
src[GCOMP],
@@ -4281,6 +4288,8 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_RGBA8888_REV] = _mesa_texstore_rgba8888;
table[MESA_FORMAT_ARGB8888] = _mesa_texstore_argb8888;
table[MESA_FORMAT_ARGB8888_REV] = _mesa_texstore_argb8888;
+ table[MESA_FORMAT_RGBX8888] = _mesa_texstore_rgba8888;
+ table[MESA_FORMAT_RGBX8888_REV] = _mesa_texstore_rgba8888;
table[MESA_FORMAT_XRGB8888] = _mesa_texstore_argb8888;
table[MESA_FORMAT_XRGB8888_REV] = _mesa_texstore_argb8888;
table[MESA_FORMAT_RGB888] = _mesa_texstore_rgb888;