summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/pipebuffer
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2008-01-25 20:53:31 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2008-01-25 20:53:31 +0000
commit1e0d30a515e4cac891b6c590f12a33e0e8a8e295 (patch)
tree72ffec9e89bd0bd9202fcfc39f5e7bdf881adcf2 /src/mesa/pipe/pipebuffer
parent756d52ec12c41ee90ee9598dc9028cc134806bd2 (diff)
gallium: rename pipe_buffer_handle to pipe_buffer, rework pipebuffer/ code
Provide an actual definition of the pipe_buffer struct, containing the parameters used to create the buffer, and its refcount. Shift refcounting buffers out of the winsys interface, similar to surfaces & textures. Rework pipebuffer/ to reflect the fact these changes, and also Michel's reworking of the buffer interface.
Diffstat (limited to 'src/mesa/pipe/pipebuffer')
-rw-r--r--src/mesa/pipe/pipebuffer/Makefile2
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.c49
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer.h111
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_client.c60
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.c102
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.h10
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.c140
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_handle.h120
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_malloc.c41
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_null.c98
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr.h24
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c36
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c88
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c75
14 files changed, 289 insertions, 667 deletions
diff --git a/src/mesa/pipe/pipebuffer/Makefile b/src/mesa/pipe/pipebuffer/Makefile
index 061d8a060f..0d23e8b8f1 100644
--- a/src/mesa/pipe/pipebuffer/Makefile
+++ b/src/mesa/pipe/pipebuffer/Makefile
@@ -8,10 +8,8 @@ LIBNAME = pipebuffer
DRIVER_SOURCES = \
pb_buffer.c \
pb_buffer_client.c \
- pb_buffer_handle.c \
pb_buffer_fenced.c \
pb_buffer_malloc.c \
- pb_buffer_null.c \
pb_bufmgr_fenced.c \
pb_bufmgr_mm.c \
pb_bufmgr_pool.c
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.c b/src/mesa/pipe/pipebuffer/pb_buffer.c
index 99c960b697..90ab9044ff 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.c
@@ -34,19 +34,44 @@
#include "pb_buffer.h"
+#include "pipe/p_winsys.h"
-void
-buffer_reference(struct pipe_buffer **dst,
- struct pipe_buffer *src)
+
+static void *
+pb_winsys_map(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf,
+ unsigned flags)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ return buf->vtbl->map(buf, flags);
+}
+
+static void
+pb_winsys_unmap(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ buf->vtbl->unmap(buf);
+}
+
+static void
+pb_winsys_destroy(struct pipe_winsys *winsys,
+ struct pipe_buffer *ws_buf)
+{
+ struct pb_buffer *buf = pb_buffer(ws_buf);
+
+ buf->vtbl->destroy(buf);
+}
+
+
+
+void
+pb_init_winsys(struct pipe_winsys *winsys)
{
- if(*dst != src) {
- if (src)
- src->vtbl->reference(src);
-
- if (*dst)
- (*dst)->vtbl->release(*dst);
-
- *dst = src;
- }
+ winsys->buffer_map = pb_winsys_map;
+ winsys->buffer_unmap = pb_winsys_unmap;
+ winsys->buffer_destroy = pb_winsys_destroy;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer.h b/src/mesa/pipe/pipebuffer/pb_buffer.h
index 0523531395..f909bded0d 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer.h
+++ b/src/mesa/pipe/pipebuffer/pb_buffer.h
@@ -47,53 +47,43 @@
#include <assert.h>
#include <stdlib.h>
+#include "pipe/p_state.h"
-struct pipe_buffer_vtbl;
-
+struct pb_vtbl;
/**
- * Base class for all pipe buffers.
+ * Base class for all pb_* buffers.
*/
-struct pipe_buffer
+struct pb_buffer
{
+ struct pipe_buffer base;
+
/**
* Pointer to the virtual function table.
*
* Avoid accessing this table directly. Use the inline functions below
* instead to avoid mistakes.
*/
- const struct pipe_buffer_vtbl *vtbl;
+ const struct pb_vtbl *vtbl;
};
-
/**
* Virtual function table for the buffer storage operations.
*
* Note that creation is not done through this table.
*/
-struct pipe_buffer_vtbl
+struct pb_vtbl
{
- /**
- * Add a reference to the buffer.
- *
- * This method can be a no-op for buffers that don't need reference
- * counting.
- */
- void (*reference)( struct pipe_buffer *buf );
-
- /**
- * Release a reference to this buffer and destroy it.
- */
- void (*release)( struct pipe_buffer *buf );
+ void (*destroy)( struct pb_buffer *buf );
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
*/
- void *(*map)( struct pipe_buffer *buf,
+ void *(*map)( struct pb_buffer *buf,
unsigned flags );
- void (*unmap)( struct pipe_buffer *buf );
+ void (*unmap)( struct pb_buffer *buf );
/**
* Get the base buffer and the offset.
@@ -106,29 +96,17 @@ struct pipe_buffer_vtbl
*
* Note that this will increase the reference count of the base buffer.
*/
- void (*get_base_buffer)( struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+ void (*get_base_buffer)( struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset );
};
-/** *dst = src with reference counting */
-void
-buffer_reference(struct pipe_buffer **dst,
- struct pipe_buffer *src);
-
-
-static inline void
-buffer_release(struct pipe_buffer *buf)
-{
- assert(buf);
- buf->vtbl->release(buf);
-}
-
-
+/* Accessor functions for pb->vtbl:
+ */
static inline void *
-buffer_map(struct pipe_buffer *buf,
- unsigned flags)
+pb_map(struct pb_buffer *buf,
+ unsigned flags)
{
assert(buf);
return buf->vtbl->map(buf, flags);
@@ -136,7 +114,7 @@ buffer_map(struct pipe_buffer *buf,
static inline void
-buffer_unmap(struct pipe_buffer *buf)
+pb_unmap(struct pb_buffer *buf)
{
assert(buf);
buf->vtbl->unmap(buf);
@@ -144,32 +122,63 @@ buffer_unmap(struct pipe_buffer *buf)
static inline void
-buffer_get_base_buffer( struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
- unsigned *offset )
+pb_get_base_buffer( struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
+ unsigned *offset )
{
buf->vtbl->get_base_buffer(buf, base_buf, offset);
}
+static inline void
+pb_destroy(struct pb_buffer *buf)
+{
+ assert(buf);
+ buf->vtbl->destroy(buf);
+}
+
-/** Placeholder for empty buffers. */
-extern struct pipe_buffer null_buffer;
/**
- * Client buffers (also designated as user buffers) are just for convenience
- * of the state tracker, so that it can masquerade its own data as a buffer.
+ * User buffers are special buffers that initially reference memory
+ * held by the user but which may if necessary copy that memory into
+ * device memory behind the scenes, for submission to hardware.
+ *
+ * These are particularly useful when the referenced data is never
+ * submitted to hardware at all, in the particular case of software
+ * vertex processing.
*/
-struct pipe_buffer *
-client_buffer_create(void *data);
+struct pb_buffer *
+pb_user_buffer_create(void *data, unsigned bytes);
/**
* Malloc-based buffer to store data that can't be used by the graphics
* hardware.
*/
-struct pipe_buffer *
-malloc_buffer_create(unsigned size);
+struct pb_buffer *
+pb_malloc_buffer_create( unsigned alignment,
+ unsigned usage,
+ unsigned size );
+
+
+
+static inline struct pipe_buffer *
+pb_pipe_buffer( struct pb_buffer *pbuf )
+{
+ return &pbuf->base;
+}
+
+static inline struct pb_buffer *
+pb_buffer( struct pipe_buffer *buf )
+{
+ /* Could add a magic cookie check on debug builds.
+ */
+ return (struct pb_buffer *)buf;
+}
+
+void
+pb_init_winsys(struct pipe_winsys *winsys);
#endif /*PB_BUFFER_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_client.c b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
index bb7f5a9a94..6bf4745301 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_client.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_client.c
@@ -35,36 +35,30 @@
#include "pb_buffer.h"
+#include "pipe/p_util.h"
-struct client_buffer
+struct pb_user_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
void *data;
};
-extern const struct pipe_buffer_vtbl client_buffer_vtbl;
+extern const struct pb_vtbl pb_user_buffer_vtbl;
-static inline struct client_buffer *
-client_buffer(struct pipe_buffer *buf)
+static INLINE struct pb_user_buffer *
+pb_user_buffer(struct pb_buffer *buf)
{
assert(buf);
- assert(buf->vtbl == &client_buffer_vtbl);
- return (struct client_buffer *)buf;
+ assert(buf->vtbl == &pb_user_buffer_vtbl);
+ return (struct pb_user_buffer *)buf;
}
static void
-client_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-client_buffer_release(struct pipe_buffer *buf)
+pb_user_buffer_destroy(struct pb_buffer *buf)
{
assert(buf);
free(buf);
@@ -72,23 +66,23 @@ client_buffer_release(struct pipe_buffer *buf)
static void *
-client_buffer_map(struct pipe_buffer *buf,
+pb_user_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
- return client_buffer(buf)->data;
+ return pb_user_buffer(buf)->data;
}
static void
-client_buffer_unmap(struct pipe_buffer *buf)
+pb_user_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-client_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+pb_user_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
*base_buf = buf;
@@ -96,27 +90,25 @@ client_buffer_get_base_buffer(struct pipe_buffer *buf,
}
-const struct pipe_buffer_vtbl
-client_buffer_vtbl = {
- client_buffer_reference,
- client_buffer_release,
- client_buffer_map,
- client_buffer_unmap,
- client_buffer_get_base_buffer
+const struct pb_vtbl
+pb_user_buffer_vtbl = {
+ pb_user_buffer_destroy,
+ pb_user_buffer_map,
+ pb_user_buffer_unmap,
+ pb_user_buffer_get_base_buffer
};
-struct pipe_buffer *
-client_buffer_create(void *data)
+struct pb_buffer *
+pb_user_buffer_create(void *data, unsigned bytes)
{
- struct client_buffer *buf;
-
- buf = (struct client_buffer *)malloc(sizeof(struct client_buffer));
+ struct pb_user_buffer *buf = CALLOC_STRUCT(pb_user_buffer);
+
if(!buf)
return NULL;
- buf->base.vtbl = &client_buffer_vtbl;
-
+ buf->base.vtbl = &pb_user_buffer_vtbl;
+ buf->base.base.size = bytes;
buf->data = data;
return &buf->base;
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
index dfb80b1dcf..625120d714 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
@@ -72,9 +72,9 @@ struct fenced_buffer_list
*/
struct fenced_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
unsigned refcount;
struct pipe_fence_handle *fence;
@@ -84,8 +84,8 @@ struct fenced_buffer
};
-static inline struct fenced_buffer *
-fenced_buffer(struct pipe_buffer *buf)
+static INLINE struct fenced_buffer *
+fenced_buffer(struct pb_buffer *buf)
{
assert(buf);
assert(buf->vtbl == &fenced_buffer_vtbl);
@@ -93,12 +93,6 @@ fenced_buffer(struct pipe_buffer *buf)
}
-static void
-_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
-{
- buffer_release(fenced_buf->buffer);
- free(fenced_buf);
-}
static void
@@ -143,97 +137,81 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
LIST_DEL(list);
fenced_list->numDelayed--;
-
- _fenced_buffer_destroy(fenced_buf);
- }
-}
-
-static void
-fenced_buffer_reference(struct pipe_buffer *buf)
-{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
-
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- fenced_buf->refcount++;
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ /* Do the delayed destroy:
+ */
+ pb_destroy(fenced_buf->buffer);
+ free(fenced_buf);
+ }
}
static void
-fenced_buffer_release(struct pipe_buffer *buf)
+fenced_buffer_destroy(struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
-
- fenced_buf->refcount--;
- if(!fenced_buf->refcount) {
- if (fenced_buf->fence) {
- LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
- fenced_list->numDelayed++;
- }
- else {
- _fenced_buffer_destroy(fenced_buf);
- }
-
- if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
- _fenced_buffer_list_check_free(fenced_list, 0);
+ if (fenced_buf->fence) {
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
+ fenced_list->numDelayed++;
+ }
+ else {
+ pb_destroy(fenced_buf->buffer);
+ free(fenced_buf);
}
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
+ if ((fenced_list->numDelayed % fenced_list->checkDelayed) == 0)
+ _fenced_buffer_list_check_free(fenced_list, 0);
}
static void *
-fenced_buffer_map(struct pipe_buffer *buf,
+fenced_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- return buffer_map(fenced_buf->buffer, flags);
+ return pb_map(fenced_buf->buffer, flags);
}
static void
-fenced_buffer_unmap(struct pipe_buffer *buf)
+fenced_buffer_unmap(struct pb_buffer *buf)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- buffer_unmap(fenced_buf->buffer);
+ pb_unmap(fenced_buf->buffer);
}
static void
-fenced_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+fenced_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- buffer_get_base_buffer(fenced_buf->buffer, base_buf, offset);
+ pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
}
-const struct pipe_buffer_vtbl
+const struct pb_vtbl
fenced_buffer_vtbl = {
- fenced_buffer_reference,
- fenced_buffer_release,
+ fenced_buffer_destroy,
fenced_buffer_map,
fenced_buffer_unmap,
fenced_buffer_get_base_buffer
};
-struct pipe_buffer *
+struct pb_buffer *
fenced_buffer_create(struct fenced_buffer_list *fenced_list,
- struct pipe_buffer *buffer)
+ struct pb_buffer *buffer)
{
struct fenced_buffer *buf;
if(!buffer)
return NULL;
- buf = (struct fenced_buffer *)calloc(1, sizeof(struct fenced_buffer));
+ buf = CALLOC_STRUCT(fenced_buffer);
if(!buf)
return NULL;
@@ -247,20 +225,16 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
void
-buffer_fence(struct pipe_buffer *buf,
+buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence)
{
- if(buf->vtbl == &fenced_buffer_vtbl) {
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
- struct pipe_winsys *winsys = fenced_list->winsys;
+ struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+ struct pipe_winsys *winsys = fenced_list->winsys;
- _glthread_LOCK_MUTEX(fenced_list->mutex);
- winsys->fence_reference(winsys, &fenced_buf->fence, fence);
- _glthread_UNLOCK_MUTEX(fenced_list->mutex);
- }
- else
- assert(0);
+ _glthread_LOCK_MUTEX(fenced_list->mutex);
+ winsys->fence_reference(winsys, &fenced_buf->fence, fence);
+ _glthread_UNLOCK_MUTEX(fenced_list->mutex);
}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
index 07e42a67f8..09082a5390 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.h
@@ -70,7 +70,7 @@ struct fenced_buffer_list;
*
* NOTE: Made public for debugging purposes.
*/
-extern const struct pipe_buffer_vtbl fenced_buffer_vtbl;
+extern const struct pb_vtbl fenced_buffer_vtbl;
/**
@@ -98,19 +98,19 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
*
* NOTE: this will not increase the buffer reference count.
*/
-struct pipe_buffer *
+struct pb_buffer *
fenced_buffer_create(struct fenced_buffer_list *fenced,
- struct pipe_buffer *buffer);
+ struct pb_buffer *buffer);
/**
* Set a buffer's fence.
*
- * NOTE: Although it takes a generic pipe buffer argument, it will fail
+ * NOTE: Although it takes a generic pb_buffer argument, it will fail
* on everything but buffers returned by fenced_buffer_create.
*/
void
-buffer_fence(struct pipe_buffer *buf,
+buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence);
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c b/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
deleted file mode 100644
index 9aeff976f3..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.c
+++ /dev/null
@@ -1,140 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * Drop-in implementation of the winsys driver functions for buffer handles.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include <assert.h>
-#include <stdlib.h>
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_defines.h"
-
-#include "pb_buffer.h"
-#include "pb_buffer_handle.h"
-
-
-static struct pipe_buffer_handle *
-buffer_handle_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct pipe_buffer_handle *handle;
-
- handle = (struct pipe_buffer_handle *)malloc(sizeof(struct pipe_buffer_handle));
- if(!handle)
- return NULL;
-
- handle->refcount = 1;
- handle->alignment = alignment;
- handle->usage = usage;
- handle->size = size;
-
- handle->buf = &null_buffer;
-
- return handle;
-}
-
-
-static struct pipe_buffer_handle *
-buffer_handle_create_user(struct pipe_winsys *winsys,
- void *data, unsigned size)
-{
- struct pipe_buffer_handle *handle;
- struct pipe_buffer *buf;
-
- handle = buffer_handle_create(winsys, 1, 0, size);
- if(!handle)
- return NULL;
-
- buf = client_buffer_create(data);
- if(!buf) {
- free(handle);
- return NULL;
- }
-
- buffer_handle_data(handle, buf);
-
- return handle;
-}
-
-
-static void *
-buffer_handle_map(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle,
- unsigned flags)
-{
- return buffer_map(handle->buf, flags);
-}
-
-
-static void
-buffer_handle_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer_handle *handle)
-{
- buffer_unmap(handle->buf);
-}
-
-
-static void
-buffer_handle_reference(struct pipe_winsys *winsys,
- struct pipe_buffer_handle **dst,
- struct pipe_buffer_handle *src)
-{
- /* XXX: should this be thread safe? */
-
- if (src) {
- src->refcount++;
- }
-
- if (*dst) {
- (*dst)->refcount--;
- if ((*dst)->refcount == 0) {
- buffer_release((*dst)->buf);
- free(*dst);
- }
- }
-
- *dst = src;
-}
-
-
-void
-buffer_handle_init_winsys(struct pipe_winsys *winsys)
-{
- winsys->buffer_create = buffer_handle_create;
- winsys->user_buffer_create = buffer_handle_create_user;
- winsys->buffer_map = buffer_handle_map;
- winsys->buffer_unmap = buffer_handle_unmap;
- winsys->buffer_reference = buffer_handle_reference;
-}
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h b/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
deleted file mode 100644
index 34133c9fba..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_handle.h
+++ /dev/null
@@ -1,120 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * Buffer handle interface.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-#ifndef PB_BUFFER_HANDLE_H_
-#define PB_BUFFER_HANDLE_H_
-
-
-#include <assert.h>
-
-#include "pb_buffer.h"
-
-
-/**
- * Buffer handle.
- *
- * The buffer handle and the buffer data storage are separate entities. This
- * is modelled after ARB_vertex_buffer_object, which is the interface that
- * Gallium requires. See p_winsys.h for more information.
- */
-struct pipe_buffer_handle
-{
- /** Reference count */
- unsigned refcount;
-
- /** Allocation characteristics */
- unsigned alignment;
- unsigned usage;
- unsigned size;
-
- /**
- * The actual buffer.
- *
- * It should never be NULL. Use null_buffer instead.
- */
- struct pipe_buffer *buf;
-};
-
-
-/**
- * Set buffer storage.
- *
- * NOTE: this will not increase the buffer reference count.
- */
-static inline void
-buffer_handle_data(struct pipe_buffer_handle *handle,
- struct pipe_buffer *buf)
-{
- assert(handle);
- assert(handle->buf);
- buffer_release(handle->buf);
- assert(buf);
- handle->buf = buf;
-}
-
-
-static inline void
-buffer_handle_clear(struct pipe_buffer_handle *handle)
-{
- buffer_handle_data(handle, &null_buffer);
-}
-
-
-static inline int
-buffer_handle_has_data(struct pipe_buffer_handle *handle) {
- assert(handle);
- assert(handle->buf);
- return handle->buf != &null_buffer;
-}
-
-
-/**
- * Fill in the pipe_winsys' buffer-related callbacks.
- *
- * Specifically, the fullfilled functions are:
- * - buffer_create
- * - user_buffer_create
- * - buffer_map
- * - buffer_unmap
- * - buffer_reference
- * - buffer_subdata
- * - buffer_get_subdata
- *
- * NOTE: buffer_data is left untouched.
- */
-void
-buffer_handle_init_winsys(struct pipe_winsys *winsys);
-
-
-#endif /*PB_BUFFER_HANDLE_H_*/
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
index 65ad51e1e7..e02eb1eebd 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
@@ -42,15 +42,15 @@
struct malloc_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
void *data;
};
-extern const struct pipe_buffer_vtbl malloc_buffer_vtbl;
+extern const struct pb_vtbl malloc_buffer_vtbl;
-static inline struct malloc_buffer *
-malloc_buffer(struct pipe_buffer *buf)
+static INLINE struct malloc_buffer *
+malloc_buffer(struct pb_buffer *buf)
{
assert(buf);
assert(buf->vtbl == &malloc_buffer_vtbl);
@@ -59,14 +59,7 @@ malloc_buffer(struct pipe_buffer *buf)
static void
-malloc_buffer_reference(struct pipe_buffer *buf)
-{
- /* no-op */
-}
-
-
-static void
-malloc_buffer_release(struct pipe_buffer *buf)
+malloc_buffer_destroy(struct pb_buffer *buf)
{
free(malloc_buffer(buf)->data);
free(buf);
@@ -74,7 +67,7 @@ malloc_buffer_release(struct pipe_buffer *buf)
static void *
-malloc_buffer_map(struct pipe_buffer *buf,
+malloc_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
return malloc_buffer(buf)->data;
@@ -82,15 +75,15 @@ malloc_buffer_map(struct pipe_buffer *buf,
static void
-malloc_buffer_unmap(struct pipe_buffer *buf)
+malloc_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-malloc_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+malloc_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
*base_buf = buf;
@@ -98,18 +91,19 @@ malloc_buffer_get_base_buffer(struct pipe_buffer *buf,
}
-const struct pipe_buffer_vtbl
+const struct pb_vtbl
malloc_buffer_vtbl = {
- malloc_buffer_reference,
- malloc_buffer_release,
+ malloc_buffer_destroy,
malloc_buffer_map,
malloc_buffer_unmap,
malloc_buffer_get_base_buffer
};
-struct pipe_buffer *
-malloc_buffer_create(unsigned size)
+struct pb_buffer *
+pb_malloc_buffer_create( unsigned alignment,
+ unsigned usage,
+ unsigned size )
{
struct malloc_buffer *buf;
@@ -121,7 +115,10 @@ malloc_buffer_create(unsigned size)
return NULL;
buf->base.vtbl = &malloc_buffer_vtbl;
-
+ buf->base.base.alignment = alignment;
+ buf->base.base.usage = usage;
+ buf->base.base.size = size;
+
buf->data = malloc(size);
if(!buf->data) {
free(buf);
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_null.c b/src/mesa/pipe/pipebuffer/pb_buffer_null.c
deleted file mode 100644
index a356c6b2d5..0000000000
--- a/src/mesa/pipe/pipebuffer/pb_buffer_null.c
+++ /dev/null
@@ -1,98 +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.
- *
- **************************************************************************/
-
-/**
- * \file
- * Null buffer implementation.
- *
- * We have a special null buffer object so that we can safely call buffer
- * operations without having to check whether the buffer pointer is null or not.
- *
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
- */
-
-
-#include "pipe/p_winsys.h"
-#include "pipe/p_defines.h"
-
-#include "pb_buffer.h"
-
-
-static void
-null_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-null_buffer_release(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void *
-null_buffer_map(struct pipe_buffer *buf,
- unsigned flags)
-{
- assert(0);
- return NULL;
-}
-
-
-static void
-null_buffer_unmap(struct pipe_buffer *buf)
-{
- assert(0);
-}
-
-
-static void
-null_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-const struct pipe_buffer_vtbl
-pipe_buffer_vtbl = {
- null_buffer_reference,
- null_buffer_release,
- null_buffer_map,
- null_buffer_unmap,
- null_buffer_get_base_buffer
-};
-
-
-struct pipe_buffer
-null_buffer = {
- &pipe_buffer_vtbl
-};
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
index 12e36323a8..13d4ea7545 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
@@ -60,15 +60,15 @@ struct pipe_winsys;
/**
* Abstract base class for all buffer managers.
*/
-struct buffer_manager
+struct pb_manager
{
/* XXX: we will likely need more allocation flags */
- struct pipe_buffer *
- (*create_buffer)( struct buffer_manager *mgr,
+ struct pb_buffer *
+ (*create_buffer)( struct pb_manager *mgr,
size_t size );
void
- (*destroy)( struct buffer_manager *mgr );
+ (*destroy)( struct pb_manager *mgr );
};
@@ -80,8 +80,8 @@ struct buffer_manager
*
* It is meant to manage the allocation of batch buffer pools.
*/
-struct buffer_manager *
-pool_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+pool_bufmgr_create(struct pb_manager *provider,
size_t n, size_t size);
@@ -92,8 +92,8 @@ pool_bufmgr_create(struct buffer_manager *provider,
* with the size of the heap, and then using the old mm memory manager to manage
* that heap.
*/
-struct buffer_manager *
-mm_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2);
/**
@@ -101,8 +101,8 @@ mm_bufmgr_create(struct buffer_manager *provider,
*
* Buffer will be release when the manager is destroyed.
*/
-struct buffer_manager *
-mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+struct pb_manager *
+mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2);
@@ -115,8 +115,8 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
* NOTE: the buffer manager that provides the buffers will be destroyed
* at the same time.
*/
-struct buffer_manager *
-fenced_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys);
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
index defd8e4df7..8cdbbed272 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
@@ -42,30 +42,30 @@
#include "pb_bufmgr.h"
-struct fenced_buffer_manager
+struct fenced_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
- struct buffer_manager *provider;
+ struct pb_manager *provider;
struct fenced_buffer_list *fenced_list;
};
-static inline struct fenced_buffer_manager *
-fenced_buffer_manager(struct buffer_manager *mgr)
+static inline struct fenced_pb_manager *
+fenced_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct fenced_buffer_manager *)mgr;
+ return (struct fenced_pb_manager *)mgr;
}
-static struct pipe_buffer *
-fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+static struct pb_buffer *
+fenced_bufmgr_create_buffer(struct pb_manager *mgr, size_t size)
{
- struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
- struct pipe_buffer *buf;
- struct pipe_buffer *fenced_buf;
+ struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
+ struct pb_buffer *buf;
+ struct pb_buffer *fenced_buf;
/* check for free buffers before allocating new ones */
fenced_buffer_list_check_free(fenced_mgr->fenced_list, 0);
@@ -84,7 +84,7 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
if(!fenced_buf) {
- buffer_release(buf);
+ pb_destroy(buf);
}
return fenced_buf;
@@ -92,9 +92,9 @@ fenced_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
static void
-fenced_bufmgr_destroy(struct buffer_manager *mgr)
+fenced_bufmgr_destroy(struct pb_manager *mgr)
{
- struct fenced_buffer_manager *fenced_mgr = fenced_buffer_manager(mgr);
+ struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
fenced_buffer_list_destroy(fenced_mgr->fenced_list);
@@ -104,13 +104,13 @@ fenced_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-fenced_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys)
{
- struct fenced_buffer_manager *fenced_mgr;
+ struct fenced_pb_manager *fenced_mgr;
- fenced_mgr = (struct fenced_buffer_manager *)calloc(1, sizeof(*fenced_mgr));
+ fenced_mgr = (struct fenced_pb_manager *)calloc(1, sizeof(*fenced_mgr));
if (!fenced_mgr)
return NULL;
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
index d174f24e32..f456b571d9 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -53,9 +53,9 @@
#define SUPER(__derived) (&(__derived)->base)
-struct mm_buffer_manager
+struct mm_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
_glthread_Mutex mutex;
@@ -64,31 +64,31 @@ struct mm_buffer_manager
size_t align2;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
void *map;
};
-static inline struct mm_buffer_manager *
-mm_buffer_manager(struct buffer_manager *mgr)
+static inline struct mm_pb_manager *
+mm_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct mm_buffer_manager *)mgr;
+ return (struct mm_pb_manager *)mgr;
}
struct mm_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct mm_buffer_manager *mgr;
+ struct mm_pb_manager *mgr;
struct mem_block *block;
};
static inline struct mm_buffer *
-mm_buffer(struct pipe_buffer *buf)
+mm_buffer(struct pb_buffer *buf)
{
assert(buf);
return (struct mm_buffer *)buf;
@@ -96,17 +96,10 @@ mm_buffer(struct pipe_buffer *buf)
static void
-mm_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
-
-static void
-mm_buffer_release(struct pipe_buffer *buf)
+mm_buffer_destroy(struct pb_buffer *buf)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
+ struct mm_pb_manager *mm = mm_buf->mgr;
_glthread_LOCK_MUTEX(mm->mutex);
mmFreeMem(mm_buf->block);
@@ -116,50 +109,49 @@ mm_buffer_release(struct pipe_buffer *buf)
static void *
-mm_buffer_map(struct pipe_buffer *buf,
+mm_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
+ struct mm_pb_manager *mm = mm_buf->mgr;
return (unsigned char *) mm->map + mm_buf->block->ofs;
}
static void
-mm_buffer_unmap(struct pipe_buffer *buf)
+mm_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-mm_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+mm_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
- struct mm_buffer_manager *mm = mm_buf->mgr;
- buffer_get_base_buffer(mm->buffer, base_buf, offset);
+ struct mm_pb_manager *mm = mm_buf->mgr;
+ pb_get_base_buffer(mm->buffer, base_buf, offset);
*offset += mm_buf->block->ofs;
}
-static const struct pipe_buffer_vtbl
+static const struct pb_vtbl
mm_buffer_vtbl = {
- mm_buffer_reference,
- mm_buffer_release,
+ mm_buffer_destroy,
mm_buffer_map,
mm_buffer_unmap,
mm_buffer_get_base_buffer
};
-static struct pipe_buffer *
-mm_bufmgr_create_buffer(struct buffer_manager *mgr,
+static struct pb_buffer *
+mm_bufmgr_create_buffer(struct pb_manager *mgr,
size_t size)
{
- struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+ struct mm_pb_manager *mm = mm_pb_manager(mgr);
struct mm_buffer *mm_buf;
_glthread_LOCK_MUTEX(mm->mutex);
@@ -200,16 +192,16 @@ mm_bufmgr_create_buffer(struct buffer_manager *mgr,
static void
-mm_bufmgr_destroy(struct buffer_manager *mgr)
+mm_bufmgr_destroy(struct pb_manager *mgr)
{
- struct mm_buffer_manager *mm = mm_buffer_manager(mgr);
+ struct mm_pb_manager *mm = mm_pb_manager(mgr);
_glthread_LOCK_MUTEX(mm->mutex);
mmDestroy(mm->heap);
- buffer_unmap(mm->buffer);
- buffer_release(mm->buffer);
+ pb_unmap(mm->buffer);
+ pb_destroy(mm->buffer);
_glthread_UNLOCK_MUTEX(mm->mutex);
@@ -217,16 +209,16 @@ mm_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+struct pb_manager *
+mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
size_t size, size_t align2)
{
- struct mm_buffer_manager *mm;
+ struct mm_pb_manager *mm;
if(!buffer)
return NULL;
- mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm));
+ mm = (struct mm_pb_manager *)calloc(1, sizeof(*mm));
if (!mm)
return NULL;
@@ -240,9 +232,9 @@ mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
mm->buffer = buffer;
- mm->map = buffer_map(mm->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ mm->map = pb_map(mm->buffer,
+ PIPE_BUFFER_USAGE_CPU_READ |
+ PIPE_BUFFER_USAGE_CPU_WRITE);
if(!mm->map)
goto failure;
@@ -256,19 +248,19 @@ failure:
if(mm->heap)
mmDestroy(mm->heap);
if(mm->map)
- buffer_unmap(mm->buffer);
+ pb_unmap(mm->buffer);
if(mm)
free(mm);
return NULL;
}
-struct buffer_manager *
-mm_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+mm_bufmgr_create(struct pb_manager *provider,
size_t size, size_t align2)
{
- struct pipe_buffer *buffer;
- struct buffer_manager *mgr;
+ struct pb_buffer *buffer;
+ struct pb_manager *mgr;
assert(provider);
assert(provider->create_buffer);
@@ -278,7 +270,7 @@ mm_bufmgr_create(struct buffer_manager *provider,
mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
if (!mgr) {
- buffer_release(buffer);
+ pb_destroy(buffer);
return NULL;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
index e6a8c78668..7e8494f615 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
@@ -55,9 +55,9 @@
#define SUPER(__derived) (&(__derived)->base)
-struct pool_buffer_manager
+struct pool_pb_manager
{
- struct buffer_manager base;
+ struct pb_manager base;
_glthread_Mutex mutex;
@@ -68,26 +68,26 @@ struct pool_buffer_manager
struct list_head free;
- struct pipe_buffer *buffer;
+ struct pb_buffer *buffer;
void *map;
struct pool_buffer *bufs;
};
-static inline struct pool_buffer_manager *
-pool_buffer_manager(struct buffer_manager *mgr)
+static inline struct pool_pb_manager *
+pool_pb_manager(struct pb_manager *mgr)
{
assert(mgr);
- return (struct pool_buffer_manager *)mgr;
+ return (struct pool_pb_manager *)mgr;
}
struct pool_buffer
{
- struct pipe_buffer base;
+ struct pb_buffer base;
- struct pool_buffer_manager *mgr;
+ struct pool_pb_manager *mgr;
struct list_head head;
@@ -96,25 +96,19 @@ struct pool_buffer
static inline struct pool_buffer *
-pool_buffer(struct pipe_buffer *buf)
+pool_buffer(struct pb_buffer *buf)
{
assert(buf);
return (struct pool_buffer *)buf;
}
-static void
-pool_buffer_reference(struct pipe_buffer *buf)
-{
- /* No-op */
-}
-
static void
-pool_buffer_release(struct pipe_buffer *buf)
+pool_buffer_destroy(struct pb_buffer *buf)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
+ struct pool_pb_manager *pool = pool_buf->mgr;
_glthread_LOCK_MUTEX(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
@@ -124,10 +118,10 @@ pool_buffer_release(struct pipe_buffer *buf)
static void *
-pool_buffer_map(struct pipe_buffer *buf, unsigned flags)
+pool_buffer_map(struct pb_buffer *buf, unsigned flags)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
+ struct pool_pb_manager *pool = pool_buf->mgr;
void *map;
_glthread_LOCK_MUTEX(pool->mutex);
@@ -138,38 +132,37 @@ pool_buffer_map(struct pipe_buffer *buf, unsigned flags)
static void
-pool_buffer_unmap(struct pipe_buffer *buf)
+pool_buffer_unmap(struct pb_buffer *buf)
{
/* No-op */
}
static void
-pool_buffer_get_base_buffer(struct pipe_buffer *buf,
- struct pipe_buffer **base_buf,
+pool_buffer_get_base_buffer(struct pb_buffer *buf,
+ struct pb_buffer **base_buf,
unsigned *offset)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
- struct pool_buffer_manager *pool = pool_buf->mgr;
- buffer_get_base_buffer(pool->buffer, base_buf, offset);
+ struct pool_pb_manager *pool = pool_buf->mgr;
+ pb_get_base_buffer(pool->buffer, base_buf, offset);
*offset += pool_buf->start;
}
-static const struct pipe_buffer_vtbl
+static const struct pb_vtbl
pool_buffer_vtbl = {
- pool_buffer_reference,
- pool_buffer_release,
+ pool_buffer_destroy,
pool_buffer_map,
pool_buffer_unmap,
pool_buffer_get_base_buffer
};
-static struct pipe_buffer *
-pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
+static struct pb_buffer *
+pool_bufmgr_create_buffer(struct pb_manager *mgr, size_t size)
{
- struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ struct pool_pb_manager *pool = pool_pb_manager(mgr);
struct pool_buffer *pool_buf;
struct list_head *item;
@@ -201,15 +194,15 @@ pool_bufmgr_create_buffer(struct buffer_manager *mgr, size_t size)
static void
-pool_bufmgr_destroy(struct buffer_manager *mgr)
+pool_bufmgr_destroy(struct pb_manager *mgr)
{
- struct pool_buffer_manager *pool = pool_buffer_manager(mgr);
+ struct pool_pb_manager *pool = pool_pb_manager(mgr);
_glthread_LOCK_MUTEX(pool->mutex);
free(pool->bufs);
- buffer_unmap(pool->buffer);
- buffer_release(pool->buffer);
+ pb_unmap(pool->buffer);
+ pb_destroy(pool->buffer);
_glthread_UNLOCK_MUTEX(pool->mutex);
@@ -217,16 +210,16 @@ pool_bufmgr_destroy(struct buffer_manager *mgr)
}
-struct buffer_manager *
-pool_bufmgr_create(struct buffer_manager *provider,
+struct pb_manager *
+pool_bufmgr_create(struct pb_manager *provider,
size_t numBufs,
size_t bufSize)
{
- struct pool_buffer_manager *pool;
+ struct pool_pb_manager *pool;
struct pool_buffer *pool_buf;
int i;
- pool = (struct pool_buffer_manager *)calloc(1, sizeof(*pool));
+ pool = (struct pool_pb_manager *)calloc(1, sizeof(*pool));
if (!pool)
return NULL;
@@ -245,7 +238,7 @@ pool_bufmgr_create(struct buffer_manager *provider,
if (!pool->buffer)
goto failure;
- pool->map = buffer_map(pool->buffer,
+ pool->map = pb_map(pool->buffer,
PIPE_BUFFER_USAGE_CPU_READ |
PIPE_BUFFER_USAGE_CPU_WRITE);
if(!pool->map)
@@ -270,9 +263,9 @@ failure:
if(pool->bufs)
free(pool->bufs);
if(pool->map)
- buffer_unmap(pool->buffer);
+ pb_unmap(pool->buffer);
if(pool->buffer)
- buffer_release(pool->buffer);
+ pb_destroy(pool->buffer);
if(pool)
free(pool);
return NULL;