Merge commit 'origin/master' into gallium-sw-api-2
authorKeith Whitwell <keithw@vmware.com>
Wed, 10 Mar 2010 08:29:27 +0000 (08:29 +0000)
committerKeith Whitwell <keithw@vmware.com>
Wed, 10 Mar 2010 08:29:27 +0000 (08:29 +0000)
104 files changed:
SConstruct
configs/autoconf.in
configs/default
configs/linux-cell
configs/linux-dri
configs/linux-egl
configs/linux-i965
configs/linux-opengl-es
src/SConscript
src/gallium/SConscript
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/target-helpers/swrast_xlib.c [new file with mode: 0644]
src/gallium/auxiliary/target-helpers/swrast_xlib.h [new file with mode: 0644]
src/gallium/drivers/cell/ppu/Makefile
src/gallium/drivers/cell/ppu/cell_buffer.c [new file with mode: 0644]
src/gallium/drivers/cell/ppu/cell_buffer.h [new file with mode: 0644]
src/gallium/drivers/cell/ppu/cell_context.c
src/gallium/drivers/cell/ppu/cell_context.h
src/gallium/drivers/cell/ppu/cell_draw_arrays.c
src/gallium/drivers/cell/ppu/cell_fence.c
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/cell/ppu/cell_public.h [new file with mode: 0644]
src/gallium/drivers/cell/ppu/cell_screen.c
src/gallium/drivers/cell/ppu/cell_screen.h
src/gallium/drivers/cell/ppu/cell_state_emit.c
src/gallium/drivers/cell/ppu/cell_state_shader.c
src/gallium/drivers/cell/ppu/cell_texture.c
src/gallium/drivers/cell/ppu/cell_texture.h
src/gallium/drivers/cell/ppu/cell_vertex_shader.c
src/gallium/drivers/cell/ppu/cell_winsys.h [deleted file]
src/gallium/drivers/failover/fo_context.c
src/gallium/drivers/i915/i915_debug_fp.c
src/gallium/drivers/llvmpipe/lp_buffer.c
src/gallium/drivers/llvmpipe/lp_public.h [new file with mode: 0644]
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/llvmpipe/lp_screen.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_texture.c
src/gallium/drivers/llvmpipe/lp_texture.h
src/gallium/drivers/llvmpipe/lp_winsys.h [deleted file]
src/gallium/drivers/softpipe/Makefile
src/gallium/drivers/softpipe/SConscript
src/gallium/drivers/softpipe/sp_buffer.c [new file with mode: 0644]
src/gallium/drivers/softpipe/sp_buffer.h [new file with mode: 0644]
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_public.h [new file with mode: 0644]
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/softpipe/sp_screen.h
src/gallium/drivers/softpipe/sp_state_fs.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/softpipe/sp_winsys.c [deleted file]
src/gallium/drivers/softpipe/sp_winsys.h [deleted file]
src/gallium/drivers/trace/tr_drm.c
src/gallium/drivers/trace/tr_public.h [new file with mode: 0644]
src/gallium/drivers/trace/tr_screen.h
src/gallium/include/state_tracker/sw_winsys.h [new file with mode: 0644]
src/gallium/include/state_tracker/xlib_sw_winsys.h [new file with mode: 0644]
src/gallium/state_trackers/egl/common/egl_g3d.c
src/gallium/state_trackers/egl/common/native.h
src/gallium/state_trackers/egl/x11/native_x11.c
src/gallium/state_trackers/egl/x11/native_x11.h
src/gallium/state_trackers/egl/x11/native_ximage.c
src/gallium/state_trackers/egl/x11/sw_winsys.c [deleted file]
src/gallium/state_trackers/egl/x11/sw_winsys.h [deleted file]
src/gallium/state_trackers/glx/xlib/SConscript
src/gallium/state_trackers/glx/xlib/glx_api.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/glx/xlib/xm_api.h
src/gallium/state_trackers/glx/xlib/xm_public.h [new file with mode: 0644]
src/gallium/state_trackers/glx/xlib/xm_winsys.h [deleted file]
src/gallium/targets/Makefile [new file with mode: 0644]
src/gallium/targets/SConscript [new file with mode: 0644]
src/gallium/targets/libgl-gdi/SConscript [new file with mode: 0644]
src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c [new file with mode: 0644]
src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c [new file with mode: 0644]
src/gallium/targets/libgl-xlib/Makefile [new file with mode: 0644]
src/gallium/targets/libgl-xlib/SConscript [new file with mode: 0644]
src/gallium/targets/libgl-xlib/xlib.c [new file with mode: 0644]
src/gallium/winsys/SConscript
src/gallium/winsys/drm/Makefile.egl
src/gallium/winsys/drm/i965/xlib/xlib_i965.c
src/gallium/winsys/gdi/SConscript
src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c [deleted file]
src/gallium/winsys/gdi/gdi_softpipe_winsys.c [deleted file]
src/gallium/winsys/gdi/gdi_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/gdi/gdi_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/null/Makefile [new file with mode: 0644]
src/gallium/winsys/null/SConscript [new file with mode: 0644]
src/gallium/winsys/null/null_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/null/null_sw_winsys.h [new file with mode: 0644]
src/gallium/winsys/xlib/Makefile
src/gallium/winsys/xlib/SConscript
src/gallium/winsys/xlib/xlib.c [deleted file]
src/gallium/winsys/xlib/xlib.h [deleted file]
src/gallium/winsys/xlib/xlib_brw_context.c [deleted file]
src/gallium/winsys/xlib/xlib_cell.c [deleted file]
src/gallium/winsys/xlib/xlib_llvmpipe.c [deleted file]
src/gallium/winsys/xlib/xlib_softpipe.c [deleted file]
src/gallium/winsys/xlib/xlib_sw_winsys.c [new file with mode: 0644]
src/gallium/winsys/xlib/xmesa.h [deleted file]
src/gallium/winsys/xlib/xmesa_x.h [deleted file]

index e1c4a1898ce01aec5f97d8127eeee1f961a65861..5e171ea2e16d8b9e2abee07f7dd79041f457f284 100644 (file)
@@ -53,6 +53,8 @@ opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers,
                      ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe']))
 opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys,
                      ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon']))
+opts.Add(ListVariable('targets', 'target drivers to build', 'all',
+                     ['xlib']))
 
 opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
 
