summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/common
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-07-11 00:05:53 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-07-11 00:05:53 +1000
commit19171ab1d30f14ac0d39894125a3d53a91ca5b89 (patch)
tree7adb5b8317f9acfe1f4f0ba2e10dd79b228cd57d /src/gallium/winsys/common
parent225863aeb5f2dfe4980ae5887f5623ecb05e9ced (diff)
parent64f92e00c8292113f9a6372959febe903af09db6 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/gallium/winsys/common')
-rw-r--r--src/gallium/winsys/common/intel_drm/intel_be_device.c33
-rw-r--r--src/gallium/winsys/common/intel_drm/intel_be_device.h13
2 files changed, 44 insertions, 2 deletions
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_device.c b/src/gallium/winsys/common/intel_drm/intel_be_device.c
index efb57a394e..8db0329615 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_device.c
+++ b/src/gallium/winsys/common/intel_drm/intel_be_device.c
@@ -125,6 +125,37 @@ intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned byte
return &buffer->base;
}
+struct pipe_buffer *
+intel_be_buffer_from_handle(struct intel_be_device *device,
+ const char* name, unsigned handle)
+{
+ struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
+ struct pipe_buffer *buffer;
+
+ if (!be_buf)
+ goto err;
+
+ memset(be_buf, 0, sizeof(*be_buf));
+
+ driGenBuffers(device->staticPool, name, 1, &be_buf->driBO, 0, 0, 0);
+ driBOSetReferenced(be_buf->driBO, handle);
+
+ if (0) /** XXX TODO check error */
+ goto err_bo;
+
+ buffer = &be_buf->base;
+ buffer->refcount = 1;
+ buffer->alignment = 0;
+ buffer->usage = 0;
+ buffer->size = driBOSize(be_buf->driBO);
+
+ return buffer;
+err_bo:
+ free(be_buf);
+err:
+ return NULL;
+}
+
/*
* Surface functions.
@@ -157,6 +188,7 @@ intel_i915_surface_release(struct pipe_winsys *winsys, struct pipe_surface **s)
assert((size_t)"intel_i915_surface_release is deprecated" & 0);
}
+
/*
* Fence functions
*/
@@ -189,6 +221,7 @@ intel_be_fence_finish( struct pipe_winsys *sws,
return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
}
+
/*
* Misc functions
*/
diff --git a/src/gallium/winsys/common/intel_drm/intel_be_device.h b/src/gallium/winsys/common/intel_drm/intel_be_device.h
index abf0253917..3f8b3f585c 100644
--- a/src/gallium/winsys/common/intel_drm/intel_be_device.h
+++ b/src/gallium/winsys/common/intel_drm/intel_be_device.h
@@ -48,14 +48,23 @@ struct intel_be_buffer {
struct _DriBufferObject *driBO;
};
+/**
+ * Create a be buffer from a drm bo handle
+ *
+ * Takes a reference
+ */
+struct pipe_buffer *
+intel_be_buffer_from_handle(struct intel_be_device *device,
+ const char* name, unsigned handle);
+
static INLINE struct intel_be_buffer *
-intel_be_buffer( struct pipe_buffer *buf )
+intel_be_buffer(struct pipe_buffer *buf)
{
return (struct intel_be_buffer *)buf;
}
static INLINE struct _DriBufferObject *
-dri_bo( struct pipe_buffer *buf )
+dri_bo(struct pipe_buffer *buf)
{
return intel_be_buffer(buf)->driBO;
}