plugins: use linear storage if not the same device

When dmabuf is negotiated downstream and decoding and rendering are
not done on the same device, the layout has to be linear in order for
the memory to be shared accross devices, since each device has its
own way to do tiling.

Right now this code is rather just a to-do comment, since we are not
fetching the device ids.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
This commit is contained in:
Julien Isorce 2016-10-19 15:47:41 +01:00 committed by Víctor Manuel Jáquez Leal
parent 2d463f79f2
commit a8e482f93f

View file

@ -539,6 +539,26 @@ error_create_allocator:
}
}
static inline guint
get_dmabuf_surface_allocation_flags ()
{
/* @FIXME: fetch the real devices ids */
/* Pair vendor/device identifies an unique physical device. */
guint va_vendor_id = 0x00;
guint va_device_id = 0x00;
guint gl_vendor_id = 0x00;
guint gl_device_id = 0x00;
/* Requires linear memory only if fd export is done on a different
* device than the device where the fd is imported. */
gboolean same_physical_device = va_vendor_id == gl_vendor_id
&& va_device_id == gl_device_id;
if (same_physical_device)
return 0;
return GST_VAAPI_SURFACE_ALLOC_FLAG_LINEAR_STORAGE;
}
static gboolean
ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
GstCaps * caps)
@ -565,14 +585,12 @@ ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo,
return TRUE;
plugin->srcpad_allocator = NULL;
/* enable direct rendering if downstream requests raw video */
if (caps && gst_caps_is_video_raw (caps)) {
if (plugin->srcpad_can_dmabuf) {
if (GST_IS_VIDEO_DECODER (plugin) || GST_IS_BASE_TRANSFORM (plugin)) {
plugin->srcpad_allocator =
gst_vaapi_dmabuf_allocator_new (plugin->display, vinfo, 0,
GST_PAD_SRC);
gst_vaapi_dmabuf_allocator_new (plugin->display, vinfo,
get_dmabuf_surface_allocation_flags (), GST_PAD_SRC);
}
} else {
usage_flag = GST_VAAPI_IMAGE_USAGE_FLAG_DIRECT_RENDER;