summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-09-15 13:47:53 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2015-01-28 17:35:16 +0100
commitf3c58d4ef4c2edb776bdd554502ecec8eed21044 (patch)
tree600e5dbde797364e570ca5b6bf76761b852382f2
parent073d6d59e1a95dedb8c97f66b55f641034e39a0c (diff)
downloadgst-vaapi-f3c58d4ef4c2edb776bdd554502ecec8eed21044.tar.gz
surface: add support for GEM buffer exports.
Add support for GEM buffer exports. This will only work with VA drivers based off libdrm, e.g. the Intel HD Graphics VA driver. This is needed to support interop with EGL and the "Desktop" GL specification. Indeed, the EXT_image_dma_buf_import extension is not going to be supported in Desktop GL, due to the lack of support for GL_TEXTURE_EXTERNAL_OES targets there. This is useful for implementing VA/EGL interop with legacy Mesa stacks, in Desktop OpenGL context. https://bugzilla.gnome.org/show_bug.cgi?id=736717
-rw-r--r--gst-libs/gst/vaapi/gstvaapibufferproxy.c6
-rw-r--r--gst-libs/gst/vaapi/gstvaapibufferproxy.h2
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface_drm.c22
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface_drm.h3
4 files changed, 33 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy.c b/gst-libs/gst/vaapi/gstvaapibufferproxy.c
index 485d555f..22e17f2a 100644
--- a/gst-libs/gst/vaapi/gstvaapibufferproxy.c
+++ b/gst-libs/gst/vaapi/gstvaapibufferproxy.c
@@ -45,6 +45,9 @@ from_GstVaapiBufferMemoryType (guint type)
case GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF:
va_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME;
break;
+ case GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF:
+ va_type = VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM;
+ break;
default:
va_type = 0;
break;
@@ -61,6 +64,9 @@ to_GstVaapiBufferMemoryType (guint va_type)
case VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME:
type = GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF;
break;
+ case VA_SURFACE_ATTRIB_MEM_TYPE_KERNEL_DRM:
+ type = GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF;
+ break;
default:
type = 0;
break;
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy.h b/gst-libs/gst/vaapi/gstvaapibufferproxy.h
index 3a92a2c8..a70d33f4 100644
--- a/gst-libs/gst/vaapi/gstvaapibufferproxy.h
+++ b/gst-libs/gst/vaapi/gstvaapibufferproxy.h
@@ -60,11 +60,13 @@ typedef struct _GstVaapiBufferProxy GstVaapiBufferProxy;
/**
* GstVaapiBufferMemoryType:
* @GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF: DRM PRIME buffer memory type.
+ * @GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF: Kernel DRM buffer memory type.
*
* Set of underlying VA buffer memory types.
*/
typedef enum {
GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF = 1,
+ GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF,
} GstVaapiBufferMemoryType;
GstVaapiBufferProxy *
diff --git a/gst-libs/gst/vaapi/gstvaapisurface_drm.c b/gst-libs/gst/vaapi/gstvaapisurface_drm.c
index 117ad390..bebbea1e 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface_drm.c
+++ b/gst-libs/gst/vaapi/gstvaapisurface_drm.c
@@ -75,3 +75,25 @@ gst_vaapi_surface_get_dma_buf_handle (GstVaapiSurface * surface)
return gst_vaapi_surface_get_drm_buf_handle (surface,
GST_VAAPI_BUFFER_MEMORY_TYPE_DMA_BUF);
}
+
+/**
+ * gst_vaapi_surface_get_gem_buf_handle:
+ * @surface: a #GstVaapiSurface
+ *
+ * If the underlying VA driver implementation supports it, this
+ * function allows for returning a suitable GEM buffer handle as a
+ * #GstVaapiBufferProxy instance. The resulting buffer handle is live
+ * until the last reference to the proxy gets released. Besides, any
+ * further change to the parent VA @surface may fail.
+ *
+ * Return value: the underlying buffer as a #GstVaapiBufferProxy
+ * instance.
+ */
+GstVaapiBufferProxy *
+gst_vaapi_surface_get_gem_buf_handle (GstVaapiSurface * surface)
+{
+ g_return_val_if_fail (surface != NULL, NULL);
+
+ return gst_vaapi_surface_get_drm_buf_handle (surface,
+ GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF);
+}
diff --git a/gst-libs/gst/vaapi/gstvaapisurface_drm.h b/gst-libs/gst/vaapi/gstvaapisurface_drm.h
index 90a5ebb5..cfbccbe1 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface_drm.h
+++ b/gst-libs/gst/vaapi/gstvaapisurface_drm.h
@@ -31,6 +31,9 @@ G_BEGIN_DECLS
GstVaapiBufferProxy *
gst_vaapi_surface_get_dma_buf_handle (GstVaapiSurface * surface);
+GstVaapiBufferProxy *
+gst_vaapi_surface_get_gem_buf_handle (GstVaapiSurface * surface);
+
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_DRM_H */