egl: Implementation of egl dri2 drivers for MESA_query_driver
authorVeluri Mithun <velurimithun38@gmail.com>
Wed, 23 Jan 2019 17:15:42 +0000 (22:45 +0530)
committerEric Engestrom <eric.engestrom@intel.com>
Thu, 24 Jan 2019 14:37:52 +0000 (14:37 +0000)
Signed-off-by: Veluri Mithun <velurimithun38@gmail.com>
Acked-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/egl/drivers/dri2/egl_dri2.c
src/egl/drivers/dri2/egl_dri2.h

index bce9ecb274ff2620d6dffdc7345d07d4ef58aa03..892e32dd4e35e87927d9b3e504e7556e3e6de144 100644 (file)
@@ -426,6 +426,11 @@ static const struct dri2_extension_match swrast_core_extensions[] = {
    { NULL, 0, 0 }
 };
 
+static const struct dri2_extension_match optional_driver_extensions[] = {
+   { __DRI_CONFIG_OPTIONS, 1, offsetof(struct dri2_egl_display, configOptions) },
+   { NULL, 0, 0 }
+};
+
 static const struct dri2_extension_match optional_core_extensions[] = {
    { __DRI2_ROBUSTNESS, 1, offsetof(struct dri2_egl_display, robustness) },
    { __DRI2_NO_ERROR, 1, offsetof(struct dri2_egl_display, no_error) },
@@ -510,6 +515,8 @@ dri2_load_driver_dri3(_EGLDisplay *disp)
    }
    dri2_dpy->driver_extensions = extensions;
 
+   dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true);
+
    return EGL_TRUE;
 }
 
@@ -529,6 +536,8 @@ dri2_load_driver(_EGLDisplay *disp)
    }
    dri2_dpy->driver_extensions = extensions;
 
+   dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true);
+
    return EGL_TRUE;
 }
 
@@ -548,6 +557,8 @@ dri2_load_driver_swrast(_EGLDisplay *disp)
    }
    dri2_dpy->driver_extensions = extensions;
 
+   dri2_bind_extensions(dri2_dpy, optional_driver_extensions, extensions, true);
+
    return EGL_TRUE;
 }
 
@@ -564,6 +575,26 @@ dri2_renderer_query_integer(struct dri2_egl_display *dri2_dpy, int param)
    return value;
 }
 
+static const char *
+dri2_query_driver_name(_EGLDisplay *disp)
+{
+    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+    return dri2_dpy->driver_name;
+}
+
+static char *
+dri2_query_driver_config(_EGLDisplay *disp)
+{
+    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+    const __DRIconfigOptionsExtension *ext = dri2_dpy->configOptions;
+
+    if (ext->base.version >= 2)
+        return ext->getXml(dri2_dpy->driver_name);
+
+    return strdup(ext->xml);
+}
+
+
 void
 dri2_setup_screen(_EGLDisplay *disp)
 {
@@ -608,6 +639,10 @@ dri2_setup_screen(_EGLDisplay *disp)
    disp->Extensions.KHR_no_config_context = EGL_TRUE;
    disp->Extensions.KHR_surfaceless_context = EGL_TRUE;
 
+   if (dri2_dpy->configOptions) {
+       disp->Extensions.MESA_query_driver = EGL_TRUE;
+   }
+
    /* Report back to EGL the bitmask of priorities supported */
    disp->Extensions.IMG_context_priority =
       dri2_renderer_query_integer(dri2_dpy,
@@ -3229,6 +3264,8 @@ _eglInitDriver(_EGLDriver *dri2_drv)
    dri2_drv->API.DestroyImageKHR = dri2_destroy_image_khr;
    dri2_drv->API.CreateWaylandBufferFromImageWL = dri2_create_wayland_buffer_from_image;
    dri2_drv->API.QuerySurface = dri2_query_surface;
+   dri2_drv->API.QueryDriverName = dri2_query_driver_name;
+   dri2_drv->API.QueryDriverConfig = dri2_query_driver_config;
 #ifdef HAVE_LIBDRM
    dri2_drv->API.CreateDRMImageMESA = dri2_create_drm_image_mesa;
    dri2_drv->API.ExportDRMImageMESA = dri2_export_drm_image_mesa;
index 4abe1ba1952f719d7dd2e03074a223b5fa6078c1..726ba16ae61980d56c5a259c1a870c2087154f58 100644 (file)
@@ -185,6 +185,7 @@ struct dri2_egl_display
    const __DRI2blobExtension *blob;
    const __DRI2rendererQueryExtension *rendererQuery;
    const __DRI2interopExtension *interop;
+   const __DRIconfigOptionsExtension *configOptions;
    const __DRImutableRenderBufferDriverExtension *mutable_render_buffer;
    int                       fd;