summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2003-01-26 14:37:15 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2003-01-26 14:37:15 +0000
commit45b47d079f6a749c15498a6cef78d891f8acb665 (patch)
tree63f53e25c3ebf3f0320a27ab72f0e13491021c77 /src/mesa
parent7cac85d00a6110aa92236b2e841faeeb34f684c1 (diff)
Make GL_SGI_texture_color_table work per-texture unit.
Clean-up and optimize _swrast_texture_table_lookup().
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/attrib.c17
-rw-r--r--src/mesa/main/colortab.c98
-rw-r--r--src/mesa/main/context.c19
-rw-r--r--src/mesa/main/enable.c11
-rw-r--r--src/mesa/main/get.c10
-rw-r--r--src/mesa/main/mtypes.h33
-rw-r--r--src/mesa/swrast/s_context.c9
-rw-r--r--src/mesa/swrast/s_texture.c362
-rw-r--r--src/mesa/swrast/s_texture.h10
9 files changed, 299 insertions, 270 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index c34b80a60d..7a8f5c7f3b 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.76 2003/01/22 17:58:52 brianp Exp $ */
+/* $Id: attrib.c,v 1.77 2003/01/26 14:37:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -199,8 +199,8 @@ _mesa_PushAttrib(GLbitfield mask)
for (i=0; i<MAX_TEXTURE_UNITS; i++) {
attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
+ attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled;
}
- attr->TextureColorTable = ctx->Texture.ColorTableEnabled;
/* GL_NV_vertex_program */
attr->VertexProgram = ctx->VertexProgram.Enabled;
attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled;
@@ -534,8 +534,6 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,
enable->SampleCoverageInvert,
GL_SAMPLE_COVERAGE_INVERT_ARB);
- TEST_AND_UPDATE(ctx->Texture.ColorTableEnabled, enable->TextureColorTable,
- GL_TEXTURE_COLOR_TABLE_SGI);
/* GL_NV_vertex_program */
TEST_AND_UPDATE(ctx->VertexProgram.Enabled,
enable->VertexProgram,
@@ -596,6 +594,9 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
(*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
}
}
+
+ /* GL_SGI_texture_color_table */
+ ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i];
}
if (ctx->Driver.ActiveTexture) {
@@ -630,13 +631,7 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
}
if (ctx->Extensions.SGI_texture_color_table) {
_mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI,
- texAttrib->ColorTableEnabled);
- _mesa_ColorTableParameterfv(GL_TEXTURE_COLOR_TABLE_SGI,
- GL_COLOR_TABLE_SCALE_SGI,
- texAttrib->ColorTableScale);
- _mesa_ColorTableParameterfv(GL_TEXTURE_COLOR_TABLE_SGI,
- GL_COLOR_TABLE_BIAS_SGI,
- texAttrib->ColorTableBias);
+ texAttrib->Unit[i].ColorTableEnabled);
}
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode);
_mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor);
diff --git a/src/mesa/main/colortab.c b/src/mesa/main/colortab.c
index 04625c6c82..184aa8eff2 100644
--- a/src/mesa/main/colortab.c
+++ b/src/mesa/main/colortab.c
@@ -1,4 +1,4 @@
-/* $Id: colortab.c,v 1.47 2003/01/21 21:47:45 brianp Exp $ */
+/* $Id: colortab.c,v 1.48 2003/01/26 14:37:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -262,23 +262,23 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
return;
}
- table = &ctx->TextureColorTable;
+ table = &(texUnit->ColorTable);
floatTable = GL_TRUE;
- rScale = ctx->Texture.ColorTableScale[0];
- gScale = ctx->Texture.ColorTableScale[1];
- bScale = ctx->Texture.ColorTableScale[2];
- aScale = ctx->Texture.ColorTableScale[3];
- rBias = ctx->Texture.ColorTableBias[0];
- gBias = ctx->Texture.ColorTableBias[1];
- bBias = ctx->Texture.ColorTableBias[2];
- aBias = ctx->Texture.ColorTableBias[3];
+ rScale = ctx->Pixel.TextureColorTableScale[0];
+ gScale = ctx->Pixel.TextureColorTableScale[1];
+ bScale = ctx->Pixel.TextureColorTableScale[2];
+ aScale = ctx->Pixel.TextureColorTableScale[3];
+ rBias = ctx->Pixel.TextureColorTableBias[0];
+ gBias = ctx->Pixel.TextureColorTableBias[1];
+ bBias = ctx->Pixel.TextureColorTableBias[2];
+ aBias = ctx->Pixel.TextureColorTableBias[3];
break;
case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
if (!ctx->Extensions.SGI_texture_color_table) {
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
return;
}
- table = &ctx->ProxyTextureColorTable;
+ table = &(texUnit->ProxyColorTable);
proxy = GL_TRUE;
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
@@ -515,15 +515,15 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
_mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
return;
}
- table = &ctx->TextureColorTable;
- rScale = ctx->Texture.ColorTableScale[0];
- gScale = ctx->Texture.ColorTableScale[1];
- bScale = ctx->Texture.ColorTableScale[2];
- aScale = ctx->Texture.ColorTableScale[3];
- rBias = ctx->Texture.ColorTableBias[0];
- gBias = ctx->Texture.ColorTableBias[1];
- bBias = ctx->Texture.ColorTableBias[2];
- aBias = ctx->Texture.ColorTableBias[3];
+ table = &(texUnit->ColorTable);
+ rScale = ctx->Pixel.TextureColorTableScale[0];
+ gScale = ctx->Pixel.TextureColorTableScale[1];
+ bScale = ctx->Pixel.TextureColorTableScale[2];
+ aScale = ctx->Pixel.TextureColorTableScale[3];
+ rBias = ctx->Pixel.TextureColorTableBias[0];
+ gBias = ctx->Pixel.TextureColorTableBias[1];
+ bBias = ctx->Pixel.TextureColorTableBias[2];
+ aBias = ctx->Pixel.TextureColorTableBias[3];
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
@@ -727,7 +727,7 @@ _mesa_GetColorTable( GLenum target, GLenum format,
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
return;
}
- table = &ctx->TextureColorTable;
+ table = &(texUnit->ColorTable);
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
@@ -917,16 +917,16 @@ _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
return;
}
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- ctx->Texture.ColorTableScale[0] = params[0];
- ctx->Texture.ColorTableScale[1] = params[1];
- ctx->Texture.ColorTableScale[2] = params[2];
- ctx->Texture.ColorTableScale[3] = params[3];
+ ctx->Pixel.TextureColorTableScale[0] = params[0];
+ ctx->Pixel.TextureColorTableScale[1] = params[1];
+ ctx->Pixel.TextureColorTableScale[2] = params[2];
+ ctx->Pixel.TextureColorTableScale[3] = params[3];
}
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- ctx->Texture.ColorTableBias[0] = params[0];
- ctx->Texture.ColorTableBias[1] = params[1];
- ctx->Texture.ColorTableBias[2] = params[2];
- ctx->Texture.ColorTableBias[3] = params[3];
+ ctx->Pixel.TextureColorTableBias[0] = params[0];
+ ctx->Pixel.TextureColorTableBias[1] = params[1];
+ ctx->Pixel.TextureColorTableBias[2] = params[2];
+ ctx->Pixel.TextureColorTableBias[3] = params[3];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
@@ -1073,19 +1073,19 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
return;
}
- table = &ctx->TextureColorTable;
+ table = &(texUnit->ColorTable);
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- params[0] = ctx->Texture.ColorTableScale[0];
- params[1] = ctx->Texture.ColorTableScale[1];
- params[2] = ctx->Texture.ColorTableScale[2];
- params[3] = ctx->Texture.ColorTableScale[3];
+ params[0] = ctx->Pixel.TextureColorTableScale[0];
+ params[1] = ctx->Pixel.TextureColorTableScale[1];
+ params[2] = ctx->Pixel.TextureColorTableScale[2];
+ params[3] = ctx->Pixel.TextureColorTableScale[3];
return;
}
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- params[0] = ctx->Texture.ColorTableBias[0];
- params[1] = ctx->Texture.ColorTableBias[1];
- params[2] = ctx->Texture.ColorTableBias[2];
- params[3] = ctx->Texture.ColorTableBias[3];
+ params[0] = ctx->Pixel.TextureColorTableBias[0];
+ params[1] = ctx->Pixel.TextureColorTableBias[1];
+ params[2] = ctx->Pixel.TextureColorTableBias[2];
+ params[3] = ctx->Pixel.TextureColorTableBias[3];
return;
}
break;
@@ -1094,7 +1094,7 @@ _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params )
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
return;
}
- table = &ctx->ProxyTextureColorTable;
+ table = &(texUnit->ProxyColorTable);
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
@@ -1247,19 +1247,19 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
return;
}
- table = &ctx->TextureColorTable;
+ table = &(texUnit->ColorTable);
if (pname == GL_COLOR_TABLE_SCALE_SGI) {
- params[0] = (GLint) ctx->Texture.ColorTableScale[0];
- params[1] = (GLint) ctx->Texture.ColorTableScale[1];
- params[2] = (GLint) ctx->Texture.ColorTableScale[2];
- params[3] = (GLint) ctx->Texture.ColorTableScale[3];
+ params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0];
+ params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1];
+ params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2];
+ params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3];
return;
}
else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
- params[0] = (GLint) ctx->Texture.ColorTableBias[0];
- params[1] = (GLint) ctx->Texture.ColorTableBias[1];
- params[2] = (GLint) ctx->Texture.ColorTableBias[2];
- params[3] = (GLint) ctx->Texture.ColorTableBias[3];
+ params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0];
+ params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1];
+ params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2];
+ params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3];
return;
}
break;
@@ -1268,7 +1268,7 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
_mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
return;
}
- table = &ctx->ProxyTextureColorTable;
+ table = &(texUnit->ProxyColorTable);
break;
case GL_POST_CONVOLUTION_COLOR_TABLE:
table = &ctx->PostConvolutionColorTable;
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 9dac955c8a..7430d94410 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.192 2003/01/21 21:47:45 brianp Exp $ */
+/* $Id: context.c,v 1.193 2003/01/26 14:37:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -863,6 +863,11 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
texUnit->Current3D = ctx->Shared->Default3D;
texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
texUnit->CurrentRect = ctx->Shared->DefaultRect;
+
+ /* GL_SGI_texture_color_table */
+ texUnit->ColorTableEnabled = GL_FALSE;
+ _mesa_init_colortable(&texUnit->ColorTable);
+ _mesa_init_colortable(&texUnit->ProxyColorTable);
}
@@ -1253,6 +1258,9 @@ init_attrib_groups( GLcontext *ctx )
}
ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0);
ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0);
+ /* GL_SGI_texture_color_table */
+ ASSIGN_4V(ctx->Pixel.TextureColorTableScale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.TextureColorTableBias, 0.0, 0.0, 0.0, 0.0);
/* Point group */
ctx->Point.SmoothFlag = GL_FALSE;
@@ -1323,9 +1331,6 @@ init_attrib_groups( GLcontext *ctx )
init_texture_unit( ctx, i );
ctx->Texture.SharedPalette = GL_FALSE;
_mesa_init_colortable(&ctx->Texture.Palette);
- ASSIGN_4V(ctx->Texture.ColorTableScale, 1.0, 1.0, 1.0, 1.0);
- ASSIGN_4V(ctx->Texture.ColorTableBias, 0.0, 0.0, 0.0, 0.0);
- ctx->Texture.ColorTableEnabled = GL_FALSE;
/* Transformation group */
ctx->Transform.MatrixMode = GL_MODELVIEW;
@@ -1465,8 +1470,6 @@ init_attrib_groups( GLcontext *ctx )
_mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable);
_mesa_init_colortable(&ctx->PostColorMatrixColorTable);
_mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable);
- _mesa_init_colortable(&ctx->TextureColorTable);
- _mesa_init_colortable(&ctx->ProxyTextureColorTable);
/* Vertex/fragment programs */
ctx->Program.ErrorPos = -1;
@@ -1993,6 +1996,9 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_texture_object( NULL, ctx->Texture.ProxyCubeMap );
_mesa_free_texture_object( NULL, ctx->Texture.ProxyRect );
+ for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
+ _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable );
+
/* Free evaluator data */
if (ctx->EvalMap.Map1Vertex3.Points)
FREE( ctx->EvalMap.Map1Vertex3.Points );
@@ -2040,7 +2046,6 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_colortable_data( &ctx->PostConvolutionColorTable );
_mesa_free_colortable_data( &ctx->PostColorMatrixColorTable );
_mesa_free_colortable_data( &ctx->Texture.Palette );
- _mesa_free_colortable_data( &ctx->TextureColorTable );
_math_matrix_dtr(&ctx->Viewport._WindowMap);
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 44c1e14015..f343c2099a 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.73 2003/01/21 21:47:49 brianp Exp $ */
+/* $Id: enable.c,v 1.74 2003/01/26 14:37:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -693,10 +693,10 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_TEXTURE_COLOR_TABLE_SGI:
CHECK_EXTENSION(SGI_texture_color_table, cap);
- if (ctx->Texture.ColorTableEnabled == state)
+ if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- ctx->Texture.ColorTableEnabled = state;
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
break;
/* GL_EXT_convolution */
@@ -1161,6 +1161,11 @@ _mesa_IsEnabled( GLenum cap )
CHECK_EXTENSION(SGI_color_table);
return ctx->Pixel.PostColorMatrixColorTableEnabled;
+ /* GL_SGI_texture_color_table */
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_texture_color_table);
+ return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
+
/* GL_EXT_convolution */
case GL_CONVOLUTION_1D:
CHECK_EXTENSION(EXT_convolution);
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 8a0aa50b19..011ec4d64c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.104 2003/01/22 00:42:45 brianp Exp $ */
+/* $Id: get.c,v 1.105 2003/01/26 14:37:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -1232,7 +1232,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
/* GL_SGI_texture_color_table */
case GL_TEXTURE_COLOR_TABLE_SGI:
CHECK_EXTENSION_B(SGI_texture_color_table, pname);
- *params = ctx->Texture.ColorTableEnabled;
+ *params = textureUnit->ColorTableEnabled;
break;
/* GL_EXT_secondary_color */
@@ -2631,7 +2631,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
/* GL_SGI_texture_color_table */
case GL_TEXTURE_COLOR_TABLE_SGI:
CHECK_EXTENSION_D(SGI_texture_color_table, pname);
- *params = (GLdouble) ctx->Texture.ColorTableEnabled;
+ *params = (GLdouble) textureUnit->ColorTableEnabled;
break;
/* GL_EXT_secondary_color */
@@ -4004,7 +4004,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
/* GL_SGI_texture_color_table */
case GL_TEXTURE_COLOR_TABLE_SGI:
CHECK_EXTENSION_F(SGI_texture_color_table, pname);
- *params = (GLfloat) ctx->Texture.ColorTableEnabled;
+ *params = (GLfloat) textureUnit->ColorTableEnabled;
break;
/* GL_EXT_secondary_color */
@@ -5415,7 +5415,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
/* GL_SGI_texture_color_table */
case GL_TEXTURE_COLOR_TABLE_SGI:
CHECK_EXTENSION_I(SGI_texture_color_table, pname);
- *params = (GLint) ctx->Texture.ColorTableEnabled;
+ *params = (GLint) textureUnit->ColorTableEnabled;
break;
/* GL_EXT_secondary_color */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ba80d95287..4c3fb3bbd4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.101 2003/01/22 17:58:52 brianp Exp $ */
+/* $Id: mtypes.h,v 1.102 2003/01/26 14:37:15 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -438,11 +438,14 @@ struct gl_enable_attrib {
GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
- GLboolean TextureColorTable; /* SGI_texture_color_table */
- GLboolean VertexProgram; /* GL_NV_vertex_program */
- GLboolean VertexProgramPointSize; /* GL_NV_vertex_program */
- GLboolean VertexProgramTwoSide; /* GL_NV_vertex_program */
- GLboolean PointSprite; /* GL_NV_point_sprite */
+ /* SGI_texture_color_table */
+ GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
+ /* GL_NV_vertex_program */
+ GLboolean VertexProgram;
+ GLboolean VertexProgramPointSize;
+ GLboolean VertexProgramTwoSide;
+ /* GL_NV_point_sprite */
+ GLboolean PointSprite;
};
@@ -661,6 +664,9 @@ struct gl_pixel_attrib {
GLfloat PCMCTscale[4];
GLfloat PCMCTbias[4];
GLboolean PostColorMatrixColorTableEnabled;
+ /* GL_SGI_texture_color_table */
+ GLfloat TextureColorTableScale[4];
+ GLfloat TextureColorTableBias[4];
/* Convolution */
GLboolean Convolution1DEnabled;
GLboolean Convolution2DEnabled;
@@ -955,16 +961,21 @@ struct gl_texture_unit {
struct gl_texture_object Saved3D;
struct gl_texture_object SavedCubeMap;
struct gl_texture_object SavedRect;
+
+ /* GL_SGI_texture_color_table */
+ struct gl_color_table ColorTable;
+ struct gl_color_table ProxyColorTable;
+ GLboolean ColorTableEnabled;
};
/* The texture attribute group */
struct gl_texture_attrib {
/* multitexture */
- GLuint CurrentUnit; /* Active texture unit */
+ GLuint CurrentUnit; /* Active texture unit */
GLuint _EnabledUnits; /* one bit set for each really-enabled unit */
- GLuint _GenFlags; /* for texgen */
+ GLuint _GenFlags; /* for texgen */
GLuint _TexGenEnabled;
GLuint _TexMatEnabled;
@@ -979,10 +990,6 @@ struct gl_texture_attrib {
/* GL_EXT_shared_texture_palette */
GLboolean SharedPalette;
struct gl_color_table Palette;
- /* GL_SGI_texture_color_table */
- GLfloat ColorTableScale[4];
- GLfloat ColorTableBias[4];
- GLboolean ColorTableEnabled;
};
@@ -1724,8 +1731,6 @@ struct __GLcontextRec {
struct gl_color_table ProxyPostConvolutionColorTable;
struct gl_color_table PostColorMatrixColorTable;
struct gl_color_table ProxyPostColorMatrixColorTable;
- struct gl_color_table TextureColorTable;
- struct gl_color_table ProxyTextureColorTable;
struct program_state Program; /* for vertex or fragment progs */
struct vertex_program_state VertexProgram; /* GL_NV_vertex_program */
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index c4bc9de9f1..89427578e6 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -1,10 +1,10 @@
-/* $Id: s_context.c,v 1.43 2003/01/14 04:55:46 brianp Exp $ */
+/* $Id: s_context.c,v 1.44 2003/01/26 14:37:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -295,6 +295,11 @@ _swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
lambda, rgba );
+
+ /* GL_SGI_texture_color_table */
+ if (ctx->Texture.Unit[texUnit].ColorTableEnabled) {
+ _swrast_texture_table_lookup(&ctx->Texture.Unit[texUnit].ColorTable, n, rgba);
+ }
}
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index bc1e14d967..190c701b2c 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -1,4 +1,4 @@
-/* $Id: s_texture.c,v 1.77 2003/01/21 21:47:53 brianp Exp $ */
+/* $Id: s_texture.c,v 1.78 2003/01/26 14:37:16 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -296,117 +296,130 @@
#define K1BIT 32
-static void texture_table_lookup(const struct gl_color_table *table,
- GLuint n, GLchan rgba[][4])
+/*
+ * Do the lookup for GL_SGI_texture_color_table.
+ */
+void
+_swrast_texture_table_lookup(const struct gl_color_table *table,
+ GLuint n, GLchan rgba[][4])
{
- ASSERT(table->FloatTable);
if (!table->Table || table->Size == 0)
return;
switch (table->Format) {
case GL_INTENSITY:
/* replace RGBA with I */
- if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLchan *lut = (const GLchan *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLchan c = lut[CLAMP(j, 0, 1)];
- rgba[i][RCOMP] = rgba[i][GCOMP] =
- rgba[i][BCOMP] = rgba[i][ACOMP] = c;
- }
-
- }
- else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
+ if (table->FloatTable) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] =
rgba[i][BCOMP] = rgba[i][ACOMP] = c;
}
}
+ else {
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLchan c = lut[rgba[i][RCOMP]];
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = lut[j];
+ }
+ }
+ }
break;
case GL_LUMINANCE:
/* replace RGB with L */
- if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLchan *lut = (const GLchan *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLchan c = lut[j];
- rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
- }
- }
- else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
+ if (table->FloatTable) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
GLchan c;
CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
}
}
+ else {
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLchan c = lut[rgba[i][RCOMP]];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = lut[j];
+ }
+ }
+ }
break;
case GL_ALPHA:
/* replace A with A */
- if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLchan *lut = (const GLchan *) table->Table;
+ if (table->FloatTable) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
- rgba[i][ACOMP] = lut[j];
+ GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ GLchan c;
+ CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
+ rgba[i][ACOMP] = c;
}
}
- else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLfloat *lut = (const GLfloat *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint j = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
- CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[j]);
+ else {
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = lut[rgba[i][ACOMP]];
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ rgba[i][ACOMP] = lut[j];
+ }
}
}
break;
case GL_LUMINANCE_ALPHA:
/* replace RGBA with LLLA */
- if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLchan *lut = (const GLchan *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint jL = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
- GLchan luminance, alpha;
- luminance = lut[jL * 2 + 0];
- alpha = lut[jA * 2 + 1];
- rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
- rgba[i][ACOMP] = alpha;;
- }
- }
- else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
+ if (table->FloatTable) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jL = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
+ GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
GLchan luminance, alpha;
CLAMPED_FLOAT_TO_CHAN(luminance, lut[jL * 2 + 0]);
CLAMPED_FLOAT_TO_CHAN(alpha, lut[jA * 2 + 1]);
@@ -414,50 +427,85 @@ static void texture_table_lookup(const struct gl_color_table *table,
rgba[i][ACOMP] = alpha;;
}
}
+ else {
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLchan l = lut[rgba[i][RCOMP] * 2 + 0];
+ GLchan a = lut[rgba[i][ACOMP] * 2 + 1];;
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = l;
+ rgba[i][ACOMP] = a;
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ GLchan luminance = lut[jL * 2 + 0];
+ GLchan alpha = lut[jA * 2 + 1];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
+ rgba[i][ACOMP] = alpha;
+ }
+ }
+ }
break;
case GL_RGB:
/* replace RGB with RGB */
- if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLchan *lut = (const GLchan *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale;
- GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale;
- rgba[i][RCOMP] = lut[jR * 3 + 0];
- rgba[i][GCOMP] = lut[jG * 3 + 1];
- rgba[i][BCOMP] = lut[jB * 3 + 2];
- }
- }
- else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
+ if (table->FloatTable) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLfloat *lut = (const GLfloat *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale;
- GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale;
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 3 + 0]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 3 + 1]);
CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 3 + 2]);
}
}
+ else {
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0];
+ rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1];
+ rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2];
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ rgba[i][RCOMP] = lut[jR * 3 + 0];
+ rgba[i][GCOMP] = lut[jG * 3 + 1];
+ rgba[i][BCOMP] = lut[jB * 3 + 2];
+ }
+ }
+ }
break;
case GL_RGBA:
/* replace RGBA with RGBA */
if (!table->FloatTable) {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
const GLchan *lut = (const GLchan *) table->Table;
GLuint i;
for (i = 0; i < n; i++) {
- GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale;
- GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale;
- GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
rgba[i][RCOMP] = lut[jR * 4 + 0];
rgba[i][GCOMP] = lut[jG * 4 + 1];
rgba[i][BCOMP] = lut[jB * 4 + 2];
@@ -465,24 +513,36 @@ static void texture_table_lookup(const struct gl_color_table *table,
}
}
else {
- const GLint max = table->Size - 1;
- const GLfloat scale = (GLfloat) max;
- const GLfloat *lut = (const GLfloat *) table->Table;
- GLuint i;
- for (i = 0; i < n; i++) {
- GLint jR = CHAN_TO_FLOAT(rgba[i][RCOMP])*scale;
- GLint jG = CHAN_TO_FLOAT(rgba[i][GCOMP])*scale;
- GLint jB = CHAN_TO_FLOAT(rgba[i][BCOMP])*scale;
- GLint jA = CHAN_TO_FLOAT(rgba[i][ACOMP])*scale;
- CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
- CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
- CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
- CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
+ if (CHAN_TYPE == GL_UNSIGNED_BYTE && table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0];
+ rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1];
+ rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2];
+ rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3];
+ }
+ }
+ else {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
+ }
}
}
break;
default:
- _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba");
+ _mesa_problem(NULL, "Bad format in _swrast_texture_table_lookup");
return;
}
}
@@ -864,10 +924,6 @@ sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
-
}
@@ -884,9 +940,6 @@ sample_linear_1d( GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -963,9 +1016,6 @@ sample_lambda_1d( GLcontext *ctx, GLuint texUnit,
return;
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1347,9 +1397,6 @@ sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1366,9 +1413,6 @@ sample_linear_2d( GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_2d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1560,9 +1604,6 @@ sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
_mesa_problem(ctx, "Bad mag filter in sample_lambda_2d");
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1901,9 +1942,6 @@ sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_3d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1920,9 +1958,6 @@ sample_linear_3d( GLcontext *ctx, GLuint texUnit,
for (i=0;i<n;i++) {
sample_3d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -1998,9 +2033,6 @@ sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
return;
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2099,9 +2131,6 @@ sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2120,14 +2149,11 @@ sample_linear_cube(GLcontext *ctx, GLuint texUnit,
sample_2d_linear(ctx, tObj, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
static void
-sample_cube_nearest_mipmap_nearest(GLcontext *ctx,
+sample_cube_nearest_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
@@ -2142,14 +2168,11 @@ sample_cube_nearest_mipmap_nearest(GLcontext *ctx,
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
static void
-sample_cube_linear_mipmap_nearest(GLcontext *ctx,
+sample_cube_linear_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
@@ -2164,14 +2187,11 @@ sample_cube_linear_mipmap_nearest(GLcontext *ctx,
images = choose_cube_face(tObj, texcoord[i], newCoord);
sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
static void
-sample_cube_nearest_mipmap_linear(GLcontext *ctx,
+sample_cube_nearest_mipmap_linear(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
@@ -2199,14 +2219,11 @@ sample_cube_nearest_mipmap_linear(GLcontext *ctx,
rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
static void
-sample_cube_linear_mipmap_linear(GLcontext *ctx,
+sample_cube_linear_mipmap_linear(GLcontext *ctx, GLuint texUnit,
const struct gl_texture_object *tObj,
GLuint n, GLfloat texcoord[][4],
const GLfloat lambda[], GLchan rgba[][4])
@@ -2234,9 +2251,6 @@ sample_cube_linear_mipmap_linear(GLcontext *ctx,
rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2266,19 +2280,23 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_NEAREST:
- sample_cube_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_cube_nearest_mipmap_nearest(ctx, texUnit, tObj, m,
+ texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_NEAREST:
- sample_cube_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ sample_cube_linear_mipmap_nearest(ctx, texUnit, tObj, m,
+ texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_NEAREST_MIPMAP_LINEAR:
- sample_cube_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_cube_nearest_mipmap_linear(ctx, texUnit, tObj, m,
+ texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
case GL_LINEAR_MIPMAP_LINEAR:
- sample_cube_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ sample_cube_linear_mipmap_linear(ctx, texUnit, tObj, m,
+ texcoords + minStart,
lambda + minStart, rgba + minStart);
break;
default:
@@ -2302,9 +2320,6 @@ sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
_mesa_problem(ctx, "Bad mag filter in sample_lambda_cube");
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2364,9 +2379,6 @@ sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
(*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2455,9 +2467,6 @@ sample_linear_rect(GLcontext *ctx, GLuint texUnit,
rgba[i][3] =
(GLchan) (w00 * t00[3] + w10 * t10[3] + w01 * t01[3] + w11 * t11[3]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -2495,9 +2504,6 @@ sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
texcoords + magStart, NULL, rgba + magStart);
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
@@ -4167,6 +4173,10 @@ _swrast_texture_span( GLcontext *ctx, struct sw_span *span )
swrast->TextureSample[unit]( ctx, unit, texUnit->_Current,
span->end, span->array->texcoords[unit],
lambda, texels );
+ /* GL_SGI_texture_color_table */
+ if (texUnit->ColorTableEnabled) {
+ _swrast_texture_table_lookup(&texUnit->ColorTable, span->end, texels);
+ }
}
}
diff --git a/src/mesa/swrast/s_texture.h b/src/mesa/swrast/s_texture.h
index a920c0fb7c..388c2db08d 100644
--- a/src/mesa/swrast/s_texture.h
+++ b/src/mesa/swrast/s_texture.h
@@ -1,10 +1,10 @@
-/* $Id: s_texture.h,v 1.13 2002/05/02 00:59:20 brianp Exp $ */
+/* $Id: s_texture.h,v 1.14 2003/01/26 14:37:17 brianp Exp $ */
/*
* Mesa 3-D graphics library
- * Version: 4.1
+ * Version: 5.1
*
- * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2003 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"),
@@ -34,6 +34,10 @@
extern void
+_swrast_texture_table_lookup( const struct gl_color_table *table,
+ GLuint n, GLchan rgba[][4] );
+
+extern void
_swrast_choose_texture_sample_func( GLcontext *ctx,
GLuint texUnit,
const struct gl_texture_object *tObj );