summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/xlib
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-09-11 06:09:05 +1000
committerBen Skeggs <[email protected]>2008-09-11 06:09:05 +1000
commit7158203b081ad34c03382f07e0df748eae235e9b (patch)
treeee61efebbafb5464ec090c21b5e05533588789a1 /src/gallium/winsys/xlib
parent02025148c28d03d644e3d66dde1a423fe21e1c44 (diff)
parenteb5b16d278e0f7ee0121049e43dfee1d52f2b0f7 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Conflicts: configs/default
Diffstat (limited to 'src/gallium/winsys/xlib')
-rw-r--r--src/gallium/winsys/xlib/Makefile5
-rw-r--r--src/gallium/winsys/xlib/SConscript4
-rw-r--r--src/gallium/winsys/xlib/brw_aub.c2
-rw-r--r--src/gallium/winsys/xlib/glxapi.c26
-rw-r--r--src/gallium/winsys/xlib/xm_api.c18
-rw-r--r--src/gallium/winsys/xlib/xm_winsys.c106
-rw-r--r--src/gallium/winsys/xlib/xm_winsys_aub.c5
-rw-r--r--src/gallium/winsys/xlib/xmesaP.h3
8 files changed, 67 insertions, 102 deletions
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
index ec92c790685..11c76324113 100644
--- a/src/gallium/winsys/xlib/Makefile
+++ b/src/gallium/winsys/xlib/Makefile
@@ -33,10 +33,7 @@ XLIB_WINSYS_SOURCES = \
XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
-ifeq ($(CONFIG_NAME), linux-cell)
-# The SPU code is in a separate .a file, unfortunately
-CELL_SPU_LIB = $(TOP)/src/gallium/drivers/cell/spu/g3d_spu.a
-endif
+# Note: CELL_SPU_LIB is only defined for cell configs
LIBS = \
$(GALLIUM_DRIVERS) \
diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript
index 8650f595a72..324fbef306a 100644
--- a/src/gallium/winsys/xlib/SConscript
+++ b/src/gallium/winsys/xlib/SConscript
@@ -36,8 +36,10 @@ if env['platform'] == 'linux' \
drivers += [trace]
# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
- env.SharedLibrary(
+ libgl = env.SharedLibrary(
target ='GL',
source = sources,
LIBS = glapi + mesa + drivers + auxiliaries + env['LIBS'],
)
+
+ env.InstallSharedLibrary(libgl, version=(1, 5))
diff --git a/src/gallium/winsys/xlib/brw_aub.c b/src/gallium/winsys/xlib/brw_aub.c
index 6e814ce5d11..9e96efaa530 100644
--- a/src/gallium/winsys/xlib/brw_aub.c
+++ b/src/gallium/winsys/xlib/brw_aub.c
@@ -34,8 +34,8 @@
#include "brw_aub.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_debug.h"
+#include "util/u_memory.h"
struct brw_aubfile {
diff --git a/src/gallium/winsys/xlib/glxapi.c b/src/gallium/winsys/xlib/glxapi.c
index c2ccce6f520..c059fc3edb5 100644
--- a/src/gallium/winsys/xlib/glxapi.c
+++ b/src/gallium/winsys/xlib/glxapi.c
@@ -37,6 +37,7 @@
#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
+#include "pipe/p_thread.h"
extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
@@ -127,26 +128,13 @@ get_dispatch(Display *dpy)
/**
* GLX API current context.
*/
-#if defined(GLX_USE_TLS)
-PUBLIC __thread void * CurrentContext
- __attribute__((tls_model("initial-exec")));
-#elif defined(THREADS)
-static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
-#else
-static GLXContext CurrentContext = 0;
-#endif
+pipe_tsd ContextTSD;
static void
SetCurrentContext(GLXContext c)
{
-#if defined(GLX_USE_TLS)
- CurrentContext = c;
-#elif defined(THREADS)
- _glthread_SetTSD(&ContextTSD, c);
-#else
- CurrentContext = c;
-#endif
+ pipe_tsd_set(&ContextTSD, c);
}
@@ -238,13 +226,7 @@ glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
GLXContext PUBLIC
glXGetCurrentContext(void)
{
-#if defined(GLX_USE_TLS)
- return CurrentContext;
-#elif defined(THREADS)
- return (GLXContext) _glthread_GetTSD(&ContextTSD);
-#else
- return CurrentContext;
-#endif
+ return (GLXContext) pipe_tsd_get(&ContextTSD);
}
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/winsys/xlib/xm_api.c
index 4e5441a13d2..b0105131071 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/winsys/xlib/xm_api.c
@@ -62,11 +62,11 @@
#include "xmesaP.h"
#include "main/context.h"
#include "main/framebuffer.h"
-#include "glapi/glthread.h"
#include "state_tracker/st_public.h"
#include "state_tracker/st_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "xm_winsys_aub.h"
@@ -74,7 +74,7 @@
/**
* Global X driver lock
*/
-_glthread_Mutex _xmesa_lock;
+pipe_mutex _xmesa_lock;
int xmesa_mode;
@@ -244,10 +244,10 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
#else
Status stat;
- _glthread_LOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_lock(_xmesa_lock);
XSync(b->xm_visual->display, 0); /* added for Chromium */
stat = get_drawable_size(dpy, b->drawable, width, height);
- _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ pipe_mutex_unlock(_xmesa_lock);
if (!stat) {
/* probably querying a window that's recently been destroyed */
@@ -778,7 +778,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
uint pf;
if (firstTime) {
- _glthread_INIT_MUTEX(_xmesa_lock);
+ pipe_mutex_init(_xmesa_lock);
firstTime = GL_FALSE;
}
@@ -833,7 +833,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
fail:
if (c->st)
st_destroy_context(c->st);
- if (pipe)
+ else if (pipe)
pipe->destroy(pipe);
FREE(c);
return NULL;
@@ -844,7 +844,12 @@ 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
+ screen->destroy(screen);
+ */
_mesa_free(c);
}
@@ -1293,6 +1298,7 @@ void XMesaFlush( XMesaContext c )
#ifdef XFree86Server
/* NOT_NEEDED */
#else
+ st_finish(c->st);
XSync( c->xm_visual->display, False );
#endif
}
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c
index 6071a5ad5e4..5e9a1f92f11 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xm_winsys.c
@@ -42,8 +42,9 @@
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
#ifdef GALLIUM_CELL
@@ -55,7 +56,6 @@
#endif
#ifdef GALLIUM_TRACE
-#include "trace/tr_winsys.h"
#include "trace/tr_screen.h"
#include "trace/tr_context.h"
#endif
@@ -83,18 +83,6 @@ struct xm_buffer
/**
- * Subclass of pipe_surface for Xlib winsys
- */
-struct xmesa_surface
-{
- struct pipe_surface surface;
-
- int tileSize;
- boolean no_swap;
-};
-
-
-/**
* Subclass of pipe_winsys for Xlib winsys
*/
struct xmesa_pipe_winsys
@@ -107,14 +95,6 @@ struct xmesa_pipe_winsys
/** Cast wrapper */
-static INLINE struct xmesa_surface *
-xmesa_surface(struct pipe_surface *ps)
-{
- return (struct xmesa_surface *) ps;
-}
-
-
-/** Cast wrapper */
static INLINE struct xm_buffer *
xm_buffer( struct pipe_buffer *buf )
{
@@ -307,16 +287,16 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
uint x, y;
- /* check that the XImage has been previously initialized */
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
if (XSHM_ENABLED(xm_buf) && (xm_buf->tempImage == NULL)) {
alloc_shm_ximage(xm_buf, b, TILE_SIZE, TILE_SIZE);
}
ximage = (XSHM_ENABLED(xm_buf)) ? xm_buf->tempImage : b->tempImage;
+ /* check that the XImage has been previously initialized */
+ assert(ximage->format);
+ assert(ximage->bitmap_unit);
+
if (!XSHM_ENABLED(xm_buf)) {
/* update XImage's fields */
ximage->width = TILE_SIZE;
@@ -326,11 +306,16 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
for (y = 0; y < surf->height; y += TILE_SIZE) {
for (x = 0; x < surf->width; x += TILE_SIZE) {
- int dx = x;
- int dy = y;
int tx = x / TILE_SIZE;
int ty = y / TILE_SIZE;
int offset = ty * tilesPerRow + tx;
+ int w = TILE_SIZE;
+ int h = TILE_SIZE;
+
+ if (y + h > surf->height)
+ h = surf->height - y;
+ if (x + w > surf->width)
+ w = surf->width - x;
offset *= 4 * TILE_SIZE * TILE_SIZE;
@@ -339,11 +324,12 @@ xmesa_display_surface_tiled(XMesaBuffer b, const struct pipe_surface *surf)
if (XSHM_ENABLED(xm_buf)) {
#if defined(USE_XSHM) && !defined(XFree86Server)
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, x, y, TILE_SIZE, TILE_SIZE, False);
+ ximage, 0, 0, x, y, w, h, False);
#endif
- } else {
+ }
+ else {
XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, dx, dy, TILE_SIZE, TILE_SIZE);
+ ximage, 0, 0, x, y, w, h);
}
}
}
@@ -359,13 +345,24 @@ xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
- const struct xmesa_surface *xm_surf
- = xmesa_surface((struct pipe_surface *) surf);
+ static boolean no_swap = 0;
+ static boolean firsttime = 1;
+ static int tileSize = 0;
- if (xm_surf->no_swap)
+ if (firsttime) {
+ no_swap = getenv("SP_NO_RAST") != NULL;
+#ifdef GALLIUM_CELL
+ if (!getenv("GALLIUM_NOCELL")) {
+ tileSize = 32; /** probably temporary */
+ }
+#endif
+ firsttime = 0;
+ }
+
+ if (no_swap)
return;
- if (xm_surf->tileSize) {
+ if (tileSize) {
xmesa_display_surface_tiled(b, surf);
return;
}
@@ -532,29 +529,14 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
static struct pipe_surface *
xm_surface_alloc(struct pipe_winsys *ws)
{
- struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
- static boolean no_swap = 0;
- static boolean firsttime = 1;
-
- if (firsttime) {
- no_swap = getenv("SP_NO_RAST") != NULL;
- firsttime = 0;
- }
+ struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
assert(ws);
- xms->surface.refcount = 1;
- xms->surface.winsys = ws;
+ surface->refcount = 1;
+ surface->winsys = ws;
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- xms->tileSize = 32; /** probably temporary */
- }
-#endif
-
- xms->no_swap = no_swap;
-
- return &xms->surface;
+ return surface;
}
@@ -567,7 +549,7 @@ xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
@@ -651,11 +633,7 @@ xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
ws->base.get_name = xm_get_name;
}
-#ifdef GALLIUM_TRACE
- return trace_winsys_create(&ws->base);
-#else
- return &ws->base;
-#endif
+ return &ws->base;
}
@@ -684,14 +662,12 @@ xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
{
struct pipe_screen *screen = softpipe_create_screen(pws);
-#ifdef GALLIUM_TRACE
- screen = trace_screen_create(screen);
-#endif
-
pipe = softpipe_create(screen, pws, NULL);
#ifdef GALLIUM_TRACE
- pipe = trace_context_create(pipe);
+ screen = trace_screen_create(screen);
+
+ pipe = trace_context_create(screen, pipe);
#endif
}
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c
index 7fc9debdd54..b7c10b6bcae 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.c
+++ b/src/gallium/winsys/xlib/xm_winsys_aub.c
@@ -37,8 +37,9 @@
#include "xmesaP.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i965simple/brw_winsys.h"
#include "i965simple/brw_screen.h"
#include "brw_aub.h"
@@ -307,7 +308,7 @@ aub_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
surf->refcount--;
if (surf->refcount == 0) {
if (surf->buffer)
- pipe_buffer_reference(winsys, &surf->buffer, NULL);
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
free(surf);
}
*s = NULL;
diff --git a/src/gallium/winsys/xlib/xmesaP.h b/src/gallium/winsys/xlib/xmesaP.h
index 9b15b2ddf99..fcaeee52bcf 100644
--- a/src/gallium/winsys/xlib/xmesaP.h
+++ b/src/gallium/winsys/xlib/xmesaP.h
@@ -35,9 +35,10 @@
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
+#include "pipe/p_thread.h"
-extern _glthread_Mutex _xmesa_lock;
+extern pipe_mutex _xmesa_lock;
extern XMesaBuffer XMesaBufferList;