[PATCH] Flush the wl_display at the end of SwapBuffers

Giulio Camuffo giuliocamuffo at gmail.com
Wed Dec 4 06:44:57 PST 2013


2013/12/4 Neil Roberts <neil at linux.intel.com>:
> I think this is a good idea. Imagine a simple game main loop like this:
>
> while (TRUE) {
>         do_some_game_logic();
>         redraw();
>         eglSwapBuffers();
> }
>
> In that case it wouldn't flush the commit until the right at the
> beginning of each call to eglSwapBuffers when it waits for the frame
> callback. Then it would have to block waiting for the compositor to
> finish rendering before it receives the frame callback. If we dispatch
> after the swap buffers then in this case the compositor could start
> rendering while the game is in do_some_game_logic().
>
> There was a similar patch proposed on the Mesa-dev mailing list here:
>
> http://lists.freedesktop.org/archives/mesa-dev/2013-August/043697.html
>
> That also points out the additional problem case where the rendering is
> done in a separate thread. After the rendering is done potentially
> nothing would wake up the main loop thread and cause a dispatch.
>
> That patch also moves the call to dri2_dpy->flush->flush further up. I'm

I made that patch out of a pastebin by Daniel Stone, which had that
already moved
up, i don't know why.

> not sure if that is necessary. It also adds a pointer to the wl_display
> in struct dri2_egl_surface which definitely looks unnecessary. So I
> think Axel's patch makes more sense.

Yeah, I didn't realize dri2_dpy had a wl_display pointer.

>
> Reviewed-by: Neil Roberts <neil at linux.intel.com>
>
> Regards,
> - Neil
>
> Axel Davy <axel.davy at ens.fr> writes:
>
>> We would like the compositor to receive the commited buffer
>> as soon as possible, so it has the time to treat it, and
>> release old ones. We shouldn't rely on the client
>> to flush the queue for us.
>>
>> Signed-off-by: Axel Davy <axel.davy at ens.fr>
>> ---
>> We flush the wl_display after we flush the drawable.
>>
>>  src/egl/drivers/dri2/platform_wayland.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
>> index 7e3733b..8c3d1f1 100644
>> --- a/src/egl/drivers/dri2/platform_wayland.c
>> +++ b/src/egl/drivers/dri2/platform_wayland.c
>> @@ -627,6 +627,8 @@ dri2_swap_buffers_with_damage(_EGLDriver *drv,
>>        (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
>>     (*dri2_dpy->flush->invalidate)(dri2_surf->dri_drawable);
>>
>> +   wl_display_flush(dri2_dpy->wl_dpy);
>> +
>>     return EGL_TRUE;
>>  }
>>
>> --
>> 1.8.1.2
>>
>> _______________________________________________
>> wayland-devel mailing list
>> wayland-devel at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list