mesa: short-cut new_state == _NEW_LINE in _mesa_update_state_locked()
authorBrian Paul <brianp@vmware.com>
Wed, 14 Oct 2015 15:10:19 +0000 (09:10 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 15 Oct 2015 13:21:07 +0000 (07:21 -0600)
We can skip to the end of _mesa_update_state_locked() if only the
_NEW_LINE flag is set since none of the derived state depends on it
(just like _NEW_CURRENT_ATTRIB).  Note that we still call the
ctx->Driver.UpdateState() function, of course.

v2: use bitmask-based test, per Eric.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/state.c

index d3b1c72b08d94307636ae4d207aedaa5e8b7f726..4043c4f20576600a63746fe4bf2a9f0a2bbf55ed 100644 (file)
@@ -391,8 +391,12 @@ _mesa_update_state_locked( struct gl_context *ctx )
    GLbitfield new_state = ctx->NewState;
    GLbitfield prog_flags = _NEW_PROGRAM;
    GLbitfield new_prog_state = 0x0;
+   const GLbitfield computed_states = ~(_NEW_CURRENT_ATTRIB | _NEW_LINE);
 
-   if (new_state == _NEW_CURRENT_ATTRIB) 
+   /* we can skip a bunch of state validation checks if the dirty
+    * state matches one or more bits in 'computed_states'.
+    */
+   if ((new_state & computed_states) == 0)
       goto out;
 
    if (MESA_VERBOSE & VERBOSE_STATE)