After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773453 - vaapi: support GLTextureUpload for EGL/Wayland
vaapi: support GLTextureUpload for EGL/Wayland
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 736713 748634
 
 
Reported: 2016-10-25 05:26 UTC by Hyunjun Ko
Modified: 2017-11-08 09:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gstreamer-vaapi-EGL-GLTextureUpload-2f368a4d.patch (5.91 KB, patch)
2017-08-04 07:08 UTC, Daniel van Vugt
none Details | Review
libs: surface: egl: error message if no extension (2.14 KB, patch)
2017-11-01 10:27 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: texture: egl: code style (1.39 KB, patch)
2017-11-01 10:27 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: display: egl: free leaked memory (1.09 KB, patch)
2017-11-01 10:27 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: fix memory leak when GL context is created (1011 bytes, patch)
2017-11-01 10:27 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: set GL objects if context is handled (1.37 KB, patch)
2017-11-01 10:28 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: set GL objects if ensured (2.30 KB, patch)
2017-11-01 10:28 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
plugins: centralize assignation of GL objects (2.39 KB, patch)
2017-11-01 10:28 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: texture: egl: update EGL display and context (2.24 KB, patch)
2017-11-01 10:28 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: display: egl: add gst_vaapi_display_egl_set_current_display() (3.49 KB, patch)
2017-11-01 10:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
libs: display: egl: add gst_vaapi_display_egl_set_current_display() (3.43 KB, patch)
2017-11-02 10:20 UTC, Víctor Manuel Jáquez Leal
committed Details | Review
libs: surface: egl: add comment (1.41 KB, patch)
2017-11-06 17:00 UTC, Víctor Manuel Jáquez Leal
committed Details | Review

Description Hyunjun Ko 2016-10-25 05:26:11 UTC
Currently, there are a couple of issues on gstreamer-vaapi, specifically running on Wayland

https://bugzilla.gnome.org/show_bug.cgi?id=772838
https://bugzilla.gnome.org/show_bug.cgi?id=770025

On X11, vaapi can create proper GLX context by itself.
But in case of EGL/Wayland, AFAIK, no.

To make it working through GLTextureUploadMeta, vaapi elements need GL context /display to upload.

If cluttersink can pass this information to upstream, gst-vaapi could use this info and make it working.

What do you think?
Or if there is other solution for this, that would be welcome!
Comment 1 Lionel Landwerlin 2016-10-25 06:26:03 UTC
What do think about the dmabuf support?
There are patches floating around (for Cogl and ClutterGst). It seems like a much better way of exchanging buffer.
Comment 2 Hyunjun Ko 2016-10-25 07:07:26 UTC
(In reply to Lionel Landwerlin from comment #1)
> What do think about the dmabuf support?
> There are patches floating around (for Cogl and ClutterGst). It seems like a
> much better way of exchanging buffer.

It could be much better than using GLTextureUploadMeta for sure, once it get started to work :)
Need to discuss with Victor or Jullien, who are working on handling dmabuf on gst-vaapi.
Comment 3 Víctor Manuel Jáquez Leal 2016-10-25 10:14:22 UTC
Hi Lionel,

Julien and I are working on dmabuf support for downstream in gstreamer-vaapi. We already have working branches for it, but we are waiting for the merge of the new caps feature memoy:dmabuf (bug 759358) and the having an vaapi-dmabuf allocator. These changes are going to be merged after the release 1.10

Do you have a branch with the patches needed for cluttersink in order to test?
Comment 4 Lionel Landwerlin 2016-10-25 10:21:51 UTC
Hi Victor,

Here is the Cogl branch (just a single commit) :
https://github.com/djdeath/cogl/tree/texture-dmabuf

And the corresponding ClutterGst branch :
https://github.com/djdeath/clutter-gst/tree/dmabuf
Comment 5 Daniel van Vugt 2017-08-04 07:08:10 UTC
Created attachment 356914 [details] [review]
gstreamer-vaapi-EGL-GLTextureUpload-2f368a4d.patch

Here's a patch for gstreamer-vaapi that implements the EGL-GLTextureUpload path. This completely fixes bug 773453 and bug 784369.

As an added bonus, it also helps to reduce the problem of bug 783850, but more work will be required on that one.
Comment 6 Víctor Manuel Jáquez Leal 2017-11-01 10:27:40 UTC
Created attachment 362733 [details] [review]
libs: surface: egl: error message if no extension

