Mesa (master): mesa: stop passing state bitfield to UpdateState()

Timothy Arceri tarceri at kemper.freedesktop.org
Thu Jun 8 23:14:02 UTC 2017


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

Author: Timothy Arceri <tarceri at itsqueeze.com>
Date:   Wed Jun  7 12:19:13 2017 +1000

mesa: stop passing state bitfield to UpdateState()

The code comment which seems to have been added in cab974cf6c2db
(from year 2000) says:

   "Set ctx->NewState to zero to avoid recursion if
   Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)"

As far as I can tell nothing in any of the UpdateState() calls
should cause it to be called recursively.

V2: add a wrapper around the osmesa update function so it can still
    be used internally.

Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/mesa/drivers/dri/i915/i915_context.c     | 4 +++-
 src/mesa/drivers/dri/i915/intel_context.c    | 3 ++-
 src/mesa/drivers/dri/i965/brw_context.c      | 3 ++-
 src/mesa/drivers/dri/nouveau/nouveau_state.c | 3 ++-
 src/mesa/drivers/dri/r200/r200_state.c       | 4 +++-
 src/mesa/drivers/dri/radeon/radeon_state.c   | 4 +++-
 src/mesa/drivers/dri/swrast/swrast.c         | 4 +++-
 src/mesa/drivers/osmesa/osmesa.c             | 9 +++++++--
 src/mesa/drivers/x11/xm_dd.c                 | 5 +++--
 src/mesa/drivers/x11/xmesaP.h                | 4 ----
 src/mesa/main/dd.h                           | 2 +-
 src/mesa/main/state.c                        | 7 ++-----
 src/mesa/state_tracker/st_context.c          | 3 ++-
 13 files changed, 33 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c
index 6c4882378f..1406b65b65 100644
--- a/src/mesa/drivers/dri/i915/i915_context.c
+++ b/src/mesa/drivers/dri/i915/i915_context.c
@@ -52,8 +52,10 @@
 /* Override intel default.
  */
 static void
