summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorTopi Pohjolainen <[email protected]>2013-03-26 15:14:20 +0200
committerTopi Pohjolainen <[email protected]>2013-08-02 08:56:03 +0300
commit674dedc87a860f7aea41d5a37d8fd842e196dfdd (patch)
treeb6dc7fa791050f984ac36f0041e2f0dfdade0019 /src/mesa/drivers
parentee844b66605fed48fc61b8787b6a86cf1c4e94d7 (diff)
dri: propagate extra dma_buf import attributes to the drivers
v2: do not break ABI, but instead introduce new entry point for dma buffers and bump up the dri-interface version to eight v3 (Chad): allow the hook to specify an error originating from the driver. For now only unsupported format is considered. I thought about rejecting the hints also as they are addressing only YUV sampling which is not supported at the moment but then thought against it as the spec is not saying one way or the other. v4 (Eric, Chad): restrict to rgb formatted only v5: rebased on top of i915/i965 split v6 (Chad): document using full extension name Signed-off-by: Topi Pohjolainen <[email protected]> Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.h7
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c48
2 files changed, 53 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h
index 428f4dce1dc..ebb54886ac2 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ b/src/mesa/drivers/dri/i965/intel_regions.h
@@ -40,6 +40,7 @@
#include "main/mtypes.h"
#include "intel_bufmgr.h"
+#include <GL/internal/dri_interface.h>
#ifdef __cplusplus
extern "C" {
@@ -149,6 +150,12 @@ struct __DRIimageRec {
GLuint tile_y;
bool has_depthstencil;
+ /* Provided by EGL_EXT_image_dma_buf_import */
+ enum __DRIYUVColorSpace yuv_color_space;
+ enum __DRISampleRange sample_range;
+ enum __DRIChromaSiting horizontal_siting;
+ enum __DRIChromaSiting vertical_siting;
+
void *data;
};
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 3a3efc0f6cf..12a96c03f73 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -684,6 +684,49 @@ intel_create_image_from_fds(__DRIscreen *screen,
return image;
}
+static __DRIimage *
+intel_create_image_from_dma_bufs(__DRIscreen *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)
+{
+ __DRIimage *image;
+ struct intel_image_format *f = intel_image_format_lookup(fourcc);
+
+ /* For now only packed formats that have native sampling are supported. */
+ if (!f || f->nplanes != 1) {
+ *error = __DRI_IMAGE_ERROR_BAD_MATCH;
+ return NULL;
+ }
+
+ image = intel_create_image_from_fds(screen, width, height, fourcc, fds,
+ num_fds, strides, offsets,
+ loaderPrivate);
+
+ /*
+ * Invalid parameters and any inconsistencies between are assumed to be
+ * checked by the caller. Therefore besides unsupported formats one can fail
+ * only in allocation.
+ */
+ if (!image) {
+ *error = __DRI_IMAGE_ERROR_BAD_ALLOC;
+ return NULL;
+ }
+
+ image->yuv_color_space = yuv_color_space;
+ image->sample_range = sample_range;
+ image->horizontal_siting = horizontal_siting;
+ image->vertical_siting = vertical_siting;
+
+ *error = __DRI_IMAGE_ERROR_SUCCESS;
+ return image;
+}
static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
@@ -744,7 +787,7 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
}
static struct __DRIimageExtensionRec intelImageExtension = {
- .base = { __DRI_IMAGE, 7 },
+ .base = { __DRI_IMAGE, 8 },
.createImageFromName = intel_create_image_from_name,
.createImageFromRenderbuffer = intel_create_image_from_renderbuffer,
@@ -756,7 +799,8 @@ static struct __DRIimageExtensionRec intelImageExtension = {
.createImageFromNames = intel_create_image_from_names,
.fromPlanar = intel_from_planar,
.createImageFromTexture = intel_create_image_from_texture,
- .createImageFromFds = intel_create_image_from_fds
+ .createImageFromFds = intel_create_image_from_fds,
+ .createImageFromDmaBufs = intel_create_image_from_dma_bufs
};
static const __DRIextension *intelScreenExtensions[] = {