egl/x11: attribute for dri2_add_config failure
authorEmil Velikov <emil.velikov@collabora.com>
Thu, 25 Aug 2016 14:24:44 +0000 (15:24 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 14 Oct 2016 11:53:39 +0000 (12:53 +0100)
... in dri2_x11_add_configs_for_visuals().

Currently the latter does not consider that, thus in such cases it adds
"empty" configs in the list.

Properly account for things and as we do that we can reuse count,
instead of calling _eglGetArraySize to determine if we've added any
configs.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
src/egl/drivers/dri2/platform_x11.c

index 0b1b5144b802689fae824bbc6feb0dc80cdb1c47..2921147ecaef9cab43d514a0716eef57a8d2aaca 100644 (file)
@@ -723,7 +723,7 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
    xcb_screen_iterator_t s;
    xcb_depth_iterator_t d;
    xcb_visualtype_t *visuals;
-   int i, j, id;
+   int i, j, count;
    unsigned int rgba_masks[4];
    EGLint surface_type;
    EGLint config_attrs[] = {
@@ -734,7 +734,7 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
 
    s = xcb_setup_roots_iterator(xcb_get_setup(dri2_dpy->conn));
    d = xcb_screen_allowed_depths_iterator(get_xcb_screen(s, dri2_dpy->screen));
-   id = 1;
+   count = 0;
 
    surface_type =
       EGL_WINDOW_BIT |
@@ -754,6 +754,9 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
 
         class_added[visuals[i]._class] = EGL_TRUE;
         for (j = 0; dri2_dpy->driver_configs[j]; j++) {
+            struct dri2_egl_config *dri2_conf;
+            const __DRIconfig *config = dri2_dpy->driver_configs[j];
+
             config_attrs[1] = visuals[i].visual_id;
             config_attrs[3] = visuals[i]._class;
 
@@ -761,8 +764,10 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
             rgba_masks[1] = visuals[i].green_mask;
             rgba_masks[2] = visuals[i].blue_mask;
             rgba_masks[3] = 0;
-           dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
-                           surface_type, config_attrs, rgba_masks);
+            dri2_conf = dri2_add_config(disp, config, count + 1, surface_type,
+                                        config_attrs, rgba_masks);
+            if (dri2_conf)
+               count++;
 
             /* Allow a 24-bit RGB visual to match a 32-bit RGBA EGLConfig.
              * Otherwise it will only match a 32-bit RGBA visual.  On a
@@ -774,8 +779,10 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
             if (d.data->depth == 24) {
                rgba_masks[3] =
                   ~(rgba_masks[0] | rgba_masks[1] | rgba_masks[2]);
-               dri2_add_config(disp, dri2_dpy->driver_configs[j], id++,
-                               surface_type, config_attrs, rgba_masks);
+               dri2_conf = dri2_add_config(disp, config, count + 1, surface_type,
+                                           config_attrs, rgba_masks);
+               if (dri2_conf)
+                  count++;
             }
         }
       }
@@ -783,7 +790,7 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
       xcb_depth_next(&d);
    }
 
-   if (!_eglGetArraySize(disp->Configs)) {
+   if (!count) {
       _eglLog(_EGL_WARNING, "DRI2: failed to create any config");
       return EGL_FALSE;
    }