-i915InvalidateState(struct gl_context * ctx, GLuint new_state)
+i915InvalidateState(struct gl_context * ctx)
 {
+   GLuint new_state = ctx->NewState;
+
    _swrast_InvalidateState(ctx, new_state);
    _swsetup_InvalidateState(ctx, new_state);
    _vbo_InvalidateState(ctx, new_state);
diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
index 5607d5b5b6..6c59b425a9 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -314,8 +314,9 @@ static const struct debug_control debug_control[] = {
 
 
 static void
-intelInvalidateState(struct gl_context * ctx, GLuint new_state)
+intelInvalidateState(struct gl_context * ctx)
 {
+   GLuint new_state = ctx->NewState;
     struct intel_context *intel = intel_context(ctx);
 
     if (ctx->swrast_context)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 92490f728f..81166450b9 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -187,8 +187,9 @@ intel_disable_rb_aux_buffer(struct brw_context *brw, const struct brw_bo *bo)
 }
 
 static void
-intel_update_state(struct gl_context * ctx, GLuint new_state)
+intel_update_state(struct gl_context * ctx)
 {
+   GLuint new_state = ctx->NewState;
    struct brw_context *brw = brw_context(ctx);
    struct intel_texture_object *tex_obj;
    struct intel_renderbuffer *depth_irb;
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c
index de36fa41b5..567f32fa43 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_state.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c
@@ -451,8 +451,9 @@ nouveau_state_emit(struct gl_context *ctx)
 }
 
 static void
-nouveau_update_state(struct gl_context *ctx, GLbitfield new_state)
+nouveau_update_state(struct gl_context *ctx)
 {
+	GLbitfield new_state = ctx->NewState;
 	int i;
 
 	if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index 9fb15f2490..d5a6f09174 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -2276,8 +2276,10 @@ GLboolean r200ValidateState( struct gl_context *ctx )
 }
 
 
-static void r200InvalidateState( struct gl_context *ctx, GLuint new_state )
+static void r200InvalidateState(struct gl_context *ctx)
 {
+   GLuint new_state = ctx->NewState;
+
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
 
    _swrast_InvalidateState( ctx, new_state );
diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
index 1baf229e64..ff2a7089dd 100644
--- a/src/mesa/drivers/dri/radeon/radeon_state.c
+++ b/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -2044,8 +2044,10 @@ GLboolean radeonValidateState( struct gl_context *ctx )
 }
 
 
-static void radeonInvalidateState( struct gl_context *ctx, GLuint new_state )
+static void radeonInvalidateState(struct gl_context *ctx)
 {
+   GLuint new_state = ctx->NewState;
+
    _swrast_InvalidateState( ctx, new_state );
    _swsetup_InvalidateState( ctx, new_state );
    _vbo_InvalidateState( ctx, new_state );
diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c
index de1fe4c918..a68f7a0b96 100644
--- a/src/mesa/drivers/dri/swrast/swrast.c
+++ b/src/mesa/drivers/dri/swrast/swrast.c
@@ -697,8 +697,10 @@ get_string(struct gl_context *ctx, GLenum pname)
 }
 
 static void
-update_state( struct gl_context *ctx, GLuint new_state )
+update_state(struct gl_context *ctx)
 {
+    GLuint new_state = ctx->NewState;
+
     /* not much to do here - pass it on */
     _swrast_InvalidateState( ctx, new_state );
     _swsetup_InvalidateState( ctx, new_state );
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index a3d4facdea..ed69353743 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -117,7 +117,7 @@ get_string( struct gl_context *ctx, GLenum name )
 
 
 static void
-osmesa_update_state( struct gl_context *ctx, GLuint new_state )
+osmesa_update_state(struct gl_context *ctx, GLuint new_state)
 {
    /* easy - just propogate */
    _swrast_InvalidateState( ctx, new_state );
@@ -126,6 +126,11 @@ osmesa_update_state( struct gl_context *ctx, GLuint new_state )
    _vbo_InvalidateState( ctx, new_state );
 }
 
+static void
+osmesa_update_state_wrapper(struct gl_context *ctx)
+{
+   osmesa_update_state(ctx, ctx->NewState);
+}
 
 
 /**
@@ -828,7 +833,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
       _mesa_init_driver_functions(&functions);
       /* override with our functions */
       functions.GetString = get_string;
-      functions.UpdateState = osmesa_update_state;
+      functions.UpdateState = osmesa_update_state_wrapper;
 
       if (!_mesa_initialize_context(&osmesa->mesa,
                                     api_profile,
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index cd5809e070..e06831ca77 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -678,9 +678,10 @@ enable( struct gl_context *ctx, GLenum pname, GLboolean state )
  * Called when the driver should update its state, based on the new_state
  * flags.
  */
-void
-xmesa_update_state( struct gl_context *ctx, GLbitfield new_state )
+static void
+xmesa_update_state(struct gl_context *ctx)
 {
+   GLbitfield new_state = ctx->NewState;
    const XMesaContext xmesa = XMESA_CONTEXT(ctx);
 
    /* Propagate statechange information to swrast and swrast_setup
diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
index 9320442f46..ff3ddc4ddd 100644
--- a/src/mesa/drivers/x11/xmesaP.h
+++ b/src/mesa/drivers/x11/xmesaP.h
@@ -354,10 +354,6 @@ xmesa_init_driver_functions( XMesaVisual xmvisual,
                              struct dd_function_table *driver );
 
 extern void
-xmesa_update_state( struct gl_context *ctx, GLbitfield new_state );
-
-
-extern void
 xmesa_MapRenderbuffer(struct gl_context *ctx,
                       struct gl_renderbuffer *rb,
                       GLuint x, GLuint y, GLuint w, GLuint h,
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 3f3102546d..0b262d0b46 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -93,7 +93,7 @@ struct dd_function_table {
     * This is in addition to any state change callbacks Mesa may already have
     * made.
     */
-   void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state );
+   void (*UpdateState)(struct gl_context *ctx);
 
    /**
     * This is called whenever glFinish() is called.
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index d534f554ba..04dafa983c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -415,13 +415,10 @@ _mesa_update_state_locked( struct gl_context *ctx )
     * The driver might plug in different span functions, for example.
     * Also, this is where the driver can invalidate the state of any
     * active modules (such as swrast_setup, swrast, tnl, etc).
-    *
-    * Set ctx->NewState to zero to avoid recursion if
-    * Driver.UpdateState() has to call FLUSH_VERTICES().  (fixed?)
     */
-   new_state = ctx->NewState | new_prog_state;
+   ctx->NewState |= new_prog_state;
+   ctx->Driver.UpdateState(ctx);
    ctx->NewState = 0;
-   ctx->Driver.UpdateState(ctx, new_state);
    ctx->Array.VAO->NewArrays = 0x0;
 }
 
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 33bc16713c..0e768ea9e4 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -182,8 +182,9 @@ st_invalidate_buffers(struct st_context *st)
  * Called via ctx->Driver.UpdateState()
  */
 static void
-st_invalidate_state(struct gl_context * ctx, GLbitfield new_state)
+st_invalidate_state(struct gl_context * ctx)
 {
+   GLbitfield new_state = ctx->NewState;
    struct st_context *st = st_context(ctx);
 
    if (new_state & _NEW_BUFFERS) {




More information about the mesa-commit mailing list