GNOME Bugzilla – Bug 792378
qmlglsink: make work with eglfs_kms
Last modified: 2018-03-28 11:32:49 UTC
Created attachment 366567 [details] Log file I'm trying to run use qmlglsink. I'm running test qml app (gst-plugins-bad/tests/examples/qt/qmlsink/) on x86_64 linux PC using eglfs_kms mode. While everything works well on my desktop using X11, it always fails with "Failed to create a OpenGL context: EGL_BAD_CONTEXT" error without X. I believe it is the same bug described here: http://gstreamer-devel.966125.n4.nabble.com/Running-gmlglsink-without-x11-td4682127.html
Unless you're running with the patches from bug 782923, then I believe kms+qmlglsink will not work.
Thank you for the info. Is it only required patch to apply? So I need to close the bug and follow mentioned one, right?
Today I've tried to apply the patch to latest master (it was applied without errors) and there is an error "qtglwidget qtitem.cc:350:initWinSys: Failed to initialize egl: EGL_NOT_INITIALIZED".
Created attachment 368849 [details] [review] qmlglsink gbm patch The patch from bug 782923 is a requirement, but it is not sufficent. qmlglsink itself also needs to be patched. Here is a patch.
In the comments for bug 783521, there was this response by Matthew: ::: ext/qt/gstqtglutility.cc @@ +122,3 @@ + EGLDisplay egl_display = (EGLDisplay) + native->nativeResourceForWindow("egldisplay", NULL); + display = (GstGLDisplay *) gst_gl_display_egl_new_with_egl_display (egl_display); What if egl_display is invalid? Also, this code will always be run when libgstgl is GST_GL_HAVE_WINDOW_GBM enabled and realistically, could probably replace the next #else cause so you don't need to #elif GST_GL_HAVE_WINDOW_GBM. I added a check to see if egl_display is EGL_NO_DISPLAY, but beyond that, it is actually unclear to me what to do if there's no valid egl_display. The code does not indicate error handling for that. I also do not understand the comment about #else - removing that part seems erroneous, since it looks like a "generic EGL fallback"...?
Created attachment 368851 [details] [review] qmlglsink gbm patch v2 Accidentally uploaded an older version of the patch, which had an error. Here is the new one.
With latest patches from related issue qmlglsink shows video. I'd be glad to help you in any further testing.
Review of attachment 368851 [details] [review]: ::: ext/qt/gstqtglutility.cc @@ +43,3 @@ +#include <gst/gl/egl/gstegl.h> +#include <gst/gl/egl/gstgldisplay_egl.h> +#include <qpa/qplatformnativeinterface.h> This probably needs a new configure check, meson check? @@ +124,3 @@ + QGuiApplication::platformNativeInterface(); + EGLDisplay egl_display = (EGLDisplay) + native->nativeResourceForWindow("egldisplay", NULL); I'm wondering if this code shouldn't also be used for the #else (generic EGL) case below instead of randomly selecting 0 as EGL display.
Review of attachment 368851 [details] [review]: ::: ext/qt/gstqtglutility.cc @@ +43,3 @@ +#include <gst/gl/egl/gstegl.h> +#include <gst/gl/egl/gstgldisplay_egl.h> +#include <qpa/qplatformnativeinterface.h> There's no meson definition for qml plugins yet. configure check for qpa/qplatformnativeinterface.h already exists however need to be explicitly checked in the GBM case in order to enable GBM in qmlglsink. Same for the viv-fb case actually. @@ +120,3 @@ + * display. (It must be a non-NULL struct gbm_device * pointer.) So we have + * no choice but to use the native interface to get the EGLDisplay. + */ Remove "We actually use the code mentioned above in the comments," It's confusing :) Just state what we need to do for GBM. @@ +124,3 @@ + QGuiApplication::platformNativeInterface(); + EGLDisplay egl_display = (EGLDisplay) + native->nativeResourceForWindow("egldisplay", NULL); 0 is the 'any display' value defined in the egl headers so is not 'random' As for whether this should be used for generic EGL, probably. The main other use case for that is android where there is only ever one EGLDisplay.
Created attachment 369271 [details] [review] qmlglsink qpa egldisplay patch Looking at the GBM patch, it is apparent that there is nothing in there that is strictly GBM specific. Instead, it is QPA specific. So I changed the patch to add a preprocessor define to indicate the presence of qplatformnativeinterface.h . If present, QPlatformNativeInterface is used for getting the EGLDisplay. The existing GST_GL_DISPLAY_TYPE_ANY path is retained as a fallback if the QPA header isn't present.
commit 56a1eb65e2f82c36d5f63e1182ebf78680a0adba (HEAD -> master) Author: Carlos Rafael Giani <dv@pseudoterminal.org> Date: Sun Mar 4 15:14:08 2018 +0100 qt: Get EGL native display from QPA if platform header is available https://bugzilla.gnome.org/show_bug.cgi?id=792378