@@ -110,9 +112,11 @@ Export([
 #######################################################################
 # Environment setup
 
-# Always build trace driver
+# Always build trace and identity drivers
 if 'trace' not in env['drivers']:
     env['drivers'].append('trace')
+if 'identity' not in env['drivers']:
+    env['drivers'].append('identity')
 
 # Includes
 env.Append(CPPPATH = [
index 510d658b119c5abacc62c25fd319d57f3ebbc7ac..bf34f3bffad543f1299259f89560e248e0def348 100644 (file)
@@ -73,6 +73,7 @@ EGL_DRIVERS_DIRS = @EGL_DRIVERS_DIRS@
 GALLIUM_DIRS = @GALLIUM_DIRS@
 GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@
 GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
+GALLIUM_TARGET_DIRS = @GALLIUM_TARGET_DIRS@
 GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@
 GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
index 4fe64cc6c950a5bec30c689b14d5f6facd63eae3..a6a92efe8fb72e5a8aad25b8f7166764133299dc 100644 (file)
@@ -86,7 +86,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2
 
 # Directories to build
 LIB_DIR = lib
-SRC_DIRS = glsl mesa gallium egl gallium/winsys glu glut/glx glew glw
+SRC_DIRS = glsl mesa gallium egl gallium/winsys gallium/targets glu glut/glx glew glw
 GLU_DIRS = sgi
 DRIVER_DIRS = x11 osmesa
 # Which subdirs under $(TOP)/progs/ to enter:
@@ -100,7 +100,8 @@ GALLIUM_DIRS = auxiliary drivers state_trackers
 GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
 GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity
 GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
-GALLIUM_WINSYS_DIRS = drm xlib
+GALLIUM_WINSYS_DIRS = drm null xlib
+GALLIUM_TARGET_DIRS = libgl-xlib
 GALLIUM_WINSYS_DRM_DIRS = swrast
 GALLIUM_STATE_TRACKERS_DIRS = glx vega
 
index e89a08cd93455fd1e1819d1aa90b7b189f2692bf..306b9e01f47a4eafc2c87ba9ce8fee3c10af6052 100644 (file)
@@ -37,7 +37,7 @@ CXXFLAGS = $(COMMON_C_CPP_FLAGS)
 
 
 # Omitting glw here:
-SRC_DIRS = glsl mesa gallium gallium/winsys glu glut/glx glew
+SRC_DIRS = glsl mesa gallium gallium/winsys gallium/targets glu glut/glx glew
 
 # Build no traditional Mesa drivers:
 DRIVER_DIRS =
index b75273946da84245f94d181afe1da1c8acbea0f0..04bcfd859d1919bf6516685fd397af965b78af2f 100644 (file)
@@ -59,6 +59,7 @@ EGL_DRIVERS_DIRS = glx
 
 DRIVER_DIRS = dri
 GALLIUM_WINSYS_DIRS = drm
+GALLIUM_TARGET_DIRS =
 GALLIUM_WINSYS_DRM_DIRS = vmware intel i965
 GALLIUM_STATE_TRACKERS_DIRS = egl
 
index a8910018fce8a5ccb5598db0521f65b1bee35d8f..28165ed5b5a3f30a6d0d86c223a97b0fbdb445b0 100644 (file)
@@ -47,10 +47,11 @@ GL_LIB_DEPS   = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
 
 
 # Directories
-SRC_DIRS = gallium mesa gallium/winsys glu egl
+SRC_DIRS = gallium mesa gallium/winsys gallium/targets glu egl
 PROGRAM_DIRS = egl
 
 DRIVER_DIRS = dri
 GALLIUM_WINSYS_DIRS = egl_drm
+GALLIUM_TARGET_DIRS =
 
 DRI_DIRS = intel 
index e66abc347bb68486018f902db2decfbf03b04440..7656a2adc5eedda07d4c52b03e88c83048e19891 100644 (file)
@@ -6,3 +6,4 @@ CONFIG_NAME = linux-i965
 
 GALLIUM_DRIVER_DIRS = i965
 GALLIUM_WINSYS_DIRS = drm/i965/xlib
+GALLIUM_TARGET_DIRS =
index 259c26a931bd525c1806a1c0f0198547d5b933c8..76054aad14e25160a5d2ecdb9b91b30dd033d459 100644 (file)
@@ -6,7 +6,7 @@ CONFIG_NAME = linux-opengl-es
 
 # Directories to build
 LIB_DIR = lib
-SRC_DIRS = egl glsl mesa/es gallium gallium/winsys
+SRC_DIRS = egl glsl mesa/es gallium gallium/winsys gallium/targets
 PROGRAM_DIRS = es1/screen es1/xegl es2/xegl
 
 # egl st needs this
index cd4896ada401935a25d97d798773981f86fe7b04..cf6db730da24c4c3725068ede845848df71d00ef 100644 (file)
@@ -1,13 +1,12 @@
 Import('*')
 
 SConscript('glsl/SConscript')
-SConscript('gallium/SConscript')
 
 if 'mesa' in env['statetrackers']:
-       SConscript('mesa/SConscript')
+    SConscript('mesa/SConscript')
 
-SConscript('gallium/winsys/SConscript')
+SConscript('gallium/SConscript')
 
 if platform != 'embedded':
-       SConscript('glut/glx/SConscript')
-       SConscript('glew/SConscript')
+    SConscript('glut/glx/SConscript')
+    SConscript('glew/SConscript')
index d56c5c84617a3b1be30a929b8785a59375e163bc..ba541f9636778a1754194882a5627e78876eea40 100644 (file)
@@ -15,3 +15,7 @@ if platform != 'embedded':
 
 if platform == 'windows':
        SConscript('state_trackers/wgl/SConscript')
+
+SConscript('winsys/SConscript')
+
+SConscript('targets/SConscript')
index 68b1a3e854661a73db89d18e32a43962377cedf4..c84e8d781d32f0c9792ce3e02a44bc3546dd69f1 100644 (file)
@@ -131,7 +131,8 @@ C_SOURCES = \
        vl/vl_mpeg12_mc_renderer.c \
        vl/vl_compositor.c \
        vl/vl_csc.c \
-       vl/vl_shader_build.c
+       vl/vl_shader_build.c \
+       target-helpers/swrast_xlib.c
 
 GALLIVM_SOURCES = \
         gallivm/lp_bld_alpha.c \
diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.c b/src/gallium/auxiliary/target-helpers/swrast_xlib.c
new file mode 100644 (file)
index 0000000..bf30ff6
--- /dev/null
@@ -0,0 +1,106 @@
+/**************************************************************************
+ * 
+ * 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 "swrast_xlib.h"
+
+#include "state_tracker/xlib_sw_winsys.h"
+#include "util/u_debug.h"
+#include "softpipe/sp_public.h"
+#include "llvmpipe/lp_public.h"
+#include "identity/id_public.h"
+#include "trace/tr_public.h"
+#include "cell/ppu/cell_public.h"
+
+
+/* Helper function to build a subset of a driver stack consisting of
+ * one of the software rasterizers (cell, llvmpipe, softpipe) and the
+ * xlib winsys.
+ *
+ * This can be called by any target that builds on top of this
+ * combination.
+ */
+struct pipe_screen *
+swrast_xlib_create_screen( Display *display )
+{
+   struct sw_winsys *winsys;
+   struct pipe_screen *screen = NULL;
+
+   /* Create the underlying winsys, which performs presents to Xlib
+    * drawables:
+    */
+   winsys = xlib_create_sw_winsys( display );
+   if (winsys == NULL)
+      return NULL;
+
+   /* Create a software rasterizer on top of that winsys:
+    */
+#if defined(GALLIUM_CELL)
+   if (screen == NULL &&
+       !debug_get_bool_option("GALLIUM_NO_CELL", FALSE))
+      screen = cell_create_screen( winsys );
+#endif
+
+#if defined(GALLIUM_LLVMPIPE)
+   if (screen == NULL &&
+       !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE))
+      screen = llvmpipe_create_screen( winsys );
+#endif
+
+   if (screen == NULL)
+      screen = softpipe_create_screen( winsys );
+
+   if (screen == NULL)
+      goto fail;
+
+   /* Inject any wrapping layers we want to here:
+    */
+   if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) {
+      screen = identity_screen_create(screen);
+   }
+
+   if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) {
+      screen = trace_screen_create( screen );
+   }
+
+   return screen;
+
+fail:
+   if (winsys)
+      winsys->destroy( winsys );
+
+   return NULL;
+}
+
+
+
+
diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.h b/src/gallium/auxiliary/target-helpers/swrast_xlib.h
new file mode 100644 (file)
index 0000000..3a0f713
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef SWRAST_XLIB_HELPER_H
+#define SWRAST_XLIB_HELPER_H
+
+#include <X11/Xlib.h>
+#include "pipe/p_compiler.h"
+
+/* Helper to build the xlib winsys, choose between the software
+ * rasterizers and construct the lower part of a driver stack.
+ *
+ * Just add a state tracker.
+ */
+struct pipe_screen *swrast_xlib_create_screen( Display *display );
+
+
+#endif
index c92f8e5cba2d8f71c9cab329c3735840443f5829..8769b826b5f358551bb0947b0227b37ab1ff532c 100644 (file)
@@ -21,6 +21,7 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a
 
 SOURCES = \
        cell_batch.c \
+       cell_buffer.c \
        cell_clear.c \
        cell_context.c \
        cell_draw_arrays.c \
diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.c b/src/gallium/drivers/cell/ppu/cell_buffer.c
new file mode 100644 (file)
index 0000000..f56a28d
--- /dev/null
@@ -0,0 +1,118 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "cell_screen.h"
+#include "cell_buffer.h"
+
+
+static void *
+cell_buffer_map(struct pipe_screen *screen,
+                    struct pipe_buffer *buf,
+                    unsigned flags)
+{
+   struct cell_buffer *cell_buf = cell_buffer(buf);
+   return cell_buf->data;
+}
+
+
+static void
+cell_buffer_unmap(struct pipe_screen *screen,
+                      struct pipe_buffer *buf)
+{
+}
+
+
+static void
+cell_buffer_destroy(struct pipe_buffer *buf)
+{
+   struct cell_buffer *sbuf = cell_buffer(buf);
+
+   if (!sbuf->userBuffer)
+      align_free(sbuf->data);
+      
+   FREE(sbuf);
+}
+
+
+static struct pipe_buffer *
+cell_buffer_create(struct pipe_screen *screen,
+                       unsigned alignment,
+                       unsigned usage,
+                       unsigned size)
+{
+   struct cell_buffer *buffer = CALLOC_STRUCT(cell_buffer);
+
+   pipe_reference_init(&buffer->base.reference, 1);
+   buffer->base.screen = screen;
+   buffer->base.alignment = MAX2(alignment, 16);
+   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 *
+cell_user_buffer_create(struct pipe_screen *screen,
+                            void *ptr,
+                            unsigned bytes)
+{
+   struct cell_buffer *buffer;
+
+   buffer = CALLOC_STRUCT(cell_buffer);
+   if(!buffer)
+      return NULL;
+
+   pipe_reference_init(&buffer->base.reference, 1);
+   buffer->base.screen = screen;
+   buffer->base.size = bytes;
+   buffer->userBuffer = TRUE;
+   buffer->data = ptr;
+
+   return &buffer->base;
+}
+
+
+void
+cell_init_screen_buffer_funcs(struct pipe_screen *screen)
+{
+   screen->buffer_create = cell_buffer_create;
+   screen->user_buffer_create = cell_user_buffer_create;
+   screen->buffer_map = cell_buffer_map;
+   screen->buffer_unmap = cell_buffer_unmap;
+   screen->buffer_destroy = cell_buffer_destroy;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.h b/src/gallium/drivers/cell/ppu/cell_buffer.h
new file mode 100644 (file)
index 0000000..ef0a8a7
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ *
+ * 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 VMWARE 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 SP_BUFFER_H
+#define SP_BUFFER_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+struct cell_buffer
+{
+   struct pipe_buffer base;
+   boolean userBuffer;  /** Is this a user-space buffer? */
+   void *data;
+};
+
+
+/** Cast wrapper */
+static INLINE struct cell_buffer *
+cell_buffer( struct pipe_buffer *buf )
+{
+   return (struct cell_buffer *)buf;
+}
+
+
+void
+cell_init_screen_buffer_funcs(struct pipe_screen *screen);
+
+
+#endif /* SP_BUFFER_H */
index 5bff9869fd0e8fb3129e7066e29ac8475c067eb6..afcea616d5934c8743c578742184865566d11aa5 100644 (file)
@@ -36,7 +36,6 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_format.h"
 #include "util/u_memory.h"
-#include "util/u_simple_screen.h"
 #include "pipe/p_screen.h"
 
 #include "draw/draw_context.h"
@@ -137,7 +136,7 @@ cell_create_context(struct pipe_screen *screen,
    memset(cell, 0, sizeof(*cell));
 
    cell->winsys = NULL;                /* XXX: fixme - get this from screen? */
-   cell->pipe.winsys = screen->winsys;
+   cell->pipe.winsys = NULL;
    cell->pipe.screen = screen;
    cell->pipe.priv = priv;
    cell->pipe.destroy = cell_destroy_context;
index 584f3558044098fa355f5411eb6e92b1eba59c96..28f80b82cd590d3336ff5274066e9c780c5a093f 100644 (file)
@@ -34,7 +34,7 @@
 #include "pipe/p_defines.h"
 #include "draw/draw_vertex.h"
 #include "draw/draw_vbuf.h"
-#include "cell_winsys.h"
+/*#include "cell_winsys.h"*/
 #include "cell/common.h"
 #include "rtasm/rtasm_ppc_spe.h"
 #include "tgsi/tgsi_scan.h"
index bffd0fac6fed3ad03cda65a7abbe365ebbdc31d7..15d4e8338f43eb532c7cd86676b305a45506213b 100644 (file)
 
 #include "pipe/p_defines.h"
 #include "pipe/p_context.h"
-#include "util/u_simple_screen.h"
 #include "util/u_inlines.h"
 
 #include "cell_context.h"
 #include "cell_draw_arrays.h"
 #include "cell_state.h"
 #include "cell_flush.h"
+#include "cell_buffer.h"
 
 #include "draw/draw_context.h"
 
 
 
-static void
-cell_map_constant_buffers(struct cell_context *sp)
-{
-   struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i;
-   for (i = 0; i < 2; i++) {
-      if (sp->constants[i] && sp->constants[i]->size) {
-         sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i],
-                                                   PIPE_BUFFER_USAGE_CPU_READ);
-         cell_flush_buffer_range(sp, sp->mapped_constants[i], 
-                                 sp->constants[i]->size);
-      }
-   }
-
-   draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, 0,
-                                   sp->mapped_constants[PIPE_SHADER_VERTEX],
-                                   sp->constants[PIPE_SHADER_VERTEX]->size);
-}
-
-static void
-cell_unmap_constant_buffers(struct cell_context *sp)
-{
-   struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i;
-   for (i = 0; i < 2; i++) {
-      if (sp->constants[i] && sp->constants[i]->size)
-         ws->buffer_unmap(ws, sp->constants[i]);
-      sp->mapped_constants[i] = NULL;
-   }
-}
 
 
 
@@ -93,33 +63,27 @@ cell_draw_range_elements(struct pipe_context *pipe,
                          unsigned max_index,
                          unsigned mode, unsigned start, unsigned count)
 {
-   struct cell_context *sp = cell_context(pipe);
-   struct draw_context *draw = sp->draw;
+   struct cell_context *cell = cell_context(pipe);
+   struct draw_context *draw = cell->draw;
    unsigned i;
 
-   if (sp->dirty)
-      cell_update_derived( sp );
+   if (cell->dirty)
+      cell_update_derived( cell );
 
 #if 0
-   cell_map_surfaces(sp);
+   cell_map_surfaces(cell);
 #endif
-   cell_map_constant_buffers(sp);
 
    /*
     * Map vertex buffers
     */
-   for (i = 0; i < sp->num_vertex_buffers; i++) {
-      void *buf = pipe_buffer_map(pipe->screen,
-                                           sp->vertex_buffer[i].buffer,
-                                           PIPE_BUFFER_USAGE_CPU_READ);
-      cell_flush_buffer_range(sp, buf, sp->vertex_buffer[i].buffer->size);
+   for (i = 0; i < cell->num_vertex_buffers; i++) {
+      void *buf = cell_buffer(cell->vertex_buffer[i].buffer)->data;
       draw_set_mapped_vertex_buffer(draw, i, buf);
    }
    /* Map index buffer, if present */
    if (indexBuffer) {
-      void *mapped_indexes = pipe_buffer_map(pipe->screen,
-                                                      indexBuffer,
-                                                      PIPE_BUFFER_USAGE_CPU_READ);
+      void *mapped_indexes = cell_buffer(indexBuffer)->data;
       draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
    }
    else {
@@ -134,17 +98,19 @@ cell_draw_range_elements(struct pipe_context *pipe,
    /*
     * unmap vertex/index buffers - will cause draw module to flush
     */
-   for (i = 0; i < sp->num_vertex_buffers; i++) {
+   for (i = 0; i < cell->num_vertex_buffers; i++) {
       draw_set_mapped_vertex_buffer(draw, i, NULL);
-      pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
    }
    if (indexBuffer) {
       draw_set_mapped_element_buffer(draw, 0, NULL);
-      pipe_buffer_unmap(pipe->screen, indexBuffer);
    }
 
-   /* Note: leave drawing surfaces mapped */
-   cell_unmap_constant_buffers(sp);
+   /*
+    * TODO: Flush only when a user vertex/index buffer is present
+    * (or even better, modify draw module to do this
+    * internally when this condition is seen?)
+    */
+   draw_flush(draw);
 }
 
 
index e10071529a8fa226d1d9179ee55c2553f45d0b77..035ef41b898aabea3b152b53eb64a451bdea052b 100644 (file)
@@ -92,7 +92,6 @@ cell_add_buffer_to_list(struct cell_context *cell,
                         struct cell_buffer_list *list,
                         struct pipe_buffer *buffer)
 {
-   struct pipe_screen *ps = cell->pipe.screen;
    struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
    /* create new list node which references the buffer, insert at head */
    if (node) {
@@ -157,8 +156,13 @@ cell_add_fenced_textures(struct cell_context *cell)
          printf("Adding texture %p buffer %p to list\n",
                 ct, ct->tiled_buffer[level]);
 #endif
-         if (ct->buffer)
+#if 00
+         /* XXX this needs to be fixed/restored!
+          * Maybe keep pointers to textures, not buffers.
+          */
+         if (ct->base.buffer)
             cell_add_buffer_to_list(cell, list, ct->buffer);
+#endif
       }
    }
 }
index 3d8b4409c75cb8cd13f793c9a4a6aa12ede81f8d..dce10ae7f863c0a4e2c83e1c66afe0a51d43b1af 100644 (file)
@@ -292,17 +292,23 @@ cell_set_sampler_textures(struct pipe_context *pipe,
 static void
 cell_map_surfaces(struct cell_context *cell)
 {
+#if 0
    struct pipe_screen *screen = cell->pipe.screen;
+#endif
    uint i;
 
    for (i = 0; i < 1; i++) {
       struct pipe_surface *ps = cell->framebuffer.cbufs[i];
       if (ps) {
          struct cell_texture *ct = cell_texture(ps->texture);
+#if 0
          cell->cbuf_map[i] = screen->buffer_map(screen,
                                                 ct->buffer,
                                                 (PIPE_BUFFER_USAGE_GPU_READ |
                                                  PIPE_BUFFER_USAGE_GPU_WRITE));
+#else
+         cell->cbuf_map[i] = ct->data;
+#endif
       }
    }
 
@@ -310,10 +316,14 @@ cell_map_surfaces(struct cell_context *cell)
       struct pipe_surface *ps = cell->framebuffer.zsbuf;
       if (ps) {
          struct cell_texture *ct = cell_texture(ps->texture);
+#if 0
          cell->zsbuf_map = screen->buffer_map(screen,
                                               ct->buffer,
                                               (PIPE_BUFFER_USAGE_GPU_READ |
                                                PIPE_BUFFER_USAGE_GPU_WRITE));
+#else
+         cell->zsbuf_map = ct->data;
+#endif
       }
    }
 }
@@ -325,17 +335,17 @@ cell_map_surfaces(struct cell_context *cell)
 static void
 cell_unmap_surfaces(struct cell_context *cell)
 {
-   struct pipe_screen *screen = cell->pipe.screen;
+   /*struct pipe_screen *screen = cell->pipe.screen;*/
    uint i;
 
    for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       struct pipe_surface *ps = cell->framebuffer.cbufs[i];
       if (ps && cell->cbuf_map[i]) {
-         struct cell_texture *ct = cell_texture(ps->texture);
+         /*struct cell_texture *ct = cell_texture(ps->texture);*/
          assert(ps->texture);
-         assert(ct->buffer);
+         /*assert(ct->buffer);*/
 
-         screen->buffer_unmap(screen, ct->buffer);
+         /*screen->buffer_unmap(screen, ct->buffer);*/
          cell->cbuf_map[i] = NULL;
       }
    }
@@ -343,8 +353,8 @@ cell_unmap_surfaces(struct cell_context *cell)
    {
       struct pipe_surface *ps = cell->framebuffer.zsbuf;
       if (ps && cell->zsbuf_map) {
-         struct cell_texture *ct = cell_texture(ps->texture);
-         screen->buffer_unmap(screen, ct->buffer);
+         /*struct cell_texture *ct = cell_texture(ps->texture);*/
+         /*screen->buffer_unmap(screen, ct->buffer);*/
          cell->zsbuf_map = NULL;
       }
    }
diff --git a/src/gallium/drivers/cell/ppu/cell_public.h b/src/gallium/drivers/cell/ppu/cell_public.h
new file mode 100644 (file)
index 0000000..7e2e093
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef CELL_PUBLIC_H
+#define CELL_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+cell_create_screen(struct sw_winsys *winsys);
+
+#endif
index a43f8638dcdc71daa5e7dcb7f2ef0bd6a37ae325..31fd963d19a15f9d9ce9c4eac0391cf6f8fd559c 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "util/u_memory.h"
 #include "util/u_simple_screen.h"
-#include "util/u_simple_screen.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
 #include "cell_context.h"
 #include "cell_screen.h"
 #include "cell_texture.h"
-#include "cell_winsys.h"
+#include "cell_buffer.h"
+#include "cell_public.h"
+
+#include "state_tracker/sw_winsys.h"
 
 
 static const char *
@@ -134,19 +136,28 @@ cell_is_format_supported( struct pipe_screen *screen,
                           unsigned tex_usage, 
                           unsigned geom_flags )
 {
-   /* cell supports most formats, XXX for now anyway */
+   struct sw_winsys *winsys = cell_screen(screen)->winsys;
+
    if (format == PIPE_FORMAT_DXT5_RGBA ||
        format == PIPE_FORMAT_A8B8G8R8_SRGB)
       return FALSE;
-   else
-      return TRUE;
+
+   if (tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+      if (!winsys->is_displaytarget_format_supported(winsys, format))
+         return FALSE;
+   }
+
+   /* This is often a lie.  Pull in logic from llvmpipe to fix.
+    */
+   return TRUE;
 }
 
 
 static void
 cell_destroy_screen( struct pipe_screen *screen )
 {
-   struct pipe_winsys *winsys = screen->winsys;
+   struct cell_screen *sp_screen = cell_screen(screen);
+   struct sw_winsys *winsys = sp_screen->winsys;
 
    if(winsys->destroy)
       winsys->destroy(winsys);
@@ -155,32 +166,34 @@ cell_destroy_screen( struct pipe_screen *screen )
 }
 
 
+
 /**
  * Create a new pipe_screen object
  * Note: we're not presently subclassing pipe_screen (no cell_screen) but
  * that would be the place to put SPU thread/context info...
  */
 struct pipe_screen *
-cell_create_screen(struct pipe_winsys *winsys)
+cell_create_screen(struct sw_winsys *winsys)
 {
-   struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
+   struct cell_screen *screen = CALLOC_STRUCT(cell_screen);
 
    if (!screen)
       return NULL;
 
    screen->winsys = winsys;
+   screen->base.winsys = NULL;
 
-   screen->destroy = cell_destroy_screen;
+   screen->base.destroy = cell_destroy_screen;
 
-   screen->get_name = cell_get_name;
-   screen->get_vendor = cell_get_vendor;
-   screen->get_param = cell_get_param;
-   screen->get_paramf = cell_get_paramf;
-   screen->is_format_supported = cell_is_format_supported;
-   screen->context_create = cell_create_context;
+   screen->base.get_name = cell_get_name;
+   screen->base.get_vendor = cell_get_vendor;
+   screen->base.get_param = cell_get_param;
+   screen->base.get_paramf = cell_get_paramf;
+   screen->base.is_format_supported = cell_is_format_supported;
+   screen->base.context_create = cell_create_context;
 
-   cell_init_screen_texture_funcs(screen);
-   u_simple_screen_init(screen);
+   cell_init_screen_texture_funcs(&screen->base);
+   cell_init_screen_buffer_funcs(&screen->base);
 
-   return screen;
+   return &screen->base;
 }
index c7e15889d66bd56f0837b4e482395f3a109dbf92..baff9d3b7d41a30918f1f7489651be0f11049232 100644 (file)
 #define CELL_SCREEN_H
 
 
-struct pipe_screen;
-struct pipe_winsys;
+#include "pipe/p_screen.h"
 
+struct sw_winsys;
 
-extern struct pipe_screen *
-cell_create_screen(struct pipe_winsys *winsys);
+struct cell_screen {
+   struct pipe_screen base;
+
+   struct sw_winsys *winsys;
+
+   /* Increments whenever textures are modified.  Contexts can track
+    * this.
+    */
+   unsigned timestamp;          
+};
+
+static INLINE struct cell_screen *
+cell_screen( struct pipe_screen *pipe )
+{
+   return (struct cell_screen *)pipe;
+}
 
 
 #endif /* CELL_SCREEN_H */
index a59c7828ac307c426e08f2d634a756653f8324cf..424e2628a9563483695c3d5690d7aadc5272218d 100644 (file)
@@ -245,16 +245,13 @@ cell_emit_state(struct cell_context *cell)
       uint i, j;
       float *buf = cell_batch_alloc16(cell, ROUNDUP16(32 + num_const * sizeof(float)));
       uint32_t *ibuf = (uint32_t *) buf;
-      const float *constants = pipe_buffer_map(cell->pipe.screen,
-                                               cell->constants[shader],
-                                               PIPE_BUFFER_USAGE_CPU_READ);
+      const float *constants = cell->mapped_constants[shader];
       ibuf[0] = CELL_CMD_STATE_FS_CONSTANTS;
       ibuf[4] = num_const;
       j = 8;
       for (i = 0; i < num_const; i++) {
          buf[j++] = constants[i];
       }
-      pipe_buffer_unmap(cell->pipe.screen, cell->constants[shader]);
    }
 
    if (cell->dirty & (CELL_NEW_FRAMEBUFFER |
index 9b2f86fdfbafd250c999fc1ffd1f19cca4c7da67..9e29ddc2d4598e5be868499a83ed473b7221fe93 100644 (file)
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
 #include "util/u_inlines.h"
-#include "util/u_simple_screen.h"
 #include "draw/draw_context.h"
 #include "tgsi/tgsi_parse.h"
 
 #include "cell_context.h"
 #include "cell_state.h"
 #include "cell_gen_fp.h"
+#include "cell_buffer.h"
 
 
 /** cast wrapper */
@@ -183,17 +183,29 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
 static void
 cell_set_constant_buffer(struct pipe_context *pipe,
                          uint shader, uint index,
-                         struct pipe_buffer *buf)
+                         struct pipe_buffer *constants)
 {
    struct cell_context *cell = cell_context(pipe);
+   unsigned size = constants ? constants->size : 0;
+   const void *data = constants ? cell_buffer(constants)->data : NULL;
 
    assert(shader < PIPE_SHADER_TYPES);
    assert(index == 0);
 
+   if (cell->constants[shader] == constants)
+      return;
+
    draw_flush(cell->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&cell->constants[shader], buf);
+   pipe_buffer_reference(&cell->constants[shader], constants);
+
+   if(shader == PIPE_SHADER_VERTEX) {
+      draw_set_mapped_constant_buffer(cell->draw, PIPE_SHADER_VERTEX, 0,
+                                      data, size);
+   }
+
+   cell->mapped_constants[shader] = data;
 
    if (shader == PIPE_SHADER_VERTEX)
       cell->dirty |= CELL_NEW_VS_CONSTANTS;
index fad290dfa0ee956fb7db4ee67fac67d2771b60b9..c8a1acd86a913d2c0501c3b6cb66005f2c0e2ac6 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
 #include "util/u_inlines.h"
-#include "util/u_simple_screen.h"
 
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
 
 #include "cell_context.h"
+#include "cell_screen.h"
 #include "cell_state.h"
 #include "cell_texture.h"
 
+#include "state_tracker/sw_winsys.h"
 
 
-static void
-cell_texture_layout(struct cell_texture *ct)
+
+static boolean
+cell_texture_layout(struct pipe_screen *screen, 
+                    struct cell_texture *ct)
 {
    struct pipe_texture *pt = &ct->base;
    unsigned level;
@@ -83,9 +86,34 @@ cell_texture_layout(struct cell_texture *ct)
       height = u_minify(height, 1);
       depth = u_minify(depth, 1);
    }
+
+   ct->data = align_malloc(ct->buffer_size, 16);
+   return ct->data != NULL;
 }
 
 
+/**
+ * Texture layout for simple color buffers.
+ */
+static boolean
+cell_displaytarget_layout(struct pipe_screen *screen,
+                          struct cell_texture * ct)
+{
+   struct sw_winsys *winsys = cell_screen(screen)->winsys;
+
+   /* Round up the surface size to a multiple of the tile size?
+    */
+   ct->dt = winsys->displaytarget_create(winsys,
+                                          ct->base.format,
+                                          ct->base.width0, 
+                                          ct->base.height0,
+                                          16,
+                                          &ct->dt_stride );
+
+   return ct->dt != NULL;
+}
+
 static struct pipe_texture *
 cell_texture_create(struct pipe_screen *screen,
                     const struct pipe_texture *templat)
@@ -98,31 +126,46 @@ cell_texture_create(struct pipe_screen *screen,
    pipe_reference_init(&ct->base.reference, 1);
    ct->base.screen = screen;
 
-   cell_texture_layout(ct);
+   /* Create both a displaytarget (linear) and regular texture
+    * (twiddled).  Convert twiddled->linear at flush_frontbuffer time.
+    */
+   if (ct->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
+                             PIPE_TEXTURE_USAGE_SCANOUT |
+                             PIPE_TEXTURE_USAGE_SHARED)) {
+      if (!cell_displaytarget_layout(screen, ct))
+         goto fail;
+   }
 
-   ct->buffer = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_PIXEL,
-                                   ct->buffer_size);
+   if (!cell_texture_layout(screen, ct))
+      goto fail;
 
-   if (!ct->buffer) {
-      FREE(ct);
-      return NULL;
+   return &ct->base;
+
+fail:
+   if (ct->dt) {
+      struct sw_winsys *winsys = cell_screen(screen)->winsys;
+      winsys->displaytarget_destroy(winsys, ct->dt);
    }
 
-   return &ct->base;
+   FREE(ct);
+
+   return NULL;
 }
 
 
 static void
 cell_texture_destroy(struct pipe_texture *pt)
 {
+   struct cell_screen *screen = cell_screen(pt->screen);
+   struct sw_winsys *winsys = screen->winsys;
    struct cell_texture *ct = cell_texture(pt);
 
-   if (ct->mapped) {
-      pipe_buffer_unmap(ct->buffer->screen, ct->buffer);
-      ct->mapped = NULL;
+   if (ct->dt) {
+      /* display target */
+      winsys->displaytarget_destroy(winsys, ct->dt);
    }
 
-   pipe_buffer_reference(&ct->buffer, NULL);
+   align_free(ct->data);
 
    FREE(ct);
 }
@@ -389,10 +432,8 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer)
 
    assert(transfer->texture);
 
-   if (!ct->mapped) {
-      /* map now */
-      ct->mapped = pipe_buffer_map(screen, ct->buffer,
-                                   pipe_transfer_buffer_flags(transfer));
+   if (ct->mapped == NULL) {
+      ct->mapped = ct->data;
    }
 
    /*
@@ -442,9 +483,8 @@ cell_transfer_unmap(struct pipe_screen *screen,
    const uint stride = ct->stride[level];
 
    if (!ct->mapped) {
-      /* map now */
-      ct->mapped = pipe_buffer_map(screen, ct->buffer,
-                                   PIPE_BUFFER_USAGE_CPU_READ);
+      assert(0);
+      return;
    }
 
    if (transfer->usage & PIPE_TRANSFER_WRITE) {
@@ -467,6 +507,50 @@ cell_transfer_unmap(struct pipe_screen *screen,
 }
 
 
+
+/* This used to be overriden by the co-state tracker, but really needs
+ * to be active with sw_winsys.
+ *
+ * Contrasting with llvmpipe and softpipe, this is the only place
+ * where we use the ct->dt display target in any real sense.
+ *
+ * Basically just untwiddle our local data into the linear
+ * displaytarget.
+ */
+static void
+cell_flush_frontbuffer(struct pipe_screen *_screen,
+                       struct pipe_surface *surface,
+                       void *context_private)
+{
+   struct cell_screen *screen = cell_screen(_screen);
+   struct sw_winsys *winsys = screen->winsys;
+   struct cell_texture *ct = cell_texture(surface->texture);
+
+   if (!ct->dt)
+      return;
+
+   /* Need to untwiddle from our internal representation here:
+    */
+   {
+      unsigned *map = winsys->displaytarget_map(winsys, ct->dt,
+                                                (PIPE_BUFFER_USAGE_CPU_READ |
+                                                 PIPE_BUFFER_USAGE_CPU_WRITE));
+      unsigned *src = (unsigned *)(ct->data + ct->level_offset[surface->level]);
+
+      untwiddle_image_uint(surface->width,
+                           surface->height,
+                           TILE_SIZE,
+                           map,
+                           ct->dt_stride,
+                           src);
+
+      winsys->displaytarget_unmap(winsys, ct->dt);
+   }
+
+   winsys->displaytarget_display(winsys, ct->dt, context_private);
+}
+
+
 void
 cell_init_screen_texture_funcs(struct pipe_screen *screen)
 {
@@ -481,4 +565,6 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen)
 
    screen->transfer_map = cell_transfer_map;
    screen->transfer_unmap = cell_transfer_unmap;
+
+   screen->flush_frontbuffer = cell_flush_frontbuffer;
 }
index 3ffc0bfdb514392f0d3bc919046887c934afaec8..2be057931220b2fb763a73636ee1fae031106012 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef CELL_TEXTURE_H
 #define CELL_TEXTURE_H
 
+#include "cell/common.h"
 
 struct cell_context;
 struct pipe_texture;
@@ -43,8 +44,20 @@ struct cell_texture
    unsigned long level_offset[CELL_MAX_TEXTURE_LEVELS];
    unsigned long stride[CELL_MAX_TEXTURE_LEVELS];
 
-   /** The tiled texture data is held in this buffer */
-   struct pipe_buffer *buffer;
+   /**
+    * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
+    * usage.
+    */
+   struct sw_displaytarget *dt;
+   unsigned dt_stride;
+
+   /**
+    * Malloc'ed data for regular textures, or a mapping to dt above.
+    */
+   void *data;
+
+   /* Size of the linear buffer??
+    */
    unsigned long buffer_size;
 
    /** The buffer above, mapped.  This is the memory from which the
index cf8cd411598f0bb9528cafa9cd76cf3b40df9e8d..3d389d6ea36c930440c5b6b923fc2e7f534fa872 100644 (file)
@@ -31,7 +31,6 @@
 
 #include "pipe/p_defines.h"
 #include "pipe/p_context.h"
-#include "util/u_simple_screen.h"
 #include "util/u_math.h"
 
 #include "cell_context.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.h b/src/gallium/drivers/cell/ppu/cell_winsys.h
deleted file mode 100644 (file)
index e227e06..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-
-#ifndef CELL_WINSYS_H
-#define CELL_WINSYS_H
-
-#include "pipe/p_compiler.h"
-
-
-/**
- * Very simple winsys at this time.
- * Will probably eventually add SPU control info.
- */
-struct cell_winsys
-{
-   uint dummy;
-};
-
-
-
-
-#endif
index 2ccc5d3e6052bb06b9598420d40ba16278464eda..659e40cbf0318b9a66e731bdf91042376bfec442 100644 (file)
@@ -27,7 +27,6 @@
 
 
 #include "pipe/p_defines.h"
-#include "util/u_simple_screen.h"
 #include "util/u_memory.h"
 #include "pipe/p_context.h"
 
index 066e7392d187248f1ba4735ee86530a4fe56a3e2..f41c51f299122ae88d7d2aa3e4af344102dcc326 100644 (file)
@@ -28,7 +28,6 @@
 
 #include "i915_reg.h"
 #include "i915_debug.h"
-#include "util/u_simple_screen.h"
 #include "util/u_debug.h"
 
 
index 9eda97208184000002bebb0ffb6889677646ed9b..dab20cb63977bbd2ceca8cc9cefc4ef47d365ce3 100644 (file)
 #include "util/u_memory.h"
 #include "util/u_math.h"
 
-#include "lp_winsys.h"
 #include "lp_screen.h"
 #include "lp_buffer.h"
 
+#include "state_tracker/sw_winsys.h"
 
 static void *
 llvmpipe_buffer_map(struct pipe_screen *screen,
diff --git a/src/gallium/drivers/llvmpipe/lp_public.h b/src/gallium/drivers/llvmpipe/lp_public.h
new file mode 100644 (file)
index 0000000..ec6b660
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef LP_PUBLIC_H
+#define LP_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+llvmpipe_create_screen(struct sw_winsys *winsys);
+
+#endif
index 934b0d8439e282335064f6b67850ae3b31773d24..5093f58bb19736d11f829428cda482f1006d37bc 100644 (file)
 #include "lp_texture.h"
 #include "lp_buffer.h"
 #include "lp_fence.h"
-#include "lp_winsys.h"
 #include "lp_jit.h"
 #include "lp_screen.h"
 #include "lp_context.h"
 #include "lp_debug.h"
+#include "lp_public.h"
+
+#include "state_tracker/sw_winsys.h"
 
 #ifdef DEBUG
 int LP_DEBUG = 0;
@@ -167,7 +169,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
                               unsigned geom_flags )
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
-   struct llvmpipe_winsys *winsys = screen->winsys;
+   struct sw_winsys *winsys = screen->winsys;
    const struct util_format_description *format_desc;
 
    format_desc = util_format_description(format);
@@ -246,7 +248,7 @@ llvmpipe_flush_frontbuffer(struct pipe_screen *_screen,
                            void *context_private)
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
-   struct llvmpipe_winsys *winsys = screen->winsys;
+   struct sw_winsys *winsys = screen->winsys;
    struct llvmpipe_texture *texture = llvmpipe_texture(surface->texture);
 
    assert(texture->dt);
@@ -259,7 +261,7 @@ static void
 llvmpipe_destroy_screen( struct pipe_screen *_screen )
 {
    struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
-   struct llvmpipe_winsys *winsys = screen->winsys;
+   struct sw_winsys *winsys = screen->winsys;
 
    lp_jit_screen_cleanup(screen);
 
@@ -276,7 +278,7 @@ llvmpipe_destroy_screen( struct pipe_screen *_screen )
  * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen).
  */
 struct pipe_screen *
-llvmpipe_create_screen(struct llvmpipe_winsys *winsys)
+llvmpipe_create_screen(struct sw_winsys *winsys)
 {
    struct llvmpipe_screen *screen = CALLOC_STRUCT(llvmpipe_screen);
 
index 4a1b4d6f3e21ce727aec6cc35c342f635338875f..f4e62cbf08eb796a287528c7f0d5f78dcda13ade 100644 (file)
 #include "pipe/p_defines.h"
 
 
-struct llvmpipe_winsys;
+struct sw_winsys;
 
 
 struct llvmpipe_screen
 {
    struct pipe_screen base;
 
-   struct llvmpipe_winsys *winsys;
+   struct sw_winsys *winsys;
 
    LLVMModuleRef module;
    LLVMExecutionEngineRef engine;
@@ -76,4 +76,5 @@ llvmpipe_screen( struct pipe_screen *pipe )
 }
 
 
+
 #endif /* LP_SCREEN_H */
index cc7c18c8c0c039294532febdf9ec4d18b4f9ec59..fbe14924cb10628acd2ac4ff4dc7800dc505b488 100644 (file)
@@ -46,7 +46,7 @@
 #include "lp_rast.h"
 #include "lp_setup_context.h"
 #include "lp_screen.h"
-#include "lp_winsys.h"
+#include "state_tracker/sw_winsys.h"
 
 #include "draw/draw_context.h"
 #include "draw/draw_vbuf.h"
@@ -487,9 +487,9 @@ lp_setup_set_sampler_textures( struct setup_context *setup,
              */
 
             struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen);
-            struct llvmpipe_winsys *winsys = screen->winsys;
+            struct sw_winsys *winsys = screen->winsys;
             jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt,
-                                                 PIPE_BUFFER_USAGE_CPU_READ);
+                                                      PIPE_BUFFER_USAGE_CPU_READ);
             assert(jit_tex->data[0]);
          }
 
index e41d6238ed2b36ac80b50849652d5f500c25cd47..74b7b4ec5e1c1fc563e91be1f77564a508222701 100644 (file)
@@ -42,7 +42,7 @@
 #include "lp_screen.h"
 #include "lp_texture.h"
 #include "lp_tile_size.h"
-#include "lp_winsys.h"
+#include "state_tracker/sw_winsys.h"
 
 
 /**
@@ -93,7 +93,7 @@ static boolean
 llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
                               struct llvmpipe_texture *lpt)
 {
-   struct llvmpipe_winsys *winsys = screen->winsys;
+   struct sw_winsys *winsys = screen->winsys;
 
    /* Round up the surface size to a multiple of the tile size to
     * avoid tile clipping.
@@ -151,7 +151,7 @@ llvmpipe_texture_destroy(struct pipe_texture *pt)
 
    if (lpt->dt) {
       /* display target */
-      struct llvmpipe_winsys *winsys = screen->winsys;
+      struct sw_winsys *winsys = screen->winsys;
       winsys->displaytarget_destroy(winsys, lpt->dt);
    }
    else {
@@ -321,7 +321,7 @@ llvmpipe_transfer_map( struct pipe_screen *_screen,
 
    if (lpt->dt) {
       /* display target */
-      struct llvmpipe_winsys *winsys = screen->winsys;
+      struct sw_winsys *winsys = screen->winsys;
 
       map = winsys->displaytarget_map(winsys, lpt->dt,
                                       pipe_transfer_buffer_flags(transfer));
@@ -362,7 +362,7 @@ llvmpipe_transfer_unmap(struct pipe_screen *screen,
 
    if (lpt->dt) {
       /* display target */
-      struct llvmpipe_winsys *winsys = lp_screen->winsys;
+      struct sw_winsys *winsys = lp_screen->winsys;
       winsys->displaytarget_unmap(winsys, lpt->dt);
    }
 }
index c511a01298731bac3b87b6ca3bf3703f007e43fa..b23f929b1670a7bc95a8dc8f92cb23975f92b81c 100644 (file)
@@ -39,7 +39,8 @@
 struct pipe_context;
 struct pipe_screen;
 struct llvmpipe_context;
-struct llvmpipe_displaytarget;
+
+struct sw_displaytarget;
 
 
 struct llvmpipe_texture
@@ -53,7 +54,7 @@ struct llvmpipe_texture
     * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
     * usage.
     */
-   struct llvmpipe_displaytarget *dt;
+   struct sw_displaytarget *dt;
 
    /**
     * Malloc'ed data for regular textures, or a mapping to dt above.
diff --git a/src/gallium/drivers/llvmpipe/lp_winsys.h b/src/gallium/drivers/llvmpipe/lp_winsys.h
deleted file mode 100644 (file)
index ce11fa9..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007-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.
- * 
- **************************************************************************/
-
-/**
- * @file
- * llvmpipe public interface.
- */
-
-
-#ifndef LP_WINSYS_H
-#define LP_WINSYS_H
-
-
-#include "pipe/p_compiler.h" /* for boolean */
-#include "pipe/p_format.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-struct pipe_screen;
-struct pipe_context;
-
-
-/**
- * Opaque pointer.
- */
-struct llvmpipe_displaytarget;
-
-
-/**
- * This is the interface that llvmpipe expects any window system
- * hosting it to implement.
- * 
- * llvmpipe is for the most part a self sufficient driver. The only thing it
- * does not know is how to display a surface.
- */
-struct llvmpipe_winsys
-{
-   void 
-   (*destroy)( struct llvmpipe_winsys *ws );
-
-   boolean
-   (*is_displaytarget_format_supported)( struct llvmpipe_winsys *ws,
-                                         enum pipe_format format );
-   
-   /**
-    * Allocate storage for a render target.
-    * 
-    * Often surfaces which are meant to be blitted to the front screen (i.e.,
-    * display targets) must be allocated with special characteristics, memory 
-    * pools, or obtained directly from the windowing system.
-    *  
-    * This callback is invoked by the pipe_screen when creating a texture marked
-    * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying 
-    * storage.
-    */
-   struct llvmpipe_displaytarget *
-   (*displaytarget_create)( struct llvmpipe_winsys *ws,
-                            enum pipe_format format,
-                            unsigned width, unsigned height,
-                            unsigned alignment,
-                            unsigned *stride );
-
-   void *
-   (*displaytarget_map)( struct llvmpipe_winsys *ws, 
-                         struct llvmpipe_displaytarget *dt,
-                         unsigned flags );
-
-   void
-   (*displaytarget_unmap)( struct llvmpipe_winsys *ws,
-                           struct llvmpipe_displaytarget *dt );
-
-   /**
-    * @sa pipe_screen:flush_frontbuffer.
-    *
-    * This call will likely become asynchronous eventually.
-    */
-   void
-   (*displaytarget_display)( struct llvmpipe_winsys *ws, 
-                             struct llvmpipe_displaytarget *dt,
-                             void *context_private );
-
-   void 
-   (*displaytarget_destroy)( struct llvmpipe_winsys *ws, 
-                             struct llvmpipe_displaytarget *dt );
-};
-
-
-
-struct pipe_screen *
-llvmpipe_create_screen( struct llvmpipe_winsys * );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LP_WINSYS_H */
index e4ac49fa85f40a49f6f095ec13e4c68f3bd0d66b..1c6e4ae0768e235ec5b48617aa767649774f447f 100644 (file)
@@ -6,6 +6,7 @@ LIBNAME = softpipe
 C_SOURCES = \
        sp_fs_exec.c \
        sp_fs_sse.c \
+       sp_buffer.c \
        sp_clear.c \
        sp_flush.c \
        sp_query.c \
@@ -32,7 +33,6 @@ C_SOURCES = \
        sp_tex_tile_cache.c \
        sp_tile_cache.c \
        sp_surface.c \
-       sp_video_context.c \
-       sp_winsys.c
+       sp_video_context.c
 
 include ../../Makefile.template
index 3042e556c6417f7b07d5dc055f535afa9e0d0a70..27ab00b036e539eb1e969ec6d6d221214ccf10e1 100644 (file)
@@ -7,6 +7,7 @@ softpipe = env.ConvenienceLibrary(
        source = [
                'sp_fs_exec.c',
                'sp_fs_sse.c',
+               'sp_buffer.c',
                'sp_clear.c',
                'sp_context.c',
                'sp_draw_arrays.c',
@@ -33,8 +34,7 @@ softpipe = env.ConvenienceLibrary(
                'sp_tex_tile_cache.c',
                'sp_texture.c',
                'sp_tile_cache.c',
-               'sp_video_context.c',
-               'sp_winsys.c'
+               'sp_video_context.c'
        ])
 
 Export('softpipe')
diff --git a/src/gallium/drivers/softpipe/sp_buffer.c b/src/gallium/drivers/softpipe/sp_buffer.c
new file mode 100644 (file)
index 0000000..8f39025
--- /dev/null
@@ -0,0 +1,118 @@
+/**************************************************************************
+ *
+ * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "sp_screen.h"
+#include "sp_buffer.h"
+
+
+static void *
+softpipe_buffer_map(struct pipe_screen *screen,
+                    struct pipe_buffer *buf,
+                    unsigned flags)
+{
+   struct softpipe_buffer *softpipe_buf = softpipe_buffer(buf);
+   return softpipe_buf->data;
+}
+
+
+static void
+softpipe_buffer_unmap(struct pipe_screen *screen,
+                      struct pipe_buffer *buf)
+{
+}
+
+
+static void
+softpipe_buffer_destroy(struct pipe_buffer *buf)
+{
+   struct softpipe_buffer *sbuf = softpipe_buffer(buf);
+
+   if (!sbuf->userBuffer)
+      align_free(sbuf->data);
+      
+   FREE(sbuf);
+}
+
+
+static struct pipe_buffer *
+softpipe_buffer_create(struct pipe_screen *screen,
+                       unsigned alignment,
+                       unsigned usage,
+                       unsigned size)
+{
+   struct softpipe_buffer *buffer = CALLOC_STRUCT(softpipe_buffer);
+
+   pipe_reference_init(&buffer->base.reference, 1);
+   buffer->base.screen = screen;
+   buffer->base.alignment = MAX2(alignment, 16);
+   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 *
+softpipe_user_buffer_create(struct pipe_screen *screen,
+                            void *ptr,
+                            unsigned bytes)
+{
+   struct softpipe_buffer *buffer;
+
+   buffer = CALLOC_STRUCT(softpipe_buffer);
+   if(!buffer)
+      return NULL;
+
+   pipe_reference_init(&buffer->base.reference, 1);
+   buffer->base.screen = screen;
+   buffer->base.size = bytes;
+   buffer->userBuffer = TRUE;
+   buffer->data = ptr;
+
+   return &buffer->base;
+}
+
+
+void
+softpipe_init_screen_buffer_funcs(struct pipe_screen *screen)
+{
+   screen->buffer_create = softpipe_buffer_create;
+   screen->user_buffer_create = softpipe_user_buffer_create;
+   screen->buffer_map = softpipe_buffer_map;
+   screen->buffer_unmap = softpipe_buffer_unmap;
+   screen->buffer_destroy = softpipe_buffer_destroy;
+}
diff --git a/src/gallium/drivers/softpipe/sp_buffer.h b/src/gallium/drivers/softpipe/sp_buffer.h
new file mode 100644 (file)
index 0000000..9d8e56a
--- /dev/null
@@ -0,0 +1,55 @@
+/**************************************************************************
+ *
+ * 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 VMWARE 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 SP_BUFFER_H
+#define SP_BUFFER_H
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+struct softpipe_buffer
+{
+   struct pipe_buffer base;
+   boolean userBuffer;  /** Is this a user-space buffer? */
+   void *data;
+};
+
+
+/** Cast wrapper */
+static INLINE struct softpipe_buffer *
+softpipe_buffer( struct pipe_buffer *buf )
+{
+   return (struct softpipe_buffer *)buf;
+}
+
+
+void
+softpipe_init_screen_buffer_funcs(struct pipe_screen *screen);
+
+
+#endif /* SP_BUFFER_H */
index e8f2318e488ee585da3c0f2e861db4db57ca7d91..30494719f7b9fa817e1dd3d241874eed834b4c4c 100644 (file)
@@ -210,7 +210,7 @@ softpipe_create_context( struct pipe_screen *screen,
    softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE );
    softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE );
 
-   softpipe->pipe.winsys = screen->winsys;
+   softpipe->pipe.winsys = NULL;
    softpipe->pipe.screen = screen;
    softpipe->pipe.destroy = softpipe_destroy;
    softpipe->pipe.priv = priv;
index 396d46d4ba64b15aaecd4cacc38c5e817b98824b..9a8158e6a22978f47bdcbe213cbc8ee25f7efd4c 100644 (file)
@@ -93,7 +93,7 @@ struct softpipe_context {
    ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS];
 
    /** Mapped constant buffers */
-   void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
+   const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
 
    /** Vertex format */
    struct vertex_info vertex_info;
index b2acc36bf7af2672c58f2b699071872cd960e3de..7b77eb239fd54adaf32ce72fd1698ee977d5b917 100644 (file)
 
 #include "pipe/p_defines.h"
 #include "pipe/p_context.h"
-#include "util/u_simple_screen.h"
 #include "util/u_inlines.h"
 #include "util/u_prim.h"
 
 #include "sp_context.h"
 #include "sp_query.h"
 #include "sp_state.h"
+#include "sp_buffer.h"
 
 #include "draw/draw_context.h"
 
 
 
-static void
-softpipe_map_constant_buffers(struct softpipe_context *sp)
-{
-   struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i;
-
-   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
-      uint j;
-
-      for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) {
-         if (sp->constants[i][j] && sp->constants[i][j]->size) {
-            sp->mapped_constants[i][j] = ws->buffer_map(ws,
-                                                        sp->constants[i][j],
-                                                        PIPE_BUFFER_USAGE_CPU_READ);
-         }
-      }
-   }
-
-   for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
-      if (sp->constants[PIPE_SHADER_VERTEX][i]) {
-         draw_set_mapped_constant_buffer(sp->draw,
-                                         PIPE_SHADER_VERTEX,
-                                         i,
-                                         sp->mapped_constants[PIPE_SHADER_VERTEX][i],
-                                         sp->constants[PIPE_SHADER_VERTEX][i]->size);
-      }
-      if (sp->constants[PIPE_SHADER_GEOMETRY][i]) {
-         draw_set_mapped_constant_buffer(sp->draw,
-                                         PIPE_SHADER_GEOMETRY,
-                                         i,
-                                         sp->mapped_constants[PIPE_SHADER_GEOMETRY][i],
-                                         sp->constants[PIPE_SHADER_GEOMETRY][i]->size);
-      }
-   }
-}
-
-
-static void
-softpipe_unmap_constant_buffers(struct softpipe_context *sp)
-{
-   struct pipe_winsys *ws = sp->pipe.winsys;
-   uint i;
 
-   /* really need to flush all prims since the vert/frag shaders const buffers
-    * are going away now.
-    */
-   draw_flush(sp->draw);
-
-   for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
-      draw_set_mapped_constant_buffer(sp->draw,
-                                      PIPE_SHADER_VERTEX,
-                                      i,
-                                      NULL,
-                                      0);
-      draw_set_mapped_constant_buffer(sp->draw,
-                                      PIPE_SHADER_GEOMETRY,
-                                      i,
-                                      NULL,
-                                      0);
-   }
-
-   for (i = 0; i < PIPE_SHADER_TYPES; i++) {
-      uint j;
-
-      for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) {
-         if (sp->constants[i][j] && sp->constants[i][j]->size) {
-            ws->buffer_unmap(ws, sp->constants[i][j]);
-         }
-         sp->mapped_constants[i][j] = NULL;
-      }
-   }
-}
 
 
 /**
@@ -261,25 +190,16 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
    }
 
    softpipe_map_transfers(sp);
-   softpipe_map_constant_buffers(sp);
 
    /* Map vertex buffers */
    for (i = 0; i < sp->num_vertex_buffers; i++) {
-      void *buf;
-
-      buf = pipe_buffer_map(pipe->screen,
-                            sp->vertex_buffer[i].buffer,
-                            PIPE_BUFFER_USAGE_CPU_READ);
+      void *buf = softpipe_buffer(sp->vertex_buffer[i].buffer)->data;
       draw_set_mapped_vertex_buffer(draw, i, buf);
    }
 
    /* Map index buffer, if present */
    if (indexBuffer) {
-      void *mapped_indexes;
-
-      mapped_indexes = pipe_buffer_map(pipe->screen,
-                                       indexBuffer,
-                                       PIPE_BUFFER_USAGE_CPU_READ);
+      void *mapped_indexes = softpipe_buffer(indexBuffer)->data;
       draw_set_mapped_element_buffer_range(draw,
                                            indexSize,
                                            minIndex,
@@ -300,15 +220,18 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
    /* unmap vertex/index buffers - will cause draw module to flush */
    for (i = 0; i < sp->num_vertex_buffers; i++) {
       draw_set_mapped_vertex_buffer(draw, i, NULL);
-      pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
    }
    if (indexBuffer) {
       draw_set_mapped_element_buffer(draw, 0, NULL);
-      pipe_buffer_unmap(pipe->screen, indexBuffer);
    }
 
-   /* Note: leave drawing surfaces mapped */
-   softpipe_unmap_constant_buffers(sp);
+   /*
+    * TODO: Flush only when a user vertex/index buffer is present
+    * (or even better, modify draw module to do this
+    * internally when this condition is seen?)
+    */
+   draw_flush(draw);
 
+   /* Note: leave drawing surfaces mapped */
    sp->dirty_render_cache = TRUE;
 }
diff --git a/src/gallium/drivers/softpipe/sp_public.h b/src/gallium/drivers/softpipe/sp_public.h
new file mode 100644 (file)
index 0000000..62d0903
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef SP_PUBLIC_H
+#define SP_PUBLIC_H
+
+struct pipe_screen;
+struct sw_winsys;
+
+struct pipe_screen *
+softpipe_create_screen(struct sw_winsys *winsys);
+
+#endif
index 3405a043c6bf02e2924d5f063eb224b00009a45c..e0a2ef604e94711a1f6de7cbcd7667a5ea5d723f 100644 (file)
 
 
 #include "util/u_memory.h"
-#include "util/u_simple_screen.h"
-#include "util/u_simple_screen.h"
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 
+#include "state_tracker/sw_winsys.h"
+
 #include "sp_texture.h"
-#include "sp_winsys.h"
 #include "sp_screen.h"
 #include "sp_context.h"
+#include "sp_buffer.h"
+#include "sp_public.h"
 
 
 static const char *
@@ -145,6 +146,8 @@ softpipe_is_format_supported( struct pipe_screen *screen,
                               unsigned tex_usage, 
                               unsigned geom_flags )
 {
+   struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+
    assert(target == PIPE_TEXTURE_1D ||
           target == PIPE_TEXTURE_2D ||
           target == PIPE_TEXTURE_3D ||
@@ -166,15 +169,25 @@ softpipe_is_format_supported( struct pipe_screen *screen,
    case PIPE_FORMAT_NONE:
       return FALSE;
    default:
-      return TRUE;
+      break;
    }
+
+   if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+      if(!winsys->is_displaytarget_format_supported(winsys, format))
+         return FALSE;
+   }
+
+   /* XXX: this is often a lie.  Pull in logic from llvmpipe to fix.
+    */
+   return TRUE;
 }
 
 
 static void
 softpipe_destroy_screen( struct pipe_screen *screen )
 {
-   struct pipe_winsys *winsys = screen->winsys;
+   struct softpipe_screen *sp_screen = softpipe_screen(screen);
+   struct sw_winsys *winsys = sp_screen->winsys;
 
    if(winsys->destroy)
       winsys->destroy(winsys);
@@ -183,21 +196,37 @@ softpipe_destroy_screen( struct pipe_screen *screen )
 }
 
 
+/* This is often overriden by the co-state tracker.
+ */
+static void
+softpipe_flush_frontbuffer(struct pipe_screen *_screen,
+                           struct pipe_surface *surface,
+                           void *context_private)
+{
+   struct softpipe_screen *screen = softpipe_screen(_screen);
+   struct sw_winsys *winsys = screen->winsys;
+   struct softpipe_texture *texture = softpipe_texture(surface->texture);
+
+   assert(texture->dt);
+   if (texture->dt)
+      winsys->displaytarget_display(winsys, texture->dt, context_private);
+}
 
 /**
  * Create a new pipe_screen object
  * Note: we're not presently subclassing pipe_screen (no softpipe_screen).
  */
 struct pipe_screen *
-softpipe_create_screen(struct pipe_winsys *winsys)
+softpipe_create_screen(struct sw_winsys *winsys)
 {
    struct softpipe_screen *screen = CALLOC_STRUCT(softpipe_screen);
 
    if (!screen)
       return NULL;
 
-   screen->base.winsys = winsys;
+   screen->winsys = winsys;
 
+   screen->base.winsys = NULL;
    screen->base.destroy = softpipe_destroy_screen;
 
    screen->base.get_name = softpipe_get_name;
@@ -206,9 +235,10 @@ softpipe_create_screen(struct pipe_winsys *winsys)
    screen->base.get_paramf = softpipe_get_paramf;
    screen->base.is_format_supported = softpipe_is_format_supported;
    screen->base.context_create = softpipe_create_context;
+   screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
 
    softpipe_init_screen_texture_funcs(&screen->base);
-   u_simple_screen_init(&screen->base);
+   softpipe_init_screen_buffer_funcs(&screen->base);
 
    return &screen->base;
 }
index 3d4bfd3e840b9c2909bfa01ca4c3ecde5f318bde..f741454c9e5f472578baa43a25db8aa93fa3d4a3 100644 (file)
 #include "pipe/p_defines.h"
 
 
+struct sw_winsys;
 
 struct softpipe_screen {
    struct pipe_screen base;
 
+   struct sw_winsys *winsys;
+
    /* Increments whenever textures are modified.  Contexts can track
     * this.
     */
@@ -55,4 +58,5 @@ softpipe_screen( struct pipe_screen *pipe )
 }
 
 
+
 #endif /* SP_SCREEN_H */
index c88e213751092320e127ff2c9523ddf8b29d9026..2b089c2831642108d13fd71528d4c5abaa12703b 100644 (file)
@@ -28,6 +28,7 @@
 #include "sp_context.h"
 #include "sp_state.h"
 #include "sp_fs.h"
+#include "sp_buffer.h"
 
 #include "pipe/p_defines.h"
 #include "util/u_memory.h"
@@ -163,26 +164,33 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
    FREE( state );
 }
 
