[PATCH v2 06/11] gbm: creates hooks for dri2_loader_extension in dri backend

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Wed Jan 25 06:24:18 PST 2012


---
 src/gbm/backends/dri/gbm_dri.c    |   53 ++++++++++++++++++++++++++++++++++++-
 src/gbm/backends/dri/gbm_driint.h |   17 +++++++++++-
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 6f6b00d..ec2c572 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -54,6 +54,49 @@ dri_lookup_egl_image(__DRIscreen *screen, void *image, void *data)
    return dri->lookup_image(screen, image, dri->lookup_user_data);
 }
 
+static __DRIbuffer *
+dri_get_buffers(__DRIdrawable * driDrawable,
+		 int *width, int *height,
+		 unsigned int *attachments, int count,
+		 int *out_count, void *data)
+{
+   struct gbm_dri_surface *surf = data;
+   struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
+
+   if (dri->get_buffers == NULL)
+      return NULL;
+
+   return dri->get_buffers(driDrawable, width, height, attachments,
+                           count, out_count, surf->dri_private);
+}
+
+static void
+dri_flush_front_buffer(__DRIdrawable * driDrawable, void *data)
+{
+   struct gbm_dri_surface *surf = data;
+   struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
+
+   if (dri->flush_front_buffer != NULL)
+      dri->flush_front_buffer(driDrawable, surf->dri_private);
+}
+
+static __DRIbuffer *
+dri_get_buffers_with_format(__DRIdrawable * driDrawable,
+                            int *width, int *height,
+                            unsigned int *attachments, int count,
+                            int *out_count, void *data)
+{
+   struct gbm_dri_surface *surf = data;
+   struct gbm_dri_device *dri = gbm_dri_device(surf->base.gbm);
+
+   if (dri->get_buffers_with_format == NULL)
+      return NULL;
+
+   return
+      dri->get_buffers_with_format(driDrawable, width, height, attachments,
+                                   count, out_count, surf->dri_private);
+}
+
 const __DRIuseInvalidateExtension use_invalidate = {
    { __DRI_USE_INVALIDATE, 1 }
 };
@@ -63,6 +106,13 @@ const __DRIimageLookupExtension image_lookup_extension = {
    dri_lookup_egl_image
 };
 
+const __DRIdri2LoaderExtension dri2_loader_extension = {
+   { __DRI_DRI2_LOADER, 3 },
+   dri_get_buffers,
+   dri_flush_front_buffer,
+   dri_get_buffers_with_format,
+};
+
 struct dri_extension_match {
    const char *name;
    int version;
@@ -187,7 +237,8 @@ dri_screen_create(struct gbm_dri_device *dri)
 
    dri->extensions[0] = &image_lookup_extension.base;
    dri->extensions[1] = &use_invalidate.base;
-   dri->extensions[2] = NULL;
+   dri->extensions[2] = &dri2_loader_extension.base;
+   dri->extensions[3] = NULL;
 
    if (dri->dri2 == NULL)
       return -1;
diff --git a/src/gbm/backends/dri/gbm_driint.h b/src/gbm/backends/dri/gbm_driint.h
index d04ae6b..f404368 100644
--- a/src/gbm/backends/dri/gbm_driint.h
+++ b/src/gbm/backends/dri/gbm_driint.h
@@ -36,6 +36,8 @@
 #include <GL/gl.h> /* dri_interface needs GL types */
 #include "GL/internal/dri_interface.h"
 
+struct gbm_dri_surface;
+
 struct gbm_dri_device {
    struct gbm_drm_device base;
 
@@ -47,12 +49,23 @@ struct gbm_dri_device {
    __DRIdri2Extension   *dri2;
    __DRIimageExtension  *image;
    __DRI2flushExtension *flush;
+   __DRIdri2LoaderExtension *loader;
 
    const __DRIconfig   **driver_configs;
-   const __DRIextension *extensions[3];
+   const __DRIextension *extensions[4];
 
    __DRIimage *(*lookup_image)(__DRIscreen *screen, void *image, void *data);
    void *lookup_user_data;
+
+   __DRIbuffer *(*get_buffers)(__DRIdrawable * driDrawable,
+                               int *width, int *height,
+                               unsigned int *attachments, int count,
+                               int *out_count, void *data);
+   void (*flush_front_buffer)(__DRIdrawable * driDrawable, void *data);
+   __DRIbuffer *(*get_buffers_with_format)(__DRIdrawable * driDrawable,
+			     int *width, int *height,
+			     unsigned int *attachments, int count,
+			     int *out_count, void *data);
 };
 
 struct gbm_dri_bo {
@@ -63,6 +76,8 @@ struct gbm_dri_bo {
 
 struct gbm_dri_surface {
    struct gbm_surface base;
+
+   void *dri_private;
 };
 
 static inline struct gbm_dri_device *
-- 
1.7.4.1



More information about the wayland-devel mailing list