mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 10:41:04 +00:00
[716/906] wayland: properly choose EGL_RENDERABLE_TYPE
based on the gl api we chose
This commit is contained in:
parent
cdbe8c2d0e
commit
f6a9c807f6
2 changed files with 51 additions and 25 deletions
|
@ -363,31 +363,53 @@ error:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_gst_gl_window_wayland_egl_choose_config (GstGLWindowWaylandEGL * window_egl,
|
||||||
|
GError ** error)
|
||||||
|
{
|
||||||
|
EGLint numConfigs;
|
||||||
|
gint i = 0;
|
||||||
|
EGLint config_attrib[20];
|
||||||
|
|
||||||
|
config_attrib[i++] = EGL_SURFACE_TYPE;
|
||||||
|
config_attrib[i++] = EGL_WINDOW_BIT;
|
||||||
|
config_attrib[i++] = EGL_RENDERABLE_TYPE;
|
||||||
|
if (window_egl->gl_api & GST_GL_API_GLES2)
|
||||||
|
config_attrib[i++] = EGL_OPENGL_ES2_BIT;
|
||||||
|
else
|
||||||
|
config_attrib[i++] = EGL_OPENGL_BIT;
|
||||||
|
config_attrib[i++] = EGL_DEPTH_SIZE;
|
||||||
|
config_attrib[i++] = 16;
|
||||||
|
config_attrib[i++] = EGL_NONE;
|
||||||
|
|
||||||
|
if (eglChooseConfig (window_egl->egl_display, config_attrib,
|
||||||
|
&window_egl->egl_config, 1, &numConfigs))
|
||||||
|
GST_INFO ("config set: %ld, %ld", (gulong) window_egl->egl_config,
|
||||||
|
(gulong) numConfigs);
|
||||||
|
else {
|
||||||
|
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_WRONG_CONFIG,
|
||||||
|
"Failed to set window configuration: %s", WlEGLErrorString ());
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
failure:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_gl_window_wayland_egl_create_context (GstGLWindow * window,
|
gst_gl_window_wayland_egl_create_context (GstGLWindow * window,
|
||||||
GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
|
GstGLAPI gl_api, guintptr external_gl_context, GError ** error)
|
||||||
{
|
{
|
||||||
GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window);
|
||||||
|
|
||||||
EGLint config_attrib[] = {
|
EGLint context_attrib[3];
|
||||||
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
gint i = 0;
|
||||||
EGL_RED_SIZE, 1,
|
|
||||||
EGL_GREEN_SIZE, 1,
|
|
||||||
EGL_BLUE_SIZE, 1,
|
|
||||||
EGL_ALPHA_SIZE, 1,
|
|
||||||
EGL_DEPTH_SIZE, 1,
|
|
||||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
EGLint context_attrib[] = {
|
|
||||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
|
|
||||||
EGLint majorVersion;
|
EGLint majorVersion;
|
||||||
EGLint minorVersion;
|
EGLint minorVersion;
|
||||||
EGLint numConfigs;
|
|
||||||
|
|
||||||
if (!_setup_wayland (window_egl, error))
|
if (!_setup_wayland (window_egl, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -445,18 +467,19 @@ gst_gl_window_wayland_egl_create_context (GstGLWindow * window,
|
||||||
window_egl->gl_api = GST_GL_API_GLES2;
|
window_egl->gl_api = GST_GL_API_GLES2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eglChooseConfig (window_egl->egl_display, config_attrib,
|
if (!_gst_gl_window_wayland_egl_choose_config (window_egl, error)) {
|
||||||
&window_egl->egl_config, 1, &numConfigs))
|
g_assert (error == NULL || *error != NULL);
|
||||||
GST_DEBUG ("config set: %ld, %ld", (gulong) window_egl->egl_config,
|
|
||||||
(gulong) numConfigs);
|
|
||||||
else {
|
|
||||||
g_set_error (error, GST_GL_WINDOW_ERROR, GST_GL_WINDOW_ERROR_WRONG_CONFIG,
|
|
||||||
"Failed to set window configuration: %s", WlEGLErrorString ());
|
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG ("about to create gl context");
|
GST_DEBUG ("about to create gl context");
|
||||||
|
|
||||||
|
if (window_egl->gl_api & GST_GL_API_GLES2) {
|
||||||
|
context_attrib[i++] = EGL_CONTEXT_CLIENT_VERSION;
|
||||||
|
context_attrib[i++] = 2;
|
||||||
|
}
|
||||||
|
context_attrib[i++] = EGL_NONE;
|
||||||
|
|
||||||
window_egl->egl_context =
|
window_egl->egl_context =
|
||||||
eglCreateContext (window_egl->egl_display, window_egl->egl_config,
|
eglCreateContext (window_egl->egl_display, window_egl->egl_config,
|
||||||
(EGLContext) external_gl_context, context_attrib);
|
(EGLContext) external_gl_context, context_attrib);
|
||||||
|
|
|
@ -108,7 +108,7 @@ gst_gl_window_x11_egl_choose_format (GstGLWindowX11 * window_x11,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_gl_window_x11_egl_choose_config (GstGLWindowX11EGL * window_egl,
|
_gst_gl_window_x11_egl_choose_config (GstGLWindowX11EGL * window_egl,
|
||||||
GError ** error)
|
GError ** error)
|
||||||
{
|
{
|
||||||
EGLint numConfigs;
|
EGLint numConfigs;
|
||||||
|
@ -215,7 +215,10 @@ gst_gl_window_x11_egl_create_context (GstGLWindowX11 * window_x11,
|
||||||
window_egl->gl_api = GST_GL_API_GLES2;
|
window_egl->gl_api = GST_GL_API_GLES2;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_gl_window_x11_egl_choose_config (window_egl, error);
|
if (!_gst_gl_window_x11_egl_choose_config (window_egl, error)) {
|
||||||
|
g_assert (error == NULL || *error != NULL);
|
||||||
|
goto failure;
|
||||||
|
}
|
||||||
|
|
||||||
window_egl->egl_surface =
|
window_egl->egl_surface =
|
||||||
eglCreateWindowSurface (window_egl->egl_display, window_egl->egl_config,
|
eglCreateWindowSurface (window_egl->egl_display, window_egl->egl_config,
|
||||||
|
|
Loading…
Reference in a new issue