i915g: Implement EGL_EXT_image_dma_buf_import
authorStéphane Marchesin <marcheu@chromium.org>
Thu, 2 Apr 2015 03:00:08 +0000 (20:00 -0700)
committerStéphane Marchesin <marcheu@chromium.org>
Thu, 2 Apr 2015 03:13:37 +0000 (20:13 -0700)
This adds all the plumbing to get EGL_EXT_image_dma_buf_import in
i915g.

Signed-off-by: Stéphane Marchesin <marcheu@chromium.org>
src/gallium/auxiliary/target-helpers/inline_drm_helper.h
src/gallium/drivers/i915/i915_resource_texture.c
src/gallium/drivers/i915/i915_winsys.h
src/gallium/targets/pipe-loader/pipe_i915.c
src/gallium/winsys/i915/drm/i915_drm_buffer.c

index 54c1c6c325988f0cee305d2a2cecd2b46519224a..542ad43879043c4c19a93090dd1030ffc3f0b377 100644 (file)
@@ -430,7 +430,7 @@ dd_configuration(enum drm_conf conf)
 
 #if defined(GALLIUM_I915)
    if (strcmp(driver_name, "i915") == 0)
-      return NULL;
+      return configuration_query(conf);
    else
 #endif
 #if defined(GALLIUM_ILO)
index 36fb3e28a7530021089a86691c3a0f79c7763aa7..dc8f4d1c903fd6bc7d447ffa2284f715564882ab 100644 (file)
@@ -989,7 +989,7 @@ i915_texture_from_handle(struct pipe_screen * screen,
 
    assert(screen);
 
-   buffer = iws->buffer_from_handle(iws, whandle, &tiling, &stride);
+   buffer = iws->buffer_from_handle(iws, whandle, template->height0, &tiling, &stride);
 
    /* Only supports one type */
    if ((template->target != PIPE_TEXTURE_2D &&
index 6cf802fe073930f192a86612bdc23dd4cbc2f3d2..509e6cca13bbb0eabc1b02a897894e3aaf2821fd 100644 (file)
@@ -176,6 +176,7 @@ struct i915_winsys {
    struct i915_winsys_buffer *
       (*buffer_from_handle)(struct i915_winsys *iws,
                             struct winsys_handle *whandle,
+                            unsigned height,
                             enum i915_winsys_buffer_tile *tiling,
                             unsigned *stride);
 
index 85662cb85b589a648c736c73bfe07c0b9a929996..b0da6137f3d238cdc7c59fd90386beb1e3195e30 100644 (file)
@@ -23,5 +23,28 @@ create_screen(int fd)
    return screen;
 }
 
+static const struct drm_conf_ret throttle_ret = {
+   .type = DRM_CONF_INT,
+   .val.val_int = 2,
+};
+
+static const struct drm_conf_ret share_fd_ret = {
+   .type = DRM_CONF_BOOL,
+   .val.val_int = true,
+};
+
+static const struct drm_conf_ret *drm_configuration(enum drm_conf conf)
+{
+   switch (conf) {
+   case DRM_CONF_THROTTLE:
+      return &throttle_ret;
+   case DRM_CONF_SHARE_FD:
+      return &share_fd_ret;
+   default:
+      break;
+   }
+   return NULL;
+}
+
 PUBLIC
-DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen, NULL)
+DRM_DRIVER_DESCRIPTOR("i915", "i915", create_screen, drm_configuration)
index 38e06193c61f3b82079e76d07f2c62afcd995612..c0698529e1cf246ef4f796043c125da08e35d3d0 100644 (file)
@@ -1,4 +1,3 @@
-
 #include "state_tracker/drm_driver.h"
 #include "i915_drm_winsys.h"
 #include "util/u_memory.h"
@@ -72,7 +71,7 @@ i915_drm_buffer_create_tiled(struct i915_winsys *iws,
 
    buf->bo = drm_intel_bo_alloc_tiled(idws->gem_manager,
                                       i915_drm_type_to_name(type),
-                                     *stride, height, 1,
+                                      *stride, height, 1,
                                       &tiling_mode, &pitch, 0);
 
    if (!buf->bo)
@@ -91,6 +90,7 @@ err:
 static struct i915_winsys_buffer *
 i915_drm_buffer_from_handle(struct i915_winsys *iws,
                             struct winsys_handle *whandle,
+                            unsigned height,
                             enum i915_winsys_buffer_tile *tiling,
                             unsigned *stride)
 {
@@ -98,7 +98,7 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
    struct i915_drm_buffer *buf;
    uint32_t tile = 0, swizzle = 0;
 
-   if (whandle->type != DRM_API_HANDLE_TYPE_SHARED)
+   if ((whandle->type != DRM_API_HANDLE_TYPE_SHARED) && (whandle->type != DRM_API_HANDLE_TYPE_FD))
       return NULL;
 
    buf = CALLOC_STRUCT(i915_drm_buffer);
@@ -106,7 +106,14 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws,
       return NULL;
 
    buf->magic = 0xDEAD1337;
-   buf->bo = drm_intel_bo_gem_create_from_name(idws->gem_manager, "gallium3d_from_handle", whandle->handle);
+
+   if (whandle->type == DRM_API_HANDLE_TYPE_SHARED)
+       buf->bo = drm_intel_bo_gem_create_from_name(idws->gem_manager, "gallium3d_from_handle", whandle->handle);
+   else if (whandle->type == DRM_API_HANDLE_TYPE_FD) {
+       int fd = (int) whandle->handle;
+       buf->bo = drm_intel_bo_gem_create_from_prime(idws->gem_manager, fd, height * whandle->stride);
+   }
+
    buf->flinked = TRUE;
    buf->flink = whandle->handle;