summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/drm/Makefile.egl3
-rw-r--r--src/gallium/winsys/gdi/SConscript2
-rw-r--r--src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c157
-rw-r--r--src/gallium/winsys/gdi/gdi_softpipe_winsys.c239
-rw-r--r--src/gallium/winsys/xlib/Makefile90
-rw-r--r--src/gallium/winsys/xlib/SConscript83
-rw-r--r--src/gallium/winsys/xlib/xlib.c101
-rw-r--r--src/gallium/winsys/xlib/xlib.h7
-rw-r--r--src/gallium/winsys/xlib/xlib_brw_context.c209
-rw-r--r--src/gallium/winsys/xlib/xlib_cell.c268
-rw-r--r--src/gallium/winsys/xlib/xlib_llvmpipe.c379
-rw-r--r--src/gallium/winsys/xlib/xlib_softpipe.c458
-rw-r--r--src/gallium/winsys/xlib/xlib_sw_winsys.c427
-rw-r--r--src/gallium/winsys/xlib/xmesa.h424
-rw-r--r--src/gallium/winsys/xlib/xmesa_x.h86
15 files changed, 530 insertions, 2403 deletions
diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl
index 8363de6e97..a006ad70b6 100644
--- a/src/gallium/winsys/drm/Makefile.egl
+++ b/src/gallium/winsys/drm/Makefile.egl
@@ -13,7 +13,8 @@ EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o)
common_LIBS = -ldrm -lm -ldl
-x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a
+x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \
+ $(TOP)/src/gallium/winsys/xlib/libws_xlib.a
x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes
kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a
diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript
index 4cbc86f331..4b32aa27e1 100644
--- a/src/gallium/winsys/gdi/SConscript
+++ b/src/gallium/winsys/gdi/SConscript
@@ -18,7 +18,7 @@ if env['platform'] == 'windows':
'ws2_32',
])
- sources = []
+ sources = ['gdi_sw_winsys.c']
drivers = []
if 'softpipe' in env['drivers']:
diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
index a9fa03b8e5..3d317c70dd 100644
--- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
@@ -36,153 +36,8 @@
#include <windows.h>
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "llvmpipe/lp_winsys.h"
+#include "gdi_winsys.h"
#include "llvmpipe/lp_texture.h"
-#include "stw_winsys.h"
-
-
-struct gdi_llvmpipe_displaytarget
-{
- enum pipe_format format;
- unsigned width;
- unsigned height;
- unsigned stride;
-
- unsigned size;
-
- void *data;
-
- BITMAPINFO bmi;
-};
-
-
-/** Cast wrapper */
-static INLINE struct gdi_llvmpipe_displaytarget *
-gdi_llvmpipe_displaytarget( struct llvmpipe_displaytarget *buf )
-{
- return (struct gdi_llvmpipe_displaytarget *)buf;
-}
-
-
-static boolean
-gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
- enum pipe_format format )
-{
- switch(format) {
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return TRUE;
-
- /* TODO: Support other formats possible with BMPs, as described in
- * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */
-
- default:
- return FALSE;
- }
-}
-
-
-static void *
-gdi_llvmpipe_displaytarget_map(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt,
- unsigned flags )
-{
- struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
-
- return gdt->data;
-}
-
-
-static void
-gdi_llvmpipe_displaytarget_unmap(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt )
-{
-
-}
-
-
-static void
-gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys,
- struct llvmpipe_displaytarget *dt)
-{
- struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt);
-
- align_free(gdt->data);
- FREE(gdt);
-}
-
-
-static struct llvmpipe_displaytarget *
-gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys,
- enum pipe_format format,
- unsigned width, unsigned height,
- unsigned alignment,
- unsigned *stride)
-{
- struct gdi_llvmpipe_displaytarget *gdt;
- unsigned cpp;
- unsigned bpp;
-
- gdt = CALLOC_STRUCT(gdi_llvmpipe_displaytarget);
- if(!gdt)
- goto no_gdt;
-
- gdt->format = format;
- gdt->width = width;
- gdt->height = height;
-
- bpp = util_format_get_blocksizebits(format);
- cpp = util_format_get_blocksize(format);
-
- gdt->stride = align(width * cpp, alignment);
- gdt->size = gdt->stride * height;
-
- gdt->data = align_malloc(gdt->size, alignment);
- if(!gdt->data)
- goto no_data;
-
- gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp;
- gdt->bmi.bmiHeader.biHeight= -(long)height;
- gdt->bmi.bmiHeader.biPlanes = 1;
- gdt->bmi.bmiHeader.biBitCount = bpp;
- gdt->bmi.bmiHeader.biCompression = BI_RGB;
- gdt->bmi.bmiHeader.biSizeImage = 0;
- gdt->bmi.bmiHeader.biXPelsPerMeter = 0;
- gdt->bmi.bmiHeader.biYPelsPerMeter = 0;
- gdt->bmi.bmiHeader.biClrUsed = 0;
- gdt->bmi.bmiHeader.biClrImportant = 0;
-
- *stride = gdt->stride;
- return (struct llvmpipe_displaytarget *)gdt;
-
-no_data:
- FREE(gdt);
-no_gdt:
- return NULL;
-}
-
-
-static void
-gdi_llvmpipe_displaytarget_display(struct llvmpipe_winsys *winsys,
- struct llvmpipe_displaytarget *dt,
- void *context_private)
-{
- assert(0);
-}
-
-
-static void
-gdi_llvmpipe_destroy(struct llvmpipe_winsys *winsys)
-{
- FREE(winsys);
-}
static struct pipe_screen *
@@ -191,18 +46,10 @@ gdi_llvmpipe_screen_create(void)
static struct llvmpipe_winsys *winsys;
struct pipe_screen *screen;
- winsys = CALLOC_STRUCT(llvmpipe_winsys);
+ winsys = gdi_create_sw_winsys();
if(!winsys)
goto no_winsys;
- winsys->destroy = gdi_llvmpipe_destroy;
- winsys->is_displaytarget_format_supported = gdi_llvmpipe_is_displaytarget_format_supported;
- winsys->displaytarget_create = gdi_llvmpipe_displaytarget_create;
- winsys->displaytarget_map = gdi_llvmpipe_displaytarget_map;
- winsys->displaytarget_unmap = gdi_llvmpipe_displaytarget_unmap;
- winsys->displaytarget_display = gdi_llvmpipe_displaytarget_display;
- winsys->displaytarget_destroy = gdi_llvmpipe_displaytarget_destroy;
-
screen = llvmpipe_create_screen(winsys);
if(!screen)
goto no_screen;
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
index 71360e55aa..56e84fd066 100644
--- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2008 Tungsten Graphics, Inc., Bismarck, ND., USA
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,257 +28,58 @@
/**
* @file
- * Softpipe support.
+ * LLVMpipe support.
*
- * @author Keith Whitwell
- * @author Brian Paul
- * @author Jose Fonseca
+ * @author Jose Fonseca <jfonseca@vmware.com>
*/
#include <windows.h>
-#include "util/u_simple_screen.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "softpipe/sp_winsys.h"
+#include "gdi_winsys.h"
#include "softpipe/sp_texture.h"
-#include "stw_winsys.h"
-
-
-struct gdi_softpipe_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
- void *mapped;
-};
-
-
-/** Cast wrapper */
-static INLINE struct gdi_softpipe_buffer *
-gdi_softpipe_buffer( struct pipe_buffer *buf )
-{
- return (struct gdi_softpipe_buffer *)buf;
-}
-
-
-static void *
-gdi_softpipe_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf);
- gdi_softpipe_buf->mapped = gdi_softpipe_buf->data;
- return gdi_softpipe_buf->mapped;
-}
-
-
-static void
-gdi_softpipe_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf);
- gdi_softpipe_buf->mapped = NULL;
-}
-
-
-static void
-gdi_softpipe_buffer_destroy(struct pipe_buffer *buf)
-{
- struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf);
-
- if (oldBuf->data) {
- if (!oldBuf->userBuffer)
- align_free(oldBuf->data);
-
- oldBuf->data = NULL;
- }
-
- FREE(oldBuf);
-}
-
-
-static const char *
-gdi_softpipe_get_name(struct pipe_winsys *winsys)
-{
- return "softpipe";
-}
-
-
-static struct pipe_buffer *
-gdi_softpipe_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- buffer->data = align_malloc(size, alignment);
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys,
- void *ptr,
- unsigned bytes)
-{
- struct gdi_softpipe_buffer *buffer;
-
- buffer = CALLOC_STRUCT(gdi_softpipe_buffer);
- if(!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- unsigned nblocksy;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- *stride * nblocksy);
-}
-
-
-static void
-gdi_softpipe_dummy_flush_frontbuffer(struct pipe_winsys *winsys,
- struct pipe_surface *surface,
- void *context_private)
-{
- assert(0);
-}
-
-
-static void
-gdi_softpipe_fence_reference(struct pipe_winsys *winsys,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
-}
-
-
-static int
-gdi_softpipe_fence_signalled(struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return 0;
-}
-
-
-static int
-gdi_softpipe_fence_finish(struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return 0;
-}
-
-
-static void
-gdi_softpipe_destroy(struct pipe_winsys *winsys)
-{
- FREE(winsys);
-}
static struct pipe_screen *
gdi_softpipe_screen_create(void)
{
- static struct pipe_winsys *winsys;
+ static struct softpipe_winsys *winsys;
struct pipe_screen *screen;
- winsys = CALLOC_STRUCT(pipe_winsys);
+ winsys = gdi_create_sw_winsys();
if(!winsys)
- return NULL;
-
- winsys->destroy = gdi_softpipe_destroy;
-
- winsys->buffer_create = gdi_softpipe_buffer_create;
- winsys->user_buffer_create = gdi_softpipe_user_buffer_create;
- winsys->buffer_map = gdi_softpipe_buffer_map;
- winsys->buffer_unmap = gdi_softpipe_buffer_unmap;
- winsys->buffer_destroy = gdi_softpipe_buffer_destroy;
-
- winsys->surface_buffer_create = gdi_softpipe_surface_buffer_create;
-
- winsys->fence_reference = gdi_softpipe_fence_reference;
- winsys->fence_signalled = gdi_softpipe_fence_signalled;
- winsys->fence_finish = gdi_softpipe_fence_finish;
-
- winsys->flush_frontbuffer = gdi_softpipe_dummy_flush_frontbuffer;
- winsys->get_name = gdi_softpipe_get_name;
+ goto no_winsys;
screen = softpipe_create_screen(winsys);
if(!screen)
- gdi_softpipe_destroy(winsys);
+ goto no_screen;
return screen;
+
+no_screen:
+ FREE(winsys);
+no_winsys:
+ return NULL;
}
+
+
static void
gdi_softpipe_present(struct pipe_screen *screen,
struct pipe_surface *surface,
HDC hDC)
{
struct softpipe_texture *texture;
- struct gdi_softpipe_buffer *buffer;
- BITMAPINFO bmi;
+ struct gdi_softpipe_displaytarget *gdt;
texture = softpipe_texture(surface->texture);
-
- buffer = gdi_softpipe_buffer(texture->buffer);
-
- memset(&bmi, 0, sizeof(BITMAPINFO));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_blocksize(surface->format);
- bmi.bmiHeader.biHeight= -(long)surface->height;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = util_format_get_blocksizebits(surface->format);
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = 0;
- bmi.bmiHeader.biXPelsPerMeter = 0;
- bmi.bmiHeader.biYPelsPerMeter = 0;
- bmi.bmiHeader.biClrUsed = 0;
- bmi.bmiHeader.biClrImportant = 0;
+ gdt = gdi_softpipe_displaytarget(texture->dt);
StretchDIBits(hDC,
- 0, 0, surface->width, surface->height,
- 0, 0, surface->width, surface->height,
- buffer->data, &bmi, 0, SRCCOPY);
+ 0, 0, gdt->width, gdt->height,
+ 0, 0, gdt->width, gdt->height,
+ gdt->data, &gdt->bmi, 0, SRCCOPY);
}
diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
index 824c666ae3..bb631b16ce 100644
--- a/src/gallium/winsys/xlib/Makefile
+++ b/src/gallium/winsys/xlib/Makefile
@@ -1,100 +1,20 @@
-# src/gallium/winsys/xlib/Makefile
-
-# This makefile produces a "stand-alone" libGL.so which is based on
-# Xlib (no DRI HW acceleration)
-
-
TOP = ../../../..
include $(TOP)/configs/current
+LIBNAME = ws_xlib
-GL_MAJOR = 1
-GL_MINOR = 5
-GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
-
-
-INCLUDE_DIRS = \
- -I$(TOP)/include \
- -I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main \
+LIBRARY_INCLUDES = \
-I$(TOP)/src/gallium/include \
-I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/state_trackers/glx/xlib \
-I$(TOP)/src/gallium/auxiliary
-DEFINES += \
- -DGALLIUM_SOFTPIPE
-#-DGALLIUM_CELL will be defined by the config */
-
-XLIB_WINSYS_SOURCES = \
+C_SOURCES = \
xlib.c \
xlib_cell.c \
+ xlib_sw_winsys.c \
xlib_llvmpipe.c \
xlib_softpipe.c
-
-XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
-
-
-# Note: CELL_SPU_LIB is only defined for cell configs
-
-LIBS = \
- $(GALLIUM_DRIVERS) \
- $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
- $(TOP)/src/mesa/libglapi.a \
- $(TOP)/src/mesa/libmesagallium.a \
- $(GALLIUM_AUXILIARIES) \
- $(CELL_SPU_LIB) \
-
-
-.SUFFIXES : .cpp
-
-.c.o:
- $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@
-
-
-
-default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME)
-
-$(TOP)/$(LIB_DIR)/gallium:
- @ mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-# Make the libGL.so library
-$(TOP)/$(LIB_DIR)/gallium/$(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) \
- -install $(TOP)/$(LIB_DIR)/gallium \
- $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
- -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
-
-
-depend: $(XLIB_WINSYS_SOURCES)
- @ echo "running $(MKDEP)"
- @ rm -f depend # workaround oops on gutsy?!?
- @ touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \
- > /dev/null 2>/dev/null
-
-
-install: default
- $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL
- $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR)
- $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL
- @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
- $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \
- fi
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
-
-clean:
- -rm -f *.o
+include ../../Makefile.template
-include depend
diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript
index 8c9d318af2..26a13e42b5 100644
--- a/src/gallium/winsys/xlib/SConscript
+++ b/src/gallium/winsys/xlib/SConscript
@@ -1,64 +1,29 @@
#######################################################################
# SConscript for xlib winsys
-Import('*')
-
-if env['platform'] != 'linux':
- Return()
-
-if 'mesa' not in env['statetrackers']:
- print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so'
- Return()
-
-if env['dri']:
- print 'warning: DRI enabled: skipping build of xlib libGL.so'
- Return()
-
-if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']):
- print 'warning: no supported pipe driver: skipping build of xlib libGL.so'
- Return()
-
-env = env.Clone()
-env.Append(CPPPATH = [
- '#/src/mesa',
- '#/src/mesa/main',
- '#src/gallium/state_trackers/glx/xlib',
-])
-
-env.Append(CPPDEFINES = ['USE_XSHM'])
-
-sources = [
- 'xlib.c',
-]
-
-drivers = [trace]
-
-if 'softpipe' in env['drivers']:
- env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
- sources += ['xlib_softpipe.c']
- drivers += [softpipe]
-
-if 'llvmpipe' in env['drivers']:
- env.Tool('llvm')
- if 'LLVM_VERSION' in env:
- env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
- env.Tool('udis86')
- sources += ['xlib_llvmpipe.c']
- drivers += [llvmpipe]
-
-if 'cell' in env['drivers']:
- env.Append(CPPDEFINES = 'GALLIUM_CELL')
- sources += ['xlib_cell.c']
- drivers += [cell]
-
-# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
-libgl = env.SharedLibrary(
- target ='GL',
- source = sources,
- LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'],
-)
+Import('*')
-if not env['dri']:
- # Only install this libGL.so if DRI not enabled
- env.InstallSharedLibrary(libgl, version=(1, 5))
+if env['platform'] == 'linux' \
+ and 'mesa' in env['statetrackers']:
+
+ env = env.Clone()
+
+ env.Append(CPPPATH = [
+ '#/src/gallium/include',
+ '#/src/gallium/auxiliary',
+ '#/src/gallium/drivers',
+ ])
+
+ env.Append(CPPDEFINES = ['USE_XSHM'])
+
+ st_xlib = env.ConvenienceLibrary(
+ target = 'ws_xlib',
+ source = [
+ 'xlib_cell.c',
+ 'xlib_llvmpipe.c',
+ 'xlib_softpipe.c',
+ 'xlib_sw_winsys.c',
+ ]
+ )
+ Export('ws_xlib')
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
index 67617a470d..6ca9e362e7 100644
--- a/src/gallium/winsys/xlib/xlib.c
+++ b/src/gallium/winsys/xlib/xlib.c
@@ -32,107 +32,18 @@
*/
#include "xlib.h"
-#include "xm_winsys.h"
+#include "util/u_debug.h"
-#include <stdlib.h>
-#include <assert.h>
-
-/* Todo, replace all this with callback-structs provided by the
- * individual implementations.
- */
-
-enum mode {
- MODE_CELL,
- MODE_LLVMPIPE,
- MODE_SOFTPIPE
-};
-
-/* advertise OpenGL support */
-PUBLIC const int st_api_OpenGL = 1;
-
-static enum mode get_mode()
+struct xm_driver *xlib_sw_winsys_init( void )
{
-#ifdef GALLIUM_CELL
+#if defined(GALLIUM_CELL)
if (!getenv("GALLIUM_NOCELL"))
- return MODE_CELL;
-#endif
-
-#if defined(GALLIUM_LLVMPIPE)
- return MODE_LLVMPIPE;
-#else
- return MODE_SOFTPIPE;
+ return &xlib_cell_driver;
#endif
-}
-
-static void _init( void ) __attribute__((constructor));
-
-static void _init( void )
-{
- enum mode xlib_mode = get_mode();
- switch (xlib_mode) {
- case MODE_CELL:
-#if defined(GALLIUM_CELL)
- xmesa_set_driver( &xlib_cell_driver );
-#endif
- break;
- case MODE_LLVMPIPE:
#if defined(GALLIUM_LLVMPIPE)
- xmesa_set_driver( &xlib_llvmpipe_driver );
-#endif
- break;
- case MODE_SOFTPIPE:
-#if defined(GALLIUM_SOFTPIPE)
- xmesa_set_driver( &xlib_softpipe_driver );
+ return &xlib_llvmpipe_driver;
#endif
- 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);
+ return &xlib_softpipe_driver;
}
-
-
-/**
- * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
- * libglapi.a. We need to define them here.
- */
-#ifdef GLX_INDIRECT_RENDERING
-
-#define GL_GLEXT_PROTOTYPES
-#include "GL/gl.h"
-#include "glapi/glapi.h"
-#include "glapi/glapitable.h"
-#include "glapi/glapidispatch.h"
-
-#if defined(USE_MGL_NAMESPACE)
-#define NAME(func) mgl##func
-#else
-#define NAME(func) gl##func
-#endif
-
-#define DISPATCH(FUNC, ARGS, MESSAGE) \
- CALL_ ## FUNC(GET_DISPATCH(), ARGS);
-
-#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
- return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
-
-/* skip normal ones */
-#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
-#include "glapi/glapitemp.h"
-
-#endif /* GLX_INDIRECT_RENDERING */
diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h
index 8e091d0c08..3c20048616 100644
--- a/src/gallium/winsys/xlib/xlib.h
+++ b/src/gallium/winsys/xlib/xlib.h
@@ -3,11 +3,16 @@
#define XLIB_H
#include "pipe/p_compiler.h"
-#include "xm_winsys.h"
+#include "state_tracker/xlib_sw_winsys.h"
extern struct xm_driver xlib_softpipe_driver;
extern struct xm_driver xlib_llvmpipe_driver;
extern struct xm_driver xlib_cell_driver;
+struct sw_winsys *xlib_create_sw_winsys( Display *display );
+
+void xlib_sw_display(struct xlib_drawable *xm_buffer,
+ struct sw_displaytarget *dt);
+
#endif
diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c
deleted file mode 100644
index 22bf41a46f..0000000000
--- a/src/gallium/winsys/xlib/xlib_brw_context.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/**************************************************************************
- *
- * 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 "util/u_simple_screen.h"
-#include "util/u_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/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c
index 1dc9e8fa11..ce4efe8851 100644
--- a/src/gallium/winsys/xlib/xlib_cell.c
+++ b/src/gallium/winsys/xlib/xlib_cell.c
@@ -32,98 +32,19 @@
* Brian Paul
*/
-#include "xlib.h"
-
-#ifdef GALLIUM_CELL
-
-#include "xm_api.h"
-
-#undef ASSERT
-#undef Elements
-
-#include "util/u_simple_screen.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.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"
-#include "cell/ppu/cell_texture.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;
-}
+#include "xlib.h"
-/* 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 defined(GALLIUM_CELL)
- if (oldBuf) {
- if (oldBuf->data) {
- if (!oldBuf->userBuffer) {
- align_free(oldBuf->data);
- }
+#include "cell/ppu/cell_texture.h"
+#include "cell/ppu/cell_screen.h"
+#include "state_tracker/sw_winsys.h"
+#include "util/u_debug.h"
- oldBuf->data = NULL;
- }
- free(oldBuf);
- }
-}
/**
@@ -155,15 +76,16 @@ twiddle_tile(const uint *tileIn, uint *tileOut)
}
}
-
-
/**
* Display a surface that's in a tiled configuration. That is, all the
* pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory.
*/
static void
-xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
+xm_displaytarget_display(struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ void *winsys_drawable)
{
+ struct xmesa_buffer *xm_buffer = (struct xm_drawable *)winsys_drawable;
XImage *ximage;
struct xm_buffer *xm_buf = xm_buffer(
cell_texture(surf->texture)->buffer);
@@ -210,165 +132,21 @@ xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf)
-
-
-static void
-xm_flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *surf,
- void *context_private)
-{
- /*
- * The front color buffer is actually just another XImage buffer.
- * This function copies that XImage to the actual X Window.
- */
- XMesaContext xmctx = (XMesaContext) context_private;
- if (xmctx)
- xlib_cell_display_surface(xmctx->xm_buffer, surf);
-}
-
-
-
-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);
-
- pipe_reference_init(&buffer->base.reference, 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);
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
- buffer->shm = 0;
-
- return &buffer->base;
-}
-
-
-
-static struct pipe_buffer *
-xm_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- unsigned nblocksy;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- /* XXX a bit of a hack */
- *stride * align(nblocksy, TILE_SIZE));
-}
-
-
-/*
- * 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_buffer_create = xm_surface_buffer_create;
-
- 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( void )
+xlib_create_cell_screen( Display *dpy )
{
- struct pipe_winsys *winsys;
+ struct sw_winsys *winsys;
struct pipe_screen *screen;
- winsys = xlib_create_cell_winsys();
+ winsys = xlib_create_sw_winsys( dpy );
if (winsys == NULL)
return NULL;
+ /* Plug in a little cell-specific code:
+ */
+
+ ws->base.displaytarget_display = xm_cell_displaytarget_display;
+
screen = cell_create_screen(winsys);
if (screen == NULL)
goto fail;
@@ -384,18 +162,12 @@ fail:
+
struct xm_driver xlib_cell_driver =
{
.create_pipe_screen = xlib_create_cell_screen,
- .display_surface = xlib_cell_display_surface,
};
-#else
-struct xm_driver xlib_cell_driver =
-{
- .create_pipe_screen = NULL,
- .display_surface = NULL,
-};
-#endif
+#endif /* GALLIUM_CELL */
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
index 6cebd4c201..8b66b7459d 100644
--- a/src/gallium/winsys/xlib/xlib_llvmpipe.c
+++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c
@@ -33,375 +33,25 @@
*/
-#if defined(GALLIUM_LLVMPIPE)
-
-#include "xm_api.h"
-#undef ASSERT
-#undef Elements
-
-#include "util/u_simple_screen.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "llvmpipe/lp_winsys.h"
-#include "llvmpipe/lp_texture.h"
#include "xlib.h"
-/**
- * Subclass of pipe_buffer for Xlib winsys.
- * Low-level OS/window system memory buffer
- */
-struct xm_displaytarget
-{
- enum pipe_format format;
- unsigned width;
- unsigned height;
- unsigned stride;
-
- void *data;
- void *mapped;
-
- XImage *tempImage;
-#ifdef USE_XSHM
- int shm;
- XShmSegmentInfo shminfo;
-#endif
-};
-
-
-/**
- * Subclass of llvmpipe_winsys for Xlib winsys
- */
-struct xmesa_llvmpipe_winsys
-{
- struct llvmpipe_winsys base;
-/* struct xmesa_visual *xm_visual; */
-};
-
-
-
-/** Cast wrapper */
-static INLINE struct xm_displaytarget *
-xm_displaytarget( struct llvmpipe_displaytarget *dt )
-{
- return (struct xm_displaytarget *)dt;
-}
-
-
-/**
- * X Shared Memory Image extension code
- */
-
-#ifdef USE_XSHM
-
-static volatile int mesaXErrorFlag = 0;
-
-/**
- * Catches potential Xlib errors.
- */
-static int
-mesaHandleXError(Display *dpy, XErrorEvent *event)
-{
- (void) dpy;
- (void) event;
- mesaXErrorFlag = 1;
- return 0;
-}
-
-static char *alloc_shm(struct xm_displaytarget *buf, unsigned size)
-{
- XShmSegmentInfo *const shminfo = & buf->shminfo;
-
- shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
- if (shminfo->shmid < 0) {
- return NULL;
- }
-
- shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
- if (shminfo->shmaddr == (char *) -1) {
- shmctl(shminfo->shmid, IPC_RMID, 0);
- return NULL;
- }
-
- shminfo->readOnly = False;
- return shminfo->shmaddr;
-}
-
-
-/**
- * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
- */
-static void
-alloc_shm_ximage(struct xm_displaytarget *xm_buffer,
- struct xmesa_buffer *xmb,
- unsigned width, unsigned height)
-{
- /*
- * We have to do a _lot_ of error checking here to be sure we can
- * really use the XSHM extension. It seems different servers trigger
- * errors at different points if the extension won't work. Therefore
- * we have to be very careful...
- */
- int (*old_handler)(Display *, XErrorEvent *);
-
- xm_buffer->tempImage = XShmCreateImage(xmb->xm_visual->display,
- xmb->xm_visual->visinfo->visual,
- xmb->xm_visual->visinfo->depth,
- ZPixmap,
- NULL,
- &xm_buffer->shminfo,
- width, height);
- if (xm_buffer->tempImage == NULL) {
- xm_buffer->shm = 0;
- return;
- }
-
-
- mesaXErrorFlag = 0;
- old_handler = XSetErrorHandler(mesaHandleXError);
- /* This may trigger the X protocol error we're ready to catch: */
- XShmAttach(xmb->xm_visual->display, &xm_buffer->shminfo);
- XSync(xmb->xm_visual->display, False);
-
- if (mesaXErrorFlag) {
- /* we are on a remote display, this error is normal, don't print it */
- XFlush(xmb->xm_visual->display);
- mesaXErrorFlag = 0;
- XDestroyImage(xm_buffer->tempImage);
- xm_buffer->tempImage = NULL;
- xm_buffer->shm = 0;
- (void) XSetErrorHandler(old_handler);
- return;
- }
-
- xm_buffer->shm = 1;
-}
-
-#endif /* USE_XSHM */
-
-static boolean
-xm_is_displaytarget_format_supported( struct llvmpipe_winsys *ws,
- enum pipe_format format )
-{
- /* TODO: check visuals or other sensible thing here */
- return TRUE;
-}
-
-
-static void *
-xm_displaytarget_map(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt,
- unsigned flags)
-{
- struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
- xm_dt->mapped = xm_dt->data;
- return xm_dt->mapped;
-}
-
-static void
-xm_displaytarget_unmap(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt)
-{
- struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
- xm_dt->mapped = NULL;
-}
-
-static void
-xm_displaytarget_destroy(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt)
-{
- struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
-
- if (xm_dt->data) {
-#ifdef USE_XSHM
- if (xm_dt->shminfo.shmid >= 0) {
- shmdt(xm_dt->shminfo.shmaddr);
- shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0);
-
- xm_dt->shminfo.shmid = -1;
- xm_dt->shminfo.shmaddr = (char *) -1;
- }
- else
-#endif
- FREE(xm_dt->data);
- }
-
- FREE(xm_dt);
-}
-
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xm_llvmpipe_display(struct xmesa_buffer *xm_buffer,
- struct llvmpipe_displaytarget *dt)
-{
- XImage *ximage;
- struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
- static boolean no_swap = 0;
- static boolean firsttime = 1;
-
- if (firsttime) {
- no_swap = getenv("SP_NO_RAST") != NULL;
- firsttime = 0;
- }
-
- if (no_swap)
- return;
-
-#ifdef USE_XSHM
- if (xm_dt->shm)
- {
- if (xm_dt->tempImage == NULL)
- {
- assert(util_format_get_blockwidth(xm_dt->format) == 1);
- assert(util_format_get_blockheight(xm_dt->format) == 1);
- alloc_shm_ximage(xm_dt, xm_buffer,
- xm_dt->stride / util_format_get_blocksize(xm_dt->format),
- xm_dt->height);
- }
-
- ximage = xm_dt->tempImage;
- ximage->data = xm_dt->data;
-
- /* _debug_printf("XSHM\n"); */
- XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
- ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
- }
- else
-#endif
- {
- /* display image in Window */
- ximage = xm_dt->tempImage;
- ximage->data = xm_dt->data;
-
- /* check that the XImage has been previously initialized */
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
- /* update XImage's fields */
- ximage->width = xm_dt->width;
- ximage->height = xm_dt->height;
- ximage->bytes_per_line = xm_dt->stride;
-
- /* _debug_printf("XPUT\n"); */
- XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc,
- ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
- }
-}
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xm_displaytarget_display(struct llvmpipe_winsys *ws,
- struct llvmpipe_displaytarget *dt,
- void *context_private)
-{
- XMesaContext xmctx = (XMesaContext) context_private;
- struct xmesa_buffer *xm_buffer = xmctx->xm_buffer;
- xm_llvmpipe_display(xm_buffer, dt);
-}
-
-
-static struct llvmpipe_displaytarget *
-xm_displaytarget_create(struct llvmpipe_winsys *winsys,
- enum pipe_format format,
- unsigned width, unsigned height,
- unsigned alignment,
- unsigned *stride)
-{
- struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget);
- unsigned nblocksy, size;
-
- xm_dt = CALLOC_STRUCT(xm_displaytarget);
- if(!xm_dt)
- goto no_xm_dt;
-
- xm_dt->format = format;
- xm_dt->width = width;
- xm_dt->height = height;
-
- nblocksy = util_format_get_nblocksy(format, height);
- xm_dt->stride = align(util_format_get_stride(format, width), alignment);
- size = xm_dt->stride * nblocksy;
-
-#ifdef USE_XSHM
- if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
- {
- xm_dt->shminfo.shmid = -1;
- xm_dt->shminfo.shmaddr = (char *) -1;
- xm_dt->shm = TRUE;
-
- xm_dt->data = alloc_shm(xm_dt, size);
- if(!xm_dt->data)
- goto no_data;
- }
-#endif
-
- if(!xm_dt->data) {
- xm_dt->data = align_malloc(size, alignment);
- if(!xm_dt->data)
- goto no_data;
- }
-
- *stride = xm_dt->stride;
- return (struct llvmpipe_displaytarget *)xm_dt;
-
-no_data:
- FREE(xm_dt);
-no_xm_dt:
- return NULL;
-}
-
-
-static void
-xm_destroy( struct llvmpipe_winsys *ws )
-{
- FREE(ws);
-}
-
-
-static struct llvmpipe_winsys *
-xlib_create_llvmpipe_winsys( void )
-{
- struct xmesa_llvmpipe_winsys *ws;
-
- ws = CALLOC_STRUCT(xmesa_llvmpipe_winsys);
- if (!ws)
- return NULL;
-
- ws->base.destroy = xm_destroy;
-
- ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported;
-
- ws->base.displaytarget_create = xm_displaytarget_create;
- ws->base.displaytarget_map = xm_displaytarget_map;
- ws->base.displaytarget_unmap = xm_displaytarget_unmap;
- ws->base.displaytarget_destroy = xm_displaytarget_destroy;
-
- ws->base.displaytarget_display = xm_displaytarget_display;
-
- return &ws->base;
-}
+#if defined(GALLIUM_LLVMPIPE)
+#include "llvmpipe/lp_texture.h"
+#include "llvmpipe/lp_screen.h"
+#include "state_tracker/xlib_sw_winsys.h"
+#include "util/u_debug.h"
static struct pipe_screen *
-xlib_create_llvmpipe_screen( void )
+xlib_create_llvmpipe_screen( Display *display )
{
- struct llvmpipe_winsys *winsys;
+ struct sw_winsys *winsys;
struct pipe_screen *screen;
- winsys = xlib_create_llvmpipe_winsys();
+ winsys = xlib_create_sw_winsys( display );
if (winsys == NULL)
return NULL;
@@ -419,22 +69,9 @@ fail:
}
-static void
-xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer,
- struct pipe_surface *surf)
-{
- struct llvmpipe_texture *texture = llvmpipe_texture(surf->texture);
-
- assert(texture->dt);
- if (texture->dt)
- xm_llvmpipe_display(xm_buffer, texture->dt);
-}
-
-
struct xm_driver xlib_llvmpipe_driver =
{
.create_pipe_screen = xlib_create_llvmpipe_screen,
- .display_surface = xlib_llvmpipe_display_surface
};
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
index 716338aef4..08b7f08837 100644
--- a/src/gallium/winsys/xlib/xlib_softpipe.c
+++ b/src/gallium/winsys/xlib/xlib_softpipe.c
@@ -26,461 +26,20 @@
*
**************************************************************************/
-/*
- * Authors:
- * Keith Whitwell
- * Brian Paul
- */
-
-
-#include "xm_api.h"
-
-#undef ASSERT
-#undef Elements
-
-#include "util/u_simple_screen.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "softpipe/sp_winsys.h"
-#include "softpipe/sp_texture.h"
#include "xlib.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;
-#ifdef USE_XSHM
- boolean shm; /** Is this a shared memory buffer? */
- XShmSegmentInfo shminfo;
-#endif
-};
-
-
-/**
- * Subclass of pipe_winsys for Xlib winsys
- */
-struct xmesa_pipe_winsys
-{
- struct pipe_winsys base;
-/* struct xmesa_visual *xm_visual; */
-};
-
-
-
-/** Cast wrapper */
-static INLINE struct xm_buffer *
-xm_buffer( struct pipe_buffer *buf )
-{
- return (struct xm_buffer *)buf;
-}
-
-
-/**
- * X Shared Memory Image extension code
- */
-
-#ifdef USE_XSHM
-
-static volatile int mesaXErrorFlag = 0;
-
-/**
- * Catches potential Xlib errors.
- */
-static int
-mesaHandleXError(Display *dpy, XErrorEvent *event)
-{
- (void) dpy;
- (void) event;
- mesaXErrorFlag = 1;
- return 0;
-}
-
-
-static char *alloc_shm(struct xm_buffer *buf, unsigned size)
-{
- XShmSegmentInfo *const shminfo = & buf->shminfo;
-
- shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
- if (shminfo->shmid < 0) {
- return NULL;
- }
-
- shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
- if (shminfo->shmaddr == (char *) -1) {
- shmctl(shminfo->shmid, IPC_RMID, 0);
- return NULL;
- }
-
- shminfo->readOnly = False;
- return shminfo->shmaddr;
-}
-
-
-/**
- * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
- */
-static void
-alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
- unsigned width, unsigned height)
-{
- /*
- * We have to do a _lot_ of error checking here to be sure we can
- * really use the XSHM extension. It seems different servers trigger
- * errors at different points if the extension won't work. Therefore
- * we have to be very careful...
- */
- int (*old_handler)(Display *, XErrorEvent *);
-
- b->tempImage = XShmCreateImage(xmb->xm_visual->display,
- xmb->xm_visual->visinfo->visual,
- xmb->xm_visual->visinfo->depth,
- ZPixmap,
- NULL,
- &b->shminfo,
- width, height);
- if (b->tempImage == NULL) {
- b->shm = FALSE;
- return;
- }
-
-
- mesaXErrorFlag = 0;
- old_handler = XSetErrorHandler(mesaHandleXError);
- /* This may trigger the X protocol error we're ready to catch: */
- XShmAttach(xmb->xm_visual->display, &b->shminfo);
- XSync(xmb->xm_visual->display, False);
-
- if (mesaXErrorFlag) {
- /* we are on a remote display, this error is normal, don't print it */
- XFlush(xmb->xm_visual->display);
- mesaXErrorFlag = 0;
- XDestroyImage(b->tempImage);
- b->tempImage = NULL;
- b->shm = FALSE;
- (void) XSetErrorHandler(old_handler);
- return;
- }
-
- b->shm = TRUE;
-}
-
-#endif /* USE_XSHM */
-
-
-
-/* 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_buffer *buf)
-{
- struct xm_buffer *oldBuf = xm_buffer(buf);
-
- /*
- * Note oldBuf->data may point to one of three things:
- * 1. XShm shared memory image data
- * 2. User-provided (wrapped) memory, see xm_user_buffer_create()
- * 3. Regular, malloc'd memory
- * We need to be careful with freeing that data now.
- */
-
- if (oldBuf->data) {
-#ifdef USE_XSHM
- if (oldBuf->shminfo.shmid >= 0) {
- shmdt(oldBuf->shminfo.shmaddr);
- shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0);
-
- oldBuf->shminfo.shmid = -1;
- oldBuf->shminfo.shmaddr = (char *) -1;
- }
-
- if (oldBuf->shm) {
- oldBuf->data = NULL;
- }
-
- if (oldBuf->tempImage) {
- XDestroyImage(oldBuf->tempImage);
- oldBuf->tempImage = NULL;
- }
-#endif
-
- if (oldBuf->data && !oldBuf->userBuffer) {
- /* this was regular malloc'd memory */
- align_free(oldBuf->data);
- }
-
- oldBuf->data = NULL;
- }
-
- free(oldBuf);
-}
-
-
-/**
- * Display/copy the image in the surface into the X window specified
- * by the XMesaBuffer.
- */
-static void
-xlib_softpipe_display_surface(struct xmesa_buffer *b,
- struct pipe_surface *surf)
-{
- XImage *ximage;
- struct softpipe_texture *spt = softpipe_texture(surf->texture);
- struct xm_buffer *xm_buf = xm_buffer(spt->buffer);
- static boolean no_swap = 0;
- static boolean firsttime = 1;
-
- if (firsttime) {
- no_swap = getenv("SP_NO_RAST") != NULL;
- firsttime = 0;
- }
-
- if (no_swap)
- return;
-
-#ifdef USE_XSHM
- if (xm_buf->shm)
- {
- if (xm_buf->tempImage == NULL)
- {
- assert(util_format_get_blockwidth(surf->texture->format) == 1);
- assert(util_format_get_blockheight(surf->texture->format) == 1);
- alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] /
- util_format_get_blocksize(surf->texture->format), surf->height);
- }
-
- ximage = xm_buf->tempImage;
- ximage->data = xm_buf->data;
-
- /* _debug_printf("XSHM\n"); */
- XShmPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, 0, 0, surf->width, surf->height, False);
- }
- else
-#endif
- {
- /* display image in Window */
- ximage = b->tempImage;
- ximage->data = xm_buf->data;
-
- /* check that the XImage has been previously initialized */
- assert(ximage->format);
- assert(ximage->bitmap_unit);
-
- /* update XImage's fields */
- ximage->width = surf->width;
- ximage->height = surf->height;
- ximage->bytes_per_line = spt->stride[surf->level];
-
- /* _debug_printf("XPUT\n"); */
- XPutImage(b->xm_visual->display, b->drawable, b->gc,
- ximage, 0, 0, 0, 0, surf->width, surf->height);
- }
-}
-
-
-static void
-xm_flush_frontbuffer(struct pipe_winsys *pws,
- struct pipe_surface *surf,
- void *context_private)
-{
- /*
- * The front color buffer is actually just another XImage buffer.
- * This function copies that XImage to the actual X Window.
- */
- XMesaContext xmctx = (XMesaContext) context_private;
- xlib_softpipe_display_surface(xmctx->xm_buffer, surf);
- xmesa_check_and_update_buffer_size(xmctx, xmctx->xm_buffer);
-}
-
-
-
-static const char *
-xm_get_name(struct pipe_winsys *pws)
-{
- return "Xlib";
-}
-
-
-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);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- /* 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);
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-xm_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- unsigned nblocksy, size;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), alignment);
- size = *stride * nblocksy;
-
-#ifdef USE_XSHM
- if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
- {
- struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
- buffer->userBuffer = FALSE;
- buffer->shminfo.shmid = -1;
- buffer->shminfo.shmaddr = (char *) -1;
- buffer->shm = TRUE;
-
- buffer->data = alloc_shm(buffer, size);
- if (!buffer->data)
- goto out;
-
- return &buffer->base;
-
- out:
- if (buffer)
- FREE(buffer);
- }
-#endif
-
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- size);
-}
-
-
-/*
- * 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_softpipe_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_buffer_create = xm_surface_buffer_create;
-
- 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;
-}
-
+#include "softpipe/sp_texture.h"
+#include "softpipe/sp_screen.h"
+#include "state_tracker/xlib_sw_winsys.h"
+#include "util/u_debug.h"
static struct pipe_screen *
-xlib_create_softpipe_screen( void )
+xlib_create_softpipe_screen( Display *display )
{
- struct pipe_winsys *winsys;
+ struct sw_winsys *winsys;
struct pipe_screen *screen;
- winsys = xlib_create_softpipe_winsys();
+ winsys = xlib_create_sw_winsys( display );
if (winsys == NULL)
return NULL;
@@ -498,10 +57,11 @@ fail:
}
+
+
struct xm_driver xlib_softpipe_driver =
{
.create_pipe_screen = xlib_create_softpipe_screen,
- .display_surface = xlib_softpipe_display_surface
};
diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c
new file mode 100644
index 0000000000..9a4ae39aeb
--- /dev/null
+++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c
@@ -0,0 +1,427 @@
+/**************************************************************************
+ *
+ * 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
+ */
+
+
+
+
+#undef ASSERT
+#undef Elements
+
+#include "pipe/p_format.h"
+#include "pipe/p_context.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "state_tracker/xlib_sw_winsys.h"
+
+#include "xlib.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+
+/**
+ * Subclass of pipe_buffer for Xlib winsys.
+ * Low-level OS/window system memory buffer
+ */
+struct xm_displaytarget
+{
+ enum pipe_format format;
+ unsigned width;
+ unsigned height;
+ unsigned stride;
+
+ void *data;
+ void *mapped;
+
+ Display *display;
+ Visual *visual;
+ XImage *tempImage;
+
+ XShmSegmentInfo shminfo;
+ int shm;
+};
+
+
+/**
+ * Subclass of sw_winsys for Xlib winsys
+ */
+struct xlib_sw_winsys
+{
+ struct sw_winsys base;
+
+
+
+ Display *display;
+};
+
+
+
+/** Cast wrapper */
+static INLINE struct xm_displaytarget *
+xm_displaytarget( struct sw_displaytarget *dt )
+{
+ return (struct xm_displaytarget *)dt;
+}
+
+
+/**
+ * X Shared Memory Image extension code
+ */
+
+#ifdef USE_XSHM
+
+static volatile int mesaXErrorFlag = 0;
+
+/**
+ * Catches potential Xlib errors.
+ */
+static int
+mesaHandleXError(Display *dpy, XErrorEvent *event)
+{
+ (void) dpy;
+ (void) event;
+ mesaXErrorFlag = 1;
+ return 0;
+}
+
+
+static char *alloc_shm(struct xm_displaytarget *buf, unsigned size)
+{
+ XShmSegmentInfo *const shminfo = & buf->shminfo;
+
+ shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
+ if (shminfo->shmid < 0) {
+ return NULL;
+ }
+
+ shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
+ if (shminfo->shmaddr == (char *) -1) {
+ shmctl(shminfo->shmid, IPC_RMID, 0);
+ return NULL;
+ }
+
+ shminfo->readOnly = False;
+ return shminfo->shmaddr;
+}
+
+
+/**
+ * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
+ */
+static void
+alloc_shm_ximage(struct xm_displaytarget *xm_dt,
+ struct xlib_drawable *xmb,
+ unsigned width, unsigned height)
+{
+ /*
+ * We have to do a _lot_ of error checking here to be sure we can
+ * really use the XSHM extension. It seems different servers trigger
+ * errors at different points if the extension won't work. Therefore
+ * we have to be very careful...
+ */
+ int (*old_handler)(Display *, XErrorEvent *);
+
+ xm_dt->tempImage = XShmCreateImage(xm_dt->display,
+ xmb->visual,
+ xmb->depth,
+ ZPixmap,
+ NULL,
+ &xm_dt->shminfo,
+ width, height);
+ if (xm_dt->tempImage == NULL) {
+ xm_dt->shm = 0;
+ return;
+ }
+
+
+ mesaXErrorFlag = 0;
+ old_handler = XSetErrorHandler(mesaHandleXError);
+ /* This may trigger the X protocol error we're ready to catch: */
+ XShmAttach(xm_dt->display, &xm_dt->shminfo);
+ XSync(xm_dt->display, False);
+
+ if (mesaXErrorFlag) {
+ /* we are on a remote display, this error is normal, don't print it */
+ XFlush(xm_dt->display);
+ mesaXErrorFlag = 0;
+ XDestroyImage(xm_dt->tempImage);
+ xm_dt->tempImage = NULL;
+ xm_dt->shm = 0;
+ (void) XSetErrorHandler(old_handler);
+ return;
+ }
+
+ xm_dt->shm = 1;
+}
+
+#endif /* USE_XSHM */
+
+static void
+alloc_ximage(struct xm_displaytarget *xm_dt,
+ struct xlib_drawable *xmb,
+ unsigned width, unsigned height)
+{
+#ifdef USE_XSHM
+ if (xm_dt->shm) {
+ alloc_shm_ximage(xm_dt, xmb, width, height);
+ return;
+ }
+#endif
+
+ xm_dt->tempImage = XCreateImage(xm_dt->display,
+ xmb->visual,
+ xmb->depth,
+ ZPixmap, 0,
+ NULL, width, height,
+ 8, 0);
+}
+
+static boolean
+xm_is_displaytarget_format_supported( struct sw_winsys *ws,
+ enum pipe_format format )
+{
+ /* TODO: check visuals or other sensible thing here */
+ return TRUE;
+}
+
+
+static void *
+xm_displaytarget_map(struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ unsigned flags)
+{
+ struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+ xm_dt->mapped = xm_dt->data;
+ return xm_dt->mapped;
+}
+
+static void
+xm_displaytarget_unmap(struct sw_winsys *ws,
+ struct sw_displaytarget *dt)
+{
+ struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+ xm_dt->mapped = NULL;
+}
+
+static void
+xm_displaytarget_destroy(struct sw_winsys *ws,
+ struct sw_displaytarget *dt)
+{
+ struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+
+ if (xm_dt->data) {
+#ifdef USE_XSHM
+ if (xm_dt->shminfo.shmid >= 0) {
+ shmdt(xm_dt->shminfo.shmaddr);
+ shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0);
+
+ xm_dt->shminfo.shmid = -1;
+ xm_dt->shminfo.shmaddr = (char *) -1;
+ }
+ else
+#endif
+ FREE(xm_dt->data);
+ }
+
+ FREE(xm_dt);
+}
+
+
+/**
+ * Display/copy the image in the surface into the X window specified
+ * by the XMesaBuffer.
+ */
+void
+xlib_sw_display(struct xlib_drawable *xlib_drawable,
+ struct sw_displaytarget *dt)
+{
+ XImage *ximage;
+ struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+ static boolean no_swap = 0;
+ static boolean firsttime = 1;
+
+ if (firsttime) {
+ no_swap = getenv("SP_NO_RAST") != NULL;
+ firsttime = 0;
+ }
+
+ if (no_swap)
+ return;
+
+ if (xm_dt->tempImage == NULL)
+ {
+ assert(util_format_get_blockwidth(xm_dt->format) == 1);
+ assert(util_format_get_blockheight(xm_dt->format) == 1);
+ alloc_ximage(xm_dt, xlib_drawable,
+ xm_dt->stride / util_format_get_blocksize(xm_dt->format),
+ xm_dt->height);
+ if (!xm_dt->tempImage)
+ return;
+ }
+
+#ifdef USE_XSHM
+ if (xm_dt->shm)
+ {
+ ximage = xm_dt->tempImage;
+ ximage->data = xm_dt->data;
+
+ /* _debug_printf("XSHM\n"); */
+ XShmPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc,
+ ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
+ }
+ else
+#endif
+ {
+ /* display image in Window */
+ ximage = xm_dt->tempImage;
+ ximage->data = xm_dt->data;
+
+ /* check that the XImage has been previously initialized */
+ assert(ximage->format);
+ assert(ximage->bitmap_unit);
+
+ /* update XImage's fields */
+ ximage->width = xm_dt->width;
+ ximage->height = xm_dt->height;
+ ximage->bytes_per_line = xm_dt->stride;
+
+ /* _debug_printf("XPUT\n"); */
+ XPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc,
+ ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height);
+ }
+}
+
+/**
+ * Display/copy the image in the surface into the X window specified
+ * by the XMesaBuffer.
+ */
+static void
+xm_displaytarget_display(struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ void *context_private)
+{
+ struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private;
+ xlib_sw_display(xlib_drawable, dt);
+}
+
+
+static struct sw_displaytarget *
+xm_displaytarget_create(struct sw_winsys *winsys,
+ enum pipe_format format,
+ unsigned width, unsigned height,
+ unsigned alignment,
+ unsigned *stride)
+{
+ struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget);
+ unsigned nblocksy, size;
+
+ xm_dt = CALLOC_STRUCT(xm_displaytarget);
+ if(!xm_dt)
+ goto no_xm_dt;
+
+ xm_dt->display = ((struct xlib_sw_winsys *)winsys)->display;
+ xm_dt->format = format;
+ xm_dt->width = width;
+ xm_dt->height = height;
+
+ nblocksy = util_format_get_nblocksy(format, height);
+ xm_dt->stride = align(util_format_get_stride(format, width), alignment);
+ size = xm_dt->stride * nblocksy;
+
+#ifdef USE_XSHM
+ if (!debug_get_bool_option("XLIB_NO_SHM", FALSE))
+ {
+ xm_dt->shminfo.shmid = -1;
+ xm_dt->shminfo.shmaddr = (char *) -1;
+ xm_dt->shm = TRUE;
+
+ xm_dt->data = alloc_shm(xm_dt, size);
+ if(!xm_dt->data)
+ goto no_data;
+ }
+#endif
+
+ if(!xm_dt->data) {
+ xm_dt->data = align_malloc(size, alignment);
+ if(!xm_dt->data)
+ goto no_data;
+ }
+
+ *stride = xm_dt->stride;
+ return (struct sw_displaytarget *)xm_dt;
+
+no_data:
+ FREE(xm_dt);
+no_xm_dt:
+ return NULL;
+}
+
+
+static void
+xm_destroy( struct sw_winsys *ws )
+{
+ FREE(ws);
+}
+
+
+struct sw_winsys *
+xlib_create_sw_winsys( Display *display )
+{
+ struct xlib_sw_winsys *ws;
+
+ ws = CALLOC_STRUCT(xlib_sw_winsys);
+ if (!ws)
+ return NULL;
+
+ ws->display = display;
+ ws->base.destroy = xm_destroy;
+
+ ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported;
+
+ ws->base.displaytarget_create = xm_displaytarget_create;
+ ws->base.displaytarget_map = xm_displaytarget_map;
+ ws->base.displaytarget_unmap = xm_displaytarget_unmap;
+ ws->base.displaytarget_destroy = xm_displaytarget_destroy;
+
+ ws->base.displaytarget_display = xm_displaytarget_display;
+
+ return &ws->base;
+}
+
diff --git a/src/gallium/winsys/xlib/xmesa.h b/src/gallium/winsys/xlib/xmesa.h
deleted file mode 100644
index 98139af833..0000000000
--- a/src/gallium/winsys/xlib/xmesa.h
+++ /dev/null
@@ -1,424 +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.
- */
-
-
-/*
- * Mesa/X11 interface. This header file serves as the documentation for
- * the Mesa/X11 interface functions.
- *
- * Note: this interface isn't intended for user programs. It's primarily
- * just for implementing the pseudo-GLX interface.
- */
-
-
-/* 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
-
-#ifdef __VMS
-#include <GL/vms_x_fix.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef XFree86Server
-#include "xmesa_xf86.h"
-#else
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "xmesa_x.h"
-#endif
-#include "GL/gl.h"
-
-#ifdef AMIWIN
-#include <pragmas/xlib_pragmas.h>
-extern struct Library *XLibBase;
-#endif
-
-
-#define XMESA_MAJOR_VERSION 6
-#define XMESA_MINOR_VERSION 3
-
-
-
-/*
- * Values passed to XMesaGetString:
- */
-#define XMESA_VERSION 1
-#define XMESA_EXTENSIONS 2
-
-
-/*
- * Values passed to XMesaSetFXmode:
- */
-#define XMESA_FX_WINDOW 1
-#define XMESA_FX_FULLSCREEN 2
-
-
-
-typedef struct xmesa_context *XMesaContext;
-
-typedef struct xmesa_visual *XMesaVisual;
-
-typedef struct xmesa_buffer *XMesaBuffer;
-
-
-
-/*
- * 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( XMesaDisplay *display,
- XMesaVisualInfo 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 );
-
-
-#ifdef XFree86Server
-/*
- * These are the extra routines required for integration with XFree86.
- * None of these routines should be user visible. -KEM
- */
-extern GLboolean XMesaForceCurrent( XMesaContext c );
-
-extern GLboolean XMesaLoseCurrent( XMesaContext c );
-
-extern GLboolean XMesaCopyContext( XMesaContext src,
- XMesaContext dst,
- GLuint mask );
-#endif /* XFree86Server */
-
-
-/*
- * Create an XMesaBuffer from an X window.
- */
-extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
-
-
-/*
- * Create an XMesaBuffer from an X pixmap.
- */
-extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
- XMesaPixmap p,
- XMesaColormap 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( XMesaDisplay *dpy,
- XMesaDrawable d );
-
-
-
-/*
- * Bind a buffer to a context and make the context the current one.
- */
-extern GLboolean XMesaMakeCurrent( XMesaContext c,
- XMesaBuffer b );
-
-
-/*
- * 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 );
-
-
-/*
- * Return handle to the current (draw) buffer.
- */
-extern XMesaBuffer XMesaGetCurrentBuffer( void );
-
-
-/*
- * Return handle to the current read buffer.
- * New in Mesa 3.3
- */
-extern XMesaBuffer XMesaGetCurrentReadBuffer( 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 );
-
-
-/*
- * Return a pointer to the the Pixmap or XImage being used as the back
- * color buffer of an XMesaBuffer. This function is a way to get "under
- * the hood" of X/Mesa so one can manipulate the back buffer directly.
- * Input: b - the XMesaBuffer
- * Output: pixmap - pointer to back buffer's Pixmap, or 0
- * ximage - pointer to back buffer's XImage, or NULL
- * Return: GL_TRUE = context is double buffered
- * GL_FALSE = context is single buffered
- */
-extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
- XMesaPixmap *pixmap,
- XMesaImage **ximage );
-
-
-
-/*
- * 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.
- *
- * New in Mesa 2.4.
- */
-extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
- GLint *width,
- GLint *height,
- GLint *bytesPerValue,
- void **buffer );
-
-
-
-/*
- * Flush/sync a context
- */
-extern void XMesaFlush( XMesaContext c );
-
-
-
-/*
- * Get an X/Mesa-specific string.
- * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
- */
-extern const char *XMesaGetString( XMesaContext c, int name );
-
-
-
-/*
- * 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 );
-
-
-
-/*
- * Return a dithered pixel value.
- * Input: c - XMesaContext
- * x, y - window coordinate
- * red, green, blue, alpha - color components in [0,1]
- * Return: pixel value
- *
- * New in Mesa 2.3.
- */
-extern unsigned long XMesaDitherColor( XMesaContext xmesa,
- GLint x,
- GLint y,
- GLfloat red,
- GLfloat green,
- GLfloat blue,
- GLfloat alpha );
-
-
-
-/*
- * 3Dfx Glide driver only!
- * Set 3Dfx/Glide full-screen or window rendering mode.
- * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
- * XMESA_FX_FULLSCREEN (full-screen rendering mode)
- * Return: GL_TRUE if success
- * GL_FALSE if invalid mode or if not using 3Dfx driver
- *
- * New in Mesa 2.6.
- */
-extern GLboolean XMesaSetFXmode( GLint mode );
-
-
-
-/*
- * Reallocate the back/depth/stencil/accum/etc/ buffers associated with
- * buffer <b> if its size has changed.
- *
- * New in Mesa 4.0.2
- */
-extern void XMesaResizeBuffers( XMesaBuffer b );
-
-
-
-/*
- * Create a pbuffer.
- * New in Mesa 4.1
- */
-extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
- unsigned int width, unsigned int height);
-
-
-
-/*
- * Texture from Pixmap
- * New in Mesa 7.1
- */
-extern void
-XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer,
- const int *attrib_list);
-
-extern void
-XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer);
-
-
-extern XMesaBuffer
-XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p,
- XMesaColormap cmap,
- int format, int target, int mipmap);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
diff --git a/src/gallium/winsys/xlib/xmesa_x.h b/src/gallium/winsys/xlib/xmesa_x.h
deleted file mode 100644
index 865bab4313..0000000000
--- a/src/gallium/winsys/xlib/xmesa_x.h
+++ /dev/null
@@ -1,86 +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>
- *
- * When we're building the XMesa driver for stand-alone Mesa we
- * include this file when building the xm_*.c files.
- * We need to define some types and macros differently when building
- * in the Xserver vs. stand-alone Mesa.
- */
-
-#ifndef _XMESA_X_H_
-#define _XMESA_X_H_
-
-typedef Display XMesaDisplay;
-typedef Pixmap XMesaPixmap;
-typedef Colormap XMesaColormap;
-typedef Drawable XMesaDrawable;
-typedef Window XMesaWindow;
-typedef GC XMesaGC;
-typedef XVisualInfo *XMesaVisualInfo;
-typedef XImage XMesaImage;
-typedef XPoint XMesaPoint;
-typedef XColor XMesaColor;
-
-#define XMesaDestroyImage XDestroyImage
-
-#define XMesaPutPixel XPutPixel
-#define XMesaGetPixel XGetPixel
-
-#define XMesaSetForeground XSetForeground
-#define XMesaSetBackground XSetBackground
-#define XMesaSetPlaneMask XSetPlaneMask
-#define XMesaSetFunction XSetFunction
-#define XMesaSetFillStyle XSetFillStyle
-#define XMesaSetTile XSetTile
-
-#define XMesaDrawPoint XDrawPoint
-#define XMesaDrawPoints XDrawPoints
-#define XMesaDrawLine XDrawLine
-#define XMesaFillRectangle XFillRectangle
-#define XMesaGetImage XGetImage
-#define XMesaPutImage XPutImage
-#define XMesaCopyArea XCopyArea
-
-#define XMesaCreatePixmap XCreatePixmap
-#define XMesaFreePixmap XFreePixmap
-#define XMesaFreeGC XFreeGC
-
-#define GET_COLORMAP_SIZE(__v) __v->visinfo->colormap_size
-#define GET_REDMASK(__v) __v->mesa_visual.redMask
-#define GET_GREENMASK(__v) __v->mesa_visual.greenMask
-#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
-#define GET_VISUAL_DEPTH(__v) __v->visinfo->depth
-#define GET_BLACK_PIXEL(__v) BlackPixel(__v->display, __v->mesa_visual.screen)
-#define CHECK_BYTE_ORDER(__v) host_byte_order()==ImageByteOrder(__v->display)
-#define CHECK_FOR_HPCR(__v) XInternAtom(__v->display, "_HP_RGB_SMOOTH_MAP_LIST", True)
-
-#endif