egl/dri2: use dri2_bind_extensions to manage the optional extensions
authorEmil Velikov <emil.velikov@collabora.com>
Wed, 24 Aug 2016 23:51:05 +0000 (00:51 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 14 Oct 2016 11:46:03 +0000 (12:46 +0100)
v2: dri2_bind_extensions() now takes optional as an argument.

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

index 4b7baafb4964aec21efd6581edcdfe523910c2e2..203517fbc9d0e1197b78a449f13669f934282fa7 100644 (file)
@@ -395,6 +395,15 @@ static struct dri2_extension_match swrast_core_extensions[] = {
    { NULL, 0, 0 }
 };
 
+static struct dri2_extension_match optional_core_extensions[] = {
+   { __DRI2_ROBUSTNESS, 1, offsetof(struct dri2_egl_display, robustness) },
+   { __DRI2_CONFIG_QUERY, 1, offsetof(struct dri2_egl_display, config) },
+   { __DRI2_FENCE, 1, offsetof(struct dri2_egl_display, fence) },
+   { __DRI2_RENDERER_QUERY, 1, offsetof(struct dri2_egl_display, rendererQuery) },
+   { __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop) },
+   { NULL, 0, 0 }
+};
+
 static EGLBoolean
 dri2_bind_extensions(struct dri2_egl_display *dri2_dpy,
                      struct dri2_extension_match *matches,
@@ -686,7 +695,6 @@ dri2_create_screen(_EGLDisplay *disp)
 {
    const __DRIextension **extensions;
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
-   unsigned i;
 
    if (dri2_dpy->image_driver) {
       dri2_dpy->dri_screen =
@@ -740,23 +748,7 @@ dri2_create_screen(_EGLDisplay *disp)
          goto cleanup_dri_screen;
    }
 
-   for (i = 0; extensions[i]; i++) {
-      if (strcmp(extensions[i]->name, __DRI2_ROBUSTNESS) == 0) {
-         dri2_dpy->robustness = (__DRIrobustnessExtension *) extensions[i];
-      }
-      if (strcmp(extensions[i]->name, __DRI2_CONFIG_QUERY) == 0) {
-         dri2_dpy->config = (__DRI2configQueryExtension *) extensions[i];
-      }
-      if (strcmp(extensions[i]->name, __DRI2_FENCE) == 0) {
-         dri2_dpy->fence = (__DRI2fenceExtension *) extensions[i];
-      }
-      if (strcmp(extensions[i]->name, __DRI2_RENDERER_QUERY) == 0) {
-         dri2_dpy->rendererQuery = (__DRI2rendererQueryExtension *) extensions[i];
-      }
-      if (strcmp(extensions[i]->name, __DRI2_INTEROP) == 0)
-         dri2_dpy->interop = (__DRI2interopExtension *) extensions[i];
-   }
-
+   dri2_bind_extensions(dri2_dpy, optional_core_extensions, extensions, true);
    dri2_setup_screen(disp);
 
    return EGL_TRUE;