[Mesa-dev] [PATCH] i965: fix MakeCurrent when switching a context between multiple drawables.

Ian Romanick idr at freedesktop.org
Thu Apr 3 13:46:15 PDT 2014


Kristian: You had some thoughts on this.  Could you share them with the
list? :)

On 03/27/2014 01:47 AM, Iago Toral Quiroga wrote:
> Commit 11baad35088dfd4bdabc1710df650dbfb413e7a3 produces a regression when
> switching a single context between multiple drawables.
> 
> The problem is that we check whether we have a viewport set to decide if we
> need to generate buffers for the drawble, but the viewport is initialized
> with the first call to MakeCurrent for that context, so calling MakeCurrent on
> the same context with a different drawable will have the viewport already
> initialized and will not generate buffers for the new drawable.
> 
> This patch fixes the problem by reverting to the previous solution implemented
> in commit 05da4a7a5e7d5bd988cb31f94ed8e1f053d9ee39 with a small fix to suppport
> single buffer drawables too. This solution checks if we have a renderbuffer for
> the drawable to decide if we need to generate a buffer or not. The original
> implementation, however, did this by checking the BACK_LEFT buffer, which is
> not a valid solution for single buffer drawables. This patch modifies this
> to check the FRONT_LEFT buffer instead, which should work in both scenarios.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=74005
> ---
>  src/mesa/drivers/dri/i965/brw_context.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index c9719f5..c593286 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -926,6 +926,7 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
>  {
>     struct brw_context *brw;
>     GET_CURRENT_CONTEXT(curCtx);
> +   struct intel_renderbuffer *rb = NULL;
>  
>     if (driContextPriv)
>        brw = (struct brw_context *) driContextPriv->driverPrivate;
> @@ -950,6 +951,7 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
>        } else {
>           fb = driDrawPriv->driverPrivate;
>           readFb = driReadPriv->driverPrivate;
> +         rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
>           driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
>           driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
>        }
> @@ -961,10 +963,9 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
>        intel_gles3_srgb_workaround(brw, fb);
>        intel_gles3_srgb_workaround(brw, readFb);
>  
> -      /* If the context viewport hasn't been initialized, force a call out to
> -       * the loader to get buffers so we have a drawable size for the initial
> -       * viewport. */
> -      if (!brw->ctx.ViewportInitialized)
> +      /* If we don't have buffers for the drawable yet, force a call to
> +       * getbuffers here so we can have a default drawable size. */
> +      if (rb && !rb->mt)
>           intel_prepare_render(brw);
>  
>        _mesa_make_current(ctx, fb, readFb);
> 



More information about the mesa-dev mailing list