mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +01:00
mesa: added MESA_FORMAT_XRGB8888
This commit is contained in:
parent
c5b7254892
commit
74d61d03b5
5 changed files with 60 additions and 4 deletions
|
|
@ -114,6 +114,14 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
|
||||||
0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
|
0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
|
||||||
1, 1, 4 /* BlockWidth/Height,Bytes */
|
1, 1, 4 /* BlockWidth/Height,Bytes */
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MESA_FORMAT_XRGB8888, /* Name */
|
||||||
|
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_RGB888, /* Name */
|
MESA_FORMAT_RGB888, /* Name */
|
||||||
GL_RGB, /* BaseFormat */
|
GL_RGB, /* BaseFormat */
|
||||||
|
|
@ -799,6 +807,7 @@ _mesa_format_to_type_and_comps(gl_format format,
|
||||||
case MESA_FORMAT_RGBA8888_REV:
|
case MESA_FORMAT_RGBA8888_REV:
|
||||||
case MESA_FORMAT_ARGB8888:
|
case MESA_FORMAT_ARGB8888:
|
||||||
case MESA_FORMAT_ARGB8888_REV:
|
case MESA_FORMAT_ARGB8888_REV:
|
||||||
|
case MESA_FORMAT_XRGB8888:
|
||||||
*datatype = GL_UNSIGNED_BYTE;
|
*datatype = GL_UNSIGNED_BYTE;
|
||||||
*comps = 4;
|
*comps = 4;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ typedef enum
|
||||||
MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
|
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, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
|
||||||
MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
|
MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
|
||||||
|
MESA_FORMAT_XRGB8888, /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
|
||||||
MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
|
MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
|
||||||
MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
|
MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
|
||||||
MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
|
MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
|
||||||
|
|
|
||||||
|
|
@ -368,6 +368,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
|
||||||
fetch_texel_3d_f_argb8888_rev,
|
fetch_texel_3d_f_argb8888_rev,
|
||||||
store_texel_argb8888_rev
|
store_texel_argb8888_rev
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MESA_FORMAT_XRGB8888,
|
||||||
|
fetch_texel_1d_f_xrgb8888,
|
||||||
|
fetch_texel_2d_f_xrgb8888,
|
||||||
|
fetch_texel_3d_f_xrgb8888,
|
||||||
|
store_texel_xrgb8888
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MESA_FORMAT_RGB888,
|
MESA_FORMAT_RGB888,
|
||||||
fetch_texel_1d_f_rgb888,
|
fetch_texel_1d_f_rgb888,
|
||||||
|
|
|
||||||
|
|
@ -535,6 +535,30 @@ static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* MESA_FORMAT_XRGB8888 ******************************************************/
|
||||||
|
|
||||||
|
/* Fetch texel from 1D, 2D or 3D xrgb8888 texture, return 4 GLchans */
|
||||||
|
static void FETCH(f_xrgb8888)( const struct gl_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 >> 16) & 0xff );
|
||||||
|
texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
|
||||||
|
texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
|
||||||
|
texel[ACOMP] = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DIM == 3
|
||||||
|
static void store_texel_xrgb8888(struct gl_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(0xff, rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* MESA_FORMAT_RGB888 ********************************************************/
|
/* MESA_FORMAT_RGB888 ********************************************************/
|
||||||
|
|
||||||
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
|
/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
|
||||||
|
|
|
||||||
|
|
@ -1344,12 +1344,14 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
|
||||||
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
|
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
|
||||||
|
|
||||||
ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
|
ASSERT(dstFormat == MESA_FORMAT_ARGB8888 ||
|
||||||
dstFormat == MESA_FORMAT_ARGB8888_REV);
|
dstFormat == MESA_FORMAT_ARGB8888_REV ||
|
||||||
|
dstFormat == MESA_FORMAT_XRGB8888);
|
||||||
ASSERT(texelBytes == 4);
|
ASSERT(texelBytes == 4);
|
||||||
|
|
||||||
if (!ctx->_ImageTransferState &&
|
if (!ctx->_ImageTransferState &&
|
||||||
!srcPacking->SwapBytes &&
|
!srcPacking->SwapBytes &&
|
||||||
dstFormat == MESA_FORMAT_ARGB8888 &&
|
(dstFormat == MESA_FORMAT_ARGB8888 ||
|
||||||
|
dstFormat == MESA_FORMAT_XRGB8888) &&
|
||||||
baseInternalFormat == GL_RGBA &&
|
baseInternalFormat == GL_RGBA &&
|
||||||
srcFormat == GL_BGRA &&
|
srcFormat == GL_BGRA &&
|
||||||
((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
|
((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
|
||||||
|
|
@ -1379,7 +1381,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
|
||||||
}
|
}
|
||||||
else if (!ctx->_ImageTransferState &&
|
else if (!ctx->_ImageTransferState &&
|
||||||
!srcPacking->SwapBytes &&
|
!srcPacking->SwapBytes &&
|
||||||
dstFormat == MESA_FORMAT_ARGB8888 &&
|
(dstFormat == MESA_FORMAT_ARGB8888 ||
|
||||||
|
dstFormat == MESA_FORMAT_XRGB8888) &&
|
||||||
srcFormat == GL_RGB &&
|
srcFormat == GL_RGB &&
|
||||||
(baseInternalFormat == GL_RGBA ||
|
(baseInternalFormat == GL_RGBA ||
|
||||||
baseInternalFormat == GL_RGB) &&
|
baseInternalFormat == GL_RGB) &&
|
||||||
|
|
@ -1455,6 +1458,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
|
||||||
/* dstmap - how to swizzle from RGBA to dst format:
|
/* dstmap - how to swizzle from RGBA to dst format:
|
||||||
*/
|
*/
|
||||||
if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
|
if ((littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
|
||||||
|
(littleEndian && dstFormat == MESA_FORMAT_XRGB8888) ||
|
||||||
(!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV)) {
|
(!littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV)) {
|
||||||
dstmap[3] = 3; /* alpha */
|
dstmap[3] = 3; /* alpha */
|
||||||
dstmap[2] = 0; /* red */
|
dstmap[2] = 0; /* red */
|
||||||
|
|
@ -1463,7 +1467,8 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
|
assert((littleEndian && dstFormat == MESA_FORMAT_ARGB8888_REV) ||
|
||||||
(!littleEndian && dstFormat == MESA_FORMAT_ARGB8888));
|
(!littleEndian && dstFormat == MESA_FORMAT_ARGB8888) ||
|
||||||
|
(!littleEndian && dstFormat == MESA_FORMAT_XRGB8888));
|
||||||
dstmap[3] = 2;
|
dstmap[3] = 2;
|
||||||
dstmap[2] = 1;
|
dstmap[2] = 1;
|
||||||
dstmap[1] = 0;
|
dstmap[1] = 0;
|
||||||
|
|
@ -1511,6 +1516,15 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
|
||||||
src += 4;
|
src += 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (dstFormat == MESA_FORMAT_XRGB8888) {
|
||||||
|
for (col = 0; col < srcWidth; col++) {
|
||||||
|
dstUI[col] = PACK_COLOR_8888( 0xff,
|
||||||
|
CHAN_TO_UBYTE(src[RCOMP]),
|
||||||
|
CHAN_TO_UBYTE(src[GCOMP]),
|
||||||
|
CHAN_TO_UBYTE(src[BCOMP]) );
|
||||||
|
src += 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
for (col = 0; col < srcWidth; col++) {
|
for (col = 0; col < srcWidth; col++) {
|
||||||
dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
|
dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
|
||||||
|
|
@ -2973,6 +2987,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
|
||||||
{ MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 },
|
{ MESA_FORMAT_RGBA8888_REV, _mesa_texstore_rgba8888 },
|
||||||
{ MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 },
|
{ MESA_FORMAT_ARGB8888, _mesa_texstore_argb8888 },
|
||||||
{ MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 },
|
{ MESA_FORMAT_ARGB8888_REV, _mesa_texstore_argb8888 },
|
||||||
|
{ MESA_FORMAT_XRGB8888, _mesa_texstore_argb8888 },
|
||||||
{ MESA_FORMAT_RGB888, _mesa_texstore_rgb888 },
|
{ MESA_FORMAT_RGB888, _mesa_texstore_rgb888 },
|
||||||
{ MESA_FORMAT_BGR888, _mesa_texstore_bgr888 },
|
{ MESA_FORMAT_BGR888, _mesa_texstore_bgr888 },
|
||||||
{ MESA_FORMAT_RGB565, _mesa_texstore_rgb565 },
|
{ MESA_FORMAT_RGB565, _mesa_texstore_rgb565 },
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue