diff options
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/xlib/xlib.c | 77 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib.h | 13 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_brw.h | 18 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_brw_screen.c | 20 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_softpipe.c | 55 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_softpipe.h | 50 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_trace.c | 28 | ||||
-rw-r--r-- | src/gallium/winsys/xlib/xlib_trace.h | 26 |
8 files changed, 96 insertions, 191 deletions
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c index 8d4d734b036..e5f8048b6a8 100644 --- a/src/gallium/winsys/xlib/xlib.c +++ b/src/gallium/winsys/xlib/xlib.c @@ -31,9 +31,7 @@ * Keith Whitwell */ -#include "xlib_trace.h" -#include "xlib_softpipe.h" -#include "xlib_brw.h" +#include "xlib.h" #include "xm_winsys.h" #include <stdlib.h> @@ -50,7 +48,6 @@ enum mode { MODE_SOFTPIPE }; -static enum mode xlib_mode; static enum mode get_mode() { @@ -68,80 +65,24 @@ static enum mode get_mode() return MODE_SOFTPIPE; } +static void _init( void ) __attribute__((constructor)); -struct pipe_winsys * -xmesa_create_pipe_winsys( void ) +static void _init( void ) { - xlib_mode = get_mode(); + enum mode xlib_mode = get_mode(); switch (xlib_mode) { case MODE_TRACE: - return xlib_create_trace_winsys(); - case MODE_BRW: - return xlib_create_brw_winsys(); - case MODE_CELL: - return xlib_create_cell_winsys(); - case MODE_SOFTPIPE: - return xlib_create_softpipe_winsys(); - default: - assert(0); - return NULL; - } -} - -struct pipe_screen * -xmesa_create_pipe_screen( struct pipe_winsys *winsys ) -{ - switch (xlib_mode) { - case MODE_TRACE: - return xlib_create_trace_screen( winsys ); - case MODE_BRW: - return xlib_create_brw_screen( winsys ); - case MODE_CELL: - return xlib_create_cell_screen( winsys ); - case MODE_SOFTPIPE: - return xlib_create_softpipe_screen( winsys ); - default: - assert(0); - return NULL; - } -} - -struct pipe_context * -xmesa_create_pipe_context( struct pipe_screen *screen, - void *priv ) -{ - switch (xlib_mode) { - case MODE_TRACE: - return xlib_create_trace_context( screen, priv ); - case MODE_BRW: - return xlib_create_brw_context( screen, priv ); - case MODE_CELL: - return xlib_create_cell_context( screen, priv ); - case MODE_SOFTPIPE: - return xlib_create_softpipe_context( screen, priv ); - default: - assert(0); - return NULL; - } -} - -void -xmesa_display_surface( struct xmesa_buffer *buffer, - struct pipe_surface *surf ) -{ - switch (xlib_mode) { - case MODE_TRACE: - xlib_trace_display_surface( buffer, surf ); + xmesa_set_driver( &xlib_trace_driver ); break; case MODE_BRW: - xlib_brw_display_surface( buffer, surf ); + xmesa_set_driver( &xlib_brw_driver ); break; case MODE_CELL: - xlib_cell_display_surface( buffer, surf ); + xmesa_set_driver( &xlib_cell_driver ); break; case MODE_SOFTPIPE: - xlib_softpipe_display_surface( buffer, surf ); + xmesa_set_driver( &xlib_softpipe_driver ); break; default: assert(0); @@ -149,8 +90,6 @@ xmesa_display_surface( struct xmesa_buffer *buffer, } } - - /*********************************************************************** * * Butt-ugly hack to convince the linker not to throw away public GL diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h new file mode 100644 index 00000000000..9e47f23be50 --- /dev/null +++ b/src/gallium/winsys/xlib/xlib.h @@ -0,0 +1,13 @@ + +#ifndef XLIB_H +#define XLIB_H + +#include "xm_winsys.h" + +extern struct xm_driver xlib_trace_driver; +extern struct xm_driver xlib_softpipe_driver; +extern struct xm_driver xlib_cell_driver; +extern struct xm_driver xlib_brw_driver; + + +#endif diff --git a/src/gallium/winsys/xlib/xlib_brw.h b/src/gallium/winsys/xlib/xlib_brw.h index aad3f229bf6..be2dd147dbe 100644 --- a/src/gallium/winsys/xlib/xlib_brw.h +++ b/src/gallium/winsys/xlib/xlib_brw.h @@ -6,20 +6,6 @@ struct pipe_buffer; struct pipe_surface; struct xmesa_buffer; -struct pipe_winsys *xlib_create_brw_winsys( void ); - -struct pipe_screen *xlib_create_brw_screen( struct pipe_winsys * ); - -struct pipe_context *xlib_create_brw_context( struct pipe_screen *, - void *priv ); - -void xlib_brw_display_surface(struct xmesa_buffer *b, - struct pipe_surface *surf); - -/*********************************************************************** - * Internal functions - */ - unsigned xlib_brw_get_buffer_offset( struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned access_flags ); @@ -37,4 +23,8 @@ void xlib_brw_commands_aub(struct pipe_winsys *winsys, unsigned *cmds, unsigned nr_dwords); +struct pipe_context * +xlib_create_brw_context( struct pipe_screen *screen, + void *unused ); + #endif diff --git a/src/gallium/winsys/xlib/xlib_brw_screen.c b/src/gallium/winsys/xlib/xlib_brw_screen.c index 9325bdc7a68..1e4c2f6c411 100644 --- a/src/gallium/winsys/xlib/xlib_brw_screen.c +++ b/src/gallium/winsys/xlib/xlib_brw_screen.c @@ -45,6 +45,7 @@ #include "xlib_brw_aub.h" #include "xlib_brw.h" +#include "xlib.h" @@ -311,7 +312,7 @@ xlib_brw_destroy_pipe_winsys_aub( struct pipe_winsys *winsys ) -struct pipe_winsys * +static struct pipe_winsys * xlib_create_brw_winsys( void ) { struct aub_pipe_winsys *iws = CALLOC_STRUCT( aub_pipe_winsys ); @@ -349,14 +350,10 @@ xlib_create_brw_winsys( void ) } -struct pipe_screen * +static struct pipe_screen * xlib_create_brw_screen( struct pipe_winsys *winsys ) { -#ifdef GALLIUM_CELL - return NULL; -#else return brw_create_screen(winsys, 0/* XXX pci_id */); -#endif } @@ -464,7 +461,7 @@ void xlib_brw_buffer_subdata_typed( struct pipe_winsys *pws, } -void +static void xlib_brw_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) { @@ -472,3 +469,12 @@ xlib_brw_display_surface(struct xmesa_buffer *b, surf, aub_bo(surf->buffer)->offset ); } + + +struct xm_driver xlib_brw_driver = +{ + .create_pipe_winsys = xlib_create_brw_winsys, + .create_pipe_screen = xlib_create_brw_screen, + .create_pipe_context = xlib_create_brw_context, + .display_surface = xlib_brw_display_surface, +}; diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 2a8bd4681e6..7ad73be2608 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -54,7 +54,7 @@ #define TILE_SIZE 32 /* avoid compilation errors */ #endif -#include "xlib_softpipe.h" +#include "xlib.h" /** * Subclass of pipe_buffer for Xlib winsys. @@ -303,7 +303,7 @@ twiddle_tile(const uint *tileIn, uint *tileOut) * Display a surface that's in a tiled configuration. That is, all the * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory. */ -void +static void xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) { XImage *ximage; @@ -374,7 +374,7 @@ xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) * Display/copy the image in the surface into the X window specified * by the XMesaBuffer. */ -void +static void xlib_softpipe_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) { @@ -620,7 +620,7 @@ xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, -struct pipe_winsys * +static struct pipe_winsys * xlib_create_softpipe_winsys( void ) { static struct xmesa_pipe_winsys *ws = NULL; @@ -655,7 +655,7 @@ xlib_create_softpipe_winsys( void ) } -struct pipe_screen * +static struct pipe_screen * xlib_create_softpipe_screen( struct pipe_winsys *pws ) { struct pipe_screen *screen; @@ -671,7 +671,7 @@ fail: } -struct pipe_context * +static struct pipe_context * xlib_create_softpipe_context( struct pipe_screen *screen, void *context_private ) { @@ -689,6 +689,14 @@ fail: return NULL; } +struct xm_driver xlib_softpipe_driver = +{ + .create_pipe_winsys = xlib_create_softpipe_winsys, + .create_pipe_screen = xlib_create_softpipe_screen, + .create_pipe_context = xlib_create_softpipe_context, + .display_surface = xlib_softpipe_display_surface +}; + /*********************************************************************** * Cell piggybacks on softpipe code still. @@ -698,28 +706,25 @@ fail: * and creating cell-specific versions of either those functions or * the entire file. */ -struct pipe_winsys * +#ifdef GALLIUM_CELL + +static struct pipe_winsys * xlib_create_cell_winsys( void ) { return xlib_create_softpipe_winsys(); } -struct pipe_screen * +static struct pipe_screen * xlib_create_cell_screen( struct pipe_winsys *pws ) { -#ifdef GALLIUM_CELL return cell_create_screen( pws ); -#else - return NULL; -#endif } -struct pipe_context * +static struct pipe_context * xlib_create_cell_context( struct pipe_screen *screen, void *priv ) { -#ifdef GALLIUM_CELL struct cell_winsys *cws; struct pipe_context *pipe; @@ -742,6 +747,26 @@ xlib_create_cell_context( struct pipe_screen *screen, return pipe; fail: -#endif return NULL; } +#endif + +#if defined(GALLIUM_CELL) +struct xm_driver xlib_cell_driver = +{ + .create_pipe_winsys = xlib_create_cell_winsys, + .create_pipe_screen = xlib_create_cell_screen, + .create_pipe_context = xlib_create_cell_context, + .display_surface = xlib_cell_display_surface, +}; +#else +struct xm_driver xlib_cell_driver = +{ + .create_pipe_winsys = xlib_create_softpipe_winsys, + .create_pipe_screen = xlib_create_softpipe_screen, + .create_pipe_context = xlib_create_softpipe_context, + .display_surface = xlib_softpipe_display_surface, +}; +#endif + + diff --git a/src/gallium/winsys/xlib/xlib_softpipe.h b/src/gallium/winsys/xlib/xlib_softpipe.h deleted file mode 100644 index 0de96cc4c6b..00000000000 --- a/src/gallium/winsys/xlib/xlib_softpipe.h +++ /dev/null @@ -1,50 +0,0 @@ - -#ifndef XLIB_SOFTPIPE_H -#define XLIB_SOFTPIPE_H - -struct pipe_winsys; -struct pipe_screen; -struct pipe_context; -struct pipe_surface; -struct xmesa_buffer; - - -struct pipe_winsys * -xlib_create_softpipe_winsys( void ); - -struct pipe_screen * -xlib_create_softpipe_screen( struct pipe_winsys *pws ); - -struct pipe_context * -xlib_create_softpipe_context( struct pipe_screen *screen, - void *context_priv ); - -void -xlib_softpipe_display_surface( struct xmesa_buffer *, - struct pipe_surface * ); - -/*********************************************************************** - * Cell piggybacks on softpipe code still. - * - * Should be untangled sufficiently to live in a separate file, at - * least. That would mean removing #ifdef GALLIUM_CELL's from above - * and creating cell-specific versions of either those functions or - * the entire file. - */ -struct pipe_winsys * -xlib_create_cell_winsys( void ); - -struct pipe_screen * -xlib_create_cell_screen( struct pipe_winsys *pws ); - - -struct pipe_context * -xlib_create_cell_context( struct pipe_screen *screen, - void *priv ); - -void -xlib_cell_display_surface( struct xmesa_buffer *, - struct pipe_surface * ); - - -#endif diff --git a/src/gallium/winsys/xlib/xlib_trace.c b/src/gallium/winsys/xlib/xlib_trace.c index 45afba7a474..1b8d3f8a115 100644 --- a/src/gallium/winsys/xlib/xlib_trace.c +++ b/src/gallium/winsys/xlib/xlib_trace.c @@ -33,25 +33,24 @@ */ -#include "xlib_softpipe.h" -#include "xlib_trace.h" +#include "xlib.h" #include "trace/tr_screen.h" #include "trace/tr_context.h" -struct pipe_winsys * +static struct pipe_winsys * xlib_create_trace_winsys( void ) { - return xlib_create_softpipe_winsys(); + return xlib_softpipe_driver.create_pipe_winsys(); } -struct pipe_screen * +static struct pipe_screen * xlib_create_trace_screen( struct pipe_winsys *winsys ) { struct pipe_screen *screen, *trace_screen; - screen = xlib_create_softpipe_screen( winsys ); + screen = xlib_softpipe_driver.create_pipe_screen( winsys ); if (screen == NULL) goto fail; @@ -68,13 +67,13 @@ fail: return NULL; } -struct pipe_context * +static struct pipe_context * xlib_create_trace_context( struct pipe_screen *screen, void *priv ) { struct pipe_context *pipe, *trace_pipe; - pipe = xlib_create_softpipe_context( screen, priv ); + pipe = xlib_softpipe_driver.create_pipe_context( screen, priv ); if (pipe == NULL) goto fail; @@ -92,11 +91,20 @@ fail: return NULL; } -void +static void xlib_trace_display_surface( struct xmesa_buffer *buffer, struct pipe_surface *surf ) { /* ?? */ - xlib_softpipe_display_surface( buffer, surf ); + xlib_softpipe_driver.display_surface( buffer, surf ); } + + +struct xm_driver xlib_trace_driver = +{ + .create_pipe_winsys = xlib_create_trace_winsys, + .create_pipe_screen = xlib_create_trace_screen, + .create_pipe_context = xlib_create_trace_context, + .display_surface = xlib_trace_display_surface, +}; diff --git a/src/gallium/winsys/xlib/xlib_trace.h b/src/gallium/winsys/xlib/xlib_trace.h deleted file mode 100644 index c79c0fe34de..00000000000 --- a/src/gallium/winsys/xlib/xlib_trace.h +++ /dev/null @@ -1,26 +0,0 @@ - -#ifndef XLIB_TRACE_H -#define XLIB_TRACE_H - -struct pipe_winsys; -struct pipe_screen; -struct pipe_context; -struct pipe_surface; -struct xmesa_buffer; - -struct pipe_winsys * -xlib_create_trace_winsys( void ); - -struct pipe_screen * -xlib_create_trace_screen( struct pipe_winsys *winsys ); - -struct pipe_context * -xlib_create_trace_context( struct pipe_screen *screen, - void *priv ); - -void -xlib_trace_display_surface( struct xmesa_buffer *buffer, - struct pipe_surface *surf ); - - -#endif |