ws/xlib: remove self-knowledge about users of xlib winsys
authorKeith Whitwell <keithw@vmware.com>
Tue, 9 Mar 2010 15:25:42 +0000 (15:25 +0000)
committerKeith Whitwell <keithw@vmware.com>
Tue, 9 Mar 2010 15:33:21 +0000 (15:33 +0000)
Several software rasterizers can make use of this winsys, but there
isn't any reason why the winsys itself should know about them.

This change moves that information into the libgl-xlib target.

Need to fix up other targets making use of this winsys.

19 files changed:
src/gallium/drivers/cell/ppu/cell_public.h [new file with mode: 0644]
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/cell/ppu/cell_screen.h
src/gallium/drivers/llvmpipe/lp_public.h [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h
src/gallium/drivers/softpipe/sp_public.h [new file with mode: 0644]
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_screen.h
src/gallium/include/state_tracker/xlib_sw_winsys.h
src/gallium/targets/libgl-xlib/xlib.c
src/gallium/winsys/xlib/Makefile
src/gallium/winsys/xlib/SConscript
src/gallium/winsys/xlib/xlib.c [deleted file]
src/gallium/winsys/xlib/xlib.h [deleted file]
src/gallium/winsys/xlib/xlib_cell.c [deleted file]
src/gallium/winsys/xlib/xlib_llvmpipe.c [deleted file]
src/gallium/winsys/xlib/xlib_softpipe.c [deleted file]
src/gallium/winsys/xlib/xlib_sw_winsys.c

diff --git a/src/gallium/drivers/cell/ppu/cell_public.h b/src/gallium/drivers/cell/ppu/cell_public.h
new file mode 100644 (file)
index 0000000..7e2e093
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef CELL_PUBLIC_H
+#define CELL_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+cell_create_screen(struct sw_winsys *winsys);
+
+#endif
index fc04767..31fd963 100644 (file)
@@ -36,6 +36,7 @@
 #include "cell_screen.h"
 #include "cell_texture.h"
 #include "cell_buffer.h"
+#include "cell_public.h"
 
 #include "state_tracker/sw_winsys.h"
 
index 6a22433..baff9d3 100644 (file)
@@ -51,8 +51,5 @@ cell_screen( struct pipe_screen *pipe )
    return (struct cell_screen *)pipe;
 }
 
-extern struct pipe_screen *
-cell_create_screen(struct sw_winsys *winsys);
-
 
 #endif /* CELL_SCREEN_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_public.h b/src/gallium/drivers/llvmpipe/lp_public.h
new file mode 100644 (file)
index 0000000..ec6b660
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef LP_PUBLIC_H
+#define LP_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+llvmpipe_create_screen(struct sw_winsys *winsys);
+
+#endif
index 9bb3043..5093f58 100644 (file)
@@ -38,6 +38,7 @@
 #include "lp_screen.h"
 #include "lp_context.h"
 #include "lp_debug.h"
+#include "lp_public.h"
 
 #include "state_tracker/sw_winsys.h"
 
index 0c86283..f4e62cb 100644 (file)
@@ -76,7 +76,5 @@ llvmpipe_screen( struct pipe_screen *pipe )
 }
 
 
-struct pipe_screen *
-llvmpipe_create_screen(struct sw_winsys *winsys);
 
 #endif /* LP_SCREEN_H */
diff --git a/src/gallium/drivers/softpipe/sp_public.h b/src/gallium/drivers/softpipe/sp_public.h
new file mode 100644 (file)
index 0000000..62d0903
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef SP_PUBLIC_H
+#define SP_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+softpipe_create_screen(struct sw_winsys *winsys);
+
+#endif
index 44680ea..e0a2ef6 100644 (file)
@@ -36,6 +36,7 @@
 #include "sp_screen.h"
 #include "sp_context.h"
 #include "sp_buffer.h"
+#include "sp_public.h"
 
 
 static const char *
index 4d7d8ba..f741454 100644 (file)
@@ -59,12 +59,4 @@ softpipe_screen( struct pipe_screen *pipe )
 
 
 
-/**
- * Create a softpipe screen that uses the
- * given winsys for allocating buffers.
- */
-struct pipe_screen *softpipe_create_screen( struct sw_winsys * );
-
-
-
 #endif /* SP_SCREEN_H */
