1From 0af26805c35c6a600a13ed106bbc7cf85a37ce66 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 29 Mar 2016 20:38:30 -0700
4Subject: [PATCH] Fix for framerate with nested composition
5
6frame rate appears irregular and lower than expected when using nested composition.
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 interface/khronos/egl/egl_client.c | 8 ++++++++
11 1 file changed, 8 insertions(+)
12
13diff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c
14index 03fe67b..13a110c 100644
15--- a/interface/khronos/egl/egl_client.c
16+++ b/interface/khronos/egl/egl_client.c
17@@ -2342,6 +2342,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
18                      surface->back_wl_buffer = buffer;
19                   }
20
21+                  glFlush();
22+                  glFinish();
23+
24                   RPC_CALL7(eglIntSwapBuffers_impl,
25                         thread,
26                         EGLINTSWAPBUFFERS_ID_V2,
27@@ -2353,6 +2356,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
28                         RPC_UINT(khrn_platform_get_window_position(surface->win)),
29                         RPC_INT(surface->back_wl_buffer->resource));
30
31+                  RPC_FLUSH(thread);
32+
33                   surface->front_wl_buffer->in_use = 1;
34                   wl_surface_attach(wl_egl_window->wl_surface,
35                                     surface->front_wl_buffer->wl_buffer,
36@@ -2360,11 +2365,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
37                   wl_surface_damage(wl_egl_window->wl_surface, 0, 0,
38                                     surface->width, surface->height);
39                   wl_surface_commit(wl_egl_window->wl_surface);
40+                  wl_display_flush(wl_display);
41
42                   while(ret != -1 && surface->back_wl_buffer->in_use)
43                      ret = wl_display_dispatch_queue(wl_display, process->wl_queue);
44                } else
45 #endif
46+               {
47                RPC_CALL6(eglIntSwapBuffers_impl,
48                      thread,
49                      EGLINTSWAPBUFFERS_ID,
50@@ -2376,6 +2383,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
51                      RPC_UINT(khrn_platform_get_window_position(surface->win)));
52
53                RPC_FLUSH(thread);
54+               }
55
56 #ifdef ANDROID
57                CLIENT_UNLOCK();
58