Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 65f8bca55aead676cd06fc3210aeffef1f2158c6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> |
| 3 | Date: Thu, 19 Jan 2017 18:56:07 +0000 |
| 4 | Subject: [PATCH 13/18] Implement triple buffering for wayland |
| 5 | |
| 6 | Change from double to triple buffering for wayland. |
| 7 | This enables higher frame rates without tearing artifacts |
| 8 | by allowing both the glFinish and the buffer release |
| 9 | interlock to operate without pushing the frame period |
| 10 | to two vertical intervals |
| 11 | |
| 12 | Signed-off-by: Jeff Wannamaker <jeff_wannamaker@cable.comcast.com> |
| 13 | Signed-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 | |
| 20 | diff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c |
| 21 | index 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); |
| 34 | diff --git a/interface/khronos/egl/egl_client_surface.c b/interface/khronos/egl/egl_client_surface.c |
| 35 | index 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); |
| 66 | diff --git a/interface/khronos/egl/egl_client_surface.h b/interface/khronos/egl/egl_client_surface.h |
| 67 | index 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 | -- |
| 89 | 2.19.1 |
| 90 | |