Mesa (master): mesa: move texture_override() code into calling loop

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 2 16:45:22 UTC 2009


Module: Mesa
Branch: master
Commit: 000c3438c96c5b8f16969c1bcbcce1b6a6321ec9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=000c3438c96c5b8f16969c1bcbcce1b6a6321ec9

Author: Brian Paul <brianp at vmware.com>
Date:   Sat Feb 28 17:40:41 2009 -0700

mesa: move texture_override() code into calling loop

We can avoid a few iterations this way.

---

 src/mesa/main/texstate.c |   49 +++++++++++++++++----------------------------
 1 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index aded127..5ac8579 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -385,27 +385,6 @@ update_texture_compare_function(GLcontext *ctx,
 
 
 /**
- * Helper function for determining which texture object (1D, 2D, cube, etc)
- * should actually be used.
- */
-static void
-texture_override(GLcontext *ctx,
-                 struct gl_texture_unit *texUnit, GLbitfield enableBits,
-                 struct gl_texture_object *texObj, GLuint textureBit)
-{
-   if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) {
-      if (!texObj->_Complete) {
-         _mesa_test_texobj_completeness(ctx, texObj);
-      }
-      if (texObj->_Complete) {
-         texUnit->_ReallyEnabled = textureBit;
-         texUnit->_Current = texObj;
-      }
-   }
-}
-
-
-/**
  * Examine texture unit's combine/env state to update derived state.
  */
 static void
@@ -547,14 +526,11 @@ update_texture_state( GLcontext *ctx )
       GLbitfield enableBits;
       GLuint texIndex;
 
-      texUnit->_Current = NULL;
-      texUnit->_ReallyEnabled = 0x0;
-
       /* Get the bitmask of texture target enables.
        * enableBits will be a mask of the TEXTURE_*_BIT flags indicating
        * which texture targets are enabled (fixed function) or referenced
        * by a fragment shader/program.  When multiple flags are set, we'll
-       * settle on the one with highest priority (see texture_override below).
+       * settle on the one with highest priority (see below).
        */
       enableBits = 0x0;
       if (vprog) {
@@ -571,14 +547,27 @@ update_texture_state( GLcontext *ctx )
       if (enableBits == 0x0)
          continue;
 
-      /* Look for the highest-priority texture target that's enabled and
-       * complete.  That's the one we'll use for texturing.  If we're using
-       * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
+      texUnit->_Current = NULL;
+      texUnit->_ReallyEnabled = 0x0;
+
+      /* Look for the highest priority texture target that's enabled (or used
+       * by the vert/frag shaders) and "complete".  That's the one we'll use
+       * for texturing.  If we're using vert/frag program we're guaranteed
+       * that bitcount(enabledBits) <= 1.
        * Note that the TEXTURE_x_INDEX values are in high to low priority.
        */
       for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) {
-         texture_override(ctx, texUnit, enableBits,
-                          texUnit->CurrentTex[texIndex], 1 << texIndex);
+         if (enableBits & (1 << texIndex)) {
+            struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
+            if (!texObj->_Complete) {
+               _mesa_test_texobj_completeness(ctx, texObj);
+            }
+            if (texObj->_Complete) {
+               texUnit->_ReallyEnabled = 1 << texIndex;
+               texUnit->_Current = texObj;
+               break;
+            }
+         }
       }
 
       if (texUnit->_Current)




More information about the mesa-commit mailing list