summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2004-02-06 17:39:03 +0000
committerIan Romanick <[email protected]>2004-02-06 17:39:03 +0000
commit07d6a983595b7ee52c8448fc579d952ce36472b8 (patch)
treeccc7d63948da1efaca6cdd00c852c9d9094f5405 /src/mesa/main
parentc71ee917e325e8b8c1591047d6e33adb4e051da8 (diff)
Refactor "class" texture environments to be implemented in terms of
ARB_texture_env_combine state.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c62
-rw-r--r--src/mesa/main/mtypes.h42
-rw-r--r--src/mesa/main/texstate.c387
-rw-r--r--src/mesa/main/texstore.c28
4 files changed, 368 insertions, 151 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 8beb0a575b9..c5339fdbf35 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -652,38 +652,38 @@ pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
}
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT,
- unit->CombineModeRGB);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT,
- unit->CombineModeA);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT,
- unit->CombineSourceRGB[0]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT,
- unit->CombineSourceRGB[1]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_EXT,
- unit->CombineSourceRGB[2]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT,
- unit->CombineSourceA[0]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_EXT,
- unit->CombineSourceA[1]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_EXT,
- unit->CombineSourceA[2]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT,
- unit->CombineOperandRGB[0]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT,
- unit->CombineOperandRGB[1]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_EXT,
- unit->CombineOperandRGB[2]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_EXT,
- unit->CombineOperandA[0]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_EXT,
- unit->CombineOperandA[1]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_EXT,
- unit->CombineOperandA[2]);
- _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_EXT,
- 1 << unit->CombineScaleShiftRGB);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,
+ unit->Combine.ModeRGB);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
+ unit->Combine.ModeA);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB,
+ unit->Combine.SourceRGB[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB,
+ unit->Combine.SourceRGB[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB,
+ unit->Combine.SourceRGB[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA,
+ unit->Combine.SourceA[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA,
+ unit->Combine.SourceA[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA,
+ unit->Combine.SourceA[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB,
+ unit->Combine.OperandRGB[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB,
+ unit->Combine.OperandRGB[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB,
+ unit->Combine.OperandRGB[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
+ unit->Combine.OperandA[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
+ unit->Combine.OperandA[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
+ unit->Combine.OperandA[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE,
+ 1 << unit->Combine.ScaleShiftRGB);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE,
- 1 << unit->CombineScaleShiftA);
+ 1 << unit->Combine.ScaleShiftA);
}
/* Restore texture object state */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6665e139902..5ed79424d53 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1164,6 +1164,25 @@ struct gl_texture_object {
/*@}*/
};
+/**
+ * Texture combine environment state.
+ *
+ * \todo
+ * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
+ * structure will need to be expanded for 4 elements.
+ */
+struct gl_tex_env_combine_state {
+ GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
+ GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
+ GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
+ GLuint ScaleShiftA; /**< 0, 1 or 2 */
+ GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
+ GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
+};
/**
* Texture unit record
@@ -1201,16 +1220,19 @@ struct gl_texture_unit {
/**
* \name GL_EXT_texture_env_combine
*/
- /*@{*/
- GLenum CombineModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
- GLenum CombineSourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineSourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
- GLenum CombineOperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
- GLenum CombineOperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
- GLuint CombineScaleShiftRGB; /**< 0, 1 or 2 */
- GLuint CombineScaleShiftA; /**< 0, 1 or 2 */
- /*@}*/
+ struct gl_tex_env_combine_state Combine;
+
+ /**
+ * Derived state based on \c EnvMode and the \c BaseFormat of the
+ * currently enabled texture.
+ */
+ struct gl_tex_env_combine_state _EnvMode;
+
+ /**
+ * Currently enabled combiner state. This will point to either
+ * \c Combine or \c _EnvMode.
+ */
+ struct gl_tex_env_combine_state *_CurrentCombine;
struct gl_texture_object *Current1D;
struct gl_texture_object *Current2D;
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index e27c42e07b6..8cb247e413b 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -22,6 +22,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+/**
+ * \file texstate.c
+ *
+ * Texture state handling.
+ */
#include "glheader.h"
#include "colormac.h"
@@ -50,6 +55,20 @@
#define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
#endif
+/**
+ * Default texture combine environment state. This is used to initialize
+ * a context's texture units and as the basis for converting "classic"
+ * texture environmnets to ARB_texture_env_combine style values.
+ */
+static const struct gl_tex_env_combine_state default_combine_state = {
+ GL_MODULATE, GL_MODULATE,
+ { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT },
+ { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT },
+ { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA },
+ { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA },
+ 0, 0,
+ 2, 2
+};
void
@@ -92,14 +111,14 @@ _mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
dst->Texture.Unit[i].LodBias = src->Texture.Unit[i].LodBias;
/* GL_EXT_texture_env_combine */
- dst->Texture.Unit[i].CombineModeRGB = src->Texture.Unit[i].CombineModeRGB;
- dst->Texture.Unit[i].CombineModeA = src->Texture.Unit[i].CombineModeA;
- COPY_3V(dst->Texture.Unit[i].CombineSourceRGB, src->Texture.Unit[i].CombineSourceRGB);
- COPY_3V(dst->Texture.Unit[i].CombineSourceA, src->Texture.Unit[i].CombineSourceA);
- COPY_3V(dst->Texture.Unit[i].CombineOperandRGB, src->Texture.Unit[i].CombineOperandRGB);
- COPY_3V(dst->Texture.Unit[i].CombineOperandA, src->Texture.Unit[i].CombineOperandA);
- dst->Texture.Unit[i].CombineScaleShiftRGB = src->Texture.Unit[i].CombineScaleShiftRGB;
- dst->Texture.Unit[i].CombineScaleShiftA = src->Texture.Unit[i].CombineScaleShiftA;
+ dst->Texture.Unit[i].Combine.ModeRGB = src->Texture.Unit[i].Combine.ModeRGB;
+ dst->Texture.Unit[i].Combine.ModeA = src->Texture.Unit[i].Combine.ModeA;
+ COPY_3V(dst->Texture.Unit[i].Combine.SourceRGB, src->Texture.Unit[i].Combine.SourceRGB);
+ COPY_3V(dst->Texture.Unit[i].Combine.SourceA, src->Texture.Unit[i].Combine.SourceA);
+ COPY_3V(dst->Texture.Unit[i].Combine.OperandRGB, src->Texture.Unit[i].Combine.OperandRGB);
+ COPY_3V(dst->Texture.Unit[i].Combine.OperandA, src->Texture.Unit[i].Combine.OperandA);
+ dst->Texture.Unit[i].Combine.ScaleShiftRGB = src->Texture.Unit[i].Combine.ScaleShiftRGB;
+ dst->Texture.Unit[i].Combine.ScaleShiftA = src->Texture.Unit[i].Combine.ScaleShiftA;
/* texture object state */
_mesa_copy_texture_object(dst->Texture.Unit[i].Current1D,
@@ -125,22 +144,22 @@ _mesa_print_texunit_state( GLcontext *ctx, GLuint unit )
const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit;
_mesa_printf("Texture Unit %d\n", unit);
_mesa_printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode));
- _mesa_printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineModeRGB));
- _mesa_printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineModeA));
- _mesa_printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[0]));
- _mesa_printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[1]));
- _mesa_printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceRGB[2]));
- _mesa_printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[0]));
- _mesa_printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[1]));
- _mesa_printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineSourceA[2]));
- _mesa_printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[0]));
- _mesa_printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[1]));
- _mesa_printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandRGB[2]));
- _mesa_printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[0]));
- _mesa_printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[1]));
- _mesa_printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->CombineOperandA[2]));
- _mesa_printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->CombineScaleShiftRGB);
- _mesa_printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->CombineScaleShiftA);
+ _mesa_printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
+ _mesa_printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
+ _mesa_printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0]));
+ _mesa_printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1]));
+ _mesa_printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2]));
+ _mesa_printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0]));
+ _mesa_printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1]));
+ _mesa_printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2]));
+ _mesa_printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0]));
+ _mesa_printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1]));
+ _mesa_printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2]));
+ _mesa_printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0]));
+ _mesa_printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1]));
+ _mesa_printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2]));
+ _mesa_printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB);
+ _mesa_printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA);
_mesa_printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]);
}
@@ -150,6 +169,125 @@ _mesa_print_texunit_state( GLcontext *ctx, GLuint unit )
/* Texture Environment */
/**********************************************************************/
+/**
+ * Convert "classic" texture environment to ARB_texture_env_combine style
+ * environments.
+ *
+ * \param state texture_env_combine state vector to be filled-in.
+ * \param mode Classic texture environment mode (i.e., \c GL_REPLACE,
+ * \c GL_BLEND, \c GL_DECAL, etc.).
+ * \param tex_base_format Base format of the texture associated with the
+ * texture unit.
+ */
+static void
+calculate_derived_texenv( struct gl_tex_env_combine_state * state,
+ GLenum mode, GLenum tex_base_format )
+{
+ GLenum mode_rgb;
+ GLenum mode_a;
+
+ *state = default_combine_state;
+
+ switch( tex_base_format ) {
+ case GL_ALPHA:
+ state->SourceRGB[0] = GL_PREVIOUS;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ break;
+
+ case GL_LUMINANCE:
+ case GL_RGB:
+ case GL_YCBCR_MESA:
+ state->SourceA[0] = GL_PREVIOUS;
+ break;
+
+ default:
+ state->SourceRGB[0] = GL_PREVIOUS;
+ state->SourceA[0] = GL_PREVIOUS;
+ state->ModeRGB = GL_REPLACE;
+ state->ModeA = GL_REPLACE;
+ ASSERT(0);
+ return;
+ }
+
+ switch( mode ) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ mode_rgb = (tex_base_format == GL_ALPHA) ? GL_REPLACE : mode;
+ mode_a = mode;
+ break;
+
+ case GL_DECAL:
+ mode_rgb = GL_INTERPOLATE;
+ mode_a = GL_REPLACE;
+
+ state->SourceA[0] = GL_PREVIOUS;
+
+ /* Having alpha / luminance / intensity textures replace using the
+ * incoming fragment color matches the definition in NV_texture_shader.
+ * The 1.5 spec simply marks these as "undefined".
+ */
+ switch( tex_base_format ) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ state->SourceRGB[0] = GL_PREVIOUS;
+ break;
+ case GL_RGB:
+ case GL_YCBCR_MESA:
+ mode_rgb = GL_REPLACE;
+ break;
+ case GL_RGBA:
+ state->SourceRGB[2] = GL_TEXTURE;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ mode_rgb = GL_INTERPOLATE;
+ mode_a = GL_MODULATE;
+
+ switch( tex_base_format ) {
+ case GL_ALPHA:
+ mode_rgb = GL_REPLACE;
+ break;
+ case GL_INTENSITY:
+ mode_a = GL_INTERPOLATE;
+ /* FALLTHROUGH */
+ case GL_LUMINANCE:
+ case GL_RGB:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ case GL_YCBCR_MESA:
+ state->SourceRGB[2] = GL_TEXTURE;
+ state->SourceA[2] = GL_TEXTURE;
+ state->SourceRGB[0] = GL_CONSTANT;
+ state->OperandRGB[2] = GL_SRC_COLOR;
+ break;
+ }
+ break;
+
+ case GL_ADD:
+ mode_rgb = (tex_base_format == GL_ALPHA) ? GL_REPLACE : GL_ADD;
+ mode_a = (tex_base_format == GL_INTENSITY) ? GL_ADD : GL_MODULATE;
+ break;
+
+ default:
+ mode_rgb = GL_REPLACE;
+ mode_a = GL_REPLACE;
+ ASSERT(0);
+ break;
+ }
+
+ state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS)
+ ? mode_rgb : GL_REPLACE;
+ state->ModeA = (state->SourceA[0] != GL_PREVIOUS)
+ ? mode_a : GL_REPLACE;
+}
void GLAPIENTRY
_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
@@ -179,6 +317,18 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
texUnit->EnvMode = mode;
+
+ /* FIXME: Is this needed here or is having it in
+ * FIXME: update_texture_state enough?
+ */
+ if ( mode == GL_COMBINE ) {
+ texUnit->_CurrentCombine = & texUnit->Combine;
+ }
+ else if ( texUnit->_Current != NULL ) {
+ calculate_derived_texenv( & texUnit->_EnvMode, mode,
+ texUnit->_Current->Image[0][0]->Format );
+ texUnit->_CurrentCombine = & texUnit->_EnvMode;
+ }
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
@@ -243,10 +393,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
return;
}
- if (texUnit->CombineModeRGB == mode)
+ if (texUnit->Combine.ModeRGB == mode)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineModeRGB = mode;
+ texUnit->Combine.ModeRGB = mode;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -284,10 +434,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
return;
}
- if (texUnit->CombineModeA == mode)
+ if (texUnit->Combine.ModeA == mode)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineModeA = mode;
+ texUnit->Combine.ModeA = mode;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -311,10 +461,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
(ctx->Extensions.ATI_texture_env_combine3 &&
(source == GL_ZERO || source == GL_ONE))) {
/* legal */
- if (texUnit->CombineSourceRGB[s] == source)
+ if (texUnit->Combine.SourceRGB[s] == source)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineSourceRGB[s] = source;
+ texUnit->Combine.SourceRGB[s] = source;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", source);
@@ -343,10 +493,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
(ctx->Extensions.ATI_texture_env_combine3 &&
(source == GL_ZERO || source == GL_ONE))) {
/* legal */
- if (texUnit->CombineSourceA[s] == source)
+ if (texUnit->Combine.SourceA[s] == source)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineSourceA[s] = source;
+ texUnit->Combine.SourceA[s] = source;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", source);
@@ -369,10 +519,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
case GL_ONE_MINUS_SRC_COLOR:
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
- if (texUnit->CombineOperandRGB[s] == operand)
+ if (texUnit->Combine.OperandRGB[s] == operand)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineOperandRGB[s] = operand;
+ texUnit->Combine.OperandRGB[s] = operand;
break;
default:
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
@@ -392,11 +542,11 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
switch (operand) {
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA:
- if (texUnit->CombineOperandA[pname-GL_OPERAND0_ALPHA] ==
+ if (texUnit->Combine.OperandA[pname-GL_OPERAND0_ALPHA] ==
operand)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineOperandA[pname-GL_OPERAND0_ALPHA] = operand;
+ texUnit->Combine.OperandA[pname-GL_OPERAND0_ALPHA] = operand;
break;
default:
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
@@ -417,10 +567,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
case GL_ONE_MINUS_SRC_COLOR: /* ARB combine only */
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA: /* ARB combine only */
- if (texUnit->CombineOperandRGB[2] == operand)
+ if (texUnit->Combine.OperandRGB[2] == operand)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineOperandRGB[2] = operand;
+ texUnit->Combine.OperandRGB[2] = operand;
break;
default:
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
@@ -439,10 +589,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
switch (operand) {
case GL_SRC_ALPHA:
case GL_ONE_MINUS_SRC_ALPHA: /* ARB combine only */
- if (texUnit->CombineOperandA[2] == operand)
+ if (texUnit->Combine.OperandA[2] == operand)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineOperandA[2] = operand;
+ texUnit->Combine.OperandA[2] = operand;
break;
default:
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
@@ -472,10 +622,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
"glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
return;
}
- if (texUnit->CombineScaleShiftRGB == newshift)
+ if (texUnit->Combine.ScaleShiftRGB == newshift)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineScaleShiftRGB = newshift;
+ texUnit->Combine.ScaleShiftRGB = newshift;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -500,10 +650,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
"glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
return;
}
- if (texUnit->CombineScaleShiftA == newshift)
+ if (texUnit->Combine.ScaleShiftA == newshift)
return;
FLUSH_VERTICES(ctx, _NEW_TEXTURE);
- texUnit->CombineScaleShiftA = newshift;
+ texUnit->Combine.ScaleShiftA = newshift;
}
else {
TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
@@ -634,7 +784,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_COMBINE_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineModeRGB;
+ *params = (GLfloat) texUnit->Combine.ModeRGB;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -643,7 +793,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_COMBINE_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineModeA;
+ *params = (GLfloat) texUnit->Combine.ModeA;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -652,7 +802,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE0_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceRGB[0];
+ *params = (GLfloat) texUnit->Combine.SourceRGB[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -661,7 +811,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE1_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceRGB[1];
+ *params = (GLfloat) texUnit->Combine.SourceRGB[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -670,7 +820,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE2_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceRGB[2];
+ *params = (GLfloat) texUnit->Combine.SourceRGB[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -679,7 +829,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE0_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceA[0];
+ *params = (GLfloat) texUnit->Combine.SourceA[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -688,7 +838,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE1_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceA[1];
+ *params = (GLfloat) texUnit->Combine.SourceA[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -697,7 +847,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_SOURCE2_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineSourceA[2];
+ *params = (GLfloat) texUnit->Combine.SourceA[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -706,7 +856,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND0_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandRGB[0];
+ *params = (GLfloat) texUnit->Combine.OperandRGB[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -715,7 +865,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND1_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandRGB[1];
+ *params = (GLfloat) texUnit->Combine.OperandRGB[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -724,7 +874,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND2_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandRGB[2];
+ *params = (GLfloat) texUnit->Combine.OperandRGB[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -733,7 +883,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND0_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandA[0];
+ *params = (GLfloat) texUnit->Combine.OperandA[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -742,7 +892,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND1_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandA[1];
+ *params = (GLfloat) texUnit->Combine.OperandA[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -751,7 +901,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_OPERAND2_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLfloat) texUnit->CombineOperandA[2];
+ *params = (GLfloat) texUnit->Combine.OperandA[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
@@ -760,9 +910,9 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_RGB_SCALE:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- if (texUnit->CombineScaleShiftRGB == 0)
+ if (texUnit->Combine.ScaleShiftRGB == 0)
*params = 1.0;
- else if (texUnit->CombineScaleShiftRGB == 1)
+ else if (texUnit->Combine.ScaleShiftRGB == 1)
*params = 2.0;
else
*params = 4.0;
@@ -775,9 +925,9 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
case GL_ALPHA_SCALE:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- if (texUnit->CombineScaleShiftA == 0)
+ if (texUnit->Combine.ScaleShiftA == 0)
*params = 1.0;
- else if (texUnit->CombineScaleShiftA == 1)
+ else if (texUnit->Combine.ScaleShiftA == 1)
*params = 2.0;
else
*params = 4.0;
@@ -848,7 +998,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_COMBINE_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineModeRGB;
+ *params = (GLint) texUnit->Combine.ModeRGB;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -857,7 +1007,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_COMBINE_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineModeA;
+ *params = (GLint) texUnit->Combine.ModeA;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -866,7 +1016,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE0_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceRGB[0];
+ *params = (GLint) texUnit->Combine.SourceRGB[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -875,7 +1025,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE1_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceRGB[1];
+ *params = (GLint) texUnit->Combine.SourceRGB[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -884,7 +1034,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE2_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceRGB[2];
+ *params = (GLint) texUnit->Combine.SourceRGB[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -893,7 +1043,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE0_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceA[0];
+ *params = (GLint) texUnit->Combine.SourceA[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -902,7 +1052,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE1_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceA[1];
+ *params = (GLint) texUnit->Combine.SourceA[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -911,7 +1061,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_SOURCE2_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineSourceA[2];
+ *params = (GLint) texUnit->Combine.SourceA[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -920,7 +1070,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND0_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandRGB[0];
+ *params = (GLint) texUnit->Combine.OperandRGB[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -929,7 +1079,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND1_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandRGB[1];
+ *params = (GLint) texUnit->Combine.OperandRGB[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -938,7 +1088,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND2_RGB:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandRGB[2];
+ *params = (GLint) texUnit->Combine.OperandRGB[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -947,7 +1097,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND0_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandA[0];
+ *params = (GLint) texUnit->Combine.OperandA[0];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -956,7 +1106,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND1_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandA[1];
+ *params = (GLint) texUnit->Combine.OperandA[1];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -965,7 +1115,7 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_OPERAND2_ALPHA:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- *params = (GLint) texUnit->CombineOperandA[2];
+ *params = (GLint) texUnit->Combine.OperandA[2];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
@@ -974,9 +1124,9 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_RGB_SCALE:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- if (texUnit->CombineScaleShiftRGB == 0)
+ if (texUnit->Combine.ScaleShiftRGB == 0)
*params = 1;
- else if (texUnit->CombineScaleShiftRGB == 1)
+ else if (texUnit->Combine.ScaleShiftRGB == 1)
*params = 2;
else
*params = 4;
@@ -989,9 +1139,9 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
case GL_ALPHA_SCALE:
if (ctx->Extensions.EXT_texture_env_combine ||
ctx->Extensions.ARB_texture_env_combine) {
- if (texUnit->CombineScaleShiftA == 0)
+ if (texUnit->Combine.ScaleShiftA == 0)
*params = 1;
- else if (texUnit->CombineScaleShiftA == 1)
+ else if (texUnit->Combine.ScaleShiftA == 1)
*params = 2;
else
*params = 4;
@@ -2800,6 +2950,64 @@ update_texture_state( GLcontext *ctx )
if (texUnit->_ReallyEnabled)
ctx->Texture._EnabledUnits |= (1 << unit);
+ if ( texUnit->EnvMode == GL_COMBINE ) {
+ texUnit->_CurrentCombine = & texUnit->Combine;
+ }
+ else {
+ calculate_derived_texenv( & texUnit->_EnvMode,
+ texUnit->EnvMode,
+ texUnit->_Current->Image[0][0]->Format );
+ texUnit->_CurrentCombine = & texUnit->_EnvMode;
+ }
+
+ switch (texUnit->_CurrentCombine->ModeRGB) {
+ case GL_REPLACE:
+ texUnit->_CurrentCombine->_NumArgsRGB = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ texUnit->_CurrentCombine->_NumArgsRGB = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ texUnit->_CurrentCombine->_NumArgsRGB = 3;
+ break;
+ default:
+ texUnit->_CurrentCombine->_NumArgsRGB = 0;
+ ASSERT(0);
+ break;
+ }
+
+ switch (texUnit->_CurrentCombine->ModeA) {
+ case GL_REPLACE:
+ texUnit->_CurrentCombine->_NumArgsA = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ texUnit->_CurrentCombine->_NumArgsA = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ texUnit->_CurrentCombine->_NumArgsA = 3;
+ break;
+ default:
+ texUnit->_CurrentCombine->_NumArgsA = 0;
+ ASSERT(0);
+ break;
+ }
+
if (texUnit->TexGenEnabled) {
if (texUnit->TexGenEnabled & S_BIT) {
texUnit->_GenFlags |= texUnit->_GenBitS;
@@ -2910,22 +3118,9 @@ init_texture_unit( GLcontext *ctx, GLuint unit )
texUnit->EnvMode = GL_MODULATE;
ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
- texUnit->CombineModeRGB = GL_MODULATE;
- texUnit->CombineModeA = GL_MODULATE;
- texUnit->CombineSourceRGB[0] = GL_TEXTURE;
- texUnit->CombineSourceRGB[1] = GL_PREVIOUS_EXT;
- texUnit->CombineSourceRGB[2] = GL_CONSTANT_EXT;
- texUnit->CombineSourceA[0] = GL_TEXTURE;
- texUnit->CombineSourceA[1] = GL_PREVIOUS_EXT;
- texUnit->CombineSourceA[2] = GL_CONSTANT_EXT;
- texUnit->CombineOperandRGB[0] = GL_SRC_COLOR;
- texUnit->CombineOperandRGB[1] = GL_SRC_COLOR;
- texUnit->CombineOperandRGB[2] = GL_SRC_ALPHA;
- texUnit->CombineOperandA[0] = GL_SRC_ALPHA;
- texUnit->CombineOperandA[1] = GL_SRC_ALPHA;
- texUnit->CombineOperandA[2] = GL_SRC_ALPHA;
- texUnit->CombineScaleShiftRGB = 0;
- texUnit->CombineScaleShiftA = 0;
+ texUnit->Combine = default_combine_state;
+ texUnit->_EnvMode = default_combine_state;
+ texUnit->_CurrentCombine = & texUnit->_EnvMode;
texUnit->TexGenEnabled = 0;
texUnit->GenModeS = GL_EYE_LINEAR;
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 3e73de29b00..97040487f64 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1425,9 +1425,9 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
const GLint rowAb1 = (rowA[k] >> 11) & 0x1f;
const GLint rowBb0 = (rowB[j] >> 11) & 0x1f;
const GLint rowBb1 = (rowB[k] >> 11) & 0x1f;
- const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 4;
- const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 4;
- const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 4;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
dst[i] = (blue << 11) | (green << 5) | red;
}
}
@@ -1456,10 +1456,10 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
const GLint rowAa1 = (rowA[k] >> 12) & 0xf;
const GLint rowBa0 = (rowB[j] >> 12) & 0xf;
const GLint rowBa1 = (rowB[k] >> 12) & 0xf;
- const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 4;
- const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 4;
- const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 4;
- const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 4;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2;
dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red;
}
}
@@ -1488,10 +1488,10 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
const GLint rowAa1 = (rowA[k] >> 15) & 0x1;
const GLint rowBa0 = (rowB[j] >> 15) & 0x1;
const GLint rowBa1 = (rowB[k] >> 15) & 0x1;
- const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 4;
- const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 4;
- const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 4;
- const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 4;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2;
dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red;
}
}
@@ -1531,9 +1531,9 @@ do_row(const struct gl_texture_format *format, GLint srcWidth,
const GLint rowAb1 = (rowA[k] >> 5) & 0x7;
const GLint rowBb0 = (rowB[j] >> 5) & 0x7;
const GLint rowBb1 = (rowB[k] >> 5) & 0x7;
- const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 4;
- const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 4;
- const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 4;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
dst[i] = (blue << 5) | (green << 2) | red;
}
}