mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
opengl: Fix usage of eglCreate/DestroyImage
The implementation was inconsistent between create and destroy. EGLImage creation and destruction is requires for EGL 1.5 and up, while otherwise the KHR version is only available if EGL_KHR_image_base feature is set. Not doing these check may lead to getting a function pointer to a stub, which is notably the case when using apitrace. Fixes #1389 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3170>
This commit is contained in:
parent
2ae4abcf99
commit
0c28e3cf26
1 changed files with 28 additions and 9 deletions
|
@ -299,10 +299,8 @@ _gst_egl_image_create (GstGLContext * context, guint target,
|
||||||
EGLContext egl_context = EGL_NO_CONTEXT;
|
EGLContext egl_context = EGL_NO_CONTEXT;
|
||||||
EGLImageKHR img = EGL_NO_IMAGE_KHR;
|
EGLImageKHR img = EGL_NO_IMAGE_KHR;
|
||||||
GstGLDisplayEGL *display_egl;
|
GstGLDisplayEGL *display_egl;
|
||||||
gint plat_major, plat_minor;
|
|
||||||
guint attrib_len = 0;
|
guint attrib_len = 0;
|
||||||
|
|
||||||
gst_gl_context_get_gl_platform_version (context, &plat_major, &plat_minor);
|
|
||||||
|
|
||||||
display_egl = gst_gl_display_egl_from_gl_display (context->display);
|
display_egl = gst_gl_display_egl_from_gl_display (context->display);
|
||||||
if (!display_egl) {
|
if (!display_egl) {
|
||||||
|
@ -321,6 +319,9 @@ _gst_egl_image_create (GstGLContext * context, guint target,
|
||||||
while (attribs[attrib_len++] != EGL_NONE) {
|
while (attribs[attrib_len++] != EGL_NONE) {
|
||||||
}
|
}
|
||||||
#ifdef EGL_VERSION_1_5
|
#ifdef EGL_VERSION_1_5
|
||||||
|
gint plat_major, plat_minor;
|
||||||
|
gst_gl_context_get_gl_platform_version (context, &plat_major, &plat_minor);
|
||||||
|
|
||||||
if (GST_GL_CHECK_GL_VERSION (plat_major, plat_minor, 1, 5)) {
|
if (GST_GL_CHECK_GL_VERSION (plat_major, plat_minor, 1, 5)) {
|
||||||
EGLImageKHR (*gst_eglCreateImage) (EGLDisplay dpy, EGLContext ctx,
|
EGLImageKHR (*gst_eglCreateImage) (EGLDisplay dpy, EGLContext ctx,
|
||||||
EGLenum target, EGLClientBuffer buffer, const EGLAttrib * attrib_list);
|
EGLenum target, EGLClientBuffer buffer, const EGLAttrib * attrib_list);
|
||||||
|
@ -347,7 +348,7 @@ _gst_egl_image_create (GstGLContext * context, guint target,
|
||||||
g_free (egl_attribs);
|
g_free (egl_attribs);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
if (gst_gl_context_check_feature (context, "EGL_KHR_image_base")) {
|
||||||
EGLImageKHR (*gst_eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx,
|
EGLImageKHR (*gst_eglCreateImageKHR) (EGLDisplay dpy, EGLContext ctx,
|
||||||
EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
|
EGLenum target, EGLClientBuffer buffer, const EGLint * attrib_list);
|
||||||
EGLint *egl_attribs = NULL;
|
EGLint *egl_attribs = NULL;
|
||||||
|
@ -356,8 +357,8 @@ _gst_egl_image_create (GstGLContext * context, guint target,
|
||||||
gst_eglCreateImageKHR = gst_gl_context_get_proc_address (context,
|
gst_eglCreateImageKHR = gst_gl_context_get_proc_address (context,
|
||||||
"eglCreateImageKHR");
|
"eglCreateImageKHR");
|
||||||
if (!gst_eglCreateImageKHR) {
|
if (!gst_eglCreateImageKHR) {
|
||||||
GST_WARNING_OBJECT (context, "\"eglCreateImageKHR\" not exposed by the "
|
GST_ERROR_OBJECT (context, "\"eglCreateImageKHR\" not exposed by the "
|
||||||
"implementation");
|
"implementation as required by EGL_KHR_image_base");
|
||||||
return EGL_NO_IMAGE_KHR;
|
return EGL_NO_IMAGE_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,6 +372,9 @@ _gst_egl_image_create (GstGLContext * context, guint target,
|
||||||
egl_attribs);
|
egl_attribs);
|
||||||
|
|
||||||
g_free (egl_attribs);
|
g_free (egl_attribs);
|
||||||
|
} else {
|
||||||
|
GST_INFO_OBJECT (context, "EGLImage creation not supported");
|
||||||
|
return EGL_NO_IMAGE_KHR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
|
@ -383,16 +387,31 @@ _gst_egl_image_destroy (GstGLContext * context, EGLImageKHR image)
|
||||||
EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
|
EGLDisplay egl_display = EGL_DEFAULT_DISPLAY;
|
||||||
GstGLDisplayEGL *display_egl;
|
GstGLDisplayEGL *display_egl;
|
||||||
|
|
||||||
gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
|
#ifdef EGL_VERSION_1_5
|
||||||
"eglDestroyImage");
|
gint plat_major, plat_minor;
|
||||||
if (!gst_eglDestroyImage) {
|
gst_gl_context_get_gl_platform_version (context, &plat_major, &plat_minor);
|
||||||
|
|
||||||
|
if (GST_GL_CHECK_GL_VERSION (plat_major, plat_minor, 1, 5)) {
|
||||||
|
gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
|
||||||
|
"eglDestroyImage");
|
||||||
|
if (!gst_eglDestroyImage) {
|
||||||
|
GST_ERROR_OBJECT (context, "\"eglDestroyImage\" not exposed by the "
|
||||||
|
"implementation as required by EGL >= 1.5");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
if (gst_gl_context_check_feature (context, "EGL_KHR_image_base")) {
|
||||||
gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
|
gst_eglDestroyImage = gst_gl_context_get_proc_address (context,
|
||||||
"eglDestroyImageKHR");
|
"eglDestroyImageKHR");
|
||||||
if (!gst_eglDestroyImage) {
|
if (!gst_eglDestroyImage) {
|
||||||
GST_ERROR_OBJECT (context, "\"eglDestroyImage\" not exposed by the "
|
GST_ERROR_OBJECT (context, "\"eglDestroyImage\" not exposed by the "
|
||||||
"implementation");
|
"implementation as required by EGL_KHR_image_base");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
GST_ERROR_OBJECT (context, "Destruction of EGLImage not supported.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
display_egl = gst_gl_display_egl_from_gl_display (context->display);
|
display_egl = gst_gl_display_egl_from_gl_display (context->display);
|
||||||
|
|
Loading…
Reference in a new issue