Mesa (master): pipe-loader: introduce pipe_loader_sw_probe_xlib helper

Emil Velikov evelikov at kemper.freedesktop.org
Sat Feb 22 03:24:59 UTC 2014


Module: Mesa
Branch: master
Commit: cc3aeacab64a6928a903f1dbfeaa7c880a8de5a6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=cc3aeacab64a6928a903f1dbfeaa7c880a8de5a6

Author: Emil Velikov <emil.l.velikov at gmail.com>
Date:   Mon Feb 10 20:19:20 2014 +0000

pipe-loader: introduce pipe_loader_sw_probe_xlib helper

Will be used in the upcoming patches.

v2: handle xlib_create_sw_winsys failure, drop unneeded header

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
Reviewed-by: Jakob Bornecrantz <jakob at vmware.com> (v1)

---

 src/gallium/auxiliary/pipe-loader/Makefile.am      |    4 +++
 src/gallium/auxiliary/pipe-loader/pipe_loader.h    |   18 ++++++++++++++
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |   26 +++++++++++++++++---
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/Makefile.am b/src/gallium/auxiliary/pipe-loader/Makefile.am
index ccdbea5..232fe40 100644
--- a/src/gallium/auxiliary/pipe-loader/Makefile.am
+++ b/src/gallium/auxiliary/pipe-loader/Makefile.am
@@ -8,6 +8,10 @@ AM_CPPFLAGS = $(DEFINES) \
 	-I$(top_srcdir)/src/gallium/auxiliary \
 	-I$(top_srcdir)/src/gallium/winsys
 
+if NEED_WINSYS_XLIB
+AM_CPPFLAGS += -DHAVE_WINSYS_XLIB
+endif
+
 noinst_LTLIBRARIES =
 
 if HAVE_LOADER_GALLIUM
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader.h b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
index ce2118f..315ab32 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader.h
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader.h
@@ -35,6 +35,10 @@
 
 #include "pipe/p_compiler.h"
 
+#ifdef HAVE_WINSYS_XLIB
+#include <X11/Xlib.h>
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -100,6 +104,20 @@ pipe_loader_create_screen(struct pipe_loader_device *dev,
 void
 pipe_loader_release(struct pipe_loader_device **devs, int ndev);
 
+#ifdef HAVE_WINSYS_XLIB
+
+/**
+ * Initialize Xlib for an associated display.
+ *
+ * This function is platform-specific.
+ *
+ * \sa pipe_loader_probe
+ */
+bool
+pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display);
+
+#endif
+
 /**
  * Get a list of known software devices.
  *
diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
index 90d2975..7e2585e 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c
@@ -44,12 +44,32 @@ struct pipe_loader_sw_device {
 static struct pipe_loader_ops pipe_loader_sw_ops;
 
 static struct sw_winsys *(*backends[])() = {
-#ifdef HAVE_WINSYS_XLIB
-   x11_sw_create,
-#endif
    null_sw_create
 };
 
+#ifdef HAVE_WINSYS_XLIB
+bool
+pipe_loader_sw_probe_xlib(struct pipe_loader_device **devs, Display *display)
+{
+   struct pipe_loader_sw_device *sdev = CALLOC_STRUCT(pipe_loader_sw_device);
+
+   if (!sdev)
+      return false;
+
+   sdev->base.type = PIPE_LOADER_DEVICE_SOFTWARE;
+   sdev->base.driver_name = "swrast";
+   sdev->base.ops = &pipe_loader_sw_ops;
+   sdev->ws = xlib_create_sw_winsys(display);
+   if (!sdev->ws) {
+      FREE(sdev);
+      return false;
+   }
+   *devs = &sdev->base;
+
+   return true;
+}
+#endif
+
 int
 pipe_loader_sw_probe(struct pipe_loader_device **devs, int ndev)
 {




More information about the mesa-commit mailing list