[Mesa-dev] [PATCH 25/30] egl/dri2: use dri2_bind_extensions to manage the optional extensions

Emil Velikov emil.l.velikov at gmail.com
Thu Aug 25 16:18:47 UTC 2016


From: Emil Velikov <emil.velikov at collabora.com>

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/egl/drivers/dri2/egl_dri2.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f41f9a9..6edee68 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -387,6 +387,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), true },
+   { __DRI2_CONFIG_QUERY, 1, offsetof(struct dri2_egl_display, config), true },
+   { __DRI2_FENCE, 1, offsetof(struct dri2_egl_display, fence), true },
+   { __DRI2_RENDERER_QUERY, 1, offsetof(struct dri2_egl_display, rendererQuery), true },
+   { __DRI2_INTEROP, 1, offsetof(struct dri2_egl_display, interop), true },
+   { NULL, 0, 0 }
+};
+
 static EGLBoolean
 dri2_bind_extensions(struct dri2_egl_display *dri2_dpy,
                      struct dri2_extension_match *matches,
@@ -677,7 +686,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 =
@@ -731,23 +739,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);
    dri2_setup_screen(disp);
 
    return EGL_TRUE;
-- 
2.9.0



More information about the mesa-dev mailing list