From 5fc21c6044166b199d32006d37f94e6d54aef62a Mon Sep 17 00:00:00 2001 From: "Wu, Zhongmin" Date: Thu, 18 Jan 2018 15:39:22 +0800 Subject: [PATCH] egl/android: Implement the eglSwapinterval for Android. 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 Reviewed-by: Eric Engestrom Reviewed-by: Emil Velikov Reviewed-by: Tomasz Figa [Emil Velikov: polish inline comment, add dEQP stats, s/dpy/disp/] Signed-off-by: Emil Velikov --- src/egl/drivers/dri2/platform_android.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index 4f25cb74691..7f1a496ea24 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -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; -- 2.30.2