gl-renderer: configs for pbuffers too
authorPekka Paalanen <pekka.paalanen@collabora.com>
Fri, 13 Sep 2019 14:24:49 +0000 (17:24 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.com>
Fri, 4 Oct 2019 09:17:18 +0000 (12:17 +0300)
Fold more code into the common config choosing, the pbuffer path this time.
Simplifies code and allows gl_renderer_get_egl_config() to grow smarter in the
future to guarantee config compatility in the absence of configless_context
extension.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
libweston/renderer-gl/egl-glue.c
libweston/renderer-gl/gl-renderer-internal.h
libweston/renderer-gl/gl-renderer.c

index 5b1ba32daff2a707d13263d631e4e81c4a37913b..dad8e57d1734f9173df90ab2d6499bfb1a2bb3ac 100644 (file)
@@ -132,7 +132,7 @@ egl_config_pixel_format_matches(struct gl_renderer *gr,
        return true;
 }
 
-int
+static int
 egl_choose_config(struct gl_renderer *gr,
                  const EGLint *attribs,
                  const struct pixel_format_info *const *pinfo,
@@ -187,6 +187,7 @@ out:
 
 EGLConfig
 gl_renderer_get_egl_config(struct gl_renderer *gr,
+                          EGLint egl_surface_type,
                           const uint32_t *drm_formats,
                           unsigned drm_formats_count)
 {
@@ -195,7 +196,7 @@ gl_renderer_get_egl_config(struct gl_renderer *gr,
        unsigned pinfo_count;
        unsigned i;
        EGLint config_attribs[] = {
-               EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
+               EGL_SURFACE_TYPE,    egl_surface_type,
                EGL_RED_SIZE,        1,
                EGL_GREEN_SIZE,      1,
                EGL_BLUE_SIZE,       1,
index 511fd1850fb8bc050d35f9860ab693aa51a4a894..5e101af2da060ae91d9663fd7808a821756abbaa 100644 (file)
@@ -127,17 +127,9 @@ gl_renderer_print_egl_error_state(void);
 void
 log_egl_config_info(EGLDisplay egldpy, EGLConfig eglconfig);
 
-struct pixel_format_info;
-
-int
-egl_choose_config(struct gl_renderer *gr,
-                 const EGLint *attribs,
-                 const struct pixel_format_info *const *pinfo,
-                 unsigned pinfo_count,
-                 EGLConfig *config_out);
-
 EGLConfig
 gl_renderer_get_egl_config(struct gl_renderer *gr,
+                          EGLint egl_surface_type,
                           const uint32_t *drm_formats,
                           unsigned drm_formats_count);
 
index c8981c34fb59ad2aecf60af186af233992815efb..ed4ea652fb536d0046ae014479b504e8c56869d1 100644 (file)
@@ -3067,7 +3067,7 @@ gl_renderer_create_window_surface(struct gl_renderer *gr,
        EGLSurface egl_surface = EGL_NO_SURFACE;
        EGLConfig egl_config;
 
-       egl_config = gl_renderer_get_egl_config(gr,
+       egl_config = gl_renderer_get_egl_config(gr, EGL_WINDOW_BIT,
                                                drm_formats, drm_formats_count);
        if (egl_config == EGL_NO_CONFIG_KHR)
                return EGL_NO_SURFACE;
@@ -3325,24 +3325,15 @@ output_handle_destroy(struct wl_listener *listener, void *data)
 static int
 gl_renderer_create_pbuffer_surface(struct gl_renderer *gr) {
        EGLConfig pbuffer_config;
-
-       static const EGLint pbuffer_config_attribs[] = {
-               EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
-               EGL_RED_SIZE, 1,
-               EGL_GREEN_SIZE, 1,
-               EGL_BLUE_SIZE, 1,
-               EGL_ALPHA_SIZE, 0,
-               EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-               EGL_NONE
-       };
-
        static const EGLint pbuffer_attribs[] = {
                EGL_WIDTH, 10,
                EGL_HEIGHT, 10,
                EGL_NONE
        };
 
-       if (egl_choose_config(gr, pbuffer_config_attribs, NULL, 0, &pbuffer_config) < 0) {
+       pbuffer_config = gl_renderer_get_egl_config(gr, EGL_PBUFFER_BIT,
+                                                   NULL, 0);
+       if (pbuffer_config == EGL_NO_CONFIG_KHR) {
                weston_log("failed to choose EGL config for PbufferSurface\n");
                return -1;
        }
@@ -3436,7 +3427,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
                goto fail_with_error;
 
        if (!gr->has_configless_context) {
-               gr->egl_config = gl_renderer_get_egl_config(gr,
+               gr->egl_config = gl_renderer_get_egl_config(gr, EGL_WINDOW_BIT,
                                                            drm_formats,
                                                            drm_formats_count);
                if (gr->egl_config == EGL_NO_CONFIG_KHR) {