drawable->last_swap_fence = drawable->first_swap_fence;
drawable->first_swap_fence = NULL;
- /* The lock_hardware is required for the cliprects. Buffer offsets
- * should work regardless.
+ /* Call lock_hardware to update dPriv cliprects.
*/
dri_lock_hardware(context, drawable);
{
#include "xm_winsys.h"
#include <GL/glx.h>
+
+/* Driver interface routines, set up by xlib backend on library
+ * _init(). These are global in the same way that function names are
+ * global.
+ */
+static struct xm_driver driver;
+
+void xmesa_set_driver( const struct xm_driver *templ )
+{
+ driver = *templ;
+}
+
/**
* Global X driver lock
*/
/* XXX: create once per Xlib Display.
*/
- winsys = xmesa_create_pipe_winsys();
+ winsys = driver.create_pipe_winsys();
if (winsys == NULL)
goto fail;
/* XXX: create once per Xlib Display.
*/
- screen = xmesa_create_pipe_screen( winsys );
+ screen = driver.create_pipe_screen( winsys );
if (screen == NULL)
goto fail;
- pipe = xmesa_create_pipe_context( screen,
+ pipe = driver.create_pipe_context( screen,
(void *)c );
if (pipe == NULL)
goto fail;
surf = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT);
if (surf) {
- xmesa_display_surface(b, surf);
-// xmesa_display_surface(b, surf);
+ driver.display_surface(b, surf);
}
xmesa_check_and_update_buffer_size(NULL, b);
struct xmesa_buffer;
-/* Will turn this into a callback-style interface. For now, these
- * have fixed names, and are implemented in the winsys/xlib directory.
- */
-struct pipe_winsys *xmesa_create_pipe_winsys( void );
-
-struct pipe_screen *xmesa_create_pipe_screen( struct pipe_winsys * );
-
-/* The context_private argument needs to go away. Is currently used
- * in a round-about way to associate a display-target surface with its
- * Xlib window.
- */
-struct pipe_context *xmesa_create_pipe_context( struct pipe_screen *,
+struct xm_driver {
+
+ struct pipe_winsys *(*create_pipe_winsys)( void );
+
+ struct pipe_screen *(*create_pipe_screen)( struct pipe_winsys * );
+
+ /* The context_private argument needs to go away. Is currently used
+ * in a round-about way to associate a display-target surface with its
+ * Xlib window.
+ */
+ struct pipe_context *(*create_pipe_context)( struct pipe_screen *,
void *context_private );
-void xmesa_display_surface( struct xmesa_buffer *,
+ void (*display_surface)( struct xmesa_buffer *,
struct pipe_surface * );
+};
+
+
+extern void
+xmesa_set_driver( const struct xm_driver *driver );
+
#endif
* Keith Whitwell
*/
-#include "xlib_trace.h"
-#include "xlib_softpipe.h"
-#include "xlib_brw.h"
+#include "xlib.h"
#include "xm_winsys.h"
#include <stdlib.h>
MODE_SOFTPIPE
};
-static enum mode xlib_mode;
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);
}
}
-
-
/***********************************************************************
*
* Butt-ugly hack to convince the linker not to throw away public GL
--- /dev/null
+
+#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
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 );
unsigned *cmds,
unsigned nr_dwords);
+struct pipe_context *
+xlib_create_brw_context( struct pipe_screen *screen,
+ void *unused );
+
#endif
#include "xlib_brw_aub.h"
#include "xlib_brw.h"
+#include "xlib.h"
-struct pipe_winsys *
+static struct pipe_winsys *
xlib_create_brw_winsys( void )
{
struct aub_pipe_winsys *iws = CALLOC_STRUCT( aub_pipe_winsys );
}
-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
}
}
-void
+static void
xlib_brw_display_surface(struct xmesa_buffer *b,
struct pipe_surface *surf)
{
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,
+};
#define TILE_SIZE 32 /* avoid compilation errors */
#endif
-#include "xlib_softpipe.h"
+#include "xlib.h"
/**
* Subclass of pipe_buffer for Xlib winsys.
* 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;
* 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)
{
-struct pipe_winsys *
+static struct pipe_winsys *
xlib_create_softpipe_winsys( void )
{
static struct xmesa_pipe_winsys *ws = NULL;
}
-struct pipe_screen *
+static struct pipe_screen *
xlib_create_softpipe_screen( struct pipe_winsys *pws )
{
struct pipe_screen *screen;
}
-struct pipe_context *
+static struct pipe_context *
xlib_create_softpipe_context( struct pipe_screen *screen,
void *context_private )
{
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.
* 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;
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
+
+
+++ /dev/null
-
-#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
*/
-#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;
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;
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,
+};
+++ /dev/null
-
-#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