126e4beaaSAndrew GeisslerFrom ffdcdf7605f4f266b408cf161e7c76dab54d689b Mon Sep 17 00:00:00 2001 21a4b7ee2SBrad BishopFrom: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> 31a4b7ee2SBrad BishopDate: Thu, 19 Jan 2017 18:56:07 +0000 426e4beaaSAndrew GeisslerSubject: [PATCH] Implement triple buffering for wayland 51a4b7ee2SBrad Bishop 61a4b7ee2SBrad BishopChange from double to triple buffering for wayland. 71a4b7ee2SBrad BishopThis enables higher frame rates without tearing artifacts 81a4b7ee2SBrad Bishopby allowing both the glFinish and the buffer release 91a4b7ee2SBrad Bishopinterlock to operate without pushing the frame period 101a4b7ee2SBrad Bishopto two vertical intervals 111a4b7ee2SBrad Bishop 121a4b7ee2SBrad BishopSigned-off-by: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> 131a4b7ee2SBrad BishopSigned-off-by: Khem Raj <raj.khem@gmail.com> 141a4b7ee2SBrad Bishop--- 15*520786ccSPatrick WilliamsUpstream-Status: Pending 16*520786ccSPatrick Williams 171a4b7ee2SBrad Bishop interface/khronos/egl/egl_client.c | 3 ++- 181a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.c | 8 ++++++++ 191a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.h | 11 +++++++++++ 201a4b7ee2SBrad Bishop 3 files changed, 21 insertions(+), 1 deletion(-) 211a4b7ee2SBrad Bishop 221a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c 231a4b7ee2SBrad Bishopindex 13a110c..0380274 100644 241a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client.c 251a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client.c 261a4b7ee2SBrad Bishop@@ -2323,7 +2323,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) 271a4b7ee2SBrad Bishop 281a4b7ee2SBrad Bishop buffer_temp = surface->front_wl_buffer; 291a4b7ee2SBrad Bishop surface->front_wl_buffer = surface->back_wl_buffer; 301a4b7ee2SBrad Bishop- surface->back_wl_buffer = buffer_temp; 311a4b7ee2SBrad Bishop+ surface->back_wl_buffer = surface->middle_wl_buffer; 321a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = buffer_temp; 331a4b7ee2SBrad Bishop 341a4b7ee2SBrad Bishop configid = egl_config_to_id(surface->config); 351a4b7ee2SBrad Bishop color = egl_config_get_color_format(configid); 361a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.c b/interface/khronos/egl/egl_client_surface.c 371a4b7ee2SBrad Bishopindex 9a9582c..10b3b04 100644 381a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.c 391a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.c 401a4b7ee2SBrad Bishop@@ -402,12 +402,14 @@ EGL_SURFACE_T *egl_surface_create( 411a4b7ee2SBrad Bishop if (type == WINDOW && wl_display) { 421a4b7ee2SBrad Bishop surface->wl_egl_window = (struct wl_egl_window*)win; 431a4b7ee2SBrad Bishop surface->front_wl_buffer = NULL; 441a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = NULL; 451a4b7ee2SBrad Bishop surface->back_wl_buffer = allocate_wl_buffer( 461a4b7ee2SBrad Bishop surface->wl_egl_window, color); 471a4b7ee2SBrad Bishop resource = surface->back_wl_buffer->resource; 481a4b7ee2SBrad Bishop } else { 491a4b7ee2SBrad Bishop surface->wl_egl_window = NULL; 501a4b7ee2SBrad Bishop surface->front_wl_buffer = NULL; 511a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = NULL; 521a4b7ee2SBrad Bishop surface->back_wl_buffer = NULL; 531a4b7ee2SBrad Bishop resource = DISPMANX_NO_HANDLE; 541a4b7ee2SBrad Bishop } 551a4b7ee2SBrad Bishop@@ -696,6 +698,12 @@ void egl_surface_free(EGL_SURFACE_T *surface) 561a4b7ee2SBrad Bishop surface->back_wl_buffer = 0; 571a4b7ee2SBrad Bishop } 581a4b7ee2SBrad Bishop 591a4b7ee2SBrad Bishop+ if (surface->middle_wl_buffer) { 601a4b7ee2SBrad Bishop+ wl_buffer_destroy(surface->middle_wl_buffer->wl_buffer); 611a4b7ee2SBrad Bishop+ free(surface->middle_wl_buffer); 621a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = 0; 631a4b7ee2SBrad Bishop+ } 641a4b7ee2SBrad Bishop+ 651a4b7ee2SBrad Bishop if (surface->front_wl_buffer) { 661a4b7ee2SBrad Bishop wl_buffer_destroy(surface->front_wl_buffer->wl_buffer); 671a4b7ee2SBrad Bishop free(surface->front_wl_buffer); 681a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.h b/interface/khronos/egl/egl_client_surface.h 691a4b7ee2SBrad Bishopindex e328b77..58a3184 100644 701a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.h 711a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.h 721a4b7ee2SBrad Bishop@@ -312,6 +312,17 @@ typedef struct { 731a4b7ee2SBrad Bishop */ 741a4b7ee2SBrad Bishop struct wl_dispmanx_client_buffer *front_wl_buffer; 751a4b7ee2SBrad Bishop 761a4b7ee2SBrad Bishop+ /* 771a4b7ee2SBrad Bishop+ middle_wl_buffer 781a4b7ee2SBrad Bishop+ 791a4b7ee2SBrad Bishop+ Validity: 801a4b7ee2SBrad Bishop+ type == WINDOW 811a4b7ee2SBrad Bishop+ 821a4b7ee2SBrad Bishop+ Invariant: 831a4b7ee2SBrad Bishop+ client-side information about the wl_buffer in the middle 841a4b7ee2SBrad Bishop+ */ 851a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *middle_wl_buffer; 861a4b7ee2SBrad Bishop+ 871a4b7ee2SBrad Bishop /* 881a4b7ee2SBrad Bishop back_wl_buffer 891a4b7ee2SBrad Bishop 90