aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2007-08-06 10:15:30 +0100
committerKeith Whitwell <[email protected]>2007-08-06 10:15:30 +0100
commit95794abec4bdc5cda9f2e7d139a70c3acf372fe3 (patch)
tree31b3c2550363639bccd6a8d1e72a860f196800f7 /src/mesa/pipe
parent1d1b9e6be45e75ad12a01c82e3c0d55ff9da4183 (diff)
Add pipe buffer managment functions.
The state_tracker driver needs these to implement, eg. pixel buffer objects, vertex buffer objects.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/Makefile.template1
-rw-r--r--src/mesa/pipe/p_context.h41
-rw-r--r--src/mesa/pipe/p_state.h13
-rw-r--r--src/mesa/pipe/softpipe/Makefile1
-rw-r--r--src/mesa/pipe/softpipe/sp_buffer.c119
-rw-r--r--src/mesa/pipe/softpipe/sp_buffer.h40
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_region.c10
-rw-r--r--src/mesa/pipe/softpipe/sp_winsys.h23
9 files changed, 226 insertions, 24 deletions
diff --git a/src/mesa/pipe/Makefile.template b/src/mesa/pipe/Makefile.template
index 7c64981d7b0..84b4dcd13a8 100644
--- a/src/mesa/pipe/Makefile.template
+++ b/src/mesa/pipe/Makefile.template
@@ -39,6 +39,7 @@ $(LIBNAME): $(OBJECTS) Makefile $(TOP)/src/mesa/pipe/Makefile.template
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+ rm -f depend
touch depend
$(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) \
$(ASM_SOURCES) 2> /dev/null
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 92670c77337..76a25935672 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -169,9 +169,44 @@ struct pipe_context {
GLuint width, GLuint height,
GLuint value);
- struct _DriBufferObject *(*region_buffer)(struct pipe_context *pipe,
- struct pipe_region *region,
- GLuint flag);
+
+ /* 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);
};
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index 3be1010007a..518110d4470 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -292,4 +292,17 @@ struct pipe_texture_object
};
+struct pipe_buffer_handle;
+
+#define PIPE_BUFFER_FLAG_READ 0x1
+#define PIPE_BUFFER_FLAG_WRITE 0x2
+
+#define PIPE_BUFFER_USE_TEXTURE 0x1
+#define PIPE_BUFFER_USE_VERTEX_BUFFER 0x2
+#define PIPE_BUFFER_USE_INDEX_BUFFER 0x4
+#define PIPE_BUFFER_USE_RENDER_TARGET 0x8
+
+
+
+
#endif
diff --git a/src/mesa/pipe/softpipe/Makefile b/src/mesa/pipe/softpipe/Makefile
index 04464154e75..0eacfa2182a 100644
--- a/src/mesa/pipe/softpipe/Makefile
+++ b/src/mesa/pipe/softpipe/Makefile
@@ -5,6 +5,7 @@ include $(TOP)/configs/current
LIBNAME = softpipe
DRIVER_SOURCES = \
+ sp_buffer.c \
sp_clear.c \
sp_context.c \
sp_prim_setup.c \
diff --git a/src/mesa/pipe/softpipe/sp_buffer.c b/src/mesa/pipe/softpipe/sp_buffer.c
new file mode 100644
index 00000000000..f3a47184496
--- /dev/null
+++ b/src/mesa/pipe/softpipe/sp_buffer.c
@@ -0,0 +1,119 @@
+/**************************************************************************
+ *
+ * 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"
+
+
+
+/* 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
new file mode 100644
index 00000000000..9805c5142ad
--- /dev/null
+++ b/src/mesa/pipe/softpipe/sp_buffer.h
@@ -0,0 +1,40 @@
+/**************************************************************************
+ *
+ * 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 22928f7bd64..9352c7afa71 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -36,6 +36,7 @@
#include "sp_context.h"
#include "sp_clear.h"
#include "sp_region.h"
+#include "sp_buffer.h"
#include "sp_state.h"
#include "sp_surface.h"
#include "sp_prim_setup.h"
@@ -219,6 +220,7 @@ 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_region.c b/src/mesa/pipe/softpipe/sp_region.c
index 78a0919ad50..a0ced3eb869 100644
--- a/src/mesa/pipe/softpipe/sp_region.c
+++ b/src/mesa/pipe/softpipe/sp_region.c
@@ -80,7 +80,7 @@ sp_region_alloc(struct pipe_context *pipe,
region->height = height; /* needed? */
region->refcount = 1;
- region->buffer = sp->winsys->create_buffer(sp->winsys, "region", 64 );
+ region->buffer = sp->winsys->create_buffer( sp->winsys, 64 );
sp->winsys->buffer_data( sp->winsys,
region->buffer,
@@ -259,13 +259,6 @@ sp_region_fill(struct pipe_context *pipe,
-static struct _DriBufferObject *
-sp_region_buffer(struct pipe_context *pipe,
- struct pipe_region *region, GLuint flag)
-{
- return region->buffer;
-}
-
void
@@ -279,6 +272,5 @@ sp_init_region_functions(struct softpipe_context *sp)
sp->pipe.region_data = sp_region_data;
sp->pipe.region_copy = sp_region_copy;
sp->pipe.region_fill = sp_region_fill;
- sp->pipe.region_buffer = sp_region_buffer;
}
diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h
index 43953c648ba..bc6db15d326 100644
--- a/src/mesa/pipe/softpipe/sp_winsys.h
+++ b/src/mesa/pipe/softpipe/sp_winsys.h
@@ -46,7 +46,7 @@
* etc.
*/
-struct softpipe_buffer_handle;
+struct pipe_buffer_handle;
struct softpipe_winsys {
@@ -60,34 +60,33 @@ struct softpipe_winsys {
* Softpipe only really wants to make system memory allocations,
* right??
*/
- struct softpipe_buffer_handle *(*create_buffer)(struct softpipe_winsys *sws,
- const char *name,
- unsigned alignment );
+ struct pipe_buffer_handle *(*create_buffer)(struct softpipe_winsys *sws,
+ unsigned alignment );
void *(*buffer_map)( struct softpipe_winsys *sws,
- struct softpipe_buffer_handle *buf );
+ struct pipe_buffer_handle *buf );
void (*buffer_unmap)( struct softpipe_winsys *sws,
- struct softpipe_buffer_handle *buf );
+ struct pipe_buffer_handle *buf );
- struct softpipe_buffer_handle *(*buffer_reference)( struct softpipe_winsys *sws,
- struct softpipe_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 softpipe_buffer_handle *buf );
+ struct pipe_buffer_handle **buf );
void (*buffer_data)(struct softpipe_winsys *sws,
- struct softpipe_buffer_handle *buf,
+ struct pipe_buffer_handle *buf,
unsigned size, const void *data );
void (*buffer_subdata)(struct softpipe_winsys *sws,
- struct softpipe_buffer_handle *buf,
+ struct pipe_buffer_handle *buf,
unsigned long offset,
unsigned long size,
const void *data);
void (*buffer_get_subdata)(struct softpipe_winsys *sws,
- struct softpipe_buffer_handle *buf,
+ struct pipe_buffer_handle *buf,
unsigned long offset,
unsigned long size,
void *data);