-
-
 void
 softpipe_set_constant_buffer(struct pipe_context *pipe,
                              uint shader, uint index,
-                             struct pipe_buffer *buf)
+                             struct pipe_buffer *constants)
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
+   unsigned size = constants ? constants->size : 0;
+   const void *data = constants ? softpipe_buffer(constants)->data : NULL;
 
    assert(shader < PIPE_SHADER_TYPES);
-   assert(index < PIPE_MAX_CONSTANT_BUFFERS);
+   assert(index == 0);
 
    draw_flush(softpipe->draw);
 
    /* note: reference counting */
-   pipe_buffer_reference(&softpipe->constants[shader][index], buf);
+   pipe_buffer_reference(&softpipe->constants[shader][index], constants);
 
+   if(shader == PIPE_SHADER_VERTEX) {
+      draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index,
+                                      data, size);
+   }
+
+   softpipe->mapped_constants[shader][index] = data;
    softpipe->dirty |= SP_NEW_CONSTANTS;
 }
 
+
 void *
 softpipe_create_gs_state(struct pipe_context *pipe,
                          const struct pipe_shader_state *templ)
index c0052359fdca0c08799df69905aae0786b496632..11d184effb92d6bff08bffb1328dd21bd28f3a0e 100644 (file)
@@ -41,7 +41,8 @@
 #include "sp_context.h"
 #include "sp_texture.h"
 #include "sp_screen.h"
