summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarad Gautam <[email protected]>2017-05-30 17:24:08 +0530
committerDaniel Stone <[email protected]>2017-06-08 22:27:30 +0100
commitc303772e5bedabe10918373c60e6b3e46c5a16ab (patch)
tree35ee5b89c400f36391fae90b90b6f27a499affbf
parentf58e6358bf775e21d49f7a0ea0007f1940c48217 (diff)
i965: Support dmabuf import with modifiers
Add support for createImageFromDmaBufs2, adding a modifier to the original, and allow importing CCS resources with auxiliary data from dmabufs. v2: avoid DRIimageExtension version bump, pass single modifier to createImageFromDmaBufs2. Reviewed-by: Daniel Stone <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c94
1 files changed, 76 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 638a9b080bd..94b2af38e4c 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -304,6 +304,19 @@ static const struct {
.height_align = 32 },
};
+static bool
+modifier_is_supported(uint64_t modifier)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(tiling_modifier_map); i++) {
+ if (tiling_modifier_map[i].modifier == modifier)
+ return true;
+ }
+
+ return false;
+}
+
static uint32_t
modifier_to_tiling(uint64_t modifier)
{
@@ -827,10 +840,11 @@ intel_create_image_from_names(__DRIscreen *dri_screen,
}
static __DRIimage *
-intel_create_image_from_fds(__DRIscreen *dri_screen,
- int width, int height, int fourcc,
- int *fds, int num_fds, int *strides, int *offsets,
- void *loaderPrivate)
+intel_create_image_from_fds_common(__DRIscreen *dri_screen,
+ int width, int height, int fourcc,
+ uint64_t modifier, int *fds, int num_fds,
+ int *strides, int *offsets,
+ void *loaderPrivate)
{
struct intel_screen *screen = dri_screen->driverPrivate;
struct intel_image_format *f;
@@ -845,6 +859,9 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
if (f == NULL)
return NULL;
+ if (modifier != DRM_FORMAT_MOD_INVALID && !modifier_is_supported(modifier))
+ return NULL;
+
if (f->nplanes == 1)
image = intel_allocate_image(screen, f->planes[0].dri_format,
loaderPrivate);
@@ -880,7 +897,10 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
}
}
- image->modifier = tiling_to_modifier(image->bo->tiling_mode);
+ if (modifier != DRM_FORMAT_MOD_INVALID)
+ image->modifier = modifier;
+ else
+ image->modifier = tiling_to_modifier(image->bo->tiling_mode);
tiled_height = get_tiled_height(image->modifier, height);
int size = 0;
@@ -914,16 +934,29 @@ intel_create_image_from_fds(__DRIscreen *dri_screen,
}
static __DRIimage *
-intel_create_image_from_dma_bufs(__DRIscreen *dri_screen,
- int width, int height, int fourcc,
- int *fds, int num_fds,
- int *strides, int *offsets,
- enum __DRIYUVColorSpace yuv_color_space,
- enum __DRISampleRange sample_range,
- enum __DRIChromaSiting horizontal_siting,
- enum __DRIChromaSiting vertical_siting,
- unsigned *error,
- void *loaderPrivate)
+intel_create_image_from_fds(__DRIscreen *dri_screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds, int *strides, int *offsets,
+ void *loaderPrivate)
+{
+ return intel_create_image_from_fds_common(dri_screen, width, height, fourcc,
+ DRM_FORMAT_MOD_INVALID,
+ fds, num_fds, strides, offsets,
+ loaderPrivate);
+}
+
+static __DRIimage *
+intel_create_image_from_dma_bufs2(__DRIscreen *dri_screen,
+ int width, int height,
+ int fourcc, uint64_t modifier,
+ int *fds, int num_fds,
+ int *strides, int *offsets,
+ enum __DRIYUVColorSpace yuv_color_space,
+ enum __DRISampleRange sample_range,
+ enum __DRIChromaSiting horizontal_siting,
+ enum __DRIChromaSiting vertical_siting,
+ unsigned *error,
+ void *loaderPrivate)
{
__DRIimage *image;
struct intel_image_format *f = intel_image_format_lookup(fourcc);
@@ -933,9 +966,10 @@ intel_create_image_from_dma_bufs(__DRIscreen *dri_screen,
return NULL;
}
- image = intel_create_image_from_fds(dri_screen, width, height, fourcc, fds,
- num_fds, strides, offsets,
- loaderPrivate);
+ image = intel_create_image_from_fds_common(dri_screen, width, height,
+ fourcc, modifier,
+ fds, num_fds, strides, offsets,
+ loaderPrivate);
/*
* Invalid parameters and any inconsistencies between are assumed to be
@@ -958,6 +992,29 @@ intel_create_image_from_dma_bufs(__DRIscreen *dri_screen,
}
static __DRIimage *
+intel_create_image_from_dma_bufs(__DRIscreen *dri_screen,
+ int width, int height, int fourcc,
+ int *fds, int num_fds,
+ int *strides, int *offsets,
+ enum __DRIYUVColorSpace yuv_color_space,
+ enum __DRISampleRange sample_range,
+ enum __DRIChromaSiting horizontal_siting,
+ enum __DRIChromaSiting vertical_siting,
+ unsigned *error,
+ void *loaderPrivate)
+{
+ return intel_create_image_from_dma_bufs2(dri_screen, width, height,
+ fourcc, DRM_FORMAT_MOD_INVALID,
+ fds, num_fds, strides, offsets,
+ yuv_color_space,
+ sample_range,
+ horizontal_siting,
+ vertical_siting,
+ error,
+ loaderPrivate);
+}
+
+static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
{
int width, height, offset, stride, dri_format, index;
@@ -1023,6 +1080,7 @@ static const __DRIimageExtension intelImageExtension = {
.mapImage = NULL,
.unmapImage = NULL,
.createImageWithModifiers = intel_create_image_with_modifiers,
+ .createImageFromDmaBufs2 = intel_create_image_from_dma_bufs2,
};
static uint64_t