index 3cb6794..13dc837 100644 (file)
@@ -18,13 +18,17 @@ struct xlib_drawable {
    Drawable drawable;
 };
 
-
+/* This is the interface required by the glx/xlib state tracker.  Why
+ * is it being defined in this file?
+ */
 struct xm_driver {
    struct pipe_screen *(*create_pipe_screen)( Display *display );
 };
 
-/* Called by the libgl-xlib target code to build the rendering stack.
+/* This is the public interface to the ws/xlib module.  Why isn't it
+ * being defined in that directory?
  */
-struct xm_driver *xlib_sw_winsys_init( void );
+struct sw_winsys *xlib_create_sw_winsys( Display *display );
+
 
 #endif
index 7cae088..6651bd5 100644 (file)
 #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"
 
 /* advertise OpenGL support */
 PUBLIC const int st_api_OpenGL = 1;
 
-static void _init( void ) __attribute__((constructor));
+
+static struct pipe_screen *
+create_screen( struct sw_winsys *winsys )
+{
+#if defined(GALLIUM_CELL)
+   if (!getenv("GALLIUM_NOCELL")) 
+      return cell_create_screen( winsys );
+#endif
+
+#if defined(GALLIUM_LLVMPIPE)
+   return 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;
+
+   screen = create_screen(winsys);
+   if (screen == NULL)
+      goto fail;
+
+   return screen;
+
+fail:
+   if (winsys)
+      winsys->destroy( winsys );
+
+   return NULL;
+}
+
+
+struct xm_driver xlib_driver = 
+{
+   .create_pipe_screen = xlib_create_screen,
+};
+
+
+
 
 /* Build the rendering stack.
  */
+static void _init( void ) __attribute__((constructor));
 static void _init( void )
 {
-   struct xm_driver *driver;
-
-   /* Initialize the xlib software winsys.  Later on, once Display and
-    * other parameters are known, this will be used to create the
-    * gallium driver (such as softpipe), etc.
-    */
-   driver = xlib_sw_winsys_init();
-
    /* Initialize the xlib libgl code, pass in the winsys:
     */
-   xmesa_set_driver( driver );
+   xmesa_set_driver( &xlib_driver );
 }
 
 
index bb631b1..68542b4 100644 (file)
@@ -9,11 +9,7 @@ LIBRARY_INCLUDES = \
        -I$(TOP)/src/gallium/auxiliary
 
 C_SOURCES = \
-       xlib.c \
-       xlib_cell.c \
-       xlib_sw_winsys.c \
-       xlib_llvmpipe.c \
-       xlib_softpipe.c
+       xlib_sw_winsys.c 
 
 include ../../Makefile.template
 
