[Mesa-dev] [PATCH 6/8] intel: Don't flush the old context in intelMakeCurrent

Ian Romanick idr at freedesktop.org
Thu Oct 16 08:41:25 PDT 2014


On 10/01/2014 12:00 PM, Neil Roberts wrote:
> It shouldn't be necessary to flush the context within the driver
> implementation because the old context is explicitly flushed in
> _mesa_make_current before the driver code is reached. It is useful to only
> have a single place that flushes the context when switching contexts to make
> it easier to later implement the GL_KHR_context_flush_control extension.

I'm a little bit skeptical of this.  _mesa_make_current doesn't call
intelMakeCurrent.  intelMakeCurrent calls _mesa_make_current, and it
calls _mesa_make_current much later in this function.  By the time
_mesa_make_current is called, a bunch of driver state has been
changed... and I bet the later call to _mesa_flush will do bad things.

This also seems like a really tough bug to trigger. :(

> ---
>  src/mesa/drivers/dri/i915/intel_context.c | 9 ---------
>  src/mesa/drivers/dri/i965/brw_context.c   | 9 ---------
>  2 files changed, 18 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i915/intel_context.c b/src/mesa/drivers/dri/i915/intel_context.c
> index 3104776..c70bd25 100644
> --- a/src/mesa/drivers/dri/i915/intel_context.c
> +++ b/src/mesa/drivers/dri/i915/intel_context.c
> @@ -622,21 +622,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
>                   __DRIdrawable * driReadPriv)
>  {
>     struct intel_context *intel;
> -   GET_CURRENT_CONTEXT(curCtx);
>  
>     if (driContextPriv)
>        intel = (struct intel_context *) driContextPriv->driverPrivate;
>     else
>        intel = NULL;
>  
> -   /* According to the glXMakeCurrent() man page: "Pending commands to
> -    * the previous context, if any, are flushed before it is released."
> -    * But only flush if we're actually changing contexts.
> -    */
> -   if (intel_context(curCtx) && intel_context(curCtx) != intel) {
> -      _mesa_flush(curCtx);
> -   }
> -
>     if (driContextPriv) {
>        struct gl_context *ctx = &intel->ctx;
>        struct gl_framebuffer *fb, *readFb;
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index d78ae56..f9b2e9b 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -972,21 +972,12 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
>                   __DRIdrawable * driReadPriv)
>  {
>     struct brw_context *brw;
> -   GET_CURRENT_CONTEXT(curCtx);
>  
>     if (driContextPriv)
>        brw = (struct brw_context *) driContextPriv->driverPrivate;
>     else
>        brw = NULL;
>  
> -   /* According to the glXMakeCurrent() man page: "Pending commands to
> -    * the previous context, if any, are flushed before it is released."
> -    * But only flush if we're actually changing contexts.
> -    */
> -   if (brw_context(curCtx) && brw_context(curCtx) != brw) {
> -      _mesa_flush(curCtx);
> -   }
> -
>     if (driContextPriv) {
>        struct gl_context *ctx = &brw->ctx;
>        struct gl_framebuffer *fb, *readFb;
> 



More information about the mesa-dev mailing list