[Intel-gfx] [PATCH] mesa/intel: add DRI2 swapbuffers interface
Jesse Barnes
jbarnes at virtuousgeek.org
Mon Apr 13 22:58:57 CEST 2009
On Fri, 27 Feb 2009 15:34:26 -0500
Kristian Høgsberg <krh at bitplanet.net> wrote:
> 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.
Finally getting back to this...
So if we drop setBuffers, it means we need a way of invalidating the
current set of drawables in a reliable way. The closest thing we have
today with DRI2 is the Viewport hook: it will update the renderbuffers
down in the driver so we could call it at swapbuffers time after the
swap. However it won't work without server changes since the server
will short circuit getbuffers requests without size changes...
Also, ->flush doesn't seem like the right place to invalidate things,
since we need to flush before the swap, and only update/invalidate the
buffers after it completes. So I'm not sure how best to handle this.
Given that the fake front buffer discussion has opened up a can of
worms in this area, I expect changes here anyway...
>
> > @@ -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.
I wanted to support old servers here; if the server doesn't support
swapping we shouldn't even try the call (since as you say it would
incur an extra round trip for nothing).
In the server side, yes I agree if we get a request we can't swap we
should just copy internally and not have the client send a new
request. I think that's how things are handled with this set...
--
Jesse Barnes, Intel Open Source Technology Center
More information about the Intel-gfx
mailing list