-#include "sp_winsys.h"
+
+#include "state_tracker/sw_winsys.h"
 
 
 /**
@@ -73,11 +74,9 @@ softpipe_texture_layout(struct pipe_screen *screen,
       depth = u_minify(depth, 1);
    }
 
-   spt->buffer = screen->buffer_create(screen, 32,
-                                       PIPE_BUFFER_USAGE_PIXEL,
-                                       buffer_size);
+   spt->data = align_malloc(buffer_size, 16);
 
-   return spt->buffer != NULL;
+   return spt->data != NULL;
 }
 
 
@@ -88,19 +87,18 @@ static boolean
 softpipe_displaytarget_layout(struct pipe_screen *screen,
                               struct softpipe_texture * spt)
 {
-   unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE |
-                     PIPE_BUFFER_USAGE_GPU_READ_WRITE);
-   unsigned tex_usage = spt->base.tex_usage;
-
-   spt->buffer = screen->winsys->surface_buffer_create( screen->winsys, 
-                                                        spt->base.width0, 
-                                                        spt->base.height0,
-                                                        spt->base.format,
-                                                        usage,
-                                                        tex_usage,
-                                                        &spt->stride[0]);
-
-   return spt->buffer != NULL;
+   struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+
+   /* Round up the surface size to a multiple of the tile size?
+    */
+   spt->dt = winsys->displaytarget_create(winsys,
+                                          spt->base.format,
+                                          spt->base.width0, 
+                                          spt->base.height0,
+                                          16,
+                                          &spt->stride[0] );
+
+   return spt->dt != NULL;
 }
 
 
@@ -147,9 +145,19 @@ softpipe_texture_create(struct pipe_screen *screen,
 static void
 softpipe_texture_destroy(struct pipe_texture *pt)
 {
+   struct softpipe_screen *screen = softpipe_screen(pt->screen);
    struct softpipe_texture *spt = softpipe_texture(pt);
 
-   pipe_buffer_reference(&spt->buffer, NULL);
+   if (spt->dt) {
+      /* display target */
+      struct sw_winsys *winsys = screen->winsys;
+      winsys->displaytarget_destroy(winsys, spt->dt);
+   }
+   else {
+      /* regular texture */
+      align_free(spt->data);
+   }
+
    FREE(spt);
 }
 
@@ -329,9 +337,20 @@ softpipe_transfer_map( struct pipe_screen *screen,
    spt = softpipe_texture(transfer->texture);
    format = transfer->texture->format;
 
-   map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer));
-   if (map == NULL)
-      return NULL;
+   if (spt->dt) {
+      /* display target */
+      struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+
+      map = winsys->displaytarget_map(winsys, spt->dt,
+                                      pipe_transfer_buffer_flags(transfer));
+      if (map == NULL)
+         return NULL;
+   }
+   else {
+      map = spt->data;
+      if (map == NULL)
+         return NULL;
+   }
 
    /* May want to different things here depending on read/write nature
     * of the map:
@@ -363,7 +382,11 @@ softpipe_transfer_unmap(struct pipe_screen *screen,
    assert(transfer->texture);
    spt = softpipe_texture(transfer->texture);
 
-   pipe_buffer_unmap( screen, spt->buffer );
+   if (spt->dt) {
+      /* display target */
+      struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
+      winsys->displaytarget_unmap(winsys, spt->dt);
+   }
 
    if (transfer->usage & PIPE_TRANSFER_WRITE) {
       /* Mark the texture as dirty to expire the tile caches. */
index b54cf33ef5cc06c6ab5a6401c70446213caca351..1c8636d1d56b9695038117a455b9c01611cc937f 100644 (file)
@@ -49,9 +49,16 @@ struct softpipe_texture
    unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS];
    unsigned stride[SP_MAX_TEXTURE_2D_LEVELS];
 
