intel: Use flink for global buffer ids
authorJakob Bornecrantz <wallbraker@gmail.com>
Fri, 27 Feb 2009 02:27:31 +0000 (03:27 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Fri, 27 Feb 2009 02:36:48 +0000 (03:36 +0100)
Also fix minor drm api change

src/gallium/winsys/drm/intel/gem/intel_be_api.c
src/gallium/winsys/drm/intel/gem/intel_be_device.c
src/gallium/winsys/drm/intel/gem/intel_be_device.h

index e79ff0c6a3d0f042bc63190f326a207c16b792bf..3f71c25441495ca3b210a20ebcdd2a0b3152977e 100644 (file)
@@ -11,4 +11,5 @@ struct drm_api drm_api_hocks =
        .buffer_from_texture = i915_get_texture_buffer,
        .buffer_from_handle = intel_be_buffer_from_handle,
        .handle_from_buffer = intel_be_handle_from_buffer,
+       .global_handle_from_buffer = intel_be_global_handle_from_buffer,
 };
index c0ba83400694dabae36a1ddcdf8f319cb609e468..595de447267a1d1a18be2493bbc9f9f08d4f368e 100644 (file)
@@ -70,6 +70,8 @@ intel_be_buffer_create(struct pipe_winsys *winsys,
        buffer->base.alignment = alignment;
        buffer->base.usage = usage;
        buffer->base.size = size;
+       buffer->flinked = FALSE;
+       buffer->flink = 0;
 
        if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
                /* Local buffer */
@@ -162,14 +164,39 @@ err:
        return NULL;
 }
 
-unsigned
+boolean
 intel_be_handle_from_buffer(struct pipe_screen *screen,
-                            struct pipe_buffer *buf)
+                            struct pipe_buffer *buffer,
+                            unsigned *handle)
 {
-       drm_intel_bo *bo = intel_bo(buf);
-       return bo->handle;
+       drm_intel_bo *bo;
+
+       if (!buffer)
+               return FALSE;
+
+       *handle = intel_bo(buffer)->handle;
+       return TRUE;
 }
 
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+                                  struct pipe_buffer *buffer,
+                                  unsigned *handle)
+{
+       struct intel_be_buffer *buf = intel_be_buffer(buffer);
+
+       if (!buffer)
+               return FALSE;
+
+       if (!buf->flinked) {
+               if (drm_intel_bo_flink(intel_bo(buffer), &buf->flink))
+                       return FALSE;
+               buf->flinked = TRUE;
+       }
+
+       *handle = buf->flink;
+       return TRUE;
+}
 /*
  * Fence
  */
index 5bf7d3fc4f14d475682a404b0df932d861288142..47d2176cb4220ffc0474a7766202748bdb89802c 100644 (file)
@@ -44,6 +44,8 @@ intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
 struct intel_be_buffer {
        struct pipe_buffer base;
        drm_intel_bo *bo;
+       boolean flinked;
+       unsigned flink;
 };
 
 /**
@@ -60,9 +62,20 @@ intel_be_buffer_from_handle(struct pipe_screen *screen,
  *
  * If buffer is destroyed handle may become invalid.
  */
-unsigned
+boolean
 intel_be_handle_from_buffer(struct pipe_screen *screen,
-                            struct pipe_buffer *buffer);
+                            struct pipe_buffer *buffer,
+                            unsigned *handle);
+
+/**
+ * Gets the global handle from a buffer.
+ *
+ * If buffer is destroyed handle may become invalid.
+ */
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+                                   struct pipe_buffer *buffer,
+                                   unsigned *handle);
 
 static INLINE struct intel_be_buffer *
 intel_be_buffer(struct pipe_buffer *buf)