[Mesa-dev] [PATCH 06/14] mesa: Replace use of _ReallyEnabled as a boolean with use of _Current.

Eric Anholt eric at anholt.net
Thu Apr 24 17:50:13 PDT 2014


I'm probably not the only person that has tried to kill _ReallyEnabled.
This does the mechanical part of the work, and cleans _ReallyEnabled from
i965.

I think that using _Current makes texture management clearer: You can't
have multiple targets in use in the same texture image unit at the same
time, because there's just that one pointer.
---
 src/mesa/drivers/common/meta.c                   |  2 +-
 src/mesa/drivers/dri/i915/i830_texblend.c        |  2 +-
 src/mesa/drivers/dri/i965/brw_draw.c             |  2 +-
 src/mesa/drivers/dri/i965/brw_tex.c              |  2 +-
 src/mesa/drivers/dri/i965/brw_wm.c               |  2 +-
 src/mesa/drivers/dri/i965/brw_wm_sampler_state.c |  2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |  2 +-
 src/mesa/drivers/dri/i965/gen7_sampler_state.c   |  2 +-
 src/mesa/drivers/dri/nouveau/nv04_context.c      |  4 ++--
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c   |  2 +-
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c    |  2 +-
 src/mesa/drivers/dri/nouveau/nv10_state_frag.c   |  2 +-
 src/mesa/drivers/dri/nouveau/nv10_state_tex.c    |  2 +-
 src/mesa/drivers/dri/nouveau/nv20_state_tex.c    |  4 ++--
 src/mesa/drivers/dri/r200/r200_state.c           |  4 ++--
 src/mesa/drivers/dri/r200/r200_tcl.c             |  2 +-
 src/mesa/drivers/dri/r200/r200_texstate.c        | 14 ++++----------
 src/mesa/drivers/dri/radeon/radeon_state.c       |  4 ++--
 src/mesa/drivers/dri/radeon/radeon_state_init.c  |  6 +++---
 src/mesa/drivers/dri/radeon/radeon_tcl.c         |  2 +-
 src/mesa/drivers/dri/radeon/radeon_texstate.c    | 13 ++++---------
 src/mesa/main/ff_fragment_shader.cpp             |  2 +-
 src/mesa/main/ffvertex_prog.c                    |  2 +-
 src/mesa/main/texstate.c                         |  2 +-
 src/mesa/swrast/s_context.c                      |  2 +-
 src/mesa/swrast/s_texcombine.c                   | 10 +++++-----
 src/mesa/swrast/s_texture.c                      | 10 ++++------
 27 files changed, 46 insertions(+), 59 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 0f0cfc7..ab86f9c 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3265,7 +3265,7 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
          GLfloat s, t, s1, t1;
          GLuint tw, th;
 
