There are three reasons left for this function flagging it: Re-computing completeness (and therefore the number of levels), binding a new current texture object, or you're doing some sort of fixed function (and nobody cares). For other cases, like rebinding a shader, we no longer trigger the driver recomputing every piece of texture state.
Improves a VS state change microbenchmark by 14.8284% +/- 1.02% (n=10) on gen7. On the other hand, it causes GPU hangs on nexuiz. Any clue why this might be insufficient? --- src/mesa/main/texstate.c | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 2dbf530..86b8b3d 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -577,7 +577,6 @@ update_texture_state( struct gl_context *ctx ) */ /* TODO: only set this if there are actual changes */ - ctx->NewState |= _NEW_TEXTURE; /* * Update texture unit state. @@ -588,6 +587,7 @@ update_texture_state( struct gl_context *ctx ) GLbitfield enabledFragTargets = 0x0; GLbitfield enabledTargets = 0x0; GLuint texIndex; + struct gl_texture_object *oldObj = texUnit->_Current; /* Get the bitmask of texture target enables. * enableBits will be a mask of the TEXTURE_*_BIT flags indicating @@ -609,10 +609,18 @@ update_texture_state( struct gl_context *ctx ) enabledTargets = enabledVertTargets | enabledFragTargets; + /* This is not flagged with _NEW_TEXTURE, because the test for changing of + * the _Current texture object will cover every case where _ReallyEnabled + * could have changed. + */ texUnit->_ReallyEnabled = 0x0; if (enabledTargets == 0x0) { /* neither vertex nor fragment processing uses this unit */ + if (texUnit->_ReallyEnabled) { + ctx->NewState |= _NEW_TEXTURE; + texUnit->_ReallyEnabled = 0x0; + } continue; } @@ -626,6 +634,10 @@ update_texture_state( struct gl_context *ctx ) if (enabledTargets & (1 << texIndex)) { struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; if (!texObj->_Complete) { + /* While _Complete is only consumed by us, this call also updates + _MaxLevel, which drivers do need to see. + */ + ctx->NewState |= _NEW_TEXTURE; _mesa_test_texobj_completeness(ctx, texObj); } if (texObj->_Complete) { @@ -652,22 +664,26 @@ update_texture_state( struct gl_context *ctx ) _mesa_reference_texobj(&texUnit->_Current, texObj); texUnit->_ReallyEnabled = 1 << texTarget; } - else { - /* fixed-function: texture unit is really disabled */ - continue; - } } + + if (oldObj != texUnit->_Current) + ctx->NewState |= _NEW_TEXTURE; } /* Determine which texture coordinate sets are actually needed */ if (fprog) { const GLuint coordMask = (1 << MAX_TEXTURE_COORD_UNITS) - 1; + GLuint new_coord_units = ((fprog->InputsRead >> FRAG_ATTRIB_TEX0) & + coordMask); /* Note that this gets consumed by update_ffvs_texture_state(). */ - ctx->Texture._EnabledCoordUnits - = (fprog->InputsRead >> FRAG_ATTRIB_TEX0) & coordMask; + if (ctx->Texture._EnabledCoordUnits != new_coord_units) { + ctx->NewState |= _NEW_TEXTURE; + ctx->Texture._EnabledCoordUnits = new_coord_units; + } } else { + ctx->NewState |= _NEW_TEXTURE; update_fffs_texture_state(ctx); } @@ -675,8 +691,10 @@ update_texture_state( struct gl_context *ctx ) * program. Those state flags are only used in the case of fixed function * vertex shading, in the tnl pipeline or ff_vertex_shader. */ - if (!vprog) + if (!vprog) { + ctx->NewState |= _NEW_TEXTURE; update_ffvs_texture_state(ctx); + } } -- 1.7.9 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev