i915: Update gem backend a bit
authorJakob Bornecrantz <wallbraker@gmail.com>
Sun, 18 Jan 2009 14:35:50 +0000 (15:35 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Sun, 18 Jan 2009 14:35:50 +0000 (15:35 +0100)
src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
src/gallium/winsys/drm/intel/gem/intel_be_device.c
src/gallium/winsys/drm/intel/gem/intel_be_device.h

index 2399910613864de84c2c6a23380a7a0fb1eaa7c7..af5c0277484bf9246839bfdf4ee0f34a4367937f 100644 (file)
@@ -12,6 +12,7 @@ intel_be_batchbuffer_alloc(struct intel_be_context *intel)
 {
        struct intel_be_batchbuffer *batch = CALLOC_STRUCT(intel_be_batchbuffer);
 
+
        batch->base.buffer = NULL;
        batch->base.winsys = &intel->base;
        batch->base.map = NULL;
@@ -28,7 +29,7 @@ intel_be_batchbuffer_alloc(struct intel_be_context *intel)
 
        intel_be_batchbuffer_reset(batch);
 
-       return NULL;
+       return batch;
 }
 
 void
index cf0c1408dc831fa5d4290f0ac31300b97f2f3466..201a4850498df6e994ae355076506fb783cd6cae 100644 (file)
@@ -141,9 +141,10 @@ err:
 }
 
 struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *dev,
-                           const char* name, unsigned handle)
+intel_be_buffer_from_handle(struct pipe_winsys *winsys,
+                            const char* name, unsigned handle)
 {
+       struct intel_be_device *dev = intel_be_device(winsys);
        struct intel_be_buffer *buffer = CALLOC_STRUCT(intel_be_buffer);
 
        if (!buffer)
@@ -169,6 +170,14 @@ err:
        return NULL;
 }
 
+unsigned
+intel_be_handle_from_buffer(struct pipe_winsys *winsys,
+                            struct pipe_buffer *buf)
+{
+       drm_intel_bo *bo = intel_bo(buf);
+       return bo->handle;
+}
+
 /*
  * Fence
  */
@@ -248,8 +257,6 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
 
        dev->pools.gem = drm_intel_bufmgr_gem_init(dev->fd, dev->max_batch_size);
 
-       dev->screen = i915_create_screen(&dev->base, id);
-
        return true;
 }
 
index 53d63536c9755509f5572410f7bf14163c07ba76..96e94c47e712e4bfa875a121c03e1544bd7a6f75 100644 (file)
@@ -16,11 +16,6 @@ struct intel_be_device
 {
        struct pipe_winsys base;
 
-       /**
-        * Hw level screen
-        */
-       struct pipe_screen *screen;
-
        int fd; /**< Drm file discriptor */
 
        size_t max_batch_size;
@@ -47,14 +42,23 @@ struct intel_be_buffer {
 };
 
 /**
- * Create a be buffer from a drm bo handle
+ * Create a be buffer from a drm bo handle.
  *
- * Takes a reference
+ * Takes a reference.
  */
 struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *device,
+intel_be_buffer_from_handle(struct pipe_winsys *winsys,
                             const char* name, unsigned handle);
 
+/**
+ * Gets a handle from a buffer.
+ *
+ * If buffer is destroyed handle may become invalid.
+ */
+unsigned
+intel_be_handle_from_buffer(struct pipe_winsys *winsys,
+                            struct pipe_buffer *buffer);
+
 static INLINE struct intel_be_buffer *
 intel_be_buffer(struct pipe_buffer *buf)
 {