updates from 4.0.4 (MESA_ycbcr_texture, APPLE_client_storage, etc)

This commit is contained in:
Brian Paul
2002-09-21 16:51:25 +00:00
parent c62aeed003
commit c5b9950660
12 changed files with 392 additions and 75 deletions

View File

@@ -1,4 +1,4 @@
/* $Id: extensions.c,v 1.78 2002/09/06 02:56:08 brianp Exp $ */ /* $Id: extensions.c,v 1.79 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -113,6 +113,7 @@ static struct {
{ OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) }, { OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) },
{ OFF, "GL_MESA_packed_depth_stencil", 0 }, { OFF, "GL_MESA_packed_depth_stencil", 0 },
{ OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) }, { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
{ OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
{ ON, "GL_MESA_window_pos", F(MESA_window_pos) }, { ON, "GL_MESA_window_pos", F(MESA_window_pos) },
{ OFF, "GL_NV_blend_square", F(NV_blend_square) }, { OFF, "GL_NV_blend_square", F(NV_blend_square) },
{ OFF, "GL_NV_point_sprite", F(NV_point_sprite) }, { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
@@ -130,7 +131,9 @@ static struct {
{ OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) }, { OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) },
{ OFF, "GL_SGIX_shadow", F(SGIX_shadow) }, { OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
{ OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) }, { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
{ OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) } { OFF, "GL_3DFX_texture_compression_FXT1", F(_3DFX_texture_compression_FXT1) },
{ OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) }
}; };
@@ -181,6 +184,7 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
"GL_IBM_texture_mirrored_repeat", "GL_IBM_texture_mirrored_repeat",
"GL_INGR_blend_func_separate", "GL_INGR_blend_func_separate",
"GL_MESA_resize_buffers", "GL_MESA_resize_buffers",
"GL_MESA_ycbcr_texture",
"GL_NV_blend_square", "GL_NV_blend_square",
"GL_NV_point_sprite", "GL_NV_point_sprite",
"GL_NV_texture_rectangle", "GL_NV_texture_rectangle",

View File

@@ -1,4 +1,4 @@
/* $Id: image.c,v 1.66 2002/04/26 13:59:09 brianp Exp $ */ /* $Id: image.c,v 1.67 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -57,7 +57,8 @@ const struct gl_pixelstore_attrib _mesa_native_packing = {
0, /* ImageHeight */ 0, /* ImageHeight */
0, /* SkipImages */ 0, /* SkipImages */
GL_FALSE, /* SwapBytes */ GL_FALSE, /* SwapBytes */
GL_FALSE /* LsbFirst */ GL_FALSE, /* LsbFirst */
GL_FALSE /* ClientStorage */
}; };
@@ -203,6 +204,9 @@ GLint _mesa_sizeof_packed_type( GLenum type )
return sizeof(GLuint); return sizeof(GLuint);
case GL_UNSIGNED_INT_2_10_10_10_REV: case GL_UNSIGNED_INT_2_10_10_10_REV:
return sizeof(GLuint); return sizeof(GLuint);
case GL_UNSIGNED_SHORT_8_8_MESA:
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
return sizeof(GLushort);
default: default:
return -1; return -1;
} }
@@ -245,6 +249,8 @@ GLint _mesa_components_in_format( GLenum format )
return 4; return 4;
case GL_ABGR_EXT: case GL_ABGR_EXT:
return 4; return 4;
case GL_YCBCR_MESA:
return 2;
default: default:
return -1; return -1;
} }
@@ -303,6 +309,12 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
return sizeof(GLuint); return sizeof(GLuint);
else else
return -1; return -1;
case GL_UNSIGNED_SHORT_8_8_MESA:
case GL_UNSIGNED_SHORT_8_8_REV_MESA:
if (format == GL_YCBCR_MESA)
return sizeof(GLushort);
else
return -1;
default: default:
return -1; return -1;
} }
@@ -393,6 +405,12 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
default: default:
return GL_FALSE; return GL_FALSE;
} }
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
return GL_TRUE;
else
return GL_FALSE;
default: default:
; /* fall-through */ ; /* fall-through */
} }

View File

