[PATCH] xserver/glx/dri2: use new GLX/DRI2 swap event types
Jeremy Huddleston
jeremyhu at apple.com
Fri May 6 13:00:19 PDT 2011
Yeah, that looks about right.
This in combination with the latest version of "xserver/glx/dri2: use new GLX/DRI2 swap event types"
Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
On May 6, 2011, at 10:39, Jesse Barnes wrote:
> On Fri, 06 May 2011 09:25:35 +0200
> Michel Dänzer <michel at daenzer.net> wrote:
>
>> On Don, 2011-05-05 at 14:02 -0700, Jesse Barnes wrote:
>>>>> if (swap_complete) {
>>>>> if (pPriv->swap_count > 0xffffffff)
>>>>> ErrorF("something appropriate");
>>>>> swap_complete(client, swap_data, type, ust, frame, (CARD32)pPriv->swap_count);
>>>>> }
>>>>
>>>> Yeah, it's annoying. How about I leave out the error message and handle
>>>> wrapping on the client side instead? That way at least the client code
>>>> won't notice that the server is only transmitting 32 bits...
>>>
>>> Nevermind, that can't work generally since clients are free to
>>> mask/unmask the events, so we could miss a 0 count and thus a wrap.
>>
>> Missing 0 isn't a problem, you can assume there's been a wraparound
>> whenever the current value is smaller than the previous one. This would
>> only fail if the client misses several wraparounds, in which case
>> apparently it doesn't care all that much in the first place. :)
>>
>> Please do this.
>
> How does this look for the direct case? The indirect case is a little
> more complicated since I need to add a new glx_drawable type and track
> it (Kristian says this should help clean up some of the Apple mess as
> well). This patch handles at least one wrap correctly (I set the
> server's starting swap_count at 0xfffffff0 and then ran the
> glx-swap-event test in piglit; wrapping worked ok).
>
> --
> Jesse Barnes, Intel Open Source Technology Center
>
> From f1e288f61e10b71018600a24ca0bdda93f8481db Mon Sep 17 00:00:00 2001
> From: Jesse Barnes <jbarnes at virtuousgeek.org>
> Date: Fri, 6 May 2011 10:31:24 -0700
> Subject: [PATCH] DRI2: handle swap event swap count wrapping
>
> Add a wrap counter to the DRI drawable and track it as we receive events.
> This allows us to support the full 64 bits of the event structure we
> pass to the client even though the server only gives us a 32 bit count.
>
> Signed-off-by: Jesse Barnes <jbarnes at virtuousgeek.org>
> ---
> src/glx/dri2.c | 12 +++++++++++-
> src/glx/dri2_glx.c | 2 ++
> src/glx/glxclient.h | 2 ++
> 3 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/src/glx/dri2.c b/src/glx/dri2.c
> index 8654a37..08ceec0 100644
> --- a/src/glx/dri2.c
> +++ b/src/glx/dri2.c
> @@ -88,6 +88,7 @@ static Bool
> DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
> {
> XExtDisplayInfo *info = DRI2FindDisplay(dpy);
> + __GLXDRIdrawable *pdraw;
>
> XextCheckExtension(dpy, info, dri2ExtensionName, False);
>
> @@ -124,7 +125,16 @@ DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire)
> }
> aevent->ust = ((CARD64)awire->ust_hi << 32) | awire->ust_lo;
> aevent->msc = ((CARD64)awire->msc_hi << 32) | awire->msc_lo;
> - aevent->sbc = awire->sbc;
> +
> + pdraw = dri2GetGlxDrawableFromXDrawableId(dpy, awire->drawable);
> + if (!pdraw)
> + return False;
> +
> + if (awire->sbc < pdraw->lastEventSbc)
> + pdraw->eventSbcWrap += 0x100000000;
> + pdraw->lastEventSbc = awire->sbc;
> + aevent->sbc = awire->sbc + pdraw->eventSbcWrap;
> +
> return True;
> }
> #endif
> diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
> index fc0237a..421f543 100644
> --- a/src/glx/dri2_glx.c
> +++ b/src/glx/dri2_glx.c
> @@ -258,6 +258,8 @@ dri2CreateDrawable(struct glx_screen *base, XID xDrawable,
> pdraw->base.xDrawable = xDrawable;
> pdraw->base.drawable = drawable;
> pdraw->base.psc = &psc->base;
> + pdraw->base.lastEventSbc = 0;
> + pdraw->base.eventSbcWrap = 0;
> pdraw->bufferCount = 0;
> pdraw->swap_interval = 1; /* default may be overridden below */
> pdraw->have_back = 0;
> diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h
> index 2b6966f..1eb2483 100644
> --- a/src/glx/glxclient.h
> +++ b/src/glx/glxclient.h
> @@ -138,6 +138,8 @@ struct __GLXDRIdrawableRec
> GLenum textureTarget;
> GLenum textureFormat; /* EXT_texture_from_pixmap support */
> unsigned long eventMask;
> + uint32_t lastEventSbc;
> + int64_t eventSbcWrap;
> };
>
> /*
> --
> 1.7.4.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>
More information about the xorg-devel
mailing list