mesa: add _rev signed rgba texture format

This commit is contained in:
Roland Scheidegger
2009-03-27 21:59:33 +01:00
parent 7d00ba195c
commit bb386a1eca
4 changed files with 78 additions and 5 deletions
+25
View File
@@ -746,6 +746,30 @@ const struct gl_texture_format _mesa_texformat_signed_rgba8888 = {
store_texel_signed_rgba8888 /* StoreTexel */
};
const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev = {
MESA_FORMAT_SIGNED_RGBA8888_REV, /* MesaFormat */
GL_RGBA, /* BaseFormat */
GL_SIGNED_NORMALIZED, /* DataType */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
8, /* AlphaBits */
0, /* LuminanceBits */
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
0, /* StencilBits */
4, /* TexelBytes */
_mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */
NULL, /* FetchTexel1D */
NULL, /* FetchTexel2D */
NULL, /* FetchTexel3D */
fetch_texel_1d_signed_rgba8888_rev, /* FetchTexel1Df */
fetch_texel_2d_signed_rgba8888_rev, /* FetchTexel2Df */
fetch_texel_3d_signed_rgba8888_rev, /* FetchTexel3Df */
store_texel_signed_rgba8888_rev /* StoreTexel */
};
/*@}*/
@@ -1854,6 +1878,7 @@ _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
return;
case MESA_FORMAT_SIGNED_RGBA8888:
case MESA_FORMAT_SIGNED_RGBA8888_REV:
*datatype = GL_BYTE;
*comps = 4;
return;
+3 -1
View File
@@ -169,7 +169,8 @@ enum _format {
*/
/*@{*/
MESA_FORMAT_DUDV8,
MESA_FORMAT_SIGNED_RGBA8888
MESA_FORMAT_SIGNED_RGBA8888,
MESA_FORMAT_SIGNED_RGBA8888_REV
/*@}*/
};
@@ -221,6 +222,7 @@ extern const struct gl_texture_format _mesa_texformat_intensity_float16;
/*@{*/
extern const struct gl_texture_format _mesa_texformat_dudv8;
extern const struct gl_texture_format _mesa_texformat_signed_rgba8888;
extern const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev;
/*@}*/
/** \name Assorted hardware-friendly formats */
+22 -1
View File
@@ -1321,7 +1321,7 @@ static void FETCH(dudv8)(const struct gl_texture_image *texImage,
texel[ACOMP] = 0;
}
/* MESA_FORMAT_SIGNED_ARGB8888 ***********************************************/
/* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
static void FETCH(signed_rgba8888)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
@@ -1343,6 +1343,27 @@ static void store_texel_signed_rgba8888(struct gl_texture_image *texImage,
}
#endif
static void FETCH(signed_rgba8888_rev)( 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] = BYTE_TO_FLOAT_TEX( (s ) & 0xff );
texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 8) & 0xff );
texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24) );
}
#if DIM == 3
static void store_texel_signed_rgba8888_rev(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_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
}
#endif
/* MESA_FORMAT_YCBCR *********************************************************/
+28 -3
View File
@@ -2564,14 +2564,15 @@ _mesa_texstore_dudv8(TEXSTORE_PARAMS)
}
/**
* Store a texture in MESA_FORMAT_RGBA8888 or MESA_FORMAT_RGBA8888_REV.
* Store a texture in MESA_FORMAT_SIGNED_RGBA8888 or MESA_FORMAT_SIGNED_RGBA8888_REV
*/
GLboolean
_mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
ASSERT(dstFormat == &_mesa_texformat_signed_rgba8888);
ASSERT(dstFormat == &_mesa_texformat_signed_rgba8888 ||
dstFormat == &_mesa_texformat_signed_rgba8888_rev);
ASSERT(dstFormat->TexelBytes == 4);
if (!ctx->_ImageTransferState &&
@@ -2588,6 +2589,20 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
dstFormat == &_mesa_texformat_signed_rgba8888_rev &&
baseInternalFormat == GL_RGBA &&
((srcFormat == GL_RGBA && srcType == GL_BYTE && littleEndian) ||
(srcFormat == GL_ABGR_EXT && srcType == GL_BYTE && !littleEndian))) {
/* simple memcpy path */
memcpy_texture(ctx, dims,
dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
dstRowStride,
dstImageOffsets,
srcWidth, srcHeight, srcDepth, srcFormat, srcType,
srcAddr, srcPacking);
}
else if (!ctx->_ImageTransferState &&
(srcType == GL_BYTE) &&
can_swizzle(baseInternalFormat) &&
@@ -2597,7 +2612,8 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
/* dstmap - how to swizzle from RGBA to dst format:
*/
if (littleEndian && dstFormat == &_mesa_texformat_signed_rgba8888) {
if ((littleEndian && dstFormat == &_mesa_texformat_signed_rgba8888) ||
(!littleEndian && dstFormat == &_mesa_texformat_signed_rgba8888_rev)) {
dstmap[3] = 0;
dstmap[2] = 1;
dstmap[1] = 2;
@@ -2649,6 +2665,15 @@ _mesa_texstore_signed_rgba8888(TEXSTORE_PARAMS)
srcRow += 4;
}
}
else {
for (col = 0; col < srcWidth; col++) {
dstUI[col] = PACK_COLOR_8888_REV( FLOAT_TO_BYTE_TEX(srcRow[RCOMP]),
FLOAT_TO_BYTE_TEX(srcRow[GCOMP]),
FLOAT_TO_BYTE_TEX(srcRow[BCOMP]),
FLOAT_TO_BYTE_TEX(srcRow[ACOMP]) );
srcRow += 4;
}
}
dstRow += dstRowStride;
}
}