Commit 2f19fecd authored by Keith Whitwell's avatar Keith Whitwell

xlib: allow winsys's to register themselves with glx/xlib state tracker

parent a2d5031b
......@@ -142,8 +142,7 @@ dri_display_surface(__DRIdrawablePrivate *dPriv,
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);
{
......
......@@ -71,6 +71,18 @@
#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
*/
......@@ -756,17 +768,17 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
/* 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;
......@@ -1118,8 +1130,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
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);
......
......@@ -36,22 +36,27 @@ struct pipe_surface;
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
......@@ -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
......
#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
......@@ -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
......@@ -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,
};
......@@ -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
#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
......@@ -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,
};
#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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment