1*1a4b7ee2SBrad BishopFrom 65f8bca55aead676cd06fc3210aeffef1f2158c6 Mon Sep 17 00:00:00 2001 2*1a4b7ee2SBrad BishopFrom: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> 3*1a4b7ee2SBrad BishopDate: Thu, 19 Jan 2017 18:56:07 +0000 4*1a4b7ee2SBrad BishopSubject: [PATCH 13/18] Implement triple buffering for wayland 5*1a4b7ee2SBrad Bishop 6*1a4b7ee2SBrad BishopChange from double to triple buffering for wayland. 7*1a4b7ee2SBrad BishopThis enables higher frame rates without tearing artifacts 8*1a4b7ee2SBrad Bishopby allowing both the glFinish and the buffer release 9*1a4b7ee2SBrad Bishopinterlock to operate without pushing the frame period 10*1a4b7ee2SBrad Bishopto two vertical intervals 11*1a4b7ee2SBrad Bishop 12*1a4b7ee2SBrad BishopSigned-off-by: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> 13*1a4b7ee2SBrad BishopSigned-off-by: Khem Raj <raj.khem@gmail.com> 14*1a4b7ee2SBrad Bishop--- 15*1a4b7ee2SBrad Bishop interface/khronos/egl/egl_client.c | 3 ++- 16*1a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.c | 8 ++++++++ 17*1a4b7ee2SBrad Bishop interface/khronos/egl/egl_client_surface.h | 11 +++++++++++ 18*1a4b7ee2SBrad Bishop 3 files changed, 21 insertions(+), 1 deletion(-) 19*1a4b7ee2SBrad Bishop 20*1a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c 21*1a4b7ee2SBrad Bishopindex 13a110c..0380274 100644 22*1a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client.c 23*1a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client.c 24*1a4b7ee2SBrad Bishop@@ -2323,7 +2323,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) 25*1a4b7ee2SBrad Bishop 26*1a4b7ee2SBrad Bishop buffer_temp = surface->front_wl_buffer; 27*1a4b7ee2SBrad Bishop surface->front_wl_buffer = surface->back_wl_buffer; 28*1a4b7ee2SBrad Bishop- surface->back_wl_buffer = buffer_temp; 29*1a4b7ee2SBrad Bishop+ surface->back_wl_buffer = surface->middle_wl_buffer; 30*1a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = buffer_temp; 31*1a4b7ee2SBrad Bishop 32*1a4b7ee2SBrad Bishop configid = egl_config_to_id(surface->config); 33*1a4b7ee2SBrad Bishop color = egl_config_get_color_format(configid); 34*1a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.c b/interface/khronos/egl/egl_client_surface.c 35*1a4b7ee2SBrad Bishopindex 9a9582c..10b3b04 100644 36*1a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.c 37*1a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.c 38*1a4b7ee2SBrad Bishop@@ -402,12 +402,14 @@ EGL_SURFACE_T *egl_surface_create( 39*1a4b7ee2SBrad Bishop if (type == WINDOW && wl_display) { 40*1a4b7ee2SBrad Bishop surface->wl_egl_window = (struct wl_egl_window*)win; 41*1a4b7ee2SBrad Bishop surface->front_wl_buffer = NULL; 42*1a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = NULL; 43*1a4b7ee2SBrad Bishop surface->back_wl_buffer = allocate_wl_buffer( 44*1a4b7ee2SBrad Bishop surface->wl_egl_window, color); 45*1a4b7ee2SBrad Bishop resource = surface->back_wl_buffer->resource; 46*1a4b7ee2SBrad Bishop } else { 47*1a4b7ee2SBrad Bishop surface->wl_egl_window = NULL; 48*1a4b7ee2SBrad Bishop surface->front_wl_buffer = NULL; 49*1a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = NULL; 50*1a4b7ee2SBrad Bishop surface->back_wl_buffer = NULL; 51*1a4b7ee2SBrad Bishop resource = DISPMANX_NO_HANDLE; 52*1a4b7ee2SBrad Bishop } 53*1a4b7ee2SBrad Bishop@@ -696,6 +698,12 @@ void egl_surface_free(EGL_SURFACE_T *surface) 54*1a4b7ee2SBrad Bishop surface->back_wl_buffer = 0; 55*1a4b7ee2SBrad Bishop } 56*1a4b7ee2SBrad Bishop 57*1a4b7ee2SBrad Bishop+ if (surface->middle_wl_buffer) { 58*1a4b7ee2SBrad Bishop+ wl_buffer_destroy(surface->middle_wl_buffer->wl_buffer); 59*1a4b7ee2SBrad Bishop+ free(surface->middle_wl_buffer); 60*1a4b7ee2SBrad Bishop+ surface->middle_wl_buffer = 0; 61*1a4b7ee2SBrad Bishop+ } 62*1a4b7ee2SBrad Bishop+ 63*1a4b7ee2SBrad Bishop if (surface->front_wl_buffer) { 64*1a4b7ee2SBrad Bishop wl_buffer_destroy(surface->front_wl_buffer->wl_buffer); 65*1a4b7ee2SBrad Bishop free(surface->front_wl_buffer); 66*1a4b7ee2SBrad Bishopdiff --git a/interface/khronos/egl/egl_client_surface.h b/interface/khronos/egl/egl_client_surface.h 67*1a4b7ee2SBrad Bishopindex e328b77..58a3184 100644 68*1a4b7ee2SBrad Bishop--- a/interface/khronos/egl/egl_client_surface.h 69*1a4b7ee2SBrad Bishop+++ b/interface/khronos/egl/egl_client_surface.h 70*1a4b7ee2SBrad Bishop@@ -312,6 +312,17 @@ typedef struct { 71*1a4b7ee2SBrad Bishop */ 72*1a4b7ee2SBrad Bishop struct wl_dispmanx_client_buffer *front_wl_buffer; 73*1a4b7ee2SBrad Bishop 74*1a4b7ee2SBrad Bishop+ /* 75*1a4b7ee2SBrad Bishop+ middle_wl_buffer 76*1a4b7ee2SBrad Bishop+ 77*1a4b7ee2SBrad Bishop+ Validity: 78*1a4b7ee2SBrad Bishop+ type == WINDOW 79*1a4b7ee2SBrad Bishop+ 80*1a4b7ee2SBrad Bishop+ Invariant: 81*1a4b7ee2SBrad Bishop+ client-side information about the wl_buffer in the middle 82*1a4b7ee2SBrad Bishop+ */ 83*1a4b7ee2SBrad Bishop+ struct wl_dispmanx_client_buffer *middle_wl_buffer; 84*1a4b7ee2SBrad Bishop+ 85*1a4b7ee2SBrad Bishop /* 86*1a4b7ee2SBrad Bishop back_wl_buffer 87*1a4b7ee2SBrad Bishop 88*1a4b7ee2SBrad Bishop-- 89*1a4b7ee2SBrad Bishop2.19.1 90*1a4b7ee2SBrad Bishop 91