From: Eric Engestrom Date: Wed, 21 Jun 2017 20:55:56 +0000 (+0100) Subject: egl: properly count configs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c87f73724efbec493d0149738d3a7ea11bfab222;p=mesa.git egl: properly count configs dri2_conf represents another config (which shouldn't be counted) if it doesn't have the requested ID. Reported-by: Liu Zhiquan Signed-off-by: Eric Engestrom Cc: Reviewed-by: Emil Velikov --- diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index eaaeff4641c..dba5ad6d551 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -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]++; } } diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c index 2cf7106255f..869f599df57 100644 --- a/src/egl/drivers/dri2/platform_drm.c +++ b/src/egl/drivers/dri2/platform_drm.c @@ -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]++; } } diff --git a/src/egl/drivers/dri2/platform_surfaceless.c b/src/egl/drivers/dri2/platform_surfaceless.c index 0eb3fb7505c..f292f2b3fe3 100644 --- a/src/egl/drivers/dri2/platform_surfaceless.c +++ b/src/egl/drivers/dri2/platform_surfaceless.c @@ -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]++; } } diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index 1444449e8c5..128ef75105d 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -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]++; } } diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c index 95e560a32a6..f91ad67d5f9 100644 --- a/src/egl/drivers/dri2/platform_x11.c +++ b/src/egl/drivers/dri2/platform_x11.c @@ -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++; } } }