-/* $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
_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:
_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;
_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;
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)");
_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;
_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;
_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;
_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;
-/* $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
#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]);
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];
}
}
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;
}
}
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);
- }
-
}
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);
- }
}
return;
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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);
- }
}
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);
- }
}
_mesa_problem(ctx, "Bad mag filter in sample_lambda_2d");
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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);
- }
}
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);
- }
}
return;
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel],
newCoord, rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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])
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])
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])
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])
rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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:
_mesa_problem(ctx, "Bad mag filter in sample_lambda_cube");
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
(*img->FetchTexel)(img, col, row, 0, (GLvoid *) rgba[i]);
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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);
- }
}
texcoords + magStart, NULL, rgba + magStart);
}
}
- if (ctx->Texture.ColorTableEnabled) {
- texture_table_lookup(&ctx->TextureColorTable, n, rgba);
- }
}
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);
+ }
}
}