@@ -1,4 +1,4 @@
/* $Id: mtypes.h,v 1.85 2002/09/06 02:56:09 brianp Exp $ */ /* $Id: mtypes.h,v 1.86 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -850,6 +850,8 @@ struct gl_texture_image {
GLfloat HeightScale; /* used for mipmap lod computation */ GLfloat HeightScale; /* used for mipmap lod computation */
GLfloat DepthScale; /* used for mipmap lod computation */ GLfloat DepthScale; /* used for mipmap lod computation */
GLvoid *Data; /* Image data, accessed via FetchTexel() */ GLvoid *Data; /* Image data, accessed via FetchTexel() */
GLboolean IsClientData; /* Data owned by client? */
const struct gl_texture_format *TexFormat; const struct gl_texture_format *TexFormat;
@@ -1042,6 +1044,7 @@ struct gl_pixelstore_attrib {
GLint SkipImages; /* for GL_EXT_texture3D */ GLint SkipImages; /* for GL_EXT_texture3D */
GLboolean SwapBytes; GLboolean SwapBytes;
GLboolean LsbFirst; GLboolean LsbFirst;
GLboolean ClientStorage; /* GL_APPLE_client_storage */
}; };
@@ -1433,7 +1436,7 @@ struct gl_extensions {
GLboolean INGR_blend_func_separate; GLboolean INGR_blend_func_separate;
GLboolean MESA_window_pos; GLboolean MESA_window_pos;
GLboolean MESA_resize_buffers; GLboolean MESA_resize_buffers;
GLboolean MESA_sprite_point; GLboolean MESA_ycbcr_texture;
GLboolean NV_blend_square; GLboolean NV_blend_square;
GLboolean NV_point_sprite; GLboolean NV_point_sprite;
GLboolean NV_texture_rectangle; GLboolean NV_texture_rectangle;
@@ -1450,6 +1453,7 @@ struct gl_extensions {
GLboolean SGIX_shadow; GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */ GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean _3DFX_texture_compression_FXT1; GLboolean _3DFX_texture_compression_FXT1;
GLboolean APPLE_client_storage;
}; };

View File

@@ -1,4 +1,4 @@
/* $Id: pixel.c,v 1.34 2002/04/24 20:11:20 brianp Exp $ */ /* $Id: pixel.c,v 1.35 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -223,6 +223,12 @@ _mesa_PixelStorei( GLenum pname, GLint param )
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK); FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Unpack.Alignment = param; ctx->Unpack.Alignment = param;
break; break;
case GL_UNPACK_CLIENT_STORAGE_APPLE:
if (param == (GLint)ctx->Unpack.ClientStorage)
return;
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE;
break;
default: default:
_mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" ); _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
return; return;

View File

@@ -1,4 +1,4 @@
/* $Id: texformat.c,v 1.14 2002/07/09 01:22:50 brianp Exp $ */ /* $Id: texformat.c,v 1.15 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -437,6 +437,44 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
}; };
const struct gl_texture_format _mesa_texformat_ycbcr = {
MESA_FORMAT_YCBCR, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
GL_UNSIGNED_SHORT_8_8_MESA, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
0, /* AlphaBits */
0, /* LuminanceBits */
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
fetch_1d_texel_ycbcr, /* FetchTexel1D */
fetch_2d_texel_ycbcr, /* FetchTexel2D */
fetch_3d_texel_ycbcr, /* FetchTexel3D */
};
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
MESA_FORMAT_YCBCR_REV, /* MesaFormat */
GL_YCBCR_MESA, /* BaseFormat */
GL_UNSIGNED_SHORT_8_8_REV_MESA, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
0, /* AlphaBits */
0, /* LuminanceBits */
0, /* IntensityBits */
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
fetch_1d_texel_ycbcr_rev, /* FetchTexel1D */
fetch_2d_texel_ycbcr_rev, /* FetchTexel2D */
fetch_3d_texel_ycbcr_rev, /* FetchTexel3D */
};
/* Big-endian */ /* Big-endian */
#if 0 #if 0
const struct gl_texture_format _mesa_texformat_abgr8888 = { const struct gl_texture_format _mesa_texformat_abgr8888 = {
@@ -736,6 +774,12 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
_mesa_problem(ctx, "texture compression extension not enabled"); _mesa_problem(ctx, "texture compression extension not enabled");
return &_mesa_texformat_rgba; return &_mesa_texformat_rgba;
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA)
return &_mesa_texformat_ycbcr;
else
return &_mesa_texformat_ycbcr_rev;
default: default:
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()"); _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
_mesa_debug(ctx, "intformat = %d %x\n", internalFormat, internalFormat); _mesa_debug(ctx, "intformat = %d %x\n", internalFormat, internalFormat);

View File

@@ -1,4 +1,4 @@
/* $Id: texformat.h,v 1.9 2002/06/15 02:38:16 brianp Exp $ */ /* $Id: texformat.h,v 1.10 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -64,6 +64,9 @@ enum _format {
MESA_FORMAT_L8, /* LLLL LLLL */ MESA_FORMAT_L8, /* LLLL LLLL */
MESA_FORMAT_I8, /* IIII IIII */ MESA_FORMAT_I8, /* IIII IIII */
MESA_FORMAT_CI8, /* CCCC CCCC */ MESA_FORMAT_CI8, /* CCCC CCCC */
MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
#if 0 #if 0
/* upcoming little-endian formats: */ /* upcoming little-endian formats: */
@@ -141,6 +144,8 @@ extern const struct gl_texture_format _mesa_texformat_a8;
extern const struct gl_texture_format _mesa_texformat_l8; extern const struct gl_texture_format _mesa_texformat_l8;
extern const struct gl_texture_format _mesa_texformat_i8; extern const struct gl_texture_format _mesa_texformat_i8;
extern const struct gl_texture_format _mesa_texformat_ci8; extern const struct gl_texture_format _mesa_texformat_ci8;
extern const struct gl_texture_format _meas_texformat_ycbcr;
extern const struct gl_texture_format _meas_texformat_ycbcr_rev;
/* The null format: /* The null format:
*/ */

View File

@@ -1,10 +1,10 @@
/* $Id: texformat_tmp.h,v 1.6 2002/06/15 02:55:22 brianp Exp $ */ /* $Id: texformat_tmp.h,v 1.7 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
* Version: 3.5 * Version: 4.1
* *
* Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@@ -191,7 +191,8 @@ static void FETCH(rgb565)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
@@ -202,7 +203,8 @@ static void FETCH(argb4444)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
@@ -213,7 +215,8 @@ static void FETCH(argb1555)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
@@ -235,7 +238,8 @@ static void FETCH(rgb332)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
GLchan *rgba = (GLchan *) texel; GLubyte s = *src; const GLubyte s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
@@ -283,6 +287,67 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
*index = UBYTE_TO_CHAN( *src ); *index = UBYTE_TO_CHAN( *src );
} }
/* XXX this may break if GLchan != GLubyte */
static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel )
{
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
const GLubyte cb = *src0 & 0xff; /* chroma U */
const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
const GLubyte cr = *src1 & 0xff; /* chroma V */
GLchan *rgba = (GLchan *) texel;
GLint r, g, b;
if (i & 1) {
/* odd pixel: use y1,cr,cb */
r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
}
else {
/* even pixel: use y0,cr,cb */
r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
}
rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX);
rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX);
rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX);
rgba[ACOMP] = CHAN_MAX;
}
/* XXX this may break if GLchan != GLubyte */
static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel )
{
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
const GLubyte y0 = *src0 & 0xff; /* luminance */
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma U */
const GLubyte y1 = *src1 & 0xff; /* luminance */
const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma V */
GLchan *rgba = (GLchan *) texel;
GLint r, g, b;
if (i & 1) {
/* odd pixel: use y1,cr,cb */
r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
}
else {
/* even pixel: use y0,cr,cb */
r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
}
rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX);
rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX);
rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX);
rgba[ACOMP] = CHAN_MAX;
}
/* big-endian */ /* big-endian */
@@ -324,7 +389,8 @@ static void FETCH(bgr565)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
@@ -335,7 +401,8 @@ static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
@@ -346,7 +413,8 @@ static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLushort *src = USHORT_SRC( texImage, i, j, k ); const GLushort *src = USHORT_SRC( texImage, i, j, k );
GLchan *rgba = (GLchan *) texel; GLushort s = *src; const GLushort s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
@@ -368,7 +436,8 @@ static void FETCH(bgr233)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel ) GLint i, GLint j, GLint k, GLvoid *texel )
{ {
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 ); const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
GLchan *rgba = (GLchan *) texel; GLubyte s = *src; const GLubyte s = *src;
GLchan *rgba = (GLchan *) texel;
rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 ); rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 ); rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 ); rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );

