Commit 4df219f3 authored by Carlos Rafael Giani's avatar Carlos Rafael Giani Committed by Nicolas Dufresne

gl: Add Mesa3D GBM backend

This makes it possible to use the GStreamer OpenGL elements without a
windowing system if a libdrm- and Mesa3D-supported GPU is present

https://bugzilla.gnome.org/show_bug.cgi?id=782923
parent 79f9f9e6
......@@ -951,6 +951,7 @@ gst-libs/gst/gl/wayland/Makefile
gst-libs/gst/gl/win32/Makefile
gst-libs/gst/gl/x11/Makefile
gst-libs/gst/gl/viv-fb/Makefile
gst-libs/gst/gl/gbm/Makefile
gst-libs/gst/riff/Makefile
gst-libs/gst/rtp/Makefile
gst-libs/gst/rtsp/Makefile
......
......@@ -134,6 +134,11 @@ SUBDIRS += viv-fb
libgstgl_@GST_API_VERSION@_la_LIBADD += viv-fb/libgstgl-viv-fb.la
endif
if HAVE_WINDOW_GBM
SUBDIRS += gbm
libgstgl_@GST_API_VERSION@_la_LIBADD += gbm/libgstgl-gbm.la
endif
if USE_EGL
SUBDIRS += egl
libgstgl_@GST_API_VERSION@_la_LIBADD += egl/libgstgl-egl.la
......
......@@ -149,6 +149,14 @@ gst_gl_display_egl_get_from_native (GstGLDisplayType type, guintptr display)
ret = _gst_eglGetPlatformDisplay (EGL_PLATFORM_WAYLAND, (gpointer) display,
NULL);
}
#endif
#if GST_GL_HAVE_WINDOW_GBM
if (ret == EGL_NO_DISPLAY && (type & GST_GL_DISPLAY_TYPE_GBM) &&
(gst_gl_check_extension ("EGL_MESA_platform_gbm", egl_exts) ||
gst_gl_check_extension ("EGL_MESA_platform_gbm", egl_exts))) {
ret = _gst_eglGetPlatformDisplay (EGL_PLATFORM_GBM_MESA, (gpointer) display,
NULL);
}
#endif
/* android only has one winsys/display connection */
......
## Process this file with automake to produce Makefile.in
noinst_LTLIBRARIES = libgstgl-gbm.la
libgstgl_gbm_la_SOURCES = \
gstgl_gbm_utils.c \
gstgldisplay_gbm.c \
gstglwindow_gbm_egl.c
noinst_HEADERS = \
gstgl_gbm_utils.h \
gstgldisplay_gbm.h \
gstglwindow_gbm_egl.h
libgstgl_gbm_la_CFLAGS = \
-I$(top_srcdir)/gst-libs \
-I$(top_builddir)/gst-libs \
$(GL_CFLAGS) \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(DRM_CFLAGS) \
$(GBM_CFLAGS) \
$(G_UDEV_CFLAGS)
libgstgl_gbm_la_LDFLAGS = \
$(GST_LIB_LDFLAGS) \
$(GST_ALL_LDFLAGS) \
$(DRM_LIBS) \
$(GBM_LIBS) \
$(G_UDEV_LIBS)
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2018 Carlos Rafael Giani <dv@pseudoterminal.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GL_GBM_PRIVATE_H__
#define __GST_GL_GBM_PRIVATE_H__
#include <gbm.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <gst/gst.h>
typedef struct _GstGLDRMFramebuffer GstGLDRMFramebuffer;
struct _GstGLDRMFramebuffer
{
struct gbm_bo *bo;
guint32 fb_id;
};
const gchar* gst_gl_gbm_get_name_for_drm_connector (drmModeConnector * connector);
const gchar* gst_gl_gbm_get_name_for_drm_encoder (drmModeEncoder * encoder);
const gchar* gst_gl_gbm_format_to_string (guint32 format);
int gst_gl_gbm_depth_from_format (guint32 format);
int gst_gl_gbm_bpp_from_format (guint32 format);
GstGLDRMFramebuffer* gst_gl_gbm_drm_fb_get_from_bo (struct gbm_bo *bo);
int gst_gl_gbm_find_and_open_drm_node (void);
#endif /* __GST_GL_DISPLAY_GBM_UTILS_H__ */
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2018 Carlos Rafael Giani <dv@pseudoterminal.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GL_DISPLAY_GBM_H__
#define __GST_GL_DISPLAY_GBM_H__
#include <gbm.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <gst/gst.h>
#include <gst/gl/gstgldisplay.h>
#include <gst/gl/egl/gstegl.h>
G_BEGIN_DECLS
GType gst_gl_display_gbm_get_type (void);
#define GST_TYPE_GL_DISPLAY_GBM (gst_gl_display_gbm_get_type())
#define GST_GL_DISPLAY_GBM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY_GBM,GstGLDisplayGBM))
#define GST_GL_DISPLAY_GBM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_GL_DISPLAY_GBM,GstGLDisplayGBMClass))
#define GST_IS_GL_DISPLAY_GBM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY_GBM))
#define GST_IS_GL_DISPLAY_GBM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_GL_DISPLAY_GBM))
#define GST_GL_DISPLAY_GBM_CAST(obj) ((GstGLDisplayGBM*)(obj))
#define GST_GL_DISPLAY_GBM_PRIVATE(obj) (((GstGLDisplayGBM*)(obj))->priv)
typedef struct _GstGLDisplayGBM GstGLDisplayGBM;
typedef struct _GstGLDisplayGBMClass GstGLDisplayGBMClass;
struct _GstGLDisplayGBM
{
GstGLDisplay parent;
/* <private> */
int drm_fd;
drmModeRes *drm_mode_resources;
drmModeConnector *drm_mode_connector;
drmModeModeInfo *drm_mode_info;
int crtc_index;
guint32 crtc_id;
struct gbm_device *gbm_dev;
gpointer _reserved[GST_PADDING];
};
struct _GstGLDisplayGBMClass
{
GstGLDisplayClass object_class;
/*< private >*/
gpointer _reserved[GST_PADDING_LARGE];
};
GstGLDisplayGBM *gst_gl_display_gbm_new (void);
G_END_DECLS
#endif /* __GST_GL_DISPLAY_GBM_H__ */
This diff is collapsed.
/*
* GStreamer
* Copyright (C) 2018 Carlos Rafael Giani <dv@pseudoterminal.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __GST_GL_WINDOW_GBM_EGL_H__
#define __GST_GL_WINDOW_GBM_EGL_H__
#include <gbm.h>
#include <gst/gl/gl.h>
#include <gst/gl/egl/gstegl.h>
G_BEGIN_DECLS
#define GST_TYPE_GL_WINDOW_GBM_EGL (gst_gl_window_gbm_egl_get_type())
#define GST_GL_WINDOW_GBM_EGL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), GST_TYPE_GL_WINDOW_GBM_EGL, GstGLWindowGBMEGL))
#define GST_GL_WINDOW_GBM_EGL_CLASS(k) (G_TYPE_CHECK_CLASS((k), GST_TYPE_GL_WINDOW_GBM_EGL, GstGLWindowGBMEGLClass))
#define GST_IS_GL_WINDOW_GBM_EGL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GST_TYPE_GL_WINDOW_GBM_EGL))
#define GST_IS_GL_WINDOW_GBM_EGL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GST_TYPE_GL_WINDOW_GBM_EGL))
#define GST_GL_WINDOW_GBM_EGL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GST_TYPE_GL_WINDOW_GBM_EGL, GstGLWindowGBMEGL_Class))
typedef struct _GstGLWindowGBMEGL GstGLWindowGBMEGL;
typedef struct _GstGLWindowGBMEGLClass GstGLWindowGBMEGLClass;
typedef struct _GstGLDisplayGBM GstGLDisplayGBM;
struct _GstGLWindowGBMEGL {
/*< private >*/
GstGLWindow parent;
struct gbm_surface *gbm_surf;
struct gbm_bo *current_bo, *prev_bo;
int waiting_for_flip;
GstGLDisplayGBM *display;
gpointer _reserved[GST_PADDING];
};
struct _GstGLWindowGBMEGLClass {
/*< private >*/
GstGLWindowClass parent_class;
/*< private >*/
gpointer _reserved[GST_PADDING_LARGE];
};
GType gst_gl_window_gbm_egl_get_type (void);
GstGLWindowGBMEGL * gst_gl_window_gbm_egl_new (GstGLDisplay * display);
G_END_DECLS
#endif /* __GST_GL_WINDOW_GBM_EGL_H__ */
......@@ -73,6 +73,9 @@
#if GST_GL_HAVE_WINDOW_VIV_FB
#include <gst/gl/viv-fb/gstgldisplay_viv_fb.h>
#endif
#if GST_GL_HAVE_WINDOW_GBM
#include <gst/gl/gbm/gstgldisplay_gbm.h>
#endif
GST_DEBUG_CATEGORY_STATIC (gst_context);
GST_DEBUG_CATEGORY_STATIC (gst_gl_display_debug);
......@@ -313,6 +316,11 @@ gst_gl_display_new (void)
display = GST_GL_DISPLAY (gst_gl_display_viv_fb_new (disp_idx));
}
#endif
#if GST_GL_HAVE_WINDOW_GBM
if (!display && (!user_choice || g_strstr_len (user_choice, 3, "gbm"))) {
display = GST_GL_DISPLAY (gst_gl_display_gbm_new ());
}
#endif
#if GST_GL_HAVE_PLATFORM_EGL
if (!display && (!platform_choice
|| g_strstr_len (platform_choice, 3, "egl")))
......
......@@ -49,6 +49,7 @@ GType gst_gl_display_get_type (void);
* @GST_GL_DISPLAY_TYPE_DISPMANX: Dispmanx display
* @GST_GL_DISPLAY_TYPE_EGL: EGL display
* @GST_GL_DISPLAY_TYPE_VIV_FB: Vivante Framebuffer display
* @GST_GL_DISPLAY_TYPE_GBM: Mesa3D GBM display
* @GST_GL_DISPLAY_TYPE_ANY: any display type
*/
typedef enum
......@@ -61,6 +62,7 @@ typedef enum
GST_GL_DISPLAY_TYPE_DISPMANX = (1 << 4),
GST_GL_DISPLAY_TYPE_EGL = (1 << 5),
GST_GL_DISPLAY_TYPE_VIV_FB = (1 << 6),
GST_GL_DISPLAY_TYPE_GBM = (1 << 7),
GST_GL_DISPLAY_TYPE_ANY = G_MAXUINT32
} GstGLDisplayType;
......
......@@ -62,6 +62,9 @@
#if GST_GL_HAVE_WINDOW_VIV_FB
#include "viv-fb/gstglwindow_viv_fb_egl.h"
#endif
#if GST_GL_HAVE_WINDOW_GBM
#include "gbm/gstglwindow_gbm_egl.h"
#endif
#if GST_GL_HAVE_WINDOW_DISPMANX
#include "dispmanx/gstglwindow_dispmanx_egl.h"
#endif
......@@ -279,6 +282,10 @@ gst_gl_window_new (GstGLDisplay * display)
if (!window && (!user_choice || g_strstr_len (user_choice, 6, "viv-fb")))
window = GST_GL_WINDOW (gst_gl_window_viv_fb_egl_new (display));
#endif
#if GST_GL_HAVE_WINDOW_GBM
if (!window && (!user_choice || g_strstr_len (user_choice, 3, "gbm")))
window = GST_GL_WINDOW (gst_gl_window_gbm_egl_new (display));
#endif
if (!window) {
/* subclass returned a NULL window */
......
......@@ -126,6 +126,7 @@ HAVE_GLES2=no
HAVE_GLES3_H=no
HAVE_WAYLAND_EGL=no
HAVE_VIV_FB_EGL=no
HAVE_GBM_EGL=no
HAVE_EGL_RPI=no
case $host in
......@@ -171,6 +172,12 @@ case $host in
AC_CHECK_LIB([EGL], [fbGetDisplay], [HAVE_VIV_FB_EGL=yes])
fi
if test "x$HAVE_EGL" = "xyes" -a "x$HAVE_DRM" = "xyes"; then
PKG_CHECK_MODULES(GBM, gbm, HAVE_GBM_EGL=yes, HAVE_GBM_EGL=no)
AC_SUBST(GBM_CFLAGS)
AC_SUBST(GBM_LIBS)
fi
dnl FIXME: Mali EGL depends on GLESv1 or GLESv2
AC_CHECK_HEADER([EGL/fbdev_window.h],
[
......@@ -467,6 +474,16 @@ case $host in
fi
fi
if test "x$HAVE_GBM_EGL" = "xyes"; then
if test "x$NEED_EGL" = "xno" -o "x$HAVE_EGL" = "xno"; then
AC_MSG_WARN([EGL is required by the Mesa GBM EGL backend])
else
HAVE_WINDOW_GBM=yes
GL_LIBS="$GL_LIBS"
GL_CFLAGS="$GL_CFLAGS"
fi
fi
if test "x$HAVE_X11_XCB" = "xyes" -a "x$HAVE_EGL_RPI" = "xno"; then
if test "x$NEED_X11" != "xno"; then
GL_LIBS="$GL_LIBS $X11_XCB_LIBS"
......@@ -511,7 +528,7 @@ case $host in
fi
else
if test "x$NEED_EGL" != "xno"; then
if test "x$HAVE_WINDOW_WAYLAND" = "xyes" -o "x$HAVE_WINDOW_X11" = "xyes" -o "x$HAVE_WINDOW_DISPMANX" = "xyes" -o "x$HAVE_WINDOW_VIV_FB" = "xyes"; then
if test "x$HAVE_WINDOW_WAYLAND" = "xyes" -o "x$HAVE_WINDOW_X11" = "xyes" -o "x$HAVE_WINDOW_DISPMANX" = "xyes" -o "x$HAVE_WINDOW_VIV_FB" = "xyes" -o "x$HAVE_WINDOW_GBM" = "xyes"; then
GL_LIBS="$GL_LIBS -lEGL $EGL_LIBS"
GL_CFLAGS="$GL_CFLAGS $EGL_CFLAGS"
USE_EGL=yes
......@@ -669,6 +686,7 @@ GST_GL_HAVE_WINDOW_ANDROID=0
GST_GL_HAVE_WINDOW_DISPMANX=0
GST_GL_HAVE_WINDOW_EAGL=0
GST_GL_HAVE_WINDOW_VIV_FB=0
GST_GL_HAVE_WINDOW_GBM=0
if test "x$HAVE_WINDOW_X11" = "xyes"; then
GL_WINDOWS="x11 $GL_WINDOWS"
......@@ -702,6 +720,10 @@ if test "x$HAVE_WINDOW_VIV_FB" = "xyes"; then
GL_WINDOWS="viv-fb $GL_WINDOWS"
GST_GL_HAVE_WINDOW_VIV_FB=1
fi
if test "x$HAVE_WINDOW_GBM" = "xyes"; then
GL_WINDOWS="gbm $GL_WINDOWS"
GST_GL_HAVE_WINDOW_GBM=1
fi
GL_CONFIG_DEFINES="$GL_CONFIG_DEFINES
#define GST_GL_HAVE_WINDOW_X11 $GST_GL_HAVE_WINDOW_X11
......@@ -712,6 +734,7 @@ GL_CONFIG_DEFINES="$GL_CONFIG_DEFINES
#define GST_GL_HAVE_WINDOW_DISPMANX $GST_GL_HAVE_WINDOW_DISPMANX
#define GST_GL_HAVE_WINDOW_EAGL $GST_GL_HAVE_WINDOW_EAGL
#define GST_GL_HAVE_WINDOW_VIV_FB $GST_GL_HAVE_WINDOW_VIV_FB
#define GST_GL_HAVE_WINDOW_GBM $GST_GL_HAVE_WINDOW_GBM
"
dnl PLATFORM's
......@@ -789,6 +812,7 @@ if test "x$GL_APIS" = "x" -o "x$GL_PLATFORMS" = "x" -o "x$GL_WINDOWS" = "x"; the
HAVE_WINDOW_COCOA=no
HAVE_WINDOW_EAGL=no
HAVE_WINDOW_VIV_FB=no
HAVE_WINDOW_GBM=no
fi
AC_SUBST(GL_APIS)
......@@ -808,6 +832,7 @@ AM_CONDITIONAL(HAVE_WINDOW_WAYLAND, test "x$HAVE_WINDOW_WAYLAND" = "xyes")
AM_CONDITIONAL(HAVE_WINDOW_ANDROID, test "x$HAVE_WINDOW_ANDROID" = "xyes")
AM_CONDITIONAL(HAVE_WINDOW_EAGL, test "x$HAVE_WINDOW_EAGL" = "xyes")
AM_CONDITIONAL(HAVE_WINDOW_VIV_FB, test "x$HAVE_WINDOW_VIV_FB" = "xyes")
AM_CONDITIONAL(HAVE_WINDOW_GBM, test "x$HAVE_WINDOW_GBM" = "xyes")
AM_CONDITIONAL(USE_OPENGL, test "x$USE_OPENGL" = "xyes")
AM_CONDITIONAL(USE_GLES2, test "x$USE_GLES2" = "xyes")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment