[Intel-gfx] [PATCH] mesa/intel: add DRI2 swapbuffers interface

Kristian Høgsberg krh at bitplanet.net
Fri Feb 27 21:34:26 CET 2009


On Fri, Feb 27, 2009 at 2:22 PM, Jesse Barnes <jbarnes at virtuousgeek.org> wrote:
> On Thursday, February 26, 2009 1:31:03 pm Jesse Barnes wrote:
>> Add support to Mesa and the intel driver for the new DRI2 swapbuffers
>> interface.  Uses the new flush hook to make sure any outstanding rendering
>> is complete before sending the swapbuffers request.
>
> Need to update the FBconfigs too; we now support the exchange method.
>
> --
> Jesse Barnes, Intel Open Source Technology Center
>
> diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
> index a726b93..b663028 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -681,6 +681,9 @@ struct __DRIdri2ExtensionRec {
>                                      __DRIcontext *shared,
>                                      void *loaderPrivate);
>
> +    void (*setBuffers)(__DRIdrawable *drawable,
> +                      __DRIbuffer *buffers,
> +                      int count);
>  };

We don't need setBuffers, we can just require the flush extension.
When the flush entry point is called, mark the buffers as invalid
which will cause the dri driver to call getBuffers() before doing any
further rendering.

> @@ -223,8 +226,40 @@ static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw,
>  static void dri2SwapBuffers(__GLXDRIdrawable *pdraw)
>  {
>     __GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
> +    __GLXdisplayPrivate *dpyPriv = __glXInitialize(priv->base.psc->dpy);
> +    __GLXDRIdisplayPrivate *pdp =
> +       (__GLXDRIdisplayPrivate *)dpyPriv->dri2Display;
> +    __GLXscreenConfigs *psc = pdraw->psc;
> +    DRI2Buffer *buffers;
> +    int i, count;
> +
> +#ifdef __DRI2_FLUSH
> +    if (pdraw->psc->f)
> +       (*pdraw->psc->f->flush)(pdraw->driDrawable);
> +#endif
> +
> +    /* Old servers can't handle swapbuffers */
> +    if (!pdp->swapAvailable)
> +       return dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
> +
> +    buffers = DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable, &count);
> +    if (buffers == NULL || !count)
> +       return dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);

As for the AIGLX case, DRI2SwapBuffers should swap the buffers or
fallback to CopyRegion in the server.  This requires an extra round
trip in the fallback case and we have implement the fallback logic
everywhere we use DRI2SwapBuffers instead of just once in the server.

cheers,
Kristian



More information about the Intel-gfx mailing list