summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/Makefile2
-rw-r--r--src/gallium/auxiliary/util/p_debug.c26
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile3
-rw-r--r--src/gallium/drivers/trace/Makefile18
-rw-r--r--src/gallium/include/pipe/p_debug.h5
-rw-r--r--src/gallium/state_trackers/Makefile25
-rw-r--r--src/gallium/state_trackers/glx/Makefile25
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_context.c168
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_context.h95
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_drawable.c363
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_drawable.h (renamed from src/gallium/drivers/cell/ppu/cell_winsys.c)61
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_extensions.c108
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_lock.c90
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_screen.c255
-rw-r--r--src/gallium/state_trackers/glx/dri/dri_screen.h83
-rw-r--r--src/gallium/state_trackers/glx/xlib/Makefile25
-rw-r--r--src/gallium/state_trackers/glx/xlib/fakeglx.c (renamed from src/gallium/winsys/xlib/fakeglx.c)670
-rw-r--r--src/gallium/state_trackers/glx/xlib/fakeglx.h (renamed from src/gallium/winsys/xlib/xfonts.h)10
-rw-r--r--src/gallium/state_trackers/glx/xlib/fakeglx_fonts.c (renamed from src/gallium/winsys/xlib/xfonts.c)8
-rw-r--r--src/gallium/state_trackers/glx/xlib/glxapi.c (renamed from src/gallium/winsys/xlib/glxapi.c)146
-rw-r--r--src/gallium/state_trackers/glx/xlib/glxapi.h (renamed from src/gallium/winsys/xlib/glxapi.h)15
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c (renamed from src/gallium/winsys/xlib/xm_api.c)371
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.h393
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_winsys.h (renamed from src/gallium/winsys/xlib/xm_winsys_aub.h)45
-rw-r--r--src/gallium/winsys/xlib/Makefile19
-rw-r--r--src/gallium/winsys/xlib/glxheader.h62
-rw-r--r--src/gallium/winsys/xlib/realglx.c180
-rw-r--r--src/gallium/winsys/xlib/realglx.h326
-rw-r--r--src/gallium/winsys/xlib/xlib.c105
-rw-r--r--src/gallium/winsys/xlib/xlib.h14
-rw-r--r--src/gallium/winsys/xlib/xlib_brw.h30
-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.c209
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_screen.c (renamed from src/gallium/winsys/xlib/xm_winsys_aub.c)264
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c479
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c (renamed from src/gallium/winsys/xlib/xm_winsys.c)294
-rw-r--r--src/gallium/winsys/xlib/xlib_trace.c107
-rw-r--r--src/gallium/winsys/xlib/xm_image.c133
-rw-r--r--src/gallium/winsys/xlib/xm_image.h77
-rw-r--r--src/gallium/winsys/xlib/xmesaP.h180
41 files changed, 3037 insertions, 2454 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/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index acdfa211c8..f373f941dd 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -406,6 +406,32 @@ debug_dump_enum(const struct debug_named_value *names,
const char *
+debug_dump_enum_noprefix(const struct debug_named_value *names,
+ const char *prefix,
+ unsigned long value)
+{
+ static char rest[64];
+
+ while(names->name) {
+ if(names->value == value) {
+ const char *name = names->name;
+ while (*name == *prefix) {
+ name++;
+ prefix++;
+ }
+ return name;
+ }
+ ++names;
+ }
+
+
+
+ util_snprintf(rest, sizeof(rest), "0x%08lx", value);
+ return rest;
+}
+
+
+const char *
debug_dump_flags(const struct debug_named_value *names,
unsigned long value)
{
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 4d6ac0d266..c92f8e5cba 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -39,8 +39,7 @@ SOURCES = \
cell_texture.c \
cell_vbuf.c \
cell_vertex_fetch.c \
- cell_vertex_shader.c \
- cell_winsys.c
+ cell_vertex_shader.c
OBJECTS = $(SOURCES:.c=.o) \
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/include/pipe/p_debug.h b/src/gallium/include/pipe/p_debug.h
index 3b00fb9aa8..e9c95982dd 100644
--- a/src/gallium/include/pipe/p_debug.h
+++ b/src/gallium/include/pipe/p_debug.h
@@ -261,6 +261,11 @@ const char *
debug_dump_enum(const struct debug_named_value *names,
unsigned long value);
+const char *
+debug_dump_enum_noprefix(const struct debug_named_value *names,
+ const char *prefix,
+ unsigned long value);
+
/**
* Convert binary flags value to a string.
diff --git a/src/gallium/state_trackers/Makefile b/src/gallium/state_trackers/Makefile
new file mode 100644
index 0000000000..07b3fbf311
--- /dev/null
+++ b/src/gallium/state_trackers/Makefile
@@ -0,0 +1,25 @@
+TOP = ../../..
+include $(TOP)/configs/current
+
+
+SUBDIRS = glx
+
+
+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/glx/Makefile b/src/gallium/state_trackers/glx/Makefile
new file mode 100644
index 0000000000..f779035763
--- /dev/null
+++ b/src/gallium/state_trackers/glx/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/glx/dri/dri_context.c b/src/gallium/state_trackers/glx/dri/dri_context.c
new file mode 100644
index 0000000000..9424e18bee
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_context.c
@@ -0,0 +1,168 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * 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 "dri_screen.h"
+#include "dri_context.h"
+#include "dri_winsys.h"
+
+#include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
+#include "pipe/p_context.h"
+
+#include "util/u_memory.h"
+
+
+GLboolean
+dri_create_context(const __GLcontextModes *visual,
+ __DRIcontextPrivate *cPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
+ struct dri_screen *screen = dri_screen(sPriv);
+ struct dri_context *ctx = NULL;
+ struct st_context *st_share = NULL;
+
+ if (sharedContextPrivate) {
+ st_share = ((struct dri_context *) sharedContextPrivate)->st;
+ }
+
+ ctx = CALLOC_STRUCT(dri_context);
+ if (ctx == NULL)
+ goto fail;
+
+ cPriv->driverPrivate = ctx;
+ ctx->cPriv = cPriv;
+ ctx->sPriv = sPriv;
+
+ driParseConfigFiles(&ctx->optionCache,
+ &screen->optionCache,
+ sPriv->myNum,
+ "dri");
+
+ ctx->pipe = screen->pipe_screen->create_context(screen->pipe_screen,
+ screen->pipe_winsys,
+ hw_winsys );
+ if (ctx->pipe == NULL)
+ goto fail;
+
+ ctx->pipe->priv = ctx; /* I guess */
+
+ ctx->st = st_create_context(ctx->pipe, visual, st_share);
+ if (ctx->st == NULL)
+ goto fail;
+
+ dri_init_extensions( ctx );
+
+ return GL_TRUE;
+
+fail:
+ if (ctx && ctx->st)
+ st_destroy_context( ctx->st );
+
+ if (ctx && ctx->pipe)
+ ctx->pipe->destroy( ctx->pipe );
+
+ FREE(ctx);
+ return FALSE;
+}
+
+
+void
+dri_destroy_context(__DRIcontextPrivate *cPriv)
+{
+ struct dri_context *ctx = dri_context(cPriv);
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct pipe_winsys *winsys = screen->winsys;
+
+ /* No particular reason to wait for command completion before
+ * destroying a context, but it is probably worthwhile flushing it
+ * to avoid having to add code elsewhere to cope with flushing a
+ * partially destroyed context.
+ */
+ st_flush(ctx->st);
+
+ if (screen->dummyContext == ctx)
+ screen->dummyContext = NULL;
+
+ /* Also frees ctx->pipe?
+ */
+ st_destroy_context(ctx->st);
+
+ FREE(ctx);
+}
+
+
+GLboolean
+dri_unbind_context(__DRIcontextPrivate *cPriv)
+{
+ struct dri_context *ctx = dri_context(cPriv);
+ st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
+ /* XXX make_current(NULL)? */
+ return GL_TRUE;
+}
+
+
+GLboolean
+dri_make_current(__DRIcontextPrivate *cPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (cPriv) {
+ struct dri_context *ctx = dri_context(cPriv);
+ struct dri_screen *screen = dri_screen(cPriv->driScreenPriv);
+ struct dri_drawable *draw = dri_drawable(driDrawPriv);
+ struct dri_drawable *read = dri_drawable(driReadPriv);
+
+ /* This is for situations in which we need a rendering context but
+ * there may not be any currently bound.
+ */
+ screen->dummyContext = ctx;
+
+ st_make_current( ctx->st,
+ draw->stfb,
+ read->stfb );
+
+ ctx->dPriv = driDrawPriv;
+
+ /* Update window sizes if necessary:
+ */
+ if (draw->stamp != driDrawPriv->lastStamp) {
+ dri_update_window_size( draw );
+ }
+
+ if (read->stamp != driReadPriv->lastStamp) {
+ dri_update_window_size( read );
+ }
+
+ }
+ else {
+ st_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
diff --git a/src/gallium/state_trackers/glx/dri/dri_context.h b/src/gallium/state_trackers/glx/dri/dri_context.h
new file mode 100644
index 0000000000..4e6a305abb
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_context.h
@@ -0,0 +1,95 @@
+/**************************************************************************
+ *
+ * Copyright (C) 2009 VMware, Inc. 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.
+ *
+ **************************************************************************/
+
+#ifndef DRI_CONTEXT_H
+#define DRI_CONTEXT_H
+
+#include "pipe/p_compiler.h"
+#include "drm.h"
+#include "dri_util.h"
+
+
+struct pipe_context;
+struct pipe_fence;
+struct st_context;
+
+
+struct dri_context
+{
+ __DRIcontextPrivate *cPriv;
+ __DRIdrawablePrivate *dPriv;
+
+ struct st_context *st;
+ struct pipe_context *pipe;
+
+ boolean locked;
+
+ /**
+ * Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+
+static INLINE struct dri_context *
+dri_context(__DRIcontextPrivate *driContextPriv)
+{
+ return (struct dri_context *) driContextPriv->driverPrivate;
+}
+
+/***********************************************************************
+ * dri_context.c
+ */
+void
+dri_destroy_context(__DRIcontextPrivate * driContextPriv);
+
+boolean
+dri_unbind_context(__DRIcontextPrivate * driContextPriv);
+
+boolean
+dri_make_current(__DRIcontextPrivate * driContextPriv,
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv);
+
+boolean
+dri_create_context(const __GLcontextModes * visual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate);
+
+
+
+/***********************************************************************
+ * dri_lock.c
+ */
+void dri_lock_hardware( struct dri_context *context,
+ struct dri_drawable *drawable );
+
+void dri_unlock_hardware( struct dri_context *dri );
+boolean dri_is_locked( struct dri_context *dri );
+
+
+
+#endif
diff --git a/src/gallium/state_trackers/glx/dri/dri_drawable.c b/src/gallium/state_trackers/glx/dri/dri_drawable.c
new file mode 100644
index 0000000000..b712acda88
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_drawable.c
@@ -0,0 +1,363 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * 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 "dri_screen.h"
+#include "dri_context.h"
+#include "dri_swapbuffers.h"
+
+#include "pipe/p_context.h"
+#include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_cb_fbo.h"
+
+
+static void
+blit_swapbuffers(__DRIdrawablePrivate *dPriv,
+ __DRIcontextPrivate *cPriv,
+ struct pipe_surface *src,
+ const drm_clip_rect_t *rect)
+{
+ struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
+ struct dri_drawable *fb = dri_drawable(dPriv);
+ struct dri_context *context = dri_context(cPriv);
+
+ const int nbox = dPriv->numClipRects;
+ const drm_clip_rect_t *pbox = dPriv->pClipRects;
+
+ struct pipe_surface *dest = fb->front_surface;
+ const int backWidth = fb->stfb->Base.Width;
+ const int backHeight = fb->stfb->Base.Height;
+ int i;
+
+ for (i = 0; i < nbox; i++, pbox++) {
+ drm_clip_rect_t box;
+ drm_clip_rect_t sbox;
+
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ (pbox->x2 - pbox->x1) > dest->width ||
+ (pbox->y2 - pbox->y1) > dest->height)
+ continue;
+
+ box = *pbox;
+
+ if (rect) {
+ drm_clip_rect_t rrect;
+
+ rrect.x1 = dPriv->x + rect->x1;
+ rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y;
+ rrect.x2 = rect->x2 + rrect.x1;
+ rrect.y2 = rect->y2 + rrect.y1;
+ if (rrect.x1 > box.x1)
+ box.x1 = rrect.x1;
+ if (rrect.y1 > box.y1)
+ box.y1 = rrect.y1;
+ if (rrect.x2 < box.x2)
+ box.x2 = rrect.x2;
+ if (rrect.y2 < box.y2)
+ box.y2 = rrect.y2;
+
+ if (box.x1 > box.x2 || box.y1 > box.y2)
+ continue;
+ }
+
+ /* restrict blit to size of actually rendered area */
+ if (box.x2 - box.x1 > backWidth)
+ box.x2 = backWidth + box.x1;
+ if (box.y2 - box.y1 > backHeight)
+ box.y2 = backHeight + box.y1;
+
+ debug_printf("%s: box %d,%d-%d,%d\n", __FUNCTION__,
+ box.x1, box.y1, box.x2, box.y2);
+
+ sbox.x1 = box.x1 - dPriv->x;
+ sbox.y1 = box.y1 - dPriv->y;
+
+ ctx->st->pipe->surface_copy( ctx->st->pipe,
+ FALSE,
+ dest,
+ box.x1, box.y1,
+ src,
+ sbox.x1, sbox.y1,
+ box.x2 - box.x1,
+ box.y2 - box.y1 );
+ }
+}
+
+/**
+ * Display a colorbuffer surface in an X window.
+ * Used for SwapBuffers and flushing front buffer rendering.
+ *
+ * \param dPriv the window/drawable to display into
+ * \param surf the surface to display
+ * \param rect optional subrect of surface to display (may be NULL).
+ */
+static void
+dri_display_surface(__DRIdrawablePrivate *dPriv,
+ struct pipe_surface *source,
+ const drm_clip_rect_t *rect)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct dri_screen *screen = dri_screen(dPriv->driScreenPriv);
+ struct dri_context *context = screen->dummy_context;
+ struct pipe_winsys *winsys = screen->winsys;
+
+ if (!context)
+ return;
+
+ if (drawable->last_swap_fence) {
+ winsys->fence_finish( winsys,
+ drawable->last_swap_fence,
+ 0 );
+
+ winsys->fence_reference( winsys,
+ &drawable->last_swap_fence,
+ NULL );
+ }
+
+ drawable->last_swap_fence = drawable->first_swap_fence;
+ drawable->first_swap_fence = NULL;
+
+ /* Call lock_hardware to update dPriv cliprects.
+ */
+ dri_lock_hardware(context, drawable);
+ {
+ if (dPriv->numClipRects) {
+ blit_swapbuffers( context, dPriv, source, rect );
+ }
+ }
+ dri_unlock_hardware(context);
+
+ if (drawble->stamp != drawable->dPriv->lastStamp) {
+ dri_update_window_size( dpriv );
+ }
+}
+
+
+
+/**
+ * This will be called a drawable is known to have moved/resized.
+ */
+void
+dri_update_window_size(__DRIdrawablePrivate *dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ st_resize_framebuffer(drawable->stfb, dPriv->w, dPriv->h);
+ drawable->stamp = dPriv->lastStamp;
+}
+
+
+
+void
+dri_swap_buffers(__DRIdrawablePrivate * dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_surface *back_surf;
+
+ assert(drawable);
+ assert(drawable->stfb);
+
+ back_surf = st_get_framebuffer_surface(drawable->stfb,
+ ST_SURFACE_BACK_LEFT);
+ if (back_surf) {
+ st_notify_swapbuffers(drawable->stfb);
+ dri_display_surface(dPriv, back_surf, NULL);
+ st_notify_swapbuffers_complete(drawable->stfb);
+ }
+}
+
+
+/**
+ * Called via glXCopySubBufferMESA() to copy a subrect of the back
+ * buffer to the front buffer/screen.
+ */
+void
+dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+ struct pipe_surface *back_surf;
+
+ assert(drawable);
+ assert(drawable->stfb);
+
+ back_surf = st_get_framebuffer_surface(drawable->stfb,
+ ST_SURFACE_BACK_LEFT);
+ if (back_surf) {
+ drm_clip_rect_t rect;
+ rect.x1 = x;
+ rect.y1 = y;
+ rect.x2 = w;
+ rect.y2 = h;
+
+ st_notify_swapbuffers(drawable->stfb);
+ dri_display_surface(dPriv, back_surf, &rect);
+ }
+}
+
+
+
+/*
+ * The state tracker keeps track of whether the fake frontbuffer has
+ * been touched by any rendering since the last time we copied its
+ * contents to the real frontbuffer. Our task is easy:
+ */
+static void
+dri_flush_frontbuffer( struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ void *context_private)
+{
+ struct dri_context *dri = (struct dri_context *) context_private;
+ __DRIdrawablePrivate *dPriv = dri->driDrawable;
+
+ dri_display_surface(dPriv, surf, NULL);
+}
+
+
+
+/* Need to create a surface which wraps the front surface to support
+ * client-side swapbuffers.
+ */
+static void
+dri_create_front_surface(struct dri_screen *screen,
+ struct pipe_winsys *winsys,
+ unsigned handle)
+{
+ struct pipe_screen *pipe_screen = screen->pipe_screen;
+ struct pipe_texture *texture;
+ struct pipe_texture templat;
+ struct pipe_surface *surface;
+ struct pipe_buffer *buffer;
+ unsigned pitch;
+
+ assert(screen->front.cpp == 4);
+
+// buffer = dri_buffer_from_handle(screen->winsys,
+// "front", handle);
+
+ if (!buffer)
+ return;
+
+ screen->front.buffer = dri_bo(buffer);
+
+ memset(&templat, 0, sizeof(templat));
+ templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+ templat.target = PIPE_TEXTURE_2D;
+ templat.last_level = 0;
+ templat.depth[0] = 1;
+ templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ templat.width[0] = screen->front.width;
+ templat.height[0] = screen->front.height;
+ pf_get_block(templat.format, &templat.block);
+ pitch = screen->front.pitch;
+
+ texture = pipe_screen->texture_blanket(pipe_screen,
+ &templat,
+ &pitch,
+ buffer);
+
+ /* Unref the buffer we don't need it anyways */
+ pipe_buffer_reference(screen, &buffer, NULL);
+
+ surface = pipe_screen->get_tex_surface(pipe_screen,
+ texture,
+ 0,
+ 0,
+ 0,
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ screen->front.texture = texture;
+ screen->front.surface = surface;
+}
+
+/**
+ * This is called when we need to set up GL rendering to a new X window.
+ */
+static boolean
+dri_create_buffer(__DRIscreenPrivate *sPriv,
+ __DRIdrawablePrivate *dPriv,
+ const __GLcontextModes *visual,
+ boolean isPixmap)
+{
+ enum pipe_format colorFormat, depthFormat, stencilFormat;
+ struct dri_drawable *drawable;
+
+ if (isPixmap)
+ goto fail; /* not implemented */
+
+ drawable = CALLOC_STRUCT(dri_drawable);
+ if (drawable == NULL)
+ goto fail;
+
+ /* XXX: todo: use the pipe_screen queries to figure out which
+ * render targets are supportable.
+ */
+ if (visual->redBits == 5)
+ colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
+ else
+ colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ if (visual->depthBits == 16)
+ depthFormat = PIPE_FORMAT_Z16_UNORM;
+ else if (visual->depthBits == 24) {
+ if (visual->stencilBits == 8)
+ depthFormat = PIPE_FORMAT_S8Z24_UNORM;
+ else
+ depthFormat = PIPE_FORMAT_X8Z24_UNORM;
+ }
+
+ drawable->stfb = st_create_framebuffer(visual,
+ colorFormat,
+ depthFormat,
+ dPriv->w,
+ dPriv->h,
+ (void*) drawable);
+ if (drawable->stfb == NULL)
+ goto fail;
+
+ dPriv->driverPrivate = (void *) drawable;
+ return GL_TRUE;
+
+fail:
+ FREE(drawable);
+ return GL_FALSE;
+}
+
+static void
+dri_destroy_buffer(__DRIdrawablePrivate *dPriv)
+{
+ struct dri_drawable *drawable = dri_drawable(dPriv);
+
+ /* No particular need to wait on fences before dereferencing them:
+ */
+ winsys->fence_reference( winsys, &ctx->last_swap_fence, NULL );
+ winsys->fence_reference( winsys, &ctx->first_swap_fence, NULL );
+
+ st_unreference_framebuffer(drawable->stfb);
+
+ FREE(drawable);
+}
+
diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.c b/src/gallium/state_trackers/glx/dri/dri_drawable.h
index d570bbd2f9..1001bb8c57 100644
--- a/src/gallium/drivers/cell/ppu/cell_winsys.c
+++ b/src/gallium/state_trackers/glx/dri/dri_drawable.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ *
+ * Copyright 2009, VMware, Inc.
* 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
@@ -10,11 +10,11 @@
* 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.
@@ -22,19 +22,52 @@
* 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.
- *
+ *
**************************************************************************/
+#ifndef DRI_DRAWABLE_H
+#define DRI_DRAWABLE_H
-#include "util/u_memory.h"
-#include "cell_winsys.h"
+#include "pipe/p_compiler.h"
+struct pipe_surface;
+struct pipe_fence;
+struct st_framebuffer;
-struct cell_winsys *
-cell_get_winsys(uint format)
+
+struct dri_drawable
{
- struct cell_winsys *cws = CALLOC_STRUCT(cell_winsys);
- if (cws)
- cws->preferredFormat = format;
- return cws;
+ __DRIdrawablePrivate *dPriv;
+ unsigned stamp;
+
+ struct pipe_fence *last_swap_fence;
+ struct pipe_fence *first_swap_fence;
+
+ struct st_framebuffer *stfb;
+};
+
+
+static INLINE struct dri_drawable *
+dri_drawable(__DRIdrawablePrivate * driDrawPriv)
+{
+ return (struct dri_drawable *) driDrawPriv->driverPrivate;
}
+
+
+/***********************************************************************
+ * dri_drawable.c
+ */
+
+void
+dri_swap_buffers(__DRIdrawablePrivate * dPriv);
+
+void
+dri_copy_sub_buffer(__DRIdrawablePrivate * dPriv,
+ int x, int y,
+ int w, int h);
+
+void
+dri_update_window_size(__DRIdrawablePrivate *dPriv);
+
+
+#endif
diff --git a/src/gallium/state_trackers/glx/dri/dri_extensions.c b/src/gallium/state_trackers/glx/dri/dri_extensions.c
new file mode 100644
index 0000000000..126faf7601
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_extensions.c
@@ -0,0 +1,108 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * 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.
+ *
+ **************************************************************************/
+
+
+
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_point_parameters
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_buffer_object
+#define need_GL_ARB_vertex_program
+#define need_GL_ARB_window_pos
+#define need_GL_EXT_blend_color
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_cull_vertex
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_framebuffer_object
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_secondary_color
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
+
+/**
+ * Extension strings exported by the driver.
+ */
+const struct dri_extension card_extensions[] = {
+ {"GL_ARB_multisample", GL_ARB_multisample_functions},
+ {"GL_ARB_multitexture", NULL},
+ {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
+ {"GL_ARB_texture_border_clamp", NULL},
+ {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
+ {"GL_ARB_texture_cube_map", NULL},
+ {"GL_ARB_texture_env_add", NULL},
+ {"GL_ARB_texture_env_combine", NULL},
+ {"GL_ARB_texture_env_dot3", NULL},
+ {"GL_ARB_texture_mirrored_repeat", NULL},
+ {"GL_ARB_texture_rectangle", NULL},
+ {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
+ {"GL_ARB_pixel_buffer_object", NULL},
+ {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
+ {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
+ {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
+ {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
+ {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
+ {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
+ {"GL_EXT_blend_subtract", NULL},
+ {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
+ {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
+ {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
+ {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
+ {"GL_EXT_packed_depth_stencil", NULL},
+ {"GL_EXT_pixel_buffer_object", NULL},
+ {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
+ {"GL_EXT_stencil_wrap", NULL},
+ {"GL_EXT_texture_edge_clamp", NULL},
+ {"GL_EXT_texture_env_combine", NULL},
+ {"GL_EXT_texture_env_dot3", NULL},
+ {"GL_EXT_texture_filter_anisotropic", NULL},
+ {"GL_EXT_texture_lod_bias", NULL},
+ {"GL_3DFX_texture_compression_FXT1", NULL},
+ {"GL_APPLE_client_storage", NULL},
+ {"GL_MESA_pack_invert", NULL},
+ {"GL_MESA_ycbcr_texture", NULL},
+ {"GL_NV_blend_square", NULL},
+ {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
+ {"GL_NV_vertex_program1_1", NULL},
+ {"GL_SGIS_generate_mipmap", NULL },
+ {NULL, NULL}
+};
+
+
+
+void
+dri_init_extensions( void )
+{
+ /* The card_extensions list should be pruned according to the
+ * capabilities of the pipe_screen. This is actually something
+ * that can/should be done inside st_create_context().
+ */
+ driInitExtensions( ctx->st->ctx, card_extensions, GL_TRUE );
+}
diff --git a/src/gallium/state_trackers/glx/dri/dri_lock.c b/src/gallium/state_trackers/glx/dri/dri_lock.c
new file mode 100644
index 0000000000..b272ab55f3
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_lock.c
@@ -0,0 +1,90 @@
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * 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 "pipe/p_thread.h"
+#include "dri_context.h"
+#include "xf86drm.h"
+
+pipe_static_mutex( lockMutex );
+
+static void
+dri_contended_lock(struct dri_context *ctx)
+{
+ __DRIdrawablePrivate *dPriv = ctx->dPriv;
+ __DRIcontextPrivate *cPriv = ctx->cPriv;
+ __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
+
+ drmGetLock(sPriv->fd, cPriv->hHWContext, 0);
+
+ /* Perform round trip communication with server (including dropping
+ * and retaking the above lock) to update window dimensions:
+ */
+ if (dPriv)
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+}
+
+
+/* Lock the hardware and validate our state.
+ */
+void dri_lock_hardware( struct dri_context *ctx )
+{
+ __DRIcontextPrivate *cPriv = ctx->cPriv;
+ __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
+ char __ret = 0;
+
+ pipe_mutex_lock(lockMutex);
+ assert(!ctx->locked);
+
+ DRM_CAS((drmLock *) &sPriv->pSAREA->lock,
+ cPriv->hHWContext,
+ (DRM_LOCK_HELD | cPriv->hHWContext),
+ __ret);
+
+ if (__ret)
+ dri_contended_lock( ctx );
+
+ ctx->locked = TRUE;
+}
+
+
+/* Unlock the hardware using the global current context
+ */
+void dri_unlock_hardware( struct dri_context *ctx )
+{
+ __DRIcontextPrivate *cPriv = ctx->cPriv;
+ __DRIscreenPrivate *sPriv = cPriv->driScreenPriv;
+
+ assert(ctx->locked);
+ ctx->locked = FALSE;
+
+ DRM_UNLOCK(sPriv->fd,
+ (drmLock *) &sPriv->pSAREA->lock,
+ cPriv->hHWContext);
+
+ pipe_mutex_unlock(lockMutex);
+}
diff --git a/src/gallium/state_trackers/glx/dri/dri_screen.c b/src/gallium/state_trackers/glx/dri/dri_screen.c
new file mode 100644
index 0000000000..f7119b949a
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_screen.c
@@ -0,0 +1,255 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * 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 "utils.h"
+#include "vblank.h"
+#include "xmlpool.h"
+
+#include "dri_context.h"
+#include "dri_screen.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "pipe/p_inlines.h"
+#include "state_tracker/st_public.h"
+#include "state_tracker/st_cb_fbo.h"
+
+
+PUBLIC const char __driConfigOptions[] =
+ DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
+// DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_ALLOW_LARGE_TEXTURES(1)
+ DRI_CONF_SECTION_END DRI_CONF_END;
+
+const uint __driNConfigOptions = 3;
+
+static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
+
+extern const struct dri_extension card_extensions[];
+
+
+
+static const __DRIextension *driScreenExtensions[] = {
+ &driReadDrawableExtension,
+ &driCopySubBufferExtension.base,
+ &driSwapControlExtension.base,
+ &driFrameTrackingExtension.base,
+ &driMediaStreamCounterExtension.base,
+ NULL
+};
+
+
+
+
+static const char *
+dri_get_name( struct pipe_winsys *winsys )
+{
+ return "dri";
+}
+
+
+
+static void
+dri_destroy_screen(__DRIscreenPrivate * sPriv)
+{
+ struct dri_screen *screen = dri_screen(sPriv);
+
+ screen->pipe_screen->destroy( screen->pipe_screen );
+ screen->pipe_winsys->destroy( screen->pipe_winsys );
+ FREE(screen);
+ sPriv->private = NULL;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+dri_get_swap_info(__DRIdrawablePrivate * dPriv,
+ __DRIswapInfo * sInfo)
+{
+ if (dPriv == NULL ||
+ dPriv->driverPrivate == NULL ||
+ sInfo == NULL)
+ return -1;
+ else
+ return 0;
+}
+
+static const __DRIconfig **
+dri_fill_in_modes(__DRIscreenPrivate *psp,
+ unsigned pixel_bits )
+{
+ __DRIconfig **configs;
+ __GLcontextModes *m;
+ unsigned num_modes;
+ uint8_t depth_bits_array[3];
+ uint8_t stencil_bits_array[3];
+ uint8_t msaa_samples_array[1];
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+ int i;
+
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML
+ };
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+ depth_bits_array[2] = depth_bits;
+
+ stencil_bits_array[0] = 0; /* no depth or stencil */
+ stencil_bits_array[1] = 0; /* z24x8 */
+ stencil_bits_array[2] = 8; /* z24s8 */
+
+ msaa_samples_array[0] = 0;
+
+ depth_buffer_factor = 3;
+ back_buffer_factor = 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if (pixel_bits == 16) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ configs = driCreateConfigs(fb_format, fb_type,
+ depth_bits_array,
+ stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ msaa_samples_array, 1);
+ if (configs == NULL) {
+ debug_printf("%s: driCreateConfigs failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ return configs;
+}
+
+
+
+/* This is the driver specific part of the createNewScreen entry point.
+ *
+ * Returns the __GLcontextModes supported by this driver.
+ */
+static const __DRIconfig **dri_init_screen(__DRIscreenPrivate *sPriv)
+{
+ static const __DRIversion ddx_expected = { 1, 6, 0 }; /* hw query */
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 5, 0 }; /* hw query */
+ struct dri_screen *screen;
+
+ if (!driCheckDriDdxDrmVersions2("dri",
+ &sPriv->dri_version, &dri_expected,
+ &sPriv->ddx_version, &ddx_expected,
+ &sPriv->drm_version, &drm_expected)) {
+ return NULL;
+ }
+
+ /* Set up dispatch table to cope with all known extensions:
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+
+
+ screen = CALLOC_STRUCT(dri_screen);
+ if (!screen)
+ goto fail;
+
+ screen->sPriv = sPriv;
+ sPriv->private = (void *) screen;
+
+
+ /* Search the registered winsys' for one that likes this sPriv.
+ * This is required in situations where multiple devices speak to
+ * the same DDX and are built into the same binary.
+ *
+ * Note that cases like Intel i915 vs i965 doesn't fall into this
+ * category because they are built into separate binaries.
+ *
+ * Nonetheless, it's healthy to keep that level of detail out of
+ * this state_tracker.
+ */
+ for (i = 0;
+ i < dri1_winsys_count &&
+ screen->st_winsys == NULL;
+ i++)
+ {
+ screen->dri_winsys =
+ dri_winsys[i]->check_dri_privates( sPriv->pDevPriv,
+ sPriv->pSAREA
+ /* versions, etc?? */));
+ }
+
+
+ driParseOptionInfo(&screen->optionCache,
+ __driConfigOptions,
+ __driNConfigOptions);
+
+
+ /* Plug our info back into the __DRIscreenPrivate:
+ */
+ sPriv->private = (void *) screen;
+ sPriv->extensions = driScreenExtensions;
+
+ return dri_fill_in_modes(sPriv,
+ dri_priv->cpp * 8,
+ 24,
+ 8,
+ 1);
+fail:
+ return NULL;
+}
+
+
+
+const struct __DriverAPIRec driDriverAPI = {
+ .InitScreen = dri_init_screen,
+ .DestroyScreen = dri_destroy_screen,
+ .CreateContext = dri_create_context,
+ .DestroyContext = dri_destroy_context,
+ .CreateBuffer = dri_create_buffer,
+ .DestroyBuffer = dri_destroy_buffer,
+ .SwapBuffers = dri_swap_buffers,
+ .MakeCurrent = dri_make_current,
+ .UnbindContext = dri_unbind_context,
+ .GetSwapInfo = dri_get_swap_info,
+ .GetDrawableMSC = driDrawableGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .CopySubBuffer = dri_copy_sub_buffer,
+
+ //.InitScreen2 = dri_init_screen2,
+};
diff --git a/src/gallium/state_trackers/glx/dri/dri_screen.h b/src/gallium/state_trackers/glx/dri/dri_screen.h
new file mode 100644
index 0000000000..12ed86d22a
--- /dev/null
+++ b/src/gallium/state_trackers/glx/dri/dri_screen.h
@@ -0,0 +1,83 @@
+/**************************************************************************
+ *
+ * Copyright 2009, VMware, Inc.
+ * 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.
+ *
+ **************************************************************************/
+
+#ifndef DRI_SCREEN_H
+#define DRI_SCREEN_H
+
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+#include "pipe/p_compiler.h"
+
+struct dri_screen
+{
+ __DRIScreenPrivate *sPriv;
+ struct pipe_winsys *pipe_winsys;
+ struct pipe_screen *pipe_screen;
+
+ struct {
+ /* Need a pipe_surface pointer to do client-side swapbuffers:
+ */
+ unsigned long buffer_handle;
+ struct pipe_surface *surface;
+ struct pipe_texture *texture;
+
+ int pitch; /* row stride, in bytes */
+ int width;
+ int height;
+ int size;
+ int cpp; /* for front and back buffers */
+ } front;
+
+ int deviceID;
+ int drmMinor;
+
+
+ /**
+ * Configuration cache with default values for all contexts
+ */
+ driOptionCache optionCache;
+
+ /**
+ * Temporary(?) context to use for SwapBuffers or other situations in
+ * which we need a rendering context, but none is currently bound.
+ */
+ struct dri_context *dummyContext;
+};
+
+
+
+/** cast wrapper */
+static INLINE struct dri_screen *
+dri_screen(__DRIscreenPrivate *sPriv)
+{
+ return (struct dri_screen *) sPriv->private;
+}
+
+
+
+#endif
diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile
new file mode 100644
index 0000000000..1b63db1f0e
--- /dev/null
+++ b/src/gallium/state_trackers/glx/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 \
+ fakeglx_fonts.c \
+ xm_api.c
+
+
+include ../../../Makefile.template
+
+symlinks:
+
diff --git a/src/gallium/winsys/xlib/fakeglx.c b/src/gallium/state_trackers/glx/xlib/fakeglx.c
index fd2d222c85..65e7048188 100644
--- a/src/gallium/winsys/xlib/fakeglx.c
+++ b/src/gallium/state_trackers/glx/xlib/fakeglx.c
@@ -40,25 +40,18 @@
-#include "glxheader.h"
#include "glxapi.h"
-#include "GL/xmesa.h"
+#include "xm_api.h"
#include "context.h"
#include "config.h"
#include "macros.h"
#include "imports.h"
-#include "mtypes.h"
#include "version.h"
-#include "xfonts.h"
-#include "xmesaP.h"
+#include "fakeglx.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_public.h"
-#ifdef __VMS
-#define _mesa_sprintf sprintf
-#endif
-
/* This indicates the client-side GLX API and GLX encoder version. */
#define CLIENT_MAJOR_VERSION 1
#define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
@@ -76,7 +69,6 @@
#define VENDOR "Brian Paul"
#define EXTENSIONS \
- "GLX_MESA_set_3dfx_mode " \
"GLX_MESA_copy_sub_buffer " \
"GLX_MESA_pixmap_colormap " \
"GLX_MESA_release_buffers " \
@@ -116,22 +108,6 @@ static XMesaVisual *VisualTable = NULL;
static int NumVisuals = 0;
-/*
- * This struct and some code fragments borrowed
- * from Mark Kilgard's GLUT library.
- */
-typedef struct _OverlayInfo {
- /* Avoid 64-bit portability problems by being careful to use
- longs due to the way XGetWindowProperty is specified. Note
- that these parameters are passed as CARD32s over X
- protocol. */
- unsigned long overlay_visual;
- long transparent_type;
- long value;
- long layer;
-} OverlayInfo;
-
-
/* Macro to handle c_class vs class field name in XVisualInfo struct */
#if defined(__cplusplus) || defined(c_plusplus)
@@ -173,98 +149,6 @@ is_usable_visual( XVisualInfo *vinfo )
}
-
-/**
- * Get an array OverlayInfo records for specified screen.
- * \param dpy the display
- * \param screen screen number
- * \param numOverlays returns numver of OverlayInfo records
- * \return pointer to OverlayInfo array, free with XFree()
- */
-static OverlayInfo *
-GetOverlayInfo(Display *dpy, int screen, int *numOverlays)
-{
- Atom overlayVisualsAtom;
- Atom actualType;
- Status status;
- unsigned char *ovInfo;
- unsigned long sizeData, bytesLeft;
- int actualFormat;
-
- /*
- * The SERVER_OVERLAY_VISUALS property on the root window contains
- * a list of overlay visuals. Get that list now.
- */
- overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
- if (overlayVisualsAtom == None) {
- return 0;
- }
-
- status = XGetWindowProperty(dpy, RootWindow(dpy, screen),
- overlayVisualsAtom, 0L, (long) 10000, False,
- overlayVisualsAtom, &actualType, &actualFormat,
- &sizeData, &bytesLeft,
- &ovInfo);
-
- if (status != Success || actualType != overlayVisualsAtom ||
- actualFormat != 32 || sizeData < 4) {
- /* something went wrong */
- XFree((void *) ovInfo);
- *numOverlays = 0;
- return NULL;
- }
-
- *numOverlays = sizeData / 4;
- return (OverlayInfo *) ovInfo;
-}
-
-
-
-/**
- * Return the level (overlay, normal, underlay) of a given XVisualInfo.
- * Input: dpy - the X display
- * vinfo - the XVisualInfo to test
- * Return: level of the visual:
- * 0 = normal planes
- * >0 = overlay planes
- * <0 = underlay planes
- */
-static int
-level_of_visual( Display *dpy, XVisualInfo *vinfo )
-{
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen, i;
-
- overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
- if (!overlay_info) {
- return 0;
- }
-
- /* search the overlay visual list for the visual ID of interest */
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- if (ov->overlay_visual == vinfo->visualid) {
- /* found the visual */
- if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
- int level = ov->layer;
- XFree((void *) overlay_info);
- return level;
- }
- else {
- XFree((void *) overlay_info);
- return 0;
- }
- }
- }
-
- /* The visual ID was not found in the overlay list. */
- XFree((void *) overlay_info);
- return 0;
-}
-
-
-
-
/*
* Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
* configuration in our list of GLX visuals.
@@ -421,60 +305,28 @@ default_accum_bits(void)
static XMesaVisual
create_glx_visual( Display *dpy, XVisualInfo *visinfo )
{
- int vislevel;
GLint zBits = default_depth_bits();
GLint accBits = default_accum_bits();
GLboolean alphaFlag = default_alpha_bits() > 0;
- vislevel = level_of_visual( dpy, visinfo );
- if (vislevel) {
- /* Configure this visual as a CI, single-buffered overlay */
+ if (is_usable_visual( visinfo )) {
+ /* Configure this visual as RGB, double-buffered, depth-buffered. */
+ /* This is surely wrong for some people's needs but what else */
+ /* can be done? They should use glXChooseVisual(). */
return save_glx_visual( dpy, visinfo,
- GL_FALSE, /* rgb */
- GL_FALSE, /* alpha */
- GL_FALSE, /* double */
+ GL_TRUE, /* rgb */
+ alphaFlag, /* alpha */
+ GL_TRUE, /* double */
GL_FALSE, /* stereo */
- 0, /* depth bits */
- 0, /* stencil bits */
- 0,0,0,0, /* accum bits */
- vislevel, /* level */
+ zBits,
+ STENCIL_BITS,
+ accBits, /* r */
+ accBits, /* g */
+ accBits, /* b */
+ accBits, /* a */
+ 0, /* level */
0 /* numAux */
- );
- }
- else if (is_usable_visual( visinfo )) {
- if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
- /* Configure this visual as a COLOR INDEX visual. */
- return save_glx_visual( dpy, visinfo,
- GL_FALSE, /* rgb */
- GL_FALSE, /* alpha */
- GL_TRUE, /* double */
- GL_FALSE, /* stereo */
- zBits,
- STENCIL_BITS,
- 0, 0, 0, 0, /* accum bits */
- 0, /* level */
- 0 /* numAux */
- );
- }
- else {
- /* Configure this visual as RGB, double-buffered, depth-buffered. */
- /* This is surely wrong for some people's needs but what else */
- /* can be done? They should use glXChooseVisual(). */
- return save_glx_visual( dpy, visinfo,
- GL_TRUE, /* rgb */
- alphaFlag, /* alpha */
- GL_TRUE, /* double */
- GL_FALSE, /* stereo */
- zBits,
- STENCIL_BITS,
- accBits, /* r */
- accBits, /* g */
- accBits, /* b */
- accBits, /* a */
- 0, /* level */
- 0 /* numAux */
- );
- }
+ );
}
else {
_mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
@@ -512,45 +364,6 @@ find_glx_visual( Display *dpy, XVisualInfo *vinfo )
-/**
- * Return the transparent pixel value for a GLX visual.
- * Input: glxvis - the glx_visual
- * Return: a pixel value or -1 if no transparent pixel
- */
-static int
-transparent_pixel( XMesaVisual glxvis )
-{
- Display *dpy = glxvis->display;
- XVisualInfo *vinfo = glxvis->visinfo;
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen, i;
-
- overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
- if (!overlay_info) {
- return -1;
- }
-
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- if (ov->overlay_visual == vinfo->visualid) {
- /* found it! */
- if (ov->transparent_type == 0) {
- /* type 0 indicates no transparency */
- XFree((void *) overlay_info);
- return -1;
- }
- else {
- /* ov->value is the transparent pixel */
- XFree((void *) overlay_info);
- return ov->value;
- }
- }
- }
-
- /* The visual ID was not found in the overlay list. */
- XFree((void *) overlay_info);
- return -1;
-}
@@ -597,7 +410,7 @@ get_visual( Display *dpy, int scr, unsigned int depth, int xclass )
return NULL;
}
}
-
+
return vis;
}
@@ -650,89 +463,48 @@ get_env_visual(Display *dpy, int scr, const char *varname)
/*
- * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
- * Input: dpy, screen - X display and screen number
- * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
+ * Select an X visual which satisfies the RGBA flag and minimum depth.
+ * Input: dpy,
+ * screen - X display and screen number
* min_depth - minimum visual depth
* preferred_class - preferred GLX visual class or DONT_CARE
* Return: pointer to an XVisualInfo or NULL.
*/
static XVisualInfo *
-choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
+choose_x_visual( Display *dpy, int screen, int min_depth,
int preferred_class )
{
XVisualInfo *vis;
int xclass, visclass = 0;
int depth;
- if (rgba) {
- Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
- /* First see if the MESA_RGB_VISUAL env var is defined */
- vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
- if (vis) {
- return vis;
- }
- /* Otherwise, search for a suitable visual */
- if (preferred_class==DONT_CARE) {
- for (xclass=0;xclass<6;xclass++) {
- switch (xclass) {
- case 0: visclass = TrueColor; break;
- case 1: visclass = DirectColor; break;
- case 2: visclass = PseudoColor; break;
- case 3: visclass = StaticColor; break;
- case 4: visclass = GrayScale; break;
- case 5: visclass = StaticGray; break;
- }
- if (min_depth==0) {
- /* start with shallowest */
- for (depth=0;depth<=32;depth++) {
- if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
- /* Special case: try to get 8-bit PseudoColor before */
- /* 8-bit TrueColor */
- vis = get_visual( dpy, screen, 8, PseudoColor );
- if (vis) {
- return vis;
- }
- }
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- else {
- /* start with deepest */
- for (depth=32;depth>=min_depth;depth--) {
- if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
- /* Special case: try to get 8-bit PseudoColor before */
- /* 8-bit TrueColor */
- vis = get_visual( dpy, screen, 8, PseudoColor );
- if (vis) {
- return vis;
- }
- }
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
- }
- }
- else {
- /* search for a specific visual class */
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
- default: return NULL;
+ /* First see if the MESA_RGB_VISUAL env var is defined */
+ vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
+ if (vis) {
+ return vis;
+ }
+ /* Otherwise, search for a suitable visual */
+ if (preferred_class==DONT_CARE) {
+ for (xclass=0;xclass<6;xclass++) {
+ switch (xclass) {
+ case 0: visclass = TrueColor; break;
+ case 1: visclass = DirectColor; break;
+ case 2: visclass = PseudoColor; break;
+ case 3: visclass = StaticColor; break;
+ case 4: visclass = GrayScale; break;
+ case 5: visclass = StaticGray; break;
}
if (min_depth==0) {
/* start with shallowest */
for (depth=0;depth<=32;depth++) {
+ if (visclass==TrueColor && depth==8) {
+ /* Special case: try to get 8-bit PseudoColor before */
+ /* 8-bit TrueColor */
+ vis = get_visual( dpy, screen, 8, PseudoColor );
+ if (vis) {
+ return vis;
+ }
+ }
vis = get_visual( dpy, screen, depth, visclass );
if (vis) {
return vis;
@@ -742,6 +514,14 @@ choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
else {
/* start with deepest */
for (depth=32;depth>=min_depth;depth--) {
+ if (visclass==TrueColor && depth==8) {
+ /* Special case: try to get 8-bit PseudoColor before */
+ /* 8-bit TrueColor */
+ vis = get_visual( dpy, screen, 8, PseudoColor );
+ if (vis) {
+ return vis;
+ }
+ }
vis = get_visual( dpy, screen, depth, visclass );
if (vis) {
return vis;
@@ -751,56 +531,28 @@ choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
}
}
else {
- /* First see if the MESA_CI_VISUAL env var is defined */
- vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
- if (vis) {
- return vis;
- }
- /* Otherwise, search for a suitable visual, starting with shallowest */
- if (preferred_class==DONT_CARE) {
- for (xclass=0;xclass<4;xclass++) {
- switch (xclass) {
- case 0: visclass = PseudoColor; break;
- case 1: visclass = StaticColor; break;
- case 2: visclass = GrayScale; break;
- case 3: visclass = StaticGray; break;
- }
- /* try 8-bit up through 16-bit */
- for (depth=8;depth<=16;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- /* try min_depth up to 8-bit */
- for (depth=min_depth;depth<8;depth++) {
- vis = get_visual( dpy, screen, depth, visclass );
- if (vis) {
- return vis;
- }
- }
- }
+ /* search for a specific visual class */
+ switch (preferred_class) {
+ case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
+ case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
+ case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
+ case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
+ case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
+ case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
+ default: return NULL;
}
- else {
- /* search for a specific visual class */
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
- default: return NULL;
- }
- /* try 8-bit up through 16-bit */
- for (depth=8;depth<=16;depth++) {
+ if (min_depth==0) {
+ /* start with shallowest */
+ for (depth=0;depth<=32;depth++) {
vis = get_visual( dpy, screen, depth, visclass );
if (vis) {
return vis;
}
}
- /* try min_depth up to 8-bit */
- for (depth=min_depth;depth<8;depth++) {
+ }
+ else {
+ /* start with deepest */
+ for (depth=32;depth>=min_depth;depth--) {
vis = get_visual( dpy, screen, depth, visclass );
if (vis) {
return vis;
@@ -815,117 +567,6 @@ choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
-/*
- * Find the deepest X over/underlay visual of at least min_depth.
- * Input: dpy, screen - X display and screen number
- * level - the over/underlay level
- * trans_type - transparent pixel type: GLX_NONE_EXT,
- * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
- * or DONT_CARE
- * trans_value - transparent pixel value or DONT_CARE
- * min_depth - minimum visual depth
- * preferred_class - preferred GLX visual class or DONT_CARE
- * Return: pointer to an XVisualInfo or NULL.
- */
-static XVisualInfo *
-choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag,
- int level, int trans_type, int trans_value,
- int min_depth, int preferred_class )
-{
- OverlayInfo *overlay_info;
- int numOverlaysPerScreen;
- int i;
- XVisualInfo *deepvis;
- int deepest;
-
- /*DEBUG int tt, tv; */
-
- switch (preferred_class) {
- case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break;
- case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break;
- case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break;
- case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break;
- case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break;
- case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break;
- default: preferred_class = DONT_CARE;
- }
-
- overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen);
- if (!overlay_info) {
- return NULL;
- }
-
- /* Search for the deepest overlay which satisifies all criteria. */
- deepest = min_depth;
- deepvis = NULL;
-
- for (i = 0; i < numOverlaysPerScreen; i++) {
- const OverlayInfo *ov = overlay_info + i;
- XVisualInfo *vislist, vistemplate;
- int count;
-
- if (ov->layer!=level) {
- /* failed overlay level criteria */
- continue;
- }
- if (!(trans_type==DONT_CARE
- || (trans_type==GLX_TRANSPARENT_INDEX_EXT
- && ov->transparent_type>0)
- || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
- /* failed transparent pixel type criteria */
- continue;
- }
- if (trans_value!=DONT_CARE && trans_value!=ov->value) {
- /* failed transparent pixel value criteria */
- continue;
- }
-
- /* get XVisualInfo and check the depth */
- vistemplate.visualid = ov->overlay_visual;
- vistemplate.screen = scr;
- vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
- &vistemplate, &count );
-
- if (count!=1) {
- /* something went wrong */
- continue;
- }
- if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
- /* wrong visual class */
- continue;
- }
-
- /* if RGB was requested, make sure we have True/DirectColor */
- if (rgbFlag && vislist->CLASS != TrueColor
- && vislist->CLASS != DirectColor)
- continue;
-
- /* if CI was requested, make sure we have a color indexed visual */
- if (!rgbFlag
- && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
- continue;
-
- if (deepvis==NULL || vislist->depth > deepest) {
- /* YES! found a satisfactory visual */
- if (deepvis) {
- XFree( deepvis );
- }
- deepest = vislist->depth;
- deepvis = vislist;
- /* DEBUG tt = ov->transparent_type;*/
- /* DEBUG tv = ov->value; */
- }
- }
-
-/*DEBUG
- if (deepvis) {
- printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
- deepvis->visualid, level, deepvis->depth, tt, tv );
- }
-*/
- return deepvis;
-}
-
/**********************************************************************/
/*** Display-related functions ***/
@@ -1273,6 +914,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
(void) caveat;
+
/*
* Since we're only simulating the GLX extension this function will never
* find any real GL visuals. Instead, all we can do is try to find an RGB
@@ -1290,8 +932,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
if (vis) {
/* give the visual some useful GLX attributes */
double_flag = GL_TRUE;
- if (vis->depth > 8)
- rgb_flag = GL_TRUE;
+ rgb_flag = GL_TRUE;
depth_size = default_depth_bits();
stencil_size = STENCIL_BITS;
/* XXX accum??? */
@@ -1299,38 +940,17 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
}
else if (level==0) {
/* normal color planes */
- if (rgb_flag) {
- /* Get an RGB visual */
- int min_rgb = min_red + min_green + min_blue;
- if (min_rgb>1 && min_rgb<8) {
- /* a special case to be sure we can get a monochrome visual */
- min_rgb = 1;
- }
- vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
- }
- else {
- /* Get a color index visual */
- vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
- accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
+ /* Get an RGB visual */
+ int min_rgb = min_red + min_green + min_blue;
+ if (min_rgb>1 && min_rgb<8) {
+ /* a special case to be sure we can get a monochrome visual */
+ min_rgb = 1;
}
+ vis = choose_x_visual( dpy, screen, min_rgb, visual_type );
}
else {
- /* over/underlay planes */
- if (rgb_flag) {
- /* rgba overlay */
- int min_rgb = min_red + min_green + min_blue;
- if (min_rgb>1 && min_rgb<8) {
- /* a special case to be sure we can get a monochrome visual */
- min_rgb = 1;
- }
- vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
- trans_type, trans_value, min_rgb, visual_type );
- }
- else {
- /* color index overlay */
- vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
- trans_type, trans_value, min_ci, visual_type );
- }
+ _mesa_warning(NULL, "overlay not supported");
+ return NULL;
}
if (vis) {
@@ -1356,11 +976,16 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
/* we only support one size of stencil and accum buffers. */
if (stencil_size > 0)
stencil_size = STENCIL_BITS;
- if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
+
+ if (accumRedSize > 0 ||
+ accumGreenSize > 0 ||
+ accumBlueSize > 0 ||
accumAlphaSize > 0) {
+
accumRedSize =
- accumGreenSize =
- accumBlueSize = default_accum_bits();
+ accumGreenSize =
+ accumBlueSize = default_accum_bits();
+
accumAlphaSize = alpha_flag ? accumRedSize : 0;
}
@@ -1384,16 +1009,12 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list )
xmvis = choose_visual(dpy, screen, list, GL_FALSE);
if (xmvis) {
-#if 0
- return xmvis->vishandle;
-#else
/* create a new vishandle - the cached one may be stale */
xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
if (xmvis->vishandle) {
_mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
}
return xmvis->vishandle;
-#endif
}
else
return NULL;
@@ -1489,9 +1110,6 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
/* Out of memory, or context/drawable depth mismatch */
return False;
}
-#ifdef FX
- FXcreateContext( xmctx->xm_visual, draw, xmctx, drawBuffer );
-#endif
}
/* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
@@ -1509,9 +1127,6 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
/* Out of memory, or context/drawable depth mismatch */
return False;
}
-#ifdef FX
- FXcreateContext( xmctx->xm_visual, read, xmctx, readBuffer );
-#endif
}
if (no_rast &&
@@ -1541,7 +1156,7 @@ Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
}
else if (!ctx && !draw && !read) {
/* release current context w/out assigning new one. */
- XMesaMakeCurrent( NULL, NULL );
+ XMesaMakeCurrent2( NULL, NULL, NULL );
MakeCurrent_PrevContext = 0;
MakeCurrent_PrevDrawable = 0;
MakeCurrent_PrevReadable = 0;
@@ -1824,32 +1439,11 @@ get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
}
return 0;
case GLX_TRANSPARENT_TYPE_EXT:
- if (xmvis->mesa_visual.level==0) {
- /* normal planes */
- *value = GLX_NONE_EXT;
- }
- else if (xmvis->mesa_visual.level>0) {
- /* overlay */
- if (xmvis->mesa_visual.rgbMode) {
- *value = GLX_TRANSPARENT_RGB_EXT;
- }
- else {
- *value = GLX_TRANSPARENT_INDEX_EXT;
- }
- }
- else if (xmvis->mesa_visual.level<0) {
- /* underlay */
- *value = GLX_NONE_EXT;
- }
+ /* normal planes */
+ *value = GLX_NONE_EXT;
return 0;
case GLX_TRANSPARENT_INDEX_VALUE_EXT:
- {
- int pixel = transparent_pixel( xmvis );
- if (pixel>=0) {
- *value = pixel;
- }
- /* else undefined */
- }
+ /* undefined */
return 0;
case GLX_TRANSPARENT_RED_VALUE_EXT:
/* undefined */
@@ -2017,13 +1611,7 @@ Fake_glXWaitX( void )
static const char *
get_extensions( void )
{
-#ifdef FX
- const char *fx = _mesa_getenv("MESA_GLX_FX");
- if (fx && fx[0] != 'd') {
- return EXTENSIONS;
- }
-#endif
- return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
+ return EXTENSIONS;
}
@@ -2198,11 +1786,6 @@ Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
if (!xmbuf)
return 0;
-#ifdef FX
- /* XXX this will segfault if actually called */
- FXcreateContext(xmvis, win, NULL, xmbuf);
-#endif
-
(void) dpy;
(void) attribList; /* Ignored in GLX 1.3 */
@@ -2213,7 +1796,7 @@ Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
static void
Fake_glXDestroyWindow( Display *dpy, GLXWindow window )
{
- XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
+ XMesaBuffer b = XMesaFindBuffer(dpy, (Drawable) window);
if (b)
XMesaDestroyBuffer(b);
/* don't destroy X window */
@@ -2334,7 +1917,7 @@ Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
static void
Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
{
- XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
+ XMesaBuffer b = XMesaFindBuffer(dpy, (Drawable)pixmap);
if (b)
XMesaDestroyBuffer(b);
/* don't destroy X pixmap */
@@ -2988,50 +2571,6 @@ Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
return False;
}
-
-
-/*** GLX_MESA_set_3dfx_mode ***/
-
-static Bool
-Fake_glXSet3DfxModeMESA( int mode )
-{
- return XMesaSetFXmode( mode );
-}
-
-
-
-/*** GLX_NV_vertex_array range ***/
-static void *
-Fake_glXAllocateMemoryNV( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority )
-{
- (void) size;
- (void) readFrequency;
- (void) writeFrequency;
- (void) priority;
- return NULL;
-}
-
-
-static void
-Fake_glXFreeMemoryNV( GLvoid *pointer )
-{
- (void) pointer;
-}
-
-
-/*** GLX_MESA_agp_offset ***/
-
-static GLuint
-Fake_glXGetAGPOffsetMESA( const GLvoid *pointer )
-{
- (void) pointer;
- return ~0;
-}
-
-
/*** GLX_EXT_texture_from_pixmap ***/
static void
@@ -3052,16 +2591,15 @@ Fake_glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, int buffer)
}
-/* silence warning */
-extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-
/**
* Create a new GLX API dispatch table with its function pointers
* initialized to point to Mesa's "fake" GLX API functions.
- * Note: there's a similar function (_real_GetGLXDispatchTable) that
- * returns a new dispatch table with all pointers initalized to point
- * to "real" GLX functions (which understand GLX wire protocol, etc).
+ *
+ * Note: there used to be a similar function
+ * (_real_GetGLXDispatchTable) that returns a new dispatch table with
+ * all pointers initalized to point to "real" GLX functions (which
+ * understand GLX wire protocol, etc).
*/
struct _glxapi_table *
_mesa_GetGLXDispatchTable(void)
@@ -3197,16 +2735,6 @@ _mesa_GetGLXDispatchTable(void)
/*** GLX_MESA_pixmap_colormap ***/
glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
- /*** GLX_MESA_set_3dfx_mode ***/
- glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
-
- /*** GLX_NV_vertex_array_range ***/
- glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
- glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
-
- /*** GLX_MESA_agp_offset ***/
- glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
-
/*** GLX_EXT_texture_from_pixmap ***/
glx.BindTexImageEXT = Fake_glXBindTexImageEXT;
glx.ReleaseTexImageEXT = Fake_glXReleaseTexImageEXT;
diff --git a/src/gallium/winsys/xlib/xfonts.h b/src/gallium/state_trackers/glx/xlib/fakeglx.h
index e36f42f817..e5fd960072 100644
--- a/src/gallium/winsys/xlib/xfonts.h
+++ b/src/gallium/state_trackers/glx/xlib/fakeglx.h
@@ -24,15 +24,15 @@
*/
-#ifndef XFONTS_H
-#define XFONTS_H
+#ifndef FAKEGLX_H
+#define FAKEGLX_H
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
#include <X11/Xlib.h>
+struct _glxapi_table;
+
+extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
diff --git a/src/gallium/winsys/xlib/xfonts.c b/src/gallium/state_trackers/glx/xlib/fakeglx_fonts.c
index d72c600bd1..e359046756 100644
--- a/src/gallium/winsys/xlib/xfonts.c
+++ b/src/gallium/state_trackers/glx/xlib/fakeglx_fonts.c
@@ -28,14 +28,10 @@
* Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
*/
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include "glxheader.h"
#include "context.h"
#include "imports.h"
-#include "xfonts.h"
+#include "fakeglx.h"
+#include <GL/glx.h>
/* Some debugging info. */
diff --git a/src/gallium/winsys/xlib/glxapi.c b/src/gallium/state_trackers/glx/xlib/glxapi.c
index c059fc3edb..1ff04804f1 100644
--- a/src/gallium/winsys/xlib/glxapi.c
+++ b/src/gallium/state_trackers/glx/xlib/glxapi.c
@@ -37,13 +37,10 @@
#include "main/glheader.h"
#include "glapi/glapi.h"
#include "glxapi.h"
+#include "fakeglx.h"
#include "pipe/p_thread.h"
-extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
-extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
-
-
struct display_dispatch {
Display *Dpy;
struct _glxapi_table *Table;
@@ -999,93 +996,6 @@ glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colorm
return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
}
-
-
-/*** GLX_MESA_set_3dfx_mode ***/
-
-Bool PUBLIC
-glXSet3DfxModeMESA(int mode)
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return False;
- return (t->Set3DfxModeMESA)(mode);
-}
-
-
-
-/*** GLX_NV_vertex_array_range ***/
-
-void PUBLIC *
-glXAllocateMemoryNV( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return NULL;
- return (t->AllocateMemoryNV)(size, readFrequency, writeFrequency, priority);
-}
-
-
-void PUBLIC
-glXFreeMemoryNV( GLvoid *pointer )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return;
- (t->FreeMemoryNV)(pointer);
-}
-
-
-
-
-/*** GLX_MESA_agp_offset */
-
-GLuint PUBLIC
-glXGetAGPOffsetMESA( const GLvoid *pointer )
-{
- struct _glxapi_table *t;
- Display *dpy = glXGetCurrentDisplay();
- GET_DISPATCH(dpy, t);
- if (!t)
- return ~0;
- return (t->GetAGPOffsetMESA)(pointer);
-}
-
-
-/*** GLX_MESA_allocate_memory */
-
-void *
-glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
- float readfreq, float writefreq, float priority)
-{
- /* dummy */
- return NULL;
-}
-
-void
-glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
-{
- /* dummy */
-}
-
-
-GLuint
-glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
-{
- /* dummy */
- return 0;
-}
-
-
/*** GLX_EXT_texture_from_pixmap */
void
@@ -1120,45 +1030,6 @@ _glxapi_get_version(void)
}
-/*
- * Return array of extension strings.
- */
-const char **
-_glxapi_get_extensions(void)
-{
- static const char *extensions[] = {
-#ifdef GLX_EXT_import_context
- "GLX_EXT_import_context",
-#endif
-#ifdef GLX_SGI_video_sync
- "GLX_SGI_video_sync",
-#endif
-#ifdef GLX_MESA_copy_sub_buffer
- "GLX_MESA_copy_sub_buffer",
-#endif
-#ifdef GLX_MESA_release_buffers
- "GLX_MESA_release_buffers",
-#endif
-#ifdef GLX_MESA_pixmap_colormap
- "GLX_MESA_pixmap_colormap",
-#endif
-#ifdef GLX_MESA_set_3dfx_mode
- "GLX_MESA_set_3dfx_mode",
-#endif
-#ifdef GLX_SGIX_fbconfig
- "GLX_SGIX_fbconfig",
-#endif
-#ifdef GLX_SGIX_pbuffer
- "GLX_SGIX_pbuffer",
-#endif
-#ifdef GLX_EXT_texture_from_pixmap
- "GLX_EXT_texture_from_pixmap",
-#endif
- NULL
- };
- return extensions;
-}
-
/*
* Return size of the GLX dispatch table, in entries, not bytes.
@@ -1321,24 +1192,9 @@ static struct name_address_pair GLX_functions[] = {
/*** GLX_MESA_release_buffers ***/
{ "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
- /*** GLX_MESA_set_3dfx_mode ***/
- { "glXSet3DfxModeMESA", (__GLXextFuncPtr) glXSet3DfxModeMESA },
-
/*** GLX_ARB_get_proc_address ***/
{ "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
- /*** GLX_NV_vertex_array_range ***/
- { "glXAllocateMemoryNV", (__GLXextFuncPtr) glXAllocateMemoryNV },
- { "glXFreeMemoryNV", (__GLXextFuncPtr) glXFreeMemoryNV },
-
- /*** GLX_MESA_agp_offset ***/
- { "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
-
- /*** GLX_MESA_allocate_memory ***/
- { "glXAllocateMemoryMESA", (__GLXextFuncPtr) glXAllocateMemoryMESA },
- { "glXFreeMemoryMESA", (__GLXextFuncPtr) glXFreeMemoryMESA },
- { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr) glXGetMemoryOffsetMESA },
-
/*** GLX_EXT_texture_from_pixmap ***/
{ "glXBindTexImageEXT", (__GLXextFuncPtr) glXBindTexImageEXT },
{ "glXReleaseTexImageEXT", (__GLXextFuncPtr) glXReleaseTexImageEXT },
diff --git a/src/gallium/winsys/xlib/glxapi.h b/src/gallium/state_trackers/glx/xlib/glxapi.h
index 37de81e55a..b4e12b4162 100644
--- a/src/gallium/winsys/xlib/glxapi.h
+++ b/src/gallium/state_trackers/glx/xlib/glxapi.h
@@ -184,19 +184,6 @@ struct _glxapi_table {
/*** GLX_MESA_pixmap_colormap ***/
GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
- /*** GLX_MESA_set_3dfx_mode ***/
- Bool (*Set3DfxModeMESA)(int mode);
-
- /*** GLX_NV_vertex_array_range ***/
- void * (*AllocateMemoryNV)( GLsizei size,
- GLfloat readFrequency,
- GLfloat writeFrequency,
- GLfloat priority );
- void (*FreeMemoryNV)( GLvoid *pointer );
-
- /*** GLX_MESA_agp_offset ***/
- GLuint (*GetAGPOffsetMESA)( const GLvoid *pointer );
-
/*** GLX_EXT_texture_from_pixmap ***/
void (*BindTexImageEXT)(Display *dpy, GLXDrawable drawable, int buffer,
const int *attrib_list);
@@ -209,8 +196,6 @@ extern const char *
_glxapi_get_version(void);
-extern const char **
-_glxapi_get_extensions(void);
extern GLuint
diff --git a/src/gallium/winsys/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index d28a6423b9..e0b666ffc8 100644
--- a/src/gallium/winsys/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -57,9 +57,7 @@
#undef __WIN32__
#endif
-#include "glxheader.h"
-#include "GL/xmesa.h"
-#include "xmesaP.h"
+#include "xm_api.h"
#include "main/context.h"
#include "main/framebuffer.h"
@@ -69,7 +67,20 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
-#include "xm_winsys_aub.h"
+#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
@@ -77,8 +88,6 @@
pipe_mutex _xmesa_lock;
-int xmesa_mode;
-
/**********************************************************************/
/***** X Utility Functions *****/
@@ -88,14 +97,12 @@ int xmesa_mode;
/**
* Return the host's byte order as LSBFirst or MSBFirst ala X.
*/
-#ifndef XFree86Server
static int host_byte_order( void )
{
int i = 1;
char *cptr = (char *) &i;
return (*cptr==1) ? LSBFirst : MSBFirst;
}
-#endif
/**
@@ -104,9 +111,9 @@ static int host_byte_order( void )
* 1 = shared XImage support available
* 2 = shared Pixmap support available also
*/
-int xmesa_check_for_xshm( XMesaDisplay *display )
+int xmesa_check_for_xshm( Display *display )
{
-#if defined(USE_XSHM) && !defined(XFree86Server)
+#if defined(USE_XSHM)
int major, minor, ignore;
Bool pixmaps;
@@ -146,19 +153,9 @@ int xmesa_check_for_xshm( XMesaDisplay *display )
static int
bits_per_pixel( XMesaVisual xmv )
{
-#ifdef XFree86Server
- const int depth = xmv->nplanes;
- int i;
- assert(depth > 0);
- for (i = 0; i < screenInfo.numPixmapFormats; i++) {
- if (screenInfo.formats[i].depth == depth)
- return screenInfo.formats[i].bitsPerPixel;
- }
- return depth; /* should never get here, but this should be safe */
-#else
- XMesaDisplay *dpy = xmv->display;
- XMesaVisualInfo visinfo = xmv->visinfo;
- XMesaImage *img;
+ Display *dpy = xmv->display;
+ XVisualInfo * visinfo = xmv->visinfo;
+ XImage *img;
int bitsPerPixel;
/* Create a temporary XImage */
img = XCreateImage( dpy, visinfo->visual, visinfo->depth,
@@ -174,9 +171,8 @@ bits_per_pixel( XMesaVisual xmv )
/* free the XImage */
_mesa_free( img->data );
img->data = NULL;
- XMesaDestroyImage( img );
+ XDestroyImage( img );
return bitsPerPixel;
-#endif
}
@@ -190,10 +186,9 @@ bits_per_pixel( XMesaVisual xmv )
* Return: GL_TRUE - window exists
* GL_FALSE - window doesn't exist
*/
-#ifndef XFree86Server
static GLboolean WindowExistsFlag;
-static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
+static int window_exists_err_handler( Display* dpy, XErrorEvent* xerr )
{
(void) dpy;
if (xerr->error_code == BadWindow) {
@@ -202,10 +197,10 @@ static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
return 0;
}
-static GLboolean window_exists( XMesaDisplay *dpy, Window win )
+static GLboolean window_exists( Display *dpy, Window win )
{
XWindowAttributes wa;
- int (*old_handler)( XMesaDisplay*, XErrorEvent* );
+ int (*old_handler)( Display*, XErrorEvent* );
WindowExistsFlag = GL_TRUE;
old_handler = XSetErrorHandler(window_exists_err_handler);
XGetWindowAttributes( dpy, win, &wa ); /* dummy request */
@@ -214,7 +209,7 @@ static GLboolean window_exists( XMesaDisplay *dpy, Window win )
}
static Status
-get_drawable_size( XMesaDisplay *dpy, Drawable d, uint *width, uint *height )
+get_drawable_size( Display *dpy, Drawable d, uint *width, uint *height )
{
Window root;
Status stat;
@@ -225,7 +220,6 @@ get_drawable_size( XMesaDisplay *dpy, Drawable d, uint *width, uint *height )
*height = h;
return stat;
}
-#endif
/**
@@ -235,13 +229,9 @@ get_drawable_size( XMesaDisplay *dpy, Drawable d, uint *width, uint *height )
* \param height returns height in pixels
*/
static void
-xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
+xmesa_get_window_size(Display *dpy, XMesaBuffer b,
GLuint *width, GLuint *height)
{
-#ifdef XFree86Server
- *width = MIN2(b->drawable->width, MAX_WIDTH);
- *height = MIN2(b->drawable->height, MAX_HEIGHT);
-#else
Status stat;
pipe_mutex_lock(_xmesa_lock);
@@ -254,9 +244,12 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
_mesa_warning(NULL, "XGetGeometry failed!\n");
*width = *height = 1;
}
-#endif
}
+#define GET_REDMASK(__v) __v->mesa_visual.redMask
+#define GET_GREENMASK(__v) __v->mesa_visual.greenMask
+#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
+
/**
* Choose the pixel format for the given visual.
@@ -266,11 +259,14 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
static GLuint
choose_pixel_format(XMesaVisual v)
{
+ boolean native_byte_order = (host_byte_order() ==
+ ImageByteOrder(v->display));
+
if ( GET_REDMASK(v) == 0x0000ff
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0xff0000
&& v->BitsPerPixel == 32) {
- if (CHECK_BYTE_ORDER(v)) {
+ if (native_byte_order) {
/* no byteswapping needed */
return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */;
}
@@ -282,7 +278,7 @@ choose_pixel_format(XMesaVisual v)
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0x0000ff
&& v->BitsPerPixel == 32) {
- if (CHECK_BYTE_ORDER(v)) {
+ if (native_byte_order) {
/* no byteswapping needed */
return PIPE_FORMAT_A8R8G8B8_UNORM;
}
@@ -293,7 +289,7 @@ choose_pixel_format(XMesaVisual v)
else if ( GET_REDMASK(v) == 0xf800
&& GET_GREENMASK(v) == 0x07e0
&& GET_BLUEMASK(v) == 0x001f
- && CHECK_BYTE_ORDER(v)
+ && native_byte_order
&& v->BitsPerPixel == 16) {
/* 5-6-5 RGB */
return PIPE_FORMAT_R5G6B5_UNORM;
@@ -324,8 +320,8 @@ XMesaBuffer XMesaBufferList = NULL;
* \return new XMesaBuffer or NULL if any problem
*/
static XMesaBuffer
-create_xmesa_buffer(XMesaDrawable d, BufferType type,
- XMesaVisual vis, XMesaColormap cmap)
+create_xmesa_buffer(Drawable d, BufferType type,
+ XMesaVisual vis, Colormap cmap)
{
XMesaBuffer b;
GLframebuffer *fb;
@@ -418,7 +414,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
* the notThis buffer.
*/
XMesaBuffer
-xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis)
+xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis)
{
XMesaBuffer b;
for (b = XMesaBufferList; b; b = b->Next) {
@@ -496,13 +492,9 @@ xmesa_free_buffer(XMesaBuffer buffer)
*/
static GLboolean
initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
- GLboolean rgb_flag, XMesaDrawable window,
- XMesaColormap cmap)
+ GLboolean rgb_flag, Drawable window,
+ Colormap cmap)
{
-#ifdef XFree86Server
- int client = (window) ? CLIENT_ID(window->id) : 0;
-#endif
-
ASSERT(!b || b->xm_visual == v);
/* Save true bits/pixel */
@@ -542,7 +534,7 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
if (_mesa_getenv("MESA_INFO")) {
_mesa_printf("X/Mesa visual = %p\n", (void *) v);
_mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level);
- _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v));
+ _mesa_printf("X/Mesa depth = %d\n", v->visinfo->depth);
_mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel);
}
@@ -557,12 +549,8 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
}
/* X11 graphics context */
-#ifdef XFree86Server
- b->gc = CreateScratchGC(v->display, window->depth);
-#else
b->gc = XCreateGC( v->display, window, 0, NULL );
-#endif
- XMesaSetFunction( v->display, b->gc, GXcopy );
+ XSetFunction( v->display, b->gc, GXcopy );
}
return GL_TRUE;
@@ -627,8 +615,8 @@ xmesa_convert_from_x_visual_type( int visualType )
* Return; a new XMesaVisual or 0 if error.
*/
PUBLIC
-XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
- XMesaVisualInfo visinfo,
+XMesaVisual XMesaCreateVisual( Display *display,
+ XVisualInfo * visinfo,
GLboolean rgb_flag,
GLboolean alpha_flag,
GLboolean db_flag,
@@ -647,7 +635,6 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
XMesaVisual v;
GLint red_bits, green_bits, blue_bits, alpha_bits;
-#ifndef XFree86Server
/* For debugging only */
if (_mesa_getenv("MESA_XSYNC")) {
/* This makes debugging X easier.
@@ -656,7 +643,6 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
*/
XSynchronize( display, 1 );
}
-#endif
v = (XMesaVisual) CALLOC_STRUCT(xmesa_visual);
if (!v) {
@@ -669,41 +655,22 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
* the struct but we may need some of the information contained in it
* at a later time.
*/
-#ifndef XFree86Server
v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
if(!v->visinfo) {
_mesa_free(v);
return NULL;
}
MEMCPY(v->visinfo, visinfo, sizeof(*visinfo));
-#endif
v->ximage_flag = ximage_flag;
-#ifdef XFree86Server
- /* We could calculate these values by ourselves. nplanes is either the sum
- * of the red, green, and blue bits or the number index bits.
- * ColormapEntries is either (1U << index_bits) or
- * (1U << max(redBits, greenBits, blueBits)).
- */
- assert(visinfo->nplanes > 0);
- v->nplanes = visinfo->nplanes;
- v->ColormapEntries = visinfo->ColormapEntries;
-
- v->mesa_visual.redMask = visinfo->redMask;
- v->mesa_visual.greenMask = visinfo->greenMask;
- v->mesa_visual.blueMask = visinfo->blueMask;
- v->mesa_visual.visualID = visinfo->vid;
- v->mesa_visual.screen = 0; /* FIXME: What should be done here? */
-#else
v->mesa_visual.redMask = visinfo->red_mask;
v->mesa_visual.greenMask = visinfo->green_mask;
v->mesa_visual.blueMask = visinfo->blue_mask;
v->mesa_visual.visualID = visinfo->visualid;
v->mesa_visual.screen = visinfo->screen;
-#endif
-#if defined(XFree86Server) || !(defined(__cplusplus) || defined(c_plusplus))
+#if !(defined(__cplusplus) || defined(c_plusplus))
v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->class);
#else
v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->c_class);
@@ -726,14 +693,14 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
else {
/* this is an approximation */
int depth;
- depth = GET_VISUAL_DEPTH(v);
+ depth = v->visinfo->depth;
red_bits = depth / 3;
depth -= red_bits;
green_bits = depth / 2;
depth -= green_bits;
blue_bits = depth;
alpha_bits = 0;
- assert( red_bits + green_bits + blue_bits == GET_VISUAL_DEPTH(v) );
+ assert( red_bits + green_bits + blue_bits == v->visinfo->depth );
}
alpha_bits = v->mesa_visual.alphaBits;
}
@@ -758,9 +725,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
PUBLIC
void XMesaDestroyVisual( XMesaVisual v )
{
-#ifndef XFree86Server
_mesa_free(v->visinfo);
-#endif
_mesa_free(v);
}
@@ -777,6 +742,7 @@ PUBLIC
XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
{
static GLboolean firstTime = GL_TRUE;
+ struct pipe_screen *screen;
struct pipe_context *pipe;
XMesaContext c;
GLcontext *mesaCtx;
@@ -797,24 +763,24 @@ 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.
+ */
+ screen = driver.create_pipe_screen();
+ if (screen == 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));
- }
-
+ pipe = driver.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;
@@ -826,13 +792,6 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
_mesa_enable_2_0_extensions(mesaCtx);
#endif
-#ifdef XFree86Server
- /* If we're running in the X server, do bounds checking to prevent
- * segfaults and server crashes!
- */
- mesaCtx->Const.CheckArrayBounds = GL_TRUE;
-#endif
-
return c;
fail:
@@ -840,6 +799,10 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
st_destroy_context(c->st);
else if (pipe)
pipe->destroy(pipe);
+
+ if (screen)
+ screen->destroy( screen );
+
FREE(c);
return NULL;
}
@@ -849,12 +812,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);
}
@@ -868,35 +833,26 @@ void XMesaDestroyContext( XMesaContext c )
* \return new XMesaBuffer or NULL if error
*/
PUBLIC XMesaBuffer
-XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w)
+XMesaCreateWindowBuffer(XMesaVisual v, Window w)
{
-#ifndef XFree86Server
XWindowAttributes attr;
-#endif
XMesaBuffer b;
- XMesaColormap cmap;
+ Colormap cmap;
int depth;
assert(v);
assert(w);
/* Check that window depth matches visual depth */
-#ifdef XFree86Server
- depth = ((XMesaDrawable)w)->depth;
-#else
XGetWindowAttributes( v->display, w, &attr );
depth = attr.depth;
-#endif
- if (GET_VISUAL_DEPTH(v) != depth) {
+ if (v->visinfo->depth != depth) {
_mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
- GET_VISUAL_DEPTH(v), depth);
+ v->visinfo->depth, depth);
return NULL;
}
/* Find colormap */
-#ifdef XFree86Server
- cmap = (ColormapPtr)LookupIDByType(wColormap(w), RT_COLORMAP);
-#else
if (attr.colormap) {
cmap = attr.colormap;
}
@@ -906,14 +862,13 @@ XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w)
/* OK, let's just allocate a new one and hope for the best */
cmap = XCreateColormap(v->display, w, attr.visual, AllocNone);
}
-#endif
- b = create_xmesa_buffer((XMesaDrawable) w, WINDOW, v, cmap);
+ b = create_xmesa_buffer((Drawable) w, WINDOW, v, cmap);
if (!b)
return NULL;
if (!initialize_visual_and_buffer( v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) w, cmap )) {
+ (Drawable) w, cmap )) {
xmesa_free_buffer(b);
return NULL;
}
@@ -933,18 +888,18 @@ XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w)
* \returns new XMesaBuffer or NULL if error
*/
PUBLIC XMesaBuffer
-XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
+XMesaCreatePixmapBuffer(XMesaVisual v, Pixmap p, Colormap cmap)
{
XMesaBuffer b;
assert(v);
- b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap);
+ b = create_xmesa_buffer((Drawable) p, PIXMAP, v, cmap);
if (!b)
return NULL;
if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) p, cmap)) {
+ (Drawable) p, cmap)) {
xmesa_free_buffer(b);
return NULL;
}
@@ -957,8 +912,8 @@ XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
* For GLX_EXT_texture_from_pixmap
*/
XMesaBuffer
-XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
- XMesaColormap cmap,
+XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
+ Colormap cmap,
int format, int target, int mipmap)
{
GET_CURRENT_CONTEXT(ctx);
@@ -967,7 +922,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
assert(v);
- b = create_xmesa_buffer((XMesaDrawable) p, PIXMAP, v, cmap);
+ b = create_xmesa_buffer((Drawable) p, PIXMAP, v, cmap);
if (!b)
return NULL;
@@ -1005,7 +960,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
b->TextureMipmap = mipmap;
if (!initialize_visual_and_buffer(v, b, v->mesa_visual.rgbMode,
- (XMesaDrawable) p, cmap)) {
+ (Drawable) p, cmap)) {
xmesa_free_buffer(b);
return NULL;
}
@@ -1016,12 +971,11 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
XMesaBuffer
-XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
+XMesaCreatePBuffer(XMesaVisual v, Colormap cmap,
unsigned int width, unsigned int height)
{
-#ifndef XFree86Server
- XMesaWindow root;
- XMesaDrawable drawable; /* X Pixmap Drawable */
+ Window root;
+ Drawable drawable; /* X Pixmap Drawable */
XMesaBuffer b;
/* allocate pixmap for front buffer */
@@ -1042,9 +996,6 @@ XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
}
return b;
-#else
- return 0;
-#endif
}
@@ -1064,8 +1015,7 @@ XMesaDestroyBuffer(XMesaBuffer b)
* and all attached renderbuffers.
* Called when:
* 1. the first time a buffer is bound to a context.
- * 2. from the XMesaResizeBuffers() API function.
- * 3. SwapBuffers. XXX probabaly from xm_flush_frontbuffer() too...
+ * 2. SwapBuffers. XXX probabaly from xm_flush_frontbuffer() too...
* Note: it's possible (and legal) for xmctx to be NULL. That can happen
* when resizing a buffer when no rendering context is bound.
*/
@@ -1078,13 +1028,6 @@ xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer)
}
-/*
- * Bind buffer b to context c and make c the current rendering context.
- */
-GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b )
-{
- return XMesaMakeCurrent2( c, b, b );
-}
/*
@@ -1156,76 +1099,8 @@ XMesaContext XMesaGetCurrentContext( void )
}
-XMesaBuffer XMesaGetCurrentBuffer( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- XMesaBuffer xmbuf = xmesa_buffer(ctx->DrawBuffer);
- return xmbuf;
- }
- else {
- return 0;
- }
-}
-/* New in Mesa 3.1 */
-XMesaBuffer XMesaGetCurrentReadBuffer( void )
-{
- GET_CURRENT_CONTEXT(ctx);
- if (ctx) {
- return xmesa_buffer(ctx->ReadBuffer);
- }
- else {
- return 0;
- }
-}
-
-
-#ifdef XFree86Server
-PUBLIC
-GLboolean XMesaForceCurrent(XMesaContext c)
-{
- if (c) {
- _glapi_set_dispatch(c->mesa.CurrentDispatch);
-
- if (&(c->mesa) != _mesa_get_current_context()) {
- _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer);
- }
- }
- else {
- _mesa_make_current(NULL, NULL, NULL);
- }
- return GL_TRUE;
-}
-
-
-PUBLIC
-GLboolean XMesaLoseCurrent(XMesaContext c)
-{
- (void) c;
- _mesa_make_current(NULL, NULL, NULL);
- return GL_TRUE;
-}
-
-
-PUBLIC
-GLboolean XMesaCopyContext( XMesaContext xm_src, XMesaContext xm_dst, GLuint mask )
-{
- _mesa_copy_context(&xm_src->mesa, &xm_dst->mesa, mask);
- return GL_TRUE;
-}
-#endif /* XFree86Server */
-
-
-#ifndef FX
-GLboolean XMesaSetFXmode( GLint mode )
-{
- (void) mode;
- return GL_FALSE;
-}
-#endif
-
/*
@@ -1244,10 +1119,7 @@ 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);
+ driver.display_surface(b, surf);
}
xmesa_check_and_update_buffer_size(NULL, b);
@@ -1278,56 +1150,19 @@ void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
-/*
- * Return the depth buffer associated with an XMesaBuffer.
- * Input: b - the XMesa buffer handle
- * Output: width, height - size of buffer in pixels
- * bytesPerValue - bytes per depth value (2 or 4)
- * buffer - pointer to depth buffer values
- * Return: GL_TRUE or GL_FALSE to indicate success or failure.
- */
-GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
- GLint *bytesPerValue, void **buffer )
-{
- *width = 0;
- *height = 0;
- *bytesPerValue = 0;
- *buffer = 0;
- return GL_FALSE;
-}
-
-
void XMesaFlush( XMesaContext c )
{
if (c && c->xm_visual->display) {
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
st_finish(c->st);
XSync( c->xm_visual->display, False );
-#endif
}
}
-const char *XMesaGetString( XMesaContext c, int name )
-{
- (void) c;
- if (name==XMESA_VERSION) {
- return "5.0";
- }
- else if (name==XMESA_EXTENSIONS) {
- return "";
- }
- else {
- return NULL;
- }
-}
-
-XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
+XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d )
{
XMesaBuffer b;
for (b=XMesaBufferList; b; b=b->Next) {
@@ -1342,7 +1177,7 @@ XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
/**
* Free/destroy all XMesaBuffers associated with given display.
*/
-void xmesa_destroy_buffers_on_display(XMesaDisplay *dpy)
+void xmesa_destroy_buffers_on_display(Display *dpy)
{
XMesaBuffer b, next;
for (b = XMesaBufferList; b; b = next) {
@@ -1367,48 +1202,20 @@ void XMesaGarbageCollect( void )
b->xm_visual->display &&
b->drawable &&
b->type == WINDOW) {
-#ifdef XFree86Server
- /* NOT_NEEDED */
-#else
XSync(b->xm_visual->display, False);
if (!window_exists( b->xm_visual->display, b->drawable )) {
/* found a dead window, free the ancillary info */
XMesaDestroyBuffer( b );
}
-#endif
}
}
}
-unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
- GLfloat red, GLfloat green,
- GLfloat blue, GLfloat alpha )
-{
- /* no longer supported */
- return 0;
-}
-
-
-/*
- * This is typically called when the window size changes and we need
- * to reallocate the buffer's back/depth/stencil/accum buffers.
- */
-PUBLIC void
-XMesaResizeBuffers( XMesaBuffer b )
-{
- GET_CURRENT_CONTEXT(ctx);
- XMesaContext xmctx = xmesa_context(ctx);
- if (!xmctx)
- return;
- xmesa_check_and_update_buffer_size(xmctx, b);
-}
-
-
PUBLIC void
-XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
+XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
const int *attrib_list)
{
}
@@ -1416,7 +1223,7 @@ XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
PUBLIC void
-XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer)
+XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer)
{
}
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h
new file mode 100644
index 0000000000..2b8302d174
--- /dev/null
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.h
@@ -0,0 +1,393 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.1
+ *
+ * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
+ * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL 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.
+ */
+
+
+
+/* Sample Usage:
+
+In addition to the usual X calls to select a visual, create a colormap
+and create a window, you must do the following to use the X/Mesa interface:
+
+1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
+
+2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
+ the XMesaVisual.
+
+3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
+ and XMesaVisual.
+
+4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
+ to make the context the current one.
+
+5. Make gl* calls to render your graphics.
+
+6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
+
+7. Before the X window is destroyed, call XMesaDestroyBuffer().
+
+8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
+
+*/
+
+
+
+
+#ifndef XMESA_H
+#define XMESA_H
+
+
+#include "mtypes.h"
+#include "state_tracker/st_context.h"
+#include "state_tracker/st_public.h"
+#include "pipe/p_thread.h"
+
+
+# include <X11/Xlib.h>
+# include <X11/Xlibint.h>
+# include <X11/Xutil.h>
+# ifdef USE_XSHM /* was SHM */
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <X11/extensions/XShm.h>
+# endif
+
+typedef struct xmesa_buffer *XMesaBuffer;
+typedef struct xmesa_context *XMesaContext;
+typedef struct xmesa_visual *XMesaVisual;
+
+
+
+/*
+ * Create a new X/Mesa visual.
+ * Input: display - X11 display
+ * visinfo - an XVisualInfo pointer
+ * rgb_flag - GL_TRUE = RGB mode,
+ * GL_FALSE = color index mode
+ * alpha_flag - alpha buffer requested?
+ * db_flag - GL_TRUE = double-buffered,
+ * GL_FALSE = single buffered
+ * stereo_flag - stereo visual?
+ * ximage_flag - GL_TRUE = use an XImage for back buffer,
+ * GL_FALSE = use an off-screen pixmap for back buffer
+ * depth_size - requested bits/depth values, or zero
+ * stencil_size - requested bits/stencil values, or zero
+ * accum_red_size - requested bits/red accum values, or zero
+ * accum_green_size - requested bits/green accum values, or zero
+ * accum_blue_size - requested bits/blue accum values, or zero
+ * accum_alpha_size - requested bits/alpha accum values, or zero
+ * num_samples - number of samples/pixel if multisampling, or zero
+ * level - visual level, usually 0
+ * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
+ * Return; a new XMesaVisual or 0 if error.
+ */
+extern XMesaVisual XMesaCreateVisual( Display *display,
+ XVisualInfo * visinfo,
+ GLboolean rgb_flag,
+ GLboolean alpha_flag,
+ GLboolean db_flag,
+ GLboolean stereo_flag,
+ GLboolean ximage_flag,
+ GLint depth_size,
+ GLint stencil_size,
+ GLint accum_red_size,
+ GLint accum_green_size,
+ GLint accum_blue_size,
+ GLint accum_alpha_size,
+ GLint num_samples,
+ GLint level,
+ GLint visualCaveat );
+
+/*
+ * Destroy an XMesaVisual, but not the associated XVisualInfo.
+ */
+extern void XMesaDestroyVisual( XMesaVisual v );
+
+
+
+/*
+ * Create a new XMesaContext for rendering into an X11 window.
+ *
+ * Input: visual - an XMesaVisual
+ * share_list - another XMesaContext with which to share display
+ * lists or NULL if no sharing is wanted.
+ * Return: an XMesaContext or NULL if error.
+ */
+extern XMesaContext XMesaCreateContext( XMesaVisual v,
+ XMesaContext share_list );
+
+
+/*
+ * Destroy a rendering context as returned by XMesaCreateContext()
+ */
+extern void XMesaDestroyContext( XMesaContext c );
+
+
+
+/*
+ * Create an XMesaBuffer from an X window.
+ */
+extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, Window w );
+
+
+/*
+ * Create an XMesaBuffer from an X pixmap.
+ */
+extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
+ Pixmap p,
+ Colormap cmap );
+
+
+/*
+ * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
+ */
+extern void XMesaDestroyBuffer( XMesaBuffer b );
+
+
+/*
+ * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
+ *
+ * New in Mesa 2.3.
+ */
+extern XMesaBuffer XMesaFindBuffer( Display *dpy,
+ Drawable d );
+
+
+
+/*
+ * Bind two buffers (read and draw) to a context and make the
+ * context the current one.
+ * New in Mesa 3.3
+ */
+extern GLboolean XMesaMakeCurrent2( XMesaContext c,
+ XMesaBuffer drawBuffer,
+ XMesaBuffer readBuffer );
+
+
+/*
+ * Unbind the current context from its buffer.
+ */
+extern GLboolean XMesaUnbindContext( XMesaContext c );
+
+
+/*
+ * Return a handle to the current context.
+ */
+extern XMesaContext XMesaGetCurrentContext( void );
+
+
+/*
+ * Swap the front and back buffers for the given buffer. No action is
+ * taken if the buffer is not double buffered.
+ */
+extern void XMesaSwapBuffers( XMesaBuffer b );
+
+
+/*
+ * Copy a sub-region of the back buffer to the front buffer.
+ *
+ * New in Mesa 2.6
+ */
+extern void XMesaCopySubBuffer( XMesaBuffer b,
+ int x,
+ int y,
+ int width,
+ int height );
+
+
+
+
+
+/*
+ * Flush/sync a context
+ */
+extern void XMesaFlush( XMesaContext c );
+
+
+
+/*
+ * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
+ * any memory used by that buffer.
+ *
+ * New in Mesa 2.3.
+ */
+extern void XMesaGarbageCollect( void );
+
+
+
+/*
+ * Create a pbuffer.
+ * New in Mesa 4.1
+ */
+extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, Colormap cmap,
+ unsigned int width, unsigned int height);
+
+
+
+/*
+ * Texture from Pixmap
+ * New in Mesa 7.1
+ */
+extern void
+XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
+ const int *attrib_list);
+
+extern void
+XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer);
+
+
+extern XMesaBuffer
+XMesaCreatePixmapTextureBuffer(XMesaVisual v, Pixmap p,
+ Colormap cmap,
+ int format, int target, int mipmap);
+
+
+
+
+/***********************************************************************
+ */
+
+extern pipe_mutex _xmesa_lock;
+
+extern struct xmesa_buffer *XMesaBufferList;
+
+
+/**
+ * Visual inforation, derived from GLvisual.
+ * Basically corresponds to an XVisualInfo.
+ */
+struct xmesa_visual {
+ GLvisual mesa_visual; /* Device independent visual parameters */
+ Display *display; /* The X11 display */
+ XVisualInfo * visinfo; /* X's visual info (pointer to private copy) */
+ XVisualInfo *vishandle; /* Only used in fakeglx.c */
+ GLint BitsPerPixel; /* True bits per pixel for XImages */
+
+ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
+};
+
+
+/**
+ * Context info, derived from st_context.
+ * Basically corresponds to a GLXContext.
+ */
+struct xmesa_context {
+ struct st_context *st;
+ XMesaVisual xm_visual; /** pixel format info */
+ XMesaBuffer xm_buffer; /** current drawbuffer */
+};
+
+
+/**
+ * Types of X/GLX drawables we might render into.
+ */
+typedef enum {
+ WINDOW, /* An X window */
+ GLXWINDOW, /* GLX window */
+ PIXMAP, /* GLX pixmap */
+ PBUFFER /* GLX Pbuffer */
+} BufferType;
+
+
+/**
+ * Framebuffer information, derived from.
+ * Basically corresponds to a GLXDrawable.
+ */
+struct xmesa_buffer {
+ struct st_framebuffer *stfb;
+
+ GLboolean wasCurrent; /* was ever the current buffer? */
+ XMesaVisual xm_visual; /* the X/Mesa visual */
+ Drawable drawable; /* Usually the X window ID */
+ Colormap cmap; /* the X colormap */
+ BufferType type; /* window, pixmap, pbuffer or glxwindow */
+
+ XImage *tempImage;
+ unsigned long selectedEvents;/* for pbuffers only */
+
+ GLuint shm; /* X Shared Memory extension status: */
+ /* 0 = not available */
+ /* 1 = XImage support available */
+ /* 2 = Pixmap support available too */
+#if defined(USE_XSHM)
+ XShmSegmentInfo shminfo;
+#endif
+
+ GC gc; /* scratch GC for span, line, tri drawing */
+
+ /* GLX_EXT_texture_from_pixmap */
+ GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
+ GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
+ GLint TextureMipmap; /** 0 or 1 */
+
+ struct xmesa_buffer *Next; /* Linked list pointer: */
+};
+
+
+
+/** cast wrapper */
+static INLINE XMesaContext
+xmesa_context(GLcontext *ctx)
+{
+ return (XMesaContext) ctx->DriverCtx;
+}
+
+
+/** cast wrapper */
+static INLINE XMesaBuffer
+xmesa_buffer(GLframebuffer *fb)
+{
+ struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
+ return (XMesaBuffer) st_framebuffer_private(stfb);
+}
+
+
+extern void
+xmesa_delete_framebuffer(struct gl_framebuffer *fb);
+
+extern XMesaBuffer
+xmesa_find_buffer(Display *dpy, Colormap cmap, XMesaBuffer notThis);
+
+extern void
+xmesa_check_and_update_buffer_size(XMesaContext xmctx, XMesaBuffer drawBuffer);
+
+extern void
+xmesa_destroy_buffers_on_display(Display *dpy);
+
+static INLINE GLuint
+xmesa_buffer_width(XMesaBuffer b)
+{
+ return b->stfb->Base.Width;
+}
+
+static INLINE GLuint
+xmesa_buffer_height(XMesaBuffer b)
+{
+ return b->stfb->Base.Height;
+}
+
+extern int
+xmesa_check_for_xshm(Display *display);
+
+
+#endif
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h
index cc2a755277..0e57605c34 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.h
+++ b/src/gallium/state_trackers/glx/xlib/xm_winsys.h
@@ -1,3 +1,4 @@
+
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
@@ -25,44 +26,34 @@
*
**************************************************************************/
-#ifndef AUB_WINSYS_H
-#define AUB_WINSYS_H
+#ifndef XM_WINSYS_H
+#define XM_WINSYS_H
struct pipe_context;
-struct pipe_winsys;
-struct pipe_buffer;
+struct pipe_screen;
struct pipe_surface;
-
-struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void );
-
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys );
-
+struct xmesa_buffer;
-struct pipe_context *
-xmesa_create_i965simple( struct pipe_winsys *winsys );
+struct xm_driver {
+ struct pipe_screen *(*create_pipe_screen)( void );
+ /* 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_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);
+ void (*display_surface)( struct xmesa_buffer *,
+ struct pipe_surface * );
-void xmesa_commands_aub(struct pipe_winsys *winsys,
- unsigned *cmds,
- unsigned nr_dwords);
+};
-void xmesa_display_aub( /* struct pipe_winsys *winsys, */
- struct pipe_surface *surface );
+extern void
+xmesa_set_driver( const struct xm_driver *driver );
-extern struct pipe_winsys *
-xmesa_get_pipe_winsys_aub(struct xmesa_visual *xm_vis);
#endif
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
index 11c7632411..bca59ac883 100644
--- a/src/gallium/winsys/xlib/Makefile
+++ b/src/gallium/winsys/xlib/Makefile
@@ -19,16 +19,18 @@ INCLUDE_DIRS = \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/drivers \
+ -I$(TOP)/src/gallium/state_trackers/glx/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_cell.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)
@@ -37,6 +39,7 @@ XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
LIBS = \
$(GALLIUM_DRIVERS) \
+ $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
$(TOP)/src/mesa/libglapi.a \
$(TOP)/src/mesa/libmesa.a \
$(GALLIUM_AUXILIARIES) \
@@ -57,7 +60,7 @@ default: $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
# Make the libGL.so library
-$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS)
+$(TOP)/$(LIB_DIR)/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile
$(TOP)/bin/mklib -o $(GL_LIB) \
-linker "$(CC)" \
-major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
diff --git a/src/gallium/winsys/xlib/glxheader.h b/src/gallium/winsys/xlib/glxheader.h
deleted file mode 100644
index a402191f13..0000000000
--- a/src/gallium/winsys/xlib/glxheader.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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.
- */
-
-
-#ifndef GLX_HEADER_H
-#define GLX_HEADER_H
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#include "glheader.h"
-
-#ifdef XFree86Server
-
-# include "resource.h"
-# include "windowstr.h"
-
-#else
-
-# include <X11/Xlib.h>
-# include <X11/Xlibint.h>
-# include <X11/Xutil.h>
-# ifdef USE_XSHM /* was SHM */
-# include <sys/ipc.h>
-# include <sys/shm.h>
-# include <X11/extensions/XShm.h>
-# endif
-# include <GL/glx.h>
-# include <sys/time.h>
-
-#endif
-
-
-
-/* this silences a compiler warning on several systems */
-struct timespec;
-struct itimerspec;
-
-
-#endif /*GLX_HEADER*/
diff --git a/src/gallium/winsys/xlib/realglx.c b/src/gallium/winsys/xlib/realglx.c
deleted file mode 100644
index 30adb7465b..0000000000
--- a/src/gallium/winsys/xlib/realglx.c
+++ /dev/null
@@ -1,180 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2002 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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 <assert.h>
-#include <GL/glx.h>
-#include "realglx.h"
-#include "glxapi.h"
-
-
-struct _glxapi_table *
-_real_GetGLXDispatchTable(void)
-{
- static struct _glxapi_table glx;
-
- /* be sure our dispatch table size <= libGL's table */
- {
- GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
- (void) size;
- assert(_glxapi_get_dispatch_table_size() >= size);
- }
-
- /* initialize the whole table to no-ops */
- _glxapi_set_no_op_table(&glx);
-
- /* now initialize the table with the functions I implement */
-
- /*** GLX_VERSION_1_0 ***/
- glx.ChooseVisual = _real_glXChooseVisual;
- glx.CopyContext = _real_glXCopyContext;
- glx.CreateContext = _real_glXCreateContext;
- glx.CreateGLXPixmap = _real_glXCreateGLXPixmap;
- glx.DestroyContext = _real_glXDestroyContext;
- glx.DestroyGLXPixmap = _real_glXDestroyGLXPixmap;
- glx.GetConfig = _real_glXGetConfig;
- /*glx.GetCurrentContext = _real_glXGetCurrentContext;*/
- /*glx.GetCurrentDrawable = _real_glXGetCurrentDrawable;*/
- glx.IsDirect = _real_glXIsDirect;
- glx.MakeCurrent = _real_glXMakeCurrent;
- glx.QueryExtension = _real_glXQueryExtension;
- glx.QueryVersion = _real_glXQueryVersion;
- glx.SwapBuffers = _real_glXSwapBuffers;
- glx.UseXFont = _real_glXUseXFont;
- glx.WaitGL = _real_glXWaitGL;
- glx.WaitX = _real_glXWaitX;
-
- /*** GLX_VERSION_1_1 ***/
- glx.GetClientString = _real_glXGetClientString;
- glx.QueryExtensionsString = _real_glXQueryExtensionsString;
- glx.QueryServerString = _real_glXQueryServerString;
-
- /*** GLX_VERSION_1_2 ***/
- /*glx.GetCurrentDisplay = _real_glXGetCurrentDisplay;*/
-
- /*** GLX_VERSION_1_3 ***/
- glx.ChooseFBConfig = _real_glXChooseFBConfig;
- glx.CreateNewContext = _real_glXCreateNewContext;
- glx.CreatePbuffer = _real_glXCreatePbuffer;
- glx.CreatePixmap = _real_glXCreatePixmap;
- glx.CreateWindow = _real_glXCreateWindow;
- glx.DestroyPbuffer = _real_glXDestroyPbuffer;
- glx.DestroyPixmap = _real_glXDestroyPixmap;
- glx.DestroyWindow = _real_glXDestroyWindow;
- /*glx.GetCurrentReadDrawable = _real_glXGetCurrentReadDrawable;*/
- glx.GetFBConfigAttrib = _real_glXGetFBConfigAttrib;
- glx.GetFBConfigs = _real_glXGetFBConfigs;
- glx.GetSelectedEvent = _real_glXGetSelectedEvent;
- glx.GetVisualFromFBConfig = _real_glXGetVisualFromFBConfig;
- glx.MakeContextCurrent = _real_glXMakeContextCurrent;
- glx.QueryContext = _real_glXQueryContext;
- glx.QueryDrawable = _real_glXQueryDrawable;
- glx.SelectEvent = _real_glXSelectEvent;
-
- /*** GLX_SGI_swap_control ***/
- glx.SwapIntervalSGI = _real_glXSwapIntervalSGI;
-
- /*** GLX_SGI_video_sync ***/
- glx.GetVideoSyncSGI = _real_glXGetVideoSyncSGI;
- glx.WaitVideoSyncSGI = _real_glXWaitVideoSyncSGI;
-
- /*** GLX_SGI_make_current_read ***/
- glx.MakeCurrentReadSGI = _real_glXMakeCurrentReadSGI;
- /*glx.GetCurrentReadDrawableSGI = _real_glXGetCurrentReadDrawableSGI;*/
-
-#if defined(_VL_H)
- /*** GLX_SGIX_video_source ***/
- glx.CreateGLXVideoSourceSGIX = _real_glXCreateGLXVideoSourceSGIX;
- glx.DestroyGLXVideoSourceSGIX = _real_glXDestroyGLXVideoSourceSGIX;
-#endif
-
- /*** GLX_EXT_import_context ***/
- glx.FreeContextEXT = _real_glXFreeContextEXT;
- /*glx.GetContextIDEXT = _real_glXGetContextIDEXT;*/
- /*glx.GetCurrentDisplayEXT = _real_glXGetCurrentDisplayEXT;*/
- glx.ImportContextEXT = _real_glXImportContextEXT;
- glx.QueryContextInfoEXT = _real_glXQueryContextInfoEXT;
-
- /*** GLX_SGIX_fbconfig ***/
- glx.GetFBConfigAttribSGIX = _real_glXGetFBConfigAttribSGIX;
- glx.ChooseFBConfigSGIX = _real_glXChooseFBConfigSGIX;
- glx.CreateGLXPixmapWithConfigSGIX = _real_glXCreateGLXPixmapWithConfigSGIX;
- glx.CreateContextWithConfigSGIX = _real_glXCreateContextWithConfigSGIX;
- glx.GetVisualFromFBConfigSGIX = _real_glXGetVisualFromFBConfigSGIX;
- glx.GetFBConfigFromVisualSGIX = _real_glXGetFBConfigFromVisualSGIX;
-
- /*** GLX_SGIX_pbuffer ***/
- glx.CreateGLXPbufferSGIX = _real_glXCreateGLXPbufferSGIX;
- glx.DestroyGLXPbufferSGIX = _real_glXDestroyGLXPbufferSGIX;
- glx.QueryGLXPbufferSGIX = _real_glXQueryGLXPbufferSGIX;
- glx.SelectEventSGIX = _real_glXSelectEventSGIX;
- glx.GetSelectedEventSGIX = _real_glXGetSelectedEventSGIX;
-
- /*** GLX_SGI_cushion ***/
- glx.CushionSGI = _real_glXCushionSGI;
-
- /*** GLX_SGIX_video_resize ***/
- glx.BindChannelToWindowSGIX = _real_glXBindChannelToWindowSGIX;
- glx.ChannelRectSGIX = _real_glXChannelRectSGIX;
- glx.QueryChannelRectSGIX = _real_glXQueryChannelRectSGIX;
- glx.QueryChannelDeltasSGIX = _real_glXQueryChannelDeltasSGIX;
- glx.ChannelRectSyncSGIX = _real_glXChannelRectSyncSGIX;
-
-#if defined(_DM_BUFFER_H_)
- /*** (GLX_SGIX_dmbuffer ***/
- glx.AssociateDMPbufferSGIX = NULL;
-#endif
-
- /*** GLX_SGIX_swap_group ***/
- glx.JoinSwapGroupSGIX = _real_glXJoinSwapGroupSGIX;
-
- /*** GLX_SGIX_swap_barrier ***/
- glx.BindSwapBarrierSGIX = _real_glXBindSwapBarrierSGIX;
- glx.QueryMaxSwapBarriersSGIX = _real_glXQueryMaxSwapBarriersSGIX;
-
- /*** GLX_SUN_get_transparent_index ***/
- glx.GetTransparentIndexSUN = _real_glXGetTransparentIndexSUN;
-
- /*** GLX_MESA_copy_sub_buffer ***/
- glx.CopySubBufferMESA = _real_glXCopySubBufferMESA;
-
- /*** GLX_MESA_release_buffers ***/
- glx.ReleaseBuffersMESA = _real_glXReleaseBuffersMESA;
-
- /*** GLX_MESA_pixmap_colormap ***/
- glx.CreateGLXPixmapMESA = _real_glXCreateGLXPixmapMESA;
-
- /*** GLX_MESA_set_3dfx_mode ***/
- glx.Set3DfxModeMESA = _real_glXSet3DfxModeMESA;
-
- /*** GLX_NV_vertex_array_range ***/
- glx.AllocateMemoryNV = _real_glXAllocateMemoryNV;
- glx.FreeMemoryNV = _real_glXFreeMemoryNV;
-
- /*** GLX_MESA_agp_offset ***/
- glx.GetAGPOffsetMESA = _real_glXGetAGPOffsetMESA;
-
- return &glx;
-}
diff --git a/src/gallium/winsys/xlib/realglx.h b/src/gallium/winsys/xlib/realglx.h
deleted file mode 100644
index 150129db68..0000000000
--- a/src/gallium/winsys/xlib/realglx.h
+++ /dev/null
@@ -1,326 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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.
- */
-
-
-#ifndef REALGLX_H
-#define REALGLX_H
-
-
-extern struct _glxapi_table *
-_real_GetGLXDispatchTable(void);
-
-
-/*
- * Basically just need these to prevent compiler warnings.
- */
-
-
-extern XVisualInfo *
-_real_glXChooseVisual( Display *dpy, int screen, int *list );
-
-extern GLXContext
-_real_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
- GLXContext share_list, Bool direct );
-
-extern GLXPixmap
-_real_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap );
-
-extern GLXPixmap
-_real_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
- Pixmap pixmap, Colormap cmap );
-
-extern void
-_real_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
-
-extern void
-_real_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
- unsigned long mask );
-
-extern Bool
-_real_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx );
-
-extern Bool
-_real_glXQueryExtension( Display *dpy, int *errorb, int *event );
-
-extern void
-_real_glXDestroyContext( Display *dpy, GLXContext ctx );
-
-extern Bool
-_real_glXIsDirect( Display *dpy, GLXContext ctx );
-
-extern void
-_real_glXSwapBuffers( Display *dpy, GLXDrawable drawable );
-
-extern void
-_real_glXUseXFont( Font font, int first, int count, int listbase );
-
-extern Bool
-_real_glXQueryVersion( Display *dpy, int *maj, int *min );
-
-extern int
-_real_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
- int attrib, int *value );
-
-extern void
-_real_glXWaitGL( void );
-
-
-extern void
-_real_glXWaitX( void );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXQueryExtensionsString( Display *dpy, int screen );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXQueryServerString( Display *dpy, int screen, int name );
-
-/* GLX 1.1 and later */
-extern const char *
-_real_glXGetClientString( Display *dpy, int name );
-
-
-/*
- * GLX 1.3 and later
- */
-
-extern GLXFBConfig *
-_real_glXChooseFBConfig( Display *dpy, int screen,
- const int *attribList, int *nitems );
-
-extern int
-_real_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
- int attribute, int *value );
-
-extern GLXFBConfig *
-_real_glXGetFBConfigs( Display *dpy, int screen, int *nelements );
-
-extern XVisualInfo *
-_real_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
-
-extern GLXWindow
-_real_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
- const int *attribList );
-
-extern void
-_real_glXDestroyWindow( Display *dpy, GLXWindow window );
-
-extern GLXPixmap
-_real_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
- const int *attribList );
-
-extern void
-_real_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
-
-extern GLXPbuffer
-_real_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
- const int *attribList );
-
-extern void
-_real_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
-
-extern void
-_real_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
- unsigned int *value );
-
-extern GLXContext
-_real_glXCreateNewContext( Display *dpy, GLXFBConfig config,
- int renderType, GLXContext shareList, Bool direct );
-
-
-extern Bool
-_real_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext ctx );
-
-extern int
-_real_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value );
-
-extern void
-_real_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask );
-
-extern void
-_real_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
- unsigned long *mask );
-
-#ifdef GLX_SGI_swap_control
-extern int
-_real_glXSwapIntervalSGI(int interval);
-#endif
-
-
-#ifdef GLX_SGI_video_sync
-extern int
-_real_glXGetVideoSyncSGI(unsigned int *count);
-
-extern int
-_real_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
-#endif
-
-
-#ifdef GLX_SGI_make_current_read
-extern Bool
-_real_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
-
-extern GLXDrawable
-_real_glXGetCurrentReadDrawableSGI(void);
-#endif
-
-#if defined(_VL_H) && defined(GLX_SGIX_video_source)
-extern GLXVideoSourceSGIX
-_real_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
-
-extern void
-_real_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src);
-#endif
-
-#ifdef GLX_EXT_import_context
-extern void
-_real_glXFreeContextEXT(Display *dpy, GLXContext context);
-
-extern GLXContextID
-_real_glXGetContextIDEXT(const GLXContext context);
-
-extern Display *
-_real_glXGetCurrentDisplayEXT(void);
-
-extern GLXContext
-_real_glXImportContextEXT(Display *dpy, GLXContextID contextID);
-
-extern int
-_real_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value);
-#endif
-
-#ifdef GLX_SGIX_fbconfig
-extern int
-_real_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
-
-extern GLXFBConfigSGIX *
-_real_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements);
-
-extern GLXPixmap
-_real_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
-
-extern GLXContext
-_real_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
-
-extern XVisualInfo *
-_real_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config);
-
-extern GLXFBConfigSGIX
-_real_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis);
-#endif
-
-#ifdef GLX_SGIX_pbuffer
-extern GLXPbufferSGIX
-_real_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
-
-extern void
-_real_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf);
-
-extern int
-_real_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
-
-extern void
-_real_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask);
-
-extern void
-_real_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask);
-#endif
-
-#ifdef GLX_SGI_cushion
-extern void
-_real_glXCushionSGI(Display *dpy, Window win, float cushion);
-#endif
-
-#ifdef GLX_SGIX_video_resize
-extern int
-_real_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window);
-
-extern int
-_real_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h);
-
-extern int
-_real_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h);
-
-extern int
-_real_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
-
-extern int
-_real_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype);
-#endif
-
-#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
-extern Bool
-_real_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
-#endif
-
-#ifdef GLX_SGIX_swap_group
-extern void
-_real_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member);
-#endif
-
-#ifdef GLX_SGIX_swap_barrier
-extern void
-_real_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier);
-
-extern Bool
-_real_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max);
-#endif
-
-#ifdef GLX_SUN_get_transparent_index
-extern Status
-_real_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent);
-#endif
-
-#ifdef GLX_MESA_release_buffers
-extern Bool
-_real_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
-#endif
-
-#ifdef GLX_MESA_set_3dfx_mode
-extern Bool
-_real_glXSet3DfxModeMESA( int mode );
-#endif
-
-#ifdef GLX_NV_vertex_array_range
-extern void *
-_real_glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
-extern void
-_real_glXFreeMemoryNV(GLvoid *pointer);
-#endif
-
-#ifdef GLX_MESA_agp_offset
-extern GLuint
-_real_glXGetAGPOffsetMESA(const GLvoid *pointer);
-#endif
-
-#ifdef GLX_MESA_copy_sub_buffer
-extern void
-_real_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
- int x, int y, int width, int height );
-#endif
-
-#endif /* REALGLX_H */
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
new file mode 100644
index 0000000000..4982230000
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib.c
@@ -0,0 +1,105 @@
+/**************************************************************************
+ *
+ * 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.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 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;
+}
+
+static void _init( void ) __attribute__((constructor));
+
+static void _init( void )
+{
+ enum mode xlib_mode = get_mode();
+
+ switch (xlib_mode) {
+ case MODE_TRACE:
+ xmesa_set_driver( &xlib_trace_driver );
+ break;
+ case MODE_BRW:
+ xmesa_set_driver( &xlib_brw_driver );
+ break;
+ case MODE_CELL:
+ xmesa_set_driver( &xlib_cell_driver );
+ break;
+ case MODE_SOFTPIPE:
+ xmesa_set_driver( &xlib_softpipe_driver );
+ 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.h b/src/gallium/winsys/xlib/xlib.h
new file mode 100644
index 0000000000..d602ab0b13
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib.h
@@ -0,0 +1,14 @@
+
+#ifndef XLIB_H
+#define XLIB_H
+
+#include "pipe/p_compiler.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
diff --git a/src/gallium/winsys/xlib/xlib_brw.h b/src/gallium/winsys/xlib/xlib_brw.h
new file mode 100644
index 0000000000..be2dd147db
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_brw.h
@@ -0,0 +1,30 @@
+#ifndef XLIB_BRW_H
+#define XLIB_BRW_H
+
+struct pipe_winsys;
+struct pipe_buffer;
+struct pipe_surface;
+struct xmesa_buffer;
+
+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);
+
+struct pipe_context *
+xlib_create_brw_context( struct pipe_screen *screen,
+ void *unused );
+
+#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..528473925a
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_brw_context.c
@@ -0,0 +1,209 @@
+/**************************************************************************
+ *
+ * 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:
+ */
+#ifdef GALLIUM_CELL
+ return NULL;
+#else
+ return brw_create( screen,
+ &xbcws->brw_context_winsys,
+ 0 );
+#endif
+}
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xlib_brw_screen.c
index 56e16a0fb4..030cd66bd9 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,10 @@
#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"
+#include "xlib.h"
@@ -142,29 +144,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 +163,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 +220,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 +300,20 @@ aub_get_name( struct pipe_winsys *winsys )
return "Aub/xlib";
}
-struct pipe_winsys *
-xmesa_create_pipe_winsys_aub( void )
+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);
+}
+
+
+
+static struct pipe_winsys *
+xlib_create_brw_winsys( void )
{
struct aub_pipe_winsys *iws = CALLOC_STRUCT( aub_pipe_winsys );
@@ -341,6 +331,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 +350,47 @@ xmesa_create_pipe_winsys_aub( void )
}
-void
-xmesa_destroy_pipe_winsys_aub( struct pipe_winsys *winsys )
-
+static struct pipe_screen *
+xlib_create_brw_screen( void )
{
- struct aub_pipe_winsys *iws = aub_pipe_winsys(winsys);
- brw_aub_destroy(iws->aubfile);
- free(iws->pool);
- free(iws);
-}
+ struct pipe_winsys *winsys;
+ struct pipe_screen *screen;
+ winsys = xlib_create_brw_winsys();
+ if (winsys == NULL)
+ return NULL;
+ screen = brw_create_screen(winsys, 0/* XXX pci_id */);
+ if (screen == NULL)
+ goto fail;
+ return screen;
+fail:
+ if (winsys)
+ winsys->destroy( winsys );
-
-
-#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 )
-{
- return (struct aub_brw_winsys *)sws;
+ return NULL;
}
-/* 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 +461,36 @@ 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
+static 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 );
}
+
+
+struct xm_driver xlib_brw_driver =
+{
+ .create_pipe_screen = xlib_create_brw_screen,
+ .create_pipe_context = xlib_create_brw_context,
+ .display_surface = xlib_brw_display_surface,
+};
diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
new file mode 100644
index 0000000000..93bc8ecd81
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -0,0 +1,479 @@
+/**************************************************************************
+ *
+ * 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.h"
+
+#ifdef GALLIUM_CELL
+
+#include "xm_api.h"
+
+#undef ASSERT
+#undef Elements
+
+#include "pipe/p_winsys.h"
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "cell/ppu/cell_context.h"
+#include "cell/ppu/cell_screen.h"
+#include "cell/ppu/cell_winsys.h"
+
+
+/**
+ * Subclass of pipe_buffer for Xlib winsys.
+ * Low-level OS/window system memory buffer
+ */
+struct xm_buffer
+{
+ struct pipe_buffer base;
+ boolean userBuffer; /** Is this a user-space buffer? */
+ void *data;
+ void *mapped;
+
+ XImage *tempImage;
+ int shm;
+};
+
+
+/**
+ * Subclass of pipe_winsys for Xlib winsys
+ */
+struct xmesa_pipe_winsys
+{
+ struct pipe_winsys base;
+};
+
+
+
+/** Cast wrapper */
+static INLINE struct xm_buffer *
+xm_buffer( struct pipe_buffer *buf )
+{
+ return (struct xm_buffer *)buf;
+}
+
+
+/* Most callbacks map direcly onto dri_bufmgr operations:
+ */
+static void *
+xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct xm_buffer *xm_buf = xm_buffer(buf);
+ xm_buf->mapped = xm_buf->data;
+ return xm_buf->mapped;
+}
+
+static void
+xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
+{
+ struct xm_buffer *xm_buf = xm_buffer(buf);
+ xm_buf->mapped = NULL;
+}
+
+static void
+xm_buffer_destroy(struct pipe_winsys *pws,
+ struct pipe_buffer *buf)
+{
+ struct xm_buffer *oldBuf = xm_buffer(buf);
+
+ if (oldBuf->data) {
+ {
+ if (!oldBuf->userBuffer) {
+ align_free(oldBuf->data);
+ }
+ }
+
+ oldBuf->data = NULL;
+ }
+
+ free(oldBuf);
+}
+
+
+/**
+ * For Cell. Basically, rearrange the pixels/quads from this layout:
+ * +--+--+--+--+
+ * |p0|p1|p2|p3|....
+ * +--+--+--+--+
+ *
+ * to this layout:
+ * +--+--+
+ * |p0|p1|....
+ * +--+--+
+ * |p2|p3|
+ * +--+--+
+ */
+static void
+twiddle_tile(const uint *tileIn, uint *tileOut)
+{
+ int y, x;
+
+ for (y = 0; y < TILE_SIZE; y+=2) {
+ for (x = 0; x < TILE_SIZE; x+=2) {
+ int k = 4 * (y/2 * TILE_SIZE/2 + x/2);
+ tileOut[y * TILE_SIZE + (x + 0)] = tileIn[k];
+ tileOut[y * TILE_SIZE + (x + 1)] = tileIn[k+1];
+ tileOut[(y + 1) * TILE_SIZE + (x + 0)] = tileIn[k+2];
+ tileOut[(y + 1) * TILE_SIZE + (x + 1)] = tileIn[k+3];
+ }
+ }
+}
+
+
+
+/**
+ * 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
+xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
+{
+ XImage *ximage;
+ struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
+ const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
+ uint x, y;
+
+ ximage = b->tempImage;
+
+ /* check that the XImage has been previously initialized */
+ assert(ximage->format);
+ assert(ximage->bitmap_unit);
+
+ /* update XImage's fields */
+ ximage->width = TILE_SIZE;
+ ximage->height = TILE_SIZE;
+ ximage->bytes_per_line = TILE_SIZE * 4;
+
+ for (y = 0; y < surf->height; y += TILE_SIZE) {
+ for (x = 0; x < surf->width; x += TILE_SIZE) {
+ uint tmpTile[TILE_SIZE * TILE_SIZE];
+ 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 in pixels */
+ offset *= TILE_SIZE * TILE_SIZE;
+
+ /* twiddle from ximage buffer to temp tile */
+ twiddle_tile((uint *) xm_buf->data + offset, tmpTile);
+ /* display temp tile data */
+ ximage->data = (char *) tmpTile;
+ XPutImage(b->xm_visual->display, b->drawable, b->gc,
+ ximage, 0, 0, x, y, w, h);
+ }
+ }
+}
+
+
+
+
+
+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_cell_display_surface(xmctx->xm_buffer, surf);
+}
+
+
+
+static const char *
+xm_get_name(struct pipe_winsys *pws)
+{
+ return "Xlib/Cell";
+}
+
+
+static struct pipe_buffer *
+xm_buffer_create(struct pipe_winsys *pws,
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
+{
+ struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+
+ buffer->base.refcount = 1;
+ buffer->base.alignment = alignment;
+ buffer->base.usage = usage;
+ buffer->base.size = size;
+
+
+ if (buffer->data == NULL) {
+ buffer->shm = 0;
+
+ /* align to 16-byte multiple for Cell */
+ buffer->data = align_malloc(size, max(alignment, 16));
+ }
+
+ return &buffer->base;
+}
+
+
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_buffer *
+xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
+{
+ struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+ buffer->base.refcount = 1;
+ buffer->base.size = bytes;
+ buffer->userBuffer = TRUE;
+ buffer->data = ptr;
+ buffer->shm = 0;
+
+ return &buffer->base;
+}
+
+
+
+/**
+ * Round n up to next multiple.
+ */
+static INLINE unsigned
+round_up(unsigned n, unsigned multiple)
+{
+ return (n + multiple - 1) & ~(multiple - 1);
+}
+
+static int
+xm_surface_alloc_storage(struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned flags,
+ unsigned tex_usage)
+{
+ const unsigned alignment = 64;
+
+ surf->width = width;
+ surf->height = height;
+ surf->format = format;
+ pf_get_block(format, &surf->block);
+ surf->nblocksx = pf_get_nblocksx(&surf->block, width);
+ surf->nblocksy = pf_get_nblocksy(&surf->block, height);
+ surf->stride = round_up(surf->nblocksx * surf->block.size, alignment);
+ surf->usage = flags;
+
+ assert(!surf->buffer);
+ surf->buffer = winsys->buffer_create(winsys, alignment,
+ PIPE_BUFFER_USAGE_PIXEL,
+ /* XXX a bit of a hack */
+ surf->stride * round_up(surf->nblocksy, TILE_SIZE));
+
+ if(!surf->buffer)
+ return -1;
+
+ return 0;
+}
+
+
+/**
+ * Called via winsys->surface_alloc() to create new surfaces.
+ */
+static struct pipe_surface *
+xm_surface_alloc(struct pipe_winsys *ws)
+{
+ struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
+
+ assert(ws);
+
+ surface->refcount = 1;
+ surface->winsys = ws;
+
+ return surface;
+}
+
+
+
+static void
+xm_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
+{
+ struct pipe_surface *surf = *s;
+ assert(!surf->texture);
+ surf->refcount--;
+ if (surf->refcount == 0) {
+ if (surf->buffer)
+ winsys_buffer_reference(winsys, &surf->buffer, NULL);
+ free(surf);
+ }
+ *s = NULL;
+}
+
+
+/*
+ * Fence functions - basically nothing to do, as we don't create any actual
+ * fence objects.
+ */
+
+static void
+xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+}
+
+
+static int
+xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
+
+static int
+xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
+ unsigned flag)
+{
+ return 0;
+}
+
+
+
+static struct pipe_winsys *
+xlib_create_cell_winsys( void )
+{
+ static struct xmesa_pipe_winsys *ws = NULL;
+
+ if (!ws) {
+ ws = CALLOC_STRUCT(xmesa_pipe_winsys);
+
+ /* Fill in this struct with callbacks that pipe will need to
+ * communicate with the window system, buffer manager, etc.
+ */
+ ws->base.buffer_create = xm_buffer_create;
+ ws->base.user_buffer_create = xm_user_buffer_create;
+ ws->base.buffer_map = xm_buffer_map;
+ ws->base.buffer_unmap = xm_buffer_unmap;
+ ws->base.buffer_destroy = xm_buffer_destroy;
+
+ ws->base.surface_alloc = xm_surface_alloc;
+ ws->base.surface_alloc_storage = xm_surface_alloc_storage;
+ ws->base.surface_release = xm_surface_release;
+
+ ws->base.fence_reference = xm_fence_reference;
+ ws->base.fence_signalled = xm_fence_signalled;
+ ws->base.fence_finish = xm_fence_finish;
+
+ ws->base.flush_frontbuffer = xm_flush_frontbuffer;
+ ws->base.get_name = xm_get_name;
+ }
+
+ return &ws->base;
+}
+
+
+static struct pipe_screen *
+xlib_create_cell_screen( struct pipe_winsys *pws )
+{
+ struct pipe_winsys *winsys;
+ struct pipe_screen *screen;
+
+ winsys = xlib_create_cell_winsys();
+ if (winsys == NULL)
+ return NULL;
+
+ screen = cell_create_screen(winsys);
+ if (screen == NULL)
+ goto fail;
+
+ return screen;
+
+fail:
+ if (winsys)
+ winsys->destroy( winsys );
+
+ return NULL;
+}
+
+
+static struct pipe_context *
+xlib_create_cell_context( struct pipe_screen *screen,
+ void *priv )
+{
+ struct pipe_context *pipe;
+
+
+ /* 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:
+ return NULL;
+}
+
+struct xm_driver xlib_cell_driver =
+{
+ .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_screen = NULL,
+ .create_pipe_context = NULL,
+ .display_surface = NULL,
+};
+
+#endif
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index acb5ad8f71..e8513069fe 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -33,8 +33,7 @@
*/
-#include "glxheader.h"
-#include "xmesaP.h"
+#include "xm_api.h"
#undef ASSERT
#undef Elements
@@ -47,21 +46,7 @@
#include "util/u_memory.h"
#include "softpipe/sp_winsys.h"
-#ifdef GALLIUM_CELL
-#include "cell/ppu/cell_context.h"
-#include "cell/ppu/cell_screen.h"
-#include "cell/ppu/cell_winsys.h"
-#else
-#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.h"
/**
* Subclass of pipe_buffer for Xlib winsys.
@@ -76,9 +61,7 @@ struct xm_buffer
XImage *tempImage;
int shm;
-#if defined(USE_XSHM) && !defined(XFree86Server)
XShmSegmentInfo shminfo;
-#endif
};
@@ -88,7 +71,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,8 +88,6 @@ xm_buffer( struct pipe_buffer *buf )
/**
* X Shared Memory Image extension code
*/
-#if defined(USE_XSHM) && !defined(XFree86Server)
-
#define XSHM_ENABLED(b) ((b)->shm)
static volatile int mesaXErrorFlag = 0;
@@ -115,7 +96,7 @@ static volatile int mesaXErrorFlag = 0;
* Catches potential Xlib errors.
*/
static int
-mesaHandleXError(XMesaDisplay *dpy, XErrorEvent *event)
+mesaHandleXError(Display *dpy, XErrorEvent *event)
{
(void) dpy;
(void) event;
@@ -157,10 +138,7 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
* errors at different points if the extension won't work. Therefore
* we have to be very careful...
*/
-#if 0
- GC gc;
-#endif
- int (*old_handler)(XMesaDisplay *, XErrorEvent *);
+ int (*old_handler)(Display *, XErrorEvent *);
b->tempImage = XShmCreateImage(xmb->xm_visual->display,
xmb->xm_visual->visinfo->visual,
@@ -191,39 +169,7 @@ alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
(void) XSetErrorHandler(old_handler);
return;
}
-
-
- /* Finally, try an XShmPutImage to be really sure the extension works */
-#if 0
- gc = XCreateGC(xmb->xm_visual->display, xmb->drawable, 0, NULL);
- XShmPutImage(xmb->xm_visual->display, xmb->drawable, gc,
- b->tempImage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False);
- XSync(xmb->xm_visual->display, False);
- XFreeGC(xmb->xm_visual->display, gc);
- (void) XSetErrorHandler(old_handler);
- if (mesaXErrorFlag) {
- XFlush(xmb->xm_visual->display);
- mesaXErrorFlag = 0;
- XDestroyImage(b->tempImage);
- b->tempImage = NULL;
- b->shm = 0;
- return;
- }
-#endif
-}
-
-#else
-
-#define XSHM_ENABLED(b) 0
-
-static void
-alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
- unsigned width, unsigned height)
-{
- b->shm = 0;
}
-#endif /* USE_XSHM */
-
@@ -252,7 +198,6 @@ xm_buffer_destroy(struct pipe_winsys *pws,
struct xm_buffer *oldBuf = xm_buffer(buf);
if (oldBuf->data) {
-#if defined(USE_XSHM) && !defined(XFree86Server)
if (oldBuf->shminfo.shmid >= 0) {
shmdt(oldBuf->shminfo.shmaddr);
shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0);
@@ -261,7 +206,6 @@ xm_buffer_destroy(struct pipe_winsys *pws,
oldBuf->shminfo.shmaddr = (char *) -1;
}
else
-#endif
{
if (!oldBuf->userBuffer) {
align_free(oldBuf->data);
@@ -275,139 +219,28 @@ xm_buffer_destroy(struct pipe_winsys *pws,
}
-/**
- * For Cell. Basically, rearrange the pixels/quads from this layout:
- * +--+--+--+--+
- * |p0|p1|p2|p3|....
- * +--+--+--+--+
- *
- * to this layout:
- * +--+--+
- * |p0|p1|....
- * +--+--+
- * |p2|p3|
- * +--+--+
- */
-static void
-twiddle_tile(const uint *tileIn, uint *tileOut)
-{
- int y, x;
-
- for (y = 0; y < TILE_SIZE; y+=2) {
- for (x = 0; x < TILE_SIZE; x+=2) {
- int k = 4 * (y/2 * TILE_SIZE/2 + x/2);
- tileOut[y * TILE_SIZE + (x + 0)] = tileIn[k];
- tileOut[y * TILE_SIZE + (x + 1)] = tileIn[k+1];
- tileOut[(y + 1) * TILE_SIZE + (x + 0)] = tileIn[k+2];
- tileOut[(y + 1) * TILE_SIZE + (x + 1)] = tileIn[k+3];
- }
- }
-}
-
-
-
-/**
- * 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)
-{
- XImage *ximage;
- struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
- const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE;
- uint x, y;
-
- 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;
- ximage->height = TILE_SIZE;
- ximage->bytes_per_line = TILE_SIZE * 4;
- }
-
- for (y = 0; y < surf->height; y += TILE_SIZE) {
- for (x = 0; x < surf->width; x += TILE_SIZE) {
- uint tmpTile[TILE_SIZE * TILE_SIZE];
- 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 in pixels */
- offset *= TILE_SIZE * TILE_SIZE;
-
- if (0 && XSHM_ENABLED(xm_buf)) {
- ximage->data = (char *) xm_buf->data + 4 * offset;
- /* make copy of tile data */
- memcpy(tmpTile, (uint *) ximage->data, sizeof(tmpTile));
- /* 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)
- XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, x, y, w, h, False);
-#endif
- }
- else {
- /* twiddle from ximage buffer to temp tile */
- twiddle_tile((uint *) xm_buf->data + offset, tmpTile);
- /* display temp tile data */
- ximage->data = (char *) tmpTile;
- XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, x, y, w, h);
- }
- }
- }
-}
-
/**
* Display/copy the image in the surface into the X window specified
* by the XMesaBuffer.
*/
-void
-xmesa_display_surface(XMesaBuffer b, const struct pipe_surface *surf)
+static void
+xlib_softpipe_display_surface(struct xmesa_buffer *b,
+ struct pipe_surface *surf)
{
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(surf->buffer);
static boolean no_swap = 0;
static boolean firsttime = 1;
- static int tileSize = 0;
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 (tileSize) {
- xmesa_display_surface_tiled(b, surf);
- return;
- }
-
if (XSHM_ENABLED(xm_buf) && (xm_buf->tempImage == NULL)) {
assert(surf->block.width == 1);
assert(surf->block.height == 1);
@@ -419,10 +252,8 @@ 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)
XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
ximage, 0, 0, 0, 0, surf->width, surf->height, False);
-#endif
} else {
/* check that the XImage has been previously initialized */
assert(ximage->format);
@@ -449,7 +280,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,17 +299,12 @@ xm_buffer_create(struct pipe_winsys *pws,
unsigned size)
{
struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
-#if defined(USE_XSHM) && !defined(XFree86Server)
struct xmesa_pipe_winsys *xpws = (struct xmesa_pipe_winsys *) pws;
-#endif
buffer->base.refcount = 1;
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
-
-
-#if defined(USE_XSHM) && !defined(XFree86Server)
buffer->shminfo.shmid = -1;
buffer->shminfo.shmaddr = (char *) -1;
@@ -489,7 +315,6 @@ xm_buffer_create(struct pipe_winsys *pws,
buffer->data = buffer->shminfo.shmaddr;
}
}
-#endif
if (buffer->data == NULL) {
buffer->shm = 0;
@@ -551,11 +376,7 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
assert(!surf->buffer);
surf->buffer = winsys->buffer_create(winsys, alignment,
PIPE_BUFFER_USAGE_PIXEL,
-#ifdef GALLIUM_CELL /* XXX a bit of a hack */
- surf->stride * round_up(surf->nblocksy, TILE_SIZE));
-#else
surf->stride * surf->nblocksy);
-#endif
if(!surf->buffer)
return -1;
@@ -625,34 +446,15 @@ 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)
+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);
-
/* Fill in this struct with callbacks that pipe will need to
* communicate with the window system, buffer manager, etc.
*/
@@ -678,42 +480,54 @@ xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
}
-struct pipe_context *
-xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
+static struct pipe_screen *
+xlib_create_softpipe_screen( void )
{
- 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);
- }
+ struct pipe_winsys *winsys;
+ struct pipe_screen *screen;
-#ifdef GALLIUM_CELL
- if (!getenv("GALLIUM_NOCELL")) {
- struct cell_winsys *cws = cell_get_winsys(pixelformat);
- struct pipe_screen *screen = cell_create_screen(pws);
+ winsys = xlib_create_softpipe_winsys();
+ if (winsys == NULL)
+ return NULL;
+
+ screen = softpipe_create_screen(winsys);
+ if (screen == NULL)
+ goto fail;
+
+ return screen;
+
+fail:
+ if (winsys)
+ winsys->destroy( winsys );
+
+ return NULL;
+}
- pipe = cell_create_context(screen, cws);
- }
- else
-#endif
- {
- struct pipe_screen *screen = softpipe_create_screen(pws);
-
- pipe = softpipe_create(screen, pws, NULL);
-
-#ifdef GALLIUM_TRACE
- screen = trace_screen_create(screen);
-
- pipe = trace_context_create(screen, pipe);
-#endif
- }
- if (pipe)
- pipe->priv = xmesa;
+static struct pipe_context *
+xlib_create_softpipe_context( struct pipe_screen *screen,
+ void *context_private )
+{
+ struct pipe_context *pipe;
+
+ pipe = softpipe_create(screen, screen->winsys, NULL);
+ if (pipe == NULL)
+ goto fail;
+ pipe->priv = context_private;
return pipe;
+
+fail:
+ /* Free stuff here */
+ return NULL;
}
+
+struct xm_driver xlib_softpipe_driver =
+{
+ .create_pipe_screen = xlib_create_softpipe_screen,
+ .create_pipe_context = xlib_create_softpipe_context,
+ .display_surface = xlib_softpipe_display_surface
+};
+
+
+
diff --git a/src/gallium/winsys/xlib/xlib_trace.c b/src/gallium/winsys/xlib/xlib_trace.c
new file mode 100644
index 0000000000..37095c5d8e
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_trace.c
@@ -0,0 +1,107 @@
+/**************************************************************************
+ *
+ * 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.h"
+
+#include "trace/tr_screen.h"
+#include "trace/tr_context.h"
+
+#include "pipe/p_screen.h"
+
+
+
+static struct pipe_screen *
+xlib_create_trace_screen( void )
+{
+ struct pipe_screen *screen, *trace_screen;
+
+ screen = xlib_softpipe_driver.create_pipe_screen();
+ if (screen == NULL)
+ goto fail;
+
+ /* Wrap it:
+ */
+ trace_screen = trace_screen_create(screen);
+ if (trace_screen == NULL)
+ goto fail;
+
+ return trace_screen;
+
+fail:
+ if (screen)
+ screen->destroy( screen );
+ return NULL;
+}
+
+static struct pipe_context *
+xlib_create_trace_context( struct pipe_screen *screen,
+ void *priv )
+{
+ struct pipe_context *pipe, *trace_pipe;
+
+ pipe = xlib_softpipe_driver.create_pipe_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;
+}
+
+static void
+xlib_trace_display_surface( struct xmesa_buffer *buffer,
+ struct pipe_surface *surf )
+{
+ /* ??
+ */
+ xlib_softpipe_driver.display_surface( buffer, surf );
+}
+
+
+struct xm_driver xlib_trace_driver =
+{
+ .create_pipe_screen = xlib_create_trace_screen,
+ .create_pipe_context = xlib_create_trace_context,
+ .display_surface = xlib_trace_display_surface,
+};
diff --git a/src/gallium/winsys/xlib/xm_image.c b/src/gallium/winsys/xlib/xm_image.c
deleted file mode 100644
index 087b4e4c3a..0000000000
--- a/src/gallium/winsys/xlib/xm_image.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- */
-
-#include <stdlib.h>
-#include <X11/Xmd.h>
-
-#include "glxheader.h"
-#include "xmesaP.h"
-
-#ifdef XFree86Server
-
-#ifdef ROUNDUP
-#undef ROUNDUP
-#endif
-
-#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
-
-XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data)
-{
- XMesaImage *image;
-
- image = (XMesaImage *)xalloc(sizeof(XMesaImage));
-
- if (image) {
- image->width = width;
- image->height = height;
- image->data = data;
- /* Always pad to 32 bits */
- image->bytes_per_line = ROUNDUP((bitsPerPixel * width), 32);
- image->bits_per_pixel = bitsPerPixel;
- }
-
- return image;
-}
-
-void XMesaDestroyImage(XMesaImage *image)
-{
- if (image->data)
- free(image->data);
- xfree(image);
-}
-
-unsigned long XMesaGetPixel(XMesaImage *image, int x, int y)
-{
- CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
- CARD8 *i8;
- CARD16 *i16;
- CARD32 *i32;
- switch (image->bits_per_pixel) {
- case 8:
- i8 = (CARD8 *)row;
- return i8[x];
- break;
- case 15:
- case 16:
- i16 = (CARD16 *)row;
- return i16[x];
- break;
- case 24: /* WARNING: architecture specific code */
- i8 = (CARD8 *)row;
- return (((CARD32)i8[x*3]) |
- (((CARD32)i8[x*3+1])<<8) |
- (((CARD32)i8[x*3+2])<<16));
- break;
- case 32:
- i32 = (CARD32 *)row;
- return i32[x];
- break;
- }
- return 0;
-}
-
-#ifndef XMESA_USE_PUTPIXEL_MACRO
-void XMesaPutPixel(XMesaImage *image, int x, int y, unsigned long pixel)
-{
- CARD8 *row = (CARD8 *)(image->data + y*image->bytes_per_line);
- CARD8 *i8;
- CARD16 *i16;
- CARD32 *i32;
- switch (image->bits_per_pixel) {
- case 8:
- i8 = (CARD8 *)row;
- i8[x] = (CARD8)pixel;
- break;
- case 15:
- case 16:
- i16 = (CARD16 *)row;
- i16[x] = (CARD16)pixel;
- break;
- case 24: /* WARNING: architecture specific code */
- i8 = (CARD8 *)__row;
- i8[x*3] = (CARD8)(p);
- i8[x*3+1] = (CARD8)(p>>8);
- i8[x*3+2] = (CARD8)(p>>16);
- case 32:
- i32 = (CARD32 *)row;
- i32[x] = (CARD32)pixel;
- break;
- }
-}
-#endif
-
-#endif /* XFree86Server */
diff --git a/src/gallium/winsys/xlib/xm_image.h b/src/gallium/winsys/xlib/xm_image.h
deleted file mode 100644
index 2a5e0f3777..0000000000
--- a/src/gallium/winsys/xlib/xm_image.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT 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.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Kevin E. Martin <kevin@precisioninsight.com>
- * Brian Paul <brian@precisioninsight.com>
- */
-
-#ifndef _XM_IMAGE_H_
-#define _XM_IMAGE_H_
-
-#define XMESA_USE_PUTPIXEL_MACRO
-
-extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height,
- char *data);
-extern void XMesaDestroyImage(XMesaImage *image);
-extern unsigned long XMesaGetPixel(XMesaImage *image, int x, int y);
-#ifdef XMESA_USE_PUTPIXEL_MACRO
-#define XMesaPutPixel(__i,__x,__y,__p) \
-{ \
- CARD8 *__row = (CARD8 *)(__i->data + __y*__i->bytes_per_line); \
- CARD8 *__i8; \
- CARD16 *__i16; \
- CARD32 *__i32; \
- switch (__i->bits_per_pixel) { \
- case 8: \
- __i8 = (CARD8 *)__row; \
- __i8[__x] = (CARD8)__p; \
- break; \
- case 15: \
- case 16: \
- __i16 = (CARD16 *)__row; \
- __i16[__x] = (CARD16)__p; \
- break; \
- case 24: /* WARNING: architecture specific code */ \
- __i8 = (CARD8 *)__row; \
- __i8[__x*3] = (CARD8)(__p); \
- __i8[__x*3+1] = (CARD8)(__p>>8); \
- __i8[__x*3+2] = (CARD8)(__p>>16); \
- break; \
- case 32: \
- __i32 = (CARD32 *)__row; \
- __i32[__x] = (CARD32)__p; \
- break; \
- } \
-}
-#else
-extern void XMesaPutPixel(XMesaImage *image, int x, int y,
- unsigned long pixel);
-#endif
-
-#endif /* _XM_IMAGE_H_ */
diff --git a/src/gallium/winsys/xlib/xmesaP.h b/src/gallium/winsys/xlib/xmesaP.h
deleted file mode 100644
index fcaeee52bc..0000000000
--- a/src/gallium/winsys/xlib/xmesaP.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 7.1
- *
- * Copyright (C) 1999-2007 Brian Paul 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, sublicense,
- * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL 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.
- */
-
-
-#ifndef XMESAP_H
-#define XMESAP_H
-
-
-#include "GL/xmesa.h"
-#include "mtypes.h"
-#ifdef XFree86Server
-#include "xm_image.h"
-#endif
-
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_public.h"
-#include "pipe/p_thread.h"
-
-
-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.
- * Basically corresponds to an XVisualInfo.
- */
-struct xmesa_visual {
- GLvisual mesa_visual; /* Device independent visual parameters */
- XMesaDisplay *display; /* The X11 display */
-#ifdef XFree86Server
- GLint ColormapEntries;
- GLint nplanes;
-#else
- XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
- XVisualInfo *vishandle; /* Only used in fakeglx.c */
-#endif
- GLint BitsPerPixel; /* True bits per pixel for XImages */
-
- GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
-};
-
-
-/**
- * Context info, derived from st_context.
- * Basically corresponds to a GLXContext.
- */
-struct xmesa_context {
- struct st_context *st;
- XMesaVisual xm_visual; /** pixel format info */
- XMesaBuffer xm_buffer; /** current drawbuffer */
-};
-
-
-/**
- * Types of X/GLX drawables we might render into.
- */
-typedef enum {
- WINDOW, /* An X window */
- GLXWINDOW, /* GLX window */
- PIXMAP, /* GLX pixmap */
- PBUFFER /* GLX Pbuffer */
-} BufferType;
-
-
-/**
- * Framebuffer information, derived from.
- * Basically corresponds to a GLXDrawable.
- */
-struct xmesa_buffer {
- struct st_framebuffer *stfb;
-
- GLboolean wasCurrent; /* was ever the current buffer? */
- XMesaVisual xm_visual; /* the X/Mesa visual */
- XMesaDrawable drawable; /* Usually the X window ID */
- XMesaColormap cmap; /* the X colormap */
- BufferType type; /* window, pixmap, pbuffer or glxwindow */
-
- XMesaImage *tempImage;
- unsigned long selectedEvents;/* for pbuffers only */
-
- GLuint shm; /* X Shared Memory extension status: */
- /* 0 = not available */
- /* 1 = XImage support available */
- /* 2 = Pixmap support available too */
-#if defined(USE_XSHM) && !defined(XFree86Server)
- XShmSegmentInfo shminfo;
-#endif
-
- XMesaGC gc; /* scratch GC for span, line, tri drawing */
-
- /* GLX_EXT_texture_from_pixmap */
- GLint TextureTarget; /** GLX_TEXTURE_1D_EXT, for example */
- GLint TextureFormat; /** GLX_TEXTURE_FORMAT_RGB_EXT, for example */
- GLint TextureMipmap; /** 0 or 1 */
-
- struct xmesa_buffer *Next; /* Linked list pointer: */
-};
-
-
-
-/** cast wrapper */
-static INLINE XMesaContext
-xmesa_context(GLcontext *ctx)
-{
- return (XMesaContext) ctx->DriverCtx;
-}
-
-
-/** cast wrapper */
-static INLINE XMesaBuffer
-xmesa_buffer(GLframebuffer *fb)
-{
- struct st_framebuffer *stfb = (struct st_framebuffer *) fb;
- return (XMesaBuffer) st_framebuffer_private(stfb);
-}
-
-
-extern void
-xmesa_delete_framebuffer(struct gl_framebuffer *fb);
-
-extern XMesaBuffer
-xmesa_find_buffer(XMesaDisplay *dpy, XMesaColormap cmap, XMesaBuffer notThis);
-
-extern void
-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)
-{
- return b->stfb->Base.Width;
-}
-
-static INLINE GLuint
-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);
-
-#endif