summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/extensions.c8
-rw-r--r--src/mesa/main/image.c22
-rw-r--r--src/mesa/main/mtypes.h8
-rw-r--r--src/mesa/main/pixel.c8
-rw-r--r--src/mesa/main/texformat.c46
-rw-r--r--src/mesa/main/texformat.h7
-rw-r--r--src/mesa/main/texformat_tmp.h91
-rw-r--r--src/mesa/main/teximage.c45
-rw-r--r--src/mesa/main/texstore.c25
-rw-r--r--src/mesa/main/texutil.c163
-rw-r--r--src/mesa/main/texutil_tmp.h39
-rw-r--r--src/mesa/swrast/s_texture.c5
12 files changed, 392 insertions, 75 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 24ab1ab244a..d7b311e8af1 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -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
@@ -113,6 +113,7 @@ static struct {
{ OFF, "GL_INGR_blend_func_separate", F(INGR_blend_func_separate) },
{ OFF, "GL_MESA_packed_depth_stencil", 0 },
{ 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) },
{ OFF, "GL_NV_blend_square", F(NV_blend_square) },
{ 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_shadow", F(SGIX_shadow) },
{ 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_INGR_blend_func_separate",
"GL_MESA_resize_buffers",
+ "GL_MESA_ycbcr_texture",
"GL_NV_blend_square",
"GL_NV_point_sprite",
"GL_NV_texture_rectangle",
diff --git a/src/mesa/main/image.c b/src/mesa/main/image.c
index 4eca41af86b..71ed77fceab 100644
--- a/src/mesa/main/image.c
+++ b/src/mesa/main/image.c
@@ -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
@@ -57,7 +57,8 @@ const struct gl_pixelstore_attrib _mesa_native_packing = {
0, /* ImageHeight */
0, /* SkipImages */
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);
case GL_UNSIGNED_INT_2_10_10_10_REV:
return sizeof(GLuint);
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ return sizeof(GLushort);
default:
return -1;
}
@@ -245,6 +249,8 @@ GLint _mesa_components_in_format( GLenum format )
return 4;
case GL_ABGR_EXT:
return 4;
+ case GL_YCBCR_MESA:
+ return 2;
default:
return -1;
}
@@ -303,6 +309,12 @@ GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
return sizeof(GLuint);
else
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:
return -1;
}
@@ -393,6 +405,12 @@ _mesa_is_legal_format_and_type( GLenum format, GLenum type )
default:
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:
; /* fall-through */
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 99349968869..9b6be650785 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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
@@ -850,6 +850,8 @@ struct gl_texture_image {
GLfloat HeightScale; /* used for mipmap lod computation */
GLfloat DepthScale; /* used for mipmap lod computation */
GLvoid *Data; /* Image data, accessed via FetchTexel() */
+ GLboolean IsClientData; /* Data owned by client? */
+
const struct gl_texture_format *TexFormat;
@@ -1042,6 +1044,7 @@ struct gl_pixelstore_attrib {
GLint SkipImages; /* for GL_EXT_texture3D */
GLboolean SwapBytes;
GLboolean LsbFirst;
+ GLboolean ClientStorage; /* GL_APPLE_client_storage */
};
@@ -1433,7 +1436,7 @@ struct gl_extensions {
GLboolean INGR_blend_func_separate;
GLboolean MESA_window_pos;
GLboolean MESA_resize_buffers;
- GLboolean MESA_sprite_point;
+ GLboolean MESA_ycbcr_texture;
GLboolean NV_blend_square;
GLboolean NV_point_sprite;
GLboolean NV_texture_rectangle;
@@ -1450,6 +1453,7 @@ struct gl_extensions {
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean _3DFX_texture_compression_FXT1;
+ GLboolean APPLE_client_storage;
};
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 659797e55b5..85221573047 100644
--- a/src/mesa/main/pixel.c
+++ b/src/mesa/main/pixel.c
@@ -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
@@ -223,6 +223,12 @@ _mesa_PixelStorei( GLenum pname, GLint param )
FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
ctx->Unpack.Alignment = param;
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:
_mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
return;
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 4795aeffb2f..2c95b838592 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -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
@@ -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 */
#if 0
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");
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:
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
_mesa_debug(ctx, "intformat = %d %x\n", internalFormat, internalFormat);
diff --git a/src/mesa/main/texformat.h b/src/mesa/main/texformat.h
index 9d0497708c4..802f4acefb5 100644
--- a/src/mesa/main/texformat.h
+++ b/src/mesa/main/texformat.h
@@ -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
@@ -64,6 +64,9 @@ enum _format {
MESA_FORMAT_L8, /* LLLL LLLL */
MESA_FORMAT_I8, /* IIII IIII */
MESA_FORMAT_CI8, /* CCCC CCCC */
+ MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
+ MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
+
#if 0
/* 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_i8;
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:
*/
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index bea9d87a867..35f89d54936 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -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
- * 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
* 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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
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 );
}
+/* 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 */
@@ -324,7 +389,8 @@ static void FETCH(bgr565)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLvoid *texel )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 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 )
{
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[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 963a4503dd5..e62081be5bd 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -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
@@ -222,6 +222,11 @@ _mesa_base_tex_format( GLcontext *ctx, GLint format )
return GL_DEPTH_COMPONENT;
else
return -1;
+ case GL_YCBCR_MESA:
+ if (ctx->Extensions.MESA_ycbcr_texture)
+ return GL_YCBCR_MESA;
+ else
+ return -1;
default:
return -1; /* error */
}
@@ -279,6 +284,7 @@ is_color_format(GLenum format)
case GL_RGBA12:
case GL_RGBA16:
return GL_TRUE;
+ case GL_YCBCR_MESA: /* not considered to be RGB */
default:
return GL_FALSE;
}
@@ -895,6 +901,21 @@ texture_error_check( GLcontext *ctx, GLenum target,
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 */
return GL_FALSE;
}
@@ -1336,6 +1357,10 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum 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? */
if (!pixels)
@@ -1386,6 +1411,22 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
_mesa_pack_depth_span(ctx, width, dest, type,
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 {
/* general case: convert row to RGBA format */
GLchan rgba[MAX_WIDTH][4];
@@ -1538,8 +1579,6 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
- internalFormat = GL_RGBA;
-
if (is_color_format(internalFormat)) {
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
&postConvHeight);
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index c1fa760247f..07404a26094 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -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
@@ -115,6 +115,8 @@ components_in_intformat( GLint format )
case GL_DEPTH_COMPONENT24_SGIX:
case GL_DEPTH_COMPONENT32_SGIX:
return 1;
+ case GL_YCBCR_MESA:
+ return 2; /* Y + (Cb or Cr) */
default:
return -1; /* error */
}
@@ -255,6 +257,27 @@ transfer_teximage(GLcontext *ctx, GLuint dimensions,
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) {
/* Depth texture (shadow maps) */
GLint img, row;
diff --git a/src/mesa/main/texutil.c b/src/mesa/main/texutil.c
index 97e9c4561b5..75bd3b22633 100644
--- a/src/mesa/main/texutil.c
+++ b/src/mesa/main/texutil.c
@@ -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
@@ -27,6 +27,14 @@
* Gareth Hughes <[email protected]>
*/
+/*
+ * 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
#include "all.h"
#else
@@ -51,7 +59,7 @@
#endif
-struct gl_texture_convert {
+struct convert_info {
GLint xoffset, yoffset, zoffset; /* Subimage offset */
GLint width, height, depth; /* Subimage region */
@@ -67,15 +75,16 @@ struct gl_texture_convert {
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_UNPACKING_BIT 0x2
/* =============================================================
- * RGBA8888 textures:
+ * Convert to RGBA8888 textures:
*/
#define DST_TYPE GLuint
@@ -118,7 +127,7 @@ typedef GLboolean (*convert_func)( struct gl_texture_convert *convert );
#define CONVERT_RGBA8888( name ) \
static GLboolean \
-convert_##name##_rgba8888( struct gl_texture_convert *convert ) \
+convert_##name##_rgba8888( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -154,7 +163,7 @@ CONVERT_RGBA8888( texsubimage3d )
/* =============================================================
- * ARGB8888 textures:
+ * Convert to ARGB8888 textures:
*/
#define DST_TYPE GLuint
@@ -197,7 +206,7 @@ CONVERT_RGBA8888( texsubimage3d )
#define CONVERT_ARGB8888( name ) \
static GLboolean \
-convert_##name##_argb8888( struct gl_texture_convert *convert ) \
+convert_##name##_argb8888( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -232,11 +241,11 @@ CONVERT_ARGB8888( texsubimage3d )
/* =============================================================
- * RGB888 textures:
+ * Convert to RGB888 textures:
*/
static GLboolean
-convert_texsubimage2d_rgb888( struct gl_texture_convert *convert )
+convert_texsubimage2d_rgb888( const struct convert_info *convert )
{
/* This is a placeholder for now...
*/
@@ -244,7 +253,7 @@ convert_texsubimage2d_rgb888( struct gl_texture_convert *convert )
}
static GLboolean
-convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
+convert_texsubimage3d_rgb888( const struct convert_info *convert )
{
/* 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
@@ -301,7 +310,7 @@ convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
#define CONVERT_RGB565( name ) \
static GLboolean \
-convert_##name##_rgb565( struct gl_texture_convert *convert ) \
+convert_##name##_rgb565( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -336,7 +345,7 @@ CONVERT_RGB565( texsubimage3d )
/* =============================================================
- * ARGB4444 textures:
+ * Convert to ARGB4444 textures:
*/
#define DST_TYPE GLushort
@@ -369,7 +378,7 @@ CONVERT_RGB565( texsubimage3d )
#define CONVERT_ARGB4444( name ) \
static GLboolean \
-convert_##name##_argb4444( struct gl_texture_convert *convert ) \
+convert_##name##_argb4444( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -399,7 +408,7 @@ CONVERT_ARGB4444( texsubimage3d )
/* =============================================================
- * ARGB1555 textures:
+ * Convert to ARGB1555 textures:
*/
#define DST_TYPE GLushort
@@ -463,7 +472,7 @@ CONVERT_ARGB4444( texsubimage3d )
#define CONVERT_ARGB1555( name ) \
static GLboolean \
-convert_##name##_argb1555( struct gl_texture_convert *convert ) \
+convert_##name##_argb1555( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -559,7 +568,7 @@ CONVERT_ARGB1555( texsubimage3d )
#define CONVERT_AL88( name ) \
static GLboolean \
-convert_##name##_al88( struct gl_texture_convert *convert ) \
+convert_##name##_al88( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -599,11 +608,11 @@ CONVERT_AL88( texsubimage3d )
/* =============================================================
- * RGB332 textures:
+ * Convert to RGB332 textures:
*/
static GLboolean
-convert_texsubimage2d_rgb332( struct gl_texture_convert *convert )
+convert_texsubimage2d_rgb332( const struct convert_info *convert )
{
/* This is a placeholder for now...
*/
@@ -611,7 +620,7 @@ convert_texsubimage2d_rgb332( struct gl_texture_convert *convert )
}
static GLboolean
-convert_texsubimage3d_rgb332( struct gl_texture_convert *convert )
+convert_texsubimage3d_rgb332( const struct convert_info *convert )
{
/* This is a placeholder for now...
*/
@@ -639,7 +648,7 @@ convert_texsubimage3d_rgb332( struct gl_texture_convert *convert )
#define CONVERT_CI8( name ) \
static GLboolean \
-convert_##name##_ci8( struct gl_texture_convert *convert ) \
+convert_##name##_ci8( const struct convert_info *convert ) \
{ \
convert_func *tab; \
GLint index = convert->index; \
@@ -665,12 +674,88 @@ CONVERT_CI8( texsubimage2d )
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
*/
-static convert_func gl_convert_texsubimage2d_tab[] = {
+static convert_func convert_texsubimage2d_tab[] = {
convert_texsubimage2d_rgba8888,
convert_texsubimage2d_argb8888,
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_ycbcr,
+ convert_texsubimage2d_ycbcr_rev,
};
-static convert_func gl_convert_texsubimage3d_tab[] = {
+static convert_func convert_texsubimage3d_tab[] = {
convert_texsubimage3d_rgba8888,
convert_texsubimage3d_argb8888,
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_ycbcr,
+ convert_texsubimage3d_ycbcr_rev,
};
@@ -735,14 +824,14 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage )
{
- struct gl_texture_convert convert;
+ struct convert_info convert;
ASSERT( unpacking );
ASSERT( srcImage );
ASSERT( dstImage );
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.
*/
@@ -761,7 +850,9 @@ _mesa_convert_texsubimage1d( GLint mesaFormat,
if ( convert_needs_unpacking( unpacking, format, type ) )
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
*/
GLboolean
-_mesa_convert_texsubimage2d( GLint mesaFormat,
+_mesa_convert_texsubimage2d( GLint mesaFormat, /* dest */
GLint xoffset, GLint yoffset,
GLint width, GLint height,
GLint destImageWidth,
- GLenum format, GLenum type,
+ GLenum format, GLenum type, /* source */
const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage )
{
- struct gl_texture_convert convert;
+ struct convert_info convert;
ASSERT( unpacking );
ASSERT( srcImage );
ASSERT( dstImage );
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.
*/
@@ -829,26 +920,26 @@ _mesa_convert_texsubimage2d( GLint mesaFormat,
if ( width != destImageWidth )
convert.index |= CONVERT_STRIDE_BIT;
- return gl_convert_texsubimage2d_tab[mesaFormat]( &convert );
+ return convert_texsubimage2d_tab[mesaFormat]( &convert );
}
GLboolean
-_mesa_convert_texsubimage3d( GLint mesaFormat,
+_mesa_convert_texsubimage3d( GLint mesaFormat, /* dest */
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLint dstImageWidth, GLint dstImageHeight,
- GLenum format, GLenum type,
+ GLenum format, GLenum type, /* source */
const struct gl_pixelstore_attrib *unpacking,
const GLvoid *srcImage, GLvoid *dstImage )
{
- struct gl_texture_convert convert;
+ struct convert_info convert;
ASSERT( unpacking );
ASSERT( srcImage );
ASSERT( dstImage );
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.
*/
@@ -874,7 +965,7 @@ _mesa_convert_texsubimage3d( GLint mesaFormat,
if ( width != dstImageWidth || height != dstImageHeight )
convert.index |= CONVERT_STRIDE_BIT;
- return gl_convert_texsubimage3d_tab[mesaFormat]( &convert );
+ return convert_texsubimage3d_tab[mesaFormat]( &convert );
}
diff --git a/src/mesa/main/texutil_tmp.h b/src/mesa/main/texutil_tmp.h
index 7a70a55d024..3a225aaac54 100644
--- a/src/mesa/main/texutil_tmp.h
+++ b/src/mesa/main/texutil_tmp.h
@@ -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
@@ -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_ROW_BYTES (convert->width * DST_TEXEL_BYTES)
#define DST_ROW_STRIDE (convert->dstImageWidth * DST_TEXEL_BYTES)
@@ -47,7 +60,7 @@
* PRE: No pixelstore attribs, width == dstImageWidth.
*/
static GLboolean
-TAG(texsubimage2d)( struct gl_texture_convert *convert )
+TAG(texsubimage2d)( const struct convert_info *convert )
{
const GLubyte *src = (const GLubyte *)convert->srcImage;
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
@@ -83,7 +96,7 @@ TAG(texsubimage2d)( struct gl_texture_convert *convert )
/* PRE: As above, height == dstImageHeight also.
*/
static GLboolean
-TAG(texsubimage3d)( struct gl_texture_convert *convert )
+TAG(texsubimage3d)( const struct convert_info *convert )
{
const GLubyte *src = (const GLubyte *)convert->srcImage;
GLuint *dst = (GLuint *)((GLubyte *)convert->dstImage +
@@ -122,7 +135,7 @@ TAG(texsubimage3d)( struct gl_texture_convert *convert )
* PRE: No pixelstore attribs, width != dstImageWidth.
*/
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;
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.
*/
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;
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.
*/
static GLboolean
-TAG(texsubimage2d_unpack)( struct gl_texture_convert *convert )
+TAG(texsubimage2d_unpack)( const struct convert_info *convert )
{
const GLubyte *src = (const GLubyte *)
_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.
*/
static GLboolean
-TAG(texsubimage3d_unpack)( struct gl_texture_convert *convert )
+TAG(texsubimage3d_unpack)( const struct convert_info *convert )
{
const GLubyte *src = (const GLubyte *)
_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.
*/
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 *)
_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.
*/
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 *)
_mesa_image_address( convert->unpacking, convert->srcImage,
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index f769e1e0f93..fd2bf95b178 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -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
@@ -3268,7 +3268,8 @@ texture_apply( const GLcontext *ctx,
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 */
}