swrastg: Use llvmpipe if built but only on scons
authorJakob Bornecrantz <wallbraker@gmail.com>
Fri, 26 Mar 2010 13:47:20 +0000 (14:47 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Fri, 26 Mar 2010 13:56:26 +0000 (14:56 +0100)
src/gallium/targets/dri-swrast/Makefile
src/gallium/targets/dri-swrast/SConscript
src/gallium/targets/dri-swrast/swrast_drm_api.c

index 3780da27550c20e80ec061600a4a4378ce15de69..fcfd690e438d650f21d1da59ea463d088888fa79 100644 (file)
@@ -3,7 +3,7 @@ include $(TOP)/configs/current
 
 LIBNAME = swrastg_dri.so
 
-DRIVER_DEFINES = -D__NOT_HAVE_DRM_H
+DRIVER_DEFINES = -D__NOT_HAVE_DRM_H -DGALLIUM_SOFTPIPE
 
 PIPE_DRIVERS = \
        $(TOP)/src/gallium/state_trackers/dri/sw/libdrisw.a \
index e9f742c43ce34f7a82f9a0f96f8faa765603e1fc..94ff99a0a905a2120f09b593d4305392fd2c43e3 100644 (file)
@@ -1,7 +1,7 @@
 Import('*')
 
-if not 'softpipe' in env['drivers']:
-    print 'warning: softpipe driver not built skipping swrastg_dri.so'
+if not set(('softpipe', 'llvmpipe')).intersection(env['drivers']):
+    print 'warning: no supported pipe driver: skipping build of swrastg_dri.so'
     Return()
 
 env = drienv.Clone()
@@ -13,7 +13,6 @@ env.Append(CPPPATH = [
 env.Prepend(LIBS = [
     st_drisw,
     ws_dri,
-    softpipe,
     trace,
     mesa,
     glsl,
@@ -21,6 +20,17 @@ env.Prepend(LIBS = [
     COMMON_DRI_SW_OBJECTS
 ])
 
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    env.Prepend(LIBS = [softpipe])
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        env.Prepend(LIBS = [llvmpipe])
+
 swrastg_sources = [
     'swrast_drm_api.c'
 ]
index 211836d784f4e49adf078ec8f8441f6fef162ae8..224651603d15921c0e7caf9bc4c53a0939e04d11 100644 (file)
 
 #include "pipe/p_compiler.h"
 #include "util/u_memory.h"
-
-#include "softpipe/sp_public.h"
 #include "state_tracker/drm_api.h"
 #include "state_tracker/sw_winsys.h"
 #include "dri_sw_winsys.h"
 
+#ifdef GALLIUM_SOFTPIPE
+#include "softpipe/sp_public.h"
+#endif
+
+#ifdef GALLIUM_LLVMPIPE
+#include "llvmpipe/lp_public.h"
+#endif
+
 static struct pipe_screen *
 swrast_create_screen(struct drm_api *api,
                      int drmFD,
@@ -57,15 +63,24 @@ swrast_create_screen(struct drm_api *api,
    if (winsys == NULL)
       return NULL;
 
-   screen = softpipe_create_screen( winsys );
-   if (screen == NULL)
+#ifdef GALLIUM_LLVMPIPE
+   if (!screen)
+      screen = llvmpipe_create_screen(winsys);
+#endif
+
+#ifdef GALLIUM_SOFTPIPE
+   if (!screen)
+      screen = softpipe_create_screen(winsys);
+#endif
+
+   if (!screen)
       goto fail;
 
    return screen;
 
 fail:
    if (winsys)
-      winsys->destroy( winsys );
+      winsys->destroy(winsys);
 
    return NULL;
 }