Commit 9ca6711f authored by Daniel Stone's avatar Daniel Stone

Revert "wayland: Block for the frame callback in get_back_bo not dri2_swap_buffers"

This reverts commit 25cc8890, though
since the code has changed, it was applied manually.

The intent of moving blocking from SwapBuffers to get_back_bo, was to
avoid unnecessary triple-buffering by ensuring that the compositor had
fully processed the previous frame before we started rendering. This
means that the only time we would have to resort to triple-buffering
would be when the buffer is directly scanned out, thus saving an extra
buffer for composition anyway.

The 'repaint window' changes introduced in Weston since then, however,
have narrowed the window of time between the frame event being sent and
the repaint loop needing to conclude, to 7ms by default, in order to
reduce latency. This means however that blocking in get_back_bo gives a
maximum of 7ms for the entire GL submission to begin and complete.

Not only this, but if a client is using buffer_age to avoid full
repaints, the buffer-age request will stall in get_back_bo until the
frame callback completes, meaning that the client cannot even calculate
the repaint area before the 7ms window.

The combination of the two meant that WebKit-GTK+ was failing to
achieve full framerate on a Minnowboard, due to spending a great deal of
its time attempting to query the age of the next buffer before redraw.

Revert to the previous behaviour of allowing rendering to begin but
delaying SwapBuffers, unless and until we can find a more gentle
behaviour.
Signed-off-by: Daniel Stone's avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: Jonas Ådahl's avatarJonas Ådahl <jadahl@gmail.com>
Reviewed-by: default avatarDerek Foreman <derekf@osg.samsung.com>
Tested-by: default avatarDerek Foreman <derekf@osg.samsung.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
parent 89334175
...@@ -335,14 +335,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf) ...@@ -335,14 +335,8 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
return -1; return -1;
} }
/* We always want to throttle to some event (either a frame callback or /* There might be a buffer release already queued that wasn't processed */
* a sync request) after the commit so that we can be sure the wl_display_dispatch_queue_pending(dri2_dpy->wl_dpy, dri2_dpy->wl_queue);
* compositor has had a chance to handle it and send us a release event
* before we look for a free buffer */
while (dri2_surf->throttle_callback != NULL)
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
dri2_dpy->wl_queue) == -1)
return -1;
if (dri2_surf->back == NULL) { if (dri2_surf->back == NULL) {
for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
...@@ -716,6 +710,11 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv, ...@@ -716,6 +710,11 @@ dri2_wl_swap_buffers_with_damage(_EGLDriver *drv,
struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw); struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
int i; int i;
while (dri2_surf->throttle_callback != NULL)
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
dri2_dpy->wl_queue) == -1)
return -1;
for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++)
if (dri2_surf->color_buffers[i].age > 0) if (dri2_surf->color_buffers[i].age > 0)
dri2_surf->color_buffers[i].age++; dri2_surf->color_buffers[i].age++;
...@@ -1475,14 +1474,8 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf) ...@@ -1475,14 +1474,8 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
/* find back buffer */ /* find back buffer */
/* We always want to throttle to some event (either a frame callback or /* There might be a buffer release already queued that wasn't processed */
* a sync request) after the commit so that we can be sure the wl_display_dispatch_queue_pending(dri2_dpy->wl_dpy, dri2_dpy->wl_queue);
* compositor has had a chance to handle it and send us a release event
* before we look for a free buffer */
while (dri2_surf->throttle_callback != NULL)
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
dri2_dpy->wl_queue) == -1)
return -1;
/* try get free buffer already created */ /* try get free buffer already created */
for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) { for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
...@@ -1563,6 +1556,11 @@ dri2_wl_swrast_commit_backbuffer(struct dri2_egl_surface *dri2_surf) ...@@ -1563,6 +1556,11 @@ dri2_wl_swrast_commit_backbuffer(struct dri2_egl_surface *dri2_surf)
{ {
struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display); struct dri2_egl_display *dri2_dpy = dri2_egl_display(dri2_surf->base.Resource.Display);
while (dri2_surf->throttle_callback != NULL)
if (wl_display_dispatch_queue(dri2_dpy->wl_dpy,
dri2_dpy->wl_queue) == -1)
return -1;
if (dri2_surf->base.SwapInterval > 0) { if (dri2_surf->base.SwapInterval > 0) {
dri2_surf->throttle_callback = dri2_surf->throttle_callback =
wl_surface_frame(dri2_surf->wl_win->surface); wl_surface_frame(dri2_surf->wl_win->surface);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment