summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2007-08-10 15:31:26 +0100
committerKeith Whitwell <[email protected]>2007-08-10 15:35:48 +0100
commit47fc2c4349746997704a7f81dffadd22363e0ff1 (patch)
treeda53b452a03ad6909a1b9b95db565fa7a73a511e /src/mesa/pipe/softpipe
parent12e3bb1a65bbff82dabc64110249c57a711501c1 (diff)
Lift common winsys functions into pipe's new p_winsys.
Diffstat (limited to 'src/mesa/pipe/softpipe')
-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
8 files changed, 24 insertions, 265 deletions
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index ac83da451d1..615c612e9c7 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 27443421a30..00000000000
--- 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 9805c5142ad..00000000000
--- 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 db572f169d8..91b8ae50865 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 a0bce200ed9..cdf4a53c837 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 03c00106230..34ec617866b 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 142d121047b..115f3ab8260 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 73b06590671..726e4c8bb6b 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 */