[Mesa-dev] [PATCH 03/14] mesa: Drop _EnabledUnits.

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


The field wasn't really valid, since we've got more than 32 units now.  It
turns out it was mostly just used for checking != 0, or checking for fixed
function coordinates, though.
---
 src/mesa/drivers/common/meta.c                 |  2 +-
 src/mesa/drivers/dri/i915/intel_pixel.c        |  2 +-
 src/mesa/drivers/dri/i915/intel_pixel_copy.c   |  2 +-
 src/mesa/drivers/dri/i965/intel_pixel.c        |  2 +-
 src/mesa/drivers/dri/i965/intel_pixel_copy.c   |  2 +-
 src/mesa/drivers/dri/nouveau/nv04_state_frag.c |  2 +-
 src/mesa/drivers/dri/nouveau/nv10_state_frag.c |  4 ++--
 src/mesa/drivers/dri/r200/r200_state_init.c    |  4 ++--
 src/mesa/drivers/osmesa/osmesa.c               |  4 ++--
 src/mesa/drivers/x11/xm_line.c                 |  4 ++--
 src/mesa/drivers/x11/xm_tri.c                  |  2 +-
 src/mesa/main/ffvertex_prog.c                  |  2 +-
 src/mesa/main/mtypes.h                         |  3 ---
 src/mesa/main/texstate.c                       |  4 ----
 src/mesa/swrast/s_context.c                    |  4 ++--
 src/mesa/swrast/s_texture.c                    | 29 +++++++++++---------------
 src/mesa/swrast/s_triangle.c                   |  2 +-
 17 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index ac27abb..0f0cfc7 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2328,7 +2328,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
    if (ctx->_ImageTransferState ||
        ctx->FragmentProgram._Enabled ||
        ctx->Fog.Enabled ||
-       ctx->Texture._EnabledUnits ||
+       ctx->Texture._MaxEnabledTexImageUnit != -1 ||
        width > tex->MaxSize ||
        height > tex->MaxSize) {
       _swrast_Bitmap(ctx, x, y, width, height, unpack, bitmap1);
diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c
index da2f783..6f139e1 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -77,7 +77,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
       return false;
    }
 
-   if (ctx->Texture._EnabledUnits) {
+   if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
       DBG("fallback due to texturing\n");
       return false;
    }
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
index 6cfdc92..e7b5353 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
@@ -117,7 +117,7 @@ do_blit_copypixels(struct gl_context * ctx,
    }
 
    if (ctx->Fog.Enabled ||
-       ctx->Texture._EnabledUnits ||
+       ctx->Texture._MaxEnabledTexImageUnit != -1 ||
        ctx->FragmentProgram._Enabled) {
       perf_debug("glCopyPixels(): Unsupported fragment shader state\n");
       return false;
diff --git a/src/mesa/drivers/dri/i965/intel_pixel.c b/src/mesa/drivers/dri/i965/intel_pixel.c
index 5f57022..a6db7fa 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel.c
@@ -77,7 +77,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
       return false;
    }
 
-   if (ctx->Texture._EnabledUnits) {
+   if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
       DBG("fallback due to texturing\n");
       return false;
    }
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
index 858be26..5687c28 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
@@ -125,7 +125,7 @@ do_blit_copypixels(struct gl_context * ctx,
    }
 
    if (ctx->Fog.Enabled ||
-       ctx->Texture._EnabledUnits ||
+       ctx->Texture._MaxEnabledTexImageUnit != -1 ||
        ctx->FragmentProgram._Enabled) {
       perf_debug("glCopyPixels(): Unsupported fragment shader state\n");
       return false;
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
index 17d2781..c48a0b0 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_frag.c
@@ -286,7 +286,7 @@ nv04_emit_tex_env(struct gl_context *ctx, int emit)
 
 	/* calculate non-multitex state */
 	nv04->blend &= ~NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_MAP__MASK;
-	if (ctx->Texture._EnabledUnits)
+	if (ctx->Texture._MaxEnabledTexImageUnit != -1)
 		nv04->blend |= get_texenv_mode(ctx->Texture.Unit[0].EnvMode);
 	else
 		nv04->blend |= get_texenv_mode(GL_MODULATE);
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
index 10f067f..aa7e703 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_frag.c
@@ -353,7 +353,7 @@ nv10_get_final_combiner(struct gl_context *ctx, uint64_t *in, int *n)
 		INPUT_ONE(&rc, E, 0);
 	}
 
