[cairo] [PATCH 2/3] DRM/Gallium3D: make cairo gallium backend support softpipe

Igor Oliveira itrindade.oliveira at gmail.com
Sun May 30 12:14:44 PDT 2010


---
 configure.ac                        |    4 ++--
 src/drm/cairo-drm-gallium-surface.c |   34 +++++++++++++++++++++-------------
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/configure.ac b/configure.ac
index dc54b58..33753ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -278,8 +278,8 @@ CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
 		  [mesa_DIR="$withval"],
 		  [mesa_DIR="`pwd`/../mesa"])
       gallium_DIR="$mesa_DIR/src/gallium"
-      gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary"
-      gallium_NONPKGCONFIG_LIBS="-lGL"
+      gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary -I$gallium_DIR"
+      gallium_NONPKGCONFIG_LIBS="-lGL $gallium_DIR/drivers/softpipe/libsoftpipe.a $gallium_DIR/winsys/sw/null/libws_null.a $gallium_DIR/auxiliary/libgallium.a"
       AC_SUBST(mesa_DIR)
       AC_SUBST(gallium_DIR)
   else
diff --git a/src/drm/cairo-drm-gallium-surface.c b/src/drm/cairo-drm-gallium-surface.c
index 24ead1f..17ba136 100644
--- a/src/drm/cairo-drm-gallium-surface.c
+++ b/src/drm/cairo-drm-gallium-surface.c
@@ -38,6 +38,8 @@
 
 #include <dlfcn.h>
 
+#include <drivers/softpipe/sp_public.h>
+#include <winsys/sw/null/null_sw_winsys.h>
 #include <state_tracker/drm_api.h>
 #include <pipe/p_format.h>
 #include <pipe/p_screen.h>
@@ -745,6 +747,7 @@ _cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
     const char *libdir;
     char buf[4096];
     struct drm_api *(*ctor) (void);
+    cairo_bool_t has_dri_driver = true;
 
     /* XXX need search path + probe */
     libdir = getenv ("CAIRO_GALLIUM_LIBDIR");
@@ -753,13 +756,8 @@ _cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
     buf[snprintf (buf, sizeof (buf)-1, "%s/i915_dri.so", libdir)] = '\0';
 
     handle = dlopen (buf, RTLD_LAZY);
-    if (handle == NULL)
-	return NULL;
-
-    ctor = dlsym (handle, "drm_api_create");
-    if (ctor == NULL) {
-	dlclose (handle);
-	return NULL;
+    if (handle == NULL) {
+	has_dri_driver = false;
     }
 
     device = malloc (sizeof (gallium_device_t));
@@ -783,13 +781,23 @@ _cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
 
     device->drm.bo.release = _gallium_fake_bo_release;
 
-    device->api = ctor ();
-    if (device->api == NULL) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	goto CLEANUP;
-    }
+    if (has_dri_driver) {
+	ctor = dlsym (handle, "drm_api_create");
+	if (ctor == NULL) {
+	    dlclose (handle);
+	    return NULL;
+	}
+
+	device->api = ctor ();
+	if (device->api == NULL) {
+	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	    goto CLEANUP;
+	}
 
-    device->screen = device->api->create_screen (device->api, fd);
+	device->screen = device->api->create_screen (device->api, fd);
+    } else{
+	device->screen = softpipe_create_screen(null_sw_create());
+    }
     if (device->screen == NULL) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto CLEANUP_API;
-- 
1.6.3.3



More information about the cairo mailing list