Instead of silently fail to export the image if there is not available
the EGL_MESA_drm_image, log an error message. Also a code refactoring
was done.
Comment 7 Víctor Manuel Jáquez Leal 2017-11-01 10:27:46 UTC
Created attachment 362734 [details] [review]
libs: texture: egl: code style
Comment 8 Víctor Manuel Jáquez Leal 2017-11-01 10:27:51 UTC
Created attachment 362735 [details] [review]
libs: display: egl: free leaked memory

The EGL VAAPI display forgot to release the egl display, context and
proxied VAAPI display.
Comment 9 Víctor Manuel Jáquez Leal 2017-11-01 10:27:58 UTC
Created attachment 362736 [details] [review]
plugins: fix memory leak when GL context is created

When the GL display and context are created inside an VAAPI element
the created GL context is leaked.
Comment 10 Víctor Manuel Jáquez Leal 2017-11-01 10:28:04 UTC
Created attachment 362737 [details] [review]
plugins: set GL objects if context is handled

Only set the GL display and GL other context if they are extracted
correctly from the gstreamer's context.
Comment 11 Víctor Manuel Jáquez Leal 2017-11-01 10:28:11 UTC
Created attachment 362738 [details] [review]
plugins: set GL objects if ensured

Only set the GL display and GL other context if they are ensured.
Comment 12 Víctor Manuel Jáquez Leal 2017-11-01 10:28:17 UTC
Created attachment 362739 [details] [review]
plugins: centralize assignation of GL objects

Add plugin_set_gst_gl() where the GstGL objects are assigned.
Comment 13 Víctor Manuel Jáquez Leal 2017-11-01 10:28:22 UTC
Created attachment 362740 [details] [review]
libs: texture: egl: update EGL display and context

It is required to use the context of the calling thread when wrapping
a foreign texture. According the documentation of
GstVideoGLTextureUploadMeta:

 "The caller of gst_video_gl_texture_upload_meta_upload() must
  have OpenGL set up and call this from a thread where it is valid
  to upload something to an OpenGL texture."

This patch updates the EGL display and context in GstVaapiDisplay
instance to the one used by te renderer that uploads the texture.

Original-patch-by: Daniel van Vugt <daniel.van.vugt@canonical.com>
Comment 14 Víctor Manuel Jáquez Leal 2017-11-01 10:28:29 UTC
Created attachment 362741 [details] [review]
libs: display: egl: add gst_vaapi_display_egl_set_current_display()

Adds a new function that changes the internal EGL display to the
current one (eglGetCurrentDisplay()) and sets the current context
too (eglGetCurrentContext()).

This new function is called by gst_vaapi_texture_egl_create() updating
the GstVaapiDisplayEGL with the current EGL display.
Comment 15 Víctor Manuel Jáquez Leal 2017-11-02 10:20:17 UTC
Created attachment 362803 [details] [review]
libs: display: egl: add gst_vaapi_display_egl_set_current_display()

Adds a new function that changes the internal EGL display to the
current one (eglGetCurrentDisplay()) and sets the current context
too (eglGetCurrentContext()).

This new function is called by gst_vaapi_texture_egl_create() updating
the GstVaapiDisplayEGL with the current EGL display.
Comment 16 Víctor Manuel Jáquez Leal 2017-11-06 17:00:21 UTC
Created attachment 363066 [details] [review]
libs: surface: egl: add comment

Add a warning comment when using old intel-vaapi-drivers (>1.8.4),
where the creation of surfaces from GEM fd may fail.
Comment 17 Víctor Manuel Jáquez Leal 2017-11-07 18:21:55 UTC
Attachment 362733 [details] pushed as ea503ed - libs: surface: egl: error message if no extension
Attachment 362734 [details] pushed as 0840c08 - libs: texture: egl: code style
Attachment 362735 [details] pushed as ac31160 - libs: display: egl: free leaked memory
Attachment 362736 [details] pushed as 4866e4c - plugins: fix memory leak when GL context is created
Attachment 362737 [details] pushed as fc1c415 - plugins: set GL objects if context is handled
Attachment 362738 [details] pushed as 3d56306 - plugins: set GL objects if ensured
Attachment 362739 [details] pushed as 8092537 - plugins: centralize assignation of GL objects
Attachment 362740 [details] pushed as 98a136a - libs: texture: egl: update EGL display and context
Attachment 362803 [details] pushed as 429e800 - libs: display: egl: add gst_vaapi_display_egl_set_current_display()
Attachment 363066 [details] pushed as e1f9959 - libs: surface: egl: add comment
Comment 18 Víctor Manuel Jáquez Leal 2017-11-07 18:34:35 UTC
Still to make it work in mutter for clutter-gst it is needed to export GST_GL_WINDOW=wayland to avoid the automatic detection which goes with XWayland.