From 8f7338f284cdb1fef64c85e3293d2200d0cc6387 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 3 Mar 2014 13:57:16 +1000 Subject: egl: add initial EGL_MESA_image_dma_buf_export v2.4 At the moment to get an EGL image to a dma-buf file descriptor, you have to use EGL_MESA_drm_image, and then use libdrm to convert this to a file descriptor. This extension just provides an API modelled on EGL_MESA_drm_image, to return a dma-buf file descriptor. v2: update spec for new API proposal add internal queries to get the fourcc back from intel driver. v2.1: add gallium pieces. v2.2: add offsets to spec and API, rename fd->fds, stride->strides in API. rewrite spec a bit more, add some q/a v2.3: add modifiers to query interface and 64-bit type for that (Daniel Stone) specifiy what happens to num fds vs num planes differences. (Chad Versace) v2.4: fix grammar (Daniel Stone) Signed-off-by: Dave Airlie --- src/gallium/state_trackers/dri/dri2.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/gallium/state_trackers/dri/dri2.c') diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index 7d65ba3..f8f4ecf 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -76,6 +76,30 @@ static int convert_fourcc(int format, int *dri_components_p) return format; } +static int convert_to_fourcc(int format) +{ + switch(format) { + case __DRI_IMAGE_FORMAT_RGB565: + format = __DRI_IMAGE_FOURCC_RGB565; + break; + case __DRI_IMAGE_FORMAT_ARGB8888: + format = __DRI_IMAGE_FOURCC_ARGB8888; + break; + case __DRI_IMAGE_FORMAT_XRGB8888: + format = __DRI_IMAGE_FOURCC_XRGB8888; + break; + case __DRI_IMAGE_FORMAT_ABGR8888: + format = __DRI_IMAGE_FOURCC_ABGR8888; + break; + case __DRI_IMAGE_FORMAT_XBGR8888: + format = __DRI_IMAGE_FOURCC_XBGR8888; + break; + default: + return -1; + } + return format; +} + /** * DRI2 flush extension. */ @@ -909,6 +933,12 @@ dri2_query_image(__DRIimage *image, int attrib, int *value) return GL_FALSE; *value = image->dri_components; return GL_TRUE; + case __DRI_IMAGE_ATTRIB_FOURCC: + *value = convert_to_fourcc(image->dri_format); + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_NUM_PLANES: + *value = 1; + return GL_TRUE; default: return GL_FALSE; } @@ -1203,7 +1233,7 @@ dri2_get_capabilities(__DRIscreen *_screen) /* The extension is modified during runtime if DRI_PRIME is detected */ static __DRIimageExtension dri2ImageExtension = { - .base = { __DRI_IMAGE, 10 }, + .base = { __DRI_IMAGE, 11 }, .createImageFromName = dri2_create_image_from_name, .createImageFromRenderbuffer = dri2_create_image_from_renderbuffer, -- cgit v1.1