View File

@@ -1,4 +1,4 @@
/* $Id: teximage.c,v 1.114 2002/09/14 16:51:34 brianp Exp $ */ /* $Id: teximage.c,v 1.115 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -222,6 +222,11 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format )
return GL_DEPTH_COMPONENT; return GL_DEPTH_COMPONENT;
else else
return -1; return -1;
case GL_YCBCR_MESA:
if (ctx->Extensions.MESA_ycbcr_texture)
return GL_YCBCR_MESA;
else
return -1;
default: default:
return -1; /* error */ return -1; /* error */
} }
@@ -279,6 +284,7 @@ is_color_format(GLenum format)
case GL_RGBA12: case GL_RGBA12:
case GL_RGBA16: case GL_RGBA16:
return GL_TRUE; return GL_TRUE;
case GL_YCBCR_MESA: /* not considered to be RGB */
default: default:
return GL_FALSE; return GL_FALSE;
} }
@@ -895,6 +901,21 @@ texture_error_check( GLcontext *ctx, GLenum target,
return GL_TRUE; return GL_TRUE;
} }
if (format == GL_YCBCR_MESA || iformat == GL_YCBCR_MESA) {
ASSERT(ctx->Extensions.MESA_ycbcr_texture);
if (format != GL_YCBCR_MESA ||
iformat != GL_YCBCR_MESA ||
(type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA)) {
char message[100];
sprintf(message,
"glTexImage%d(format/type/internalFormat YCBCR mismatch",
dimensions);
_mesa_error(ctx, GL_INVALID_ENUM, message);
return GL_TRUE; /* error */
}
}
/* if we get here, the parameters are OK */ /* if we get here, the parameters are OK */
return GL_FALSE; return GL_FALSE;
} }
@@ -1336,6 +1357,10 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)"); _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
} }
if (!ctx->Extensions.MESA_ycbcr_texture && format == GL_YCBCR_MESA) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
}
/* XXX what if format/type doesn't match texture format/type? */ /* XXX what if format/type doesn't match texture format/type? */
if (!pixels) if (!pixels)
@@ -1386,6 +1411,22 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
_mesa_pack_depth_span(ctx, width, dest, type, _mesa_pack_depth_span(ctx, width, dest, type,
depthRow, &ctx->Pack); depthRow, &ctx->Pack);
} }
else if (format == GL_YCBCR_MESA) {
/* No pixel transfer */
MEMCPY(dest, (const GLushort *) texImage->Data + row * width,
width * sizeof(GLushort));
/* check for byte swapping */
if ((texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR
&& type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
(texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV
&& type == GL_UNSIGNED_SHORT_8_8_MESA)) {
if (!ctx->Pack.SwapBytes)
_mesa_swap2((GLushort *) dest, width);
}
else if (ctx->Pack.SwapBytes) {
_mesa_swap2((GLushort *) dest, width);
}
}
else { else {
/* general case: convert row to RGBA format */ /* general case: convert row to RGBA format */
GLchan rgba[MAX_WIDTH][4]; GLchan rgba[MAX_WIDTH][4];
@@ -1538,8 +1579,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
GET_CURRENT_CONTEXT(ctx); GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
internalFormat = GL_RGBA;
if (is_color_format(internalFormat)) { if (is_color_format(internalFormat)) {
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
&postConvHeight); &postConvHeight);

View File

@@ -1,4 +1,4 @@
/* $Id: texstore.c,v 1.40 2002/09/17 14:14:18 brianp Exp $ */ /* $Id: texstore.c,v 1.41 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -115,6 +115,8 @@ components_in_intformat( GLint format )
case GL_DEPTH_COMPONENT24_SGIX: case GL_DEPTH_COMPONENT24_SGIX:
case GL_DEPTH_COMPONENT32_SGIX: case GL_DEPTH_COMPONENT32_SGIX:
return 1; return 1;
case GL_YCBCR_MESA:
return 2; /* Y + (Cb or Cr) */
default: default:
return -1; /* error */ return -1; /* error */
} }
@@ -255,6 +257,27 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
dest += dstImageStride; dest += dstImageStride;
} }
} }
else if (texDestFormat == GL_YCBCR_MESA) {
/* YCbCr texture */
GLint img, row;
GLushort *dest = (GLushort *) texDestAddr
+ dstZoffset * (dstImageStride / sizeof(GLushort))
+ dstYoffset * (dstRowStride / sizeof(GLushort))
+ dstXoffset * texComponents;
ASSERT(ctx->Extensions.MESA_ycbcr_texture);
printf("copy ycbcr\n");
for (img = 0; img < srcDepth; img++) {
GLushort *destRow = dest;
for (row = 0; row < srcHeight; row++) {
const GLvoid *srcRow = _mesa_image_address(srcPacking,
srcAddr, srcWidth, srcHeight,
srcFormat, srcType, img, row, 0);
MEMCPY(destRow, srcRow, srcWidth * sizeof(GLushort));
destRow += (dstRowStride / sizeof(GLushort));
}
dest += dstImageStride / sizeof(GLushort);
}
}
else if (texDestFormat == GL_DEPTH_COMPONENT) { else if (texDestFormat == GL_DEPTH_COMPONENT) {
/* Depth texture (shadow maps) */ /* Depth texture (shadow maps) */
GLint img, row; GLint img, row;

View File

@@ -1,4 +1,4 @@
/* $Id: texutil.c,v 1.30 2002/06/12 00:53:24 brianp Exp $ */ /* $Id: texutil.c,v 1.31 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -27,6 +27,14 @@
* Gareth Hughes <gareth@valinux.com> * Gareth Hughes <gareth@valinux.com>
*/ */
/*
* Description:
* Functions for texture image conversion. This takes care of converting
* typical GL_RGBA/GLubyte textures into hardware-specific formats.
* We can handle non-standard row strides and pixel unpacking parameters.
*/
#ifdef PC_HEADER #ifdef PC_HEADER
#include "all.h" #include "all.h"
#else #else
@@ -51,7 +59,7 @@
#endif #endif
struct gl_texture_convert { struct convert_info {
GLint xoffset, yoffset, zoffset; /* Subimage offset */ GLint xoffset, yoffset, zoffset; /* Subimage offset */
GLint width, height, depth; /* Subimage region */ GLint width, height, depth; /* Subimage region */
@@ -67,15 +75,16 @@ struct gl_texture_convert {
GLint index; GLint index;
}; };
typedef GLboolean (*convert_func)( struct gl_texture_convert *convert ); typedef GLboolean (*convert_func)( const struct convert_info *convert );
/* bitvalues for convert->index */
#define CONVERT_STRIDE_BIT 0x1 #define CONVERT_STRIDE_BIT 0x1
#define CONVERT_UNPACKING_BIT 0x2 #define CONVERT_UNPACKING_BIT 0x2
/* ============================================================= /* =============================================================
* RGBA8888 textures: * Convert to RGBA8888 textures:
*/ */
#define DST_TYPE GLuint #define DST_TYPE GLuint
@@ -118,7 +127,7 @@ typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
#define CONVERT_RGBA8888( name ) \ #define CONVERT_RGBA8888( name ) \
static GLboolean \ static GLboolean \
convert_##name##_rgba8888( struct gl_texture_convert *convert ) \ convert_##name##_rgba8888( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -154,7 +163,7 @@ CONVERT_RGBA8888( texsubimage3d )
/* ============================================================= /* =============================================================
* ARGB8888 textures: * Convert to ARGB8888 textures:
*/ */
#define DST_TYPE GLuint #define DST_TYPE GLuint
@@ -197,7 +206,7 @@ CONVERT_RGBA8888( texsubimage3d )
#define CONVERT_ARGB8888( name ) \ #define CONVERT_ARGB8888( name ) \
static GLboolean \ static GLboolean \
convert_##name##_argb8888( struct gl_texture_convert *convert ) \ convert_##name##_argb8888( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -232,11 +241,11 @@ CONVERT_ARGB8888( texsubimage3d )
/* ============================================================= /* =============================================================
* RGB888 textures: * Convert to RGB888 textures:
*/ */
static GLboolean static GLboolean
convert_texsubimage2d_rgb888( struct gl_texture_convert *convert ) convert_texsubimage2d_rgb888( const struct convert_info *convert )
{ {
/* This is a placeholder for now... /* This is a placeholder for now...
*/ */
@@ -244,7 +253,7 @@ convert_texsubimage2d_rgb888( struct gl_texture_convert *convert )
} }
static GLboolean static GLboolean
convert_texsubimage3d_rgb888( struct gl_texture_convert *convert ) convert_texsubimage3d_rgb888( const struct convert_info *convert )
{ {
/* This is a placeholder for now... /* This is a placeholder for now...
*/ */
@@ -254,7 +263,7 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
/* ============================================================= /* =============================================================
* RGB565 textures: * Convert to RGB565 textures:
*/ */
#define DST_TYPE GLushort #define DST_TYPE GLushort
@@ -301,7 +310,7 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
#define CONVERT_RGB565( name ) \ #define CONVERT_RGB565( name ) \
static GLboolean \ static GLboolean \
convert_##name##_rgb565( struct gl_texture_convert *convert ) \ convert_##name##_rgb565( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -336,7 +345,7 @@ CONVERT_RGB565( texsubimage3d )
/* ============================================================= /* =============================================================
* ARGB4444 textures: * Convert to ARGB4444 textures:
*/ */
#define DST_TYPE GLushort #define DST_TYPE GLushort
@@ -369,7 +378,7 @@ CONVERT_RGB565( texsubimage3d )
#define CONVERT_ARGB4444( name ) \ #define CONVERT_ARGB4444( name ) \
static GLboolean \ static GLboolean \
convert_##name##_argb4444( struct gl_texture_convert *convert ) \ convert_##name##_argb4444( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -399,7 +408,7 @@ CONVERT_ARGB4444( texsubimage3d )
/* ============================================================= /* =============================================================
* ARGB1555 textures: * Convert to ARGB1555 textures:
*/ */
#define DST_TYPE GLushort #define DST_TYPE GLushort
@@ -463,7 +472,7 @@ CONVERT_ARGB4444( texsubimage3d )
#define CONVERT_ARGB1555( name ) \ #define CONVERT_ARGB1555( name ) \
static GLboolean \ static GLboolean \
convert_##name##_argb1555( struct gl_texture_convert *convert ) \ convert_##name##_argb1555( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -559,7 +568,7 @@ CONVERT_ARGB1555( texsubimage3d )
#define CONVERT_AL88( name ) \ #define CONVERT_AL88( name ) \
static GLboolean \ static GLboolean \
convert_##name##_al88( struct gl_texture_convert *convert ) \ convert_##name##_al88( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -599,11 +608,11 @@ CONVERT_AL88( texsubimage3d )
/* ============================================================= /* =============================================================
* RGB332 textures: * Convert to RGB332 textures:
*/ */
static GLboolean static GLboolean
convert_texsubimage2d_rgb332( struct gl_texture_convert *convert ) convert_texsubimage2d_rgb332( const struct convert_info *convert )
{ {
/* This is a placeholder for now... /* This is a placeholder for now...
*/ */
@@ -611,7 +620,7 @@ convert_texsubimage2d_rgb332( struct gl_texture_convert *convert )
} }
static GLboolean static GLboolean
convert_texsubimage3d_rgb332( struct gl_texture_convert *convert ) convert_texsubimage3d_rgb332( const struct convert_info *convert )
{ {
/* This is a placeholder for now... /* This is a placeholder for now...
*/ */
@@ -639,7 +648,7 @@ convert_texsubimage3d_rgb332( struct gl_texture_convert *convert )
#define CONVERT_CI8( name ) \ #define CONVERT_CI8( name ) \
static GLboolean \ static GLboolean \
convert_##name##_ci8( struct gl_texture_convert *convert ) \ convert_##name##_ci8( const struct convert_info *convert ) \
{ \ { \
convert_func *tab; \ convert_func *tab; \
GLint index = convert->index; \ GLint index = convert->index; \
@@ -665,12 +674,88 @@ CONVERT_CI8( texsubimage2d )
CONVERT_CI8( texsubimage3d ) CONVERT_CI8( texsubimage3d )
/* =============================================================
* convert to YCBCR textures:
*/
#define DST_TYPE GLushort
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
dst = (src[0] << 8) | src[1];
#define CONVERT_DIRECT
#define SRC_TEXEL_BYTES 2
#define TAG(x) x##_ycbcr_direct
#include "texutil_tmp.h"
#define CONVERT_YCBCR( name ) \
static GLboolean \
convert_##name##_ycbcr( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
\
if (convert->format != GL_YCBCR_MESA) { \
/* Can't handle this source format/type combination */ \
return GL_FALSE; \
} \
tab = name##_tab_ycbcr_direct; \
\
return tab[index]( convert ); \
}
CONVERT_YCBCR( texsubimage2d )
CONVERT_YCBCR( texsubimage3d )
/* =============================================================
* convert to YCBCR_REV textures:
*/
#define DST_TYPE GLushort
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
dst = (src[1] << 8) | src[0];
#define CONVERT_DIRECT
#define SRC_TEXEL_BYTES 2
#define TAG(x) x##_ycbcr_rev_direct
#include "texutil_tmp.h"
#define CONVERT_YCBCR_REV( name ) \
static GLboolean \
convert_##name##_ycbcr_rev( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
\
if (convert->format != GL_YCBCR_MESA) { \
/* Can't handle this source format/type combination */ \
return GL_FALSE; \
} \
tab = name##_tab_ycbcr_rev_direct; \
\
return tab[index]( convert ); \
}
CONVERT_YCBCR_REV( texsubimage2d )
CONVERT_YCBCR_REV( texsubimage3d )
/* ============================================================= /* =============================================================
* Global entry points * Global entry points
*/ */
static convert_func gl_convert_texsubimage2d_tab[] = { static convert_func convert_texsubimage2d_tab[] = {
convert_texsubimage2d_rgba8888, convert_texsubimage2d_rgba8888,
convert_texsubimage2d_argb8888, convert_texsubimage2d_argb8888,
convert_texsubimage2d_rgb888, convert_texsubimage2d_rgb888,
@@ -683,9 +768,11 @@ static convert_func gl_convert_texsubimage2d_tab[] = {
convert_texsubimage2d_ci8, convert_texsubimage2d_ci8,
convert_texsubimage2d_ci8, convert_texsubimage2d_ci8,
convert_texsubimage2d_ci8, convert_texsubimage2d_ci8,
convert_texsubimage2d_ycbcr,
convert_texsubimage2d_ycbcr_rev,
}; };
static convert_func gl_convert_texsubimage3d_tab[] = { static convert_func convert_texsubimage3d_tab[] = {
convert_texsubimage3d_rgba8888, convert_texsubimage3d_rgba8888,
convert_texsubimage3d_argb8888, convert_texsubimage3d_argb8888,
convert_texsubimage3d_rgb888, convert_texsubimage3d_rgb888,
@@ -698,6 +785,8 @@ static convert_func gl_convert_texsubimage3d_tab[] = {
convert_texsubimage3d_ci8, convert_texsubimage3d_ci8,
convert_texsubimage3d_ci8, convert_texsubimage3d_ci8,
convert_texsubimage3d_ci8, convert_texsubimage3d_ci8,
convert_texsubimage3d_ycbcr,
convert_texsubimage3d_ycbcr_rev,
}; };
@@ -735,14 +824,14 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
const struct gl_pixelstore_attrib *unpacking, const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage ) const GLvoid *srcImage, GLvoid *dstImage )
{ {
struct gl_texture_convert convert; struct convert_info convert;
ASSERT( unpacking ); ASSERT( unpacking );
ASSERT( srcImage ); ASSERT( srcImage );
ASSERT( dstImage ); ASSERT( dstImage );
ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
ASSERT( mesaFormat <= MESA_FORMAT_CI8 ); ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV );
/* Make it easier to pass all the parameters around. /* Make it easier to pass all the parameters around.
*/ */
@@ -761,7 +850,9 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
if ( convert_needs_unpacking( unpacking, format, type ) ) if ( convert_needs_unpacking( unpacking, format, type ) )
convert.index |= CONVERT_UNPACKING_BIT; convert.index |= CONVERT_UNPACKING_BIT;
return gl_convert_texsubimage2d_tab[mesaFormat]( &convert ); ASSERT(convert.index < 4);
return convert_texsubimage2d_tab[mesaFormat]( &convert );
} }
@@ -791,22 +882,22 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
* destImage - pointer to dest image * destImage - pointer to dest image
*/ */
GLboolean GLboolean
_mesa_convert_texsubimage2d( GLint mesaFormat, _mesa_convert_texsubimage2d( GLint mesaFormat, /* dest */
GLint xoffset, GLint yoffset, GLint xoffset, GLint yoffset,
GLint width, GLint height, GLint width, GLint height,
GLint destImageWidth, GLint destImageWidth,
GLenum format, GLenum type, GLenum format, GLenum type, /* source */
const struct gl_pixelstore_attrib *unpacking, const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage ) const GLvoid *srcImage, GLvoid *dstImage )
{ {
struct gl_texture_convert convert; struct convert_info convert;
ASSERT( unpacking ); ASSERT( unpacking );
ASSERT( srcImage ); ASSERT( srcImage );
ASSERT( dstImage ); ASSERT( dstImage );
ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
ASSERT( mesaFormat <= MESA_FORMAT_CI8 ); ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV );
/* Make it easier to pass all the parameters around. /* Make it easier to pass all the parameters around.
*/ */
@@ -829,26 +920,26 @@ _mesa_convert_texsubimage2d( GLint mesaFormat,
if ( width != destImageWidth ) if ( width != destImageWidth )
convert.index |= CONVERT_STRIDE_BIT; convert.index |= CONVERT_STRIDE_BIT;
return gl_convert_texsubimage2d_tab[mesaFormat]( &convert ); return convert_texsubimage2d_tab[mesaFormat]( &convert );
} }
GLboolean GLboolean
_mesa_convert_texsubimage3d( GLint mesaFormat, _mesa_convert_texsubimage3d( GLint mesaFormat, /* dest */
GLint xoffset, GLint yoffset, GLint zoffset, GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth, GLint width, GLint height, GLint depth,
GLint dstImageWidth, GLint dstImageHeight, GLint dstImageWidth, GLint dstImageHeight,
GLenum format, GLenum type, GLenum format, GLenum type, /* source */
const struct gl_pixelstore_attrib *unpacking, const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage ) const GLvoid *srcImage, GLvoid *dstImage )
{ {
struct gl_texture_convert convert; struct convert_info convert;
ASSERT( unpacking ); ASSERT( unpacking );
ASSERT( srcImage ); ASSERT( srcImage );
ASSERT( dstImage ); ASSERT( dstImage );
ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 ); ASSERT( mesaFormat >= MESA_FORMAT_RGBA8888 );
ASSERT( mesaFormat <= MESA_FORMAT_CI8 ); ASSERT( mesaFormat <= MESA_FORMAT_YCBCR_REV );
/* Make it easier to pass all the parameters around. /* Make it easier to pass all the parameters around.
*/ */
@@ -874,7 +965,7 @@ _mesa_convert_texsubimage3d( GLint mesaFormat,
if ( width != dstImageWidth || height != dstImageHeight ) if ( width != dstImageWidth || height != dstImageHeight )
convert.index |= CONVERT_STRIDE_BIT; convert.index |= CONVERT_STRIDE_BIT;
return gl_convert_texsubimage3d_tab[mesaFormat]( &convert ); return convert_texsubimage3d_tab[mesaFormat]( &convert );
} }

View File

@@ -1,4 +1,4 @@
/* $Id: texutil_tmp.h,v 1.10 2002/06/29 19:48:16 brianp Exp $ */ /* $Id: texutil_tmp.h,v 1.11 2002/09/21 16:51:25 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -28,14 +28,27 @@
*/ */
/* /*
* NOTE: All 3D teximage code is untested and most definitely broken... * For 2D and 3D texture images, we generate functions for
* - conversion without pixel unpacking and standard stride
* - conversion without pixel unpacking and non-standard stride
* - conversion with pixel unpacking and standard stride
* - conversion with pixel unpacking and non-standard stride
*
*
* Macros which need to be defined before including this file:
* TAG(x) - the function name wrapper
* DST_TYPE - the destination texel datatype (GLuint, GLushort, etc)
* DST_TEXELS_PER_DWORD - number of dest texels that'll fit in 4 bytes
* CONVERT_TEXEL - code to convert from source to dest texel
* CONVER_TEXEL_DWORD - if multiple texels fit in 4 bytes, this macros
* will convert/store multiple texels at once
* CONVERT_DIRECT - if defined, just memcpy texels from src to dest
* SRC_TEXEL_BYTES - bytes per source texel
* PRESERVE_DST_TYPE - if defined, don't undefined these macros at end
*/ */
#define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD) #define DST_TEXEL_BYTES (4 / DST_TEXELS_PER_DWORD)
#define DST_ROW_BYTES (convert->width * DST_TEXEL_BYTES) #define DST_ROW_BYTES (convert->width * DST_TEXEL_BYTES)
#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES) #define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES)
@@ -47,7 +60,7 @@
* PRE: No pixelstore attribs, width == dstImageWidth. * PRE: No pixelstore attribs, width == dstImageWidth.
*/ */
static GLboolean static GLboolean
TAG(texsubimage2d)( struct gl_texture_convert *convert ) TAG(texsubimage2d)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *)convert->srcImage; const GLubyte *src = (const GLubyte *)convert->srcImage;
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
@@ -83,7 +96,7 @@ TAG(texsubimage2d)( struct gl_texture_convert *convert )
/* PRE: As above, height == dstImageHeight also. /* PRE: As above, height == dstImageHeight also.
*/ */
static GLboolean static GLboolean
TAG(texsubimage3d)( struct gl_texture_convert *convert ) TAG(texsubimage3d)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *)convert->srcImage; const GLubyte *src = (const GLubyte *)convert->srcImage;
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage + GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
@@ -122,7 +135,7 @@ TAG(texsubimage3d)( struct gl_texture_convert *convert )
* PRE: No pixelstore attribs, width != dstImageWidth. * PRE: No pixelstore attribs, width != dstImageWidth.
*/ */
static GLboolean static GLboolean
TAG(texsubimage2d_stride)( struct gl_texture_convert *convert ) TAG(texsubimage2d_stride)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *)convert->srcImage; const GLubyte *src = (const GLubyte *)convert->srcImage;
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
@@ -155,7 +168,7 @@ TAG(texsubimage2d_stride)( struct gl_texture_convert *convert )
/* PRE: As above, or height != dstImageHeight also. /* PRE: As above, or height != dstImageHeight also.
*/ */
static GLboolean static GLboolean
TAG(texsubimage3d_stride)( struct gl_texture_convert *convert ) TAG(texsubimage3d_stride)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *)convert->srcImage; const GLubyte *src = (const GLubyte *)convert->srcImage;
DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage + DST_TYPE *dst = (DST_TYPE *)((GLubyte *)convert->dstImage +
@@ -195,7 +208,7 @@ TAG(texsubimage3d_stride)( struct gl_texture_convert *convert )
* PRE: Require pixelstore attribs, width == dstImageWidth. * PRE: Require pixelstore attribs, width == dstImageWidth.
*/ */
static GLboolean static GLboolean
TAG(texsubimage2d_unpack)( struct gl_texture_convert *convert ) TAG(texsubimage2d_unpack)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( convert->unpacking, convert->srcImage, _mesa_image_address( convert->unpacking, convert->srcImage,
@@ -253,7 +266,7 @@ TAG(texsubimage2d_unpack)( struct gl_texture_convert *convert )
/* PRE: as above, height == dstImageHeight also. /* PRE: as above, height == dstImageHeight also.
*/ */
static GLboolean static GLboolean
TAG(texsubimage3d_unpack)( struct gl_texture_convert *convert ) TAG(texsubimage3d_unpack)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( convert->unpacking, convert->srcImage, _mesa_image_address( convert->unpacking, convert->srcImage,
@@ -328,7 +341,7 @@ TAG(texsubimage3d_unpack)( struct gl_texture_convert *convert )
* PRE: Require pixelstore attribs, width != dstImageWidth. * PRE: Require pixelstore attribs, width != dstImageWidth.
*/ */
static GLboolean static GLboolean
TAG(texsubimage2d_stride_unpack)( struct gl_texture_convert *convert ) TAG(texsubimage2d_stride_unpack)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( convert->unpacking, convert->srcImage, _mesa_image_address( convert->unpacking, convert->srcImage,
@@ -376,7 +389,7 @@ TAG(texsubimage2d_stride_unpack)( struct gl_texture_convert *convert )
/* PRE: As above, or height != dstImageHeight also. /* PRE: As above, or height != dstImageHeight also.
*/ */
static GLboolean static GLboolean
TAG(texsubimage3d_stride_unpack)( struct gl_texture_convert *convert ) TAG(texsubimage3d_stride_unpack)( const struct convert_info *convert )
{ {
const GLubyte *src = (const GLubyte *) const GLubyte *src = (const GLubyte *)
_mesa_image_address( convert->unpacking, convert->srcImage, _mesa_image_address( convert->unpacking, convert->srcImage,

View File

@@ -1,4 +1,4 @@
/* $Id: s_texture.c,v 1.65 2002/08/07 00:45:07 brianp Exp $ */ /* $Id: s_texture.c,v 1.66 2002/09/21 16:51:26 brianp Exp $ */
/* /*
* Mesa 3-D graphics library * Mesa 3-D graphics library
@@ -3268,7 +3268,8 @@ texture_apply( const GLcontext *ctx,
format = texUnit->_Current->Image[baseLevel]->Format; format = texUnit->_Current->Image[baseLevel]->Format;
if (format == GL_COLOR_INDEX || format == GL_DEPTH_COMPONENT) { if (format == GL_COLOR_INDEX || format == GL_DEPTH_COMPONENT
|| format == GL_YCBCR_MESA) {
format = GL_RGBA; /* a bit of a hack */ format = GL_RGBA; /* a bit of a hack */
} }