-         if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+         if (!ctx->Texture.Unit[i]._Current) {
             GLuint j;
             for (j = 0; j < 4; j++) {
                verts[j].st[i][0] = 0.0f;
diff --git a/src/mesa/drivers/dri/i915/i830_texblend.c b/src/mesa/drivers/dri/i915/i830_texblend.c
index e5542af..6e991c4 100644
--- a/src/mesa/drivers/dri/i915/i830_texblend.c
+++ b/src/mesa/drivers/dri/i915/i830_texblend.c
@@ -446,7 +446,7 @@ i830EmitTextureBlend(struct i830_context *i830)
 
    if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
       for (unit = 0; unit < ctx->Texture._MaxEnabledTexImageUnit; unit++)
-         if (ctx->Texture.Unit[unit]._ReallyEnabled)
+         if (ctx->Texture.Unit[unit]._Current)
             emit_texblend(i830, unit, blendunit++,
                           unit == ctx->Texture._MaxEnabledTexImageUnit);
    } else {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 34afc26..671a594 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -317,7 +317,7 @@ brw_predraw_resolve_buffers(struct brw_context *brw)
    /* Resolve depth buffer and render cache of each enabled texture. */
    int maxEnabledUnit = ctx->Texture._MaxEnabledTexImageUnit;
    for (int i = 0; i <= maxEnabledUnit; i++) {
-      if (!ctx->Texture.Unit[i]._ReallyEnabled)
+      if (!ctx->Texture.Unit[i]._Current)
 	 continue;
       tex_obj = intel_texture_object(ctx->Texture.Unit[i]._Current);
       if (!tex_obj || !tex_obj->mt)
diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c
index 305d83d..13578b8 100644
--- a/src/mesa/drivers/dri/i965/brw_tex.c
+++ b/src/mesa/drivers/dri/i965/brw_tex.c
@@ -51,7 +51,7 @@ void brw_validate_textures( struct brw_context *brw )
    for (i = 0; i <= maxEnabledUnit; i++) {
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
 
-      if (texUnit->_ReallyEnabled) {
+      if (texUnit->_Current) {
 	 intel_finalize_mipmap_tree(brw, i);
       }
    }
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 663b47e..8530f4f 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -337,7 +337,7 @@ brw_populate_sampler_prog_key_data(struct gl_context *ctx,
       int unit_id = prog->SamplerUnits[s];
       const struct gl_texture_unit *unit = &ctx->Texture.Unit[unit_id];
 
-      if (unit->_ReallyEnabled && unit->_Current->Target != GL_TEXTURE_BUFFER) {
+      if (unit->_Current && unit->_Current->Target != GL_TEXTURE_BUFFER) {
 	 const struct gl_texture_object *t = unit->_Current;
 	 const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
 	 struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit_id);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
index e8701e0..afe952a 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
@@ -395,7 +395,7 @@ brw_upload_sampler_state_table(struct brw_context *brw,
    for (unsigned s = 0; s < sampler_count; s++) {
       if (SamplersUsed & (1 << s)) {
          const unsigned unit = prog->SamplerUnits[s];
-         if (ctx->Texture.Unit[unit]._ReallyEnabled)
+         if (ctx->Texture.Unit[unit]._Current)
             brw_update_sampler_state(brw, unit, s, &samplers[s],
                                      *sst_offset, &sdc_offset[s]);
       }
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index 443820b..e93a33e 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -778,7 +778,7 @@ update_stage_texture_surfaces(struct brw_context *brw,
          const unsigned unit = prog->SamplerUnits[s];
 
          /* _NEW_TEXTURE */
-         if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+         if (ctx->Texture.Unit[unit]._Current) {
             brw->vtbl.update_texture_surface(ctx, unit, surf_offset + s, for_gather);
          }
       }
diff --git a/src/mesa/drivers/dri/i965/gen7_sampler_state.c b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
index 709a783..94091d8 100644
--- a/src/mesa/drivers/dri/i965/gen7_sampler_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_sampler_state.c
@@ -202,7 +202,7 @@ gen7_upload_sampler_state_table(struct brw_context *brw,
    for (unsigned s = 0; s < sampler_count; s++) {
       if (SamplersUsed & (1 << s)) {
          const unsigned unit = prog->SamplerUnits[s];
-         if (ctx->Texture.Unit[unit]._ReallyEnabled)
+         if (ctx->Texture.Unit[unit]._Current)
             gen7_update_sampler_state(brw, unit, s, &samplers[s],
                                       &sdc_offset[s]);
       }
diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c
index cd6e876..3cc219b 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_context.c
@@ -53,9 +53,9 @@ nv04_context_engine(struct gl_context *ctx)
 	struct nouveau_pushbuf *push = context_push(ctx);
 	struct nouveau_object *fahrenheit;
 
-	if ((ctx->Texture.Unit[0]._ReallyEnabled &&
+	if ((ctx->Texture.Unit[0]._Current &&
 	     texunit_needs_combiners(&ctx->Texture.Unit[0])) ||
-	    ctx->Texture.Unit[1]._ReallyEnabled ||
+	    ctx->Texture.Unit[1]._Current ||
 	    ctx->Stencil.Enabled ||
 	    !(ctx->Color.ColorMask[0][RCOMP] &&
 	      ctx->Color.ColorMask[0][GCOMP] &&
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
index c48a0b0..248a7d2 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
@@ -257,7 +257,7 @@ nv04_emit_tex_env(struct gl_context *ctx, int emit)
 	struct combiner_state rc_a = {}, rc_c = {};
 
 	/* Compute the new combiner state. */
-	if (ctx->Texture.Unit[i]._ReallyEnabled) {
+	if (ctx->Texture.Unit[i]._Current) {
 		INIT_COMBINER(A, ctx, &rc_a, i);
 		setup_combiner(&rc_a);
 
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
index ff60b33..15eaa71 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
@@ -65,7 +65,7 @@ nv04_emit_tex_obj(struct gl_context *ctx, int emit)
 	struct nouveau_surface *s;
 	uint32_t format = 0xa0, filter = 0x1010;
 
-	if (ctx->Texture.Unit[i]._ReallyEnabled) {
+	if (ctx->Texture.Unit[i]._Current) {
 		struct gl_texture_object *t = ctx->Texture.Unit[i]._Current;
 		struct gl_texture_image *ti = t->Image[0][t->BaseLevel];
 		const struct gl_sampler_object *sa = _mesa_get_samplerobj(ctx, i);
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
index aa7e703..c007c6c 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
@@ -304,7 +304,7 @@ nv10_get_general_combiner(struct gl_context *ctx, int i,
 {
 	struct combiner_state rc_a, rc_c;
 
-	if (ctx->Texture.Unit[i]._ReallyEnabled) {
+	if (ctx->Texture.Unit[i]._Current) {
 		INIT_COMBINER(RGB, ctx, &rc_c, i);
 
 		if (rc_c.mode == GL_DOT3_RGBA)
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
index 22c7a42..d85adfa 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tex.c
@@ -165,7 +165,7 @@ nv10_emit_tex_obj(struct gl_context *ctx, int emit)
 
 	PUSH_RESET(push, BUFCTX_TEX(i));
 
-	if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+	if (!ctx->Texture.Unit[i]._Current) {
 		BEGIN_NV04(push, NV10_3D(TEX_ENABLE(i)), 1);
 		PUSH_DATA (push, 0);
 		return;
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
index 6998406..b0a4c9f 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_state_tex.c
@@ -169,7 +169,7 @@ nv20_emit_tex_obj(struct gl_context *ctx, int emit)
 
 	PUSH_RESET(push, BUFCTX_TEX(i));
 
-	if (!ctx->Texture.Unit[i]._ReallyEnabled) {
+	if (!ctx->Texture.Unit[i]._Current) {
 		BEGIN_NV04(push, NV20_3D(TEX_ENABLE(i)), 1);
 		PUSH_DATA (push, 0);
 
@@ -263,7 +263,7 @@ nv20_emit_tex_shader(struct gl_context *ctx, int emit)
 	int i;
 
 	for (i = 0; i < NV20_TEXTURE_UNITS; i++) {
-		if (!ctx->Texture.Unit[i]._ReallyEnabled)
+		if (!ctx->Texture.Unit[i]._Current)
 			continue;
 
 		tx_shader_op |= NV20_3D_TEX_SHADER_OP_TX0_TEXTURE_2D << 5 * i;
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 7c46d11..2c7b652 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2167,7 +2167,7 @@ static void update_texturematrix( struct gl_context *ctx )
    rmesa->TexMatCompSel = 0;
 
    for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
-      if (!ctx->Texture.Unit[unit]._ReallyEnabled)
+      if (!ctx->Texture.Unit[unit]._Current)
 	 continue;
 
       if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
@@ -2239,7 +2239,7 @@ static GLboolean r200ValidateBuffers(struct gl_context *ctx)
    for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; ++i) {
       radeonTexObj *t;
 
-      if (!ctx->Texture.Unit[i]._ReallyEnabled)
+      if (!ctx->Texture.Unit[i]._Current)
 	 continue;
 
       t = radeon_tex_obj(ctx->Texture.Unit[i]._Current);
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
index 5a72414..ccc8f42 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.c
+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -412,7 +412,7 @@ static GLboolean r200_run_tcl_render( struct gl_context *ctx,
       }
 
       for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
-	 if (ctx->Texture.Unit[i]._ReallyEnabled) {
+	 if (ctx->Texture.Unit[i]._Current) {
 	    if (rmesa->TexGenNeedNormals[i]) {
 	       map_rev_fixed[2] = VERT_ATTRIB_NORMAL;
 	    }
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index c3c92cb..9ec1207 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -296,12 +296,6 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
       ~(R200_TXA_DOT_ALPHA | R200_TXA_SCALE_MASK | R200_TXA_OUTPUT_REG_MASK |
 	R200_TXA_TFACTOR_SEL_MASK | R200_TXA_TFACTOR1_SEL_MASK);
 
-   /* texUnit->_Current can be NULL if and only if the texture unit is
-    * not actually enabled.
-    */
-   assert( (texUnit->_ReallyEnabled == 0)
-	   || (texUnit->_Current != NULL) );
-
    if ( R200_DEBUG & RADEON_TEXTURE ) {
       fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
    }
@@ -320,7 +314,7 @@ static GLboolean r200UpdateTextureEnv( struct gl_context *ctx, int unit, int slo
 			(unit << R200_TXA_TFACTOR_SEL_SHIFT) |
 			(replaceargs << R200_TXA_TFACTOR1_SEL_SHIFT);
 
-   if ( !texUnit->_ReallyEnabled ) {
+   if ( !texUnit->_Current ) {
       assert( unit == 0);
       color_combine = R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO
 	  | R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
@@ -840,7 +834,7 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
 
    /* find highest used unit */
    for ( j = 0; j < R200_MAX_TEXTURE_UNITS; j++) {
-      if (ctx->Texture.Unit[j]._ReallyEnabled) {
+      if (ctx->Texture.Unit[j]._Current) {
 	 maxunitused = j;
       }
    }
@@ -869,7 +863,7 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
 
          nextunit[j] = currentnext;
 
-         if (!texUnit->_ReallyEnabled) {
+         if (!texUnit->_Current) {
 	 /* the not enabled stages are referenced "indirectly",
             must not cut off the lower stages */
 	    stageref[j] = REF_COLOR | REF_ALPHA;
@@ -953,7 +947,7 @@ static GLboolean r200UpdateAllTexEnv( struct gl_context *ctx )
    i = 0;
    while ((i <= maxunitused) && (i >= 0)) {
       /* only output instruction if the results are referenced */
-      if (ctx->Texture.Unit[i]._ReallyEnabled && stageref[i+1]) {
+      if (ctx->Texture.Unit[i]._Current && stageref[i+1]) {
          GLuint replaceunit = i;
 	 /* try to optimize GL_REPLACE away (only one level deep though) */
 	 if (	(ctx->Texture.Unit[i]._CurrentCombine->ModeRGB == GL_REPLACE) &&
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 4a19db4..414946b 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -1935,7 +1935,7 @@ static void update_texturematrix( struct gl_context *ctx )
    rmesa->TexMatColSwap = 0;
 
    for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
-      if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+      if (ctx->Texture.Unit[unit]._Current) {
 	 GLboolean needMatrix = GL_FALSE;
 	 if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
 	    needMatrix = GL_TRUE;
@@ -2016,7 +2016,7 @@ static GLboolean r100ValidateBuffers(struct gl_context *ctx)
    for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; ++i) {
       radeonTexObj *t;
 
-      if (!ctx->Texture.Unit[i]._ReallyEnabled)
+      if (!ctx->Texture.Unit[i]._Current)
 	 continue;
 
       t = rmesa->state.texture.unit[i].texobj;
diff --git a/src/mesa/drivers/dri/radeon/radeon_state_init.c b/src/mesa/drivers/dri/radeon/radeon_state_init.c
index f44dff0..c14407f 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state_init.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state_init.c
@@ -211,9 +211,9 @@ CHECK( cube1_mm, (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_CUBE_BIT), 2 + 4
 CHECK( cube2_mm, (ctx->Texture.Unit[2]._ReallyEnabled & TEXTURE_CUBE_BIT), 2 + 4*5 - CUBE_STATE_SIZE )
 CHECK( fog_add4, ctx->Fog.Enabled, 4 )
 TCL_CHECK( tcl_add4, GL_TRUE, 4 )
-TCL_CHECK( tcl_tex0_add4, ctx->Texture.Unit[0]._ReallyEnabled, 4 )
-TCL_CHECK( tcl_tex1_add4, ctx->Texture.Unit[1]._ReallyEnabled, 4 )
-TCL_CHECK( tcl_tex2_add4, ctx->Texture.Unit[2]._ReallyEnabled, 4 )
+TCL_CHECK( tcl_tex0_add4, ctx->Texture.Unit[0]._Current, 4 )
+TCL_CHECK( tcl_tex1_add4, ctx->Texture.Unit[1]._Current, 4 )
+TCL_CHECK( tcl_tex2_add4, ctx->Texture.Unit[2]._Current, 4 )
 TCL_CHECK( tcl_lighting, ctx->Light.Enabled, 0 )
 TCL_CHECK( tcl_lighting_add4, ctx->Light.Enabled, 4 )
 TCL_CHECK( tcl_eyespace_or_lighting_add4, ctx->_NeedEyeCoords || ctx->Light.Enabled, 4 )
diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.c b/src/mesa/drivers/dri/radeon/radeon_tcl.c
index 21d54fb..271d5f9 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tcl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tcl.c
@@ -386,7 +386,7 @@ static GLboolean radeon_run_tcl_render( struct gl_context *ctx,
    }
 
    for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
-      if (ctx->Texture.Unit[i]._ReallyEnabled) {
+      if (ctx->Texture.Unit[i]._Current) {
       /* TODO: probably should not emit texture coords when texgen is enabled */
 	 if (rmesa->TexGenNeedNormals[i]) {
 	    inputs |= VERT_BIT_NORMAL;
diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c
index dac8aed..4600d34 100644
--- a/src/mesa/drivers/dri/radeon/radeon_texstate.c
+++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -257,12 +257,6 @@ static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
          | RADEON_SCALE_1X | RADEON_CLAMP_TX;
 
 
-   /* texUnit->_Current can be NULL if and only if the texture unit is
-    * not actually enabled.
-    */
-   assert( (texUnit->_ReallyEnabled == 0)
-	   || (texUnit->_Current != NULL) );
-
    if ( RADEON_DEBUG & RADEON_TEXTURE ) {
       fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
    }
@@ -279,7 +273,7 @@ static GLboolean radeonUpdateTextureEnv( struct gl_context *ctx, int unit )
    rmesa->state.texture.unit[unit].format = 0;
    rmesa->state.texture.unit[unit].envMode = 0;
 
-   if ( !texUnit->_ReallyEnabled ) {
+   if ( !texUnit->_Current ) {
       color_combine = color_combine0;
       alpha_combine = alpha_combine0;
    }
@@ -1082,13 +1076,14 @@ static GLboolean radeonUpdateTextureUnit( struct gl_context *ctx, int unit )
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
 
-   if (ctx->Texture.Unit[unit]._ReallyEnabled & TEXTURE_3D_BIT) {
+   if (ctx->Texture.Unit[unit]._Current &&
+       ctx->Texture.Unit[unit]._Current->Target == GL_TEXTURE_3D) {
      disable_tex_obj_state(rmesa, unit);
      rmesa->state.texture.unit[unit].texobj = NULL;
      return GL_FALSE;
    }
 
-   if (!ctx->Texture.Unit[unit]._ReallyEnabled) {
+   if (!ctx->Texture.Unit[unit]._Current) {
      /* disable the unit */
      disable_tex_obj_state(rmesa, unit);
      rmesa->state.texture.unit[unit].texobj = NULL;
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 66c18fa..f1ef38e 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -430,7 +430,7 @@ static GLuint make_state_key( struct gl_context *ctx,  struct state_key *key )
       const struct gl_sampler_object *samp;
       GLenum format;
 
-      if (!texUnit->_ReallyEnabled || !texUnit->Enabled)
+      if (!texUnit->_Current || !texUnit->Enabled)
          continue;
 
       samp = _mesa_get_samplerobj(ctx, i);
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index bdabc3f..728cf96 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -239,7 +239,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
    for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
 
-      if (texUnit->_ReallyEnabled)
+      if (texUnit->_Current)
 	 key->unit[i].texunit_really_enabled = 1;
 
       if (ctx->Point.PointSprite)
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 5cbf791..28e8bb1 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -371,7 +371,7 @@ update_texture_matrices( struct gl_context *ctx )
       if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
 	 _math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
 
-	 if (ctx->Texture.Unit[u]._ReallyEnabled &&
+	 if (ctx->Texture.Unit[u]._Current &&
 	     ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY)
 	    ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u);
       }
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index fbc9763..ad11aa2 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -923,7 +923,7 @@ _swrast_print_vertex( struct gl_context *ctx, const SWvertex *v )
                   v->attrib[VARYING_SLOT_POS][3]);
 
       for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
-	 if (ctx->Texture.Unit[i]._ReallyEnabled)
+	 if (ctx->Texture.Unit[i]._Current)
 	    _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i,
                         v->attrib[VARYING_SLOT_TEX0 + i][0],
                         v->attrib[VARYING_SLOT_TEX0 + i][1],
diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c
index 32d7c09..c1a152a 100644
--- a/src/mesa/swrast/s_texcombine.c
+++ b/src/mesa/swrast/s_texcombine.c
@@ -189,7 +189,7 @@ texture_combine( struct gl_context *ctx, GLuint unit,
             {
                const GLuint srcUnit = srcRGB - GL_TEXTURE0;
                ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
-               if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+               if (!ctx->Texture.Unit[srcUnit]._Current)
                   goto end;
                argRGB[term] = get_texel_array(swrast, srcUnit);
             }
@@ -279,7 +279,7 @@ texture_combine( struct gl_context *ctx, GLuint unit,
             {
                const GLuint srcUnit = srcA - GL_TEXTURE0;
                ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
-               if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+               if (!ctx->Texture.Unit[srcUnit]._Current)
                   goto end;
                argA[term] = get_texel_array(swrast, srcUnit);
             }
@@ -657,7 +657,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
    for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
 
-      if (texUnit->_ReallyEnabled &&
+      if (texUnit->_Current &&
          texUnit->_CurrentCombine->ModeRGB == GL_BUMP_ENVMAP_ATI) {
          const GLfloat (*texcoords)[4] = (const GLfloat (*)[4])
             span->array->attribs[VARYING_SLOT_TEX0 + unit];
@@ -723,7 +723,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
     */
    for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
-      if (texUnit->_ReallyEnabled &&
+      if (texUnit->_Current &&
           texUnit->_CurrentCombine->ModeRGB != GL_BUMP_ENVMAP_ATI) {
          const GLfloat (*texcoords)[4] = (const GLfloat (*)[4])
             span->array->attribs[VARYING_SLOT_TEX0 + unit];
@@ -787,7 +787,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
     * We modify the span->color.rgba values.
     */
    for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
-      if (ctx->Texture.Unit[unit]._ReallyEnabled)
+      if (ctx->Texture.Unit[unit]._Current)
          texture_combine(ctx, unit, primary_rgba, swrast->TexelBuffer, span);
    }
 
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index e2d5846..dfab8e4 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -345,11 +345,10 @@ _swrast_map_textures(struct gl_context *ctx)
    int unit;
 
    for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) {
-      if (ctx->Texture.Unit[unit]._ReallyEnabled) {
-         struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+      struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
 
+      if (texObj)
          _swrast_map_texture(ctx, texObj);
-      }
    }
 }
 
@@ -362,10 +361,9 @@ _swrast_unmap_textures(struct gl_context *ctx)
 {
    int unit;
    for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) {
-      if (ctx->Texture.Unit[unit]._ReallyEnabled) {
-         struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+      struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
 
+      if (texObj)
          _swrast_unmap_texture(ctx, texObj);
-      }
    }
 }
-- 
1.9.2



More information about the mesa-dev mailing list