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