summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gallium/Makefile2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_winsys.c40
-rw-r--r--src/gallium/drivers/trace/Makefile18
-rw-r--r--src/gallium/state_trackers/Makefile25
-rw-r--r--src/gallium/state_trackers/xlib/Makefile25
-rw-r--r--src/gallium/state_trackers/xlib/fakeglx.c (renamed from src/gallium/winsys/xlib/fakeglx.c)0
-rw-r--r--src/gallium/state_trackers/xlib/glxapi.c (renamed from src/gallium/winsys/xlib/glxapi.c)0
-rw-r--r--src/gallium/state_trackers/xlib/glxapi.h (renamed from src/gallium/winsys/xlib/glxapi.h)0
-rw-r--r--src/gallium/state_trackers/xlib/glxheader.h (renamed from src/gallium/winsys/xlib/glxheader.h)0
-rw-r--r--src/gallium/state_trackers/xlib/realglx.c (renamed from src/gallium/winsys/xlib/realglx.c)0
-rw-r--r--src/gallium/state_trackers/xlib/realglx.h (renamed from src/gallium/winsys/xlib/realglx.h)0
-rw-r--r--src/gallium/state_trackers/xlib/xfonts.c (renamed from src/gallium/winsys/xlib/xfonts.c)0
-rw-r--r--src/gallium/state_trackers/xlib/xfonts.h (renamed from src/gallium/winsys/xlib/xfonts.h)0
-rw-r--r--src/gallium/state_trackers/xlib/xm_api.c (renamed from src/gallium/winsys/xlib/xm_api.c)50
-rw-r--r--src/gallium/state_trackers/xlib/xm_image.c (renamed from src/gallium/winsys/xlib/xm_image.c)0
-rw-r--r--src/gallium/state_trackers/xlib/xm_image.h (renamed from src/gallium/winsys/xlib/xm_image.h)0
-rw-r--r--src/gallium/state_trackers/xlib/xm_winsys.h (renamed from src/gallium/winsys/xlib/xm_winsys_aub.h)47
-rw-r--r--src/gallium/state_trackers/xlib/xmesaP.h (renamed from src/gallium/winsys/xlib/xmesaP.h)12
-rw-r--r--src/gallium/winsys/xlib/Makefile16
-rw-r--r--src/gallium/winsys/xlib/xlib.c165
-rw-r--r--src/gallium/winsys/xlib/xlib_brw.h40
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_aub.c (renamed from src/gallium/winsys/xlib/brw_aub.c)2
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_aub.h (renamed from src/gallium/winsys/xlib/brw_aub.h)0
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_context.c205
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_screen.c (renamed from src/gallium/winsys/xlib/xm_winsys_aub.c)246
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c (renamed from src/gallium/winsys/xlib/xm_winsys.c)159
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.h50
-rw-r--r--src/gallium/winsys/xlib/xlib_trace.c102
-rw-r--r--src/gallium/winsys/xlib/xlib_trace.h26
29 files changed, 872 insertions, 358 deletions
diff --git a/src/gallium/Makefile b/src/gallium/Makefile
index 36bd3623e7..c7b594d084 100644
--- a/src/gallium/Makefile
+++ b/src/gallium/Makefile
@@ -2,7 +2,7 @@ TOP = ../..
include $(TOP)/configs/current
-SUBDIRS = auxiliary drivers
+SUBDIRS = auxiliary drivers state_trackers
# Note winsys/ needs to be built after src/mesa
diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.c b/src/gallium/drivers/cell/ppu/cell_winsys.c
deleted file mode 100644
index d570bbd2f9..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_winsys.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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 above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * 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 TUNGSTEN GRAPHICS 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.
- *
- **************************************************************************/
-
-
-#include "util/u_memory.h"
-#include "cell_winsys.h"
-
-
-struct cell_winsys *
-cell_get_winsys(uint format)
-{
- struct cell_winsys *cws = CALLOC_STRUCT(cell_winsys);
- if (cws)
- cws->preferredFormat = format;
- return cws;
-}
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile
new file mode 100644
index 0000000000..3859b8acb0
--- /dev/null
+++ b/src/gallium/drivers/trace/Makefile
@@ -0,0 +1,18 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = trace
+
+C_SOURCES = \
+ tr_context.c \
+ tr_dump.c \
+ tr_screen.c \
+ tr_state.c \
+ tr_texture.c \
+ tr_winsys.c
+
+
+include ../../Makefile.template
+
+symlinks:
+
diff --git a/src/gallium/state_trackers/Makefile b/src/gallium/state_trackers/Makefile
new file mode 100644
index 0000000000..7e8cc03854
--- /dev/null
+++ b/src/gallium/state_trackers/Makefile
@@ -0,0 +1,25 @@
+TOP = ../../..
+include $(TOP)/configs/current
+
+
+SUBDIRS = xlib
+
+
+default: subdirs
+
+
+subdirs:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE)) || exit 1 ; \
+ fi \
+ done
+
+
+clean:
+ rm -f `find . -name \*.[oa]`
+ rm -f `find . -name depend`
+
+
+# Dummy install target
+install:
diff --git a/src/gallium/state_trackers/xlib/Makefile b/src/gallium/state_trackers/xlib/Makefile
new file mode 100644
index 0000000000..55e025653d
--- /dev/null
+++ b/src/gallium/state_trackers/xlib/Makefile
@@ -0,0 +1,25 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = xlib
+
+
+DRIVER_INCLUDES = \
+ -I$(TOP)/include \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/gallium/include \
+ -I$(TOP)/src/gallium/drivers \
+ -I$(TOP)/src/gallium/auxiliary
+
+C_SOURCES = \
+ glxapi.c \
+ fakeglx.c \
+ xfonts.c \
+ xm_api.c
+
+
+include ../../Makefile.template
+
+symlinks:
+
diff --git a/src/gallium/winsys/xlib/fakeglx.c b/src/gallium/state_trackers/xlib/fakeglx.c
index fd2d222c85..fd2d222c85 100644
--- a/src/gallium/winsys/xlib/fakeglx.c
+++ b/src/gallium/state_trackers/xlib/fakeglx.c
diff --git a/src/gallium/winsys/xlib/glxapi.c b/src/gallium/state_trackers/xlib/glxapi.c
index c059fc3edb..c059fc3edb 100644
--- a/src/gallium/winsys/xlib/glxapi.c
+++ b/src/gallium/state_trackers/xlib/glxapi.c
diff --git a/src/gallium/winsys/xlib/glxapi.h b/src/gallium/state_trackers/xlib/glxapi.h
index 37de81e55a..37de81e55a 100644
--- a/src/gallium/winsys/xlib/glxapi.h
+++ b/src/gallium/state_trackers/xlib/glxapi.h
diff --git a/src/gallium/winsys/xlib/glxheader.h b/src/gallium/state_trackers/xlib/glxheader.h
index a402191f13..a402191f13 100644
--- a/src/gallium/winsys/xlib/glxheader.h
+++ b/src/gallium/state_trackers/xlib/glxheader.h
diff --git a/src/gallium/winsys/xlib/realglx.c b/src/gallium/state_trackers/xlib/realglx.c
index 30adb7465b..30adb7465b 100644
--- a/src/gallium/winsys/xlib/realglx.c
+++ b/src/gallium/state_trackers/xlib/realglx.c
diff --git a/src/gallium/winsys/xlib/realglx.h b/src/gallium/state_trackers/xlib/realglx.h
index 150129db68..150129db68 100644
--- a/src/gallium/winsys/xlib/realglx.h
+++ b/src/gallium/state_trackers/xlib/realglx.h
diff --git a/src/gallium/winsys/xlib/xfonts.c b/src/gallium/state_trackers/xlib/xfonts.c
index d72c600bd1..d72c600bd1 100644
--- a/src/gallium/winsys/xlib/xfonts.c
+++ b/src/gallium/state_trackers/xlib/xfonts.c
diff --git a/src/gallium/winsys/xlib/xfonts.h b/src/gallium/state_trackers/xlib/xfonts.h
index e36f42f817..e36f42f817 100644
--- a/src/gallium/winsys/xlib/xfonts.h
+++ b/src/gallium/state_trackers/xlib/xfonts.h
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/state_trackers/xlib/xm_api.c
index d28a6423b9..a70741feda 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/state_trackers/xlib/xm_api.c
@@ -67,9 +67,10 @@
#include "state_tracker/st_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
+#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
-#include "xm_winsys_aub.h"
+#include "xm_winsys.h"
/**
* Global X driver lock
@@ -77,8 +78,6 @@
pipe_mutex _xmesa_lock;
-int xmesa_mode;
-
/**********************************************************************/
/***** X Utility Functions *****/
@@ -777,6 +776,8 @@ PUBLIC
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
static GLboolean firstTime = GL_TRUE;
+ struct pipe_winsys *winsys;
+ struct pipe_screen *screen;
struct pipe_context *pipe;
XMesaContext c;
GLcontext *mesaCtx;
@@ -797,24 +798,30 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
c->xm_visual = v;
c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
+
+ /* XXX: create once per Xlib Display.
+ */
+ winsys = xmesa_create_pipe_winsys();
+ if (winsys == NULL)
+ goto fail;
- if (!getenv("XM_AUB")) {
- xmesa_mode = XMESA_SOFTPIPE;
- pipe = xmesa_create_pipe_context( c, pf );
- }
- else {
- xmesa_mode = XMESA_AUB;
- pipe = xmesa_create_i965simple(xmesa_get_pipe_winsys_aub(v));
- }
+ /* XXX: create once per Xlib Display.
+ */
+ screen = xmesa_create_pipe_screen( winsys );
+ if (screen == NULL)
+ goto fail;
+ pipe = xmesa_create_pipe_context( screen,
+ (void *)c );
if (pipe == NULL)
goto fail;
- c->st = st_create_context(pipe, &v->mesa_visual,
+ c->st = st_create_context(pipe,
+ &v->mesa_visual,
share_list ? share_list->st : NULL);
if (c->st == NULL)
goto fail;
-
+
mesaCtx = c->st->ctx;
c->st->ctx->DriverCtx = c;
@@ -840,6 +847,13 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
st_destroy_context(c->st);
else if (pipe)
pipe->destroy(pipe);
+
+ if (screen)
+ screen->destroy( screen );
+
+ if (winsys)
+ winsys->destroy( winsys );
+
FREE(c);
return NULL;
}
@@ -849,12 +863,14 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
PUBLIC
void XMesaDestroyContext( XMesaContext c )
{
- struct pipe_screen *screen = c->st->pipe->screen;
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);
}
@@ -1244,10 +1260,8 @@ void XMesaSwapBuffers( XMesaBuffer b )
surf = st_get_framebuffer_surface(b->stfb, ST_SURFACE_BACK_LEFT);
if (surf) {
- if (xmesa_mode == XMESA_AUB)
- xmesa_display_aub( surf );
- else
- xmesa_display_surface(b, surf);
+ xmesa_display_surface(b, surf);
+// xmesa_display_surface(b, surf);
}
xmesa_check_and_update_buffer_size(NULL, b);
diff --git a/src/gallium/winsys/xlib/xm_image.c b/src/gallium/state_trackers/xlib/xm_image.c
index 087b4e4c3a..087b4e4c3a 100644
--- a/src/gallium/winsys/xlib/xm_image.c
+++ b/src/gallium/state_trackers/xlib/xm_image.c
diff --git a/src/gallium/winsys/xlib/xm_image.h b/src/gallium/state_trackers/xlib/xm_image.h
index 2a5e0f3777..2a5e0f3777 100644
--- a/src/gallium/winsys/xlib/xm_image.h
+++ b/src/gallium/state_trackers/xlib/xm_image.h
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.h b/src/gallium/state_trackers/xlib/xm_winsys.h
index cc2a755277..b22d65a569 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.h
+++ b/src/gallium/state_trackers/xlib/xm_winsys.h
@@ -1,3 +1,4 @@
+
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
@@ -25,44 +26,32 @@
*
**************************************************************************/
-#ifndef AUB_WINSYS_H
-#define AUB_WINSYS_H
+#ifndef XM_WINSYS_H
+#define XM_WINSYS_H
struct pipe_context;
+struct pipe_screen;
struct pipe_winsys;
-struct pipe_buffer;
struct pipe_surface;
-
-struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void );
-
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys );
-
-
-
-struct pipe_context *
-xmesa_create_i965simple( struct pipe_winsys *winsys );
-
+struct xmesa_buffer;
-void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned aub_type,
- unsigned aub_sub_type);
+/* 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 );
-void xmesa_commands_aub(struct pipe_winsys *winsys,
- unsigned *cmds,
- unsigned nr_dwords);
+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 *,
+ void *context_private );
-void xmesa_display_aub( /* struct pipe_winsys *winsys, */
- struct pipe_surface *surface );
+void xmesa_display_surface( struct xmesa_buffer *,
+ struct pipe_surface * );
-extern struct pipe_winsys *
-xmesa_get_pipe_winsys_aub(struct xmesa_visual *xm_vis);
#endif
diff --git a/src/gallium/winsys/xlib/xmesaP.h b/src/gallium/state_trackers/xlib/xmesaP.h
index fcaeee52bc..216881a157 100644
--- a/src/gallium/winsys/xlib/xmesaP.h
+++ b/src/gallium/state_trackers/xlib/xmesaP.h
@@ -42,12 +42,6 @@ extern pipe_mutex _xmesa_lock;
extern XMesaBuffer XMesaBufferList;
-/*
- */
-#define XMESA_SOFTPIPE 1
-#define XMESA_AUB 2
-extern int xmesa_mode;
-
/**
* Visual inforation, derived from GLvisual.
@@ -156,9 +150,6 @@ xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
extern void
xmesa_destroy_buffers_on_display(XMesaDisplay *dpy);
-extern struct pipe_context *
-xmesa_create_pipe_context(XMesaContext xm, uint pixelformat);
-
static INLINE GLuint
xmesa_buffer_width(XMesaBuffer b)
{
@@ -171,9 +162,6 @@ xmesa_buffer_height(XMesaBuffer b)
return b->stfb->Base.Height;
}
-extern void
-xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf);
-
extern int
xmesa_check_for_xshm(XMesaDisplay *display);
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
index 11c7632411..129d038d4f 100644
--- a/src/gallium/winsys/xlib/Makefile
+++ b/src/gallium/winsys/xlib/Makefile
@@ -19,16 +19,17 @@ INCLUDE_DIRS = \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/drivers \
+ -I$(TOP)/src/gallium/state_trackers/xlib \
-I$(TOP)/src/gallium/auxiliary
XLIB_WINSYS_SOURCES = \
- glxapi.c \
- fakeglx.c \
- xfonts.c \
- xm_api.c \
- xm_winsys.c \
- xm_winsys_aub.c \
- brw_aub.c
+ xlib.c \
+ xlib_brw_aub.c \
+ xlib_brw_context.c \
+ xlib_brw_screen.c \
+ xlib_softpipe.c \
+ xlib_trace.c
+
XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
@@ -63,6 +64,7 @@ $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS)
-major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
-install $(TOP)/$(LIB_DIR) \
$(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
+ $(TOP)/src/gallium/state_trackers/xlib/*.o \
--start-group $(LIBS) --end-group $(GL_LIB_DEPS)
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
new file mode 100644
index 0000000000..8d4d734b03
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib.c
@@ -0,0 +1,165 @@
+/**************************************************************************
+ *
+ * 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_trace.h"
+#include "xlib_softpipe.h"
+#include "xlib_brw.h"
+#include "xm_winsys.h"
+
+#include <stdlib.h>
+#include <assert.h>
+
+/* Todo, replace all this with callback-structs provided by the
+ * individual implementations.
+ */
+
+enum mode {
+ MODE_TRACE,
+ MODE_BRW,
+ MODE_CELL,
+ MODE_SOFTPIPE
+};
+
+static enum mode xlib_mode;
+
+static enum mode get_mode()
+{
+ if (getenv("XMESA_TRACE"))
+ return MODE_TRACE;
+
+ if (getenv("XMESA_BRW"))
+ return MODE_BRW;
+
+#ifdef GALLIUM_CELL
+ if (!getenv("GALLIUM_NOCELL"))
+ return MODE_CELL;
+#endif
+
+ return MODE_SOFTPIPE;
+}
+
+
+struct pipe_winsys *
+xmesa_create_pipe_winsys( void )
+{
+ 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 );
+ break;
+ case MODE_BRW:
+ xlib_brw_display_surface( buffer, surf );
+ break;
+ case MODE_CELL:
+ xlib_cell_display_surface( buffer, surf );
+ break;
+ case MODE_SOFTPIPE:
+ xlib_softpipe_display_surface( buffer, surf );
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+
+/***********************************************************************
+ *
+ * Butt-ugly hack to convince the linker not to throw away public GL
+ * symbols (they are all referenced from getprocaddress, I guess).
+ */
+extern void (*linker_foo(const unsigned char *procName))();
+extern void (*glXGetProcAddress(const unsigned char *procName))();
+
+extern void (*linker_foo(const unsigned char *procName))()
+{
+ return glXGetProcAddress(procName);
+}
diff --git a/src/gallium/winsys/xlib/xlib_brw.h b/src/gallium/winsys/xlib/xlib_brw.h
new file mode 100644
index 0000000000..aad3f229bf
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_brw.h
@@ -0,0 +1,40 @@
+#ifndef XLIB_BRW_H
+#define XLIB_BRW_H
+
+struct pipe_winsys;
+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 );
+
+void xlib_brw_buffer_subdata_typed( struct pipe_winsys *pws,
+ struct pipe_buffer *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data,
+ unsigned data_type );
+
+
+
+void xlib_brw_commands_aub(struct pipe_winsys *winsys,
+ unsigned *cmds,
+ unsigned nr_dwords);
+
+#endif
diff --git a/src/gallium/winsys/xlib/brw_aub.c b/src/gallium/winsys/xlib/xlib_brw_aub.c
index 9e96efaa53..2956e1b960 100644
--- a/src/gallium/winsys/xlib/brw_aub.c
+++ b/src/gallium/winsys/xlib/xlib_brw_aub.c
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include "brw_aub.h"
+#include "xlib_brw_aub.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "pipe/p_debug.h"
diff --git a/src/gallium/winsys/xlib/brw_aub.h b/src/gallium/winsys/xlib/xlib_brw_aub.h
index f5c60c7be2..f5c60c7be2 100644
--- a/src/gallium/winsys/xlib/brw_aub.h
+++ b/src/gallium/winsys/xlib/xlib_brw_aub.h
diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c
new file mode 100644
index 0000000000..a2bac0cc93
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_brw_context.c
@@ -0,0 +1,205 @@
+/**************************************************************************
+ *
+ * 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 "glxheader.h"
+//#include "xmesaP.h"
+
+#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "i965simple/brw_winsys.h"
+#include "xlib_brw_aub.h"
+#include "xlib_brw.h"
+
+
+
+
+#define XBCWS_BATCHBUFFER_SIZE 1024
+
+
+/* The backend to the brw driver (ie struct brw_winsys) is actually a
+ * per-context entity.
+ */
+struct xlib_brw_context_winsys {
+ struct brw_winsys brw_context_winsys; /**< batch buffer funcs */
+ struct aub_context *aub;
+
+ struct pipe_winsys *pipe_winsys;
+
+ unsigned batch_data[XBCWS_BATCHBUFFER_SIZE];
+ unsigned batch_nr;
+ unsigned batch_size;
+ unsigned batch_alloc;
+};
+
+
+/* Turn a brw_winsys into an xlib_brw_context_winsys:
+ */
+static inline struct xlib_brw_context_winsys *
+xlib_brw_context_winsys( struct brw_winsys *sws )
+{
+ return (struct xlib_brw_context_winsys *)sws;
+}
+
+
+/* Simple batchbuffer interface:
+ */
+
+static unsigned *xbcws_batch_start( struct brw_winsys *sws,
+ unsigned dwords,
+ unsigned relocs )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ if (xbcws->batch_size < xbcws->batch_nr + dwords)
+ return NULL;
+
+ xbcws->batch_alloc = xbcws->batch_nr + dwords;
+ return (void *)1; /* not a valid pointer! */
+}
+
+static void xbcws_batch_dword( struct brw_winsys *sws,
+ unsigned dword )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ assert(xbcws->batch_nr < xbcws->batch_alloc);
+ xbcws->batch_data[xbcws->batch_nr++] = dword;
+}
+
+static void xbcws_batch_reloc( struct brw_winsys *sws,
+ struct pipe_buffer *buf,
+ unsigned access_flags,
+ unsigned delta )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ assert(xbcws->batch_nr < xbcws->batch_alloc);
+ xbcws->batch_data[xbcws->batch_nr++] =
+ ( xlib_brw_get_buffer_offset( NULL, buf, access_flags ) +
+ delta );
+}
+
+static void xbcws_batch_end( struct brw_winsys *sws )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ assert(xbcws->batch_nr <= xbcws->batch_alloc);
+ xbcws->batch_alloc = 0;
+}
+
+static void xbcws_batch_flush( struct brw_winsys *sws,
+ struct pipe_fence_handle **fence )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+ assert(xbcws->batch_nr <= xbcws->batch_size);
+
+ if (xbcws->batch_nr) {
+ xlib_brw_commands_aub( xbcws->pipe_winsys,
+ xbcws->batch_data,
+ xbcws->batch_nr );
+ }
+
+ xbcws->batch_nr = 0;
+}
+
+
+
+/* Really a per-device function, just pass through:
+ */
+static unsigned xbcws_get_buffer_offset( struct brw_winsys *sws,
+ struct pipe_buffer *buf,
+ unsigned access_flags )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ return xlib_brw_get_buffer_offset( xbcws->pipe_winsys,
+ buf,
+ access_flags );
+}
+
+
+/* Really a per-device function, just pass through:
+ */
+static void xbcws_buffer_subdata_typed( struct brw_winsys *sws,
+ struct pipe_buffer *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data,
+ unsigned data_type )
+{
+ struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws);
+
+ xlib_brw_buffer_subdata_typed( xbcws->pipe_winsys,
+ buf,
+ offset,
+ size,
+ data,
+ data_type );
+}
+
+
+/**
+ * Create i965 hardware rendering context, but plugged into a
+ * dump-to-aubfile backend.
+ */
+struct pipe_context *
+xlib_create_brw_context( struct pipe_screen *screen,
+ void *unused )
+{
+ struct xlib_brw_context_winsys *xbcws = CALLOC_STRUCT( xlib_brw_context_winsys );
+
+ /* Fill in this struct with callbacks that i965simple will need to
+ * communicate with the window system, buffer manager, etc.
+ */
+ xbcws->brw_context_winsys.batch_start = xbcws_batch_start;
+ xbcws->brw_context_winsys.batch_dword = xbcws_batch_dword;
+ xbcws->brw_context_winsys.batch_reloc = xbcws_batch_reloc;
+ xbcws->brw_context_winsys.batch_end = xbcws_batch_end;
+ xbcws->brw_context_winsys.batch_flush = xbcws_batch_flush;
+ xbcws->brw_context_winsys.buffer_subdata_typed = xbcws_buffer_subdata_typed;
+ xbcws->brw_context_winsys.get_buffer_offset = xbcws_get_buffer_offset;
+
+ xbcws->pipe_winsys = screen->winsys; /* redundant */
+
+ xbcws->batch_size = XBCWS_BATCHBUFFER_SIZE;
+
+ /* Create the i965simple context:
+ */
+ return brw_create( screen,
+ &xbcws->brw_context_winsys,
+ 0 );
+}
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xlib_brw_screen.c
index 56e16a0fb4..b0c7977185 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.c
+++ b/src/gallium/winsys/xlib/xlib_brw_screen.c
@@ -33,8 +33,8 @@
*/
-#include "glxheader.h"
-#include "xmesaP.h"
+//#include "state_trackers/xlib/glxheader.h"
+//#include "state_trackers/xlib/xmesaP.h"
#include "pipe/p_winsys.h"
#include "pipe/p_inlines.h"
@@ -42,8 +42,9 @@
#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
#include "i965simple/brw_screen.h"
-#include "brw_aub.h"
-#include "xm_winsys_aub.h"
+
+#include "xlib_brw_aub.h"
+#include "xlib_brw.h"
@@ -142,29 +143,8 @@ aub_buffer_destroy(struct pipe_winsys *winsys,
}
-void xmesa_buffer_subdata_aub(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned aub_type,
- unsigned aub_sub_type)
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- struct aub_buffer *sbo = aub_bo(buf);
-
- assert(sbo->size > offset + size);
- memcpy(sbo->data + offset, data, size);
-
- brw_aub_gtt_data( iws->aubfile,
- sbo->offset + offset,
- sbo->data + offset,
- size,
- aub_type,
- aub_sub_type );
-}
-void xmesa_commands_aub(struct pipe_winsys *winsys,
+void xlib_brw_commands_aub(struct pipe_winsys *winsys,
unsigned *cmds,
unsigned nr_dwords)
{
@@ -182,16 +162,10 @@ void xmesa_commands_aub(struct pipe_winsys *winsys,
}
+/* XXX: fix me:
+ */
static struct aub_pipe_winsys *global_winsys = NULL;
-void xmesa_display_aub( /* struct pipe_winsys *winsys, */
- struct pipe_surface *surface )
-{
-// struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- brw_aub_dump_bmp( global_winsys->aubfile,
- surface,
- aub_bo(surface->buffer)->offset );
-}
@@ -245,10 +219,13 @@ aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
*/
static void
aub_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
+ struct pipe_surface *surface,
+ void *context_private)
{
- xmesa_display_aub( surf );
+// struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
+ brw_aub_dump_bmp( global_winsys->aubfile,
+ surface,
+ aub_bo(surface->buffer)->offset );
}
static struct pipe_surface *
@@ -322,8 +299,20 @@ aub_get_name( struct pipe_winsys *winsys )
return "Aub/xlib";
}
+static void
+xlib_brw_destroy_pipe_winsys_aub( struct pipe_winsys *winsys )
+
+{
+ struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
+ brw_aub_destroy(iws->aubfile);
+ free(iws->pool);
+ free(iws);
+}
+
+
+
struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void )
+xlib_create_brw_winsys( void )
{
struct aub_pipe_winsys *iws = CALLOC_STRUCT( aub_pipe_winsys );
@@ -341,6 +330,7 @@ xmesa_create_pipe_winsys_aub( void )
iws->winsys.buffer_destroy = aub_buffer_destroy;
iws->winsys.flush_frontbuffer = aub_flush_frontbuffer;
iws->winsys.get_name = aub_get_name;
+ iws->winsys.destroy = xlib_brw_destroy_pipe_winsys_aub;
iws->winsys.surface_alloc = aub_i915_surface_alloc;
iws->winsys.surface_alloc_storage = aub_i915_surface_alloc_storage;
@@ -359,122 +349,30 @@ xmesa_create_pipe_winsys_aub( void )
}
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys )
-
-{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- brw_aub_destroy(iws->aubfile);
- free(iws->pool);
- free(iws);
-}
-
-
-
-
-
-
-
-#define IWS_BATCHBUFFER_SIZE 1024
-
-struct aub_brw_winsys {
- struct brw_winsys winsys; /**< batch buffer funcs */
- struct aub_context *aub;
-
- struct pipe_winsys *pipe_winsys;
-
- unsigned batch_data[IWS_BATCHBUFFER_SIZE];
- unsigned batch_nr;
- unsigned batch_size;
- unsigned batch_alloc;
-};
-
-
-/* Turn a i965simple winsys into an aub/i965simple winsys:
- */
-static inline struct aub_brw_winsys *
-aub_brw_winsys( struct brw_winsys *sws )
+struct pipe_screen *
+xlib_create_brw_screen( struct pipe_winsys *winsys )
{
- return (struct aub_brw_winsys *)sws;
+ return brw_create_screen(winsys, 0/* XXX pci_id */);
}
-/* Simple batchbuffer interface:
+/* These per-screen functions are acually made available to the driver
+ * through the brw_winsys (per-context) entity.
*/
-
-static unsigned *aub_i965_batch_start( struct brw_winsys *sws,
- unsigned dwords,
- unsigned relocs )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- if (iws->batch_size < iws->batch_nr + dwords)
- return NULL;
-
- iws->batch_alloc = iws->batch_nr + dwords;
- return (void *)1; /* not a valid pointer! */
-}
-
-static void aub_i965_batch_dword( struct brw_winsys *sws,
- unsigned dword )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr < iws->batch_alloc);
- iws->batch_data[iws->batch_nr++] = dword;
-}
-
-static void aub_i965_batch_reloc( struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr < iws->batch_alloc);
- iws->batch_data[iws->batch_nr++] = aub_bo(buf)->offset + delta;
-}
-
-static unsigned aub_i965_get_buffer_offset( struct brw_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags )
+unsigned xlib_brw_get_buffer_offset( struct pipe_winsys *pws,
+ struct pipe_buffer *buf,
+ unsigned access_flags )
{
return aub_bo(buf)->offset;
}
-static void aub_i965_batch_end( struct brw_winsys *sws )
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
-
- assert(iws->batch_nr <= iws->batch_alloc);
- iws->batch_alloc = 0;
-}
-
-static void aub_i965_batch_flush( struct brw_winsys *sws,
- struct pipe_fence_handle **fence )
+void xlib_brw_buffer_subdata_typed( struct pipe_winsys *pws,
+ struct pipe_buffer *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data,
+ unsigned data_type )
{
- struct aub_brw_winsys *iws = aub_brw_winsys(sws);
- assert(iws->batch_nr <= iws->batch_size);
-
- if (iws->batch_nr) {
- xmesa_commands_aub( iws->pipe_winsys,
- iws->batch_data,
- iws->batch_nr );
- }
-
- iws->batch_nr = 0;
-}
-
-
-
-static void aub_i965_buffer_subdata_typed(struct brw_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned long offset,
- unsigned long size,
- const void *data,
- unsigned data_type)
-{
- struct aub_brw_winsys *iws = aub_brw_winsys(winsys);
unsigned aub_type = DW_GENERAL_STATE;
unsigned aub_sub_type;
@@ -545,46 +443,28 @@ static void aub_i965_buffer_subdata_typed(struct brw_winsys *winsys,
break;
}
- xmesa_buffer_subdata_aub( iws->pipe_winsys,
- buf,
- offset,
- size,
- data,
- aub_type,
- aub_sub_type );
-}
-
-/**
- * Create i965 hardware rendering context.
- */
-struct pipe_context *
-xmesa_create_i965simple( struct pipe_winsys *winsys )
-{
-#ifdef GALLIUM_CELL
- return NULL;
-#else
- struct aub_brw_winsys *iws = CALLOC_STRUCT( aub_brw_winsys );
- struct pipe_screen *screen = brw_create_screen(winsys, 0/* XXX pci_id */);
-
- /* Fill in this struct with callbacks that i965simple will need to
- * communicate with the window system, buffer manager, etc.
- */
- iws->winsys.batch_start = aub_i965_batch_start;
- iws->winsys.batch_dword = aub_i965_batch_dword;
- iws->winsys.batch_reloc = aub_i965_batch_reloc;
- iws->winsys.batch_end = aub_i965_batch_end;
- iws->winsys.batch_flush = aub_i965_batch_flush;
- iws->winsys.buffer_subdata_typed = aub_i965_buffer_subdata_typed;
- iws->winsys.get_buffer_offset = aub_i965_get_buffer_offset;
+ {
+ struct aub_pipe_winsys *iws = aub_pipe_winsys(pws);
+ struct aub_buffer *sbo = aub_bo(buf);
- iws->pipe_winsys = winsys;
+ assert(sbo->size > offset + size);
+ memcpy(sbo->data + offset, data, size);
- iws->batch_size = IWS_BATCHBUFFER_SIZE;
+ brw_aub_gtt_data( iws->aubfile,
+ sbo->offset + offset,
+ sbo->data + offset,
+ size,
+ aub_type,
+ aub_sub_type );
+ }
+}
+
- /* Create the i965simple context:
- */
- return brw_create( screen,
- &iws->winsys,
- 0 );
-#endif
+void
+xlib_brw_display_surface(struct xmesa_buffer *b,
+ struct pipe_surface *surf)
+{
+ brw_aub_dump_bmp( global_winsys->aubfile,
+ surf,
+ aub_bo(surf->buffer)->offset );
}
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index acb5ad8f71..e4aa2d4b6a 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -55,13 +55,7 @@
#define TILE_SIZE 32 /* avoid compilation errors */
#endif
-#ifdef GALLIUM_TRACE
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#endif
-
-#include "xm_winsys_aub.h"
-
+#include "xlib_softpipe.h"
/**
* Subclass of pipe_buffer for Xlib winsys.
@@ -76,7 +70,7 @@ struct xm_buffer
XImage *tempImage;
int shm;
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
XShmSegmentInfo shminfo;
#endif
};
@@ -88,7 +82,7 @@ struct xm_buffer
struct xmesa_pipe_winsys
{
struct pipe_winsys base;
- struct xmesa_visual *xm_visual;
+/* struct xmesa_visual *xm_visual; */
int shm;
};
@@ -105,7 +99,7 @@ xm_buffer( struct pipe_buffer *buf )
/**
* X Shared Memory Image extension code
*/
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
#define XSHM_ENABLED(b) ((b)->shm)
@@ -252,7 +246,7 @@ xm_buffer_destroy(struct pipe_winsys *pws,
struct xm_buffer *oldBuf = xm_buffer(buf);
if (oldBuf->data) {
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
if (oldBuf->shminfo.shmid >= 0) {
shmdt(oldBuf->shminfo.shmaddr);
shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0);
@@ -310,8 +304,8 @@ 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.
*/
-static void
-xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
+void
+xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
@@ -359,7 +353,7 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
/* twiddle from temp to ximage in shared memory */
twiddle_tile(tmpTile, (uint *) ximage->data);
/* display image in shared memory */
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, x, y, w, h, False);
#endif
@@ -382,7 +376,8 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
* by the XMesaBuffer.
*/
void
-xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
+xlib_softpipe_display_surface(struct xmesa_buffer *b,
+ struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
@@ -404,7 +399,7 @@ xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
return;
if (tileSize) {
- xmesa_display_surface_tiled(b, surf);
+ xlib_cell_display_surface(b, surf);
return;
}
@@ -419,7 +414,7 @@ xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
/* display image in Window */
if (XSHM_ENABLED(xm_buf)) {
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, 0, 0, surf->width, surf->height, False);
#endif
@@ -449,7 +444,7 @@ xm_flush_frontbuffer(struct pipe_winsys *pws,
* This function copies that XImage to the actual X Window.
*/
XMesaContext xmctx = (XMesaContext) context_private;
- xmesa_display_surface(xmctx->xm_buffer, surf);
+ xlib_softpipe_display_surface(xmctx->xm_buffer, surf);
}
@@ -468,7 +463,7 @@ xm_buffer_create(struct pipe_winsys *pws,
unsigned size)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
struct xmesa_pipe_winsys *xpws = (struct xmesa_pipe_winsys *) pws;
#endif
@@ -478,7 +473,7 @@ xm_buffer_create(struct pipe_winsys *pws,
buffer->base.size = size;
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
buffer->shminfo.shmid = -1;
buffer->shminfo.shmaddr = (char *) -1;
@@ -625,33 +620,16 @@ xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
}
-/**
- * Return pointer to a pipe_winsys object.
- * For Xlib, this is a singleton object.
- * Nothing special for the Xlib driver so no subclassing or anything.
- */
-struct pipe_winsys *
-xmesa_get_pipe_winsys_aub(struct xmesa_visual *xm_vis)
-{
- static struct xmesa_pipe_winsys *ws = NULL;
- if (!ws) {
- ws = (struct xmesa_pipe_winsys *) xmesa_create_pipe_winsys_aub();
- }
- return &ws->base;
-}
-
-
-static struct pipe_winsys *
-xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
+struct pipe_winsys *
+xlib_create_softpipe_winsys( void )
{
static struct xmesa_pipe_winsys *ws = NULL;
if (!ws) {
ws = CALLOC_STRUCT(xmesa_pipe_winsys);
- ws->xm_visual = xm_vis;
- ws->shm = xmesa_check_for_xshm(xm_vis->display);
+ //ws->shm = xmesa_check_for_xshm( display );
/* Fill in this struct with callbacks that pipe will need to
* communicate with the window system, buffer manager, etc.
@@ -678,42 +656,89 @@ xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
}
+struct pipe_screen *
+xlib_create_softpipe_screen( struct pipe_winsys *pws )
+{
+ struct pipe_screen *screen;
+
+ screen = softpipe_create_screen(pws);
+ if (screen == NULL)
+ goto fail;
+
+ return screen;
+
+fail:
+ return NULL;
+}
+
+
struct pipe_context *
-xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
+xlib_create_softpipe_context( struct pipe_screen *screen,
+ void *context_private )
{
- struct pipe_winsys *pws;
struct pipe_context *pipe;
- if (getenv("XM_AUB")) {
- pws = xmesa_get_pipe_winsys_aub(xmesa->xm_visual);
- }
- else {
- pws = xmesa_get_pipe_winsys(xmesa->xm_visual);
- }
+ pipe = softpipe_create(screen, screen->winsys, NULL);
+ if (pipe == NULL)
+ goto fail;
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- struct cell_winsys *cws = cell_get_winsys(pixelformat);
- struct pipe_screen *screen = cell_create_screen(pws);
+ pipe->priv = context_private;
+ return pipe;
- pipe = cell_create_context(screen, cws);
- }
- else
-#endif
- {
- struct pipe_screen *screen = softpipe_create_screen(pws);
+fail:
+ /* Free stuff here */
+ return NULL;
+}
- pipe = softpipe_create(screen, pws, NULL);
-#ifdef GALLIUM_TRACE
- screen = trace_screen_create(screen);
-
- pipe = trace_context_create(screen, pipe);
-#endif
- }
+/***********************************************************************
+ * 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 )
+{
+ return xlib_create_softpipe_winsys();
+}
+
+struct pipe_screen *
+xlib_create_cell_screen( struct pipe_winsys *pws )
+{
+ return xlib_create_softpipe_screen( pws );
+}
+
+
+struct pipe_context *
+xlib_create_cell_context( struct pipe_screen *screen,
+ void *priv )
+{
+#ifdef GALLIUM_CELL
+ struct cell_winsys *cws;
+ struct pipe_context *pipe;
- if (pipe)
- pipe->priv = xmesa;
+ if (getenv("GALLIUM_NOCELL"))
+ return xlib_create_softpipe_context( screen, priv );
+
+
+ /* This takes a cell_winsys pointer, but probably that should be
+ * created and stored at screen creation, not context creation.
+ *
+ * The actual cell_winsys value isn't used for anything, so just
+ * passing NULL for now.
+ */
+ pipe = cell_create_context( screen, NULL);
+ if (pipe == NULL)
+ goto fail;
+
+ pipe->priv = priv;
return pipe;
+
+fail:
+#endif
+ return NULL;
}
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.h b/src/gallium/winsys/xlib/xlib_softpipe.h
new file mode 100644
index 0000000000..0de96cc4c6
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_softpipe.h
@@ -0,0 +1,50 @@
+
+#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
new file mode 100644
index 0000000000..45afba7a47
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_trace.c
@@ -0,0 +1,102 @@
+/**************************************************************************
+ *
+ * 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_softpipe.h"
+#include "xlib_trace.h"
+
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+
+
+struct pipe_winsys *
+xlib_create_trace_winsys( void )
+{
+ return xlib_create_softpipe_winsys();
+}
+
+struct pipe_screen *
+xlib_create_trace_screen( struct pipe_winsys *winsys )
+{
+ struct pipe_screen *screen, *trace_screen;
+
+ screen = xlib_create_softpipe_screen( winsys );
+ if (screen == NULL)
+ goto fail;
+
+ /* Wrap it:
+ */
+ trace_screen = trace_screen_create(screen);
+ if (trace_screen == NULL)
+ goto fail;
+
+ return trace_screen;
+
+fail:
+ /* free stuff */
+ return NULL;
+}
+
+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 );
+ if (pipe == NULL)
+ goto fail;
+
+ /* Wrap it:
+ */
+ trace_pipe = trace_context_create(screen, pipe);
+ if (trace_pipe == NULL)
+ goto fail;
+
+ trace_pipe->priv = priv;
+
+ return trace_pipe;
+
+fail:
+ return NULL;
+}
+
+void
+xlib_trace_display_surface( struct xmesa_buffer *buffer,
+ struct pipe_surface *surf )
+{
+ /* ??
+ */
+ xlib_softpipe_display_surface( buffer, surf );
+}
diff --git a/src/gallium/winsys/xlib/xlib_trace.h b/src/gallium/winsys/xlib/xlib_trace.h
new file mode 100644
index 0000000000..c79c0fe34d
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_trace.h
@@ -0,0 +1,26 @@
+
+#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