mesa: stop passing state bitfield to UpdateState()

The code comment which seems to have been added in cab974cf6c
(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@vmware.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri
2017-06-07 12:19:13 +10:00
parent f627ac6e35
commit f77740f14b
13 changed files with 33 additions and 22 deletions

View File

@@ -52,8 +52,10 @@
/* Override intel default. /* Override intel default.
*/ */
static void 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); _swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state); _swsetup_InvalidateState(ctx, new_state);
_vbo_InvalidateState(ctx, new_state); _vbo_InvalidateState(ctx, new_state);

View File

@@ -314,8 +314,9 @@ static const struct debug_control debug_control[] = {
static void 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); struct intel_context *intel = intel_context(ctx);
if (ctx->swrast_context) if (ctx->swrast_context)

View File

@@ -187,8 +187,9 @@ intel_disable_rb_aux_buffer(struct brw_context *brw, const struct brw_bo *bo)
} }
static void 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 brw_context *brw = brw_context(ctx);
struct intel_texture_object *tex_obj; struct intel_texture_object *tex_obj;
struct intel_renderbuffer *depth_irb; struct intel_renderbuffer *depth_irb;

View File

@@ -451,8 +451,9 @@ nouveau_state_emit(struct gl_context *ctx)
} }
static void 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; int i;
if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW)) if (new_state & (_NEW_PROJECTION | _NEW_MODELVIEW))

View File

@@ -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); r200ContextPtr rmesa = R200_CONTEXT(ctx);
_swrast_InvalidateState( ctx, new_state ); _swrast_InvalidateState( ctx, new_state );

View File

@@ -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 ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );
_vbo_InvalidateState( ctx, new_state ); _vbo_InvalidateState( ctx, new_state );

View File

@@ -697,8 +697,10 @@ get_string(struct gl_context *ctx, GLenum pname)
} }
static void 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 */ /* not much to do here - pass it on */
_swrast_InvalidateState( ctx, new_state ); _swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state ); _swsetup_InvalidateState( ctx, new_state );

View File

@@ -126,6 +126,11 @@ osmesa_update_state( struct gl_context *ctx, GLuint new_state )
_vbo_InvalidateState( ctx, 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); _mesa_init_driver_functions(&functions);
/* override with our functions */ /* override with our functions */
functions.GetString = get_string; functions.GetString = get_string;
functions.UpdateState = osmesa_update_state; functions.UpdateState = osmesa_update_state_wrapper;
if (!_mesa_initialize_context(&osmesa->mesa, if (!_mesa_initialize_context(&osmesa->mesa,
api_profile, api_profile,

View File

@@ -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 * Called when the driver should update its state, based on the new_state
* flags. * flags.
*/ */
void static void
xmesa_update_state( struct gl_context *ctx, GLbitfield new_state ) xmesa_update_state(struct gl_context *ctx)
{ {
GLbitfield new_state = ctx->NewState;
const XMesaContext xmesa = XMESA_CONTEXT(ctx); const XMesaContext xmesa = XMESA_CONTEXT(ctx);
/* Propagate statechange information to swrast and swrast_setup /* Propagate statechange information to swrast and swrast_setup

View File

@@ -353,10 +353,6 @@ extern void
xmesa_init_driver_functions( XMesaVisual xmvisual, xmesa_init_driver_functions( XMesaVisual xmvisual,
struct dd_function_table *driver ); struct dd_function_table *driver );
extern void
xmesa_update_state( struct gl_context *ctx, GLbitfield new_state );
extern void extern void
xmesa_MapRenderbuffer(struct gl_context *ctx, xmesa_MapRenderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb, struct gl_renderbuffer *rb,

View File

@@ -93,7 +93,7 @@ struct dd_function_table {
* This is in addition to any state change callbacks Mesa may already have * This is in addition to any state change callbacks Mesa may already have
* made. * made.
*/ */
void (*UpdateState)( struct gl_context *ctx, GLbitfield new_state ); void (*UpdateState)(struct gl_context *ctx);
/** /**
* This is called whenever glFinish() is called. * This is called whenever glFinish() is called.

View File

@@ -415,13 +415,10 @@ _mesa_update_state_locked( struct gl_context *ctx )
* The driver might plug in different span functions, for example. * The driver might plug in different span functions, for example.
* Also, this is where the driver can invalidate the state of any * Also, this is where the driver can invalidate the state of any
* active modules (such as swrast_setup, swrast, tnl, etc). * 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->NewState = 0;
ctx->Driver.UpdateState(ctx, new_state);
ctx->Array.VAO->NewArrays = 0x0; ctx->Array.VAO->NewArrays = 0x0;
} }

View File

@@ -182,8 +182,9 @@ st_invalidate_buffers(struct st_context *st)
* Called via ctx->Driver.UpdateState() * Called via ctx->Driver.UpdateState()
*/ */
static void 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); struct st_context *st = st_context(ctx);
if (new_state & _NEW_BUFFERS) { if (new_state & _NEW_BUFFERS) {