egl: properly count configs
authorEric Engestrom <eric@engestrom.ch>
Wed, 21 Jun 2017 20:55:56 +0000 (21:55 +0100)
committerEric Engestrom <eric.engestrom@imgtec.com>
Thu, 22 Jun 2017 16:32:31 +0000 (17:32 +0100)
dri2_conf represents another config (which shouldn't be counted)
if it doesn't have the requested ID.

Reported-by: Liu Zhiquan <zhiquan.liu@intel.com>
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/drivers/dri2/platform_android.c
src/egl/drivers/dri2/platform_drm.c
src/egl/drivers/dri2/platform_surfaceless.c
src/egl/drivers/dri2/platform_wayland.c
src/egl/drivers/dri2/platform_x11.c

index eaaeff4641c02348ac506974c31955787def31ea..dba5ad6d5517cfa8242687b3be1470e41bed4caa 100644 (file)
@@ -1079,7 +1079,8 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
          dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
                count + 1, surface_type, config_attrs, visuals[i].rgba_masks);
          if (dri2_conf) {
-            count++;
+            if (dri2_conf->base.ConfigID == count + 1)
+               count++;
             format_count[i]++;
          }
       }
index 2cf7106255f279bca9da8fc2a29af6e79424ecd9..869f599df574a7eb227b5d20c38f41817ea2145e 100644 (file)
@@ -631,7 +631,8 @@ drm_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
          dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
                count + 1, EGL_WINDOW_BIT, attr_list, NULL);
          if (dri2_conf) {
-            count++;
+            if (dri2_conf->base.ConfigID == count + 1)
+               count++;
             format_count[j]++;
          }
       }
index 0eb3fb7505c444314467951b3912dc559c1f67dd..f292f2b3fe3a9027d0df6422291d357b30152391 100644 (file)
@@ -212,7 +212,8 @@ surfaceless_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
                count + 1, EGL_PBUFFER_BIT, NULL, visuals[j].rgba_masks);
 
          if (dri2_conf) {
-            count++;
+            if (dri2_conf->base.ConfigID == count + 1)
+               count++;
             format_count[j]++;
          }
       }
index 1444449e8c5b773c6e830f31bcd0a271208c8872..128ef75105dff3c11cc90dba4cae92913b04122b 100644 (file)
@@ -1131,7 +1131,8 @@ dri2_wl_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
          dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i],
                count + 1, EGL_WINDOW_BIT, NULL, visuals[j].rgba_masks);
          if (dri2_conf) {
-            count++;
+            if (dri2_conf->base.ConfigID == count + 1)
+               count++;
             format_count[j]++;
          }
       }
index 95e560a32a649503f213dda31d02a0f5ea219676..f91ad67d5f94567800d75d9bacd79ca3a3fe3857 100644 (file)
@@ -773,7 +773,8 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
             dri2_conf = dri2_add_config(disp, config, count + 1, surface_type,
                                         config_attrs, rgba_masks);
             if (dri2_conf)
-               count++;
+               if (dri2_conf->base.ConfigID == count + 1)
+                  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
@@ -788,7 +789,8 @@ dri2_x11_add_configs_for_visuals(struct dri2_egl_display *dri2_dpy,
                dri2_conf = dri2_add_config(disp, config, count + 1, surface_type,
                                            config_attrs, rgba_masks);
                if (dri2_conf)
-                  count++;
+                  if (dri2_conf->base.ConfigID == count + 1)
+                     count++;
             }
         }
       }