-   /* The data is held here:
+   /**
+    * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
+    * usage.
+    */
+   struct sw_displaytarget *dt;
+
+   /**
+    * Malloc'ed data for regular textures, or a mapping to dt above.
     */
-   struct pipe_buffer *buffer;
+   void *data;
 
    /* True if texture images are power-of-two in all dimensions:
     */
diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c
deleted file mode 100644 (file)
index 0a6245e..0000000
+++ /dev/null
@@ -1,245 +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.
- * 
- * 
- **************************************************************************/
-
-/**
- * @file
- * Malloc softpipe winsys. Uses malloc for all memory allocations.
- * 
- * @author Keith Whitwell
- * @author Brian Paul
- * @author Jose Fonseca
- */
-
-
-#include "util/u_simple_screen.h"/* port to just p_screen */
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-#include "pipe/p_format.h"
-#include "pipe/p_context.h"
-#include "sp_winsys.h"
-
-
-struct st_softpipe_buffer
-{
-   struct pipe_buffer base;
-   boolean userBuffer;  /** Is this a user-space buffer? */
-   void *data;
-   void *mapped;
-};
-
-
-/** Cast wrapper */
-static INLINE struct st_softpipe_buffer *
-st_softpipe_buffer( struct pipe_buffer *buf )
-{
-   return (struct st_softpipe_buffer *)buf;
-}
-
-
-static void *
-st_softpipe_buffer_map(struct pipe_winsys *winsys, 
-                       struct pipe_buffer *buf,
-                       unsigned flags)
-{
-   struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf);
-   st_softpipe_buf->mapped = st_softpipe_buf->data;
-   return st_softpipe_buf->mapped;
-}
-
-
-static void
-st_softpipe_buffer_unmap(struct pipe_winsys *winsys, 
-                         struct pipe_buffer *buf)
-{
-   struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf);
-   st_softpipe_buf->mapped = NULL;
-}
-
-
-static void
-st_softpipe_buffer_destroy(struct pipe_buffer *buf)
-{
-   struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf);
-
-   if (oldBuf->data) {
-      if (!oldBuf->userBuffer)
-         align_free(oldBuf->data);
-
-      oldBuf->data = NULL;
-   }
-
-   FREE(oldBuf);
-}
-
-
-static void
-st_softpipe_flush_frontbuffer(struct pipe_winsys *winsys,
-                              struct pipe_surface *surf,
-                              void *context_private)
-{
-}
-
-
-
-static const char *
-st_softpipe_get_name(struct pipe_winsys *winsys)
-{
-   return "softpipe";
-}
-
-
-static struct pipe_buffer *
-st_softpipe_buffer_create(struct pipe_winsys *winsys, 
-                          unsigned alignment, 
-                          unsigned usage,
-                          unsigned size)
-{
-   struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_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 *
-st_softpipe_user_buffer_create(struct pipe_winsys *winsys, 
-                               void *ptr, 
-                               unsigned bytes)
-{
-   struct st_softpipe_buffer *buffer;
-   
-   buffer = CALLOC_STRUCT(st_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 *
-st_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
-st_softpipe_fence_reference(struct pipe_winsys *winsys, 
-                            struct pipe_fence_handle **ptr,
-                            struct pipe_fence_handle *fence)
-{
-}
-
-
-static int
-st_softpipe_fence_signalled(struct pipe_winsys *winsys, 
-                            struct pipe_fence_handle *fence,
-                            unsigned flag)
-{
-   return 0;
-}
-
-
-static int
-st_softpipe_fence_finish(struct pipe_winsys *winsys, 
-                         struct pipe_fence_handle *fence,
-                         unsigned flag)
-{
-   return 0;
-}
-
-
-static void
-st_softpipe_destroy(struct pipe_winsys *winsys)
-{
-   FREE(winsys);
-}
-
-
-struct pipe_screen *
-softpipe_create_screen_malloc(void)
-{
-   static struct pipe_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = CALLOC_STRUCT(pipe_winsys);
-   if(!winsys)
-      return NULL;
-
-   winsys->destroy = st_softpipe_destroy;
-   
-   winsys->buffer_create = st_softpipe_buffer_create;
-   winsys->user_buffer_create = st_softpipe_user_buffer_create;
-   winsys->buffer_map = st_softpipe_buffer_map;
-   winsys->buffer_unmap = st_softpipe_buffer_unmap;
-   winsys->buffer_destroy = st_softpipe_buffer_destroy;
-
-   winsys->surface_buffer_create = st_softpipe_surface_buffer_create;
-
-   winsys->fence_reference = st_softpipe_fence_reference;
-   winsys->fence_signalled = st_softpipe_fence_signalled;
-   winsys->fence_finish = st_softpipe_fence_finish;
-
-   winsys->flush_frontbuffer = st_softpipe_flush_frontbuffer;
-   winsys->get_name = st_softpipe_get_name;
-
-   screen = softpipe_create_screen(winsys);
-   if(!screen)
-      st_softpipe_destroy(winsys);
-
-   return screen;
-}
diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h
deleted file mode 100644 (file)
index edc49f2..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-/* This is the interface that softpipe requires any window system
- * hosting it to implement.  This is the only include file in softpipe
- * which is public.
- */
-
-
-#ifndef SP_WINSYS_H
-#define SP_WINSYS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "pipe/p_defines.h"
-
-struct pipe_screen;
-struct pipe_winsys;
-struct pipe_context;
-struct pipe_texture;
-struct pipe_buffer;
-
-
-
-/**
- * Create a softpipe screen that uses the
- * given winsys for allocating buffers.
- */
-struct pipe_screen *softpipe_create_screen( struct pipe_winsys * );
-
-/**
- * Create a softpipe screen that uses
- * regular malloc to create all its buffers.
- */
-struct pipe_screen *softpipe_create_screen_malloc(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SP_WINSYS_H */
index c16989fa529975cf76dd72630743ca555f588c98..906b3262e4b51af5ed736beaa053a7d48d74bcbc 100644 (file)
@@ -33,6 +33,7 @@
 #include "tr_context.h"
 #include "tr_buffer.h"
 #include "tr_texture.h"
+#include "tr_public.h"
 
 struct trace_drm_api
 {
diff --git a/src/gallium/drivers/trace/tr_public.h b/src/gallium/drivers/trace/tr_public.h
new file mode 100644 (file)
index 0000000..da31c24
--- /dev/null
@@ -0,0 +1,37 @@
+/**************************************************************************
+ *
+ * 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 VMWARE 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 TR_PUBLIC_H
+#define TR_PUBLIC_H
+
+struct pipe_screen;
+struct pipe_context;
+
+struct pipe_screen *
+trace_screen_create(struct pipe_screen *screen);
+
+#endif /* TR_PUBLIC_H */
index fe5a0fa1909f285f9835d93855c3515049833ce3..597e2fc26501f25fbd0a7c5c81d6ac30b43e4c88 100644 (file)
@@ -99,9 +99,6 @@ trace_enabled(void);
 struct trace_screen *
 trace_screen(struct pipe_screen *screen);
 
-struct pipe_screen *
-trace_screen_create(struct pipe_screen *screen);
-
 void
 trace_screen_user_buffer_update(struct pipe_screen *screen,
                                 struct pipe_buffer *buffer);
diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h
new file mode 100644 (file)
index 0000000..0de98bb
--- /dev/null
@@ -0,0 +1,124 @@
+/**************************************************************************
+ * 
+ * Copyright 2007-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.
+ * 
+ **************************************************************************/
+
+/**
+ * @file
+ * Software rasterizer winsys.
+ */
+
+
+#ifndef SW_WINSYS_H
+#define SW_WINSYS_H
+
+
+#include "pipe/p_compiler.h" /* for boolean */
+#include "pipe/p_format.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct pipe_screen;
+struct pipe_context;
+
+
+/**
+ * Opaque pointer.
+ */
+struct sw_displaytarget;
+
+
+/**
+ * This is the interface that sw expects any window system
+ * hosting it to implement.
+ * 
+ * sw is for the most part a self sufficient driver. The only thing it
+ * does not know is how to display a surface.
+ */
+struct sw_winsys
+{
+   void 
+   (*destroy)( struct sw_winsys *ws );
+
+   boolean
+   (*is_displaytarget_format_supported)( struct sw_winsys *ws,
+                                         enum pipe_format format );
+   
+   /**
+    * Allocate storage for a render target.
+    * 
+    * Often surfaces which are meant to be blitted to the front screen (i.e.,
+    * display targets) must be allocated with special characteristics, memory 
+    * pools, or obtained directly from the windowing system.
+    *  
+    * This callback is invoked by the pipe_screen when creating a texture marked
+    * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying 
+    * storage.
+    */
+   struct sw_displaytarget *
+   (*displaytarget_create)( struct sw_winsys *ws,
+                            enum pipe_format format,
+                            unsigned width, unsigned height,
+                            unsigned alignment,
+                            unsigned *stride );
+
+   /**
+    * \param flags  bitmask of PIPE_BUFFER_USAGE_x flags
+    */
+   void *
+   (*displaytarget_map)( struct sw_winsys *ws, 
+                         struct sw_displaytarget *dt,
+                         unsigned flags );
+
+   void
+   (*displaytarget_unmap)( struct sw_winsys *ws,
+                           struct sw_displaytarget *dt );
+
+   /**
+    * @sa pipe_screen:flush_frontbuffer.
+    *
+    * This call will likely become asynchronous eventually.
+    */
+   void
+   (*displaytarget_display)( struct sw_winsys *ws, 
+                             struct sw_displaytarget *dt,
+                             void *context_private );
+
+   void 
+   (*displaytarget_destroy)( struct sw_winsys *ws, 
+                             struct sw_displaytarget *dt );
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SW_WINSYS_H */
diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h
new file mode 100644 (file)
index 0000000..f22c22b
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef XLIB_SW_WINSYS_H
+#define XLIB_SW_WINSYS_H
+
+#include "state_tracker/sw_winsys.h"
+#include <X11/Xlib.h>
+
+
+struct pipe_screen;
+struct pipe_surface;
+
+/* This is what the xlib software winsys expects to find in the
+ * "private" field of flush_frontbuffers().
+ *
+ * Xlib-based state trackers somehow need to know this.
+ */
+struct xlib_drawable {
+   Visual *visual;
+   int depth;
+   Drawable drawable;
+};
+
+
+/* This is the public interface to the ws/xlib module.  Why isn't it
+ * being defined in that directory?
+ */
+struct sw_winsys *xlib_create_sw_winsys( Display *display );
+
+
+#endif
index 50774b03f35a7b0635fc25b6e201fa418f00202f..f54c51a66817101aaccaefb8f6a4a62261bf3229 100644 (file)
@@ -508,20 +508,6 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id)
    return id;
 }
 
-/**
- * Flush the front buffer of the context's draw surface.
- */
-static void
-egl_g3d_flush_frontbuffer(struct pipe_screen *screen,
-                          struct pipe_surface *surf, void *context_private)
-{
-   struct egl_g3d_context *gctx = egl_g3d_context(context_private);
-   struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface);
-
-   if (gsurf)
-      gsurf->native->flush_frontbuffer(gsurf->native);
-}
-
 /**
  * Re-validate the context.
  */
@@ -602,7 +588,6 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy,
    }
 
    gdpy->native->user_data = (void *) dpy;
-   gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer;
    gdpy->native->screen->update_buffer = egl_g3d_update_buffer;
 
    egl_g3d_init_st(&gdrv->base);
index 9c22ff3e4322f9de0ca7bac32f99ad92c0dbcd68..93c81b26e103416265751c5a9ec3e6ba5eb75741 100644 (file)
@@ -140,9 +140,6 @@ struct native_config {
 struct native_display {
    /**
     * The pipe screen of the native display.
-    *
-    * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be
-    * overridden.
     */
    struct pipe_screen *screen;
 
index 7b4fe63fa07d33943513f95720d2a126138ccbf6..c6eb17ab1ac7424f078c0b206a6a4b77e248f6e7 100644 (file)
@@ -142,16 +142,9 @@ native_create_display(EGLNativeDisplayType dpy,
 
    if (!ndpy) {
       EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING;
-      boolean use_shm;
-
-      /*
-       * XXX st/mesa calls pipe_screen::update_buffer in st_validate_state.
-       * When SHM is used, there is a good chance that the shared memory
-       * segment is detached before the softpipe tile cache is flushed.
-       */
-      use_shm = FALSE;
-      _eglLog(level, "use software%s fallback", (use_shm) ? " (SHM)" : "");
-      ndpy = x11_create_ximage_display(dpy, event_handler, use_shm);
+
+      _eglLog(level, "use software fallback");
+      ndpy = x11_create_ximage_display(dpy, event_handler);
    }
 
    return ndpy;
index 8c6a7d9349753bf3b28ead3ed7050a9197e5caf1..1566524926a988a01fb86623ee7f9bc8e34e5350 100644 (file)
@@ -30,8 +30,7 @@
 
 struct native_display *
 x11_create_ximage_display(EGLNativeDisplayType dpy,
-                          struct native_event_handler *event_handler,
-                          boolean use_xshm);
+                          struct native_event_handler *event_handler);
 
 struct native_display *
 x11_create_dri2_display(EGLNativeDisplayType dpy,
index a94b1ca6c66043b9f594fbc3ec3bd7b40c5c44b7..544b3b4276e71fcadae9c02241bb4abdf68eb718 100644 (file)
 #include <sys/shm.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#include <X11/extensions/XShm.h>
 #include "util/u_memory.h"
 #include "util/u_math.h"
 #include "util/u_format.h"
 #include "pipe/p_compiler.h"
-#include "util/u_simple_screen.h"
 #include "util/u_inlines.h"
-#include "softpipe/sp_winsys.h"
+#include "state_tracker/xlib_sw_winsys.h"
+#include "target-helpers/swrast_xlib.h"
 #include "egllog.h"
 
-#include "sw_winsys.h"
 #include "native_x11.h"
 #include "x11_screen.h"
 
@@ -53,24 +51,18 @@ struct ximage_display {
    Display *dpy;
    boolean own_dpy;
 
-   struct x11_screen *xscr;
-   int xscr_number;
-
    struct native_event_handler *event_handler;
 
-   boolean use_xshm;
+   struct x11_screen *xscr;
+   int xscr_number;
 
-   struct pipe_winsys *winsys;
    struct ximage_config *configs;
    int num_configs;
 };
 
 struct ximage_buffer {
-   XImage *ximage;
-
    struct pipe_texture *texture;
-   XShmSegmentInfo *shm_info;
-   boolean xshm_attached;
+   struct xlib_drawable xdraw;
 };
 
 struct ximage_surface {
@@ -81,8 +73,6 @@ struct ximage_surface {
    XVisualInfo visual;
    struct ximage_display *xdpy;
 
-   GC gc;
-
    unsigned int server_stamp;
    unsigned int client_stamp;
    int width, height;
@@ -121,18 +111,6 @@ ximage_surface_free_buffer(struct native_surface *nsurf,
    struct ximage_buffer *xbuf = &xsurf->buffers[which];
 
    pipe_texture_reference(&xbuf->texture, NULL);
-
-   if (xbuf->shm_info) {
-      if (xbuf->xshm_attached)
-         XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info);
-      if (xbuf->shm_info->shmaddr != (void *) -1)
-         shmdt(xbuf->shm_info->shmaddr);
-      if (xbuf->shm_info->shmid != -1)
-         shmctl(xbuf->shm_info->shmid, IPC_RMID, 0);
-
-      xbuf->shm_info->shmaddr = (void *) -1;
-      xbuf->shm_info->shmid = -1;
-   }
 }
 
 static boolean
@@ -156,47 +134,25 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf,
    templ.depth0 = 1;
    templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
 
-#if 0
-   /* Interesting and suprising use of texture_blanket +
-    * user_buffer_create...  To be superceded by the sw_winsys branch,
-    * but currently disabled.
-    */
-   if (xbuf->shm_info) {
-      struct pipe_buffer *pbuf;
-      unsigned stride, size;
-      void *addr = NULL;
-
-      stride = util_format_get_stride(xsurf->color_format, xsurf->width);
-      /* alignment should depend on visual? */
-      stride = align(stride, 4);
-      size = stride * xsurf->height;
-
-      /* create and attach shm object */
-      xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755);
-      if (xbuf->shm_info->shmid != -1) {
-         xbuf->shm_info->shmaddr =
-            shmat(xbuf->shm_info->shmid, NULL, 0);
-         if (xbuf->shm_info->shmaddr != (void *) -1) {
-            if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) {
-               addr = xbuf->shm_info->shmaddr;
-               xbuf->xshm_attached = TRUE;
-            }
-         }
-      }
-
-      if (addr) {
-         pbuf = screen->user_buffer_create(screen, addr, size);
-         if (pbuf) {
-            xbuf->texture =
-               screen->texture_blanket(screen, &templ, &stride, pbuf);
-            pipe_buffer_reference(&pbuf, NULL);
-         }
+   if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) {
+      switch (which) {
+      case NATIVE_ATTACHMENT_FRONT_LEFT:
+      case NATIVE_ATTACHMENT_FRONT_RIGHT:
+         templ.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
+         break;
+      case NATIVE_ATTACHMENT_BACK_LEFT:
+      case NATIVE_ATTACHMENT_BACK_RIGHT:
+         templ.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+         break;
+      default:
+         break;
       }
    }
-   else
-#endif
-   {
-      xbuf->texture = screen->texture_create(screen, &templ);
+   xbuf->texture = screen->texture_create(screen, &templ);
+   if (xbuf->texture) {
+      xbuf->xdraw.visual = xsurf->visual.visual;
+      xbuf->xdraw.depth = xsurf->visual.depth;
+      xbuf->xdraw.drawable = xsurf->drawable;
    }
 
    /* clean up the buffer if allocation failed */
@@ -276,18 +232,10 @@ ximage_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask)
    new_valid = 0x0;
    for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
       if (native_attachment_mask_test(buffer_mask, att)) {
-         struct ximage_buffer *xbuf = &xsurf->buffers[att];
-
          /* reallocate the texture */
          if (!ximage_surface_alloc_buffer(&xsurf->base, att))
             break;
 
-         /* update ximage */
-         if (xbuf->ximage) {
-            xbuf->ximage->width = xsurf->width;
-            xbuf->ximage->height = xsurf->height;
-         }
-
          new_valid |= (1 << att);
          if (buffer_mask == new_valid)
             break;
@@ -307,43 +255,22 @@ ximage_surface_draw_buffer(struct native_surface *nsurf,
    struct ximage_surface *xsurf = ximage_surface(nsurf);
    struct ximage_buffer *xbuf = &xsurf->buffers[which];
    struct pipe_screen *screen = xsurf->xdpy->base.screen;
-   struct pipe_transfer *transfer;
+   struct pipe_surface *psurf;
 
    if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER)
       return TRUE;
 
-   assert(xsurf->drawable && xbuf->ximage && xbuf->texture);
-
-   transfer = screen->get_tex_transfer(screen, xbuf->texture,
-         0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height);
-   if (!transfer)
-      return FALSE;
+   assert(xsurf->drawable && xbuf->texture);
 
-   xbuf->ximage->bytes_per_line = transfer->stride;
-   xbuf->ximage->data = screen->transfer_map(screen, transfer);
-   if (!xbuf->ximage->data) {
-      screen->tex_transfer_destroy(transfer);
+   /* what's the cost of surface creation? */
+   psurf = screen->get_tex_surface(screen,
+         xbuf->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
+   if (!psurf)
       return FALSE;
-   }
-
-
-   if (xbuf->shm_info)
-      XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc,
-            xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False);
-   else
-      XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc,
-            xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height);
 
-   xbuf->ximage->data = NULL;
-   screen->transfer_unmap(screen, transfer);
+   screen->flush_frontbuffer(screen, psurf, &xbuf->xdraw);
 
-   /*
-    * softpipe allows the pipe transfer to be re-used, but we don't want to
-    * rely on that behavior.
-    */
-   screen->tex_transfer_destroy(transfer);
-
-   XSync(xsurf->xdpy->dpy, FALSE);
+   pipe_surface_reference(&psurf, NULL);
 
    return TRUE;
 }
@@ -371,7 +298,8 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)
    boolean ret;
 
    /* display the back buffer first */
-   ret = ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT);
+   ret = ximage_surface_draw_buffer(&xsurf->base,
+         NATIVE_ATTACHMENT_BACK_LEFT);
    /* force buffers to be updated in next validation call */
    xsurf->server_stamp++;
    ximage_surface_notify_invalid(&xsurf->base);
@@ -379,13 +307,12 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)
    xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT];
    xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT];
 
