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 <brianp@vmware.com>
[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.]
}
}
+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)
{
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;
0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
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 */
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;
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;
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 */
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) ||
}
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) ||
/* 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;
+ 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],
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;
return PIPE_FORMAT_B8G8R8A8_UNORM;
case MESA_FORMAT_ARGB8888_REV:
return PIPE_FORMAT_A8R8G8B8_UNORM;
+ case MESA_FORMAT_RGBX8888:
+ return PIPE_FORMAT_X8B8G8R8_UNORM;
+ case MESA_FORMAT_RGBX8888_REV:
+ return PIPE_FORMAT_R8G8B8X8_UNORM;
case MESA_FORMAT_XRGB8888:
return PIPE_FORMAT_B8G8R8X8_UNORM;
case MESA_FORMAT_XRGB8888_REV:
return MESA_FORMAT_ARGB8888;
case PIPE_FORMAT_A8R8G8B8_UNORM:
return MESA_FORMAT_ARGB8888_REV;
+ case PIPE_FORMAT_X8B8G8R8_UNORM:
+ return MESA_FORMAT_RGBX8888;
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ return MESA_FORMAT_RGBX8888_REV;
case PIPE_FORMAT_B8G8R8X8_UNORM:
return MESA_FORMAT_XRGB8888;
case PIPE_FORMAT_X8R8G8B8_UNORM:
fetch_texel_3d_f_argb8888_rev,
store_texel_argb8888_rev
},
+ {
+ MESA_FORMAT_RGBX8888,
+ fetch_texel_1d_f_rgbx8888,
+ fetch_texel_2d_f_rgbx8888,
+ fetch_texel_3d_f_rgbx8888,
+ store_texel_rgbx8888
+ },
+ {
+ MESA_FORMAT_RGBX8888_REV,
+ fetch_texel_1d_f_rgbx8888_rev,
+ fetch_texel_2d_f_rgbx8888_rev,
+ fetch_texel_3d_f_rgbx8888_rev,
+ store_texel_rgbx8888_rev,
+ },
{
MESA_FORMAT_XRGB8888,
fetch_texel_1d_f_xrgb8888,
#endif
+/* MESA_FORMAT_RGBX8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgbx8888 texture, return 4 GLfloats */
+static void FETCH(f_rgbx8888)( const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_rgbx8888(struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff);
+}
+#endif
+
+
+/* MESA_FORMAT_RGBX888_REV ***************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgbx8888_rev texture, return 4 GLchans */
+static void FETCH(f_rgbx8888_rev)( const struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_rgbx8888_rev(struct swrast_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+ *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 0xff);
+}
+#endif
+
+
/* MESA_FORMAT_XRGB8888 ******************************************************/
/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */