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

Kristian Høgsberg hoegsberg at gmail.com
Thu Aug 25 17:16:28 UTC 2016


On Thu, Aug 25, 2016 at 9:18 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> 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 }
> +};

If we're grouping optional extensions in their own array anyway (which
I like), why don't we make the 'optional' flag an argument to
dri2_bind_extensions() instead?

Kristian

>  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
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list