-   /* skip swapping so that the front buffer is allocated only when needed */
-   if (!xfront->texture)
-      return ret;
-
-   xtmp = *xfront;
-   *xfront = *xback;
-   *xback = xtmp;
+   /* skip swapping unless there is a front buffer */
+   if (xfront->texture) {
+      xtmp = *xfront;
+      *xfront = *xback;
+      *xback = xtmp;
+   }
 
    return ret;
 }
@@ -440,18 +367,9 @@ ximage_surface_destroy(struct native_surface *nsurf)
    struct ximage_surface *xsurf = ximage_surface(nsurf);
    int i;
 
-   for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
-      struct ximage_buffer *xbuf = &xsurf->buffers[i];
+   for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
       ximage_surface_free_buffer(&xsurf->base, i);
-      /* xbuf->shm_info is owned by xbuf->ximage? */
-      if (xbuf->ximage) {
-         XDestroyImage(xbuf->ximage);
-         xbuf->ximage = NULL;
-      }
-   }
 
-   if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER)
-      XFreeGC(xsurf->xdpy->dpy, xsurf->gc);
    free(xsurf);
 }
 
@@ -464,7 +382,6 @@ ximage_display_create_surface(struct native_display *ndpy,
    struct ximage_display *xdpy = ximage_display(ndpy);
    struct ximage_config *xconf = ximage_config(nconf);
    struct ximage_surface *xsurf;
-   int i;
 
    xsurf = CALLOC_STRUCT(ximage_surface);
    if (!xsurf)
@@ -478,52 +395,8 @@ ximage_display_create_surface(struct native_display *ndpy,
    if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) {
       xsurf->drawable = drawable;
       xsurf->visual = *xconf->visual;
-
-      xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL);
-      if (!xsurf->gc) {
-         free(xsurf);
-         return NULL;
-      }
-
       /* initialize the geometry */
       ximage_surface_update_buffers(&xsurf->base, 0x0);
-
-      for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
-         struct ximage_buffer *xbuf = &xsurf->buffers[i];
-
-         if (xdpy->use_xshm) {
-            xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info));
-            if (xbuf->shm_info) {
-               /* initialize shm info */
-               xbuf->shm_info->shmid = -1;
-               xbuf->shm_info->shmaddr = (void *) -1;
-               xbuf->shm_info->readOnly = TRUE;
-
-               xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy,
-                     xsurf->visual.visual,
-                     xsurf->visual.depth,
-                     ZPixmap, NULL,
-                     xbuf->shm_info,
-                     0, 0);
-            }
-         }
-         else {
-            xbuf->ximage = XCreateImage(xsurf->xdpy->dpy,
-                  xsurf->visual.visual,
-                  xsurf->visual.depth,
-                  ZPixmap, 0,   /* format, offset */
-                  NULL,         /* data */
-                  0, 0,         /* size */
-                  8,            /* bitmap_pad */
-                  0);           /* bytes_per_line */
-         }
-
-         if (!xbuf->ximage) {
-            XFreeGC(xdpy->dpy, xsurf->gc);
-            free(xsurf);
-            return NULL;
-         }
-      }
    }
 
    xsurf->base.destroy = ximage_surface_destroy;
@@ -734,7 +607,6 @@ ximage_display_destroy(struct native_display *ndpy)
       free(xdpy->configs);
 
    xdpy->base.screen->destroy(xdpy->base.screen);
-   free(xdpy->winsys);
 
    x11_screen_destroy(xdpy->xscr);
    if (xdpy->own_dpy)
@@ -744,8 +616,7 @@ ximage_display_destroy(struct native_display *ndpy)
 
 struct native_display *
 x11_create_ximage_display(EGLNativeDisplayType dpy,
-                          struct native_event_handler *event_handler,
-                          boolean use_xshm)
+                          struct native_event_handler *event_handler)
 {
    struct ximage_display *xdpy;
 
@@ -763,6 +634,8 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
       xdpy->own_dpy = TRUE;
    }
 
+   xdpy->event_handler = event_handler;
+
    xdpy->xscr_number = DefaultScreen(xdpy->dpy);
    xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number);
    if (!xdpy->xscr) {
@@ -770,13 +643,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
       return NULL;
    }
 
-   xdpy->event_handler = event_handler;
-
-   xdpy->use_xshm =
-      (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM));
-
-   xdpy->winsys = create_sw_winsys();
-   xdpy->base.screen = softpipe_create_screen(xdpy->winsys);
+   xdpy->base.screen = swrast_xlib_create_screen(xdpy->dpy);
 
    xdpy->base.destroy = ximage_display_destroy;
    xdpy->base.get_param = ximage_display_get_param;
diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.c b/src/gallium/state_trackers/egl/x11/sw_winsys.c
deleted file mode 100644 (file)
index 33328aa..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-/**
- * Totally software-based winsys layer.
- * Note that the one winsys function that we can't implement here
- * is flush_frontbuffer().
- * Whoever uses this code will have to provide that.
- *
- * Authors: Brian Paul
- */
-
-
-#include "util/u_simple_screen.h"
-#include "pipe/p_state.h"
-#include "util/u_inlines.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "sw_winsys.h"
-
-
-
-/** Subclass of pipe_winsys */
-struct sw_pipe_winsys
-{
-   struct pipe_winsys Base;
-   /* no extra fields for now */
-};
-
-
-/** subclass of pipe_buffer */
-struct sw_pipe_buffer
-{
-   struct pipe_buffer Base;
-   boolean UserBuffer;  /** Is this a user-space buffer? */
-   void *Data;
-   void *Mapped;
-};
-
-
-/** cast wrapper */
-static INLINE struct sw_pipe_buffer *
-sw_pipe_buffer(struct pipe_buffer *b)
-{
-   return (struct sw_pipe_buffer *) b;
-}
-
-
-static const char *
-get_name(struct pipe_winsys *pws)
-{
-   return "software";
-}
-
-
-/** Create new pipe_buffer and allocate storage of given size */
-static struct pipe_buffer *
-buffer_create(struct pipe_winsys *pws, 
-              unsigned alignment, 
-              unsigned usage,
-              unsigned size)
-{
-   struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer);
-   if (!buffer)
-      return NULL;
-
-   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, MAX2(alignment, 16));
-
-   return &buffer->Base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-{
-   struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_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 void *
-buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags)
-{
-   struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
-   buffer->Mapped = buffer->Data;
-   return buffer->Mapped;
-}
-
-
-static void
-buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
-   struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
-   buffer->Mapped = NULL;
-}
-
-
-static void
-buffer_destroy(struct pipe_buffer *buf)
-{
-   struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf);
-
-   if (buffer->Data && !buffer->UserBuffer) {
-      align_free(buffer->Data);
-      buffer->Data = NULL;
-   }
-
-   free(buffer);
-}
-
-
-static struct pipe_buffer *
-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
-fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr,
-                struct pipe_fence_handle *fence)
-{
-   /* no-op */
-}
-
-
-static int
-fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
-                unsigned flag)
-{
-   /* no-op */
-   return 0;
-}
-
-
-static int
-fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence,
-             unsigned flag)
-{
-   /* no-op */
-   return 0;
-}
-
-
-/**
- * Create/return a new pipe_winsys object.
- */
-struct pipe_winsys *
-create_sw_winsys(void)
-{
-   struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys);
-   if (!ws)
-      return NULL;
-
-   /* Fill in this struct with callbacks that pipe will need to
-    * communicate with the window system, buffer manager, etc. 
-    */
-   ws->Base.buffer_create = buffer_create;
-   ws->Base.user_buffer_create = user_buffer_create;
-   ws->Base.buffer_map = buffer_map;
-   ws->Base.buffer_unmap = buffer_unmap;
-   ws->Base.buffer_destroy = buffer_destroy;
-
-   ws->Base.surface_buffer_create = surface_buffer_create;
-
-   ws->Base.fence_reference = fence_reference;
-   ws->Base.fence_signalled = fence_signalled;
-   ws->Base.fence_finish = fence_finish;
-
-   ws->Base.flush_frontbuffer = NULL; /* not implemented here! */
-
-   ws->Base.get_name = get_name;
-
-   return &ws->Base;
-}
diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.h b/src/gallium/state_trackers/egl/x11/sw_winsys.h
deleted file mode 100644 (file)
index f96c5a1..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-
-#ifndef SW_WINSYS_H
-#define SW_WINSYS_H
-
-
-struct pipe_winsys;
-
-
-extern struct pipe_winsys *
-create_sw_winsys(void);
-
-
-#endif /* SW_WINSYS_H */
index fa96df357d5e267af49b5c12a9d75b48df366bdf..bb202351509251ec44a2d203aa335e31c3a5d69b 100644 (file)
@@ -13,8 +13,6 @@ if env['platform'] == 'linux' \
         '#/src/mesa/main',
     ])
 
-    env.Append(CPPDEFINES = ['USE_XSHM'])
-
     st_xlib = env.ConvenienceLibrary(
        target = 'st_xlib',
        source = [
index 08bf624b5c1f205a9ccd6633f44ddc15db46607d..2454585850008fc23e8a4e4e1c532eab97af3052 100644 (file)
@@ -689,7 +689,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
    int desiredVisualID = -1;
    int numAux = 0;
 
-   xmesa_init();
+   xmesa_init( dpy );
 
    parselist = list;
 
index 217bdeff75e8deb87736b7d89a7b68eba0277f5d..568bc6e96221b5bbcfe5bc01c7ebe00362094779 100644 (file)
  * corner of the window.  Therefore, most drawing functions in this
  * file have to flip Y coordinates.
  *
- * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile
- * in support for the MIT Shared Memory extension.  If enabled, when you
- * use an Ximage for the back buffer in double buffered mode, the "swap"
- * operation will be faster.  You must also link with -lXext.
  *
  * Byte swapping:  If the Mesa host and the X display use a different
  * byte order then there's some trickiness to be aware of when using
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
 
-#include "trace/tr_screen.h"
-#include "trace/tr_context.h"
-#include "trace/tr_texture.h"
-
-#include "xm_winsys.h"
+#include "xm_public.h"
 #include <GL/glx.h>
 
 
@@ -91,7 +83,6 @@ void xmesa_set_driver( const struct xm_driver *templ )
  */
 pipe_mutex _xmesa_lock;
 
-static struct pipe_screen *_screen = NULL;
 static struct pipe_screen *screen = NULL;
 
 
@@ -111,41 +102,6 @@ static int host_byte_order( void )
 }
 
 
-/**
- * Check if the X Shared Memory extension is available.
- * Return:  0 = not available
- *          1 = shared XImage support available
- *          2 = shared Pixmap support available also
- */
-int xmesa_check_for_xshm( Display *display )
-{
-#if defined(USE_XSHM)
-   int major, minor, ignore;
-   Bool pixmaps;
-
-   if (getenv("SP_NO_RAST")) 
-      return 0;
-
-   if (getenv("MESA_NOSHM")) {
-      return 0;
-   }
-
-   if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) {
-      if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) {
-        return (pixmaps==True) ? 2 : 1;
-      }
-      else {
-        return 0;
-      }
-   }
-   else {
-      return 0;
-   }
-#else
-   /* No  XSHM support */
-   return 0;
-#endif
-}
 
 
 /**
@@ -242,7 +198,7 @@ xmesa_get_window_size(Display *dpy, XMesaBuffer b,
 
    pipe_mutex_lock(_xmesa_lock);
    XSync(b->xm_visual->display, 0); /* added for Chromium */
-   stat = get_drawable_size(dpy, b->drawable, width, height);
+   stat = get_drawable_size(dpy, b->ws.drawable, width, height);
    pipe_mutex_unlock(_xmesa_lock);
 
    if (!stat) {
@@ -397,7 +353,9 @@ create_xmesa_buffer(Drawable d, BufferType type,
    if (!b)
       return NULL;
 
-   b->drawable = d;
+   b->ws.drawable = d;
+   b->ws.visual = vis->visinfo->visual;
+   b->ws.depth = vis->visinfo->depth;
 
    b->xm_visual = vis;
    b->type = type;
@@ -422,18 +380,6 @@ create_xmesa_buffer(Drawable d, BufferType type,
                                    (void *) b);
    fb = &b->stfb->Base;
 
-   /*
-    * Create scratch XImage for xmesa_display_surface()
-    */
-   b->tempImage = XCreateImage(vis->display,
-                               vis->visinfo->visual,
-                               vis->visinfo->depth,
-                               ZPixmap, 0,   /* format, offset */
-                               NULL,         /* data */
-                               0, 0,         /* size */
-                               32,           /* bitmap_pad */
-                               0);           /* bytes_per_line */
-
    /* GLX_EXT_texture_from_pixmap */
    b->TextureTarget = 0;
    b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT;
@@ -490,16 +436,11 @@ xmesa_free_buffer(XMesaBuffer buffer)
          /* Since the X window for the XMesaBuffer is going away, we don't
           * want to dereference this pointer in the future.
           */
-         b->drawable = 0;
-
-         buffer->tempImage->data = NULL;
-         XDestroyImage(buffer->tempImage);
+         b->ws.drawable = 0;
 
          /* Unreference.  If count = zero we'll really delete the buffer */
          _mesa_reference_framebuffer(&fb, NULL);
 
-         XFreeGC(b->xm_visual->display, b->gc);
-
          free(buffer);
 
          return;
@@ -576,21 +517,6 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b,
       printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel);
    }
 
-   if (b && window) {
-      /* these should have been set in create_xmesa_buffer */
-      ASSERT(b->drawable == window);
-
-      /* Setup for single/double buffering */
-      if (v->mesa_visual.doubleBufferMode) {
-         /* Double buffered */
-         b->shm = xmesa_check_for_xshm( v->display );
-      }
-
-      /* X11 graphics context */
-      b->gc = XCreateGC( v->display, window, 0, NULL );
-      XSetFunction( v->display, b->gc, GXcopy );
-   }
-
    return GL_TRUE;
 }
 
