[Mesa-dev] [Mesa-stable] [PATCH 5/5] glx: Handle out-of-sequence swap completion events correctly.

Emil Velikov emil.l.velikov at gmail.com
Sun Dec 14 07:15:25 PST 2014


Hi Mario,

I've picked up patches 1-4 in master and will land them in the stable
branches shortly.

Gents,
Can anyone spare some time and take a look at this patch.
If you're planning to look into it in a few days/a week from now, kindly
let me know so that I can keep the annoyance to a minimum :)

Thanks
Emil

On 05/12/14 07:42, Mario Kleiner wrote:
> The code for emitting INTEL_swap_events swap completion
> events needs to translate from 32-Bit sbc on the wire to
> 64-Bit sbc for the events and handle wraparound accordingly.
> 
> It assumed that events would be sent by the server in the
> order their corresponding swap requests were emitted from
> the client, iow. sbc count should be always increasing. This
> was correct for DRI2.
> 
> This is not always the case under the DRI3/Present backend,
> where the Present extension can execute swaps and send out
> completion events in a different order than the submission
> order of the present requests. This confused the wraparound
> handling. This patch fixes the problem by handling 32-Bit
> wraparound in both directions. As long as successive swap
> completion events real 64-Bit sbc's don't differ by more
> than 2^30, this should be able to do the right thing.
> 
> Cc: "10.3 10.4" <mesa-stable at lists.freedesktop.org>
> Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
> ---
>  src/glx/glxext.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/glx/glxext.c b/src/glx/glxext.c
> index 68c359e..fdc24d4 100644
> --- a/src/glx/glxext.c
> +++ b/src/glx/glxext.c
> @@ -143,8 +143,13 @@ __glXWireToEvent(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;
>  
> -      if (awire->sbc < glxDraw->lastEventSbc)
> -	 glxDraw->eventSbcWrap += 0x100000000;
> +      /* Handle 32-Bit wire sbc wraparound in both directions to cope with out
> +       * of sequence 64-Bit sbc's
> +       */
> +      if ((int64_t) awire->sbc < ((int64_t) glxDraw->lastEventSbc - 0x40000000))
> +         glxDraw->eventSbcWrap += 0x100000000;
> +      if ((int64_t) awire->sbc > ((int64_t) glxDraw->lastEventSbc + 0x40000000))
> +         glxDraw->eventSbcWrap -= 0x100000000;
>        glxDraw->lastEventSbc = awire->sbc;
>        aevent->sbc = awire->sbc + glxDraw->eventSbcWrap;
>        return True;
> 



More information about the mesa-dev mailing list