.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,
};
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 */
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
*/
struct intel_be_buffer {
struct pipe_buffer base;
drm_intel_bo *bo;
+ boolean flinked;
+ unsigned flink;
};
/**
*
* 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)