summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2007-08-10 15:31:26 +0100
committerKeith Whitwell <keith@tungstengraphics.com>2007-08-10 15:35:48 +0100
commit47fc2c4349746997704a7f81dffadd22363e0ff1 (patch)
treeda53b452a03ad6909a1b9b95db565fa7a73a511e /src/mesa/pipe
parent12e3bb1a65bbff82dabc64110249c57a711501c1 (diff)
Lift common winsys functions into pipe's new p_winsys.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/i915simple/Makefile1
-rw-r--r--src/mesa/pipe/i915simple/i915_buffer.c121
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c17
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h3
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.h10
-rw-r--r--src/mesa/pipe/i915simple/i915_debug_fp.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c7
-rw-r--r--src/mesa/pipe/i915simple/i915_regions.c26
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h58
-rw-r--r--src/mesa/pipe/p_context.h47
-rw-r--r--src/mesa/pipe/p_winsys.h114
-rw-r--r--src/mesa/pipe/softpipe/Makefile1
-rw-r--r--src/mesa/pipe/softpipe/sp_buffer.c120
-rw-r--r--src/mesa/pipe/softpipe/sp_buffer.h40
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c9
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.c19
-rw-r--r--src/mesa/pipe/softpipe/sp_flush.h1
-rw-r--r--src/mesa/pipe/softpipe/sp_region.c23
-rw-r--r--src/mesa/pipe/softpipe/sp_winsys.h76
21 files changed, 179 insertions, 520 deletions
diff --git a/src/mesa/pipe/i915simple/Makefile b/src/mesa/pipe/i915simple/Makefile
index 5b919e3bed..28fe70d069 100644
--- a/src/mesa/pipe/i915simple/Makefile
+++ b/src/mesa/pipe/i915simple/Makefile
@@ -6,7 +6,6 @@ LIBNAME = i915simple
DRIVER_SOURCES = \
i915_blit.c \
- i915_buffer.c \
i915_clear.c \
i915_flush.c \
i915_context.c \
diff --git a/src/mesa/pipe/i915simple/i915_buffer.c b/src/mesa/pipe/i915simple/i915_buffer.c
deleted file mode 100644
index 680213182b..0000000000
--- a/src/mesa/pipe/i915simple/i915_buffer.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 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 <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <stdlib.h>
-#include "i915_context.h"
-#include "i915_winsys.h"
-
-
-
-/* Most callbacks map direcly onto winsys operations at the moment,
- * but this may change, especially as state_trackers and winsys's
- * evolve in separate directions... Don't try and remove this yet.
- */
-static struct pipe_buffer_handle *
-i915_buffer_create(struct pipe_context *pipe,
- unsigned alignment,
- unsigned flags)
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_create( i915->winsys, alignment );
-}
-
-static void *i915_buffer_map(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned flags )
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_map( i915->winsys, buf );
-}
-
-static void i915_buffer_unmap(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_unmap( i915->winsys, buf );
-}
-
-static struct pipe_buffer_handle *
-i915_buffer_reference(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_reference( i915->winsys, buf );
-}
-
-static void i915_buffer_unreference(struct pipe_context *pipe,
- struct pipe_buffer_handle **buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_unreference( i915->winsys, buf );
-}
-
-static void i915_buffer_data(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_data( i915->winsys, buf, size, data );
-}
-
-static void i915_buffer_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_subdata( i915->winsys, buf, offset, size, data );
-}
-
-static void i915_buffer_get_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_get_subdata( i915->winsys, buf, offset, size, data );
-}
-
-
-void
-i915_init_buffer_functions( struct i915_context *i915 )
-{
- i915->pipe.create_buffer = i915_buffer_create;
- i915->pipe.buffer_map = i915_buffer_map;
- i915->pipe.buffer_unmap = i915_buffer_unmap;
- i915->pipe.buffer_reference = i915_buffer_reference;
- i915->pipe.buffer_unreference = i915_buffer_unreference;
- i915->pipe.buffer_data = i915_buffer_data;
- i915->pipe.buffer_subdata = i915_buffer_subdata;
- i915->pipe.buffer_get_subdata = i915_buffer_get_subdata;
-}
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index d8e54f02ee..ee6cfe2ed4 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -29,10 +29,12 @@
#include "i915_context.h"
#include "i915_winsys.h"
#include "i915_state.h"
+#include "i915_batch.h"
#include "i915_tex_layout.h"
#include "pipe/draw/draw_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#define PCI_CHIP_I915_G 0x2582
#define PCI_CHIP_I915_GM 0x2592
@@ -152,7 +154,8 @@ i915_draw_vertices(struct pipe_context *pipe,
-struct pipe_context *i915_create( struct i915_winsys *winsys,
+struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
+ struct i915_winsys *i915_winsys,
unsigned pci_id )
{
struct i915_context *i915;
@@ -175,8 +178,9 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
break;
default:
- winsys->printf(winsys, "%s: unknown pci id 0x%x, cannot create context\n",
- __FUNCTION__, pci_id);
+ pipe_winsys->printf(pipe_winsys,
+ "%s: unknown pci id 0x%x, cannot create context\n",
+ __FUNCTION__, pci_id);
return NULL;
}
@@ -184,6 +188,9 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
if (i915 == NULL)
return NULL;
+ i915->winsys = i915_winsys;
+ i915->pipe.winsys = pipe_winsys;
+
i915->pipe.destroy = i915_destroy;
i915->pipe.supported_formats = i915_supported_formats;
i915->pipe.draw_vb = i915_draw_vb;
@@ -192,7 +199,6 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
i915->pipe.reset_occlusion_counter = NULL; /* no support */
i915->pipe.get_occlusion_counter = NULL;
- i915->winsys = winsys;
/*
* Create drawing context and plug our rendering stage into it.
@@ -201,7 +207,6 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
assert(i915->draw);
draw_set_setup_stage(i915->draw, i915_draw_render_stage(i915));
- i915_init_buffer_functions(i915);
i915_init_region_functions(i915);
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
@@ -219,7 +224,7 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
/* Batch stream debugging is a bit hacked up at the moment:
*/
- i915->batch_start = winsys->batch_start( winsys, 0, 0 );
+ i915->batch_start = BEGIN_BATCH(0, 0);
/*
* XXX we could plug GL selection/feedback into the drawing pipeline
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index e8db2b7c36..7a73a8d8d0 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -182,9 +182,8 @@ void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
/***********************************************************************
- * i915_buffer.c:
+ * i915_region.c:
*/
-void i915_init_buffer_functions( struct i915_context *i915 );
void i915_init_region_functions( struct i915_context *i915 );
void i915_init_surface_functions( struct i915_context *i915 );
void i915_init_state_functions( struct i915_context *i915 );
diff --git a/src/mesa/pipe/i915simple/i915_debug.c b/src/mesa/pipe/i915simple/i915_debug.c
index 0ea6f03e49..8050eb0bf5 100644
--- a/src/mesa/pipe/i915simple/i915_debug.c
+++ b/src/mesa/pipe/i915simple/i915_debug.c
@@ -423,7 +423,7 @@ i915_dump_batchbuffer( struct i915_context *i915,
stream.offset = 0;
stream.ptr = (char *)start;
stream.print_addresses = 0;
- stream.winsys = i915->winsys;
+ stream.winsys = i915->pipe.winsys;
while (!done &&
stream.offset < bytes &&
diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h
index f0f72780d3..0ea131171e 100644
--- a/src/mesa/pipe/i915simple/i915_debug.h
+++ b/src/mesa/pipe/i915simple/i915_debug.h
@@ -39,7 +39,7 @@ struct debug_stream
char *ptr; /* pointer to gtt offset zero */
char *end; /* pointer to gtt offset zero */
unsigned print_addresses;
- struct i915_winsys *winsys;
+ struct pipe_winsys *winsys;
};
@@ -68,9 +68,11 @@ void i915_print_ureg(const char *msg, unsigned ureg);
#define DEBUG_WINSYS 0x4000
#ifdef DEBUG
-#include "i915_winsys.h"
-#define DBG( i915, ... ) \
- if ((i915)->debug & FILE_DEBUG_FLAG) (i915)->winsys->printf( (i915)->winsys, __VA_ARGS__ )
+#include "pipe/p_winsys.h"
+#define DBG( i915, ... ) do { \
+ if ((i915)->debug & FILE_DEBUG_FLAG) \
+ (i915)->pipe.winsys->printf( (i915)->pipe.winsys, __VA_ARGS__ ); \
+} while(0)
#else
#define DBG( i915, ... ) \
(void)i915
diff --git a/src/mesa/pipe/i915simple/i915_debug_fp.c b/src/mesa/pipe/i915simple/i915_debug_fp.c
index 95476d3c55..d99c609d48 100644
--- a/src/mesa/pipe/i915simple/i915_debug_fp.c
+++ b/src/mesa/pipe/i915simple/i915_debug_fp.c
@@ -29,7 +29,7 @@
#include "i915_reg.h"
#include "i915_debug.h"
-#include "i915_winsys.h"
+#include "pipe/p_winsys.h"
//#include "i915_fpc.h"
#include "shader/program.h"
#include "shader/prog_instruction.h"
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
index 8af4ce770c..9a31342cbd 100644
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ b/src/mesa/pipe/i915simple/i915_flush.c
@@ -66,16 +66,9 @@ static void i915_flush( struct pipe_context *pipe,
FLUSH_BATCH();
}
-static void i915_wait_idle(struct pipe_context *pipe)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->winsys->batch_wait_idle( i915->winsys );
-}
void i915_init_flush_functions( struct i915_context *i915 )
{
i915->pipe.flush = i915_flush;
- i915->pipe.wait_idle = i915_wait_idle;
}
diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c
index 886b089506..9b7cddb58d 100644
--- a/src/mesa/pipe/i915simple/i915_regions.c
+++ b/src/mesa/pipe/i915simple/i915_regions.c
@@ -32,8 +32,8 @@
*/
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_blit.h"
@@ -50,8 +50,10 @@ i915_region_map(struct pipe_context *pipe, struct pipe_region *region)
struct i915_context *i915 = i915_context( pipe );
if (!region->map_refcount++) {
- region->map = i915->winsys->buffer_map( i915->winsys,
- region->buffer );
+ region->map = i915->pipe.winsys->buffer_map( i915->pipe.winsys,
+ region->buffer,
+ PIPE_BUFFER_FLAG_WRITE |
+ PIPE_BUFFER_FLAG_READ);
}
return region->map;
@@ -63,8 +65,8 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
struct i915_context *i915 = i915_context( pipe );
if (!--region->map_refcount) {
- i915->winsys->buffer_unmap( i915->winsys,
- region->buffer );
+ i915->pipe.winsys->buffer_unmap( i915->pipe.winsys,
+ region->buffer );
region->map = NULL;
}
}
@@ -97,12 +99,12 @@ i915_region_alloc(struct pipe_context *pipe,
region->height = height; /* needed? */
region->refcount = 1;
- region->buffer = i915->winsys->buffer_create( i915->winsys, alignment );
+ region->buffer = i915->pipe.winsys->buffer_create( i915->pipe.winsys, alignment );
- i915->winsys->buffer_data( i915->winsys,
- region->buffer,
- pitch * cpp * height,
- NULL );
+ i915->pipe.winsys->buffer_data( i915->pipe.winsys,
+ region->buffer,
+ pitch * cpp * height,
+ NULL );
return region;
}
@@ -121,8 +123,8 @@ i915_region_release(struct pipe_context *pipe, struct pipe_region **region)
if ((*region)->refcount == 0) {
assert((*region)->map_refcount == 0);
- i915->winsys->buffer_unreference( i915->winsys,
- (*region)->buffer );
+ i915->pipe.winsys->buffer_unreference( i915->pipe.winsys,
+ (*region)->buffer );
free(*region);
}
*region = NULL;
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index ab00cbc822..22a5bf68b4 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -148,7 +148,7 @@ static void i915_set_texture_state(struct pipe_context *pipe,
static void i915_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
+ const struct pipe_framebuffer_state *fb)
{
struct i915_context *i915 = i915_context(pipe);
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
index a3dadbfd3d..803ee9073c 100644
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ b/src/mesa/pipe/i915simple/i915_winsys.h
@@ -47,57 +47,10 @@
*/
struct pipe_buffer_handle;
+struct pipe_winsys;
struct i915_winsys {
- /* Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct i915_winsys *sws );
-
-
- /* debug output
- */
- void (*printf)( struct i915_winsys *sws,
- const char *, ... );
-
- /* Many of the winsys's are probably going to have a similar
- * buffer-manager interface, as something almost identical is
- * currently exposed in the pipe interface. Probably want to avoid
- * endless repetition of this code somehow.
- */
- struct pipe_buffer_handle *(*buffer_create)(struct i915_winsys *sws,
- unsigned alignment );
-
- void *(*buffer_map)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unmap)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- struct pipe_buffer_handle *(*buffer_reference)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unreference)( struct i915_winsys *sws,
- struct pipe_buffer_handle **buf );
-
- void (*buffer_data)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data );
-
- void (*buffer_subdata)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- void (*buffer_get_subdata)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
-
-
/* An over-simple batchbuffer mechanism. Will want to improve the
* performance of this, perhaps based on the cmdstream stuff. It
* would be pretty impossible to implement swz on top of this
@@ -116,20 +69,15 @@ struct i915_winsys {
unsigned access_flags,
unsigned delta );
void (*batch_flush)( struct i915_winsys *sws );
- void (*batch_wait_idle)( struct i915_winsys *sws );
-
- /* Printf???
- */
- void (*dpf)( const char *fmt, ... );
-
};
#define I915_BUFFER_ACCESS_WRITE 0x1
#define I915_BUFFER_ACCESS_READ 0x2
-struct pipe_context *i915_create( struct i915_winsys *,
+struct pipe_context *i915_create( struct pipe_winsys *,
+ struct i915_winsys *,
unsigned pci_id );
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 533840c555..89d9b36af7 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -42,7 +42,8 @@ struct vertex_buffer;
* state setting functions, plus VBO drawing entrypoint.
*/
struct pipe_context {
-
+ struct pipe_winsys *winsys;
+
void (*destroy)( struct pipe_context * );
/*
@@ -175,44 +176,6 @@ struct pipe_context {
GLuint value);
- /* Buffer management functions need to be exposed as well. A pipe
- * buffer may be used as a texture, render target or vertex/index
- * buffer, or some combination according to flags.
- */
-
- struct pipe_buffer_handle *(*create_buffer)(struct pipe_context *pipe,
- unsigned alignment,
- unsigned flags );
-
- void *(*buffer_map)( struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned flags );
-
- void (*buffer_unmap)( struct pipe_context *pipe,
- struct pipe_buffer_handle *buf );
-
- struct pipe_buffer_handle *(*buffer_reference)( struct pipe_context *pipe,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unreference)( struct pipe_context *pipe,
- struct pipe_buffer_handle **buf );
-
- void (*buffer_data)(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data );
-
- void (*buffer_subdata)(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- void (*buffer_get_subdata)(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
-
/*
* Texture functions
*/
@@ -220,14 +183,10 @@ struct pipe_context {
struct pipe_mipmap_tree *mt );
- /* Simple flush/finish support:
+ /* Flush rendering:
*/
void (*flush)( struct pipe_context *pipe,
unsigned flags );
-
- void (*wait_idle)( struct pipe_context *pipe );
-
- void (*flush_frontbuffer)( struct pipe_context *pipe );
};
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
new file mode 100644
index 0000000000..c455ebdbbe
--- /dev/null
+++ b/src/mesa/pipe/p_winsys.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+ *
+ * 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 P_WINSYS_H
+#define P_WINSYS_H
+
+#include "main/mtypes.h"
+
+/* 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.
+ */
+
+
+/* Pipe drivers are (meant to be!) independent of both GL and the
+ * window system. The window system provides a buffer manager and a
+ * set of additional hooks for things like command buffer submission,
+ * etc.
+ *
+ * There clearly has to be some agreement between the window system
+ * driver and the hardware driver about the format of command buffers,
+ * etc.
+ */
+
+struct pipe_buffer_handle;
+
+struct pipe_winsys {
+
+ /* Do any special operations to ensure frontbuffer contents are
+ * displayed, eg copy fake frontbuffer.
+ */
+ void (*flush_frontbuffer)( struct pipe_winsys *sws );
+
+ /* debug output
+ */
+ void (*printf)( struct pipe_winsys *sws,
+ const char *, ... );
+
+
+ /* The buffer manager is modeled after the dri_bugmgr interface,
+ * but this is the subset that softpipe cares about. Remember that
+ * softpipe gets to choose the interface it needs, and the window
+ * systems must then implement that interface (rather than the
+ * other way around...).
+ *
+ * Softpipe only really wants to make system memory allocations,
+ * right??
+ */
+ struct pipe_buffer_handle *(*buffer_create)(struct pipe_winsys *sws,
+ unsigned alignment );
+
+ void *(*buffer_map)( struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned flags );
+
+ void (*buffer_unmap)( struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf );
+
+ struct pipe_buffer_handle *(*buffer_reference)( struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf );
+
+ void (*buffer_unreference)( struct pipe_winsys *sws,
+ struct pipe_buffer_handle **buf );
+
+ void (*buffer_data)(struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned size, const void *data );
+
+ void (*buffer_subdata)(struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ const void *data);
+
+ void (*buffer_get_subdata)(struct pipe_winsys *sws,
+ struct pipe_buffer_handle *buf,
+ unsigned long offset,
+ unsigned long size,
+ void *data);
+
+
+ /* Wait for any hw swapbuffers, etc. to finish:
+ */
+ void (*wait_idle)( struct pipe_winsys *sws );
+
+};
+
+
+
+#endif /* SP_WINSYS_H */
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index ac83da451d..615c612e9c 100644
--- a/src/mesa/pipe/softpipe/Makefile
+++ b/src/mesa/pipe/softpipe/Makefile
@@ -5,7 +5,6 @@ include $(TOP)/configs/current
LIBNAME = softpipe
DRIVER_SOURCES = \
- sp_buffer.c \
sp_clear.c \
sp_flush.c \
sp_context.c \
diff --git a/src/mesa/pipe/softpipe/sp_buffer.c b/src/mesa/pipe/softpipe/sp_buffer.c
deleted file mode 100644
index 27443421a3..0000000000
--- a/src/mesa/pipe/softpipe/sp_buffer.c
+++ /dev/null
@@ -1,120 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 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 <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <stdlib.h>
-#include "sp_context.h"
-#include "sp_winsys.h"
-#include "sp_buffer.h"
-
-
-
-/* Most callbacks map direcly onto winsys operations:
- */
-static struct pipe_buffer_handle *
-sp_create_buffer(struct pipe_context *pipe,
- unsigned alignment,
- unsigned flags)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- return sp->winsys->create_buffer( sp->winsys, alignment );
-}
-
-static void *sp_buffer_map(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned flags )
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- return sp->winsys->buffer_map( sp->winsys, buf );
-}
-
-static void sp_buffer_unmap(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- sp->winsys->buffer_unmap( sp->winsys, buf );
-}
-
-static struct pipe_buffer_handle *
-sp_buffer_reference(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- return sp->winsys->buffer_reference( sp->winsys, buf );
-}
-
-static void sp_buffer_unreference(struct pipe_context *pipe,
- struct pipe_buffer_handle **buf)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- sp->winsys->buffer_unreference( sp->winsys, buf );
-}
-
-static void sp_buffer_data(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- sp->winsys->buffer_data( sp->winsys, buf, size, data );
-}
-
-static void sp_buffer_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- sp->winsys->buffer_subdata( sp->winsys, buf, offset, size, data );
-}
-
-static void sp_buffer_get_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- struct softpipe_context *sp = softpipe_context( pipe );
- sp->winsys->buffer_get_subdata( sp->winsys, buf, offset, size, data );
-}
-
-
-void
-sp_init_buffer_functions( struct softpipe_context *sp )
-{
- sp->pipe.create_buffer = sp_create_buffer;
- sp->pipe.buffer_map = sp_buffer_map;
- sp->pipe.buffer_unmap = sp_buffer_unmap;
- sp->pipe.buffer_reference = sp_buffer_reference;
- sp->pipe.buffer_unreference = sp_buffer_unreference;
- sp->pipe.buffer_data = sp_buffer_data;
- sp->pipe.buffer_subdata = sp_buffer_subdata;
- sp->pipe.buffer_get_subdata = sp_buffer_get_subdata;
-}
diff --git a/src/mesa/pipe/softpipe/sp_buffer.h b/src/mesa/pipe/softpipe/sp_buffer.h
deleted file mode 100644
index 9805c5142a..0000000000
--- a/src/mesa/pipe/softpipe/sp_buffer.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef SP_BUFFER_H
-#define SP_BUFFER_H
-
-
-struct softpipe_context;
-
-
-extern void
-sp_init_buffer_functions(struct softpipe_context *sp);
-
-
-#endif /* SP_BUFFER_H */
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index db572f169d..91b8ae5086 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -33,7 +33,6 @@
#include "main/macros.h"
#include "pipe/draw/draw_context.h"
#include "pipe/p_defines.h"
-#include "sp_buffer.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
@@ -194,10 +193,12 @@ static GLuint softpipe_get_occlusion_counter(struct pipe_context *pipe)
}
-struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
+struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
+ struct softpipe_winsys *softpipe_winsys )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
+ softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.destroy = softpipe_destroy;
softpipe->pipe.supported_formats = softpipe_supported_formats;
@@ -221,7 +222,6 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
softpipe->pipe.draw_vertices = softpipe_draw_vertices;
softpipe->pipe.clear = softpipe_clear;
softpipe->pipe.flush = softpipe_flush;
- softpipe->pipe.wait_idle = softpipe_wait_idle;
softpipe->pipe.reset_occlusion_counter = softpipe_reset_occlusion_counter;
softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter;
@@ -240,7 +240,7 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
softpipe->quad.colormask = sp_quad_colormask_stage(softpipe);
softpipe->quad.output = sp_quad_output_stage(softpipe);
- softpipe->winsys = sws;
+ softpipe->winsys = softpipe_winsys;
/*
* Create drawing context and plug our rendering stage into it.
@@ -249,7 +249,6 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
assert(softpipe->draw);
draw_set_setup_stage(softpipe->draw, sp_draw_render_stage(softpipe));
- sp_init_buffer_functions(softpipe);
sp_init_region_functions(softpipe);
sp_init_surface_functions(softpipe);
diff --git a/src/mesa/pipe/softpipe/sp_flush.c b/src/mesa/pipe/softpipe/sp_flush.c
index a0bce200ed..cdf4a53c83 100644
--- a/src/mesa/pipe/softpipe/sp_flush.c
+++ b/src/mesa/pipe/softpipe/sp_flush.c
@@ -49,22 +49,3 @@ softpipe_flush( struct pipe_context *pipe,
*/
}
-void
-softpipe_wait_idle(struct pipe_context *pipe)
-{
- /* Nothing to do.
- * XXX: What about swapbuffers.
- * XXX: Even more so - what about fake frontbuffer copies??
- */
- struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->winsys->wait_idle( softpipe->winsys );
-}
-
-
-void
-softpipe_flush_frontbuffer( struct pipe_context *pipe )
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
-
- softpipe->winsys->flush_frontbuffer( softpipe->winsys );
-}
diff --git a/src/mesa/pipe/softpipe/sp_flush.h b/src/mesa/pipe/softpipe/sp_flush.h
index 03c0010623..34ec617866 100644
--- a/src/mesa/pipe/softpipe/sp_flush.h
+++ b/src/mesa/pipe/softpipe/sp_flush.h
@@ -31,6 +31,5 @@
struct pipe_context;
void softpipe_flush(struct pipe_context *pipe, unsigned flags );
-void softpipe_wait_idle(struct pipe_context *pipe);
#endif
diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c
index 142d121047..115f3ab826 100644
--- a/src/mesa/pipe/softpipe/sp_region.c
+++ b/src/mesa/pipe/softpipe/sp_region.c
@@ -32,8 +32,9 @@
*/
#include "sp_context.h"
-#include "sp_winsys.h"
#include "sp_region.h"
+#include "pipe/p_winsys.h"
+#include "pipe/p_defines.h"
/**
@@ -59,8 +60,10 @@ sp_region_map(struct pipe_context *pipe, struct pipe_region *region)
struct softpipe_context *sp = softpipe_context( pipe );
if (!region->map_refcount++) {
- region->map = sp->winsys->buffer_map( sp->winsys,
- region->buffer );
+ region->map = sp->pipe.winsys->buffer_map( sp->pipe.winsys,
+ region->buffer,
+ PIPE_BUFFER_FLAG_WRITE |
+ PIPE_BUFFER_FLAG_READ);
}
return region->map;
@@ -72,7 +75,7 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
struct softpipe_context *sp = softpipe_context( pipe );
if (!--region->map_refcount) {
- sp->winsys->buffer_unmap( sp->winsys,
+ sp->pipe.winsys->buffer_unmap( sp->pipe.winsys,
region->buffer );
region->map = NULL;
}
@@ -91,13 +94,13 @@ sp_region_alloc(struct pipe_context *pipe,
region->height = height;
region->refcount = 1;
- region->buffer = sp->winsys->create_buffer( sp->winsys, alignment );
+ region->buffer = sp->pipe.winsys->buffer_create( sp->pipe.winsys, alignment );
/* NULL data --> just allocate the space */
- sp->winsys->buffer_data( sp->winsys,
- region->buffer,
- region->pitch * cpp * height,
- NULL );
+ sp->pipe.winsys->buffer_data( sp->pipe.winsys,
+ region->buffer,
+ region->pitch * cpp * height,
+ NULL );
return region;
}
@@ -115,7 +118,7 @@ sp_region_release(struct pipe_context *pipe, struct pipe_region **region)
if ((*region)->refcount == 0) {
assert((*region)->map_refcount == 0);
- sp->winsys->buffer_unreference( sp->winsys,
+ sp->pipe.winsys->buffer_unreference( sp->pipe.winsys,
(*region)->buffer );
free(*region);
}
diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h
index 73b0659067..726e4c8bb6 100644
--- a/src/mesa/pipe/softpipe/sp_winsys.h
+++ b/src/mesa/pipe/softpipe/sp_winsys.h
@@ -28,86 +28,24 @@
#ifndef SP_WINSYS_H
#define SP_WINSYS_H
-#include "main/mtypes.h"
/* 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.
*/
-
-/* Pipe drivers are (meant to be!) independent of both GL and the
- * window system. The window system provides a buffer manager and a
- * set of additional hooks for things like command buffer submission,
- * etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-
-struct pipe_buffer_handle;
-
struct softpipe_winsys {
+ const unsigned *(*supported_formats)(struct softpipe_winsys *sws,
+ unsigned *numFormats);
- /* Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct softpipe_winsys *sws );
-
- /* Wait for any hw swapbuffers, etc. to finish:
- */
- void (*wait_idle)( struct softpipe_winsys *sws );
-
- /* debug output
- */
- void (*printf)( struct softpipe_winsys *sws,
- const char *, ... );
-
-
- /* The buffer manager is modeled after the dri_bugmgr interface,
- * but this is the subset that softpipe cares about. Remember that
- * softpipe gets to choose the interface it needs, and the window
- * systems must then implement that interface (rather than the
- * other way around...).
- *
- * Softpipe only really wants to make system memory allocations,
- * right??
- */
- struct pipe_buffer_handle *(*create_buffer)(struct softpipe_winsys *sws,
- unsigned alignment );
-
- void *(*buffer_map)( struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unmap)( struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- struct pipe_buffer_handle *(*buffer_reference)( struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unreference)( struct softpipe_winsys *sws,
- struct pipe_buffer_handle **buf );
-
- void (*buffer_data)(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data );
-
- void (*buffer_subdata)(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- void (*buffer_get_subdata)(struct softpipe_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
};
+struct pipe_winsys;
+struct pipe_context;
+
-struct pipe_context *softpipe_create( struct softpipe_winsys * );
+struct pipe_context *softpipe_create( struct pipe_winsys *,
+ struct softpipe_winsys * );
#endif /* SP_WINSYS_H */