summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2008-07-05 15:58:42 +0200
committerJakob Bornecrantz <[email protected]>2008-07-05 15:58:42 +0200
commitc6d6a57424b77ff7de611333046c054d1948ae7a (patch)
treedea04005c2b8470527276be5838e110cd63b35e6 /src/gallium/winsys
parent74db8e9b3f354b5afa30f7cd52a511504693a3c8 (diff)
i915: Added a intel be function to wrap a drm bo handle
Diffstat (limited to 'src/gallium/winsys')
-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
-rw-r--r--src/gallium/winsys/dri/intel/intel_screen.c22
3 files changed, 52 insertions, 16 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 efb57a394e4..8db03296156 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 abf02539171..3f8b3f585c7 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;
}
diff --git a/src/gallium/winsys/dri/intel/intel_screen.c b/src/gallium/winsys/dri/intel/intel_screen.c
index cfecebdb8c7..f2412217f36 100644
--- a/src/gallium/winsys/dri/intel/intel_screen.c
+++ b/src/gallium/winsys/dri/intel/intel_screen.c
@@ -49,28 +49,22 @@ intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys,
static void
intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle)
{
- struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
struct pipe_screen *screen = intelScreen->base.screen;
struct pipe_texture *texture;
struct pipe_texture templat;
struct pipe_surface *surface;
- struct pipe_buffer *buffer = &be_buf->base;
+ struct pipe_buffer *buffer;
unsigned pitch;
assert(intelScreen->front.cpp == 4);
- /* XXX create a intel_be function for this */
- {
- driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
- driBOSetReferenced(intelScreen->front.buffer, handle);
-
- memset(be_buf, 0, sizeof(*be_buf));
- buffer->refcount = 1;
- buffer->alignment = 0;
- buffer->usage = 0;
- buffer->size = driBOSize(intelScreen->front.buffer);
- be_buf->driBO = intelScreen->front.buffer;
- }
+ buffer = intel_be_buffer_from_handle(&intelScreen->base,
+ "front", handle);
+
+ if (!buffer)
+ return;
+
+ intelScreen->front.buffer = dri_bo(buffer);
memset(&templat, 0, sizeof(templat));
templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;