[Mesa-dev] [PATCH 3/3] mesa: Skip updating texgen when not doing fixed function.

Eric Anholt eric at anholt.net
Fri Jan 11 20:57:41 PST 2013


Between the previous commit and this one, improves GLBenchmark 2.1
offscreen performance by 0.48% +/- 0.24% (n=22, throttling outliers
removed).
---
 src/mesa/main/texstate.c |   70 ++++++++++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index a2541fc..87b26ae 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -480,6 +480,43 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
    }
 }
 
+static void
+update_texgen(struct gl_context *ctx)
+{
+   GLuint unit;
+
+   /* 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];
+
+      texUnit->_GenFlags = 0x0;
+
+      if (!(ctx->Texture._EnabledCoordUnits & (1 << unit)))
+	 continue;
+
+      if (texUnit->TexGenEnabled) {
+	 if (texUnit->TexGenEnabled & S_BIT) {
+	    texUnit->_GenFlags |= texUnit->GenS._ModeBit;
+	 }
+	 if (texUnit->TexGenEnabled & T_BIT) {
+	    texUnit->_GenFlags |= texUnit->GenT._ModeBit;
+	 }
+	 if (texUnit->TexGenEnabled & R_BIT) {
+	    texUnit->_GenFlags |= texUnit->GenR._ModeBit;
+	 }
+	 if (texUnit->TexGenEnabled & Q_BIT) {
+	    texUnit->_GenFlags |= texUnit->GenQ._ModeBit;
+	 }
+
+	 ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit);
+	 ctx->Texture._GenFlags |= texUnit->_GenFlags;
+      }
+
+      ASSERT(unit < Elements(ctx->TextureMatrixStack));
+      if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
+	 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
+   }
+}
 
 /**
  * \note This routine refers to derived texture matrix values to
@@ -633,37 +670,8 @@ update_texture_state( struct gl_context *ctx )
       ctx->Texture._EnabledCoordUnits = enabledFragUnits;
    }
 
-   /* 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];
-
-      texUnit->_GenFlags = 0x0;
-
-      if (!(ctx->Texture._EnabledCoordUnits & (1 << unit)))
-	 continue;
-
-      if (texUnit->TexGenEnabled) {
-	 if (texUnit->TexGenEnabled & S_BIT) {
-	    texUnit->_GenFlags |= texUnit->GenS._ModeBit;
-	 }
-	 if (texUnit->TexGenEnabled & T_BIT) {
-	    texUnit->_GenFlags |= texUnit->GenT._ModeBit;
-	 }
-	 if (texUnit->TexGenEnabled & R_BIT) {
-	    texUnit->_GenFlags |= texUnit->GenR._ModeBit;
-	 }
-	 if (texUnit->TexGenEnabled & Q_BIT) {
-	    texUnit->_GenFlags |= texUnit->GenQ._ModeBit;
-	 }
-
-	 ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit);
-	 ctx->Texture._GenFlags |= texUnit->_GenFlags;
-      }
-
-      ASSERT(unit < Elements(ctx->TextureMatrixStack));
-      if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
-	 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
-   }
+   if (!fprog || !vprog)
+      update_texgen(ctx);
 }
 
 
-- 
1.7.10.4



More information about the mesa-dev mailing list