diff options
author | Brian Paul <[email protected]> | 2009-02-28 17:40:41 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2009-03-02 09:44:32 -0700 |
commit | 000c3438c96c5b8f16969c1bcbcce1b6a6321ec9 (patch) | |
tree | e97558d1029251d32fafbe4aa4baa65f0d424d2e /src/mesa/main/texstate.c | |
parent | ebabdf9920c1628741703704796a9361c1fc07bf (diff) |
mesa: move texture_override() code into calling loop
We can avoid a few iterations this way.
Diffstat (limited to 'src/mesa/main/texstate.c')
-rw-r--r-- | 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 aded1270928..5ac85793105 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) |