-	if (ctx->Texture._EnabledUnits) {
+	if (ctx->Texture._MaxEnabledTexImageUnit != -1) {
 		INPUT_SRC(&rc, B, SPARE0, RGB);
 		INPUT_SRC(&rc, G, SPARE0, ALPHA);
 	} else {
@@ -362,7 +362,7 @@ nv10_get_final_combiner(struct gl_context *ctx, uint64_t *in, int *n)
 	}
 
 	*in = rc.in;
-	*n = log2i(ctx->Texture._EnabledUnits) + 1;
+	*n = ctx->Texture._MaxEnabledTexImageUnit + 1;
 }
 
 void
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index eb93036..d9d1a0e 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -251,8 +251,8 @@ static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom )
 CHECK( always, GL_TRUE, 0 )
 CHECK( always_add4, GL_TRUE, 4 )
 CHECK( never, GL_FALSE, 0 )
-CHECK( tex_any, ctx->Texture._EnabledUnits, 0 )
-CHECK( tf, (ctx->Texture._EnabledUnits && !ctx->ATIFragmentShader._Enabled), 0 );
+CHECK( tex_any, ctx->Texture._MaxEnabledTexImageUnit != -1, 0 )
+CHECK( tf, (ctx->Texture._MaxEnabledTexImageUnit != -1 && !ctx->ATIFragmentShader._Enabled), 0 );
 CHECK( pix_zero, !ctx->ATIFragmentShader._Enabled, 0 )
    CHECK( texenv, (rmesa->state.envneeded & (1 << (atom->idx)) && !ctx->ATIFragmentShader._Enabled), 0 )
 CHECK( afs_pass1, (ctx->ATIFragmentShader._Enabled && (ctx->ATIFragmentShader.Current->NumPasses > 1)), 0 )
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 347913d..6026fd5 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -207,7 +207,7 @@ osmesa_choose_line_function( struct gl_context *ctx )
 
    if (ctx->RenderMode != GL_RENDER ||
        ctx->Line.SmoothFlag ||
-       ctx->Texture._EnabledUnits ||
+       ctx->Texture.MaxEnabledTexImageUnit == -1 ||
        ctx->Light.ShadeModel != GL_FLAT ||
        ctx->Line.Width != 1.0F ||
        ctx->Line.StippleFlag ||
@@ -322,7 +322,7 @@ osmesa_choose_triangle_function( struct gl_context *ctx )
    if (ctx->RenderMode != GL_RENDER ||
        ctx->Polygon.SmoothFlag ||
        ctx->Polygon.StippleFlag ||
-       ctx->Texture._EnabledUnits) {
+       ctx->Texture._MaxEnabledTexImageUnit != -1) {
       return NULL;
    }
 
diff --git a/src/mesa/drivers/x11/xm_line.c b/src/mesa/drivers/x11/xm_line.c
index 00307c7..1349610 100644
--- a/src/mesa/drivers/x11/xm_line.c
+++ b/src/mesa/drivers/x11/xm_line.c
@@ -97,7 +97,7 @@ void xmesa_choose_point( struct gl_context *ctx )
    if (ctx->RenderMode == GL_RENDER
        && ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
        && swrast->_RasterMask == 0
-       && !ctx->Texture._EnabledUnits
+       && ctx->Texture._MaxEnabledTexImageUnit == 0
        && xmesa->xm_buffer->buffer != XIMAGE) {
       swrast->Point = draw_points_ANY_pixmap;
    }
@@ -456,7 +456,7 @@ get_line_func(struct gl_context *ctx)
       return (swrast_line_func) NULL;
    if (ctx->RenderMode != GL_RENDER)      return (swrast_line_func) NULL;
    if (ctx->Line.SmoothFlag)              return (swrast_line_func) NULL;
-   if (ctx->Texture._EnabledUnits)        return (swrast_line_func) NULL;
+   if (ctx->Texture._MaxEnabledTexImageUnit != -1)        return (swrast_line_func) NULL;
    if (ctx->Light.ShadeModel != GL_FLAT)  return (swrast_line_func) NULL;
    if (ctx->Line.StippleFlag)             return (swrast_line_func) NULL;
    if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
diff --git a/src/mesa/drivers/x11/xm_tri.c b/src/mesa/drivers/x11/xm_tri.c
index aa9ffe5..e9ec676 100644
--- a/src/mesa/drivers/x11/xm_tri.c
+++ b/src/mesa/drivers/x11/xm_tri.c
@@ -1015,7 +1015,7 @@ get_triangle_func(struct gl_context *ctx)
       return (swrast_tri_func) NULL;
    if (ctx->Polygon.SmoothFlag)
       return (swrast_tri_func) NULL;
-   if (ctx->Texture._EnabledUnits)
+   if (ctx->Texture._MaxEnabledTexImageUnit != -1)
       return (swrast_tri_func) NULL;
    if (swrast->_RasterMask & MULTI_DRAW_BIT)
       return (swrast_tri_func) NULL;
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index c5583c9..bdabc3f 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -233,7 +233,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
 
    if (ctx->Texture._TexGenEnabled ||
        ctx->Texture._TexMatEnabled ||
-       ctx->Texture._EnabledUnits)
+       ctx->Texture._MaxEnabledTexImageUnit != -1)
       key->texture_enabled_global = 1;
 
    for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 6694383..31e3033 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1388,9 +1388,6 @@ struct gl_texture_attrib
    /** GL_ARB_seamless_cubemap */
    GLboolean CubeMapSeamless;
 
