summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-02-08 17:17:43 +0000
committerKeith Whitwell <keithw@vmware.com>2010-02-11 15:16:16 +0000
commit76f8074b54ebd4ae68e2ed31c6ade301603cbda5 (patch)
tree2998a05e4514d5cba517f1d202c70a8a428a91d7
parent0b99303d1c6244094c24844f86f4e7677ee69f18 (diff)
gallium: wip on software api
Will eventually provide an equivalent to the drm_api struct for the software rasterizers. Currently still reliant on the "xmesa_buffer" struct from the glx/x11 state tracker, but that will be removed from the interface by the time this is complete.
-rw-r--r--src/gallium/drivers/trace/Makefile1
-rw-r--r--src/gallium/drivers/trace/SConscript1
-rw-r--r--src/gallium/include/state_tracker/xm_winsys.h (renamed from src/gallium/state_trackers/glx/xlib/xm_winsys.h)17
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c51
-rw-r--r--src/gallium/winsys/xlib/xlib.c52
-rw-r--r--src/gallium/winsys/xlib/xlib.h2
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c25
-rw-r--r--src/gallium/winsys/xlib/xlib_llvmpipe.c7
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c24
9 files changed, 71 insertions, 109 deletions
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile
index dd6831c70a..ab421f0079 100644
--- a/src/gallium/drivers/trace/Makefile
+++ b/src/gallium/drivers/trace/Makefile
@@ -12,6 +12,7 @@ C_SOURCES = \
tr_state.c \
tr_rbug.c \
tr_drm.c \
+ tr_x11.c \
tr_texture.c
include ../../Makefile.template
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index c1675d1c16..f208ae63da 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -8,6 +8,7 @@ trace = env.ConvenienceLibrary(
'tr_buffer.c',
'tr_context.c',
'tr_drm.c',
+ 'tr_x11.c',
'tr_dump.c',
'tr_dump_state.c',
'tr_screen.c',
diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/include/state_tracker/xm_winsys.h
index 4bd5b5c8d3..29969f126e 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h
+++ b/src/gallium/include/state_tracker/xm_winsys.h
@@ -32,21 +32,32 @@
struct pipe_context;
struct pipe_screen;
struct pipe_surface;
+
+
+/* XXX: remove the xmesa_buffer concept from this interface
+ */
struct xmesa_buffer;
struct xm_driver {
- struct pipe_screen *(*create_pipe_screen)( void );
+ struct pipe_screen *(*create_screen)( struct xm_driver *driver );
- void (*display_surface)( struct xmesa_buffer *,
+ void (*display_surface)( struct xm_driver *driver,
+ struct xmesa_buffer *, /* XXX: remove me! */
struct pipe_surface * );
+ void (*destroy)( struct xm_driver *driver );
+
};
+/* Currently called by the driver/winsys to register an xm_driver.
+ * Note that this is the opposite usage to drm_api.h/drm_api_create(),
+ * which is called by the state tracker.
+ */
extern void
-xmesa_set_driver( const struct xm_driver *driver );
+xmesa_set_driver( struct xm_driver *driver );
#endif
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index fb314f3b52..38d4ba5d6c 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -67,11 +67,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#include "trace/tr_texture.h"
-
-#include "xm_winsys.h"
+#include "state_tracker/xm_winsys.h"
#include <GL/glx.h>
@@ -79,11 +75,11 @@
* _init(). These are global in the same way that function names are
* global.
*/
-static struct xm_driver driver;
+static struct xm_driver *driver = NULL;
-void xmesa_set_driver( const struct xm_driver *templ )
+void xmesa_set_driver( struct xm_driver *_driver )
{
- driver = *templ;
+ driver = _driver;
}
/**
@@ -91,7 +87,6 @@ void xmesa_set_driver( const struct xm_driver *templ )
*/
pipe_mutex _xmesa_lock;
-static struct pipe_screen *_screen = NULL;
static struct pipe_screen *screen = NULL;
@@ -748,6 +743,21 @@ void XMesaDestroyVisual( XMesaVisual v )
}
+static void
+xm_flush_frontbuffer(struct pipe_screen *screen,
+ struct pipe_surface *surf,
+ void *context_private)
+{
+ /*
+ * The front color buffer is actually just another XImage buffer.
+ * This function copies that XImage to the actual X Window.
+ */
+ XMesaContext xmctx = (XMesaContext) context_private;
+ xlib_softpipe_display_surface(driver, xmctx->xm_buffer, surf);
+ xmesa_check_and_update_buffer_size(xmctx, xmctx->xm_buffer);
+}
+
+
/**
* Create a new XMesaContext.
@@ -767,8 +777,12 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
if (firstTime) {
pipe_mutex_init(_xmesa_lock);
- _screen = driver.create_pipe_screen();
- screen = trace_screen_create( _screen );
+ screen = driver->create_screen( driver );
+
+ /* Provide our own flush_frontbuffer:
+ */
+ screen->flush_frontbuffer = xm_flush_frontbuffer;
+
firstTime = GL_FALSE;
}
@@ -821,13 +835,6 @@ PUBLIC
void XMesaDestroyContext( XMesaContext c )
{
st_destroy_context(c->st);
-
- /* FIXME: We should destroy the screen here, but if we do so, surfaces may
- * outlive it, causing segfaults
- struct pipe_screen *screen = c->st->pipe->screen;
- screen->destroy(screen);
- */
-
_mesa_free(c);
}
@@ -1119,13 +1126,7 @@ void XMesaSwapBuffers( XMesaBuffer b )
st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
if (frontLeftSurf) {
- if (_screen != screen) {
- struct trace_surface *tr_surf = trace_surface( frontLeftSurf );
- struct pipe_surface *surf = tr_surf->surface;
- frontLeftSurf = surf;
- }
-
- driver.display_surface(b, frontLeftSurf);
+ driver->display_surface(driver, b, frontLeftSurf);
}
xmesa_check_and_update_buffer_size(NULL, b);
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
index 67617a470d..db42212258 100644
--- a/src/gallium/winsys/xlib/xlib.c
+++ b/src/gallium/winsys/xlib/xlib.c
@@ -32,64 +32,36 @@
*/
#include "xlib.h"
-#include "xm_winsys.h"
+#include "trace/tr_x11.h"
#include <stdlib.h>
#include <assert.h>
-/* Todo, replace all this with callback-structs provided by the
- * individual implementations.
- */
-
-enum mode {
- MODE_CELL,
- MODE_LLVMPIPE,
- MODE_SOFTPIPE
-};
/* advertise OpenGL support */
PUBLIC const int st_api_OpenGL = 1;
-static enum mode get_mode()
-{
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL"))
- return MODE_CELL;
-#endif
-
-#if defined(GALLIUM_LLVMPIPE)
- return MODE_LLVMPIPE;
-#else
- return MODE_SOFTPIPE;
-#endif
-}
-
static void _init( void ) __attribute__((constructor));
-
static void _init( void )
{
- enum mode xlib_mode = get_mode();
+ struct xm_driver *driver = NULL;
- switch (xlib_mode) {
- case MODE_CELL:
#if defined(GALLIUM_CELL)
- xmesa_set_driver( &xlib_cell_driver );
+ if (driver == NULL && !getenv("GALLIUM_NOCELL"))
+ driver = &xlib_cell_driver;
#endif
- break;
- case MODE_LLVMPIPE:
+
#if defined(GALLIUM_LLVMPIPE)
- xmesa_set_driver( &xlib_llvmpipe_driver );
+ if (driver == NULL)
+ driver = &xlib_llvmpipe_driver;
#endif
- break;
- case MODE_SOFTPIPE:
+
#if defined(GALLIUM_SOFTPIPE)
- xmesa_set_driver( &xlib_softpipe_driver );
+ if (driver == NULL)
+ driver = &xlib_softpipe_driver;
#endif
- break;
- default:
- assert(0);
- break;
- }
+
+ xmesa_set_driver( trace_xm_create( driver ) );
}
diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h
index 8e091d0c08..a66874ed75 100644
--- a/src/gallium/winsys/xlib/xlib.h
+++ b/src/gallium/winsys/xlib/xlib.h
@@ -3,7 +3,7 @@
#define XLIB_H
#include "pipe/p_compiler.h"
-#include "xm_winsys.h"
+#include "state_tracker/xm_winsys.h"
extern struct xm_driver xlib_softpipe_driver;
extern struct xm_driver xlib_llvmpipe_driver;
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 1dc9e8fa11..701bdfbfd1 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -162,7 +162,9 @@ twiddle_tile(const uint *tileIn, uint *tileOut)
* pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory.
*/
static void
-xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
+xlib_cell_display_surface(struct xm_driver *driver,
+ struct xmesa_buffer *b,
+ struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(
@@ -212,19 +214,6 @@ xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
-static void
-xm_flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *surf,
- void *context_private)
-{
- /*
- * The front color buffer is actually just another XImage buffer.
- * This function copies that XImage to the actual X Window.
- */
- XMesaContext xmctx = (XMesaContext) context_private;
- if (xmctx)
- xlib_cell_display_surface(xmctx->xm_buffer, surf);
-}
@@ -351,7 +340,7 @@ xlib_create_cell_winsys( void )
ws->base.fence_signalled = xm_fence_signalled;
ws->base.fence_finish = xm_fence_finish;
- ws->base.flush_frontbuffer = xm_flush_frontbuffer;
+ ws->base.flush_frontbuffer = NULL;
ws->base.get_name = xm_get_name;
}
@@ -360,7 +349,7 @@ xlib_create_cell_winsys( void )
static struct pipe_screen *
-xlib_create_cell_screen( void )
+xlib_create_cell_screen( struct xm_driver *driver )
{
struct pipe_winsys *winsys;
struct pipe_screen *screen;
@@ -386,7 +375,7 @@ fail:
struct xm_driver xlib_cell_driver =
{
- .create_pipe_screen = xlib_create_cell_screen,
+ .create_screen = xlib_create_cell_screen,
.display_surface = xlib_cell_display_surface,
};
@@ -394,7 +383,7 @@ struct xm_driver xlib_cell_driver =
struct xm_driver xlib_cell_driver =
{
- .create_pipe_screen = NULL,
+ .create_screen = NULL,
.display_surface = NULL,
};
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
index 6cebd4c201..45d397b8c8 100644
--- a/src/gallium/winsys/xlib/xlib_llvmpipe.c
+++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c
@@ -396,7 +396,7 @@ xlib_create_llvmpipe_winsys( void )
static struct pipe_screen *
-xlib_create_llvmpipe_screen( void )
+xlib_create_llvmpipe_screen( struct xm_driver *driver )
{
struct llvmpipe_winsys *winsys;
struct pipe_screen *screen;
@@ -420,7 +420,8 @@ fail:
static void
-xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer,
+xlib_llvmpipe_display_surface(struct xm_driver *driver,
+ struct xmesa_buffer *xm_buffer,
struct pipe_surface *surf)
{
struct llvmpipe_texture *texture = llvmpipe_texture(surf->texture);
@@ -433,7 +434,7 @@ xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer,
struct xm_driver xlib_llvmpipe_driver =
{
- .create_pipe_screen = xlib_create_llvmpipe_screen,
+ .create_screen = xlib_create_llvmpipe_screen,
.display_surface = xlib_llvmpipe_display_surface
};
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index 716338aef4..dd667da1e0 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -249,7 +249,8 @@ xm_buffer_destroy(struct pipe_buffer *buf)
* by the XMesaBuffer.
*/
static void
-xlib_softpipe_display_surface(struct xmesa_buffer *b,
+xlib_softpipe_display_surface(struct xm_driver *driver,
+ struct xmesa_buffer *b,
struct pipe_surface *surf)
{
XImage *ximage;
@@ -307,21 +308,6 @@ xlib_softpipe_display_surface(struct xmesa_buffer *b,
}
-static void
-xm_flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *surf,
- void *context_private)
-{
- /*
- * The front color buffer is actually just another XImage buffer.
- * This function copies that XImage to the actual X Window.
- */
- XMesaContext xmctx = (XMesaContext) context_private;
- xlib_softpipe_display_surface(xmctx->xm_buffer, surf);
- xmesa_check_and_update_buffer_size(xmctx, xmctx->xm_buffer);
-}
-
-
static const char *
xm_get_name(struct pipe_winsys *pws)
@@ -466,7 +452,7 @@ xlib_create_softpipe_winsys( void )
ws->base.fence_signalled = xm_fence_signalled;
ws->base.fence_finish = xm_fence_finish;
- ws->base.flush_frontbuffer = xm_flush_frontbuffer;
+ ws->base.flush_frontbuffer = NULL;
ws->base.get_name = xm_get_name;
}
@@ -475,7 +461,7 @@ xlib_create_softpipe_winsys( void )
static struct pipe_screen *
-xlib_create_softpipe_screen( void )
+xlib_create_softpipe_screen( struct xm_driver *driver )
{
struct pipe_winsys *winsys;
struct pipe_screen *screen;
@@ -500,7 +486,7 @@ fail:
struct xm_driver xlib_softpipe_driver =
{
- .create_pipe_screen = xlib_create_softpipe_screen,
+ .create_screen = xlib_create_softpipe_screen,
.display_surface = xlib_softpipe_display_surface
};