mesa: implement new texture format A16

This commit is contained in:
Marek Olšák 2010-12-22 00:32:33 +01:00
parent bae9d511f3
commit eb31837a0d
7 changed files with 58 additions and 8 deletions

View file

@ -284,6 +284,15 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
1, 1, 1 /* BlockWidth/Height,Bytes */
},
{
MESA_FORMAT_A16, /* Name */
"MESA_FORMAT_A16", /* StrName */
GL_ALPHA, /* BaseFormat */
GL_UNSIGNED_NORMALIZED, /* DataType */
0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
1, 1, 2 /* BlockWidth/Height,Bytes */
},
{
MESA_FORMAT_L8, /* Name */
"MESA_FORMAT_L8", /* StrName */
@ -1297,6 +1306,7 @@ _mesa_format_to_type_and_comps(gl_format format,
return;
case MESA_FORMAT_R16:
case MESA_FORMAT_A16:
*datatype = GL_UNSIGNED_SHORT;
*comps = 1;
return;

View file

@ -72,6 +72,7 @@ typedef enum
MESA_FORMAT_AL1616_REV, /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */
MESA_FORMAT_RGB332, /* RRRG GGBB */
MESA_FORMAT_A8, /* AAAA AAAA */
MESA_FORMAT_A16, /* AAAA AAAA AAAA AAAA */
MESA_FORMAT_L8, /* LLLL LLLL */
MESA_FORMAT_I8, /* IIII IIII */
MESA_FORMAT_CI8, /* CCCC CCCC */

View file

@ -285,6 +285,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
fetch_texel_3d_f_a8,
store_texel_a8
},
{
MESA_FORMAT_A16,
fetch_texel_1d_f_a16,
fetch_texel_2d_f_a16,
fetch_texel_3d_f_a16,
store_texel_a16
},
{
MESA_FORMAT_L8,
fetch_texel_1d_f_l8,

View file

@ -1148,6 +1148,30 @@ static void store_texel_a8(struct gl_texture_image *texImage,
#endif
/* MESA_FORMAT_A16 ************************************************************/
/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
static void FETCH(f_a16)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
texel[RCOMP] =
texel[GCOMP] =
texel[BCOMP] = 0.0F;
texel[ACOMP] = USHORT_TO_FLOAT( src[0] );
}
#if DIM == 3
static void store_texel_a16(struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, const void *texel)
{
const GLushort *rgba = (const GLushort *) texel;
GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
*dst = rgba[ACOMP];
}
#endif
/* MESA_FORMAT_L8 ************************************************************/
/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */

View file

@ -102,11 +102,13 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
/* Alpha formats */
case GL_ALPHA:
case GL_ALPHA4:
case GL_ALPHA12:
case GL_ALPHA16:
case GL_ALPHA8:
return MESA_FORMAT_A8;
case GL_ALPHA12:
case GL_ALPHA16:
return MESA_FORMAT_A16;
/* Luminance formats */
case 1:
case GL_LUMINANCE:

View file

@ -437,6 +437,11 @@ get_tex_memcpy(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixel
type == GL_UNSIGNED_BYTE) {
memCopy = GL_TRUE;
}
else if (texImage->TexFormat == MESA_FORMAT_A16 &&
format == GL_ALPHA &&
type == GL_UNSIGNED_SHORT) {
memCopy = GL_TRUE;
}
}
if (memCopy) {

View file

@ -2357,21 +2357,21 @@ _mesa_texstore_unorm1616(TEXSTORE_PARAMS)
}
/* Texstore for R16, A16. */
static GLboolean
_mesa_texstore_r16(TEXSTORE_PARAMS)
_mesa_texstore_unorm16(TEXSTORE_PARAMS)
{
const GLboolean littleEndian = _mesa_little_endian();
const GLuint texelBytes = _mesa_get_format_bytes(dstFormat);
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_R16);
ASSERT(dstFormat == MESA_FORMAT_R16 ||
dstFormat == MESA_FORMAT_A16);
ASSERT(texelBytes == 2);
if (!ctx->_ImageTransferState &&
!srcPacking->SwapBytes &&
dstFormat == MESA_FORMAT_R16 &&
baseInternalFormat == GL_RED &&
srcFormat == GL_RED &&
baseInternalFormat == srcFormat &&
srcType == GL_UNSIGNED_SHORT &&
littleEndian) {
/* simple memcpy path */
@ -4048,6 +4048,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_AL1616_REV, _mesa_texstore_unorm1616 },
{ MESA_FORMAT_RGB332, _mesa_texstore_rgb332 },
{ MESA_FORMAT_A8, _mesa_texstore_a8 },
{ MESA_FORMAT_A16, _mesa_texstore_unorm16 },
{ MESA_FORMAT_L8, _mesa_texstore_a8 },
{ MESA_FORMAT_I8, _mesa_texstore_a8 },
{ MESA_FORMAT_CI8, _mesa_texstore_ci8 },
@ -4056,7 +4057,7 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_R8, _mesa_texstore_a8 },
{ MESA_FORMAT_RG88, _mesa_texstore_unorm88 },
{ MESA_FORMAT_RG88_REV, _mesa_texstore_unorm88 },
{ MESA_FORMAT_R16, _mesa_texstore_r16 },
{ MESA_FORMAT_R16, _mesa_texstore_unorm16 },
{ MESA_FORMAT_RG1616, _mesa_texstore_unorm1616 },
{ MESA_FORMAT_RG1616_REV, _mesa_texstore_unorm1616 },
{ MESA_FORMAT_ARGB2101010, _mesa_texstore_argb2101010 },