1From 09de2ce12ed8a879cc822cd20c5f2756d030808a 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---
10Upstream-Status: Pending
11
12 interface/khronos/egl/egl_client.c | 8 ++++++++
13 1 file changed, 8 insertions(+)
14
15diff --git a/interface/khronos/egl/egl_client.c b/interface/khronos/egl/egl_client.c
16index 03fe67b..13a110c 100644
17--- a/interface/khronos/egl/egl_client.c
18+++ b/interface/khronos/egl/egl_client.c
19@@ -2342,6 +2342,9 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
20                      surface->back_wl_buffer = buffer;
21                   }
22
23+                  glFlush();
24+                  glFinish();
25+
26                   RPC_CALL7(eglIntSwapBuffers_impl,
27                         thread,
28                         EGLINTSWAPBUFFERS_ID_V2,
29@@ -2353,6 +2356,8 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
30                         RPC_UINT(khrn_platform_get_window_position(surface->win)),
31                         RPC_INT(surface->back_wl_buffer->resource));
32
33+                  RPC_FLUSH(thread);
34+
35                   surface->front_wl_buffer->in_use = 1;
36                   wl_surface_attach(wl_egl_window->wl_surface,
37                                     surface->front_wl_buffer->wl_buffer,
38@@ -2360,11 +2365,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
39                   wl_surface_damage(wl_egl_window->wl_surface, 0, 0,
40                                     surface->width, surface->height);
41                   wl_surface_commit(wl_egl_window->wl_surface);
42+                  wl_display_flush(wl_display);
43
44                   while(ret != -1 && surface->back_wl_buffer->in_use)
45                      ret = wl_display_dispatch_queue(wl_display, process->wl_queue);
46                } else
47 #endif
48+               {
49                RPC_CALL6(eglIntSwapBuffers_impl,
50                      thread,
51                      EGLINTSWAPBUFFERS_ID,
52@@ -2376,6 +2383,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surf)
53                      RPC_UINT(khrn_platform_get_window_position(surface->win)));
54
55                RPC_FLUSH(thread);
56+               }
57
58 #ifdef ANDROID
59                CLIENT_UNLOCK();
60