egl/dri2: Refuse to add EGLConfigs with no supported surface types
[mesa.git] / src / egl / drivers / dri2 / egl_dri2.c
index 526cb1969c18b1fd8bb02dc71f6b4c25e978d5ca..f968cd7af27db0e29c655ecadfbe9bd9ea1329c1 100644 (file)
@@ -420,6 +420,22 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
          base.BindToTextureRGBA = bind_to_texture_rgba;
    }
 
+   if (double_buffer) {
+      surface_type &= ~EGL_PIXMAP_BIT;
+   }
+
+   /* No support for pbuffer + MSAA for now.
+    *
+    * XXX TODO: pbuffer + MSAA does not work and causes crashes.
+    * See QT bugreport: https://bugreports.qt.io/browse/QTBUG-47509
+    */
+   if (base.Samples) {
+      surface_type &= ~EGL_PBUFFER_BIT;
+   }
+
+   if (!surface_type)
+      return NULL;
+
    base.RenderableType = disp->ClientAPIs;
    base.Conformant = disp->ClientAPIs;
 
@@ -464,19 +480,6 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
       return NULL;
    }
 
-   if (double_buffer) {
-      surface_type &= ~EGL_PIXMAP_BIT;
-   }
-
-   /* No support for pbuffer + MSAA for now.
-    *
-    * XXX TODO: pbuffer + MSAA does not work and causes crashes.
-    * See QT bugreport: https://bugreports.qt.io/browse/QTBUG-47509
-    */
-   if (base.Samples) {
-      surface_type &= ~EGL_PBUFFER_BIT;
-   }
-
    conf->base.SurfaceType |= surface_type;
 
    return conf;