summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/dri
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2014-03-03 13:57:16 +1000
committerDave Airlie <[email protected]>2015-04-01 14:10:04 +1000
commit8f7338f284cdb1fef64c85e3293d2200d0cc6387 (patch)
tree23fed8ea291e6859c04fee041ba9b22d8d7e0fc4 /src/gallium/state_trackers/dri
parent22ccdf12dd7b5db6eb0c8f2b03c3516f8376fdad (diff)
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 <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/dri')
-rw-r--r--src/gallium/state_trackers/dri/dri2.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 7d65ba30f29..f8f4ecf36d7 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,