egl/android: Implement the eglSwapinterval for Android.
authorWu, Zhongmin <zhongmin.wu@intel.com>
Thu, 18 Jan 2018 07:39:22 +0000 (15:39 +0800)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 16 Mar 2018 13:58:56 +0000 (13:58 +0000)
Implement the eglSwapinterval for Android platform to
enable the async mode for some GFX benchmarks such as
Daimler C217, CityBench.

Results of the dEQP-EGL.*swap_interval tests

'dEQP-EGL.functional.query_config.get_config_attrib.max_swap_interval'..
'dEQP-EGL.functional.query_config.get_config_attrib.min_swap_interval'..
'dEQP-EGL.functional.choose_config.simple.selection_only.max_swap_interval'..
'dEQP-EGL.functional.choose_config.simple.selection_only.min_swap_interval'..
'dEQP-EGL.functional.choose_config.simple.selection_and_sort.max_swap_interval'..
'dEQP-EGL.functional.choose_config.simple.selection_and_sort.min_swap_interval'..
'dEQP-EGL.functional.negative_api.swap_interval'..

 Test run totals:
   Passed:        7/7 (100.0%)
   Failed:        0/7 (0.0%)
   Not supported: 0/7 (0.0%)
   Warnings:      0/7 (0.0%)

Signed-off-by: Zhongmin Wu <zhongmin.wu@intel.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
[Emil Velikov: polish inline comment, add dEQP stats, s/dpy/disp/]
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/drivers/dri2/platform_android.c

index 4f25cb746915c17ea5455cd8904814b495e682ee..7f1a496ea24180c9dedeec877e4833951fc1f027 100644 (file)
@@ -417,6 +417,20 @@ droid_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
    return EGL_TRUE;
 }
 
+static EGLBoolean
+droid_swap_interval(_EGLDriver *drv, _EGLDisplay *dpy,
+                   _EGLSurface *surf, EGLint interval)
+{
+   struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
+   struct ANativeWindow *window = dri2_surf->window;
+
+   if (window->setSwapInterval(window, interval))
+      return EGL_FALSE;
+
+   surf->SwapInterval = interval;
+   return EGL_TRUE;
+}
+
 static int
 update_buffers(struct dri2_egl_surface *dri2_surf)
 {
@@ -1127,6 +1141,7 @@ static const struct dri2_egl_display_vtbl droid_display_vtbl = {
    .swap_buffers = droid_swap_buffers,
    .swap_buffers_with_damage = dri2_fallback_swap_buffers_with_damage, /* Android implements the function */
    .swap_buffers_region = dri2_fallback_swap_buffers_region,
+   .swap_interval = droid_swap_interval,
 #if ANDROID_API_LEVEL >= 23
    .set_damage_region = droid_set_damage_region,
 #else
@@ -1241,6 +1256,12 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp)
 
    dri2_setup_screen(disp);
 
+   /* We set the maximum swap interval as 1 for Android platform, since it is
+    * the maximum value supported by Android according to the value of
+    * ANativeWindow::maxSwapInterval.
+    */
+   dri2_setup_swap_interval(disp, 1);
+
    if (!droid_add_configs_for_visuals(drv, disp)) {
       err = "DRI2: failed to add configs";
       goto cleanup;