summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_tex.c40
-rw-r--r--src/mesa/main/mtypes.h43
-rw-r--r--src/mesa/main/texformat.c309
-rw-r--r--src/mesa/main/texformat_tmp.h732
-rw-r--r--src/mesa/main/teximage.c82
-rw-r--r--src/mesa/main/texstore.c24
-rw-r--r--src/mesa/swrast/s_nvfragprog.c1
-rw-r--r--src/mesa/swrast/s_texture.c70
8 files changed, 898 insertions, 403 deletions
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
index 3463cc5a6d8..9942166de67 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_tex.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -705,9 +705,8 @@ fxGlideFormat(GLint mesaFormat)
static void
fetch_intensity8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLubyte *texel;
@@ -724,9 +723,8 @@ fetch_intensity8(const struct gl_texture_image *texImage,
static void
fetch_luminance8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLubyte *texel;
@@ -743,9 +741,8 @@ fetch_luminance8(const struct gl_texture_image *texImage,
static void
fetch_alpha8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLubyte *texel;
@@ -764,7 +761,7 @@ fetch_alpha8(const struct gl_texture_image *texImage,
static void
fetch_index8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
(void) mml;
@@ -774,28 +771,26 @@ fetch_index8(const struct gl_texture_image *texImage,
static void
fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLubyte *texel;
- i = i * mml->wScale;
- j = j * mml->hScale;
+ i = i * mml->wScale;
+ j = j * mml->hScale;
- texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2;
- rgba[RCOMP] = texel[0];
- rgba[GCOMP] = texel[0];
- rgba[BCOMP] = texel[0];
- rgba[ACOMP] = texel[1];
+ texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2;
+ rgba[RCOMP] = texel[0];
+ rgba[GCOMP] = texel[0];
+ rgba[BCOMP] = texel[0];
+ rgba[ACOMP] = texel[1];
}
static void
fetch_r5g6b5(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLushort *texel;
@@ -812,9 +807,8 @@ fetch_r5g6b5(const struct gl_texture_image *texImage,
static void
fetch_r4g4b4a4(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLushort *texel;
@@ -831,9 +825,8 @@ fetch_r4g4b4a4(const struct gl_texture_image *texImage,
static void
fetch_r5g5b5a1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLushort *texel;
@@ -850,9 +843,8 @@ fetch_r5g5b5a1(const struct gl_texture_image *texImage,
static void
fetch_a8r8g8b8(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid * texelOut)
+ GLint i, GLint j, GLint k, GLchan * rgba)
{
- GLchan *rgba = (GLchan *) texelOut;
const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
const GLuint *texel;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a5f7e366c1f..a9c5f2ceca4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -7,9 +7,9 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
@@ -955,20 +955,31 @@ struct gl_stencil_attrib {
#define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
#define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
+
/**
- * Texel fetch function prototype.
+ * Texel fetch function prototype. We use texel fetch functions to
+ * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
+ * texture images. These functions help to isolate us from the gritty
+ * details of all the various texture image encodings.
*
* \param texImage texture image.
* \param col texel column.
* \param row texel row.
- * \param img texel level.
- * \param texelOut output texel. If \p texImage is color-index, \p texelOut
- * returns <tt>GLchan[1]</tt>. If \p texImage is depth, \p texelOut returns
- * <tt>GLfloat[1]</tt>. Otherwise, \p texelOut returns <tt>GLchan[4]</tt>.
+ * \param img texel image level/layer.
+ * \param texelOut output texel (up to 4 GLchans)
+ */
+typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLchan *texelOut );
+
+/**
+ * As above, but returns floats.
+ * Used for depth component images and for upcoming signed/float
+ * texture images.
*/
-typedef void (*FetchTexelFunc)( const struct gl_texture_image *texImage,
- GLint col, GLint row, GLint img,
- GLvoid *texelOut );
+typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut );
/**
* Texture format record
@@ -995,9 +1006,12 @@ struct gl_texture_format {
* \name Texel fetch function pointers
*/
/*@{*/
- FetchTexelFunc FetchTexel1D;
- FetchTexelFunc FetchTexel2D;
- FetchTexelFunc FetchTexel3D;
+ FetchTexelFuncC FetchTexel1D;
+ FetchTexelFuncC FetchTexel2D;
+ FetchTexelFuncC FetchTexel3D;
+ FetchTexelFuncF FetchTexel1Df;
+ FetchTexelFuncF FetchTexel2Df;
+ FetchTexelFuncF FetchTexel3Df;
/*@}*/
};
@@ -1033,7 +1047,8 @@ struct gl_texture_image {
const struct gl_texture_format *TexFormat;
- FetchTexelFunc FetchTexel; /**< Texel fetch function pointer */
+ FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
+ FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
GLboolean IsCompressed; /**< GL_ARB_texture_compression */
GLuint CompressedSize; /**< GL_ARB_texture_compression */
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 7af0b1cdf48..7d366b51d79 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -58,13 +58,23 @@
* Have to have this so the FetchTexel function pointer is never NULL.
*/
static void fetch_null_texel( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = 0;
- rgba[GCOMP] = 0;
- rgba[BCOMP] = 0;
- rgba[ACOMP] = 0;
+ texel[RCOMP] = 0;
+ texel[GCOMP] = 0;
+ texel[BCOMP] = 0;
+ texel[ACOMP] = 0;
+ _mesa_warning(NULL, "fetch_null_texel() called!");
+}
+
+static void fetch_null_texelf( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ texel[RCOMP] = 0.0;
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 0.0;
+ _mesa_warning(NULL, "fetch_null_texelf() called!");
}
@@ -84,9 +94,12 @@ const struct gl_texture_format _mesa_texformat_rgba = {
0, /* IndexBits */
0, /* DepthBits */
4 * CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_rgba, /* FetchTexel1D */
- fetch_2d_texel_rgba, /* FetchTexel2D */
- fetch_3d_texel_rgba, /* FetchTexel3D */
+ fetch_texel_1d_rgba, /* FetchTexel1D */
+ fetch_texel_2d_rgba, /* FetchTexel2D */
+ fetch_texel_3d_rgba, /* FetchTexel3D */
+ fetch_texel_1d_f_rgba, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb = {
@@ -101,9 +114,12 @@ const struct gl_texture_format _mesa_texformat_rgb = {
0, /* IndexBits */
0, /* DepthBits */
3 * CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_rgb, /* FetchTexel1D */
- fetch_2d_texel_rgb, /* FetchTexel2D */
- fetch_3d_texel_rgb, /* FetchTexel3D */
+ fetch_texel_1d_rgb, /* FetchTexel1D */
+ fetch_texel_2d_rgb, /* FetchTexel2D */
+ fetch_texel_3d_rgb, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_alpha = {
@@ -118,9 +134,12 @@ const struct gl_texture_format _mesa_texformat_alpha = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_alpha, /* FetchTexel1D */
- fetch_2d_texel_alpha, /* FetchTexel2D */
- fetch_3d_texel_alpha, /* FetchTexel3D */
+ fetch_texel_1d_alpha, /* FetchTexel1D */
+ fetch_texel_2d_alpha, /* FetchTexel2D */
+ fetch_texel_3d_alpha, /* FetchTexel3D */
+ fetch_texel_1d_f_alpha, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_luminance = {
@@ -135,9 +154,12 @@ const struct gl_texture_format _mesa_texformat_luminance = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_luminance, /* FetchTexel1D */
- fetch_2d_texel_luminance, /* FetchTexel2D */
- fetch_3d_texel_luminance, /* FetchTexel3D */
+ fetch_texel_1d_luminance, /* FetchTexel1D */
+ fetch_texel_2d_luminance, /* FetchTexel2D */
+ fetch_texel_3d_luminance, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
@@ -152,9 +174,12 @@ const struct gl_texture_format _mesa_texformat_luminance_alpha = {
0, /* IndexBits */
0, /* DepthBits */
2 * CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_luminance_alpha, /* FetchTexel1D */
- fetch_2d_texel_luminance_alpha, /* FetchTexel2D */
- fetch_3d_texel_luminance_alpha, /* FetchTexel3D */
+ fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_intensity = {
@@ -169,9 +194,12 @@ const struct gl_texture_format _mesa_texformat_intensity = {
0, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_intensity, /* FetchTexel1D */
- fetch_2d_texel_intensity, /* FetchTexel2D */
- fetch_3d_texel_intensity, /* FetchTexel3D */
+ fetch_texel_1d_intensity, /* FetchTexel1D */
+ fetch_texel_2d_intensity, /* FetchTexel2D */
+ fetch_texel_3d_intensity, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_color_index = {
@@ -186,9 +214,12 @@ const struct gl_texture_format _mesa_texformat_color_index = {
CHAN_BITS, /* IndexBits */
0, /* DepthBits */
CHAN_BITS / 8, /* TexelBytes */
- fetch_1d_texel_color_index, /* FetchTexel1D */
- fetch_2d_texel_color_index, /* FetchTexel2D */
- fetch_3d_texel_color_index, /* FetchTexel3D */
+ fetch_texel_1d_color_index, /* FetchTexel1D */
+ fetch_texel_2d_color_index, /* FetchTexel2D */
+ fetch_texel_3d_color_index, /* FetchTexel3D */
+ fetch_texel_1d_f_color_index, /* FetchTexel1Df */
+ fetch_texel_2d_f_color_index, /* FetchTexel2Df */
+ fetch_texel_3d_f_color_index, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_depth_component = {
@@ -203,9 +234,12 @@ const struct gl_texture_format _mesa_texformat_depth_component = {
0, /* IndexBits */
sizeof(GLfloat) * 8, /* DepthBits */
sizeof(GLfloat), /* TexelBytes */
- fetch_1d_texel_depth_component, /* FetchTexel1D */
- fetch_2d_texel_depth_component, /* FetchTexel2D */
- fetch_3d_texel_depth_component, /* FetchTexel3D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_texel_1d_f_depth_component, /* FetchTexel1Df */
+ fetch_texel_2d_f_depth_component, /* FetchTexel2Df */
+ fetch_texel_3d_f_depth_component, /* FetchTexel3Df */
};
/*@}*/
@@ -227,9 +261,12 @@ const struct gl_texture_format _mesa_texformat_rgba8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
- fetch_1d_texel_rgba8888, /* FetchTexel1D */
- fetch_2d_texel_rgba8888, /* FetchTexel2D */
- fetch_3d_texel_rgba8888, /* FetchTexel3D */
+ fetch_texel_1d_rgba8888, /* FetchTexel1D */
+ fetch_texel_2d_rgba8888, /* FetchTexel2D */
+ fetch_texel_3d_rgba8888, /* FetchTexel3D */
+ fetch_texel_1d_f_rgba8888, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba8888, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_argb8888 = {
@@ -244,9 +281,12 @@ const struct gl_texture_format _mesa_texformat_argb8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
- fetch_1d_texel_argb8888, /* FetchTexel1D */
- fetch_2d_texel_argb8888, /* FetchTexel2D */
- fetch_3d_texel_argb8888, /* FetchTexel3D */
+ fetch_texel_1d_argb8888, /* FetchTexel1D */
+ fetch_texel_2d_argb8888, /* FetchTexel2D */
+ fetch_texel_3d_argb8888, /* FetchTexel3D */
+ fetch_texel_1d_f_argb8888, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb8888, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb8888, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb888 = {
@@ -261,9 +301,12 @@ const struct gl_texture_format _mesa_texformat_rgb888 = {
0, /* IndexBits */
0, /* DepthBits */
3, /* TexelBytes */
- fetch_1d_texel_rgb888, /* FetchTexel1D */
- fetch_2d_texel_rgb888, /* FetchTexel2D */
- fetch_3d_texel_rgb888, /* FetchTexel3D */
+ fetch_texel_1d_rgb888, /* FetchTexel1D */
+ fetch_texel_2d_rgb888, /* FetchTexel2D */
+ fetch_texel_3d_rgb888, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb888, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb888, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb888, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb565 = {
@@ -278,9 +321,12 @@ const struct gl_texture_format _mesa_texformat_rgb565 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_rgb565, /* FetchTexel1D */
- fetch_2d_texel_rgb565, /* FetchTexel2D */
- fetch_3d_texel_rgb565, /* FetchTexel3D */
+ fetch_texel_1d_rgb565, /* FetchTexel1D */
+ fetch_texel_2d_rgb565, /* FetchTexel2D */
+ fetch_texel_3d_rgb565, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb565, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb565, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb565, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_argb4444 = {
@@ -295,9 +341,12 @@ const struct gl_texture_format _mesa_texformat_argb4444 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_argb4444, /* FetchTexel1D */
- fetch_2d_texel_argb4444, /* FetchTexel2D */
- fetch_3d_texel_argb4444, /* FetchTexel3D */
+ fetch_texel_1d_argb4444, /* FetchTexel1D */
+ fetch_texel_2d_argb4444, /* FetchTexel2D */
+ fetch_texel_3d_argb4444, /* FetchTexel3D */
+ fetch_texel_1d_f_argb4444, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb4444, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb4444, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_argb1555 = {
@@ -312,9 +361,12 @@ const struct gl_texture_format _mesa_texformat_argb1555 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_argb1555, /* FetchTexel1D */
- fetch_2d_texel_argb1555, /* FetchTexel2D */
- fetch_3d_texel_argb1555, /* FetchTexel3D */
+ fetch_texel_1d_argb1555, /* FetchTexel1D */
+ fetch_texel_2d_argb1555, /* FetchTexel2D */
+ fetch_texel_3d_argb1555, /* FetchTexel3D */
+ fetch_texel_1d_f_argb1555, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb1555, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb1555, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_al88 = {
@@ -329,9 +381,12 @@ const struct gl_texture_format _mesa_texformat_al88 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_al88, /* FetchTexel1D */
- fetch_2d_texel_al88, /* FetchTexel2D */
- fetch_3d_texel_al88, /* FetchTexel3D */
+ fetch_texel_1d_al88, /* FetchTexel1D */
+ fetch_texel_2d_al88, /* FetchTexel2D */
+ fetch_texel_3d_al88, /* FetchTexel3D */
+ fetch_texel_1d_f_al88, /* FetchTexel1Df */
+ fetch_texel_2d_f_al88, /* FetchTexel2Df */
+ fetch_texel_3d_f_al88, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb332 = {
@@ -346,9 +401,12 @@ const struct gl_texture_format _mesa_texformat_rgb332 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_rgb332, /* FetchTexel1D */
- fetch_2d_texel_rgb332, /* FetchTexel2D */
- fetch_3d_texel_rgb332, /* FetchTexel3D */
+ fetch_texel_1d_rgb332, /* FetchTexel1D */
+ fetch_texel_2d_rgb332, /* FetchTexel2D */
+ fetch_texel_3d_rgb332, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb332, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb332, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb332, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_a8 = {
@@ -363,9 +421,12 @@ const struct gl_texture_format _mesa_texformat_a8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_a8, /* FetchTexel1D */
- fetch_2d_texel_a8, /* FetchTexel2D */
- fetch_3d_texel_a8, /* FetchTexel3D */
+ fetch_texel_1d_a8, /* FetchTexel1D */
+ fetch_texel_2d_a8, /* FetchTexel2D */
+ fetch_texel_3d_a8, /* FetchTexel3D */
+ fetch_texel_1d_f_a8, /* FetchTexel1Df */
+ fetch_texel_2d_f_a8, /* FetchTexel2Df */
+ fetch_texel_3d_f_a8, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_l8 = {
@@ -380,9 +441,12 @@ const struct gl_texture_format _mesa_texformat_l8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_l8, /* FetchTexel1D */
- fetch_2d_texel_l8, /* FetchTexel2D */
- fetch_3d_texel_l8, /* FetchTexel3D */
+ fetch_texel_1d_l8, /* FetchTexel1D */
+ fetch_texel_2d_l8, /* FetchTexel2D */
+ fetch_texel_3d_l8, /* FetchTexel3D */
+ fetch_texel_1d_f_l8, /* FetchTexel1Df */
+ fetch_texel_2d_f_l8, /* FetchTexel2Df */
+ fetch_texel_3d_f_l8, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_i8 = {
@@ -397,9 +461,12 @@ const struct gl_texture_format _mesa_texformat_i8 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_i8, /* FetchTexel1D */
- fetch_2d_texel_i8, /* FetchTexel2D */
- fetch_3d_texel_i8, /* FetchTexel3D */
+ fetch_texel_1d_i8, /* FetchTexel1D */
+ fetch_texel_2d_i8, /* FetchTexel2D */
+ fetch_texel_3d_i8, /* FetchTexel3D */
+ fetch_texel_1d_f_i8, /* FetchTexel1Df */
+ fetch_texel_2d_f_i8, /* FetchTexel2Df */
+ fetch_texel_3d_f_i8, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_ci8 = {
@@ -414,9 +481,12 @@ const struct gl_texture_format _mesa_texformat_ci8 = {
8, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_ci8, /* FetchTexel1D */
- fetch_2d_texel_ci8, /* FetchTexel2D */
- fetch_3d_texel_ci8, /* FetchTexel3D */
+ fetch_texel_1d_ci8, /* FetchTexel1D */
+ fetch_texel_2d_ci8, /* FetchTexel2D */
+ fetch_texel_3d_ci8, /* FetchTexel3D */
+ fetch_texel_1d_f_ci8, /* FetchTexel1Df */
+ fetch_texel_2d_f_ci8, /* FetchTexel2Df */
+ fetch_texel_3d_f_ci8, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_ycbcr = {
@@ -431,9 +501,12 @@ const struct gl_texture_format _mesa_texformat_ycbcr = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_ycbcr, /* FetchTexel1D */
- fetch_2d_texel_ycbcr, /* FetchTexel2D */
- fetch_3d_texel_ycbcr, /* FetchTexel3D */
+ fetch_texel_1d_ycbcr, /* FetchTexel1D */
+ fetch_texel_2d_ycbcr, /* FetchTexel2D */
+ fetch_texel_3d_ycbcr, /* FetchTexel3D */
+ fetch_texel_1d_f_ycbcr, /* FetchTexel1Df */
+ fetch_texel_2d_f_ycbcr, /* FetchTexel2Df */
+ fetch_texel_3d_f_ycbcr, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
@@ -448,9 +521,12 @@ const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_ycbcr_rev, /* FetchTexel1D */
- fetch_2d_texel_ycbcr_rev, /* FetchTexel2D */
- fetch_3d_texel_ycbcr_rev, /* FetchTexel3D */
+ fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
+ fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
+ fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_ycbcr_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_ycbcr_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
@@ -466,8 +542,11 @@ const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgb_fxt1, /* FetchTexel2D */
+ fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
@@ -483,8 +562,11 @@ const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgba_fxt1, /* FetchTexel2D */
+ fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
@@ -500,8 +582,11 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgb_dxt1, /* FetchTexel2D */
+ fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
@@ -517,8 +602,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgba_dxt1, /* FetchTexel2D */
+ fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
@@ -534,8 +622,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgba_dxt3, /* FetchTexel2D */
+ fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
@@ -551,8 +642,11 @@ const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
0, /* DepthBits */
0, /* TexelBytes */
NULL, /*impossible*/ /* FetchTexel1D */
- fetch_2d_texel_rgba_dxt5, /* FetchTexel2D */
+ fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
};
@@ -571,9 +665,10 @@ const struct gl_texture_format _mesa_texformat_abgr8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
- fetch_1d_texel_abgr8888, /* FetchTexel1D */
- fetch_2d_texel_abgr8888, /* FetchTexel2D */
- fetch_3d_texel_abgr8888, /* FetchTexel3D */
+ fetch_texel_1d_abgr8888, /* FetchTexel1D */
+ fetch_texel_2d_abgr8888, /* FetchTexel2D */
+ fetch_texel_3d_abgr8888, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgra8888 = {
@@ -589,9 +684,10 @@ const struct gl_texture_format _mesa_texformat_bgra8888 = {
0, /* IndexBits */
0, /* DepthBits */
4, /* TexelBytes */
- fetch_1d_texel_bgra8888, /* FetchTexel1D */
- fetch_2d_texel_bgra8888, /* FetchTexel2D */
- fetch_3d_texel_bgra8888, /* FetchTexel3D */
+ fetch_texel_1d_bgra8888, /* FetchTexel1D */
+ fetch_texel_2d_bgra8888, /* FetchTexel2D */
+ fetch_texel_3d_bgra8888, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgr888 = {
@@ -607,9 +703,10 @@ const struct gl_texture_format _mesa_texformat_bgr888 = {
0, /* IndexBits */
0, /* DepthBits */
3, /* TexelBytes */
- fetch_1d_texel_bgr888, /* FetchTexel1D */
- fetch_2d_texel_bgr888, /* FetchTexel2D */
- fetch_3d_texel_bgr888, /* FetchTexel3D */
+ fetch_texel_1d_bgr888, /* FetchTexel1D */
+ fetch_texel_2d_bgr888, /* FetchTexel2D */
+ fetch_texel_3d_bgr888, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgr565 = {
@@ -625,9 +722,10 @@ const struct gl_texture_format _mesa_texformat_bgr565 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_bgr565, /* FetchTexel1D */
- fetch_2d_texel_bgr565, /* FetchTexel2D */
- fetch_3d_texel_bgr565, /* FetchTexel3D */
+ fetch_texel_1d_bgr565, /* FetchTexel1D */
+ fetch_texel_2d_bgr565, /* FetchTexel2D */
+ fetch_texel_3d_bgr565, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgra4444 = {
@@ -643,9 +741,10 @@ const struct gl_texture_format _mesa_texformat_bgra4444 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_bgra4444, /* FetchTexel1D */
- fetch_2d_texel_bgra4444, /* FetchTexel2D */
- fetch_3d_texel_bgra4444, /* FetchTexel3D */
+ fetch_texel_1d_bgra4444, /* FetchTexel1D */
+ fetch_texel_2d_bgra4444, /* FetchTexel2D */
+ fetch_texel_3d_bgra4444, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgra5551 = {
@@ -661,9 +760,10 @@ const struct gl_texture_format _mesa_texformat_bgra5551 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_bgra1555, /* FetchTexel1D */
- fetch_2d_texel_bgra1555, /* FetchTexel2D */
- fetch_3d_texel_bgra1555, /* FetchTexel3D */
+ fetch_texel_1d_bgra1555, /* FetchTexel1D */
+ fetch_texel_2d_bgra1555, /* FetchTexel2D */
+ fetch_texel_3d_bgra1555, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_la88 = {
@@ -679,9 +779,10 @@ const struct gl_texture_format _mesa_texformat_la88 = {
0, /* IndexBits */
0, /* DepthBits */
2, /* TexelBytes */
- fetch_1d_texel_la88, /* FetchTexel1D */
- fetch_2d_texel_la88, /* FetchTexel2D */
- fetch_3d_texel_la88, /* FetchTexel3D */
+ fetch_texel_1d_la88, /* FetchTexel1D */
+ fetch_texel_2d_la88, /* FetchTexel2D */
+ fetch_texel_3d_la88, /* FetchTexel3D */
+ /* XXX float fetchers */
};
const struct gl_texture_format _mesa_texformat_bgr233 = {
@@ -697,9 +798,10 @@ const struct gl_texture_format _mesa_texformat_bgr233 = {
0, /* IndexBits */
0, /* DepthBits */
1, /* TexelBytes */
- fetch_1d_texel_bgr233, /* FetchTexel1D */
- fetch_2d_texel_bgr233, /* FetchTexel2D */
- fetch_3d_texel_bgr233, /* FetchTexel3D */
+ fetch_texel_1d_bgr233, /* FetchTexel1D */
+ fetch_texel_2d_bgr233, /* FetchTexel2D */
+ fetch_texel_3d_bgr233, /* FetchTexel3D */
+ /* XXX float fetchers */
};
#endif
@@ -725,6 +827,9 @@ const struct gl_texture_format _mesa_null_texformat = {
fetch_null_texel, /* FetchTexel1D */
fetch_null_texel, /* FetchTexel2D */
fetch_null_texel, /* FetchTexel3D */
+ fetch_null_texelf, /* FetchTexel1Df */
+ fetch_null_texelf, /* FetchTexel2Df */
+ fetch_null_texelf, /* FetchTexel3Df */
};
/*@}*/
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 14eb0463abf..061f11daca3 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -17,9 +17,9 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
@@ -51,7 +51,7 @@
#define FLOAT_SRC( t, i, j, k ) \
((GLfloat *)(t)->Data + (i))
-#define FETCH(x) fetch_1d_texel_##x
+#define FETCH(x) fetch_texel_1d_##x
#elif DIM == 2
@@ -64,7 +64,7 @@
#define FLOAT_SRC( t, i, j, k ) \
((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)))
-#define FETCH(x) fetch_2d_texel_##x
+#define FETCH(x) fetch_texel_2d_##x
#elif DIM == 3
@@ -81,228 +81,477 @@
((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
(t)->RowStride + (i)))
-#define FETCH(x) fetch_3d_texel_##x
+#define FETCH(x) fetch_texel_3d_##x
#else
#error illegal number of texture dimensions
#endif
+/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */
static void FETCH(rgba)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
- GLchan *rgba = (GLchan *) texel;
- COPY_CHAN4( rgba, src );
+ COPY_CHAN4( texel, src );
}
+/* Fetch color texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */
+static void FETCH(f_rgba)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
+ texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
+ texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
+ texel[ACOMP] = CHAN_TO_FLOAT(src[3]);
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */
static void FETCH(rgb)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */
+static void FETCH(f_rgb)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = src[0];
- rgba[GCOMP] = src[1];
- rgba[BCOMP] = src[2];
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
+ texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
+ texel[ACOMP] = CHAN_MAXF;
}
+/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */
static void FETCH(alpha)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ texel[ACOMP] = src[0];
+}
+
+/* Fetch color texel from 1D, 2D or 3D ALPHA texture, returning 4 GLfloats */
+static void FETCH(f_alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = 0;
- rgba[GCOMP] = 0;
- rgba[BCOMP] = 0;
- rgba[ACOMP] = src[0];
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
}
+/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */
static void FETCH(luminance)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */
+static void FETCH(f_luminance)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = src[0];
- rgba[GCOMP] = src[0];
- rgba[BCOMP] = src[0];
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[ACOMP] = CHAN_MAXF;
}
+/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */
static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[0];
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[1];
+}
+
+/* Fetch color texel from 1D, 2D or 3D L_A texture, returning 4 GLfloats */
+static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = src[0];
- rgba[GCOMP] = src[0];
- rgba[BCOMP] = src[0];
- rgba[ACOMP] = src[1];
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[ACOMP] = CHAN_TO_FLOAT(src[1]);
}
+
+/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */
static void FETCH(intensity)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = src[0];
- rgba[GCOMP] = src[0];
- rgba[BCOMP] = src[0];
- rgba[ACOMP] = src[0];
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[0];
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[0];
}
+/* Fetch color texel from 1D, 2D or 3D INT. texture, returning 4 GLfloats */
+static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
+}
+
+
+/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLchan */
static void FETCH(color_index)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
GLchan *index = (GLchan *) texel;
- *index = *src;
+ index[0] = src[0];
+}
+
+/* Fetch CI texel from 1D, 2D or 3D CI texture, returning 1 GLfloat */
+static void FETCH(f_color_index)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
+ texel[0] = (GLfloat) src[0];
}
+
+#if 000
+/* Fetch depth texel from 1D, 2D or 3D DEPTH texture, returning 1 GLfloat */
static void FETCH(depth_component)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
+#if 0
const GLfloat *src = FLOAT_SRC( texImage, i, j, k );
GLfloat *depth = (GLfloat *) texel;
- *depth = *src;
+ depth[0] = src[0];
+#else
+ _mesa_problem(NULL, "fetching depth component as non-float!");
+#endif
}
+#endif
+
+/* Fetch depth texel from 1D, 2D or 3D DEPTH texture, returning 1 GLfloat */
+static void FETCH(f_depth_component)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_SRC( texImage, i, j, k );
+ texel[0] = src[0];
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */
static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[3] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[3] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
}
+/* Fetch color texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
+static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[3] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
static void FETCH(argb8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[3] );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[3] );
}
+/* Fetch color texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */
+static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[3] );
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
static void FETCH(rgb888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */
+static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = CHAN_MAXF;
}
+
+/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
static void FETCH(rgb565)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */
+static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = CHAN_MAX;
+ /* xxx fixup */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf8) * 255 / 0xf8 );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 3) & 0xfc) * 255 / 0xfc );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xf8) * 255 / 0xf8 );
+ texel[ACOMP] = CHAN_MAXF;
}
+
+/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
static void FETCH(argb4444)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
+}
+
+/* Fetch color texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */
+static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
+ /* xxx fixup */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 8) & 0xf) * 255 / 0xf );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 4) & 0xf) * 255 / 0xf );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xf) * 255 / 0xf );
+ texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 12) & 0xf) * 255 / 0xf );
}
+
+/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
static void FETCH(argb1555)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
}
+/* Fetch color texel from 1D, 2D or 3D argb1555 texture, return 4 GLfloats */
+static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_SRC( texImage, i, j, k );
+ const GLushort s = *src;
+ /* xxx better */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s >> 10) & 0x1f) * 255 / 0x1f );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s >> 5) & 0x1f) * 255 / 0x1f );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s ) & 0x1f) * 255 / 0x1f );
+ texel[ACOMP] = UBYTE_TO_FLOAT( ((s >> 15) & 0x01) * 255 );
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
static void FETCH(al88)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[1] );
+}
+
+/* Fetch color texel from 1D, 2D or 3D al88 texture, return 4 GLfloats */
+static void FETCH(f_al88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[1] );
}
+
+/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
static void FETCH(rgb332)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
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 );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
+ texel[ACOMP] = CHAN_MAX;
}
+/* Fetch color texel from 1D, 2D or 3D rgb332 texture, return 4 GLfloats */
+static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ const GLubyte s = *src;
+ /* xxx improve */
+ texel[RCOMP] = UBYTE_TO_FLOAT( ((s ) & 0xe0) * 255 / 0xe0 );
+ texel[GCOMP] = UBYTE_TO_FLOAT( ((s << 3) & 0xe0) * 255 / 0xe0 );
+ texel[BCOMP] = UBYTE_TO_FLOAT( ((s << 5) & 0xc0) * 255 / 0xc0 );
+ texel[ACOMP] = CHAN_MAXF;
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
static void FETCH(a8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = 0;
- rgba[GCOMP] = 0;
- rgba[BCOMP] = 0;
- rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] = 0;
+ texel[GCOMP] = 0;
+ texel[BCOMP] = 0;
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
}
+/* Fetch color texel from 1D, 2D or 3D a8 texture, return 4 GLfloats */
+static void FETCH(f_a8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
static void FETCH(l8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = CHAN_MAX;
}
+/* Fetch color texel from 1D, 2D or 3D l8 texture, return 4 GLfloats */
+static void FETCH(f_l8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = CHAN_MAXF;
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
static void FETCH(i8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+/* Fetch color texel from 1D, 2D or 3D i8 texture, return 4 GLfloats */
+static void FETCH(f_i8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
}
+
+/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLchan */
static void FETCH(ci8)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
GLchan *index = (GLchan *) texel;
*index = UBYTE_TO_CHAN( *src );
}
+
+/* Fetch color texel from 1D, 2D or 3D ci8 texture, return 1 GLfloat */
+static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
+ texel[0] = UBYTE_TO_FLOAT( *src );
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */
+/* We convert YCbCr to RGB here */
/* 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 )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
@@ -310,7 +559,6 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
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 */
@@ -324,15 +572,53 @@ static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
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;
+ texel[RCOMP] = CLAMP(r, 0, CHAN_MAX);
+ texel[GCOMP] = CLAMP(g, 0, CHAN_MAX);
+ texel[BCOMP] = CLAMP(b, 0, CHAN_MAX);
+ texel[ACOMP] = CHAN_MAX;
}
+/* Fetch color texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats */
+/* We convert YCbCr to RGB here */
+static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *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 */
+ GLfloat r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ /* XXX remove / 255 here by tweaking arithmetic above */
+ r /= 255.0;
+ g /= 255.0;
+ b /= 255.0;
+ /* XXX should we really clamp??? */
+ texel[RCOMP] = CLAMP(r, 0.0, 1.0);
+ texel[GCOMP] = CLAMP(g, 0.0, 1.0);
+ texel[BCOMP] = CLAMP(b, 0.0, 1.0);
+ texel[ACOMP] = CHAN_MAXF;
+}
+
+
+/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */
+/* We convert YCbCr to RGB here */
/* 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 )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
const GLushort *src1 = src0 + 1; /* odd */
@@ -340,7 +626,6 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
const GLubyte y1 = *src1 & 0xff; /* luminance */
const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
- GLchan *rgba = (GLchan *) texel;
GLint r, g, b;
if (i & 1) {
/* odd pixel: use y1,cr,cb */
@@ -354,72 +639,155 @@ static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
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;
+ texel[RCOMP] = CLAMP(r, 0, CHAN_MAX);
+ texel[GCOMP] = CLAMP(g, 0, CHAN_MAX);
+ texel[BCOMP] = CLAMP(b, 0, CHAN_MAX);
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch color texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */
+/* We convert YCbCr to RGB here */
+/* XXX this may break if GLchan != GLubyte */
+static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *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 V */
+ const GLubyte y1 = *src1 & 0xff; /* luminance */
+ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
+ GLfloat r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ /* XXX remove / 255 here by tweaking arithmetic above */
+ r /= 255.0;
+ g /= 255.0;
+ b /= 255.0;
+ /* XXX should we really clamp??? */
+ texel[RCOMP] = CLAMP(r, 0.0, 1.0);
+ texel[GCOMP] = CLAMP(g, 0.0, 1.0);
+ texel[BCOMP] = CLAMP(b, 0.0, 1.0);
+ texel[ACOMP] = CHAN_MAXF;
}
-#if DIM == 2
+#if DIM == 2 /* Only 2D compressed textures possible */
+
static void FETCH(rgb_fxt1)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
+static void FETCH(f_rgb_fxt1)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
-#endif
-#if DIM == 2
static void FETCH(rgba_fxt1)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
-#endif
+static void FETCH(f_rgba_fxt1)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
+#endif /* if DIM == 2 */
+
+
+#if DIM == 2 /* only 2D is valid */
-#if DIM == 2
static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
-#endif
-#if DIM == 2
+static void FETCH(f_rgb_dxt1)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
+
static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
-#endif
-#if DIM == 2
+static void FETCH(f_rgba_dxt1)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
+
static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
-#endif
-#if DIM == 2
+static void FETCH(f_rgba_dxt3)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
+
static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
/* Extract the (i,j) pixel from texImage->Data and return it
* in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
*/
}
+
+static void FETCH(f_rgba_dxt5)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* Extract the (i,j) pixel from texImage->Data and return it
+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
+ */
+}
+
#endif
@@ -428,95 +796,87 @@ static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage,
#if 0
static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[3] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[3] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
}
static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[3] );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[3] );
}
static void FETCH(bgr888)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = CHAN_MAX;
}
static void FETCH(bgr565)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
+ texel[ACOMP] = CHAN_MAX;
}
static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
}
static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLushort *src = USHORT_SRC( texImage, i, j, k );
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 );
- rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
}
static void FETCH(la88)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
- GLchan *rgba = (GLchan *) texel;
- rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
- rgba[ACOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = UBYTE_TO_CHAN( src[1] );
}
static void FETCH(bgr233)( const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLvoid *texel )
+ GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
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 );
- rgba[ACOMP] = CHAN_MAX;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
+ texel[ACOMP] = CHAN_MAX;
}
#endif
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 96b5038111a..3833b2681e6 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.0
+ * Version: 6.1
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -904,7 +904,8 @@ clear_teximage_fields(struct gl_texture_image *img)
img->DepthLog2 = 0;
img->Data = NULL;
img->TexFormat = &_mesa_null_texformat;
- img->FetchTexel = NULL;
+ img->FetchTexelc = NULL;
+ img->FetchTexelf = NULL;
img->IsCompressed = 0;
img->CompressedSize = 0;
}
@@ -1875,8 +1876,9 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
GLuint indexRow[MAX_WIDTH];
GLint col;
for (col = 0; col < width; col++) {
- (*texImage->FetchTexel)(texImage, col, row, img,
- (GLvoid *) &indexRow[col]);
+ GLchan indx;
+ (*texImage->FetchTexelc)(texImage, col, row, img, &indx);
+ indexRow[col] = indx;
}
_mesa_pack_index_span(ctx, width, type, dest,
indexRow, &ctx->Pack,
@@ -1886,8 +1888,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
GLfloat depthRow[MAX_WIDTH];
GLint col;
for (col = 0; col < width; col++) {
- (*texImage->FetchTexel)(texImage, col, row, img,
- (GLvoid *) &depthRow[col]);
+ (*texImage->FetchTexelf)(texImage, col, row, img,
+ (GLvoid *) &depthRow[col]);
}
_mesa_pack_depth_span(ctx, width, dest, type,
depthRow, &ctx->Pack);
@@ -1915,8 +1917,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
GLchan rgba[MAX_WIDTH][4];
GLint col;
for (col = 0; col < width; col++) {
- (*texImage->FetchTexel)(texImage, col, row, img,
- (GLvoid *) rgba[col]);
+ (*texImage->FetchTexelc)(texImage, col, row, img, rgba[col]);
}
_mesa_pack_rgba_span(ctx, width, (const GLchan (*)[4])rgba,
format, type, dest, &ctx->Pack,
@@ -1984,11 +1985,14 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
&ctx->Unpack, texObj, texImage);
ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexel) {
- /* If driver didn't explicitly set this, use the default */
- texImage->FetchTexel = texImage->TexFormat->FetchTexel1D;
- }
- ASSERT(texImage->FetchTexel);
+
+ /* If driver didn't explicitly set this, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
/* state update */
texObj->Complete = GL_FALSE;
@@ -2081,11 +2085,14 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
&ctx->Unpack, texObj, texImage);
ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexel) {
- /* If driver didn't explicitly set this, use the default */
- texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
- }
- ASSERT(texImage->FetchTexel);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
/* state update */
texObj->Complete = GL_FALSE;
@@ -2172,11 +2179,14 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
pixels, &ctx->Unpack, texObj, texImage);
ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexel) {
- /* If driver didn't explicitly set this, use the default */
- texImage->FetchTexel = texImage->TexFormat->FetchTexel3D;
- }
- ASSERT(texImage->FetchTexel);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
/* state update */
texObj->Complete = GL_FALSE;
@@ -2405,11 +2415,14 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
x, y, width, border);
ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexel) {
- /* If driver didn't explicitly set this, use the default */
- texImage->FetchTexel = texImage->TexFormat->FetchTexel1D;
- }
- ASSERT(texImage->FetchTexel);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
/* state update */
texObj->Complete = GL_FALSE;
@@ -2465,11 +2478,14 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
x, y, width, height, border);
ASSERT(texImage->TexFormat);
- if (!texImage->FetchTexel) {
- /* If driver didn't explicitly set this, use the default */
- texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
- }
- ASSERT(texImage->FetchTexel);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
/* state update */
texObj->Complete = GL_FALSE;
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 899201e6c4a..db51aebc9a9 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
@@ -770,7 +770,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
internalFormat, format, type);
assert(texImage->TexFormat);
- texImage->FetchTexel = texImage->TexFormat->FetchTexel1D;
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
texelBytes = texImage->TexFormat->TexelBytes;
@@ -846,7 +847,8 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
internalFormat, format, type);
assert(texImage->TexFormat);
- texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
texelBytes = texImage->TexFormat->TexelBytes;
@@ -917,7 +919,8 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
internalFormat, format, type);
assert(texImage->TexFormat);
- texImage->FetchTexel = texImage->TexFormat->FetchTexel3D;
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
texelBytes = texImage->TexFormat->TexelBytes;
@@ -1155,7 +1158,8 @@ _mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
internalFormat, 0, 0);
assert(texImage->TexFormat);
- texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
/* allocate storage */
texImage->Data = MESA_PBUFFER_ALLOC(imageSize);
@@ -1919,7 +1923,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
for (row = 0; row < srcImage->Height; row++) {
GLuint col;
for (col = 0; col < srcImage->Width; col++) {
- (*srcImage->FetchTexel)(srcImage, col, row, 0, (GLvoid *) dst);
+ srcImage->FetchTexelc(srcImage, col, row, 0, dst);
dst += components;
}
}
@@ -1993,9 +1997,11 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
dstDepth, border, srcImage->IntFormat);
dstImage->DriverData = NULL;
dstImage->TexFormat = srcImage->TexFormat;
- dstImage->FetchTexel = srcImage->FetchTexel;
+ dstImage->FetchTexelc = srcImage->FetchTexelc;
+ dstImage->FetchTexelf = srcImage->FetchTexelf;
ASSERT(dstImage->TexFormat);
- ASSERT(dstImage->FetchTexel);
+ ASSERT(dstImage->FetchTexelc);
+ ASSERT(dstImage->FetchTexelf);
/* Alloc new teximage data buffer.
* Setup src and dest data pointers.
diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c
index 2b358e9f4aa..e3679a270e1 100644
--- a/src/mesa/swrast/s_nvfragprog.c
+++ b/src/mesa/swrast/s_nvfragprog.c
@@ -56,6 +56,7 @@ fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
GLchan rgba[4];
SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ /* XXX use a float-valued TextureSample routine here!!! */
swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
1, (const GLfloat (*)[4]) texcoord,
&lambda, &rgba);
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index 2342179a4e6..2576a181c35 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 5.1
+ * Version: 6.1
*
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2004 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"),
@@ -787,7 +787,7 @@ sample_1d_nearest(GLcontext *ctx,
COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i, 0, 0, (GLvoid *) rgba);
+ img->FetchTexelc(img, i, 0, 0, rgba);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, rgba[0], rgba);
}
@@ -839,7 +839,7 @@ sample_1d_linear(GLcontext *ctx,
COPY_CHAN4(t0, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, 0, 0, (GLvoid *) t0);
+ img->FetchTexelc(img, i0, 0, 0, t0);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t0[0], t0);
}
@@ -848,7 +848,7 @@ sample_1d_linear(GLcontext *ctx,
COPY_CHAN4(t1, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, 0, 0, (GLvoid *) t1);
+ img->FetchTexelc(img, i1, 0, 0, t1);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t1[0], t1);
}
@@ -1116,7 +1116,7 @@ sample_2d_nearest(GLcontext *ctx,
COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i, j, 0, (GLvoid *) rgba);
+ img->FetchTexelc(img, i, j, 0, rgba);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, rgba[0], rgba);
}
@@ -1184,7 +1184,7 @@ sample_2d_linear(GLcontext *ctx,
COPY_CHAN4(t00, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j0, 0, (GLvoid *) t00);
+ img->FetchTexelc(img, i0, j0, 0, t00);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t00[0], t00);
}
@@ -1193,7 +1193,7 @@ sample_2d_linear(GLcontext *ctx,
COPY_CHAN4(t10, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j0, 0, (GLvoid *) t10);
+ img->FetchTexelc(img, i1, j0, 0, t10);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t10[0], t10);
}
@@ -1202,7 +1202,7 @@ sample_2d_linear(GLcontext *ctx,
COPY_CHAN4(t01, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j1, 0, (GLvoid *) t01);
+ img->FetchTexelc(img, i0, j1, 0, t01);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t01[0], t01);
}
@@ -1211,7 +1211,7 @@ sample_2d_linear(GLcontext *ctx,
COPY_CHAN4(t11, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j1, 0, (GLvoid *) t11);
+ img->FetchTexelc(img, i1, j1, 0, t11);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t11[0], t11);
}
@@ -1292,10 +1292,10 @@ sample_2d_linear_repeat(GLcontext *ctx,
GLchan t01[4];
GLchan t11[4];
- (*img->FetchTexel)(img, i0, j0, 0, (GLvoid *) t00);
- (*img->FetchTexel)(img, i1, j0, 0, (GLvoid *) t10);
- (*img->FetchTexel)(img, i0, j1, 0, (GLvoid *) t01);
- (*img->FetchTexel)(img, i1, j1, 0, (GLvoid *) t11);
+ img->FetchTexelc(img, i0, j0, 0, t00);
+ img->FetchTexelc(img, i1, j0, 0, t10);
+ img->FetchTexelc(img, i0, j1, 0, t01);
+ img->FetchTexelc(img, i1, j1, 0, t11);
#if CHAN_TYPE == GL_FLOAT
rgba[0] = w00 * t00[0] + w10 * t10[0] + w01 * t01[0] + w11 * t11[0];
@@ -1710,7 +1710,7 @@ sample_3d_nearest(GLcontext *ctx,
COPY_CHAN4(rgba, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i, j, k, (GLvoid *) rgba);
+ img->FetchTexelc(img, i, j, k, rgba);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, rgba[0], rgba);
}
@@ -1793,7 +1793,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t000, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j0, k0, (GLvoid *) t000);
+ img->FetchTexelc(img, i0, j0, k0, t000);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t000[0], t000);
}
@@ -1802,7 +1802,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t100, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j0, k0, (GLvoid *) t100);
+ img->FetchTexelc(img, i1, j0, k0, t100);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t100[0], t100);
}
@@ -1811,7 +1811,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t010, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j1, k0, (GLvoid *) t010);
+ img->FetchTexelc(img, i0, j1, k0, t010);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t010[0], t010);
}
@@ -1820,7 +1820,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t110, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j1, k0, (GLvoid *) t110);
+ img->FetchTexelc(img, i1, j1, k0, t110);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t110[0], t110);
}
@@ -1830,7 +1830,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t001, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j0, k1, (GLvoid *) t001);
+ img->FetchTexelc(img, i0, j0, k1, t001);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t001[0], t001);
}
@@ -1839,7 +1839,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t101, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j0, k1, (GLvoid *) t101);
+ img->FetchTexelc(img, i1, j0, k1, t101);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t101[0], t101);
}
@@ -1848,7 +1848,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t011, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i0, j1, k1, (GLvoid *) t011);
+ img->FetchTexelc(img, i0, j1, k1, t011);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t011[0], t011);
}
@@ -1857,7 +1857,7 @@ sample_3d_linear(GLcontext *ctx,
COPY_CHAN4(t111, tObj->_BorderChan);
}
else {
- (*img->FetchTexel)(img, i1, j1, k1, (GLvoid *) t111);
+ img->FetchTexelc(img, i1, j1, k1, t111);
if (img->Format == GL_COLOR_INDEX) {
palette_sample(ctx, tObj, t111[0], t111);
}
@@ -2449,7 +2449,7 @@ sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
col = CLAMP(col, 0, width_minus_1);
row = CLAMP(row, 0, height_minus_1);
- (*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]);
+ img->FetchTexelc(img, col, row, 0, rgba[i]);
}
}
@@ -2516,10 +2516,10 @@ sample_linear_rect(GLcontext *ctx, GLuint texUnit,
row1 = CLAMP(row1, 0, height_minus_1);
/* get four texel samples */
- (*img->FetchTexel)(img, col0, row0, 0, (GLvoid *) t00);
- (*img->FetchTexel)(img, col1, row0, 0, (GLvoid *) t10);
- (*img->FetchTexel)(img, col0, row1, 0, (GLvoid *) t01);
- (*img->FetchTexel)(img, col1, row1, 0, (GLvoid *) t11);
+ img->FetchTexelc(img, col0, row0, 0, t00);
+ img->FetchTexelc(img, col1, row0, 0, t10);
+ img->FetchTexelc(img, col0, row1, 0, t01);
+ img->FetchTexelc(img, col1, row1, 0, t11);
/* compute sample weights */
a = FRAC(fcol);
@@ -2635,7 +2635,7 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
/* XXX fix for texture rectangle! */
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoords[i][0], width, col);
COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoords[i][1], height, row);
- depthSample = *((const GLfloat *) texImage->Data + row * width + col);
+ texImage->FetchTexelf(texImage, col, row, 0, &depthSample);
switch (function) {
case GL_LEQUAL:
@@ -2726,25 +2726,25 @@ sample_depth_texture( GLcontext *ctx, GLuint unit,
depth00 = 1.0;
}
else {
- depth00 = *((const GLfloat *) texImage->Data + j0 * width + i0);
+ texImage->FetchTexelf(texImage, i0, j0, 0, &depth00);
}
if (useBorderTexel & (I1BIT | J0BIT)) {
depth10 = 1.0;
}
else {
- depth10 = *((const GLfloat *) texImage->Data + j0 * width + i1);
+ texImage->FetchTexelf(texImage, i1, j0, 0, &depth10);
}
if (useBorderTexel & (I0BIT | J1BIT)) {
depth01 = 1.0;
}
else {
- depth01 = *((const GLfloat *) texImage->Data + j1 * width + i0);
+ texImage->FetchTexelf(texImage, i0, j1, 0, &depth01);
}
if (useBorderTexel & (I1BIT | J1BIT)) {
depth11 = 1.0;
}
else {
- depth11 = *((const GLfloat *) texImage->Data + j1 * width + i1);
+ texImage->FetchTexelf(texImage, i1, j1, 0, &depth11);
}
if (0) {
@@ -2943,8 +2943,8 @@ sample_depth_texture2(const GLcontext *ctx,
count = 0;
for (jj = jmin; jj <= jmax; jj++) {
for (ii = imin; ii <= imax; ii++) {
- GLfloat depthSample = *((const GLfloat *) texImage->Data
- + jj * width + ii);
+ GLfloat depthSample;
+ texImage->FetchTexelf(texImage, ii, jj, 0, &depthSample);
if ((depthSample <= r[i] && lequal) ||
(depthSample >= r[i] && gequal)) {
count++;