-/* $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
{ 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) },
{ 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) }
+
};
"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",
-/* $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
0, /* ImageHeight */
0, /* SkipImages */
GL_FALSE, /* SwapBytes */
- GL_FALSE /* LsbFirst */
+ GL_FALSE, /* LsbFirst */
+ GL_FALSE /* ClientStorage */
};
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;
}
return 4;
case GL_ABGR_EXT:
return 4;
+ case GL_YCBCR_MESA:
+ return 2;
default:
return -1;
}
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;
}
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 */
}
-/* $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
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;
GLint SkipImages; /* for GL_EXT_texture3D */
GLboolean SwapBytes;
GLboolean LsbFirst;
+ GLboolean ClientStorage; /* GL_APPLE_client_storage */
};
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;
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean _3DFX_texture_compression_FXT1;
+ GLboolean APPLE_client_storage;
};
-/* $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
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;
-/* $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
};
+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 = {
_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);
-/* $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_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: */
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:
*/
-/* $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"),
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 );
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 );
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 );
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 );
*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 */
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 );
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 );
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 );
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 );
-/* $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
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 */
}
case GL_RGBA12:
case GL_RGBA16:
return GL_TRUE;
+ case GL_YCBCR_MESA: /* not considered to be RGB */
default:
return GL_FALSE;
}
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;
}
_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)
_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];
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);
-/* $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
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 */
}
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;
-/* $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
* 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
#include "all.h"
#else
#endif
-struct gl_texture_convert {
+struct convert_info {
GLint xoffset, yoffset, zoffset; /* Subimage offset */
GLint width, height, depth; /* Subimage region */
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
#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; \
/* =============================================================
- * ARGB8888 textures:
+ * Convert to ARGB8888 textures:
*/
#define DST_TYPE GLuint
#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; \
/* =============================================================
- * 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...
*/
}
static GLboolean
-convert_texsubimage3d_rgb888( struct gl_texture_convert *convert )
+convert_texsubimage3d_rgb888( const struct convert_info *convert )
{
/* This is a placeholder for now...
*/
/* =============================================================
- * RGB565 textures:
+ * Convert to RGB565 textures:
*/
#define DST_TYPE GLushort
#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; \
/* =============================================================
- * ARGB4444 textures:
+ * Convert to ARGB4444 textures:
*/
#define DST_TYPE GLushort
#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; \
/* =============================================================
- * ARGB1555 textures:
+ * Convert to ARGB1555 textures:
*/
#define DST_TYPE GLushort
#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; \
#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; \
/* =============================================================
- * 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...
*/
}
static GLboolean
-convert_texsubimage3d_rgb332( struct gl_texture_convert *convert )
+convert_texsubimage3d_rgb332( const struct convert_info *convert )
{
/* This is a placeholder for now...
*/
#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; \
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,
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,
convert_texsubimage3d_ci8,
convert_texsubimage3d_ci8,
convert_texsubimage3d_ci8,
+ convert_texsubimage3d_ycbcr,
+ convert_texsubimage3d_ycbcr_rev,
};
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.
*/
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 );
}
* 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.
*/
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.
*/
if ( width != dstImageWidth || height != dstImageHeight )
convert.index |= CONVERT_STRIDE_BIT;
- return gl_convert_texsubimage3d_tab[mesaFormat]( &convert );
+ return convert_texsubimage3d_tab[mesaFormat]( &convert );
}
-/* $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
*/
-
/*
- * 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)
* 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 +
/* 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 +
* 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 +
/* 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 +
* 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,
/* 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,
* 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,
/* 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,
-/* $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
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 */
}