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
|
From 414512d922d11a1955a1b84755723647b91960c3 Mon Sep 17 00:00:00 2001
From: Robert Mader <robert.mader@collabora.com>
Date: Thu, 19 Oct 2023 00:55:58 +0200
Subject: [PATCH] glcontext/egl: Prefer GLES2 over GL/GL3 by default
From a multimedia perspective GLES >= 2 has the big advantage of
supporting external textures (`OES_EGL_image_external` /
`OES_EGL_image_external_essl3`), allowing various YUV formats to be
imported directly by drivers.
It appears unlikely by now that the extension will ever be ported to
GL with Vulkan becoming more popular, leaving GL without an "official"
way to import YUV formats.
Further more, for Gst internal purposes it's likely that GLES2 works
equally well if not better on most drivers these days, especially on
embedded devices.
Thus switch the default for EGL context creation to GLES2. This won't
affect apps that create their own context, but `gst-launch-1.0` etc.,
which are often used for testing so people don't have to pass
`GST_GL_API=gles2`.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5509>
---
.../gst-libs/gst/gl/egl/gstglcontext_egl.c | 98 +++++++++----------
1 file changed, 49 insertions(+), 49 deletions(-)
diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstglcontext_egl.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstglcontext_egl.c
index c01bd46cfa7..a919014cca8 100644
--- a/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstglcontext_egl.c
+++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/egl/gstglcontext_egl.c
@@ -925,7 +925,55 @@ gst_gl_context_egl_create_context (GstGLContext * context,
gst_gl_context_egl_dump_all_configs (egl);
- if (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) {
+ if (gl_api & GST_GL_API_GLES2) {
+ gint i;
+
+ try_gles2:
+ if (!eglBindAPI (EGL_OPENGL_ES_API)) {
+ g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
+ "Failed to bind OpenGL|ES API: %s",
+ gst_egl_get_error_string (eglGetError ()));
+ goto failure;
+ }
+
+ GST_INFO ("Bound OpenGL|ES");
+
+ for (i = 0; i < G_N_ELEMENTS (gles2_versions); i++) {
+ gint profileMask = 0;
+ gint contextFlags = 0;
+ guint maj = gles2_versions[i].major;
+ guint min = gles2_versions[i].minor;
+
+ if (!gst_gl_context_egl_choose_config (egl, GST_GL_API_GLES2, maj, error)) {
+ GST_DEBUG_OBJECT (context, "Failed to choose a GLES%d config: %s",
+ maj, error && *error ? (*error)->message : "Unknown");
+ g_clear_error (error);
+ continue;
+ }
+#if defined(EGL_KHR_create_context)
+ /* try a debug context */
+ contextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+
+ egl->egl_context =
+ _create_context_with_flags (egl, (EGLContext) external_gl_context,
+ GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
+
+ if (egl->egl_context)
+ break;
+
+ /* try without a debug context */
+ contextFlags &= ~EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+#endif
+
+ egl->egl_context =
+ _create_context_with_flags (egl, (EGLContext) external_gl_context,
+ GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
+
+ if (egl->egl_context)
+ break;
+ }
+ egl->gl_api = GST_GL_API_GLES2;
+ } else if (gl_api & (GST_GL_API_OPENGL | GST_GL_API_OPENGL3)) {
GstGLAPI chosen_gl_api = 0;
gint i;
@@ -1015,54 +1063,6 @@ gst_gl_context_egl_create_context (GstGLContext * context,
}
egl->gl_api = chosen_gl_api;
- } else if (gl_api & GST_GL_API_GLES2) {
- gint i;
-
- try_gles2:
- if (!eglBindAPI (EGL_OPENGL_ES_API)) {
- g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
- "Failed to bind OpenGL|ES API: %s",
- gst_egl_get_error_string (eglGetError ()));
- goto failure;
- }
-
- GST_INFO ("Bound OpenGL|ES");
-
- for (i = 0; i < G_N_ELEMENTS (gles2_versions); i++) {
- gint profileMask = 0;
- gint contextFlags = 0;
- guint maj = gles2_versions[i].major;
- guint min = gles2_versions[i].minor;
-
- if (!gst_gl_context_egl_choose_config (egl, GST_GL_API_GLES2, maj, error)) {
- GST_DEBUG_OBJECT (context, "Failed to choose a GLES%d config: %s",
- maj, error && *error ? (*error)->message : "Unknown");
- g_clear_error (error);
- continue;
- }
-#if defined(EGL_KHR_create_context)
- /* try a debug context */
- contextFlags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
-
- /* try without a debug context */
- contextFlags &= ~EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
-#endif
-
- egl->egl_context =
- _create_context_with_flags (egl, (EGLContext) external_gl_context,
- GST_GL_API_GLES2, maj, min, contextFlags, profileMask);
-
- if (egl->egl_context)
- break;
- }
- egl->gl_api = GST_GL_API_GLES2;
}
if (egl->egl_context != EGL_NO_CONTEXT) {
--
GitLab
|