@@ -673,7 +599,7 @@ XMesaVisual XMesaCreateVisual( Display *display,
    XMesaVisual v;
    GLint red_bits, green_bits, blue_bits, alpha_bits;
 
-   xmesa_init();
+   xmesa_init( display );
 
    /* For debugging only */
    if (_mesa_getenv("MESA_XSYNC")) {
@@ -773,13 +699,12 @@ void XMesaDestroyVisual( XMesaVisual v )
  * Do one-time initializations.
  */
 void
-xmesa_init(void)
+xmesa_init( Display *display )
 {
    static GLboolean firstTime = GL_TRUE;
    if (firstTime) {
       pipe_mutex_init(_xmesa_lock);
-      _screen = driver.create_pipe_screen();
-      screen = trace_screen_create( _screen );
+      screen = driver.create_pipe_screen( display );
       firstTime = GL_FALSE;
    }
 }
@@ -800,7 +725,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
    GLcontext *mesaCtx;
    uint pf;
 
-   xmesa_init();
+   xmesa_init( v->display );
 
    /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
    c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
@@ -1149,13 +1074,9 @@ void XMesaSwapBuffers( XMesaBuffer b )
    st_swapbuffers(b->stfb, &frontLeftSurf, NULL);
 
    if (frontLeftSurf) {
-      if (_screen != screen) {
-         struct trace_surface *tr_surf = trace_surface( frontLeftSurf );
-         struct pipe_surface *surf = tr_surf->surface;
-         frontLeftSurf = surf;
-      }
-
-      driver.display_surface(b, frontLeftSurf);
+      screen->flush_frontbuffer( screen,
+                                 frontLeftSurf, 
+                                 &b->ws );
    }
 
    xmesa_check_and_update_buffer_size(NULL, b);
@@ -1203,7 +1124,7 @@ XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d )
 {
    XMesaBuffer b;
    for (b = XMesaBufferList; b; b = b->Next) {
-      if (b->drawable == d && b->xm_visual->display == dpy) {
+      if (b->ws.drawable == d && b->xm_visual->display == dpy) {
          return b;
       }
    }
@@ -1237,10 +1158,10 @@ void XMesaGarbageCollect( void )
       next = b->Next;
       if (b->xm_visual &&
           b->xm_visual->display &&
-          b->drawable &&
+          b->ws.drawable &&
           b->type == WINDOW) {
          XSync(b->xm_visual->display, False);
-         if (!window_exists( b->xm_visual->display, b->drawable )) {
+         if (!window_exists( b->xm_visual->display, b->ws.drawable )) {
             /* found a dead window, free the ancillary info */
             XMesaDestroyBuffer( b );
          }
index 004cb260dcdd47dc7baae6847e0f1689206e4001..de47064b410a5e3238bf261aa9830a0be10adb40 100644 (file)
@@ -62,15 +62,11 @@ and create a window, you must do the following to use the X/Mesa interface:
 #include "state_tracker/st_public.h"
 #include "os/os_thread.h"
 
+#include "state_tracker/xlib_sw_winsys.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;
@@ -316,6 +312,7 @@ typedef enum {
  */
 struct xmesa_buffer {
    struct st_framebuffer *stfb;
+   struct xlib_drawable ws;
 
    GLboolean wasCurrent;       /* was ever the current buffer? */
    XMesaVisual xm_visual;      /* the X/Mesa visual */
@@ -329,13 +326,6 @@ struct xmesa_buffer {
    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 */
 
@@ -367,7 +357,7 @@ xmesa_buffer(GLframebuffer *fb)
 
 
 extern void
-xmesa_init(void);
+xmesa_init(Display *dpy);
 
 extern void
 xmesa_delete_framebuffer(struct gl_framebuffer *fb);
@@ -397,8 +387,6 @@ xmesa_buffer_height(XMesaBuffer b)
    return b->stfb->Base.Height;
 }
 
-extern int
-xmesa_check_for_xshm(Display *display);
 
 
 #endif
diff --git a/src/gallium/state_trackers/glx/xlib/xm_public.h b/src/gallium/state_trackers/glx/xlib/xm_public.h
new file mode 100644 (file)
index 0000000..ac6a8ff
--- /dev/null
@@ -0,0 +1,44 @@
+
+/**************************************************************************
+ * 
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **************************************************************************/
+
+#ifndef XM_WINSYS_H
+#define XM_WINSYS_H
+
+struct xm_driver;
+
+/* This is the driver interface required by the glx/xlib state tracker. 
+ */
+struct xm_driver {
+   struct pipe_screen *(*create_pipe_screen)( Display *display );
+};
+
+extern void
+xmesa_set_driver( const struct xm_driver *driver );
+
+
+#endif
diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h
deleted file mode 100644 (file)
index 4bd5b5c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- * 
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- * 
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * 
- **************************************************************************/
-
-#ifndef XM_WINSYS_H
-#define XM_WINSYS_H
-
-struct pipe_context;
-struct pipe_screen;
-struct pipe_surface;
-struct xmesa_buffer;
-
-
-struct xm_driver {
-
-   struct pipe_screen *(*create_pipe_screen)( void );
-
-   void (*display_surface)( struct xmesa_buffer *, 
-                            struct pipe_surface * );
-
-};
-
-
-extern void
-xmesa_set_driver( const struct xm_driver *driver );
-
-
-#endif
diff --git a/src/gallium/targets/Makefile b/src/gallium/targets/Makefile
new file mode 100644 (file)
index 0000000..a0bc5eb
--- /dev/null
@@ -0,0 +1,12 @@
+# src/gallium/winsys/Makefile
+TOP = ../../..
+include $(TOP)/configs/current
+
+SUBDIRS = $(GALLIUM_TARGET_DIRS)
+
+default install clean:
+       @for dir in $(SUBDIRS) ; do \
+               if [ -d $$dir ] ; then \
+                       (cd $$dir && $(MAKE) $@) || exit 1; \
+               fi \
+       done
diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript
new file mode 100644 (file)
index 0000000..266d705
--- /dev/null
@@ -0,0 +1,16 @@
+Import('*')
+
+#if env['dri']:
+#      SConscript([
+#              'drm/SConscript',
+#      ])
+       
+if 'xlib' in env['targets']:
+       SConscript([
+               'libgl-xlib/SConscript',
+       ])
+
+#if 'gdi' in env['winsys']:
+#      SConscript([
+#              'gdi/SConscript',
+#      ])
diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript
new file mode 100644 (file)
index 0000000..5770444
--- /dev/null
@@ -0,0 +1,51 @@
+#######################################################################
+# SConscript for gdi winsys
+
+Import('*')
+
+if env['platform'] == 'windows':
+
+    env = env.Clone()
+
+    env.Append(CPPPATH = [
+        '#src/gallium/state_trackers/wgl',
+    ])
+
+    env.Append(LIBS = [
+        'gdi32',
+        'user32',
+        'kernel32',
+        'ws2_32',
+    ])
+
+    sources = []
+    drivers = []
+
+    if 'softpipe' in env['drivers']:
+        sources = ['gdi_softpipe_winsys.c']
+        drivers = [softpipe]
+
+    if 'llvmpipe' in env['drivers']:
+        env.Tool('llvm')
+        if 'LLVM_VERSION' in env:
+            sources = ['gdi_llvmpipe_winsys.c']
+            drivers = [llvmpipe]
+
+    if not sources or not drivers:
+        print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
+        Return()
+    
+    if env['gcc']:
+        sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def']
+    else:
+        sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
+        
+    drivers += [trace]
+
+    env['no_import_lib'] = 1
+
+    env.SharedLibrary(
+        target ='opengl32',
+        source = sources,
+        LIBS = wgl + ws_gdi + glapi + mesa + drivers + gallium + glsl + env['LIBS'],
+    )
diff --git a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c
new file mode 100644 (file)
index 0000000..f20c261
--- /dev/null
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * 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 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.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * LLVMpipe support.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include <windows.h>
+
+#include "stw_winsys.h"
+#include "gdi_sw_winsys.h"
+#include "llvmpipe/lp_texture.h"
+#include "llvmpipe/lp_screen.h"
+
+
+static struct pipe_screen *
+gdi_llvmpipe_screen_create(void)
+{
+   static struct sw_winsys *winsys;
+   struct pipe_screen *screen;
+
+   winsys = gdi_create_sw_winsys();
+   if(!winsys)
+      goto no_winsys;
+
+   screen = llvmpipe_create_screen(winsys);
+   if(!screen)
+      goto no_screen;
+
+   return screen;
+   
+no_screen:
+   winsys->destroy(winsys);
+no_winsys:
+   return NULL;
+}
+
+
+
+
+static void
+gdi_llvmpipe_present(struct pipe_screen *screen,
+                     struct pipe_surface *surface,
+                     HDC hDC)
+{
+   /* This will fail if any interposing layer (trace, debug, etc) has
+    * been introduced between the state-trackers and llvmpipe.
+    *
+    * Ideally this would get replaced with a call to
+    * pipe_screen::flush_frontbuffer().
+    *
+    * Failing that, it may be necessary for intervening layers to wrap
+    * other structs such as this stw_winsys as well...
+    */
+   gdi_sw_display(llvmpipe_screen(screen)->winsys,
+                  llvmpipe_texture(surface->texture)->dt,
+                  hDC);
+}
+
+
+static const struct stw_winsys stw_winsys = {
+   &gdi_llvmpipe_screen_create,
+   &gdi_llvmpipe_present,
+   NULL, /* get_adapter_luid */
+   NULL, /* shared_surface_open */
+   NULL, /* shared_surface_close */
+   NULL  /* compose */
+};
+
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
+{
+   switch (fdwReason) {
+   case DLL_PROCESS_ATTACH:
+      stw_init(&stw_winsys);
+      stw_init_thread();
+      break;
+
+   case DLL_THREAD_ATTACH:
+      stw_init_thread();
+      break;
+
+   case DLL_THREAD_DETACH:
+      stw_cleanup_thread();
+      break;
+
+   case DLL_PROCESS_DETACH:
+      stw_cleanup_thread();
+      stw_cleanup();
+      break;
+   }
+   return TRUE;
+}
diff --git a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c
new file mode 100644 (file)
index 0000000..5c5c154
--- /dev/null
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * 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 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.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * LLVMpipe support.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#include <windows.h>
+
+#include "stw_winsys.h"
+#include "gdi_sw_winsys.h"
+#include "softpipe/sp_texture.h"
+#include "softpipe/sp_screen.h"
+
+
+static struct pipe_screen *
+gdi_softpipe_screen_create(void)
+{
+   static struct sw_winsys *winsys;
+   struct pipe_screen *screen;
+
+   winsys = gdi_create_sw_winsys();
+   if(!winsys)
+      goto no_winsys;
+
+   screen = softpipe_create_screen(winsys);
+   if(!screen)
+      goto no_screen;
+
+   return screen;
+   
+no_screen:
+   winsys->destroy(winsys);
+no_winsys:
+   return NULL;
+}
+
+
+
+
+static void
+gdi_softpipe_present(struct pipe_screen *screen,
+                     struct pipe_surface *surface,
+                     HDC hDC)
+{
+   /* This will fail if any interposing layer (trace, debug, etc) has
+    * been introduced between the state-trackers and softpipe.
+    *
+    * Ideally this would get replaced with a call to
+    * pipe_screen::flush_frontbuffer().
+    *
+    * Failing that, it may be necessary for intervening layers to wrap
+    * other structs such as this stw_winsys as well...
+    */
+   gdi_sw_display(softpipe_screen(screen)->winsys,
+                  softpipe_texture(surface->texture)->dt,
+                  hDC);
+}
+
+
+static const struct stw_winsys stw_winsys = {
+   &gdi_softpipe_screen_create,
+   &gdi_softpipe_present,
+   NULL, /* get_adapter_luid */
+   NULL, /* shared_surface_open */
+   NULL, /* shared_surface_close */
+   NULL  /* compose */
+};
+
+
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
+{
+   switch (fdwReason) {
+   case DLL_PROCESS_ATTACH:
+      stw_init(&stw_winsys);
+      stw_init_thread();
+      break;
+
+   case DLL_THREAD_ATTACH:
+      stw_init_thread();
+      break;
+
+   case DLL_THREAD_DETACH:
+      stw_cleanup_thread();
+      break;
+
+   case DLL_PROCESS_DETACH:
+      stw_cleanup_thread();
+      stw_cleanup();
+      break;
+   }
+   return TRUE;
+}
diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile
new file mode 100644 (file)
index 0000000..5a4e035
--- /dev/null
@@ -0,0 +1,100 @@
+# src/gallium/targets/libgl-xlib/Makefile
+
+# This makefile produces a "stand-alone" libGL.so which is based on
+# Xlib (no DRI HW acceleration)
+
+
+TOP = ../../../..
+include $(TOP)/configs/current
+
+
+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 \
+       -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_TARGET_SOURCES = \
+       xlib.c
+
+
+XLIB_TARGET_OBJECTS = $(XLIB_TARGET_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/gallium/winsys/xlib/libws_xlib.a \
+       $(TOP)/src/gallium/drivers/trace/libtrace.a \
+       $(TOP)/src/gallium/drivers/identity/libidentity.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_TARGET_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_TARGET_OBJECTS) \
+               -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
+
+
+depend: $(XLIB_TARGET_SOURCES)
+       @ echo "running $(MKDEP)"
+       @ rm -f depend  # workaround oops on gutsy?!?
+       @ touch depend
+       $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_TARGET_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 depend
diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript
new file mode 100644 (file)
index 0000000..efa7e79
--- /dev/null
@@ -0,0 +1,69 @@
+#######################################################################
+# 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'])
+
+env.Prepend(LIBS = [
+    st_xlib,
+    ws_xlib,
+    trace,
+    identity,
+    glapi,
+    mesa,
+    glsl,
+    gallium,
+])
+
+sources = [
+    'xlib.c',
+]
+
+if 'softpipe' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
+    env.Prepend(LIBS = [softpipe])
+
+if 'llvmpipe' in env['drivers']:
+    env.Tool('llvm')
+    if 'LLVM_VERSION' in env:
+        env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE')
+        env.Tool('udis86')
+        env.Prepend(LIBS = [llvmpipe])
+    
+if 'cell' in env['drivers']:
+    env.Append(CPPDEFINES = 'GALLIUM_CELL')
+    env.Prepend(LIBS = [cell])
+
+# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
+libgl = env.SharedLibrary(
+    target ='GL',
+    source = sources,
+)
+
+if not env['dri']:
+    # Only install this libGL.so if DRI not enabled
+    env.InstallSharedLibrary(libgl, version=(1, 5))
diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c
new file mode 100644 (file)
index 0000000..5476444
--- /dev/null
@@ -0,0 +1,99 @@
+/**************************************************************************
+ * 
+ * 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 "pipe/p_compiler.h"
+#include "target-helpers/swrast_xlib.h"
+#include "xm_public.h"
+
+/* advertise OpenGL support */
+PUBLIC const int st_api_OpenGL = 1;
+
+struct xm_driver xlib_driver = 
+{
+   .create_pipe_screen = swrast_xlib_create_screen,
+};
+
+
+/* Build the rendering stack.
+ */
+static void _init( void ) __attribute__((constructor));
+static void _init( void )
+{
+   /* Initialize the xlib libgl code, pass in the winsys:
+    */
+   xmesa_set_driver( &xlib_driver );
+}
+
+
+/***********************************************************************
+ *
+ * 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);
+}
+
+
+/**
+ * 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 */
index 30c3378dfff432dac799422690b4f2f5f98300c3..4567d1744793c4d8f742e73e4ae99be6ffe78568 100644 (file)
@@ -1,5 +1,9 @@
 Import('*')
 
+SConscript([
+    'null/SConscript',
+])
+
 if env['dri']:
        SConscript([
                'drm/SConscript',
index 8363de6e975f18c75baa0bcba18a41400f6f76c7..bc5dd3a53b840815aea83b4239f14bec3c917710 100644 (file)
@@ -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
@@ -38,8 +39,10 @@ $(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so
 
 define mklib-egl
 $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \
-       $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) $($(1)_ST) \
-       $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS)
+       $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \
+       -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \
+       $(GALLIUM_AUXILIARIES) -Wl,--end-group \
+       $($(1)_LIBS) $(EGL_DRIVER_LIBS)
 endef
 
 egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile
index 74501eeb16f7e87af4de21e50fd535f65c835e27..063e9f600b9c524169d577e88ff0a998f4bbb9f4 100644 (file)
@@ -38,7 +38,7 @@
 #include "pipe/p_error.h"
 #include "pipe/p_context.h"
 
-#include "xm_winsys.h"
+#include "xm_public.h"
 
 #include "i965/brw_winsys.h"
 #include "i965/brw_screen.h"
index 4cbc86f3311212596d5e00c0c551efbaefe4e254..1267fc6eea415936c1b1372eb8744f7ecaebc11c 100644 (file)
@@ -1,5 +1,6 @@
 #######################################################################
-# SConscript for gdi winsys
+# SConscript for xlib winsys
+
 
 Import('*')
 
@@ -8,44 +9,15 @@ if env['platform'] == 'windows':
     env = env.Clone()
 
     env.Append(CPPPATH = [
-        '#src/gallium/state_trackers/wgl',
-    ])
-
-    env.Append(LIBS = [
-        'gdi32',
-        'user32',
-        'kernel32',
-        'ws2_32',
+        '#/src/gallium/include',
+        '#/src/gallium/auxiliary',
+        '#/src/gallium/drivers',
     ])
 
-    sources = []
-    drivers = []
-
-    if 'softpipe' in env['drivers']:
-        sources = ['gdi_softpipe_winsys.c']
-        drivers = [softpipe]
-
-    if 'llvmpipe' in env['drivers']:
-        env.Tool('llvm')
-        if 'LLVM_VERSION' in env:
-            sources = ['gdi_llvmpipe_winsys.c']
-            drivers = [llvmpipe]
-
-    if not sources or not drivers:
-        print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled'
-        Return()
-    
-    if env['gcc']:
-        sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def']
-    else:
-        sources += ['#src/gallium/state_trackers/wgl/opengl32.def']
-        
-    drivers += [trace]
-
-    env['no_import_lib'] = 1
-
-    env.SharedLibrary(
-        target ='opengl32',
-        source = sources,
-        LIBS = wgl + glapi + mesa + drivers + gallium + glsl + env['LIBS'],
+    ws_gdi = env.ConvenienceLibrary(
+        target = 'ws_gdi',
+        source = [
+           'gdi_sw_winsys.c',
+        ]
     )
+    Export('ws_gdi')
diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c
deleted file mode 100644 (file)
index a9fa03b..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-/**************************************************************************
- *
- * 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 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.
- *
- *
- **************************************************************************/
-
-/**
- * @file
- * LLVMpipe support.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#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 "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 *
-gdi_llvmpipe_screen_create(void)
-{
-   static struct llvmpipe_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = CALLOC_STRUCT(llvmpipe_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;
-
-   return screen;
-   
-no_screen:
-   FREE(winsys);
-no_winsys:
-   return NULL;
-}
-
-
-
-
-static void
-gdi_llvmpipe_present(struct pipe_screen *screen,
-                     struct pipe_surface *surface,
-                     HDC hDC)
-{
-    struct llvmpipe_texture *texture;
-    struct gdi_llvmpipe_displaytarget *gdt;
-
-    texture = llvmpipe_texture(surface->texture);
-    gdt = gdi_llvmpipe_displaytarget(texture->dt);
-
-    StretchDIBits(hDC,
-                  0, 0, gdt->width, gdt->height,
-                  0, 0, gdt->width, gdt->height,
-                  gdt->data, &gdt->bmi, 0, SRCCOPY);
-}
-
-
-static const struct stw_winsys stw_winsys = {
-   &gdi_llvmpipe_screen_create,
-   &gdi_llvmpipe_present,
-   NULL, /* get_adapter_luid */
-   NULL, /* shared_surface_open */
-   NULL, /* shared_surface_close */
-   NULL  /* compose */
-};
-
-
-BOOL WINAPI
-DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
-{
-   switch (fdwReason) {
-   case DLL_PROCESS_ATTACH:
-      stw_init(&stw_winsys);
-      stw_init_thread();
-      break;
-
-   case DLL_THREAD_ATTACH:
-      stw_init_thread();
-      break;
-
-   case DLL_THREAD_DETACH:
-      stw_cleanup_thread();
-      break;
-
-   case DLL_PROCESS_DETACH:
-      stw_cleanup_thread();
-      stw_cleanup();
-      break;
-   }
-   return TRUE;
-}
diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c
deleted file mode 100644 (file)
index 71360e5..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 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.
- *
- *
- **************************************************************************/
-
-/**
- * @file
- * Softpipe support.
- *
- * @author Keith Whitwell
- * @author Brian Paul
- * @author Jose Fonseca
- */
-
-
-#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 "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;
-   struct pipe_screen *screen;
-
-   winsys = CALLOC_STRUCT(pipe_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;
-
-   screen = softpipe_create_screen(winsys);
-   if(!screen)
-      gdi_softpipe_destroy(winsys);
-
-   return screen;
-}
-
-
-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;
-
-    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;
-
-    StretchDIBits(hDC,
-                  0, 0, surface->width, surface->height,
-                  0, 0, surface->width, surface->height,
-                  buffer->data, &bmi, 0, SRCCOPY);
-}
-
-
-static const struct stw_winsys stw_winsys = {
-   &gdi_softpipe_screen_create,
-   &gdi_softpipe_present,
-   NULL, /* get_adapter_luid */
-   NULL, /* shared_surface_open */
-   NULL, /* shared_surface_close */
-   NULL  /* compose */
-};
-
-
-BOOL WINAPI
-DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
-{
-   switch (fdwReason) {
-   case DLL_PROCESS_ATTACH:
-      stw_init(&stw_winsys);
-      stw_init_thread();
-      break;
-
-   case DLL_THREAD_ATTACH:
-      stw_init_thread();
-      break;
-
-   case DLL_THREAD_DETACH:
-      stw_cleanup_thread();
-      break;
-
-   case DLL_PROCESS_DETACH:
-      stw_cleanup_thread();
-      stw_cleanup();
-      break;
-   }
-   return TRUE;
-}
diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c
new file mode 100644 (file)
index 0000000..f5c0b7d
--- /dev/null
@@ -0,0 +1,222 @@
+/**************************************************************************
+ *
+ * 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 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.
+ *
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * GDI software rasterizer support.
+ *
+ * @author Jose Fonseca <jfonseca@vmware.com>
+ */
+
+
+#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 "state_tracker/sw_winsys.h"
+#include "gdi_sw_winsys.h"
+
+
+struct gdi_sw_displaytarget
+{
+   enum pipe_format format;
+   unsigned width;
+   unsigned height;
+   unsigned stride;
+
+   unsigned size;
+
+   void *data;
+
+   BITMAPINFO bmi;
+};
+
+
+/** Cast wrapper */
+static INLINE struct gdi_sw_displaytarget *
+gdi_sw_displaytarget( struct sw_displaytarget *buf )
+{
+   return (struct gdi_sw_displaytarget *)buf;
+}
+
+
+static boolean
+gdi_sw_is_displaytarget_format_supported( struct sw_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_sw_displaytarget_map(struct sw_winsys *ws,
+                               struct sw_displaytarget *dt,
+                               unsigned flags )
+{
+   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+   return gdt->data;
+}
+
+
+static void
+gdi_sw_displaytarget_unmap(struct sw_winsys *ws,
+                                 struct sw_displaytarget *dt )
+{
+
+}
+
+
+static void
+gdi_sw_displaytarget_destroy(struct sw_winsys *winsys,
+                                   struct sw_displaytarget *dt)
+{
+   struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+   align_free(gdt->data);
+   FREE(gdt);
+}
+
+
+static struct sw_displaytarget *
+gdi_sw_displaytarget_create(struct sw_winsys *winsys,
+                                  enum pipe_format format,
+                                  unsigned width, unsigned height,
+                                  unsigned alignment,
+                                  unsigned *stride)
+{
+   struct gdi_sw_displaytarget *gdt;
+   unsigned cpp;
+   unsigned bpp;
+   
+   gdt = CALLOC_STRUCT(gdi_sw_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 sw_displaytarget *)gdt;
+
+no_data:
+   FREE(gdt);
+no_gdt:
+   return NULL;
+}
+
+
+void
+gdi_sw_display( struct sw_winsys *winsys,
+                struct sw_displaytarget *dt,
+                HDC hDC )
+{
+    struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt);
+
+    StretchDIBits(hDC,
+                  0, 0, gdt->width, gdt->height,
+                  0, 0, gdt->width, gdt->height,
+                  gdt->data, &gdt->bmi, 0, SRCCOPY);
+}
+
+static void
+gdi_sw_displaytarget_display(struct sw_winsys *winsys, 
+                             struct sw_displaytarget *dt,
+                             void *context_private)
+{
+    /* nasty:
+     */
+    HDC hDC = (HDC)context_private;
+
+    gdi_sw_display(winsys, dt, hDC);
+}
+
+
+static void
+gdi_sw_destroy(struct sw_winsys *winsys)
+{
+   FREE(winsys);
+}
+
+struct sw_winsys *
+gdi_create_sw_winsys(void)
+{
+   static struct sw_winsys *winsys;
+
+   winsys = CALLOC_STRUCT(sw_winsys);
+   if(!winsys)
+      return NULL;
+
+   winsys->destroy = gdi_sw_destroy;
+   winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported;
+   winsys->displaytarget_create = gdi_sw_displaytarget_create;
+   winsys->displaytarget_map = gdi_sw_displaytarget_map;
+   winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap;
+   winsys->displaytarget_display = gdi_sw_displaytarget_display;
+   winsys->displaytarget_destroy = gdi_sw_displaytarget_destroy;
+
+   return winsys;
+}
+
diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h
new file mode 100644 (file)
index 0000000..8ecca7b
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef GDI_SW_WINSYS_H
+#define GDI_SW_WINSYS_H
+
+#include "pipe/p_compiler.h"
+#include "state_tracker/sw_winsys.h"
+
+void gdi_sw_display( struct sw_winsys *winsys,
+                     struct sw_displaytarget *dt,
+                     HDC hDC );
+
+struct sw_winsys *
+gdi_create_sw_winsys(void);
+
+#endif
diff --git a/src/gallium/winsys/null/Makefile b/src/gallium/winsys/null/Makefile
new file mode 100644 (file)
index 0000000..3a3fb75
--- /dev/null
@@ -0,0 +1,16 @@
+TOP = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = ws_null
+
+LIBRARY_INCLUDES = \
+       -I$(TOP)/src/gallium/include \
+       -I$(TOP)/src/gallium/drivers \
+       -I$(TOP)/src/gallium/auxiliary
+
+C_SOURCES = \
+       null_sw_winsys.c 
+
+include ../../Makefile.template
+
+
diff --git a/src/gallium/winsys/null/SConscript b/src/gallium/winsys/null/SConscript
new file mode 100644 (file)
index 0000000..21837dc
--- /dev/null
@@ -0,0 +1,21 @@
+#######################################################################
+# SConscript for xlib winsys
+
+
+Import('*')
+
+env = env.Clone()
+
+env.Append(CPPPATH = [
+    '#/src/gallium/include',
+    '#/src/gallium/auxiliary',
+    '#/src/gallium/drivers',
+])
+
+ws_null = env.ConvenienceLibrary(
+    target = 'ws_null',
+    source = [
+       'null_sw_winsys.c',
+    ]
+)
+Export('ws_null')
diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/null/null_sw_winsys.c
new file mode 100644 (file)
index 0000000..d961d34
--- /dev/null
@@ -0,0 +1,124 @@
+/**************************************************************************
+ * 
+ * Copyright 2010 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 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.
+ * 
+ **************************************************************************/
+
+/**
+ * @file
+ * Null software rasterizer winsys.
+ * 
+ * There is no present support. Framebuffer data needs to be obtained via
+ * transfers.
+ *
+ * @author Jose Fonseca
+ */
+
+
+#include "pipe/p_format.h"
+#include "util/u_memory.h"
+#include "state_tracker/sw_winsys.h"
+#include "null_sw_winsys.h"
+
+
+static boolean
+null_sw_is_displaytarget_format_supported(struct sw_winsys *ws,
+                                          enum pipe_format format )
+{
+   return FALSE;
+}
+
+
+static void *
+null_sw_displaytarget_map(struct sw_winsys *ws,
+                          struct sw_displaytarget *dt,
+                          unsigned flags )
+{
+   assert(0);
+   return NULL;
+}
+
+
+static void
+null_sw_displaytarget_unmap(struct sw_winsys *ws,
+                            struct sw_displaytarget *dt )
+{
+   assert(0);
+}
+
+
+static void
+null_sw_displaytarget_destroy(struct sw_winsys *winsys,
+                              struct sw_displaytarget *dt)
+{
+   assert(0);
+}
+
+
+static struct sw_displaytarget *
+null_sw_displaytarget_create(struct sw_winsys *winsys,
+                             enum pipe_format format,
+                             unsigned width, unsigned height,
+                             unsigned alignment,
+                             unsigned *stride)
+{
+   return NULL;
+}
+
+
+static void
+null_sw_displaytarget_display(struct sw_winsys *winsys,
+                              struct sw_displaytarget *dt,
+                              void *context_private)
+{
+   assert(0);
+}
+
+
+static void
+null_sw_destroy(struct sw_winsys *winsys)
+{
+   FREE(winsys);
+}
+
+
+struct sw_winsys *
+null_sw_create(void)
+{
+   static struct sw_winsys *winsys;
+
+   winsys = CALLOC_STRUCT(sw_winsys);
+   if (!winsys)
+      return NULL;
+
+   winsys->destroy = null_sw_destroy;
+   winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported;
+   winsys->displaytarget_create = null_sw_displaytarget_create;
+   winsys->displaytarget_map = null_sw_displaytarget_map;
+   winsys->displaytarget_unmap = null_sw_displaytarget_unmap;
+   winsys->displaytarget_display = null_sw_displaytarget_display;
+   winsys->displaytarget_destroy = null_sw_displaytarget_destroy;
+
+   return winsys;
+}
diff --git a/src/gallium/winsys/null/null_sw_winsys.h b/src/gallium/winsys/null/null_sw_winsys.h
new file mode 100644 (file)
index 0000000..1986186
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ *
+ * Copyright 2010 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 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.
+ *
+ **************************************************************************/
+
+
+#ifndef NULL_SW_WINSYS_H_
+#define NULL_SW_WINSYS_H_
+
+
+struct sw_winsys;
+
+
+struct sw_winsys *
+null_sw_create(void);
+
+
+#endif /* NULL_SW_WINSYS_H_ */
index 824c666ae30c74da903fc99ff80282f08a8994d4..68542b488df25f3e59bc1a9f9e9e41518d092394 100644 (file)
-# 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 = \
-       xlib.c \
-       xlib_cell.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
+C_SOURCES = \
+       xlib_sw_winsys.c 
 
-clean:
-       -rm -f *.o
+include ../../Makefile.template
 
 
-include depend
index 8c9d318af2b91cab14ef3d0990681323ccb7580e..2af6153b4c7f31864eb4babb2b7b5d2c1aca6e51 100644 (file)
@@ -1,64 +1,23 @@
 #######################################################################
 # 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',
-]
+Import('*')
 
-drivers = [trace]
-    
-if 'softpipe' in env['drivers']:
-    env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
-    sources += ['xlib_softpipe.c']
-    drivers += [softpipe]
+if env['platform'] == 'linux':
 
-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]
+    env = env.Clone()
 
-# 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'],
-)
+    env.Append(CPPPATH = [
+        '#/src/gallium/include',
+        '#/src/gallium/auxiliary',
+        '#/src/gallium/drivers',
+    ])
 
-if not env['dri']:
-    # Only install this libGL.so if DRI not enabled
-    env.InstallSharedLibrary(libgl, version=(1, 5))
+    ws_xlib = env.ConvenienceLibrary(
+        target = 'ws_xlib',
+        source = [
+           'xlib_sw_winsys.c',
+        ]
+    )
+    Export('ws_xlib')
diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c
deleted file mode 100644 (file)
index 67617a4..0000000
+++ /dev/null
@@ -1,138 +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
- */
-
-#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_CELL,
-   MODE_LLVMPIPE,
-   MODE_SOFTPIPE
-};
-
-/* advertise OpenGL support */
-PUBLIC const int st_api_OpenGL = 1;
-
-static enum mode get_mode()
-{
-#ifdef GALLIUM_CELL
-   if (!getenv("GALLIUM_NOCELL")) 
-      return MODE_CELL;
-#endif
-
-#if defined(GALLIUM_LLVMPIPE)
-   return MODE_LLVMPIPE;
-#else
-   return MODE_SOFTPIPE;
-#endif
-}
-
-static void _init( void ) __attribute__((constructor));
-
-static void _init( void )
-{
-   enum mode xlib_mode = get_mode();
-
-   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 );
-#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);
-}
-
-
-/**
- * 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
deleted file mode 100644 (file)
index 8e091d0..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-
-#ifndef XLIB_H
-#define XLIB_H
-
-#include "pipe/p_compiler.h"
-#include "xm_winsys.h"
-
-extern struct xm_driver xlib_softpipe_driver;
-extern struct xm_driver xlib_llvmpipe_driver;
-extern struct xm_driver xlib_cell_driver;
-
-
-#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 (file)
index 22bf41a..0000000
+++ /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
deleted file mode 100644 (file)
index 1dc9e8f..0000000
+++ /dev/null
@@ -1,401 +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 "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;
-}
-
-
-/* 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) {
-      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(
-      cell_texture(surf->texture)->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;
-   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 )
-{
-   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;
-}
-
-
-
-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
diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c
deleted file mode 100644 (file)
index 6cebd4c..0000000
+++ /dev/null
@@ -1,442 +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
- */
-
-
-#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;
-}
-
-
-static struct pipe_screen *
-xlib_create_llvmpipe_screen( void )
-{
-   struct llvmpipe_winsys *winsys;
-   struct pipe_screen *screen;
-
-   winsys = xlib_create_llvmpipe_winsys();
-   if (winsys == NULL)
-      return NULL;
-
-   screen = llvmpipe_create_screen(winsys);
-   if (screen == NULL)
-      goto fail;
-
-   return screen;
-
-fail:
-   if (winsys)
-      winsys->destroy( winsys );
-
-   return NULL;
-}
-
-
-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
-};
-
-
-
-#endif /* GALLIUM_LLVMPIPE */
diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c
deleted file mode 100644 (file)
index 716338a..0000000
+++ /dev/null
@@ -1,508 +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 "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;
-}
-
-
-static struct pipe_screen *
-xlib_create_softpipe_screen( void )
-{
-   struct pipe_winsys *winsys;
-   struct pipe_screen *screen;
-
-   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;
-}
-
-
-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 (file)
index 0000000..0ee5899
--- /dev/null
@@ -0,0 +1,445 @@
+/**************************************************************************
+ * 
+ * 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 <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;
+   GC gc;
+
+   /* This is the last drawable that this display target was presented
+    * against.  May need to recreate gc, tempImage when this changes??
+    */
+   Drawable drawable;
+
+   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
+ */
+
+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;
+}
+
+
+static void
+alloc_ximage(struct xm_displaytarget *xm_dt,
+             struct xlib_drawable *xmb,
+             unsigned width, unsigned height)
+{
+   if (xm_dt->shm) {
+      alloc_shm_ximage(xm_dt, xmb, width, height);
+      return;
+   }
+
+   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) {
+      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 {
+         FREE(xm_dt->data);
+      }
+   }
+
+   if (xm_dt->tempImage)
+      XDestroyImage(xm_dt->tempImage);
+
+   if (xm_dt->gc)
+      XFreeGC(xm_dt->display, xm_dt->gc);
+
+   FREE(xm_dt);
+}
+
+
+/**
+ * Display/copy the image in the surface into the X window specified
+ * by the XMesaBuffer.
+ */
+static void
+xlib_sw_display(struct xlib_drawable *xlib_drawable,
+                struct sw_displaytarget *dt)
+{
+   static boolean no_swap = 0;
+   static boolean firsttime = 1;
+   struct xm_displaytarget *xm_dt = xm_displaytarget(dt);
+   Display *display = xm_dt->display;
+   XImage *ximage;
+
+   if (firsttime) {
+      no_swap = getenv("SP_NO_RAST") != NULL;
+      firsttime = 0;
+   }
+
+   if (no_swap)
+      return;
+
+   if (xm_dt->drawable != xlib_drawable->drawable) {
+      if (xm_dt->gc) {
+         XFreeGC( display, xm_dt->gc );
+         xm_dt->gc = NULL;
+      }
+
+      if (xm_dt->tempImage) {
+         XDestroyImage( xm_dt->tempImage );
+         xm_dt->tempImage = NULL;
+      }
+
+      xm_dt->drawable = xlib_drawable->drawable;
+   }
+
+   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;
+   }
+
+   if (xm_dt->gc == NULL) {
+      xm_dt->gc = XCreateGC( display, xlib_drawable->drawable, 0, NULL );
+      XSetFunction( display, xm_dt->gc, GXcopy );
+   }
+
+   if (xm_dt->shm)
+   {
+      ximage = xm_dt->tempImage;
+      ximage->data = xm_dt->data;
+
+      /* _debug_printf("XSHM\n"); */
+      XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc,
+                   ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False);
+   }
+   else {
+      /* 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, xm_dt->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;
+
+   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;
+   }
+
+   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 (file)
index 98139af..0000000
+++ /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 (file)
index 865bab4..0000000
+++ /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