-   /** Texture units/samplers used by vertex or fragment texturing */
-   GLbitfield _EnabledUnits;
-
    /** Texture coord units/sets used for fragment texturing */
    GLbitfield _EnabledCoordUnits;
 
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index b68920c..36c543b 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -546,7 +546,6 @@ update_texture_state( struct gl_context *ctx )
    /* TODO: only set this if there are actual changes */
    ctx->NewState |= _NEW_TEXTURE;
 
-   ctx->Texture._EnabledUnits = 0x0;
    ctx->Texture._GenFlags = 0x0;
    ctx->Texture._TexMatEnabled = 0x0;
    ctx->Texture._TexGenEnabled = 0x0;
@@ -635,8 +634,6 @@ update_texture_state( struct gl_context *ctx )
       }
 
       /* if we get here, we know this texture unit is enabled */
-
-      ctx->Texture._EnabledUnits |= (1 << unit);
       ctx->Texture._MaxEnabledTexImageUnit = unit;
 
       if (enabledTargetsByStage[MESA_SHADER_FRAGMENT])
@@ -796,7 +793,6 @@ _mesa_init_texture(struct gl_context *ctx)
 
    /* Texture group */
    ctx->Texture.CurrentUnit = 0;      /* multitexture */
-   ctx->Texture._EnabledUnits = 0x0;
 
    /* Appendix F.2 of the OpenGL ES 3.0 spec says:
     *
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 9fe12f1..fbc9763 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -73,7 +73,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
       }
    }
    if (ctx->Color.ColorLogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
-   if (ctx->Texture._EnabledUnits)     rasterMask |= TEXTURE_BIT;
+   if (ctx->Texture._MaxEnabledTexImageUnit >= 0) rasterMask |= TEXTURE_BIT;
    if (   ctx->ViewportArray[0].X < 0
        || ctx->ViewportArray[0].X + ctx->ViewportArray[0].Width > (GLfloat) ctx->DrawBuffer->Width
        || ctx->ViewportArray[0].Y < 0
@@ -286,7 +286,7 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx)
        ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR);
 
    swrast->SpecularVertexAdd = (separateSpecular
-                                && ctx->Texture._EnabledUnits == 0x0
+                                && ctx->Texture._MaxEnabledTexImageUnit == -1
                                 && !_swrast_use_fragment_program(ctx)
                                 && !ctx->ATIFragmentShader._Enabled);
 }
diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
index c08a4e9..e2d5846 100644
--- a/src/mesa/swrast/s_texture.c
+++ b/src/mesa/swrast/s_texture.c
@@ -342,16 +342,14 @@ _swrast_unmap_texture(struct gl_context *ctx, struct gl_texture_object *texObj)
 void
 _swrast_map_textures(struct gl_context *ctx)
 {
-   GLbitfield enabledUnits = ctx->Texture._EnabledUnits;
+   int unit;
 
-   /* loop over enabled texture units */
-   while (enabledUnits) {
-      GLuint unit = ffs(enabledUnits) - 1;
-      struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
-      
-      _swrast_map_texture(ctx, texObj);
+   for (unit = 0; unit <= ctx->Texture._MaxEnabledTexImageUnit; unit++) {
+      if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+         struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
 
-      enabledUnits &= ~(1 << unit);
+         _swrast_map_texture(ctx, texObj);
+      }
    }
 }
 
@@ -362,15 +360,12 @@ _swrast_map_textures(struct gl_context *ctx)
 void
 _swrast_unmap_textures(struct gl_context *ctx)
 {
-   GLbitfield enabledUnits = ctx->Texture._EnabledUnits;
-
-   /* loop over enabled texture units */
-   while (enabledUnits) {
-      GLuint unit = ffs(enabledUnits) - 1;
-      struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
-      
-      _swrast_unmap_texture(ctx, texObj);
+   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;
 
-      enabledUnits &= ~(1 << unit);
+         _swrast_unmap_texture(ctx, texObj);
+      }
    }
 }
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 00383fb..ef02abe 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1071,7 +1071,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
          if (ctx->Texture._EnabledCoordUnits == 0x1
              && !_swrast_use_fragment_program(ctx)
              && !ctx->ATIFragmentShader._Enabled
-             && ctx->Texture._EnabledUnits == 0x1
+             && ctx->Texture._MaxEnabledTexImageUnit == 0
              && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
              && samp->WrapS == GL_REPEAT
              && samp->WrapT == GL_REPEAT
-- 
1.9.2



More information about the mesa-dev mailing list