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 745233 - vaapidecode: set the GL context when creating a GstVaapiTexture (GLX)
vaapidecode: set the GL context when creating a GstVaapiTexture (GLX)
Status: RESOLVED DUPLICATE of bug 753099
Product: gstreamer-vaapi
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
: 746650 (view as bug list)
Depends on:
Blocks: 755406
 
 
Reported: 2015-02-26 17:41 UTC by Víctor Manuel Jáquez Leal
Modified: 2015-11-19 17:34 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Víctor Manuel Jáquez Leal 2015-02-26 17:41:40 UTC
When glimagesink is used, this sink sends to vaapidecode the GL context to use in GLX. The merged EGL branch handle this right now.

But, when meta:GLTextureUploadMeta is negotiated and vaapidecode tries to create a GstVaapTexture_glx with the processed texture, the element is not using the received GL context from the sink so the texture processing fails. 

I haven't tried with EGL, but it seems that the bits already are in place.
Comment 1 Víctor Manuel Jáquez Leal 2015-03-04 11:36:48 UTC
Just to confirm that enabling EGL and disabling GLX, the context sharing with the glimagesink works like a charm.
Comment 2 Víctor Manuel Jáquez Leal 2015-03-23 15:23:49 UTC
*** Bug 746650 has been marked as a duplicate of this bug. ***
Comment 3 Vasilis Liaskovitis 2015-06-18 21:08:46 UTC
Hi, is it possible to make this context sharing work for vaapi + GLX? Any pointers on how to do it would be helpful. 

Is this supposed to lead to a pipeline error or only suboptimal performance due to non-zero copy behaviour? 

The pipeline filesrc ! demux ! vaapidecode ! glimagesink works for some file formats (mp4/qtdemux), I assume without proper context sharing. But fails for others (e.g. avi/avidemux) with a negotiation failure. But i think this happens even with vaapisink, so maybe it's a different bug.
Comment 4 Víctor Manuel Jáquez Leal 2015-06-19 10:35:13 UTC
(In reply to Vasilis Liaskovitis from comment #3)
> Hi, is it possible to make this context sharing work for vaapi + GLX? Any
> pointers on how to do it would be helpful.

Actually, I'm not sure if this bug is still valid.
 
> 
> Is this supposed to lead to a pipeline error or only suboptimal performance
> due to non-zero copy behaviour? 

gl elements are evolving constantly, and they are not supposed to be considered stable. So, one day they might be working, and the next, not.

For example, right now, in gstreamer-1.4, as you pointed below, some streams are not negotiated with glimagesink, and some others are. But in gstreamer-1.5 must of them works.

This bug, in the past, led to a pipeline error (different to negotiation), but now, as gl has become significantly better, GLX works, but when using OpenGL3 glimagesink has some complains.

Right now, with gstreamer-1.5 (current master)

GST_GL_WINDOW=x11 GST_GL_API=gles2 GST_GL_PLATFORM=egl   - OK
GST_GL_WINDOW=x11 GST_GL_API=opengl GST_GL_PLATFORM=glx  - OK
GST_GL_WINDOW=x11 GST_GL_API=opengl3 GST_GL_PLATFORM=glx - NOT OK

These are the errors shown with opengl3 and glx:

0:00:00.335460953 11561 0x7fb400046450 ERROR              glcontext gstglcontext.c:1078:_gst_gl_debug_callback:<glcontextglx0> high: GL error from API id:2, GL_INVALID_ENUM in glIsEnabled(GL_TEXTURE_2D)
0:00:00.335489173 11561 0x7fb400046450 ERROR              glcontext gstglcontext.c:1078:_gst_gl_debug_callback:<glcontextglx0> high: GL error from API id:2, GL_INVALID_ENUM in glEnable(GL_TEXTURE_2D)
0:00:00.335506643 11561 0x7fb400046450 ERROR              glcontext gstglcontext.c:1078:_gst_gl_debug_callback:<glcontextglx0> high: GL error from API id:2, GL_INVALID_ENUM in glGetTexLevelParameter[if]v(pname=GL_TEXTURE_BORDER)
0:00:00.335520615 11561 0x7fb400046450 ERROR              glcontext gstglcontext.c:1078:_gst_gl_debug_callback:<glcontextglx0> high: GL error from API id:2, GL_INVALID_ENUM in glDisable(GL_TEXTURE_2D)


> 
> The pipeline filesrc ! demux ! vaapidecode ! glimagesink works for some file
> formats (mp4/qtdemux), I assume without proper context sharing. But fails
> for others (e.g. avi/avidemux) with a negotiation failure. But i think this
> happens even with vaapisink, so maybe it's a different bug.

In the case of gstreamer-1.4 the vaapidecode never links to the glimagesink and the preroll never occurs. I don't know if it is worth to fix since only happen in gstreamer-1.4.
Comment 5 Vasilis Liaskovitis 2015-06-22 14:28:53 UTC
thanks, I confirm that current master repos work with  x11+opengl+GLX. 

Is context sharing always happening when creating the GstVaapTexture_glx (for performance reasons) or is it possible that the texture is copied due to different vaapi and sink gl contexts? Can I verify this from any particular log messages?
Comment 6 Víctor Manuel Jáquez Leal 2015-06-22 15:26:49 UTC
I have just pushed a couple commits which log the negotiated caps, either in vaapidecode and vaapipostroc, hence, if you run something like

$ GST_GL_WINDOW=x11 GST_GL_API=opengl GST_GL_PLATFORM=glx \
    gst-play-1.0 video.mp4 --videosink=glimagesink \
       --gst-debug="vaapidecode:4,vaapipostproc:4"

You should see something like:

new src caps = video/x-raw(meta:GstVideoGLTextureUploadMeta)

If so, the context has been shared and the sink uploads the frame from the decoder into its texture. The upload can be zero-copy or, at least, much more cheaper than mem copy.
Comment 7 Vasilis Liaskovitis 2015-06-22 22:41:49 UTC
thanks! yes i now see the GstVideoGLTextureUploadMeta with the gst-play example you mentioned.

I don't see it in the gst-launch pipeline below though, is that expected? Are any changes needed in the pipeline? 

GST_DEBUG=4,*vaapi*:6  gst-launch-1.0 -v filesrc location=/opt/video.mp4  ! qtdemux ! vaapidecode ! glimagesink
Comment 8 Víctor Manuel Jáquez Leal 2015-06-23 07:05:29 UTC
(In reply to Vasilis Liaskovitis from comment #7)
> thanks! yes i now see the GstVideoGLTextureUploadMeta with the gst-play
> example you mentioned.
> 
> I don't see it in the gst-launch pipeline below though, is that expected?
> Are any changes needed in the pipeline? 

I see it. (gstreamer 1.5, current master)

> 
> GST_DEBUG=4,*vaapi*:6  gst-launch-1.0 -v filesrc location=/opt/video.mp4  !
> qtdemux ! vaapidecode ! glimagesink

Anyway, let's do not turn a bug tracker into a support forum.
Comment 9 Víctor Manuel Jáquez Leal 2015-11-19 17:34:55 UTC
Reviewing the bug, I realized that it just turned into a duplicated of bug 753099

*** This bug has been marked as a duplicate of bug 753099 ***