From: Pekka Paalanen Date: Wed, 18 Sep 2019 13:41:51 +0000 (+0300) Subject: gl-renderer: prefer the base EGLConfig X-Git-Tag: upstream/9.0.0~373 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ba4c515a35c26b2f7ece5c39e6536714f7e91e8;p=platform%2Fupstream%2Fweston.git gl-renderer: prefer the base EGLConfig If configless_context is not supported, we pick one EGLConfig as the "base config" because we have just one GL context and different configs between the context and EGLSurfaces might not work. Until now, we did not actually make sure to pick the base config. If the base config matches the requirements, prefer it. Only if it doesn't match, go looking for another config. This should give better chances of success on systems where configless_context is not supported by relying less on eglChooseConfig(). Cc: Madhurkiran Harikrishnan Signed-off-by: Pekka Paalanen --- diff --git a/libweston/renderer-gl/egl-glue.c b/libweston/renderer-gl/egl-glue.c index dad8e57d..2c44c86b 100644 --- a/libweston/renderer-gl/egl-glue.c +++ b/libweston/renderer-gl/egl-glue.c @@ -185,6 +185,32 @@ out: return 0; } +static bool +egl_config_is_compatible(struct gl_renderer *gr, + EGLConfig config, + EGLint egl_surface_type, + const struct pixel_format_info *const *pinfo, + unsigned pinfo_count) +{ + EGLint value; + unsigned i; + + if (config == EGL_NO_CONFIG_KHR) + return false; + + if (!eglGetConfigAttrib(gr->egl_display, config, + EGL_SURFACE_TYPE, &value)) + return false; + if ((value & egl_surface_type) != egl_surface_type) + return false; + + for (i = 0; i < pinfo_count; i++) { + if (egl_config_pixel_format_matches(gr, config, pinfo[i])) + return true; + } + return false; +} + EGLConfig gl_renderer_get_egl_config(struct gl_renderer *gr, EGLint egl_surface_type, @@ -217,6 +243,10 @@ gl_renderer_get_egl_config(struct gl_renderer *gr, pinfo_count++; } + if (egl_config_is_compatible(gr, gr->egl_config, egl_surface_type, + pinfo, pinfo_count)) + return gr->egl_config; + if (egl_choose_config(gr, config_attribs, pinfo, pinfo_count, &egl_config) < 0) { weston_log("No EGLConfig matches.\n");