mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
f3c58d4ef4
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
99 lines
3.2 KiB
C
99 lines
3.2 KiB
C
/*
|
|
* gstvaapisurface_drm.c - VA surface abstraction (DRM interop)
|
|
*
|
|
* Copyright (C) 2014 Intel Corporation
|
|
* Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
* as published by the Free Software Foundation; either version 2.1
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
* Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "sysdeps.h"
|
|
#include "gstvaapisurface_drm.h"
|
|
#include "gstvaapisurface_priv.h"
|
|
#include "gstvaapiimage_priv.h"
|
|
#include "gstvaapibufferproxy_priv.h"
|
|
|
|
static GstVaapiBufferProxy *
|
|
gst_vaapi_surface_get_drm_buf_handle (GstVaapiSurface * surface, guint type)
|
|
{
|
|
GstVaapiBufferProxy *proxy;
|
|
GstVaapiImage *image;
|
|
|
|
image = gst_vaapi_surface_derive_image (surface);
|
|
if (!image)
|
|
goto error_derive_image;
|
|
|
|
proxy =
|
|
gst_vaapi_buffer_proxy_new_from_object (GST_VAAPI_OBJECT (surface),
|
|
image->internal_image.buf, type, gst_vaapi_object_unref, image);
|
|
if (!proxy)
|
|
goto error_alloc_export_buffer;
|
|
return proxy;
|
|
|
|
/* ERRORS */
|
|
error_derive_image:
|
|
GST_ERROR ("failed to extract image handle from surface");
|
|
return NULL;
|
|
error_alloc_export_buffer:
|
|
GST_ERROR ("failed to allocate export buffer proxy");
|
|
gst_vaapi_object_unref (image);
|
|
return NULL;
|
|
}
|
|
|
|
/**
|
|
* gst_vaapi_surface_get_dma_buf_handle:
|
|
* @surface: a #GstVaapiSurface
|
|
*
|
|
* If the underlying VA driver implementation supports it, this
|
|
* function allows for returning a suitable dma_buf (DRM) 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_dma_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_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);
|
|
}
|