[vlc-devel] [PATCH 5/7] egl_pbuffer: add support for surfaceless context
Romain Vimont
rom1v at videolabs.io
Wed Mar 3 17:36:38 UTC 2021
From: Alexandre Janniaux <ajanni at videolabs.io>
If the EGL extension EGL_KHR_surfaceless_context is available, create a
surfaceless context.
Co-authored-by: Romain Vimont <rom1v at videolabs.io>
---
modules/video_filter/egl_pbuffer.c | 37 ++++++++++++++++++++++++------
1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/modules/video_filter/egl_pbuffer.c b/modules/video_filter/egl_pbuffer.c
index 5ede974602..ff4ba946ce 100644
--- a/modules/video_filter/egl_pbuffer.c
+++ b/modules/video_filter/egl_pbuffer.c
@@ -155,7 +155,11 @@ static int InitEGL(vlc_gl_t *gl, unsigned width, unsigned height)
#endif
);
- const EGLint conf_attr[] = {
+ const char *extensions = eglQueryString(sys->display, EGL_EXTENSIONS);
+ bool need_surface =
+ !vlc_gl_StrHasToken(extensions, "EGL_KHR_surfaceless_context");
+
+ const EGLint conf_attr_surface[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
@@ -167,6 +171,19 @@ static int InitEGL(vlc_gl_t *gl, unsigned width, unsigned height)
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_NONE,
};
+
+ const EGLint conf_attr_surfaceless[] = {
+#ifdef USE_OPENGL_ES2
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+#else
+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+#endif
+ EGL_NONE,
+ };
+
+ const EGLint *conf_attr = need_surface ? conf_attr_surface
+ : conf_attr_surfaceless;
+
EGLConfig cfgv[1];
EGLint cfgc;
@@ -184,14 +201,20 @@ static int InitEGL(vlc_gl_t *gl, unsigned width, unsigned height)
goto error;
}
- /* Create a drawing surface */
- sys->surface = eglCreatePbufferSurface(sys->display, cfgv[0], surface_attr);
- if (sys->surface == EGL_NO_SURFACE)
+ if (need_surface)
{
- msg_Err (gl, "cannot create EGL window surface");
- assert(false);
- goto error;
+ /* Create a drawing surface */
+ sys->surface = eglCreatePbufferSurface(sys->display, cfgv[0],
+ surface_attr);
+ if (sys->surface == EGL_NO_SURFACE)
+ {
+ msg_Err (gl, "cannot create EGL window surface");
+ assert(false);
+ goto error;
+ }
}
+ else
+ sys->surface = EGL_NO_SURFACE;
#ifdef USE_OPENGL_ES2
if (eglBindAPI (EGL_OPENGL_ES_API) != EGL_TRUE)
--
2.30.1
More information about the vlc-devel
mailing list