1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
From 34694bbfcf8d532eff3f168fba867d7f0668447f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Le=20Page?= <llepage@igalia.com>
Date: Thu, 19 Oct 2023 18:45:29 +0200
Subject: [PATCH 1/2] gl: fix "winrt" string comparison in
gst_gl_display_type_from_environment
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5511>
---
subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
index 2a041b7b0a6..304c0e09a0f 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
@@ -308,7 +308,7 @@ gst_gl_display_type_from_environment (void)
return GST_GL_DISPLAY_TYPE_EAGL;
} else if (g_strstr_len (env, 7, "android")) {
return GST_GL_DISPLAY_TYPE_EGL;
- } else if (g_strstr_len (env, 4, "winrt")) {
+ } else if (g_strstr_len (env, 5, "winrt")) {
return GST_GL_DISPLAY_TYPE_EGL;
} else {
return GST_GL_DISPLAY_TYPE_NONE;
--
GitLab
From e1ca5754089df4673703be346d741c05018d2c24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Le=20Page?= <llepage@igalia.com>
Date: Thu, 19 Oct 2023 14:10:16 +0200
Subject: [PATCH 2/2] gl: add support for surfaceless display in GstGL
Use of the EGL_MESA_platform_surfaceless EGL extension to create an EGL
display that is not depending on any kind of windowing system.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5511>
---
girs/GstGL-1.0.gir | 4 +-
.../gst-libs/gst/gl/egl/gstgldisplay_egl.c | 54 ++++++++++++++++---
.../gst-libs/gst/gl/egl/gstgldisplay_egl.h | 3 ++
.../gst-libs/gst/gl/gstgldisplay.c | 9 +++-
.../gst-libs/gst/gl/gstgldisplay.h | 9 ++++
.../gst-libs/gst/gl/gstglwindow.c | 3 ++
.../gst-libs/gst/gl/meson.build | 33 ++++++++++--
.../gst-plugins-base/meson_options.txt | 2 +-
subprojects/gstreamer/docs/gst/running.md | 2 +-
subprojects/gstreamer/docs/index.md | 2 +-
10 files changed, 107 insertions(+), 14 deletions(-)
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.c
index e617b8adb88..902416c19f6 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.c
@@ -25,8 +25,8 @@
* @see_also: #GstGLDisplay
*
* #GstGLDisplayEGL represents a connection to an EGL `EGLDisplay` handle created
- * internally (gst_gl_display_egl_new()) or wrapped by the application
- * (gst_gl_display_egl_new_with_egl_display())
+ * internally (gst_gl_display_egl_new() or gst_gl_display_egl_new_surfaceless())
+ * or wrapped by the application (gst_gl_display_egl_new_with_egl_display())
*/
#ifdef HAVE_CONFIG_H
@@ -122,8 +122,8 @@ gst_gl_display_egl_finalize (GObject * object)
* @display: pointer to a display (or 0)
*
* Attempts to create a new `EGLDisplay` from @display. If @type is
- * %GST_GL_DISPLAY_TYPE_ANY, then @display must be 0. @type must not be
- * %GST_GL_DISPLAY_TYPE_NONE.
+ * %GST_GL_DISPLAY_TYPE_ANY or %GST_GL_DISPLAY_TYPE_EGL_SURFACELESS, then
+ * @display must be 0. @type must not be %GST_GL_DISPLAY_TYPE_NONE.
*
* Returns: (nullable): A `EGLDisplay` or `EGL_NO_DISPLAY`
*
@@ -137,8 +137,11 @@ gst_gl_display_egl_get_from_native (GstGLDisplayType type, guintptr display)
_gst_eglGetPlatformDisplay_type _gst_eglGetPlatformDisplay = NULL;
g_return_val_if_fail (type != GST_GL_DISPLAY_TYPE_NONE, EGL_NO_DISPLAY);
- g_return_val_if_fail ((type != GST_GL_DISPLAY_TYPE_ANY && display != 0)
- || (type == GST_GL_DISPLAY_TYPE_ANY && display == 0), EGL_NO_DISPLAY);
+ g_return_val_if_fail ((type != GST_GL_DISPLAY_TYPE_ANY &&
+ type != GST_GL_DISPLAY_TYPE_EGL_SURFACELESS && display != 0)
+ || ((type == GST_GL_DISPLAY_TYPE_ANY ||
+ type == GST_GL_DISPLAY_TYPE_EGL_SURFACELESS) && display == 0),
+ EGL_NO_DISPLAY);
init_debug ();
@@ -233,6 +236,11 @@ gst_gl_display_egl_get_from_native (GstGLDisplayType type, guintptr display)
NULL);
}
/* android only has one winsys/display connection */
+ if (ret == EGL_NO_DISPLAY && (type & GST_GL_DISPLAY_TYPE_EGL_SURFACELESS) &&
+ gst_gl_check_extension ("EGL_MESA_platform_surfaceless", egl_exts)) {
+ ret = _gst_eglGetPlatformDisplay (EGL_PLATFORM_SURFACELESS_MESA,
+ (gpointer) display, NULL);
+ }
if (ret != EGL_NO_DISPLAY)
return ret;
@@ -272,6 +280,40 @@ gst_gl_display_egl_new (void)
return ret;
}
+/**
+ * gst_gl_display_egl_new_surfaceless:
+ *
+ * Create a new surfaceless #GstGLDisplayEGL using the Mesa3D
+ * EGL_PLATFORM_SURFACELESS_MESA extension.
+ *
+ * Returns: (transfer full) (nullable): a new #GstGLDisplayEGL or %NULL
+ *
+ * Since: 1.24
+ */
+GstGLDisplayEGL *
+gst_gl_display_egl_new_surfaceless (void)
+{
+ GstGLDisplayEGL *ret;
+ gpointer display;
+
+ init_debug ();
+
+ display =
+ gst_gl_display_egl_get_from_native (GST_GL_DISPLAY_TYPE_EGL_SURFACELESS,
+ 0);
+
+ if (!display) {
+ GST_INFO ("Failed to create a surfaceless EGL display");
+ return NULL;
+ }
+
+ ret = g_object_new (GST_TYPE_GL_DISPLAY_EGL, NULL);
+ gst_object_ref_sink (ret);
+ ret->display = display;
+
+ return ret;
+}
+
/**
* gst_gl_display_egl_new_with_display:
* @display: an existing and connected EGLDisplay
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.h b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.h
index 23dc01a9ddb..f7e27de5f9d 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.h
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstgldisplay_egl.h
@@ -66,6 +66,9 @@ struct _GstGLDisplayEGLClass
GST_GL_API
GstGLDisplayEGL *gst_gl_display_egl_new (void);
+GST_GL_API
+GstGLDisplayEGL *gst_gl_display_egl_new_surfaceless (void);
+
GST_GL_API
GstGLDisplayEGL *gst_gl_display_egl_new_with_egl_display (gpointer display);
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
index 304c0e09a0f..d51863c4bed 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.c
@@ -34,7 +34,7 @@
* There are a number of environment variables that influence the choice of
* platform and window system specific functionality.
* - GST_GL_WINDOW influences the window system to use. Common values are
- * 'x11', 'wayland', 'win32' or 'cocoa'.
+ * 'x11', 'wayland', 'surfaceless', 'win32' or 'cocoa'.
* - GST_GL_PLATFORM influences the OpenGL platform to use. Common values are
* 'egl', 'glx', 'wgl' or 'cgl'.
* - GST_GL_API influences the OpenGL API requested by the OpenGL platform.
@@ -310,6 +310,8 @@ gst_gl_display_type_from_environment (void)
return GST_GL_DISPLAY_TYPE_EGL;
} else if (g_strstr_len (env, 5, "winrt")) {
return GST_GL_DISPLAY_TYPE_EGL;
+ } else if (g_strstr_len (env, 11, "surfaceless")) {
+ return GST_GL_DISPLAY_TYPE_EGL_SURFACELESS;
} else {
return GST_GL_DISPLAY_TYPE_NONE;
}
@@ -393,9 +395,14 @@ gst_gl_display_new_with_type (GstGLDisplayType type)
if (!display && (type & GST_GL_DISPLAY_TYPE_EGL)) {
display = GST_GL_DISPLAY (gst_gl_display_egl_new ());
}
+
+ if (!display && (type & GST_GL_DISPLAY_TYPE_EGL_SURFACELESS)) {
+ display = GST_GL_DISPLAY (gst_gl_display_egl_new_surfaceless ());
+ }
#endif
custom_new_types |= GST_GL_DISPLAY_TYPE_EGL_DEVICE;
custom_new_types |= GST_GL_DISPLAY_TYPE_EGL;
+ custom_new_types |= GST_GL_DISPLAY_TYPE_EGL_SURFACELESS;
custom_new_types |= GST_GL_DISPLAY_TYPE_DISPMANX;
custom_new_types |= GST_GL_DISPLAY_TYPE_WINRT;
custom_new_types |= GST_GL_DISPLAY_TYPE_ANDROID;
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.h b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.h
index 0fbefde07f6..2448218d63b 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.h
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstgldisplay.h
@@ -80,6 +80,14 @@ GType gst_gl_display_get_type (void);
*
* Since: 1.20
*/
+/**
+ * GST_GL_DISPLAY_TYPE_EGL_SURFACELESS:
+ *
+ * Mesa3D surfaceless display using the EGL_PLATFORM_SURFACELESS_MESA
+ * extension.
+ *
+ * Since: 1.24
+ */
typedef enum
{
GST_GL_DISPLAY_TYPE_NONE = 0,
@@ -95,6 +103,7 @@ typedef enum
GST_GL_DISPLAY_TYPE_EAGL = (1 << 9),
GST_GL_DISPLAY_TYPE_WINRT = (1 << 10),
GST_GL_DISPLAY_TYPE_ANDROID = (1 << 11),
+ GST_GL_DISPLAY_TYPE_EGL_SURFACELESS = (1 << 12),
GST_GL_DISPLAY_TYPE_ANY = G_MAXUINT32
} GstGLDisplayType;
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglwindow.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglwindow.c
index 91c1ae05131..a6f95b17af6 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglwindow.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglwindow.c
@@ -334,6 +334,9 @@ gst_gl_window_new (GstGLDisplay * display)
if (!window && (!user_choice || g_strstr_len (user_choice, 5, "winrt")))
window = GST_GL_WINDOW (gst_gl_window_winrt_egl_new (display));
#endif
+ if (!window && (!user_choice
+ || g_strstr_len (user_choice, 11, "surfaceless")))
+ window = GST_GL_WINDOW (gst_gl_dummy_window_new ());
if (!window) {
/* subclass returned a NULL window */
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build
index ebdab9089ab..b97ec0c049b 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build
@@ -253,6 +253,7 @@ if gl_winsys.contains('auto')
need_win_winrt = 'auto'
need_win_cocoa = 'auto'
need_win_egl = 'auto'
+ need_win_surfaceless = 'auto'
need_win_eagl = 'auto'
need_win_dispmanx = 'auto'
need_win_viv_fb = 'auto'
@@ -265,6 +266,7 @@ else
need_win_winrt = 'no'
need_win_cocoa = 'no'
need_win_egl = 'no'
+ need_win_surfaceless = 'no'
need_win_eagl = 'no'
need_win_dispmanx = 'no'
need_win_viv_fb = 'no'
@@ -283,6 +285,8 @@ else
need_win_cocoa = 'yes'
elif winsys == 'egl'
need_win_egl = 'yes'
+ elif winsys == 'surfaceless'
+ need_win_surfaceless = 'yes'
elif winsys == 'eagl'
need_win_eagl = 'yes'
elif winsys == 'dispmanx'
@@ -578,16 +582,39 @@ if need_platform_egl != 'no'
endif
# winsys_egl checks
-if need_win_egl == 'yes'
+if need_win_egl != 'no'
if need_platform_egl == 'no'
- error('Impossible situation requested: Cannot use Winsys egl without EGL support')
+ if need_win_egl == 'yes'
+ error ('Impossible situation requested: Cannot use Winsys egl without EGL support')
+ endif
elif not egl_dep.found()
- error ('Could not find EGL libraries for Winsys egl')
+ if need_win_egl == 'yes'
+ error ('Could not find EGL libraries for Winsys egl')
+ else
+ message ('Could not find EGL libraries for Winsys egl')
+ endif
else
enabled_gl_winsys += 'egl'
endif
endif
+# winsys_surfaceless checks
+if need_win_surfaceless != 'no'
+ if need_platform_egl == 'no'
+ if need_win_surfaceless == 'yes'
+ error ('Impossible situation requested: Cannot use Winsys surfaceless without EGL support')
+ endif
+ elif not egl_dep.found()
+ if need_win_surfaceless == 'yes'
+ error ('Could not find EGL libraries for Winsys surfaceless')
+ else
+ message ('Could not find EGL libraries for Winsys surfaceless')
+ endif
+ else
+ enabled_gl_winsys += 'surfaceless'
+ endif
+endif
+
# wayland checks
wayland_client_dep = unneeded_dep
wayland_cursor_dep = unneeded_dep
diff --git a/subprojects/gst-plugins-base/meson_options.txt b/subprojects/gst-plugins-base/meson_options.txt
index 2fb13cfafb2..45d0fed0aaa 100644
--- a/subprojects/gst-plugins-base/meson_options.txt
+++ b/subprojects/gst-plugins-base/meson_options.txt
@@ -12,7 +12,7 @@ option('gl_platform', type : 'array',
choices : ['glx', 'egl', 'cgl', 'wgl', 'eagl', 'auto'], value : ['auto'],
description : 'A comma separated list of opengl platforms to enable building against')
option('gl_winsys', type : 'array',
- choices : ['x11', 'wayland', 'win32', 'winrt', 'cocoa', 'dispmanx', 'egl', 'viv-fb', 'gbm', 'android', 'auto'], value : ['auto'],
+ choices : ['x11', 'wayland', 'win32', 'winrt', 'cocoa', 'dispmanx', 'egl', 'surfaceless', 'viv-fb', 'gbm', 'android', 'auto'], value : ['auto'],
description : 'A comma separated list of opengl windows systems to enable building against. Supported values are x11, wayland, win32, winrt, cocoa, dispmanx, egl, viv-fb, gbm, and android')
option('egl_module_name', type : 'string', value : '',
description : 'The file to pass to g_module_open to open the libEGL library (default: libEGL)')
diff --git a/subprojects/gstreamer/docs/gst/running.md b/subprojects/gstreamer/docs/gst/running.md
index 08eb86cc1d3..436a7900d33 100644
--- a/subprojects/gstreamer/docs/gst/running.md
+++ b/subprojects/gstreamer/docs/gst/running.md
@@ -315,7 +315,7 @@ the encoding does not look like UTF-8.
**`GST_GL_WINDOW`.**
Influences the window system to use by the GStreamer OpenGL library.
-Common values are 'x11', 'wayland', 'win32' or 'cocoa'.
+Common values are 'x11', 'wayland', 'surfaceless', 'win32' or 'cocoa'.
**`GST_GL_PLATFORM`.**
diff --git a/subprojects/gstreamer/docs/index.md b/subprojects/gstreamer/docs/index.md
index 14b04503508..72bf530bebb 100644
--- a/subprojects/gstreamer/docs/index.md
+++ b/subprojects/gstreamer/docs/index.md
@@ -325,7 +325,7 @@ the encoding does not look like UTF-8.
**GST_GL_WINDOW.**
Influences the window system to use by the GStreamer OpenGL library.
-Common values are 'x11', 'wayland', 'win32' or 'cocoa'.
+Common values are 'x11', 'wayland', 'surfaceless', 'win32' or 'cocoa'.
**GST_GL_PLATFORM.**
--
GitLab
|