summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-10 17:58:12 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-10 17:58:12 -0600
commit66ab569590f3bb9232eb7a04988ed477fe7fe2c5 (patch)
tree838330c94dd99c778ebb8f86ef78dcdc9bc62a39
parentfcdd34de4b169dc12991f7894266ee834e9bf768 (diff)
implement the user_buffer_create() function
-rw-r--r--src/mesa/drivers/x11/xm_winsys.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/mesa/drivers/x11/xm_winsys.c b/src/mesa/drivers/x11/xm_winsys.c
index b7b2941490..7e29580b50 100644
--- a/src/mesa/drivers/x11/xm_winsys.c
+++ b/src/mesa/drivers/x11/xm_winsys.c
@@ -58,8 +58,9 @@ struct xm_winsys
*/
struct xm_buffer
{
+ boolean userBuffer; /** Is this a user-space buffer? */
int refcount;
- int size;
+ unsigned size;
void *data;
void *mapped;
};
@@ -119,7 +120,8 @@ xm_buffer_reference(struct pipe_winsys *pws,
assert(oldBuf->refcount >= 0);
if (oldBuf->refcount == 0) {
if (oldBuf->data) {
- free(oldBuf->data);
+ if (!oldBuf->userBuffer)
+ free(oldBuf->data);
oldBuf->data = NULL;
}
free(oldBuf);
@@ -141,6 +143,7 @@ xm_buffer_data(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
unsigned size, const void *data )
{
struct xm_buffer *xm_buf = xm_bo(buf);
+ assert(!xm_buf->userBuffer);
if (xm_buf->size != size) {
if (xm_buf->data)
free(xm_buf->data);
@@ -157,6 +160,7 @@ xm_buffer_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
{
struct xm_buffer *xm_buf = xm_bo(buf);
GLubyte *b = (GLubyte *) xm_buf->data;
+ assert(!xm_buf->userBuffer);
assert(b);
memcpy(b + offset, data, size);
}
@@ -167,6 +171,7 @@ xm_buffer_get_subdata(struct pipe_winsys *pws, struct pipe_buffer_handle *buf,
{
const struct xm_buffer *xm_buf = xm_bo(buf);
const GLubyte *b = (GLubyte *) xm_buf->data;
+ assert(!xm_buf->userBuffer);
assert(b);
memcpy(data, b + offset, size);
}
@@ -204,9 +209,6 @@ xm_get_name(struct pipe_winsys *pws)
}
-/* Softpipe has no concept of pools. We choose the tex/region pool
- * for all buffers.
- */
static struct pipe_buffer_handle *
xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
{
@@ -216,6 +218,21 @@ xm_buffer_create(struct pipe_winsys *pws, unsigned alignment)
}
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_buffer_handle *
+xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
+{
+ struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer);
+ buffer->userBuffer = TRUE;
+ buffer->refcount = 1;
+ buffer->data = ptr;
+ buffer->size = bytes;
+ return pipe_bo(buffer);
+}
+
+
struct xmesa_pipe_winsys
{
struct pipe_winsys winsys;
@@ -235,6 +252,7 @@ xmesa_create_pipe_winsys( XMesaContext xmesa )
* that rendering be done to an appropriate _DriBufferObject.
*/
xws->winsys.buffer_create = xm_buffer_create;
+ xws->winsys.user_buffer_create = xm_user_buffer_create;
xws->winsys.buffer_map = xm_buffer_map;
xws->winsys.buffer_unmap = xm_buffer_unmap;
xws->winsys.buffer_reference = xm_buffer_reference;