Merge remote branch 'origin/gallium-st-api'
[mesa.git] / src / gallium / targets / libgl-xlib / xlib.c
index 6651bd538eeaff77406dfa21a0d2baf676dc7ab1..eff4b4778bfb3dc1e7cd9917000d42d90c32fb3c 100644 (file)
  * Authors:
  *   Keith Whitwell
  */
-
+#include "pipe/p_compiler.h"
 #include "state_tracker/xlib_sw_winsys.h"
-#include "xm_winsys.h"
 #include "util/u_debug.h"
 #include "softpipe/sp_public.h"
 #include "llvmpipe/lp_public.h"
 #include "cell/ppu/cell_public.h"
+#include "target-helpers/wrap_screen.h"
+#include "xm_public.h"
+
+#include "state_tracker/st_manager.h"
 
 /* advertise OpenGL support */
 PUBLIC const int st_api_OpenGL = 1;
 
+PUBLIC const struct st_module st_module_OpenGL = {
+   .api = ST_API_OPENGL,
+   .create_api = st_manager_create_api
+};
 
+/* Helper function to build a subset of a driver stack consisting of
+ * one of the software rasterizers (cell, llvmpipe, softpipe) and the
+ * xlib winsys.
+ *
+ * This function could be shared, but currently causes headaches for
+ * the build systems, particularly scons if we try.  Long term, want
+ * to avoid having global #defines for things like GALLIUM_LLVMPIPE,
+ * GALLIUM_CELL, etc.  Scons already eliminates those #defines, so
+ * things that are painful for it now are likely to be painful for
+ * other build systems in the future.
+ */
 static struct pipe_screen *
-create_screen( struct sw_winsys *winsys )
+swrast_xlib_create_screen( Display *display )
 {
+   struct sw_winsys *winsys;
+   struct pipe_screen *screen = NULL;
+
+   /* Create the underlying winsys, which performs presents to Xlib
+    * drawables:
+    */
+   winsys = xlib_create_sw_winsys( display );
+   if (winsys == NULL)
+      return NULL;
+
+   /* Create a software rasterizer on top of that winsys:
+    */
 #if defined(GALLIUM_CELL)
-   if (!getenv("GALLIUM_NOCELL")) 
-      return cell_create_screen( winsys );
+   if (screen == NULL &&
+       !debug_get_bool_option("GALLIUM_NO_CELL", FALSE))
+      screen = cell_create_screen( winsys );
 #endif
 
 #if defined(GALLIUM_LLVMPIPE)
-   return llvmpipe_create_screen( winsys );
+   if (screen == NULL &&
+       !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
+      screen = llvmpipe_create_screen( winsys );
 #endif
 
-   return softpipe_create_screen( winsys );
-}
-
-
-
-static struct pipe_screen *
-xlib_create_screen( Display *display )
-{
-   struct sw_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_sw_winsys( display );
-   if (winsys == NULL)
-      return NULL;
+#if defined(GALLIUM_SOFTPIPE)
+   if (screen == NULL)
+      screen = softpipe_create_screen( winsys );
+#endif
 
-   screen = create_screen(winsys);
    if (screen == NULL)
       goto fail;
 
-   return screen;
+   /* Inject any wrapping layers we want to here:
+    */
+   return gallium_wrap_screen( screen );
 
 fail:
    if (winsys)
@@ -82,15 +106,13 @@ fail:
    return NULL;
 }
 
-
-struct xm_driver xlib_driver = 
+static struct xm_driver xlib_driver = 
 {
-   .create_pipe_screen = xlib_create_screen,
+   .create_pipe_screen = swrast_xlib_create_screen,
+   .create_st_api = st_manager_create_api,
 };
 
 
-
-
 /* Build the rendering stack.
  */
 static void _init( void ) __attribute__((constructor));