index 1a1879f..d4009df 100644 (file)
@@ -18,9 +18,6 @@ if env['platform'] == 'linux' \
     ws_xlib = env.ConvenienceLibrary(
         target = 'ws_xlib',
         source = [
-           'xlib_cell.c',
-           'xlib_llvmpipe.c',
-           'xlib_softpipe.c',
            'xlib_sw_winsys.c',
         ]
     )
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
deleted file mode 100644 (file)
index 6ca9e36..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- */
-
-#include "xlib.h"
-#include "util/u_debug.h"
-
-struct xm_driver *xlib_sw_winsys_init( void )
-{
-#if defined(GALLIUM_CELL)
-   if (!getenv("GALLIUM_NOCELL")) 
-      return &xlib_cell_driver;
-#endif
-
-#if defined(GALLIUM_LLVMPIPE)
-   return &xlib_llvmpipe_driver;
-#endif
-
-   return &xlib_softpipe_driver;
-}
diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h
deleted file mode 100644 (file)
index 3c20048..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-
-#ifndef XLIB_H
-#define XLIB_H
-
-#include "pipe/p_compiler.h"
-#include "state_tracker/xlib_sw_winsys.h"
-
-extern struct xm_driver xlib_softpipe_driver;
-extern struct xm_driver xlib_llvmpipe_driver;
-extern struct xm_driver xlib_cell_driver;
-
-struct sw_winsys *xlib_create_sw_winsys( Display *display );
-
-void xlib_sw_display(struct xlib_drawable *xm_buffer,
-                     struct sw_displaytarget *dt);
-
-
-#endif
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
deleted file mode 100644 (file)
index d943953..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- *   Brian Paul
- */
-
-
-#include "xlib.h"
-
-#if defined(GALLIUM_CELL)
-
-#include "cell/ppu/cell_texture.h"
-#include "cell/ppu/cell_screen.h"
-#include "state_tracker/sw_winsys.h"
-#include "util/u_debug.h"
-
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xm_cell_displaytarget_display(struct sw_winsys *ws,
-                              struct sw_displaytarget *dt,
-                              void *context_private)
-{
-   struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private;
-   xlib_sw_display(xlib_drawable, dt);
-}
-
-
-static struct pipe_screen *
-xlib_create_cell_screen( Display *dpy )
-{
-   struct sw_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_sw_winsys( dpy );
-   if (winsys == NULL)
-      return NULL;
-
-   /* Plug in a little cell-specific code:
-    */
-
-   winsys->displaytarget_display = xm_cell_displaytarget_display;
-
-   screen = cell_create_screen(winsys);
-   if (screen == NULL)
-      goto fail;
-
-   return screen;
-
-fail:
-   if (winsys)
-      winsys->destroy( winsys );
-
-   return NULL;
-}
-
-
-struct xm_driver xlib_cell_driver = 
-{
-   .create_pipe_screen = xlib_create_cell_screen,
-};
-
-
-#endif /* GALLIUM_CELL */
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
deleted file mode 100644 (file)
index 8b66b74..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-/*
- * Authors:
- *   Keith Whitwell
- *   Brian Paul
- */
-
-
-
-
-#include "xlib.h"
-
-
-#if defined(GALLIUM_LLVMPIPE)
-
-#include "llvmpipe/lp_texture.h"
-#include "llvmpipe/lp_screen.h"
-#include "state_tracker/xlib_sw_winsys.h"
-#include "util/u_debug.h"
-
-static struct pipe_screen *
-xlib_create_llvmpipe_screen( Display *display )
-{
-   struct sw_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_sw_winsys( display );
-   if (winsys == NULL)
-      return NULL;
-
-   screen = llvmpipe_create_screen(winsys);
-   if (screen == NULL)
-      goto fail;
-
-   return screen;
-
-fail:
-   if (winsys)
-      winsys->destroy( winsys );
-
-   return NULL;
-}
-
-
-struct xm_driver xlib_llvmpipe_driver = 
-{
-   .create_pipe_screen = xlib_create_llvmpipe_screen,
-};
-
-
-
-#endif /* GALLIUM_LLVMPIPE */
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
deleted file mode 100644 (file)
index 08b7f08..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-
-#include "xlib.h"
-#include "softpipe/sp_texture.h"
-#include "softpipe/sp_screen.h"
-#include "state_tracker/xlib_sw_winsys.h"
-#include "util/u_debug.h"
-
-static struct pipe_screen *
-xlib_create_softpipe_screen( Display *display )
-{
-   struct sw_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_sw_winsys( display );
-   if (winsys == NULL)
-      return NULL;
-
-   screen = softpipe_create_screen(winsys);
-   if (screen == NULL)
-      goto fail;
-
-   return screen;
-
-fail:
-   if (winsys)
-      winsys->destroy( winsys );
-
-   return NULL;
-}
-
-
-
-
-struct xm_driver xlib_softpipe_driver = 
-{
-   .create_pipe_screen = xlib_create_softpipe_screen,
-};
-
-
-
index d03e39a..0ee5899 100644 (file)
@@ -47,8 +47,6 @@
 
 #include "state_tracker/xlib_sw_winsys.h"
 
-#include "xlib.h"
-
 #include <X11/Xlib.h>
 #include <X11/Xlibint.h>
 #include <X11/Xutil.h>
@@ -274,7 +272,7 @@ xm_displaytarget_destroy(struct sw_winsys *ws,
  * Display/copy the image in the surface into the X window specified
  * by the XMesaBuffer.
  */
-void
+static void
 xlib_sw_display(struct xlib_drawable *xlib_drawable,
                 struct sw_displaytarget *dt)
 {