aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r--src/mesa/main/texstate.c83
1 files changed, 48 insertions, 35 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index e24b3c494cc..2b05630e619 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -78,19 +78,8 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
/* per-unit state */
for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
- dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled;
- dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode;
- COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor);
- dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled;
- dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS;
- dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT;
- dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR;
- dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ;
dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias;
- /* GL_EXT_texture_env_combine */
- dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine;
-
/*
* XXX strictly speaking, we should compare texture names/ids and
* bind textures in the dest context according to id. For now, only
@@ -113,6 +102,20 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
_mesa_unlock_context_textures(dst);
}
}
+
+ for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
+ dst->Texture.FixedFuncUnit[u].Enabled = src->Texture.FixedFuncUnit[u].Enabled;
+ dst->Texture.FixedFuncUnit[u].EnvMode = src->Texture.FixedFuncUnit[u].EnvMode;
+ COPY_4V(dst->Texture.FixedFuncUnit[u].EnvColor, src->Texture.FixedFuncUnit[u].EnvColor);
+ dst->Texture.FixedFuncUnit[u].TexGenEnabled = src->Texture.FixedFuncUnit[u].TexGenEnabled;
+ dst->Texture.FixedFuncUnit[u].GenS = src->Texture.FixedFuncUnit[u].GenS;
+ dst->Texture.FixedFuncUnit[u].GenT = src->Texture.FixedFuncUnit[u].GenT;
+ dst->Texture.FixedFuncUnit[u].GenR = src->Texture.FixedFuncUnit[u].GenR;
+ dst->Texture.FixedFuncUnit[u].GenQ = src->Texture.FixedFuncUnit[u].GenQ;
+
+ /* GL_EXT_texture_env_combine */
+ dst->Texture.FixedFuncUnit[u].Combine = src->Texture.FixedFuncUnit[u].Combine;
+ }
}
@@ -122,7 +125,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
void
_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit )
{
- const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit;
+ const struct gl_fixedfunc_texture_unit *texUnit = ctx->Texture.FixedFuncUnit + unit;
printf("Texture Unit %d\n", unit);
printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_enum_to_string(texUnit->EnvMode));
printf(" GL_COMBINE_RGB = %s\n", _mesa_enum_to_string(texUnit->Combine.ModeRGB));
@@ -461,7 +464,7 @@ tex_combine_translate_operand(GLenum operand)
static void
-pack_tex_combine(struct gl_texture_unit *texUnit)
+pack_tex_combine(struct gl_fixedfunc_texture_unit *texUnit)
{
struct gl_tex_env_combine_state *state = texUnit->_CurrentCombine;
struct gl_tex_env_combine_packed *packed = &texUnit->_CurrentCombinePacked;
@@ -493,7 +496,9 @@ pack_tex_combine(struct gl_texture_unit *texUnit)
* Examine texture unit's combine/env state to update derived state.
*/
static void
-update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
+update_tex_combine(struct gl_context *ctx,
+ struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *fftexUnit)
{
struct gl_tex_env_combine_state *combine;
@@ -505,9 +510,9 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
* state, or the combiner state which is derived from traditional texenv
* mode.
*/
- if (texUnit->EnvMode == GL_COMBINE ||
- texUnit->EnvMode == GL_COMBINE4_NV) {
- texUnit->_CurrentCombine = & texUnit->Combine;
+ if (fftexUnit->EnvMode == GL_COMBINE ||
+ fftexUnit->EnvMode == GL_COMBINE4_NV) {
+ fftexUnit->_CurrentCombine = & fftexUnit->Combine;
}
else {
const struct gl_texture_object *texObj = texUnit->_Current;
@@ -516,11 +521,11 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
format = texObj->DepthMode;
}
- calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
- texUnit->_CurrentCombine = & texUnit->_EnvMode;
+ calculate_derived_texenv(&fftexUnit->_EnvMode, fftexUnit->EnvMode, format);
+ fftexUnit->_CurrentCombine = & fftexUnit->_EnvMode;
}
- combine = texUnit->_CurrentCombine;
+ combine = fftexUnit->_CurrentCombine;
/* Determine number of source RGB terms in the combiner function */
switch (combine->ModeRGB) {
@@ -529,7 +534,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
case GL_ADD:
case GL_ADD_SIGNED:
- if (texUnit->EnvMode == GL_COMBINE4_NV)
+ if (fftexUnit->EnvMode == GL_COMBINE4_NV)
combine->_NumArgsRGB = 4;
else
combine->_NumArgsRGB = 2;
@@ -561,7 +566,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
case GL_ADD:
case GL_ADD_SIGNED:
- if (texUnit->EnvMode == GL_COMBINE4_NV)
+ if (fftexUnit->EnvMode == GL_COMBINE4_NV)
combine->_NumArgsA = 4;
else
combine->_NumArgsA = 2;
@@ -582,7 +587,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
}
- pack_tex_combine(texUnit);
+ pack_tex_combine(fftexUnit);
}
static void
@@ -592,7 +597,8 @@ update_texgen(struct gl_context *ctx)
/* Setup texgen for those texture coordinate sets that are in use */
for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[unit];
texUnit->_GenFlags = 0x0;
@@ -748,10 +754,12 @@ update_ff_texture_state(struct gl_context *ctx,
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_fixedfunc_texture_unit *fftexUnit =
+ &ctx->Texture.FixedFuncUnit[unit];
GLbitfield mask;
bool complete;
- if (texUnit->Enabled == 0x0)
+ if (fftexUnit->Enabled == 0x0)
continue;
/* If a shader already dictated what texture target was used for this
@@ -788,7 +796,7 @@ update_ff_texture_state(struct gl_context *ctx,
* undefined."
*/
complete = false;
- mask = texUnit->Enabled;
+ mask = fftexUnit->Enabled;
while (mask) {
const int texIndex = u_bit_scan(&mask);
struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
@@ -815,7 +823,7 @@ update_ff_texture_state(struct gl_context *ctx,
ctx->Texture._EnabledCoordUnits |= 1 << unit;
- update_tex_combine(ctx, texUnit);
+ update_tex_combine(ctx, texUnit, fftexUnit);
}
}
@@ -998,6 +1006,19 @@ _mesa_init_texture(struct gl_context *ctx)
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
GLuint tex;
+ /* initialize current texture object ptrs to the shared default objects */
+ for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
+ _mesa_reference_texobj(&texUnit->CurrentTex[tex],
+ ctx->Shared->DefaultTex[tex]);
+ }
+
+ texUnit->_BoundTextures = 0;
+ }
+
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); u++) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[u];
+
texUnit->EnvMode = GL_MODULATE;
ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
@@ -1024,14 +1045,6 @@ _mesa_init_texture(struct gl_context *ctx)
ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 );
ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 );
-
- /* initialize current texture object ptrs to the shared default objects */
- for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
- _mesa_reference_texobj(&texUnit->CurrentTex[tex],
- ctx->Shared->DefaultTex[tex]);
- }
-
- texUnit->_BoundTextures = 0;
}
/* After we're done initializing the context's texture state the default